@pareto-engineering/design-system 4.0.0-alpha.68 → 4.0.0-alpha.70

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.
Files changed (53) hide show
  1. package/.storybook/preview.js +29 -12
  2. package/dist/cjs/a/AnimatedGradient/AnimatedGradient.js +0 -1
  3. package/dist/cjs/a/AnimatedGradient/webGIRenderer.js +0 -1
  4. package/dist/cjs/a/AppContext/ContextProvider.js +2 -0
  5. package/dist/cjs/a/ProgressBar/ProgressBar.js +0 -1
  6. package/dist/cjs/a/XMLEditor/XMLEditor.js +115 -0
  7. package/dist/cjs/a/XMLEditor/common/index.js +13 -0
  8. package/dist/cjs/a/XMLEditor/common/theme.js +186 -0
  9. package/dist/cjs/a/XMLEditor/index.js +13 -0
  10. package/dist/cjs/a/XMLEditor/styles.scss +17 -0
  11. package/dist/cjs/a/index.js +8 -1
  12. package/dist/cjs/b/Logo/Logo.js +0 -1
  13. package/dist/cjs/b/Title/Title.js +0 -1
  14. package/dist/cjs/c/ContentSlides/common/HorizontalMenu/HorizontalMenu.js +2 -0
  15. package/dist/cjs/c/ContentSlides/common/Sidebar/Sidebar.js +2 -0
  16. package/dist/cjs/c/SocialMediaShareButton/SocialMediaShareButton.js +0 -2
  17. package/dist/cjs/f/FormInput/FormInput.js +2 -0
  18. package/dist/cjs/f/fields/QueryCombobox/QueryCombobox.js +11 -1
  19. package/dist/cjs/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +32 -3
  20. package/dist/cjs/r/common/PrivateRoute/PrivateRoute.js +0 -1
  21. package/dist/cjs/test/QueryLoader/__generated__/QueryLoaderHelloQuery.graphql.js +0 -1
  22. package/dist/es/a/AnimatedGradient/AnimatedGradient.js +0 -1
  23. package/dist/es/a/AnimatedGradient/webGIRenderer.js +0 -1
  24. package/dist/es/a/BlurOverlay/BlurOverlay.js +0 -1
  25. package/dist/es/a/DotInfo/DotInfo.js +0 -1
  26. package/dist/es/a/ProgressBar/ProgressBar.js +0 -1
  27. package/dist/es/a/XMLEditor/XMLEditor.js +106 -0
  28. package/dist/es/a/XMLEditor/common/index.js +1 -0
  29. package/dist/es/a/XMLEditor/common/theme.js +180 -0
  30. package/dist/es/a/XMLEditor/index.js +1 -0
  31. package/dist/es/a/XMLEditor/styles.scss +17 -0
  32. package/dist/es/a/index.js +2 -1
  33. package/dist/es/b/Logo/Logo.js +0 -1
  34. package/dist/es/b/Title/Title.js +0 -1
  35. package/dist/es/c/SocialMediaShareButton/SocialMediaShareButton.js +0 -2
  36. package/dist/es/f/fields/QueryCombobox/QueryCombobox.js +11 -1
  37. package/dist/es/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +32 -3
  38. package/dist/es/r/common/PrivateRoute/PrivateRoute.js +0 -1
  39. package/dist/es/test/QueryLoader/__generated__/QueryLoaderHelloQuery.graphql.js +0 -1
  40. package/package.json +6 -4
  41. package/src/stories/StyleGuide/ai-icons.stories.mdx +27 -0
  42. package/src/stories/StyleGuide/icons.stories.mdx +22 -22
  43. package/src/stories/a/CodeEditor.stories.jsx +21 -0
  44. package/src/stories/f/QueryCombobox.stories.jsx +22 -0
  45. package/src/ui/a/XMLEditor/XMLEditor.jsx +171 -0
  46. package/src/ui/a/XMLEditor/common/index.js +1 -0
  47. package/src/ui/a/XMLEditor/common/theme.jsx +184 -0
  48. package/src/ui/a/XMLEditor/index.js +1 -0
  49. package/src/ui/a/XMLEditor/styles.scss +17 -0
  50. package/src/ui/a/index.js +1 -0
  51. package/src/ui/f/fields/QueryCombobox/QueryCombobox.jsx +12 -0
  52. package/src/ui/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.jsx +38 -1
  53. package/tests/__snapshots__/Storyshots.test.js.snap +166 -25
@@ -0,0 +1,171 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
2
+ import * as React from 'react'
3
+
4
+ import { useEffect, useRef } from 'react'
5
+
6
+ import PropTypes from 'prop-types'
7
+
8
+ import { EditorState } from '@codemirror/state'
9
+
10
+ import {
11
+ EditorView,
12
+ keymap,
13
+ lineNumbers,
14
+ drawSelection,
15
+ dropCursor,
16
+ highlightActiveLine,
17
+ highlightActiveLineGutter,
18
+ highlightSpecialChars,
19
+ crosshairCursor,
20
+ rectangularSelection,
21
+ } from '@codemirror/view'
22
+
23
+ import {
24
+ defaultKeymap,
25
+ indentWithTab,
26
+ } from '@codemirror/commands'
27
+
28
+ import {
29
+ // indentOnInput,
30
+ bracketMatching,
31
+ foldGutter,
32
+ } from '@codemirror/language'
33
+
34
+ import { xml } from '@codemirror/lang-xml'
35
+
36
+ import styleNames from '@pareto-engineering/bem/exports'
37
+
38
+ import { theme } from './common'
39
+
40
+ import './styles.scss'
41
+
42
+ const baseClassName = styleNames.base
43
+
44
+ const componentClassName = 'code-editor'
45
+
46
+ /**
47
+ * codemirror documentation:
48
+ * https://codemirror.net/
49
+ */
50
+
51
+ const XMLEditor = ({
52
+ id,
53
+ className: userClassName,
54
+ style,
55
+ readOnly,
56
+ height,
57
+ gutterWidth,
58
+ config,
59
+ onChange,
60
+ }) => {
61
+ const editorRef = useRef()
62
+
63
+ useEffect(() => {
64
+ const startState = EditorState.create({
65
+ doc :config,
66
+ extensions:[
67
+ keymap.of([defaultKeymap, indentWithTab]),
68
+ // TOFIX: Indent with tab prevents indentOnInout from working.
69
+ // indentOnInput(),
70
+ lineNumbers(),
71
+ bracketMatching(),
72
+ foldGutter(),
73
+ drawSelection(),
74
+ highlightActiveLine(),
75
+ highlightActiveLineGutter(),
76
+ highlightSpecialChars(),
77
+ dropCursor(),
78
+ rectangularSelection(),
79
+ crosshairCursor(),
80
+ xml(),
81
+ theme,
82
+ EditorState.readOnly.of(readOnly),
83
+ EditorView.updateListener.of((view) => {
84
+ onChange(view)
85
+ // view.state.doc.toString() to receive the current content in the editor.
86
+ }),
87
+ ],
88
+ })
89
+
90
+ const view = new EditorView({
91
+ state :startState,
92
+ parent:editorRef.current,
93
+ })
94
+
95
+ return () => {
96
+ view.destroy()
97
+ }
98
+ }, [editorRef])
99
+
100
+ return (
101
+ <div
102
+ id={id}
103
+ ref={editorRef}
104
+ className={[
105
+ baseClassName,
106
+ componentClassName,
107
+ userClassName,
108
+ ]
109
+ .filter((e) => e)
110
+ .join(' ')}
111
+ style={{
112
+ '--height' :height,
113
+ '--gutter-width':gutterWidth,
114
+ ...style,
115
+ }}
116
+ />
117
+ )
118
+ }
119
+
120
+ XMLEditor.propTypes = {
121
+ /**
122
+ * The HTML id for this element
123
+ */
124
+ id:PropTypes.string,
125
+
126
+ /**
127
+ * The HTML class names for this element
128
+ */
129
+ className:PropTypes.string,
130
+
131
+ /**
132
+ * The React-written, css properties for this element.
133
+ */
134
+ style:PropTypes.objectOf(PropTypes.string),
135
+
136
+ /**
137
+ * Whether or not the content is read only.
138
+ */
139
+ readOnly:PropTypes.bool,
140
+
141
+ /**
142
+ * The initial labeling configuration.
143
+ */
144
+ config:PropTypes.string,
145
+
146
+ /**
147
+ * The height of the editor.
148
+ */
149
+ height:PropTypes.string,
150
+
151
+ /**
152
+ * The callback for when the labeling configuration changes.
153
+ */
154
+ onChange:PropTypes.func,
155
+
156
+ /**
157
+ * The width of the gutter.
158
+ */
159
+ gutterWidth:PropTypes.string,
160
+ }
161
+
162
+ XMLEditor.defaultProps = {
163
+ config:`<View>
164
+ <!--Edit this config to customize the labeling interface.-->
165
+ </View>
166
+ `,
167
+ height :'20em',
168
+ gutterWidth:'3em',
169
+ }
170
+
171
+ export default XMLEditor
@@ -0,0 +1 @@
1
+ export { default as theme } from './theme'
@@ -0,0 +1,184 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
2
+ import { EditorView } from '@codemirror/view'
3
+ import { HighlightStyle, syntaxHighlighting } from '@codemirror/language'
4
+ import { tags } from '@lezer/highlight'
5
+
6
+ // Using https://github.com/one-dark/vscode-one-dark-theme/ as reference for the colors
7
+ const chalky = '#e5c07b'
8
+ const coral = '#e06c75'
9
+ const cyan = '#56b6c2'
10
+ const invalid = '#ffffff'
11
+ const ivory = '#abb2bf'
12
+ const stone = '#7d8799' // Brightened compared to original to increase contrast
13
+ const malibu = '#61afef'
14
+ const sage = '#98c379'
15
+ const whiskey = '#d19a66'
16
+ const violet = '#c678dd'
17
+ const darkBackground = '#21252b'
18
+ const highlightBackground = '#2c313a'
19
+ const background = '#282c34'
20
+ const tooltipBackground = '#353a42'
21
+ const selection = '#3E4451'
22
+ const cursor = '#528bff'
23
+ /**
24
+ The colors used in the theme, as CSS color strings.
25
+ */
26
+ // const color = {
27
+ // chalky,
28
+ // coral,
29
+ // cyan,
30
+ // invalid,
31
+ // ivory,
32
+ // stone,
33
+ // malibu,
34
+ // sage,
35
+ // whiskey,
36
+ // violet,
37
+ // darkBackground,
38
+ // highlightBackground,
39
+ // background,
40
+ // tooltipBackground,
41
+ // selection,
42
+ // cursor
43
+ // };
44
+ /**
45
+ The editor theme styles for One Dark.
46
+ */
47
+ const oneDarkTheme = /* @__PURE__ */EditorView.theme({
48
+ '&':{
49
+ color :ivory,
50
+ backgroundColor:background,
51
+ },
52
+ '.cm-content':{
53
+ caretColor:cursor,
54
+ },
55
+ '.cm-cursor, .cm-dropCursor' :{ borderLeftColor: cursor },
56
+ '&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection':{ backgroundColor: selection },
57
+ '.cm-panels' :{ backgroundColor: darkBackground, color: ivory },
58
+ '.cm-panels.cm-panels-top' :{ borderBottom: '2px solid black' },
59
+ '.cm-panels.cm-panels-bottom' :{ borderTop: '2px solid black' },
60
+ '.cm-searchMatch' :{
61
+ backgroundColor:'#72a1ff59',
62
+ outline :'1px solid #457dff',
63
+ },
64
+ '.cm-searchMatch.cm-searchMatch-selected':{
65
+ backgroundColor:'#6199ff2f',
66
+ },
67
+ '.cm-activeLine' :{ backgroundColor: '#6699ff0b' },
68
+ '.cm-selectionMatch' :{ backgroundColor: '#aafe661a' },
69
+ '&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket':{
70
+ backgroundColor:'#bad0f847',
71
+ },
72
+ '.cm-gutters':{
73
+ backgroundColor:background,
74
+ color :stone,
75
+ border :'none',
76
+ },
77
+ '.cm-activeLineGutter':{
78
+ backgroundColor:highlightBackground,
79
+ },
80
+ '.cm-foldPlaceholder':{
81
+ backgroundColor:'transparent',
82
+ border :'none',
83
+ color :'#ddd',
84
+ },
85
+ '.cm-tooltip':{
86
+ border :'none',
87
+ backgroundColor:tooltipBackground,
88
+ },
89
+ '.cm-tooltip .cm-tooltip-arrow:before':{
90
+ borderTopColor :'transparent',
91
+ borderBottomColor:'transparent',
92
+ },
93
+ '.cm-tooltip .cm-tooltip-arrow:after':{
94
+ borderTopColor :tooltipBackground,
95
+ borderBottomColor:tooltipBackground,
96
+ },
97
+ '.cm-tooltip-autocomplete':{
98
+ '& > ul > li[aria-selected]':{
99
+ backgroundColor:highlightBackground,
100
+ color :ivory,
101
+ },
102
+ },
103
+ }, { dark: true })
104
+ /**
105
+ The highlighting style for code in the One Dark theme.
106
+ */
107
+ const oneDarkHighlightStyle = /* @__PURE__ */HighlightStyle.define([
108
+ {
109
+ tag :tags.keyword,
110
+ color:violet,
111
+ },
112
+ {
113
+ tag :[tags.name, tags.deleted, tags.character, tags.propertyName, tags.macroName],
114
+ color:coral,
115
+ },
116
+ {
117
+ tag :[/* @__PURE__ */tags.function(tags.variableName), tags.labelName],
118
+ color:malibu,
119
+ },
120
+ {
121
+ tag:[tags.color, /* @__PURE__ */tags.constant(tags.name), /* @__PURE__ */tags.standard(
122
+ tags.name)],
123
+ color:whiskey,
124
+ },
125
+ {
126
+ tag :[/* @__PURE__ */tags.definition(tags.name), tags.separator],
127
+ color:ivory,
128
+ },
129
+ {
130
+ tag:[tags.typeName, tags.className, tags.number, tags.changed,
131
+ tags.annotation, tags.modifier, tags.self, tags.namespace],
132
+ color:chalky,
133
+ },
134
+ {
135
+ tag:[tags.operator, tags.operatorKeyword, tags.url,
136
+ tags.escape, tags.regexp, tags.link, /* @__PURE__ */tags.special(tags.string)],
137
+ color:cyan,
138
+ },
139
+ {
140
+ tag :[tags.meta, tags.comment],
141
+ color:stone,
142
+ },
143
+ {
144
+ tag :tags.strong,
145
+ fontWeight:'bold',
146
+ },
147
+ {
148
+ tag :tags.emphasis,
149
+ fontStyle:'italic',
150
+ },
151
+ {
152
+ tag :tags.strikethrough,
153
+ textDecoration:'line-through',
154
+ },
155
+ {
156
+ tag :tags.link,
157
+ color :stone,
158
+ textDecoration:'underline',
159
+ },
160
+ {
161
+ tag :tags.heading,
162
+ fontWeight:'bold',
163
+ color :coral,
164
+ },
165
+ {
166
+ tag :[tags.atom, tags.bool, /* @__PURE__ */tags.special(tags.variableName)],
167
+ color:whiskey,
168
+ },
169
+ {
170
+ tag :[tags.processingInstruction, tags.string, tags.inserted],
171
+ color:sage,
172
+ },
173
+ {
174
+ tag :tags.invalid,
175
+ color:invalid,
176
+ },
177
+ ])
178
+ /**
179
+ Extension to enable the One Dark theme (both the editor theme and
180
+ the highlight style).
181
+ */
182
+ const oneDark = [oneDarkTheme, /* @__PURE__ */syntaxHighlighting(oneDarkHighlightStyle)]
183
+
184
+ export default oneDark
@@ -0,0 +1 @@
1
+ export { default as XMLEditor } from './XMLEditor'
@@ -0,0 +1,17 @@
1
+ @use "@pareto-engineering/bem";
2
+
3
+ .#{bem.$base}.code-editor {
4
+ border-radius: 1em;
5
+ height: var(--height);
6
+ overflow: auto;
7
+
8
+ > .cm-editor {
9
+ height: 100%;
10
+
11
+ .cm-gutters {
12
+ display: flex;
13
+ justify-content: flex-end;
14
+ width: var(--gutter-width);
15
+ }
16
+ }
17
+ }
package/src/ui/a/index.js CHANGED
@@ -25,3 +25,4 @@ export { AnimatedGradient } from './AnimatedGradient'
25
25
  export { TextSteps } from './TextSteps'
26
26
  export { Removable } from './Removable'
27
27
  export { ToggleSwitch } from './ToggleSwitch'
28
+ export { XMLEditor } from './XMLEditor'
@@ -27,6 +27,7 @@ const QueryCombobox = ({
27
27
  name,
28
28
  label,
29
29
  labelColor,
30
+ getTagColor,
30
31
  color,
31
32
  optional,
32
33
  description,
@@ -104,6 +105,7 @@ const QueryCombobox = ({
104
105
  name,
105
106
  label,
106
107
  labelColor,
108
+ getTagColor,
107
109
  optional,
108
110
  description,
109
111
  setValue,
@@ -233,6 +235,16 @@ QueryCombobox.propTypes = {
233
235
  * does not match any of the options
234
236
  */
235
237
  promptCreateNewOption:PropTypes.bool,
238
+
239
+ /**
240
+ * The placeholder text for the input
241
+ * */
242
+ placeholder:PropTypes.string,
243
+
244
+ /**
245
+ * The function to get the color of the tag
246
+ * */
247
+ getTagColor:PropTypes.func,
236
248
  }
237
249
 
238
250
  QueryCombobox.defaultProps = {
@@ -47,6 +47,7 @@ const MultipleCombobox = ({
47
47
  labelColor,
48
48
  name,
49
49
  optional,
50
+ getTagColor,
50
51
  options:items,
51
52
  getOptions,
52
53
  setValue,
@@ -206,7 +207,7 @@ const MultipleCombobox = ({
206
207
  removeSelectedItem(selectedItem)
207
208
  }}
208
209
  isCompact
209
- color={color}
210
+ color={getTagColor ? getTagColor(selectedItem) : color}
210
211
  >
211
212
  <span>{selectedItem.label}</span>
212
213
  <span className="icon close">Y</span>
@@ -356,6 +357,42 @@ MultipleCombobox.propTypes = {
356
357
  * The placeholder text for the input
357
358
  */
358
359
  placeholder:PropTypes.string,
360
+
361
+ /**
362
+ * The function to set the options of the custom select input
363
+ */
364
+ setOptions:PropTypes.func,
365
+
366
+ /**
367
+ * Whether to prompt the user to create a new option if the search input
368
+ * does not match any of the options
369
+ */
370
+ promptCreateNewOption:PropTypes.bool,
371
+
372
+ /**
373
+ * The function to get the color of the tag
374
+ */
375
+ getTagColor:PropTypes.func,
376
+
377
+ /**
378
+ * The color of the label
379
+ */
380
+ labelColor:PropTypes.string,
381
+
382
+ /**
383
+ * The function to validate the input
384
+ */
385
+ validate:PropTypes.func,
386
+
387
+ /**
388
+ * Whether to allow multiple items selection
389
+ */
390
+ multiple:PropTypes.bool,
391
+
392
+ /**
393
+ * The variable to be used to search the data
394
+ */
395
+ searchVariable:PropTypes.string,
359
396
  }
360
397
 
361
398
  MultipleCombobox.defaultProps = {