@oliasoft-open-source/react-ui-library 5.9.0-beta-1 → 5.9.1-beta-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.
package/dist/index.d.ts CHANGED
@@ -1229,6 +1229,13 @@ declare interface IReorderData {
1229
1229
  export declare interface IRichTextInputProps {
1230
1230
  disabled?: boolean;
1231
1231
  onChange?: (markdown: string) => void;
1232
+ options?: {
1233
+ disableBold?: boolean;
1234
+ disableItalic?: boolean;
1235
+ disableCode?: boolean;
1236
+ disableBulletList?: boolean;
1237
+ disableOrderedList?: boolean;
1238
+ };
1232
1239
  placeholder?: string;
1233
1240
  value?: string;
1234
1241
  toolbarComponent?: ReactNode;
package/dist/index.js CHANGED
@@ -24,7 +24,7 @@ import { SimplifyAP } from "simplify-ts";
24
24
  import Papa from "papaparse";
25
25
  import { Slide, ToastContainer as Toaster, toast as toast$1 } from "react-toastify";
26
26
  import { isNullOrUndefined } from "remirror";
27
- import { BoldExtension, BulletListExtension, CodeExtension, ItalicExtension, MarkdownExtension, OrderedListExtension, PlaceholderExtension } from "remirror/extensions";
27
+ import { BoldExtension, BulletListExtension, CodeExtension, ItalicExtension, ListItemExtension, MarkdownExtension, OrderedListExtension, PlaceholderExtension } from "remirror/extensions";
28
28
  import { EditorComponent, Remirror, useActive, useCommands, useRemirror } from "@remirror/react";
29
29
  import "remirror/styles/all.css";
30
30
  import { DndProvider } from "react-dnd";
@@ -5795,50 +5795,50 @@ var rich_text_toolbar_module_default = {
5795
5795
  let RichTextIcon = /* @__PURE__ */ function(e) {
5796
5796
  return e.BOLD = "bold", e.ITALIC = "italic", e.CODE = "code", e.UL = "ul", e.OL = "ol", e;
5797
5797
  }({});
5798
- const RichTextToolbar = ({ disabled: e = !1, toolbarComponent: t = null }) => {
5799
- let { focus: n, toggleBold: r, toggleBulletList: i, toggleCode: a, toggleItalic: o, toggleOrderedList: s } = useCommands(), c = useActive(), l = [
5800
- {
5798
+ const RichTextToolbar = ({ disabled: e = !1, toolbarComponent: t = null, options: n = {} }) => {
5799
+ let { focus: r, toggleBold: i, toggleBulletList: a, toggleCode: o, toggleItalic: s, toggleOrderedList: c } = useCommands(), l = useActive(), { disableBold: u, disableItalic: d, disableCode: f, disableBulletList: p, disableOrderedList: m } = n, h = [
5800
+ !u && {
5801
5801
  icon: RichTextIcon.BOLD,
5802
- onClick: r,
5803
- active: c.bold()
5802
+ onClick: i,
5803
+ active: l.bold()
5804
5804
  },
5805
- {
5805
+ !d && {
5806
5806
  icon: RichTextIcon.ITALIC,
5807
- onClick: o,
5808
- active: c.italic()
5807
+ onClick: s,
5808
+ active: l.italic()
5809
5809
  },
5810
- {
5810
+ !f && {
5811
5811
  icon: RichTextIcon.CODE,
5812
- onClick: a,
5813
- active: c.code()
5812
+ onClick: o,
5813
+ active: l.code()
5814
5814
  },
5815
- {
5815
+ !p && {
5816
5816
  icon: RichTextIcon.UL,
5817
- onClick: i,
5818
- active: c.bulletList()
5817
+ onClick: a,
5818
+ active: l.bulletList()
5819
5819
  },
5820
- {
5820
+ !m && {
5821
5821
  icon: RichTextIcon.OL,
5822
- onClick: s,
5823
- active: c.orderedList()
5822
+ onClick: c,
5823
+ active: l.orderedList()
5824
5824
  }
5825
- ];
5825
+ ].filter((e) => !!e);
5826
5826
  return /* @__PURE__ */ jsxs("div", {
5827
5827
  className: rich_text_toolbar_module_default.richTextToolbarContainer,
5828
5828
  children: [/* @__PURE__ */ jsx("div", {
5829
5829
  className: rich_text_toolbar_module_default.richTextToolbar,
5830
- children: l.map((t, r) => /* @__PURE__ */ jsx(Button, {
5830
+ children: h.map((t, n) => /* @__PURE__ */ jsx(Button, {
5831
5831
  small: !0,
5832
5832
  round: !0,
5833
5833
  basic: !0,
5834
5834
  icon: t.icon,
5835
5835
  colored: Color.MUTED,
5836
5836
  onClick: () => {
5837
- t.onClick(), n();
5837
+ t.onClick(), r();
5838
5838
  },
5839
5839
  active: t.active,
5840
5840
  disabled: e
5841
- }, r))
5841
+ }, n))
5842
5842
  }), t]
5843
5843
  });
5844
5844
  };
@@ -5852,35 +5852,37 @@ var rich_text_input_module_default = {
5852
5852
  hideScrollbars: "_hideScrollbars_1fb4l_67",
5853
5853
  richTextInput: "_richTextInput_1fb4l_77"
5854
5854
  };
5855
- const RichTextInput = forwardRef(({ placeholder: e, onChange: t, value: n, disabled: r, toolbarComponent: i }, a) => {
5856
- let o = useContext(DisabledContext), c = r || o, { manager: u, state: d, setState: f, getContext: p } = useRemirror({
5855
+ const RichTextInput = forwardRef(({ placeholder: e, onChange: t, value: n, disabled: r, toolbarComponent: i, options: a = {} }, o) => {
5856
+ let c = useContext(DisabledContext), u = r || c, { disableBold: d, disableItalic: f, disableCode: p, disableBulletList: m, disableOrderedList: h } = a, { manager: g, state: _, setState: v, getContext: y } = useRemirror({
5857
5857
  extensions: () => [
5858
- new BoldExtension({}),
5859
- new BulletListExtension({}),
5860
- new CodeExtension(),
5861
- new ItalicExtension(),
5858
+ !d && new BoldExtension({}),
5859
+ !m && new BulletListExtension({}),
5860
+ !p && new CodeExtension(),
5861
+ !f && new ItalicExtension(),
5862
5862
  new MarkdownExtension({}),
5863
- new OrderedListExtension(),
5864
- new PlaceholderExtension({ placeholder: e })
5865
- ],
5863
+ !h && new OrderedListExtension(),
5864
+ new PlaceholderExtension({ placeholder: e }),
5865
+ new ListItemExtension({})
5866
+ ].filter((e) => !!e),
5866
5867
  content: n,
5867
5868
  selection: "start",
5868
5869
  stringHandler: "markdown"
5869
5870
  });
5870
- return useImperativeHandle(a, () => p(), [p]), /* @__PURE__ */ jsx("div", {
5871
+ return useImperativeHandle(o, () => y(), [y]), /* @__PURE__ */ jsx("div", {
5871
5872
  className: rich_text_input_module_default.richTextInput,
5872
5873
  children: /* @__PURE__ */ jsxs(Remirror, {
5873
- manager: u,
5874
- state: d,
5874
+ manager: g,
5875
+ state: _,
5875
5876
  placeholder: e,
5876
5877
  onChange: ({ helpers: e, state: n }) => {
5877
5878
  let r = e.getMarkdown(n);
5878
- t && t(r), f(n);
5879
+ t && t(r), v(n);
5879
5880
  },
5880
- editable: !c,
5881
+ editable: !u,
5881
5882
  children: [/* @__PURE__ */ jsx(RichTextToolbar, {
5882
- disabled: c,
5883
- toolbarComponent: i
5883
+ disabled: u,
5884
+ toolbarComponent: i,
5885
+ options: a
5884
5886
  }), /* @__PURE__ */ jsx(EditorComponent, {})]
5885
5887
  })
5886
5888
  });
@@ -6611,7 +6613,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6611
6613
  } : {
6612
6614
  value: G,
6613
6615
  unit: U
6614
- }), Nd = k || K?.value === void 0, [J, Pd] = useState(w ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM), Fd = !!(O || n), Y = C && C.find((e) => {
6616
+ }), Pd = k || K?.value === void 0, [J, Fd] = useState(w ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM), Id = !!(O || n), Y = C && C.find((e) => {
6615
6617
  if (!e?.value) return;
6616
6618
  if (E) return E === e.valueKey;
6617
6619
  let t = isValueWithUnit(e.value) ? getUnit(e.value) : "", { value: n = l } = convertUnit({
@@ -6620,7 +6622,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6620
6622
  toUnit: t
6621
6623
  });
6622
6624
  return withUnit(n, t) === e.value;
6623
- }), Id = () => {
6625
+ }), Ld = () => {
6624
6626
  let e = l ?? "", t = K.unit;
6625
6627
  if (checkConversion({
6626
6628
  value: e,
@@ -6634,7 +6636,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6634
6636
  return null;
6635
6637
  }
6636
6638
  } else return getAltUnitsListByQuantity(u)?.map((e) => ["", e?.unit]);
6637
- }, Ld = (t) => {
6639
+ }, Rd = (t) => {
6638
6640
  let n = getStringName(e), r = t.target, { value: i, selectionStart: a } = r, o = withUnit(i, K?.unit || ""), s = A ? withUnit(convertAndGetValue(o, B), B) : o;
6639
6641
  h({ target: {
6640
6642
  value: s,
@@ -6647,7 +6649,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6647
6649
  }), R(() => {
6648
6650
  r.selectionStart = a, r.selectionEnd = a;
6649
6651
  });
6650
- }, Rd = (e, t) => {
6652
+ }, zd = (e, t) => {
6651
6653
  t === K.unit || isNaN(Number(e)) || (q({
6652
6654
  value: e,
6653
6655
  unit: t
@@ -6678,7 +6680,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6678
6680
  e !== void 0 && q({
6679
6681
  value: e,
6680
6682
  unit: t
6681
- }), C && Pd(Y && T ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM);
6683
+ }), C && Fd(Y && T ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM);
6682
6684
  }
6683
6685
  }, [
6684
6686
  U,
@@ -6686,7 +6688,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6686
6688
  i,
6687
6689
  T
6688
6690
  ]);
6689
- let X = Id(), Z = label(K.unit) || K.unit || "", zd = p || !X || X && X.length === 1, Q = getStringName(e), $, Bd = (t) => {
6691
+ let X = Ld(), Z = label(K.unit) || K.unit || "", Bd = p || !X || X && X.length === 1, Q = getStringName(e), $, Vd = (t) => {
6690
6692
  let r = t?.value ? t.value : "", [i = "", a = ""] = isValueWithUnit(r) ? split(r) : [r], o = withPrettyUnitLabel(r);
6691
6693
  if (checkConversion({
6692
6694
  value: r,
@@ -6706,7 +6708,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6706
6708
  type: MenuType.OPTION,
6707
6709
  inline: !0,
6708
6710
  onClick: () => {
6709
- validateNumber(i).valid && !n && (Pd(PredefinedOptionsMenuState.PREDEFINED), h({ target: {
6711
+ validateNumber(i).valid && !n && (Fd(PredefinedOptionsMenuState.PREDEFINED), h({ target: {
6710
6712
  value: r,
6711
6713
  name: typeof e == "string" ? e : e?.fieldName || "",
6712
6714
  predefinedSelected: !0,
@@ -6733,10 +6735,10 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6733
6735
  label: "Custom",
6734
6736
  selected: J === PredefinedOptionsMenuState.CUSTOM
6735
6737
  }], C?.length) {
6736
- let e = C.map(Bd);
6738
+ let e = C.map(Vd);
6737
6739
  $ = [...$, ...e];
6738
6740
  }
6739
- let Vd = (e) => {
6741
+ let Hd = (e) => {
6740
6742
  if (isValueWithUnit(e)) {
6741
6743
  let t = getUnit(e), { value: n } = safeConvertValue({
6742
6744
  value: e,
@@ -6748,7 +6750,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6748
6750
  return n;
6749
6751
  }
6750
6752
  return e;
6751
- }, Hd = !C && (!F || F === GroupOrder.FIRST) ? GroupOrder.FIRST : GroupOrder.MIDDLE, Ud = !F || F === GroupOrder.LAST ? GroupOrder.LAST : GroupOrder.MIDDLE;
6753
+ }, Ud = !C && (!F || F === GroupOrder.FIRST) ? GroupOrder.FIRST : GroupOrder.MIDDLE, Wd = !F || F === GroupOrder.LAST ? GroupOrder.LAST : GroupOrder.MIDDLE;
6752
6754
  return /* @__PURE__ */ jsx("div", {
6753
6755
  className: J === PredefinedOptionsMenuState.PREDEFINED ? cx(unit_input_module_default.predefinedMenuActive) : "",
6754
6756
  children: /* @__PURE__ */ jsxs(InputGroup, {
@@ -6780,31 +6782,31 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6780
6782
  name: Q,
6781
6783
  testId: x,
6782
6784
  disabled: n,
6783
- placeholder: Vd(t),
6785
+ placeholder: Hd(t),
6784
6786
  value: K.value,
6785
- onChange: Ld,
6787
+ onChange: Rd,
6786
6788
  onFocus: v,
6787
6789
  error: i === null ? void 0 : i,
6788
6790
  warning: S === null ? void 0 : S,
6789
6791
  left: a,
6790
- allowEmpty: Nd,
6792
+ allowEmpty: Pd,
6791
6793
  validationCallback: (e, t) => D(Q, t),
6792
6794
  enableCosmeticRounding: j,
6793
6795
  enableDisplayRounding: M,
6794
6796
  roundDisplayValue: N,
6795
- groupOrder: Hd,
6796
- disableInternalErrorValidationMessages: Fd,
6797
+ groupOrder: Ud,
6798
+ disableInternalErrorValidationMessages: Id,
6797
6799
  small: o,
6798
6800
  selectOnFocus: P,
6799
6801
  tooltip: I
6800
6802
  }, Q)
6801
6803
  }),
6802
- Z && (zd || !H ? /* @__PURE__ */ jsx(InputGroupAddon, {
6803
- groupOrder: Ud,
6804
+ Z && (Bd || !H ? /* @__PURE__ */ jsx(InputGroupAddon, {
6805
+ groupOrder: Wd,
6804
6806
  small: o,
6805
6807
  children: Z
6806
6808
  }) : /* @__PURE__ */ jsx(Menu, {
6807
- groupOrder: Ud,
6809
+ groupOrder: Wd,
6808
6810
  maxHeight: 380,
6809
6811
  disabled: r,
6810
6812
  testId: x && `${x}-menu`,
@@ -6820,7 +6822,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6820
6822
  label: j ? safeRoundNumbers(i) : i,
6821
6823
  inline: !0,
6822
6824
  onClick: (n) => {
6823
- n.stopPropagation(), Rd(e, t);
6825
+ n.stopPropagation(), zd(e, t);
6824
6826
  },
6825
6827
  description: r,
6826
6828
  selected: r === Z,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oliasoft-open-source/react-ui-library",
3
- "version": "5.9.0-beta-1",
3
+ "version": "5.9.1-beta-1",
4
4
  "description": "Reusable UI components for React projects",
5
5
  "homepage": "https://oliasoft-open-source.gitlab.io/react-ui-library",
6
6
  "bugs": {