@majoo-ui/react 1.52.0 → 1.52.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.
@@ -11,6 +11,14 @@ interface ContentEditorProps {
11
11
  * Adjust editor height.
12
12
  */
13
13
  editorHeight?: number;
14
+ /**
15
+ * Customize pre-built option in the toolbar.
16
+ */
17
+ toolbar?: (defaultToolbar: object) => void;
18
+ /**
19
+ * State of the editor content.
20
+ */
21
+ editorState?: string;
14
22
  /**
15
23
  * Change event handler.
16
24
  */
@@ -19,6 +27,10 @@ interface ContentEditorProps {
19
27
  * Callback function to add image upload option.
20
28
  */
21
29
  uploadCallback?: () => void;
30
+ /**
31
+ * Set max length of the content.
32
+ */
33
+ maxLength?: number;
22
34
  }
23
35
  export default function ContentEditor(props: ContentEditorProps): JSX.Element;
24
36
  export {};
package/index.esm.js CHANGED
@@ -40,9 +40,8 @@ import ScrollSpy from 'react-ui-scrollspy';
40
40
  import { useJsApiLoader, GoogleMap, StandaloneSearchBox } from '@react-google-maps/api';
41
41
  import request from 'superagent';
42
42
  import { ResponsiveContainer, LineChart as LineChart$1, XAxis, YAxis, CartesianGrid, Tooltip as Tooltip$2, Line as Line$1 } from 'recharts';
43
- import { EditorState, convertToRaw } from 'draft-js';
43
+ import { EditorState } from 'draft-js';
44
44
  import { Editor } from 'react-draft-wysiwyg';
45
- import draftToHtml from 'draftjs-to-html';
46
45
  import ReactCrop, { centerCrop, makeAspectCrop } from 'react-image-crop';
47
46
  import { useSticky } from 'react-table-sticky';
48
47
 
@@ -29323,7 +29322,7 @@ function CheckboxTable(props) {
29323
29322
  css: {
29324
29323
  marginRight: 12,
29325
29324
  cursor: 'pointer',
29326
- display: ((_a = originalCell === null || originalCell === void 0 ? void 0 : originalCell.detail) === null || _a === void 0 ? void 0 : _a.length) ? 'flex' : 'none'
29325
+ display: ((_a = originalCell === null || originalCell === void 0 ? void 0 : originalCell.detail) === null || _a === void 0 ? void 0 : _a.length) ? 'flex' : 'none !important'
29327
29326
  },
29328
29327
  onClick: () => {
29329
29328
  if (!Object.keys(state.expanded).includes(row.id)) {
@@ -29488,18 +29487,42 @@ const Container = styled('div', {
29488
29487
  }), 1000)
29489
29488
  }
29490
29489
  });
29490
+ const MaxLengthText = styled('p', {
29491
+ fontSize: 12,
29492
+ fontWeight: 400,
29493
+ color: '$textSecondary',
29494
+ textAlign: 'right',
29495
+ padding: '$spacing-03',
29496
+ variants: {
29497
+ warning: {
29498
+ true: {
29499
+ color: '$textRed'
29500
+ }
29501
+ }
29502
+ }
29503
+ });
29491
29504
  function ContentEditor(props) {
29505
+ var _a, _b, _c, _d;
29506
+
29492
29507
  const {
29493
29508
  css,
29509
+ editorState: value,
29494
29510
  onChange,
29511
+ toolbar,
29495
29512
  editorHeight,
29496
- uploadCallback
29513
+ uploadCallback,
29514
+ maxLength
29497
29515
  } = props;
29498
29516
  const [editorState, setEditorState] = useState(() => EditorState.createEmpty());
29517
+ useEffect(() => {
29518
+ if (value) {
29519
+ setEditorState(value);
29520
+ }
29521
+ }, [value]);
29499
29522
 
29500
29523
  function onEditorStateChange(e) {
29501
29524
  setEditorState(e);
29502
- onChange === null || onChange === void 0 ? void 0 : onChange(draftToHtml(convertToRaw(e.getCurrentContent())));
29525
+ onChange === null || onChange === void 0 ? void 0 : onChange(e);
29503
29526
  }
29504
29527
 
29505
29528
  const config = {
@@ -29507,41 +29530,32 @@ function ContentEditor(props) {
29507
29530
  history: {
29508
29531
  options: ['undo', 'redo'],
29509
29532
  undo: {
29510
- icon: img$4,
29511
- className: undefined
29533
+ icon: img$4
29512
29534
  },
29513
29535
  redo: {
29514
- icon: img$3,
29515
- className: undefined
29536
+ icon: img$3
29516
29537
  }
29517
29538
  },
29518
29539
  inline: {
29519
29540
  options: ['bold', 'italic', 'underline', 'strikethrough', 'monospace'],
29520
29541
  bold: {
29521
- icon: img$9,
29522
- className: undefined
29542
+ icon: img$9
29523
29543
  },
29524
29544
  italic: {
29525
- icon: img$8,
29526
- className: undefined
29545
+ icon: img$8
29527
29546
  },
29528
29547
  underline: {
29529
- icon: img$7,
29530
- className: undefined
29548
+ icon: img$7
29531
29549
  },
29532
29550
  strikethrough: {
29533
- icon: img$6,
29534
- className: undefined
29551
+ icon: img$6
29535
29552
  },
29536
29553
  monospace: {
29537
- icon: img$a,
29538
- className: undefined
29554
+ icon: img$a
29539
29555
  }
29540
29556
  },
29541
29557
  remove: {
29542
- icon: img$5,
29543
- className: undefined,
29544
- component: undefined
29558
+ icon: img$5
29545
29559
  },
29546
29560
  blockType: {
29547
29561
  inDropdown: true,
@@ -29575,18 +29589,22 @@ function ContentEditor(props) {
29575
29589
  uploadCallback: uploadCallback
29576
29590
  }
29577
29591
  };
29578
- return jsx(Container, Object.assign({
29592
+ return jsxs(Container, Object.assign({
29579
29593
  css: css,
29580
29594
  editorHeight: editorHeight
29581
29595
  }, {
29582
- children: jsx(Editor, {
29596
+ children: [jsx(Editor, {
29583
29597
  wrapperClassName: "wrapper-root",
29584
29598
  editorClassName: "editor-root",
29585
29599
  toolbarClassName: "toolbar-root",
29586
29600
  editorState: editorState,
29587
29601
  onEditorStateChange: onEditorStateChange,
29588
- toolbar: config
29589
- }, void 0)
29602
+ toolbar: toolbar ? toolbar(config) : config
29603
+ }, void 0), maxLength && typeof maxLength === 'number' && jsx(MaxLengthText, Object.assign({
29604
+ warning: ((_b = (_a = editorState === null || editorState === void 0 ? void 0 : editorState.getCurrentContent()) === null || _a === void 0 ? void 0 : _a.getPlainText()) === null || _b === void 0 ? void 0 : _b.length) > maxLength
29605
+ }, {
29606
+ children: `${(_d = (_c = editorState === null || editorState === void 0 ? void 0 : editorState.getCurrentContent()) === null || _c === void 0 ? void 0 : _c.getPlainText()) === null || _d === void 0 ? void 0 : _d.length} / ${maxLength}`
29607
+ }), void 0)]
29590
29608
  }), void 0);
29591
29609
  }
29592
29610
 
package/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('prop-types'), require('@stitches/react'), require('@majoo-ui/core'), require('@majoo-ui/icons'), require('react-transition-group'), require('react/jsx-runtime'), require('@majoo-ui/helpers'), require('@radix-ui/react-avatar'), require('@radix-ui/react-tooltip'), require('@radix-ui/react-progress'), require('@radix-ui/react-label'), require('@radix-ui/react-checkbox'), require('@radix-ui/react-radio-group'), require('react-number-format'), require('@radix-ui/react-switch'), require('downshift'), require('react-infinite-scroller'), require('lodash.debounce'), require('otp-input-react'), require('@floating-ui/react-dom-interactions'), require('@radix-ui/react-slider'), require('@radix-ui/react-tabs'), require('@radix-ui/react-separator'), require('@radix-ui/react-toggle-group'), require('@radix-ui/react-dialog'), require('@radix-ui/react-accordion'), require('dayzed'), require('moment'), require('react-table'), require('react-dom'), require('@radix-ui/react-alert-dialog'), require('@radix-ui/react-dropdown-menu'), require('@radix-ui/react-aspect-ratio'), require('react-color/lib/components/common'), require('react-color/lib/helpers/color'), require('react-step-wizard'), require('react-ui-scrollspy'), require('@react-google-maps/api'), require('superagent'), require('recharts'), require('draft-js'), require('react-draft-wysiwyg'), require('draftjs-to-html'), require('react-image-crop'), require('react-table-sticky')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react', 'prop-types', '@stitches/react', '@majoo-ui/core', '@majoo-ui/icons', 'react-transition-group', 'react/jsx-runtime', '@majoo-ui/helpers', '@radix-ui/react-avatar', '@radix-ui/react-tooltip', '@radix-ui/react-progress', '@radix-ui/react-label', '@radix-ui/react-checkbox', '@radix-ui/react-radio-group', 'react-number-format', '@radix-ui/react-switch', 'downshift', 'react-infinite-scroller', 'lodash.debounce', 'otp-input-react', '@floating-ui/react-dom-interactions', '@radix-ui/react-slider', '@radix-ui/react-tabs', '@radix-ui/react-separator', '@radix-ui/react-toggle-group', '@radix-ui/react-dialog', '@radix-ui/react-accordion', 'dayzed', 'moment', 'react-table', 'react-dom', '@radix-ui/react-alert-dialog', '@radix-ui/react-dropdown-menu', '@radix-ui/react-aspect-ratio', 'react-color/lib/components/common', 'react-color/lib/helpers/color', 'react-step-wizard', 'react-ui-scrollspy', '@react-google-maps/api', 'superagent', 'recharts', 'draft-js', 'react-draft-wysiwyg', 'draftjs-to-html', 'react-image-crop', 'react-table-sticky'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.React = {}, global.React, global.PropTypes, global.react, global.core, global.icons, global.reactTransitionGroup, global.jsxRuntime, global.helpers, global.AvatarPrimitive, global.TooltipPrimitive, global.ProgressPrimitive, global.LabelPrimitive, global.CheckboxPrimitive, global.RadioGroupPrimitive, global.NumberFormat, global.SwitchPrimitive, global.Downshift, global.InfiniteScroll, global.debounce, global.OTPInput, global.reactDomInteractions, global.SliderPrimitive, global.TabsPrimitive, global.SeparatorPrimitive, global.ToggleGroupPrimitive, global.DialogPrimitive, global.AccordionPrimitive, global.dayzed, global.moment, global.reactTable, global.ReactDOM, global.ADialog, global.DropdownMenuPrimitive, global.AspectRatioPrimitive, global.common, global.color, global.StepWizard$1, global.ScrollSpy, global.api, global.request, global.recharts, global.draftJs, global.reactDraftWysiwyg, global.draftToHtml, global.ReactCrop, global.reactTableSticky));
5
- })(this, (function (exports, React, PropTypes, react, core, icons, reactTransitionGroup, jsxRuntime, helpers, AvatarPrimitive, TooltipPrimitive, ProgressPrimitive, LabelPrimitive, CheckboxPrimitive, RadioGroupPrimitive, NumberFormat, SwitchPrimitive, Downshift, InfiniteScroll, debounce, OTPInput, reactDomInteractions, SliderPrimitive, TabsPrimitive, SeparatorPrimitive, ToggleGroupPrimitive, DialogPrimitive, AccordionPrimitive, dayzed, moment, reactTable, ReactDOM, ADialog, DropdownMenuPrimitive, AspectRatioPrimitive, common, color, StepWizard$1, ScrollSpy, api, request, recharts, draftJs, reactDraftWysiwyg, draftToHtml, ReactCrop, reactTableSticky) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('prop-types'), require('@stitches/react'), require('@majoo-ui/core'), require('@majoo-ui/icons'), require('react-transition-group'), require('react/jsx-runtime'), require('@majoo-ui/helpers'), require('@radix-ui/react-avatar'), require('@radix-ui/react-tooltip'), require('@radix-ui/react-progress'), require('@radix-ui/react-label'), require('@radix-ui/react-checkbox'), require('@radix-ui/react-radio-group'), require('react-number-format'), require('@radix-ui/react-switch'), require('downshift'), require('react-infinite-scroller'), require('lodash.debounce'), require('otp-input-react'), require('@floating-ui/react-dom-interactions'), require('@radix-ui/react-slider'), require('@radix-ui/react-tabs'), require('@radix-ui/react-separator'), require('@radix-ui/react-toggle-group'), require('@radix-ui/react-dialog'), require('@radix-ui/react-accordion'), require('dayzed'), require('moment'), require('react-table'), require('react-dom'), require('@radix-ui/react-alert-dialog'), require('@radix-ui/react-dropdown-menu'), require('@radix-ui/react-aspect-ratio'), require('react-color/lib/components/common'), require('react-color/lib/helpers/color'), require('react-step-wizard'), require('react-ui-scrollspy'), require('@react-google-maps/api'), require('superagent'), require('recharts'), require('draft-js'), require('react-draft-wysiwyg'), require('react-image-crop'), require('react-table-sticky')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react', 'prop-types', '@stitches/react', '@majoo-ui/core', '@majoo-ui/icons', 'react-transition-group', 'react/jsx-runtime', '@majoo-ui/helpers', '@radix-ui/react-avatar', '@radix-ui/react-tooltip', '@radix-ui/react-progress', '@radix-ui/react-label', '@radix-ui/react-checkbox', '@radix-ui/react-radio-group', 'react-number-format', '@radix-ui/react-switch', 'downshift', 'react-infinite-scroller', 'lodash.debounce', 'otp-input-react', '@floating-ui/react-dom-interactions', '@radix-ui/react-slider', '@radix-ui/react-tabs', '@radix-ui/react-separator', '@radix-ui/react-toggle-group', '@radix-ui/react-dialog', '@radix-ui/react-accordion', 'dayzed', 'moment', 'react-table', 'react-dom', '@radix-ui/react-alert-dialog', '@radix-ui/react-dropdown-menu', '@radix-ui/react-aspect-ratio', 'react-color/lib/components/common', 'react-color/lib/helpers/color', 'react-step-wizard', 'react-ui-scrollspy', '@react-google-maps/api', 'superagent', 'recharts', 'draft-js', 'react-draft-wysiwyg', 'react-image-crop', 'react-table-sticky'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.React = {}, global.React, global.PropTypes, global.react, global.core, global.icons, global.reactTransitionGroup, global.jsxRuntime, global.helpers, global.AvatarPrimitive, global.TooltipPrimitive, global.ProgressPrimitive, global.LabelPrimitive, global.CheckboxPrimitive, global.RadioGroupPrimitive, global.NumberFormat, global.SwitchPrimitive, global.Downshift, global.InfiniteScroll, global.debounce, global.OTPInput, global.reactDomInteractions, global.SliderPrimitive, global.TabsPrimitive, global.SeparatorPrimitive, global.ToggleGroupPrimitive, global.DialogPrimitive, global.AccordionPrimitive, global.dayzed, global.moment, global.reactTable, global.ReactDOM, global.ADialog, global.DropdownMenuPrimitive, global.AspectRatioPrimitive, global.common, global.color, global.StepWizard$1, global.ScrollSpy, global.api, global.request, global.recharts, global.draftJs, global.reactDraftWysiwyg, global.ReactCrop, global.reactTableSticky));
5
+ })(this, (function (exports, React, PropTypes, react, core, icons, reactTransitionGroup, jsxRuntime, helpers, AvatarPrimitive, TooltipPrimitive, ProgressPrimitive, LabelPrimitive, CheckboxPrimitive, RadioGroupPrimitive, NumberFormat, SwitchPrimitive, Downshift, InfiniteScroll, debounce, OTPInput, reactDomInteractions, SliderPrimitive, TabsPrimitive, SeparatorPrimitive, ToggleGroupPrimitive, DialogPrimitive, AccordionPrimitive, dayzed, moment, reactTable, ReactDOM, ADialog, DropdownMenuPrimitive, AspectRatioPrimitive, common, color, StepWizard$1, ScrollSpy, api, request, recharts, draftJs, reactDraftWysiwyg, ReactCrop, reactTableSticky) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -54,7 +54,6 @@
54
54
  var StepWizard__default = /*#__PURE__*/_interopDefaultLegacy(StepWizard$1);
55
55
  var ScrollSpy__default = /*#__PURE__*/_interopDefaultLegacy(ScrollSpy);
56
56
  var request__default = /*#__PURE__*/_interopDefaultLegacy(request);
57
- var draftToHtml__default = /*#__PURE__*/_interopDefaultLegacy(draftToHtml);
58
57
  var ReactCrop__default = /*#__PURE__*/_interopDefaultLegacy(ReactCrop);
59
58
 
60
59
  var _jsxFileName$10 = "C:\\Users\\Lenovo\\Documents\\code\\majoo\\majoo-ui\\packages\\react\\src\\majoo-provider\\ThemeProvider.js";
@@ -29822,7 +29821,7 @@
29822
29821
  css: {
29823
29822
  marginRight: 12,
29824
29823
  cursor: 'pointer',
29825
- display: ((_a = originalCell === null || originalCell === void 0 ? void 0 : originalCell.detail) === null || _a === void 0 ? void 0 : _a.length) ? 'flex' : 'none'
29824
+ display: ((_a = originalCell === null || originalCell === void 0 ? void 0 : originalCell.detail) === null || _a === void 0 ? void 0 : _a.length) ? 'flex' : 'none !important'
29826
29825
  },
29827
29826
  onClick: function () {
29828
29827
  if (!Object.keys(state.expanded).includes(row.id)) {
@@ -29996,21 +29995,46 @@
29996
29995
  }, 1000)
29997
29996
  }
29998
29997
  });
29998
+ var MaxLengthText = styled('p', {
29999
+ fontSize: 12,
30000
+ fontWeight: 400,
30001
+ color: '$textSecondary',
30002
+ textAlign: 'right',
30003
+ padding: '$spacing-03',
30004
+ variants: {
30005
+ warning: {
30006
+ true: {
30007
+ color: '$textRed'
30008
+ }
30009
+ }
30010
+ }
30011
+ });
29999
30012
  function ContentEditor(props) {
30013
+ var _a, _b, _c, _d;
30014
+
30000
30015
  var css = props.css,
30016
+ value = props.editorState,
30001
30017
  onChange = props.onChange,
30018
+ toolbar = props.toolbar,
30002
30019
  editorHeight = props.editorHeight,
30003
- uploadCallback = props.uploadCallback;
30020
+ uploadCallback = props.uploadCallback,
30021
+ maxLength = props.maxLength;
30004
30022
 
30005
- var _a = React.useState(function () {
30023
+ var _e = React.useState(function () {
30006
30024
  return draftJs.EditorState.createEmpty();
30007
30025
  }),
30008
- editorState = _a[0],
30009
- setEditorState = _a[1];
30026
+ editorState = _e[0],
30027
+ setEditorState = _e[1];
30028
+
30029
+ React.useEffect(function () {
30030
+ if (value) {
30031
+ setEditorState(value);
30032
+ }
30033
+ }, [value]);
30010
30034
 
30011
30035
  function onEditorStateChange(e) {
30012
30036
  setEditorState(e);
30013
- onChange === null || onChange === void 0 ? void 0 : onChange(draftToHtml__default["default"](draftJs.convertToRaw(e.getCurrentContent())));
30037
+ onChange === null || onChange === void 0 ? void 0 : onChange(e);
30014
30038
  }
30015
30039
 
30016
30040
  var config = {
@@ -30018,41 +30042,32 @@
30018
30042
  history: {
30019
30043
  options: ['undo', 'redo'],
30020
30044
  undo: {
30021
- icon: img$4,
30022
- className: undefined
30045
+ icon: img$4
30023
30046
  },
30024
30047
  redo: {
30025
- icon: img$3,
30026
- className: undefined
30048
+ icon: img$3
30027
30049
  }
30028
30050
  },
30029
30051
  inline: {
30030
30052
  options: ['bold', 'italic', 'underline', 'strikethrough', 'monospace'],
30031
30053
  bold: {
30032
- icon: img$9,
30033
- className: undefined
30054
+ icon: img$9
30034
30055
  },
30035
30056
  italic: {
30036
- icon: img$8,
30037
- className: undefined
30057
+ icon: img$8
30038
30058
  },
30039
30059
  underline: {
30040
- icon: img$7,
30041
- className: undefined
30060
+ icon: img$7
30042
30061
  },
30043
30062
  strikethrough: {
30044
- icon: img$6,
30045
- className: undefined
30063
+ icon: img$6
30046
30064
  },
30047
30065
  monospace: {
30048
- icon: img$a,
30049
- className: undefined
30066
+ icon: img$a
30050
30067
  }
30051
30068
  },
30052
30069
  remove: {
30053
- icon: img$5,
30054
- className: undefined,
30055
- component: undefined
30070
+ icon: img$5
30056
30071
  },
30057
30072
  blockType: {
30058
30073
  inDropdown: true,
@@ -30086,18 +30101,22 @@
30086
30101
  uploadCallback: uploadCallback
30087
30102
  }
30088
30103
  };
30089
- return jsxRuntime.jsx(Container, __assign({
30104
+ return jsxRuntime.jsxs(Container, __assign({
30090
30105
  css: css,
30091
30106
  editorHeight: editorHeight
30092
30107
  }, {
30093
- children: jsxRuntime.jsx(reactDraftWysiwyg.Editor, {
30108
+ children: [jsxRuntime.jsx(reactDraftWysiwyg.Editor, {
30094
30109
  wrapperClassName: "wrapper-root",
30095
30110
  editorClassName: "editor-root",
30096
30111
  toolbarClassName: "toolbar-root",
30097
30112
  editorState: editorState,
30098
30113
  onEditorStateChange: onEditorStateChange,
30099
- toolbar: config
30100
- }, void 0)
30114
+ toolbar: toolbar ? toolbar(config) : config
30115
+ }, void 0), maxLength && typeof maxLength === 'number' && jsxRuntime.jsx(MaxLengthText, __assign({
30116
+ warning: ((_b = (_a = editorState === null || editorState === void 0 ? void 0 : editorState.getCurrentContent()) === null || _a === void 0 ? void 0 : _a.getPlainText()) === null || _b === void 0 ? void 0 : _b.length) > maxLength
30117
+ }, {
30118
+ children: "".concat((_d = (_c = editorState === null || editorState === void 0 ? void 0 : editorState.getCurrentContent()) === null || _c === void 0 ? void 0 : _c.getPlainText()) === null || _d === void 0 ? void 0 : _d.length, " / ").concat(maxLength)
30119
+ }), void 0)]
30101
30120
  }), void 0);
30102
30121
  }
30103
30122
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@majoo-ui/react",
3
- "version": "1.52.0",
3
+ "version": "1.52.1",
4
4
  "dependencies": {
5
5
  "@majoo-ui/core": "^1.31.1",
6
6
  "@majoo-ui/helpers": "^1.30.5",
@@ -45,6 +45,7 @@
45
45
  "otp-input-react": "^0.3.0",
46
46
  "draft-js": "^0.11.7",
47
47
  "draftjs-to-html": "^0.9.1",
48
+ "html-to-draftjs": "^1.5.0",
48
49
  "react-draft-wysiwyg": "^1.15.0"
49
50
  },
50
51
  "main": "./index.umd.js",