@pareto-engineering/design-system 5.1.0 → 5.1.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.
@@ -67,7 +67,8 @@ const EditorInput = _ref2 => {
67
67
  description,
68
68
  disabled,
69
69
  showDebugger,
70
- setEditorState
70
+ setEditorState,
71
+ setPlainTextKey
71
72
  // ...otherProps
72
73
  } = _ref2;
73
74
  const [field,,] = (0, _formik.useField)(name);
@@ -139,7 +140,7 @@ const EditorInput = _ref2 => {
139
140
  '--resize': resize,
140
141
  '--rows': `${rows}em`
141
142
  }
142
- }, /*#__PURE__*/React.createElement(_common.FormLabel, {
143
+ }, label && /*#__PURE__*/React.createElement(_common.FormLabel, {
143
144
  name: name,
144
145
  color: labelColor,
145
146
  optional: optional
@@ -158,7 +159,10 @@ const EditorInput = _ref2 => {
158
159
  className: "s-1",
159
160
  description: description,
160
161
  name: name
161
- }), showDebugger && /*#__PURE__*/React.createElement(_common2.TreeViewPlugin, null)));
162
+ }), showDebugger && /*#__PURE__*/React.createElement(_common2.TreeViewPlugin, null), setPlainTextKey && /*#__PURE__*/React.createElement(_common2.ExposePlainTextPlugin, {
163
+ setFieldValue: setFieldValue,
164
+ setPlainTextKey: setPlainTextKey
165
+ })));
162
166
  };
163
167
  EditorInput.propTypes = {
164
168
  /**
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = require("react");
8
+ var _LexicalComposerContext = require("@lexical/react/LexicalComposerContext");
9
+ var _lexical = require("lexical");
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ /**
13
+ * This is the component description
14
+ */
15
+ const ExposePlainTextPlugin = _ref => {
16
+ let {
17
+ setFieldValue,
18
+ setPlainTextKey
19
+ } = _ref;
20
+ const [editor] = (0, _LexicalComposerContext.useLexicalComposerContext)();
21
+ (0, _react.useEffect)(() => editor.registerUpdateListener(_ref2 => {
22
+ let {
23
+ editorState
24
+ } = _ref2;
25
+ editorState.read(() => {
26
+ const root = (0, _lexical.$getRoot)();
27
+ const textContent = root.getTextContent();
28
+ setFieldValue(setPlainTextKey, textContent);
29
+ });
30
+ }), [editor]);
31
+ return null;
32
+ };
33
+ ExposePlainTextPlugin.propTypes = {
34
+ setFieldValue: _propTypes.default.func.isRequired,
35
+ setPlainTextKey: _propTypes.default.string.isRequired
36
+ };
37
+ ExposePlainTextPlugin.defaultProps = {
38
+ //
39
+ };
40
+ var _default = exports.default = ExposePlainTextPlugin;
@@ -180,7 +180,7 @@ const ToolbarPlugin = _ref => {
180
180
  }, [applyStyleText]);
181
181
  return /*#__PURE__*/React.createElement("div", {
182
182
  id: id,
183
- className: [baseClassName, componentClassName, userClassName, `x-${baseBgColor}`].filter(e => e).join(' '),
183
+ className: [baseClassName, componentClassName, userClassName, `x-${baseBgColor} b-x`].filter(e => e).join(' '),
184
184
  style: inlineStyles
185
185
  }, /*#__PURE__*/React.createElement("div", {
186
186
  className: "group"
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "ColorPicker", {
15
15
  return _ColorPicker.ColorPicker;
16
16
  }
17
17
  });
18
+ Object.defineProperty(exports, "ExposePlainTextPlugin", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _ExposePlainTextPlugin.default;
22
+ }
23
+ });
18
24
  Object.defineProperty(exports, "FontSizeDropDown", {
19
25
  enumerable: true,
20
26
  get: function () {
@@ -45,4 +51,5 @@ var _StopPropagationPlugin = _interopRequireDefault(require("./StopPropagationPl
45
51
  var _ToolbarPlugin = require("./ToolbarPlugin");
46
52
  var _ColorPicker = require("./ColorPicker");
47
53
  var _FontSizeDropDown = require("./FontSizeDropDown");
54
+ var _ExposePlainTextPlugin = _interopRequireDefault(require("./ExposePlainTextPlugin"));
48
55
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -38,7 +38,8 @@ const ExpandableLexicalPreview = _ref => {
38
38
  pageTitle,
39
39
  onBlock,
40
40
  onOpen,
41
- header
41
+ header,
42
+ rows
42
43
  // ...otherProps
43
44
  } = _ref;
44
45
  const [isCollapsed, setIsCollapsed] = (0, _react.useState)(false);
@@ -79,7 +80,8 @@ const ExpandableLexicalPreview = _ref => {
79
80
  name: name,
80
81
  resize: resize,
81
82
  disabled: true,
82
- id: "the-bad-ass-input"
83
+ id: `${id}-editor-input`,
84
+ rows: rows
83
85
  }), /*#__PURE__*/React.createElement(_b.Button, {
84
86
  id: id,
85
87
  className: "expand-button ai-icon",
@@ -10,7 +10,6 @@
10
10
  position: relative;
11
11
  width: 100%;
12
12
 
13
-
14
13
  &.collapsed {
15
14
  flex-direction: row;
16
15
  }
@@ -25,7 +25,7 @@ import styleNames from '@pareto-engineering/bem/exports';
25
25
  // Local Definitions
26
26
 
27
27
  import { FormLabel, FormDescription } from "../../common";
28
- import { ToolbarPlugin, TreeViewPlugin, StopPropagationPlugin } from "./common";
28
+ import { ToolbarPlugin, TreeViewPlugin, StopPropagationPlugin, ExposePlainTextPlugin } from "./common";
29
29
  import "./styles.scss";
30
30
  const baseClassName = styleNames.base;
31
31
  const componentClassName = 'editor-input';
@@ -56,7 +56,8 @@ const EditorInput = ({
56
56
  description,
57
57
  disabled,
58
58
  showDebugger,
59
- setEditorState
59
+ setEditorState,
60
+ setPlainTextKey
60
61
  // ...otherProps
61
62
  }) => {
62
63
  const [field,,] = useField(name);
@@ -128,7 +129,7 @@ const EditorInput = ({
128
129
  '--resize': resize,
129
130
  '--rows': `${rows}em`
130
131
  }
131
- }, /*#__PURE__*/React.createElement(FormLabel, {
132
+ }, label && /*#__PURE__*/React.createElement(FormLabel, {
132
133
  name: name,
133
134
  color: labelColor,
134
135
  optional: optional
@@ -147,7 +148,10 @@ const EditorInput = ({
147
148
  className: "s-1",
148
149
  description: description,
149
150
  name: name
150
- }), showDebugger && /*#__PURE__*/React.createElement(TreeViewPlugin, null)));
151
+ }), showDebugger && /*#__PURE__*/React.createElement(TreeViewPlugin, null), setPlainTextKey && /*#__PURE__*/React.createElement(ExposePlainTextPlugin, {
152
+ setFieldValue: setFieldValue,
153
+ setPlainTextKey: setPlainTextKey
154
+ })));
151
155
  };
152
156
  EditorInput.propTypes = {
153
157
  /**
@@ -0,0 +1,32 @@
1
+ import { useEffect } from 'react';
2
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
3
+ import { $getRoot } from 'lexical';
4
+ import PropTypes from 'prop-types';
5
+
6
+ /**
7
+ * This is the component description
8
+ */
9
+ const ExposePlainTextPlugin = ({
10
+ setFieldValue,
11
+ setPlainTextKey
12
+ }) => {
13
+ const [editor] = useLexicalComposerContext();
14
+ useEffect(() => editor.registerUpdateListener(({
15
+ editorState
16
+ }) => {
17
+ editorState.read(() => {
18
+ const root = $getRoot();
19
+ const textContent = root.getTextContent();
20
+ setFieldValue(setPlainTextKey, textContent);
21
+ });
22
+ }), [editor]);
23
+ return null;
24
+ };
25
+ ExposePlainTextPlugin.propTypes = {
26
+ setFieldValue: PropTypes.func.isRequired,
27
+ setPlainTextKey: PropTypes.string.isRequired
28
+ };
29
+ ExposePlainTextPlugin.defaultProps = {
30
+ //
31
+ };
32
+ export default ExposePlainTextPlugin;
@@ -168,7 +168,7 @@ const ToolbarPlugin = ({
168
168
  }, [applyStyleText]);
169
169
  return /*#__PURE__*/React.createElement("div", {
170
170
  id: id,
171
- className: [baseClassName, componentClassName, userClassName, `x-${baseBgColor}`].filter(e => e).join(' '),
171
+ className: [baseClassName, componentClassName, userClassName, `x-${baseBgColor} b-x`].filter(e => e).join(' '),
172
172
  style: inlineStyles
173
173
  }, /*#__PURE__*/React.createElement("div", {
174
174
  className: "group"
@@ -3,4 +3,5 @@ export { default as TreeViewPlugin } from "./TreeViewPlugin";
3
3
  export { default as StopPropagationPlugin } from "./StopPropagationPlugin";
4
4
  export { ToolbarPlugin } from "./ToolbarPlugin";
5
5
  export { ColorPicker } from "./ColorPicker";
6
- export { FontSizeDropDown } from "./FontSizeDropDown";
6
+ export { FontSizeDropDown } from "./FontSizeDropDown";
7
+ export { default as ExposePlainTextPlugin } from "./ExposePlainTextPlugin";
@@ -27,7 +27,8 @@ const ExpandableLexicalPreview = ({
27
27
  pageTitle,
28
28
  onBlock,
29
29
  onOpen,
30
- header
30
+ header,
31
+ rows
31
32
  // ...otherProps
32
33
  }) => {
33
34
  const [isCollapsed, setIsCollapsed] = useState(false);
@@ -68,7 +69,8 @@ const ExpandableLexicalPreview = ({
68
69
  name: name,
69
70
  resize: resize,
70
71
  disabled: true,
71
- id: "the-bad-ass-input"
72
+ id: `${id}-editor-input`,
73
+ rows: rows
72
74
  }), /*#__PURE__*/React.createElement(Button, {
73
75
  id: id,
74
76
  className: "expand-button ai-icon",
@@ -10,7 +10,6 @@
10
10
  position: relative;
11
11
  width: 100%;
12
12
 
13
-
14
13
  &.collapsed {
15
14
  flex-direction: row;
16
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pareto-engineering/design-system",
3
- "version": "5.1.0",
3
+ "version": "5.1.1",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/es/index.js",
@@ -59,7 +59,7 @@
59
59
  "@lexical/selection": "0.12.2",
60
60
  "@lexical/table": "0.12.2",
61
61
  "@lexical/utils": "0.12.2",
62
- "@pareto-engineering/assets": "^5.1.0",
62
+ "@pareto-engineering/assets": "^5.1.1",
63
63
  "@pareto-engineering/bem": "^5.0.0",
64
64
  "@pareto-engineering/styles": "^5.0.0",
65
65
  "@pareto-engineering/utils": "^5.0.0",
@@ -87,5 +87,5 @@
87
87
  "remark-math": "^6.0.0"
88
88
  },
89
89
  "browserslist": "> 2%",
90
- "gitHead": "df984562befbec687e458242d3b8696ee7286d1e"
90
+ "gitHead": "9af8ec028d247f108df8577a080c663edadc205b"
91
91
  }
@@ -26,7 +26,12 @@ import styleNames from '@pareto-engineering/bem/exports'
26
26
  // Local Definitions
27
27
 
28
28
  import { FormLabel, FormDescription } from '../../common'
29
- import { ToolbarPlugin, TreeViewPlugin, StopPropagationPlugin } from './common'
29
+ import {
30
+ ToolbarPlugin,
31
+ TreeViewPlugin,
32
+ StopPropagationPlugin,
33
+ ExposePlainTextPlugin,
34
+ } from './common'
30
35
 
31
36
  import './styles.scss'
32
37
 
@@ -60,6 +65,7 @@ const EditorInput = ({
60
65
  disabled,
61
66
  showDebugger,
62
67
  setEditorState,
68
+ setPlainTextKey,
63
69
  // ...otherProps
64
70
  }) => {
65
71
  const [field, ,] = useField(name)
@@ -157,14 +163,17 @@ const EditorInput = ({
157
163
  '--rows' :`${rows}em`,
158
164
  }}
159
165
  >
160
- <FormLabel
161
- name={name}
162
- color={labelColor}
163
- optional={optional}
164
- >
165
- {label}
166
- </FormLabel>
167
-
166
+ {
167
+ label && (
168
+ <FormLabel
169
+ name={name}
170
+ color={labelColor}
171
+ optional={optional}
172
+ >
173
+ {label}
174
+ </FormLabel>
175
+ )
176
+ }
168
177
  { !disabled && <ToolbarPlugin /> }
169
178
  <RichTextPlugin
170
179
  contentEditable={(
@@ -187,6 +196,12 @@ const EditorInput = ({
187
196
  <StopPropagationPlugin />
188
197
  <FormDescription className="s-1" description={description} name={name} />
189
198
  { showDebugger && <TreeViewPlugin /> }
199
+ {setPlainTextKey && (
200
+ <ExposePlainTextPlugin
201
+ setFieldValue={setFieldValue}
202
+ setPlainTextKey={setPlainTextKey}
203
+ />
204
+ )}
190
205
  </div>
191
206
  </LexicalComposer>
192
207
  )
@@ -0,0 +1,42 @@
1
+ import { useEffect } from 'react'
2
+
3
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'
4
+
5
+ import {
6
+ $getRoot,
7
+ } from 'lexical'
8
+
9
+ import PropTypes from 'prop-types'
10
+
11
+ /**
12
+ * This is the component description
13
+ */
14
+ const ExposePlainTextPlugin = ({
15
+ setFieldValue,
16
+ setPlainTextKey,
17
+ }) => {
18
+ const [editor] = useLexicalComposerContext()
19
+
20
+ useEffect(() => (
21
+ editor.registerUpdateListener(({ editorState }) => {
22
+ editorState.read(() => {
23
+ const root = $getRoot()
24
+ const textContent = root.getTextContent()
25
+ setFieldValue(setPlainTextKey, textContent)
26
+ })
27
+ })
28
+ ), [editor])
29
+
30
+ return null
31
+ }
32
+
33
+ ExposePlainTextPlugin.propTypes = {
34
+ setFieldValue :PropTypes.func.isRequired,
35
+ setPlainTextKey:PropTypes.string.isRequired,
36
+ }
37
+
38
+ ExposePlainTextPlugin.defaultProps = {
39
+ //
40
+ }
41
+
42
+ export default ExposePlainTextPlugin
@@ -254,7 +254,7 @@ const ToolbarPlugin = ({
254
254
  baseClassName,
255
255
  componentClassName,
256
256
  userClassName,
257
- `x-${baseBgColor}`,
257
+ `x-${baseBgColor} b-x`,
258
258
  ]
259
259
  .filter((e) => e)
260
260
  .join(' ')}
@@ -4,3 +4,4 @@ export { default as StopPropagationPlugin } from './StopPropagationPlugin'
4
4
  export { ToolbarPlugin } from './ToolbarPlugin'
5
5
  export { ColorPicker } from './ColorPicker'
6
6
  export { FontSizeDropDown } from './FontSizeDropDown'
7
+ export { default as ExposePlainTextPlugin } from './ExposePlainTextPlugin'
@@ -37,6 +37,7 @@ const ExpandableLexicalPreview = ({
37
37
  onBlock,
38
38
  onOpen,
39
39
  header,
40
+ rows,
40
41
  // ...otherProps
41
42
  }) => {
42
43
  const [isCollapsed, setIsCollapsed] = useState(false)
@@ -54,9 +55,7 @@ const ExpandableLexicalPreview = ({
54
55
  <div
55
56
  id={id}
56
57
  className={[
57
-
58
58
  baseClassName,
59
-
60
59
  componentClassName,
61
60
  userClassName,
62
61
  `y-${color}`,
@@ -102,7 +101,8 @@ const ExpandableLexicalPreview = ({
102
101
  name={name}
103
102
  resize={resize}
104
103
  disabled
105
- id="the-bad-ass-input"
104
+ id={`${id}-editor-input`}
105
+ rows={rows}
106
106
  />
107
107
  <Button
108
108
  id={id}
@@ -10,7 +10,6 @@
10
10
  position: relative;
11
11
  width: 100%;
12
12
 
13
-
14
13
  &.collapsed {
15
14
  flex-direction: row;
16
15
  }
@@ -29426,7 +29426,7 @@ exports[`Storyshots f/fields/EditorInput Base 1`] = `
29426
29426
  Project Instructions
29427
29427
  </label>
29428
29428
  <div
29429
- className="base toolbar-plugin x-background-far"
29429
+ className="base toolbar-plugin x-background-far b-x"
29430
29430
  >
29431
29431
  <div
29432
29432
  className="group"
@@ -29906,7 +29906,7 @@ exports[`Storyshots f/fields/EditorInput Optional 1`] = `
29906
29906
  (Optional)
29907
29907
  </label>
29908
29908
  <div
29909
- className="base toolbar-plugin x-background-far"
29909
+ className="base toolbar-plugin x-background-far b-x"
29910
29910
  >
29911
29911
  <div
29912
29912
  className="group"
@@ -34992,7 +34992,7 @@ exports[`Storyshots g/ExpandableLexicalPreview Base 1`] = `
34992
34992
  </p>
34993
34993
  <div
34994
34994
  className="base editor-input y-paragraph disabled"
34995
- id="the-bad-ass-input"
34995
+ id="undefined-editor-input"
34996
34996
  style={
34997
34997
  {
34998
34998
  "--resize": "vertical",
@@ -35000,10 +35000,6 @@ exports[`Storyshots g/ExpandableLexicalPreview Base 1`] = `
35000
35000
  }
35001
35001
  }
35002
35002
  >
35003
- <label
35004
- className="base form-label x-paragraph"
35005
- htmlFor="taskDescription"
35006
- />
35007
35003
  <div
35008
35004
  aria-autocomplete="none"
35009
35005
  aria-readonly={true}
@@ -35088,7 +35084,7 @@ exports[`Storyshots g/FormBuilder Builder 1`] = `
35088
35084
  Form description
35089
35085
  </label>
35090
35086
  <div
35091
- className="base toolbar-plugin x-background-far"
35087
+ className="base toolbar-plugin x-background-far b-x"
35092
35088
  >
35093
35089
  <div
35094
35090
  className="group"
@@ -35627,7 +35623,7 @@ exports[`Storyshots g/FormBuilder Renderer 1`] = `
35627
35623
  >
35628
35624
  <div
35629
35625
  className="base editor-input y-paragraph disabled"
35630
- id="the-bad-ass-input"
35626
+ id="undefined-editor-input"
35631
35627
  style={
35632
35628
  {
35633
35629
  "--resize": "vertical",
@@ -35635,10 +35631,6 @@ exports[`Storyshots g/FormBuilder Renderer 1`] = `
35635
35631
  }
35636
35632
  }
35637
35633
  >
35638
- <label
35639
- className="base form-label x-paragraph"
35640
- htmlFor="instructions"
35641
- />
35642
35634
  <div
35643
35635
  aria-autocomplete="none"
35644
35636
  aria-readonly={true}
@@ -35726,7 +35718,7 @@ exports[`Storyshots g/FormBuilder Renderer With Disabled 1`] = `
35726
35718
  >
35727
35719
  <div
35728
35720
  className="base editor-input y-paragraph disabled"
35729
- id="the-bad-ass-input"
35721
+ id="undefined-editor-input"
35730
35722
  style={
35731
35723
  {
35732
35724
  "--resize": "vertical",
@@ -35734,10 +35726,6 @@ exports[`Storyshots g/FormBuilder Renderer With Disabled 1`] = `
35734
35726
  }
35735
35727
  }
35736
35728
  >
35737
- <label
35738
- className="base form-label x-paragraph"
35739
- htmlFor="instructions"
35740
- />
35741
35729
  <div
35742
35730
  aria-autocomplete="none"
35743
35731
  aria-readonly={true}
@@ -35825,7 +35813,7 @@ exports[`Storyshots g/FormBuilder Renderer With Submit 1`] = `
35825
35813
  >
35826
35814
  <div
35827
35815
  className="base editor-input y-paragraph disabled"
35828
- id="the-bad-ass-input"
35816
+ id="undefined-editor-input"
35829
35817
  style={
35830
35818
  {
35831
35819
  "--resize": "vertical",
@@ -35833,10 +35821,6 @@ exports[`Storyshots g/FormBuilder Renderer With Submit 1`] = `
35833
35821
  }
35834
35822
  }
35835
35823
  >
35836
- <label
35837
- className="base form-label x-paragraph"
35838
- htmlFor="instructions"
35839
- />
35840
35824
  <div
35841
35825
  aria-autocomplete="none"
35842
35826
  aria-readonly={true}