@arkyn/components 3.0.1-beta.196 → 3.0.1-beta.198

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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/richText/index.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAEX,aAAa,EACb,MAAM,2BAA2B,CAAC;AAQnC,OAAO,cAAc,CAAC;AAEtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,iBAAS,QAAQ,CAAC,KAAK,EAAE,aAAa,+BAyMrC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/richText/index.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAEX,aAAa,EACb,MAAM,2BAA2B,CAAC;AAQnC,OAAO,cAAc,CAAC;AAEtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,iBAAS,QAAQ,CAAC,KAAK,EAAE,aAAa,+BAuMrC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -3700,19 +3700,17 @@ function Ir({ children: e }) {
3700
3700
  //#endregion
3701
3701
  //#region src/components/richText/index.tsx
3702
3702
  function Lr(e) {
3703
- let { name: t, hiddenButtons: n, imageConfig: r, videoConfig: a, className: o = "", defaultValue: d = "[]", enforceCharacterLimit: f = !1, onChangeCharactersCount: h, baseErrorMessage: x, maxLimit: S = 1e4, onChange: C, isError: w, label: T, showAsterisk: D, id: O, orientation: k = "vertical", unShowFieldTemplate: A = !1 } = e, j = c(() => me(ve(pe())), []), { fieldErrors: P } = Z();
3704
- function F() {
3703
+ let { name: t, hiddenButtons: n, imageConfig: r, videoConfig: a, className: o = "", defaultValue: d = "[]", enforceCharacterLimit: f = !1, onChangeCharactersCount: h, baseErrorMessage: x, maxLimit: S = 1e4, onChange: C, isError: w, label: T, showAsterisk: D, id: O, orientation: k = "vertical", unShowFieldTemplate: A = !1 } = e, j = c(() => me(ve(pe())), []), { fieldErrors: P } = Z(), F = c(() => {
3705
3704
  try {
3706
3705
  let e = JSON.parse(d);
3707
- return !Array.isArray(e) || e.length <= 0 ? br : e.every((e) => typeof e == "object" && !!e && "type" in e && "children" in e) ? e : br;
3706
+ return !Array.isArray(e) || e.length === 0 ? structuredClone(br) : e.every((e) => typeof e == "object" && !!e && "type" in e && "children" in e) ? e : structuredClone(br);
3708
3707
  } catch {
3709
- return br;
3708
+ return structuredClone(br);
3710
3709
  }
3711
- }
3712
- let [L, R] = u(gr(F()).length), [z, B] = u(JSON.stringify(F()) || "[]"), [H, U] = u(!1), G = l(null), K = s(), q = O || K, ee = x || P?.[t], J = w || !!ee, te = i(Pr, []), ne = i(Er, []);
3710
+ }, [d]), [L, R] = u(gr(F).length), [z, B] = u(JSON.stringify(F) || "[]"), [H, U] = u(!1), G = l(null), K = s(), q = O || K, ee = x || P?.[t], J = w || !!ee, te = i(Pr, []), ne = i(Er, []);
3713
3711
  function re(e) {
3714
3712
  let t = gr(e);
3715
- R(t.length), h?.(t.length), !(f && t.length >= S) && (B(JSON.stringify(e)), C?.(e), j.children = e, fe.setNodes(j, { children: e }));
3713
+ R(t.length), h?.(t.length), !(f && t.length >= S) && (B(JSON.stringify(e)), C?.(e));
3716
3714
  }
3717
3715
  let Y = `arkynRichText ${J || S < L ? "errorTrue" : "errorFalse"} ${H ? "focusTrue" : "focusFalse"}`, ie = S - L;
3718
3716
  function X(e) {
@@ -3728,7 +3726,7 @@ function Lr(e) {
3728
3726
  orientation: k,
3729
3727
  children: /* @__PURE__ */ m(ge, {
3730
3728
  editor: j,
3731
- initialValue: F(),
3729
+ initialValue: F,
3732
3730
  onChange: re,
3733
3731
  onValueChange: re,
3734
3732
  children: [
@@ -5,140 +5,138 @@ import { toggleMark as r } from "../../services/toggleMark.js";
5
5
  import { hotKeys as i, initialValue as a } from "../../templates/richTextTemplates.js";
6
6
  import { BlockButton as o } from "./blockButton/index.js";
7
7
  import { Element as s } from "./element/index.js";
8
- import { InsertImage as ee } from "./insertImage/index.js";
9
- import { InsertVideo as te } from "./insertVideo/index.js";
10
- import { Leaf as ne } from "./leaf/index.js";
11
- import { MarkButton as c } from "./markButton/index.js";
12
- import { Toolbar as l } from "./toolbar/index.js";
8
+ import { InsertImage as c } from "./insertImage/index.js";
9
+ import { InsertVideo as l } from "./insertVideo/index.js";
10
+ import { Leaf as u } from "./leaf/index.js";
11
+ import { MarkButton as d } from "./markButton/index.js";
12
+ import { Toolbar as ee } from "./toolbar/index.js";
13
13
  /* empty css */
14
- import { useCallback as u, useId as re, useMemo as ie, useRef as ae, useState as d } from "react";
15
- import { jsx as f, jsxs as p } from "react/jsx-runtime";
16
- import { AlignCenter as oe, AlignJustify as se, AlignLeft as ce, AlignRight as le, Bold as m, Code as h, Heading1 as g, Heading2 as _, Italic as v, Quote as y, Underline as b } from "lucide-react";
17
- import x from "is-hotkey";
18
- import { Transforms as S, createEditor as C } from "slate";
19
- import { withHistory as w } from "slate-history";
20
- import { Editable as T, Slate as E, withReact as D } from "slate-react";
14
+ import { useCallback as f, useId as te, useMemo as p, useRef as m, useState as h } from "react";
15
+ import { jsx as g, jsxs as _ } from "react/jsx-runtime";
16
+ import { AlignCenter as ne, AlignJustify as re, AlignLeft as ie, AlignRight as ae, Bold as oe, Code as se, Heading1 as v, Heading2 as y, Italic as b, Quote as x, Underline as S } from "lucide-react";
17
+ import C from "is-hotkey";
18
+ import { createEditor as w } from "slate";
19
+ import { withHistory as T } from "slate-history";
20
+ import { Editable as E, Slate as D, withReact as O } from "slate-react";
21
21
  //#region src/components/richText/index.tsx
22
- function O(O) {
23
- let { name: k, hiddenButtons: A, imageConfig: j, videoConfig: M, className: N = "", defaultValue: P = "[]", enforceCharacterLimit: F = !1, onChangeCharactersCount: I, baseErrorMessage: L, maxLimit: R = 1e4, onChange: z, isError: B, label: V, showAsterisk: H, id: U, orientation: W = "vertical", unShowFieldTemplate: ue = !1 } = O, G = ie(() => w(D(C())), []), { fieldErrors: de } = e();
24
- function K() {
22
+ function k(k) {
23
+ let { name: A, hiddenButtons: j, imageConfig: M, videoConfig: N, className: P = "", defaultValue: F = "[]", enforceCharacterLimit: I = !1, onChangeCharactersCount: L, baseErrorMessage: R, maxLimit: z = 1e4, onChange: B, isError: V, label: ce, showAsterisk: H, id: U, orientation: W = "vertical", unShowFieldTemplate: G = !1 } = k, K = p(() => T(O(w())), []), { fieldErrors: le } = e(), q = p(() => {
25
24
  try {
26
- let e = JSON.parse(P);
27
- return !Array.isArray(e) || e.length <= 0 ? a : e.every((e) => typeof e == "object" && !!e && "type" in e && "children" in e) ? e : a;
25
+ let e = JSON.parse(F);
26
+ return !Array.isArray(e) || e.length === 0 ? structuredClone(a) : e.every((e) => typeof e == "object" && !!e && "type" in e && "children" in e) ? e : structuredClone(a);
28
27
  } catch {
29
- return a;
28
+ return structuredClone(a);
30
29
  }
31
- }
32
- let [q, fe] = d(n(K()).length), [pe, me] = d(JSON.stringify(K()) || "[]"), [he, J] = d(!1), ge = ae(null), _e = re(), Y = U || _e, X = L || de?.[k], ve = B || !!X, ye = u(ne, []), be = u(s, []);
30
+ }, [F]), [J, ue] = h(n(q).length), [de, fe] = h(JSON.stringify(q) || "[]"), [pe, Y] = h(!1), me = m(null), he = te(), ge = U || he, X = R || le?.[A], _e = V || !!X, ve = f(u, []), ye = f(s, []);
33
31
  function Z(e) {
34
32
  let t = n(e);
35
- fe(t.length), I?.(t.length), !(F && t.length >= R) && (me(JSON.stringify(e)), z?.(e), G.children = e, S.setNodes(G, { children: e }));
33
+ ue(t.length), L?.(t.length), !(I && t.length >= z) && (fe(JSON.stringify(e)), B?.(e));
36
34
  }
37
- let xe = `arkynRichText ${ve || R < q ? "errorTrue" : "errorFalse"} ${he ? "focusTrue" : "focusFalse"}`, Q = R - q;
35
+ let be = `arkynRichText ${_e || z < J ? "errorTrue" : "errorFalse"} ${pe ? "focusTrue" : "focusFalse"}`, Q = z - J;
38
36
  function $(e) {
39
- return !A?.includes(e);
37
+ return !j?.includes(e);
40
38
  }
41
- return /* @__PURE__ */ f(t, {
42
- name: k,
43
- label: V,
39
+ return /* @__PURE__ */ g(t, {
40
+ name: A,
41
+ label: ce,
44
42
  showAsterisk: H,
45
- className: N,
43
+ className: P,
46
44
  errorMessage: X,
47
- unShowFieldTemplate: ue,
45
+ unShowFieldTemplate: G,
48
46
  orientation: W,
49
- children: /* @__PURE__ */ p(E, {
50
- editor: G,
51
- initialValue: K(),
47
+ children: /* @__PURE__ */ _(D, {
48
+ editor: K,
49
+ initialValue: q,
52
50
  onChange: Z,
53
51
  onValueChange: Z,
54
52
  children: [
55
- /* @__PURE__ */ p("div", {
56
- className: xe,
53
+ /* @__PURE__ */ _("div", {
54
+ className: be,
57
55
  children: [
58
- /* @__PURE__ */ p(l, { children: [
59
- $("headingOne") && /* @__PURE__ */ f(o, {
56
+ /* @__PURE__ */ _(ee, { children: [
57
+ $("headingOne") && /* @__PURE__ */ g(o, {
60
58
  format: "headingOne",
61
- icon: g
59
+ icon: v
62
60
  }),
63
- $("headingTwo") && /* @__PURE__ */ f(o, {
61
+ $("headingTwo") && /* @__PURE__ */ g(o, {
64
62
  format: "headingTwo",
65
- icon: _
63
+ icon: y
66
64
  }),
67
- $("blockQuote") && /* @__PURE__ */ f(o, {
65
+ $("blockQuote") && /* @__PURE__ */ g(o, {
68
66
  format: "blockQuote",
69
- icon: y
67
+ icon: x
70
68
  }),
71
- $("bold") && /* @__PURE__ */ f(c, {
69
+ $("bold") && /* @__PURE__ */ g(d, {
72
70
  format: "bold",
73
- icon: m
71
+ icon: oe
74
72
  }),
75
- $("italic") && /* @__PURE__ */ f(c, {
73
+ $("italic") && /* @__PURE__ */ g(d, {
76
74
  format: "italic",
77
- icon: v
75
+ icon: b
78
76
  }),
79
- $("underline") && /* @__PURE__ */ f(c, {
77
+ $("underline") && /* @__PURE__ */ g(d, {
80
78
  format: "underline",
81
- icon: b
79
+ icon: S
82
80
  }),
83
- $("code") && /* @__PURE__ */ f(c, {
81
+ $("code") && /* @__PURE__ */ g(d, {
84
82
  format: "code",
85
- icon: h
83
+ icon: se
86
84
  }),
87
- $("left") && /* @__PURE__ */ f(o, {
85
+ $("left") && /* @__PURE__ */ g(o, {
88
86
  format: "left",
89
- icon: ce
87
+ icon: ie
90
88
  }),
91
- $("right") && /* @__PURE__ */ f(o, {
89
+ $("right") && /* @__PURE__ */ g(o, {
92
90
  format: "right",
93
- icon: le
91
+ icon: ae
94
92
  }),
95
- $("center") && /* @__PURE__ */ f(o, {
93
+ $("center") && /* @__PURE__ */ g(o, {
96
94
  format: "center",
97
- icon: oe
95
+ icon: ne
98
96
  }),
99
- $("justify") && /* @__PURE__ */ f(o, {
97
+ $("justify") && /* @__PURE__ */ g(o, {
100
98
  format: "justify",
101
- icon: se
99
+ icon: re
102
100
  }),
103
- j && $("image") && /* @__PURE__ */ f(ee, { ...j }),
104
- $("video") && /* @__PURE__ */ f(te, { ...M })
101
+ M && $("image") && /* @__PURE__ */ g(c, { ...M }),
102
+ $("video") && /* @__PURE__ */ g(l, { ...N })
105
103
  ] }),
106
- /* @__PURE__ */ f(T, {
104
+ /* @__PURE__ */ g(E, {
107
105
  className: "editorContainer",
108
- renderElement: be,
109
- renderLeaf: ye,
106
+ renderElement: ye,
107
+ renderLeaf: ve,
110
108
  spellCheck: !0,
111
- ref: ge,
112
- id: Y,
113
- onFocus: () => J(!0),
114
- onBlur: () => J(!1),
109
+ ref: me,
110
+ id: ge,
111
+ onFocus: () => Y(!0),
112
+ onBlur: () => Y(!1),
115
113
  onKeyDown: (e) => {
116
- for (let t in i) if (x(t, e)) {
114
+ for (let t in i) if (C(t, e)) {
117
115
  e.preventDefault();
118
116
  let n = i[t];
119
- r(G, n);
117
+ r(K, n);
120
118
  }
121
119
  }
122
120
  }),
123
- Q < 0 && /* @__PURE__ */ f("div", {
121
+ Q < 0 && /* @__PURE__ */ g("div", {
124
122
  className: "restatesCharacters",
125
123
  children: Q
126
124
  })
127
125
  ]
128
126
  }),
129
- /* @__PURE__ */ f("input", {
127
+ /* @__PURE__ */ g("input", {
130
128
  type: "hidden",
131
- name: k,
132
- value: pe.slice(0, R)
129
+ name: A,
130
+ value: de.slice(0, z)
133
131
  }),
134
- /* @__PURE__ */ f("input", {
132
+ /* @__PURE__ */ g("input", {
135
133
  type: "hidden",
136
- name: `${k}Count`,
137
- value: q
134
+ name: `${A}Count`,
135
+ value: J
138
136
  })
139
137
  ]
140
138
  })
141
139
  });
142
140
  }
143
141
  //#endregion
144
- export { O as RichText };
142
+ export { k as RichText };