@pareto-engineering/design-system 4.0.0-alpha.88 → 4.0.0-alpha.89

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.
@@ -39,13 +39,14 @@ const XMLEditor = _ref => {
39
39
  config,
40
40
  onChange,
41
41
  onBlur,
42
+ stopAllPropagation,
42
43
  stopPropagationKeys
43
44
  } = _ref;
44
45
  const editorRef = (0, _react.useRef)();
45
46
  (0, _react.useEffect)(() => {
46
47
  const startState = _state.EditorState.create({
47
48
  doc: config,
48
- extensions: [_view.keymap.of(_commands.defaultKeymap), (0, _language.indentOnInput)(), (0, _view.lineNumbers)(), (0, _language.bracketMatching)(), (0, _language.foldGutter)(), (0, _view.drawSelection)(), (0, _view.highlightActiveLine)(), (0, _view.highlightActiveLineGutter)(), (0, _view.highlightSpecialChars)(), (0, _view.dropCursor)(), (0, _view.rectangularSelection)(), (0, _view.crosshairCursor)(), (0, _langXml.xml)(), _common.theme, _state.EditorState.readOnly.of(readOnly), _view.EditorView.updateListener.of(view => {
49
+ extensions: [_view.keymap.of([_commands.defaultKeymap, _commands.indentWithTab]), (0, _language.indentOnInput)(), (0, _view.lineNumbers)(), (0, _language.bracketMatching)(), (0, _language.foldGutter)(), (0, _view.drawSelection)(), (0, _view.highlightActiveLine)(), (0, _view.highlightActiveLineGutter)(), (0, _view.highlightSpecialChars)(), (0, _view.dropCursor)(), (0, _view.rectangularSelection)(), (0, _view.crosshairCursor)(), (0, _langXml.xml)(), _common.theme, _state.EditorState.readOnly.of(readOnly), _view.EditorView.updateListener.of(view => {
49
50
  onChange(view);
50
51
  // view.state.doc.toString() to receive the current content in the editor.
51
52
  }), _view.EditorView.focusChangeEffect.of((state, focused) => {
@@ -54,7 +55,7 @@ const XMLEditor = _ref => {
54
55
  }
55
56
  }), _view.EditorView.domEventHandlers({
56
57
  keydown(e) {
57
- if (stopPropagationKeys?.includes(e.key)) {
58
+ if (stopPropagationKeys?.includes(e.key) || stopAllPropagation) {
58
59
  e.stopPropagation();
59
60
  }
60
61
  }
@@ -115,7 +116,15 @@ XMLEditor.propTypes = {
115
116
  /**
116
117
  * The keys to stop propagation on.
117
118
  */
118
- stopPropagationKeys: _propTypes.default.arrayOf(_propTypes.default.string)
119
+ stopPropagationKeys: _propTypes.default.arrayOf(_propTypes.default.string),
120
+ /**
121
+ * The callback for when the editor loses focus.
122
+ */
123
+ onBlur: _propTypes.default.func,
124
+ /**
125
+ * Whether to stop all propagation of keys to keep focus on the editor.
126
+ */
127
+ stopAllPropagation: _propTypes.default.bool
119
128
  };
120
129
  XMLEditor.defaultProps = {
121
130
  config: `<View>
@@ -4,6 +4,7 @@
4
4
  border-radius: 1em;
5
5
  height: var(--height);
6
6
  overflow: auto;
7
+ resize: both;
7
8
 
8
9
  > .cm-editor {
9
10
  height: 100%;
@@ -4,7 +4,7 @@ import { useEffect, useRef } from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
  import { EditorState } from '@codemirror/state';
6
6
  import { EditorView, keymap, lineNumbers, drawSelection, dropCursor, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, crosshairCursor, rectangularSelection } from '@codemirror/view';
7
- import { defaultKeymap } from '@codemirror/commands';
7
+ import { defaultKeymap, indentWithTab } from '@codemirror/commands';
8
8
  import { indentOnInput, bracketMatching, foldGutter } from '@codemirror/language';
9
9
  import { xml } from '@codemirror/lang-xml';
10
10
  import styleNames from '@pareto-engineering/bem/exports';
@@ -28,13 +28,14 @@ const XMLEditor = ({
28
28
  config,
29
29
  onChange,
30
30
  onBlur,
31
+ stopAllPropagation,
31
32
  stopPropagationKeys
32
33
  }) => {
33
34
  const editorRef = useRef();
34
35
  useEffect(() => {
35
36
  const startState = EditorState.create({
36
37
  doc: config,
37
- extensions: [keymap.of(defaultKeymap), indentOnInput(), lineNumbers(), bracketMatching(), foldGutter(), drawSelection(), highlightActiveLine(), highlightActiveLineGutter(), highlightSpecialChars(), dropCursor(), rectangularSelection(), crosshairCursor(), xml(), theme, EditorState.readOnly.of(readOnly), EditorView.updateListener.of(view => {
38
+ extensions: [keymap.of([defaultKeymap, indentWithTab]), indentOnInput(), lineNumbers(), bracketMatching(), foldGutter(), drawSelection(), highlightActiveLine(), highlightActiveLineGutter(), highlightSpecialChars(), dropCursor(), rectangularSelection(), crosshairCursor(), xml(), theme, EditorState.readOnly.of(readOnly), EditorView.updateListener.of(view => {
38
39
  onChange(view);
39
40
  // view.state.doc.toString() to receive the current content in the editor.
40
41
  }), EditorView.focusChangeEffect.of((state, focused) => {
@@ -43,7 +44,7 @@ const XMLEditor = ({
43
44
  }
44
45
  }), EditorView.domEventHandlers({
45
46
  keydown(e) {
46
- if (stopPropagationKeys?.includes(e.key)) {
47
+ if (stopPropagationKeys?.includes(e.key) || stopAllPropagation) {
47
48
  e.stopPropagation();
48
49
  }
49
50
  }
@@ -104,7 +105,15 @@ XMLEditor.propTypes = {
104
105
  /**
105
106
  * The keys to stop propagation on.
106
107
  */
107
- stopPropagationKeys: PropTypes.arrayOf(PropTypes.string)
108
+ stopPropagationKeys: PropTypes.arrayOf(PropTypes.string),
109
+ /**
110
+ * The callback for when the editor loses focus.
111
+ */
112
+ onBlur: PropTypes.func,
113
+ /**
114
+ * Whether to stop all propagation of keys to keep focus on the editor.
115
+ */
116
+ stopAllPropagation: PropTypes.bool
108
117
  };
109
118
  XMLEditor.defaultProps = {
110
119
  config: `<View>
@@ -4,6 +4,7 @@
4
4
  border-radius: 1em;
5
5
  height: var(--height);
6
6
  overflow: auto;
7
+ resize: both;
7
8
 
8
9
  > .cm-editor {
9
10
  height: 100%;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pareto-engineering/design-system",
3
- "version": "4.0.0-alpha.88",
3
+ "version": "4.0.0-alpha.89",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/es/index.js",
@@ -82,5 +82,5 @@
82
82
  "relay-test-utils": "^15.0.0"
83
83
  },
84
84
  "browserslist": "> 2%",
85
- "gitHead": "2e7b0a8eb0b49234aa54e29bda5bfb9feca51ec8"
85
+ "gitHead": "579aab967ee9db911c6c88b04f874542abb60d59"
86
86
  }
@@ -22,6 +22,7 @@ import {
22
22
 
23
23
  import {
24
24
  defaultKeymap,
25
+ indentWithTab,
25
26
  } from '@codemirror/commands'
26
27
 
27
28
  import {
@@ -57,6 +58,7 @@ const XMLEditor = ({
57
58
  config,
58
59
  onChange,
59
60
  onBlur,
61
+ stopAllPropagation,
60
62
  stopPropagationKeys,
61
63
  }) => {
62
64
  const editorRef = useRef()
@@ -65,7 +67,7 @@ const XMLEditor = ({
65
67
  const startState = EditorState.create({
66
68
  doc :config,
67
69
  extensions:[
68
- keymap.of(defaultKeymap),
70
+ keymap.of([defaultKeymap, indentWithTab]),
69
71
  indentOnInput(),
70
72
  lineNumbers(),
71
73
  bracketMatching(),
@@ -91,7 +93,7 @@ const XMLEditor = ({
91
93
  }),
92
94
  EditorView.domEventHandlers({
93
95
  keydown(e) {
94
- if (stopPropagationKeys?.includes(e.key)) {
96
+ if (stopPropagationKeys?.includes(e.key) || stopAllPropagation) {
95
97
  e.stopPropagation()
96
98
  }
97
99
  },
@@ -174,6 +176,16 @@ XMLEditor.propTypes = {
174
176
  * The keys to stop propagation on.
175
177
  */
176
178
  stopPropagationKeys:PropTypes.arrayOf(PropTypes.string),
179
+
180
+ /**
181
+ * The callback for when the editor loses focus.
182
+ */
183
+ onBlur:PropTypes.func,
184
+
185
+ /**
186
+ * Whether to stop all propagation of keys to keep focus on the editor.
187
+ */
188
+ stopAllPropagation:PropTypes.bool,
177
189
  }
178
190
 
179
191
  XMLEditor.defaultProps = {
@@ -4,6 +4,7 @@
4
4
  border-radius: 1em;
5
5
  height: var(--height);
6
6
  overflow: auto;
7
+ resize: both;
7
8
 
8
9
  > .cm-editor {
9
10
  height: 100%;
@@ -11567,7 +11567,7 @@ exports[`Storyshots a/Timestamp Distance Format 1`] = `
11567
11567
  className="base timestamp"
11568
11568
  onClick={[Function]}
11569
11569
  >
11570
- over 1 year ago
11570
+ almost 2 years ago
11571
11571
  </p>
11572
11572
  `;
11573
11573