@coveord/plasma-mantine 52.7.0 → 52.8.0

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 (43) hide show
  1. package/.turbo/turbo-build.log +3 -3
  2. package/.turbo/turbo-test.log +31 -30
  3. package/__mocks__/@monaco-editor/react.tsx +10 -0
  4. package/dist/.tsbuildinfo +1 -1
  5. package/dist/cjs/components/code-editor/CodeEditor.d.ts.map +1 -1
  6. package/dist/cjs/components/code-editor/CodeEditor.js +18 -5
  7. package/dist/cjs/components/code-editor/CodeEditor.js.map +1 -1
  8. package/dist/cjs/components/code-editor/search/Search.d.ts +6 -0
  9. package/dist/cjs/components/code-editor/search/Search.d.ts.map +1 -0
  10. package/dist/cjs/components/code-editor/search/Search.js +31 -0
  11. package/dist/cjs/components/code-editor/search/Search.js.map +1 -0
  12. package/dist/cjs/components/code-editor/search/index.d.ts +2 -0
  13. package/dist/cjs/components/code-editor/search/index.d.ts.map +1 -0
  14. package/dist/cjs/components/code-editor/search/index.js +8 -0
  15. package/dist/cjs/components/code-editor/search/index.js.map +1 -0
  16. package/dist/cjs/components/table/index.d.ts +2 -2
  17. package/dist/cjs/components/table/index.d.ts.map +1 -1
  18. package/dist/cjs/components/table/index.js +3 -3
  19. package/dist/cjs/components/table/index.js.map +1 -1
  20. package/dist/cjs/components/table/layouts/TableLayouts.d.ts +1 -1
  21. package/dist/esm/components/code-editor/CodeEditor.d.ts.map +1 -1
  22. package/dist/esm/components/code-editor/CodeEditor.js +19 -6
  23. package/dist/esm/components/code-editor/CodeEditor.js.map +1 -1
  24. package/dist/esm/components/code-editor/search/Search.d.ts +6 -0
  25. package/dist/esm/components/code-editor/search/Search.d.ts.map +1 -0
  26. package/dist/esm/components/code-editor/search/Search.js +21 -0
  27. package/dist/esm/components/code-editor/search/Search.js.map +1 -0
  28. package/dist/esm/components/code-editor/search/index.d.ts +2 -0
  29. package/dist/esm/components/code-editor/search/index.d.ts.map +1 -0
  30. package/dist/esm/components/code-editor/search/index.js +3 -0
  31. package/dist/esm/components/code-editor/search/index.js.map +1 -0
  32. package/dist/esm/components/table/index.d.ts +2 -2
  33. package/dist/esm/components/table/index.d.ts.map +1 -1
  34. package/dist/esm/components/table/index.js +1 -1
  35. package/dist/esm/components/table/index.js.map +1 -1
  36. package/dist/esm/components/table/layouts/TableLayouts.d.ts +1 -1
  37. package/package.json +1 -1
  38. package/src/components/code-editor/CodeEditor.tsx +13 -4
  39. package/src/components/code-editor/__tests__/CodeEditor.spec.tsx +11 -2
  40. package/src/components/code-editor/search/Search.tsx +14 -0
  41. package/src/components/code-editor/search/__tests__/Search.unit.spec.tsx +16 -0
  42. package/src/components/code-editor/search/index.ts +1 -0
  43. package/src/components/table/index.ts +9 -2
@@ -1 +1 @@
1
- {"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../../../src/components/code-editor/CodeEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIH,YAAY,EAGZ,qBAAqB,EAGrB,SAAS,EAIZ,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAC,iBAAiB,EAAsB,MAAM,OAAO,CAAC;AAM7D,QAAA,MAAM,SAAS;;;;;;;CAQZ,CAAC;AAEJ,UAAU,eACN,SAAQ,IAAI,CAAC,qBAAqB,EAAE,gBAAgB,GAAG,mBAAmB,CAAC,EACvE,YAAY,CAAC,SAAS,CAAC,OAAO,SAAS,CAAC,CAAC;IAC7C;;;;OAIG;IACH,QAAQ,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,KAAK,CAAC;IAChE,2CAA2C;IAC3C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,qDAAqD;IACrD,OAAO,CAAC,IAAI,IAAI,CAAC;IACjB;;;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M,UAAU,EAAE,iBAAiB,CAAC,eAAe,CAyIzD,CAAC"}
@@ -23,6 +23,7 @@ var _react1 = require("react");
23
23
  var _hooks1 = require("../../hooks");
24
24
  var _xml = require("./languages/xml");
25
25
  var _copyToClipboard = require("../copyToClipboard");
26
+ var _search = require("./search");
26
27
  var useStyles = (0, _core.createStyles)(function(theme) {
27
28
  return {
28
29
  root: {},
@@ -68,6 +69,7 @@ var CodeEditor = function(props) {
68
69
  finalValue: ""
69
70
  }), 2), _value = _useUncontrolled[0], handleChange = _useUncontrolled[1];
70
71
  var _useParentHeight = _sliced_to_array._((0, _hooks1.useParentHeight)(), 2), parentHeight = _useParentHeight[0], ref = _useParentHeight[1];
72
+ var editorRef = (0, _react1.useRef)(null);
71
73
  var loadLocalMonaco = function() {
72
74
  var _ref = _async_to_generator._(function() {
73
75
  var monacoInstance;
@@ -101,6 +103,10 @@ var CodeEditor = function(props) {
101
103
  _xml.XML.register(monaco);
102
104
  }
103
105
  };
106
+ var handleSearch = function() {
107
+ editorRef.current.focus();
108
+ editorRef.current.trigger("editor", "actions.find", "");
109
+ };
104
110
  (0, _react1.useEffect)(function() {
105
111
  if (monacoLoader === "local") {
106
112
  loadLocalMonaco();
@@ -129,11 +135,17 @@ var CodeEditor = function(props) {
129
135
  _description
130
136
  ]
131
137
  }) : null;
132
- var _copyButton = /*#__PURE__*/ (0, _jsxruntime.jsx)(_core.Group, {
138
+ var _buttons = /*#__PURE__*/ (0, _jsxruntime.jsxs)(_core.Group, {
133
139
  position: "right",
134
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_copyToClipboard.CopyToClipboard, {
135
- value: _value
136
- })
140
+ spacing: 0,
141
+ children: [
142
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_search.Search, {
143
+ handleSearch: handleSearch
144
+ }),
145
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_copyToClipboard.CopyToClipboard, {
146
+ value: _value
147
+ })
148
+ ]
137
149
  });
138
150
  var _editor = loaded ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_core.Box, {
139
151
  p: "md",
@@ -157,6 +169,7 @@ var CodeEditor = function(props) {
157
169
  value: _value,
158
170
  onChange: handleChange,
159
171
  onMount: function(editor, monaco) {
172
+ editorRef.current = editor;
160
173
  registerLanguages(monaco);
161
174
  editor.onDidFocusEditorText(onFocus);
162
175
  editor.onDidBlurEditorText(/*#__PURE__*/ _async_to_generator._(function() {
@@ -193,7 +206,7 @@ var CodeEditor = function(props) {
193
206
  }, others), {
194
207
  children: [
195
208
  _header,
196
- _copyButton,
209
+ _buttons,
197
210
  _editor,
198
211
  _error
199
212
  ]
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/code-editor/CodeEditor.tsx"],"sourcesContent":["import {\n Box,\n Center,\n createStyles,\n DefaultProps,\n Group,\n Input,\n InputWrapperBaseProps,\n Loader,\n px,\n Selectors,\n Space,\n Stack,\n useComponentDefaultProps,\n} from '@mantine/core';\nimport {useUncontrolled} from '@mantine/hooks';\nimport Editor, {loader, Monaco} from '@monaco-editor/react';\nimport {FunctionComponent, useEffect, useState} from 'react';\n\nimport {useParentHeight} from '../../hooks';\nimport {XML} from './languages/xml';\nimport {CopyToClipboard} from '../copyToClipboard';\n\nconst useStyles = createStyles((theme) => ({\n root: {},\n editor: {\n border: `1px solid ${theme.colors.gray[2]}`,\n borderRadius: theme.defaultRadius,\n backgroundColor: theme.colorScheme === 'light' ? theme.white : theme.black,\n height: '100%',\n },\n}));\n\ninterface CodeEditorProps\n extends Omit<InputWrapperBaseProps, 'inputContainer' | 'inputWrapperOrder'>,\n DefaultProps<Selectors<typeof useStyles>> {\n /**\n * The language syntax of the editor\n *\n * @default 'plaintext'\n */\n language?: 'plaintext' | 'json' | 'markdown' | 'python' | 'xml';\n /** Default value for uncontrolled input */\n defaultValue?: string;\n /** Value for controlled input */\n value?: string;\n /** onChange value for controlled input */\n onChange?(value: string): void;\n /** Called whenever the code editor gets the focus */\n onFocus?(): void;\n /**\n * The minimal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height is too short, it will use this value as minimum.\n *\n * @default 300\n */\n minHeight?: number;\n /**\n * The maximal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height would be too high for your liking, you can use this prop to set a maximum.\n */\n maxHeight?: number;\n disabled?: boolean;\n /**\n * Defines how the monaco editor files will be loaded.\n * Note that using `'local'` requires [some additional configuration](https://github.com/suren-atoyan/monaco-react#use-monaco-editor-as-an-npm-package).\n *\n * @default 'local'\n */\n monacoLoader?: 'cdn' | 'local';\n}\n\nconst defaultProps: Partial<CodeEditorProps> = {\n language: 'plaintext',\n monacoLoader: 'local',\n defaultValue: '',\n minHeight: 300,\n};\n\nexport const CodeEditor: FunctionComponent<CodeEditorProps> = (props) => {\n const {\n language,\n defaultValue,\n onChange,\n onFocus,\n value,\n label,\n required,\n labelProps,\n error,\n errorProps,\n description,\n descriptionProps,\n minHeight,\n maxHeight,\n disabled,\n monacoLoader,\n ...others\n } = useComponentDefaultProps('CodeEditor', defaultProps, props);\n const [loaded, setLoaded] = useState(false);\n const {classes, theme} = useStyles();\n const [_value, handleChange] = useUncontrolled<string>({\n value,\n defaultValue,\n onChange,\n finalValue: '',\n });\n const [parentHeight, ref] = useParentHeight();\n\n const loadLocalMonaco = async () => {\n const monacoInstance = await import('monaco-editor');\n loader.config({monaco: monacoInstance});\n setLoaded(true);\n };\n\n const registerLanguages = (monaco: Monaco) => {\n if (monaco && language === 'xml') {\n XML.register(monaco);\n }\n };\n\n useEffect(() => {\n if (monacoLoader === 'local') {\n loadLocalMonaco();\n } else {\n setLoaded(true);\n }\n }, []);\n\n const _label = label ? (\n <Input.Label required={required} {...labelProps}>\n {label}\n </Input.Label>\n ) : null;\n\n const _description = description ? (\n <Input.Description {...descriptionProps}>{description}</Input.Description>\n ) : null;\n\n const _error = error ? (\n <Input.Error mt=\"xs\" {...errorProps}>\n {error}\n </Input.Error>\n ) : (\n <Space h=\"xs\" />\n );\n\n const _header =\n _label || _description ? (\n <Box>\n {_label}\n {_description}\n </Box>\n ) : null;\n\n const _copyButton = (\n <Group position=\"right\">\n <CopyToClipboard value={_value} />\n </Group>\n );\n\n const _editor = loaded ? (\n <Box p=\"md\" pl=\"xs\" className={classes.editor}>\n <Editor\n defaultLanguage={language}\n theme={theme.colorScheme === 'light' ? 'light' : 'vs-dark'}\n options={{\n minimap: {enabled: false},\n wordWrap: 'on',\n wrappingStrategy: 'advanced',\n scrollBeyondLastLine: false,\n formatOnPaste: true,\n fontSize: px(theme.fontSizes.xs),\n readOnly: disabled,\n tabSize: 2,\n }}\n value={_value}\n onChange={handleChange}\n onMount={(editor, monaco) => {\n registerLanguages(monaco);\n editor.onDidFocusEditorText(onFocus);\n editor.onDidBlurEditorText(async () => {\n await editor.getAction('editor.action.formatDocument').run();\n });\n }}\n />\n </Box>\n ) : (\n <Center className={classes.editor}>\n <Loader />\n </Center>\n );\n\n return (\n <Stack\n justify=\"flex-start\"\n className={classes.root}\n spacing={0}\n sx={{height: Math.max(parentHeight, minHeight), maxHeight}}\n ref={ref}\n {...others}\n >\n {_header}\n {_copyButton}\n {_editor}\n {_error}\n </Stack>\n );\n};\n"],"names":["CodeEditor","useStyles","createStyles","theme","root","editor","border","colors","gray","borderRadius","defaultRadius","backgroundColor","colorScheme","white","black","height","defaultProps","language","monacoLoader","defaultValue","minHeight","props","useComponentDefaultProps","onChange","onFocus","value","label","required","labelProps","error","errorProps","description","descriptionProps","maxHeight","disabled","others","useState","loaded","setLoaded","classes","useUncontrolled","finalValue","_value","handleChange","useParentHeight","parentHeight","ref","loadLocalMonaco","monacoInstance","loader","config","monaco","registerLanguages","XML","register","useEffect","_label","Input","Label","_description","Description","_error","Error","mt","Space","h","_header","Box","_copyButton","Group","position","CopyToClipboard","_editor","p","pl","className","Editor","defaultLanguage","options","minimap","enabled","wordWrap","wrappingStrategy","scrollBeyondLastLine","formatOnPaste","fontSize","px","fontSizes","xs","readOnly","tabSize","onMount","onDidFocusEditorText","onDidBlurEditorText","getAction","run","Center","Loader","Stack","justify","spacing","sx","Math","max"],"mappings":";;;;+BAmFaA;;;eAAAA;;;;;;;;;;;oBArEN;qBACuB;+DACO;sBACgB;sBAEvB;mBACZ;+BACY;AAE9B,IAAMC,YAAYC,IAAAA,oBAAa,SAACC;WAAW;QACvCC,MAAM,CAAC;QACPC,QAAQ;YACJC,QAAQ,AAAC,aAAiC,OAArBH,MAAMI,OAAOC,IAAI,CAAC,EAAE;YACzCC,cAAcN,MAAMO;YACpBC,iBAAiBR,MAAMS,gBAAgB,UAAUT,MAAMU,QAAQV,MAAMW;YACrEC,QAAQ;QACZ;IACJ;;AA6CA,IAAMC,eAAyC;IAC3CC,UAAU;IACVC,cAAc;IACdC,cAAc;IACdC,WAAW;AACf;AAEO,IAAMpB,aAAiD,SAACqB;IAC3D,IAkBIC,4BAAAA,IAAAA,gCAAyB,cAAcN,cAAcK,QAjBrDJ,WAiBAK,0BAjBAL,UACAE,eAgBAG,0BAhBAH,cACAI,WAeAD,0BAfAC,UACAC,UAcAF,0BAdAE,SACAC,QAaAH,0BAbAG,OACAC,QAYAJ,0BAZAI,OACAC,WAWAL,0BAXAK,UACAC,aAUAN,0BAVAM,YACAC,QASAP,0BATAO,OACAC,aAQAR,0BARAQ,YACAC,cAOAT,0BAPAS,aACAC,mBAMAV,0BANAU,kBACAZ,YAKAE,0BALAF,WACAa,YAIAX,0BAJAW,WACAC,WAGAZ,0BAHAY,UACAhB,eAEAI,0BAFAJ,cACGiB,sCACHb;QAjBAL;QACAE;QACAI;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAZ;QACAa;QACAC;QACAhB;;IAGJ,IAA4BkB,+BAAAA,IAAAA,kBAAS,YAA9BC,SAAqBD,cAAbE,YAAaF;IAC5B,IAAyBnC,aAAAA,aAAlBsC,UAAkBtC,WAAlBsC,SAASpC,QAASF,WAATE;IAChB,IA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B;gBACtBC,eAAe;gBACfC,UAAUC,IAAAA,UAAGnF,MAAMoF,UAAUC;gBAC7BC,UAAUvD;gBACVwD,SAAS;YACb;YACAjE,OAAOiB;YACPnB,UAAUoB;YACVgD,SAAS,SAACtF,QAAQ8C;gBACdC,kBAAkBD;gBAClB9C,OAAOuF,qBAAqBpE;gBAC5BnB,OAAOwF,kCAAoB,sBAAA;;;;gCACvB;;oCAAMxF,OAAOyF,UAAU,gCAAgCC;;;gCAAvD;;;;;;gBACJ;YACJ;;uBAIR,qBAACC;QAAOrB,WAAWpC,QAAQlC;kBACvB,cAAA,qBAAC4F;;IAIT,qBACI,sBAACC;QACGC,SAAQ;QACRxB,WAAWpC,QAAQnC;QACnBgG,SAAS;QACTC,IAAI;YAACtF,QAAQuF,KAAKC,IAAI1D,cAAczB;YAAYa,WAAAA;QAAS;QACzDa,KAAKA;OACDX;;YAEH+B;YACAE;YACAI;YACAX;;;AAGb"}
1
+ {"version":3,"sources":["../../../../src/components/code-editor/CodeEditor.tsx"],"sourcesContent":["import {\n Box,\n Center,\n createStyles,\n DefaultProps,\n Group,\n Input,\n InputWrapperBaseProps,\n Loader,\n px,\n Selectors,\n Space,\n Stack,\n useComponentDefaultProps,\n} from '@mantine/core';\nimport {useUncontrolled} from '@mantine/hooks';\nimport Editor, {loader, Monaco} from '@monaco-editor/react';\nimport {FunctionComponent, useEffect, useState, useRef} from 'react';\n\nimport {useParentHeight} from '../../hooks';\nimport {XML} from './languages/xml';\nimport {CopyToClipboard} from '../copyToClipboard';\nimport {Search} from './search';\n\nconst useStyles = createStyles((theme) => ({\n root: {},\n editor: {\n border: `1px solid ${theme.colors.gray[2]}`,\n borderRadius: theme.defaultRadius,\n backgroundColor: theme.colorScheme === 'light' ? theme.white : theme.black,\n height: '100%',\n },\n}));\n\ninterface CodeEditorProps\n extends Omit<InputWrapperBaseProps, 'inputContainer' | 'inputWrapperOrder'>,\n DefaultProps<Selectors<typeof useStyles>> {\n /**\n * The language syntax of the editor\n *\n * @default 'plaintext'\n */\n language?: 'plaintext' | 'json' | 'markdown' | 'python' | 'xml';\n /** Default value for uncontrolled input */\n defaultValue?: string;\n /** Value for controlled input */\n value?: string;\n /** onChange value for controlled input */\n onChange?(value: string): void;\n /** Called whenever the code editor gets the focus */\n onFocus?(): void;\n /**\n * The minimal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height is too short, it will use this value as minimum.\n *\n * @default 300\n */\n minHeight?: number;\n /**\n * The maximal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height would be too high for your liking, you can use this prop to set a maximum.\n */\n maxHeight?: number;\n disabled?: boolean;\n /**\n * Defines how the monaco editor files will be loaded.\n * Note that using `'local'` requires [some additional configuration](https://github.com/suren-atoyan/monaco-react#use-monaco-editor-as-an-npm-package).\n *\n * @default 'local'\n */\n monacoLoader?: 'cdn' | 'local';\n}\n\nconst defaultProps: Partial<CodeEditorProps> = {\n language: 'plaintext',\n monacoLoader: 'local',\n defaultValue: '',\n minHeight: 300,\n};\n\nexport const CodeEditor: FunctionComponent<CodeEditorProps> = (props) => {\n const {\n language,\n defaultValue,\n onChange,\n onFocus,\n value,\n label,\n required,\n labelProps,\n error,\n errorProps,\n description,\n descriptionProps,\n minHeight,\n maxHeight,\n disabled,\n monacoLoader,\n ...others\n } = useComponentDefaultProps('CodeEditor', defaultProps, props);\n const [loaded, setLoaded] = useState(false);\n const {classes, theme} = useStyles();\n const [_value, handleChange] = useUncontrolled<string>({\n value,\n defaultValue,\n onChange,\n finalValue: '',\n });\n const [parentHeight, ref] = useParentHeight();\n const editorRef = useRef(null);\n\n const loadLocalMonaco = async () => {\n const monacoInstance = await import('monaco-editor');\n loader.config({monaco: monacoInstance});\n setLoaded(true);\n };\n\n const registerLanguages = (monaco: Monaco) => {\n if (monaco && language === 'xml') {\n XML.register(monaco);\n }\n };\n\n const handleSearch = () => {\n editorRef.current.focus();\n editorRef.current.trigger('editor', 'actions.find', '');\n };\n\n useEffect(() => {\n if (monacoLoader === 'local') {\n loadLocalMonaco();\n } else {\n setLoaded(true);\n }\n }, []);\n\n const _label = label ? (\n <Input.Label required={required} {...labelProps}>\n {label}\n </Input.Label>\n ) : null;\n\n const _description = description ? (\n <Input.Description {...descriptionProps}>{description}</Input.Description>\n ) : null;\n\n const _error = error ? (\n <Input.Error mt=\"xs\" {...errorProps}>\n {error}\n </Input.Error>\n ) : (\n <Space h=\"xs\" />\n );\n\n const _header =\n _label || _description ? (\n <Box>\n {_label}\n {_description}\n </Box>\n ) : null;\n\n const _buttons = (\n <Group position=\"right\" spacing={0}>\n <Search handleSearch={handleSearch} />\n <CopyToClipboard value={_value} />\n </Group>\n );\n\n const _editor = loaded ? (\n <Box p=\"md\" pl=\"xs\" className={classes.editor}>\n <Editor\n defaultLanguage={language}\n theme={theme.colorScheme === 'light' ? 'light' : 'vs-dark'}\n options={{\n minimap: {enabled: false},\n wordWrap: 'on',\n wrappingStrategy: 'advanced',\n scrollBeyondLastLine: false,\n formatOnPaste: true,\n fontSize: px(theme.fontSizes.xs),\n readOnly: disabled,\n tabSize: 2,\n }}\n value={_value}\n onChange={handleChange}\n onMount={(editor, monaco) => {\n editorRef.current = editor;\n registerLanguages(monaco);\n editor.onDidFocusEditorText(onFocus);\n editor.onDidBlurEditorText(async () => {\n await editor.getAction('editor.action.formatDocument').run();\n });\n }}\n />\n </Box>\n ) : (\n <Center className={classes.editor}>\n <Loader />\n </Center>\n );\n\n return (\n <Stack\n justify=\"flex-start\"\n className={classes.root}\n spacing={0}\n sx={{height: Math.max(parentHeight, minHeight), maxHeight}}\n ref={ref}\n {...others}\n >\n {_header}\n {_buttons}\n {_editor}\n {_error}\n </Stack>\n );\n};\n"],"names":["CodeEditor","useStyles","createStyles","theme","root","editor","border","colors","gray","borderRadius","defaultRadius","backgroundColor","colorScheme","white","black","height","defaultProps","language","monacoLoader","defaultValue","minHeight","props","useComponentDefaultProps","onChange","onFocus","value","label","required","labelProps","error","errorProps","description","descriptionProps","maxHeight","disabled","others","useState","loaded","setLoaded","classes","useUncontrolled","finalValue","_value","handleChange","useParentHeight","parentHeight","ref","editorRef","useRef","loadLocalMonaco","monacoInstance","loader","config","monaco","registerLanguages","XML","register","handleSearch","current","focus","trigger","useEffect","_label","Input","Label","_description","Description","_error","Error","mt","Space","h","_header","Box","_buttons","Group","position","spacing","Search","CopyToClipboard","_editor","p","pl","className","Editor","defaultLanguage","options","minimap","enabled","wordWrap","wrappingStrategy","scrollBeyondLastLine","formatOnPaste","fontSize","px","fontSizes","xs","readOnly","tabSize","onMount","onDidFocusEditorText","onDidBlurEditorText","getAction","run","Center","Loader","Stack","justify","sx","Math","max"],"mappings":";;;;+BAoFaA;;;eAAAA;;;;;;;;;;;oBAtEN;qBACuB;+DACO;sBACwB;sBAE/B;mBACZ;+BACY;sBACT;AAErB,IAAMC,YAAYC,IAAAA,oBAAa,SAACC;WAAW;QACvCC,MAAM,CAAC;QACPC,QAAQ;YACJC,QAAQ,AAAC,aAAiC,OAArBH,MAAMI,OAAOC,IAAI,CAAC,EAAE;YACzCC,cAAcN,MAAMO;YACpBC,iBAAiBR,MAAMS,gBAAgB,UAAUT,MAAMU,QAAQV,MAAMW;YACrEC,QAAQ;QACZ;IACJ;;AA6CA,IAAMC,eAAyC;IAC3CC,UAAU;IACVC,cAAc;IACdC,cAAc;IACdC,WAAW;AACf;AAEO,IAAMpB,aAAiD,SAACqB;IAC3D,IAkBIC,4BAAAA,IAAAA,gCAAyB,cAAcN,cAAcK,QAjBrDJ,WAiBAK,0BAjBAL,UACAE,eAgBAG,0BAhBAH,cACAI,WAeAD,0BAfAC,UACAC,UAcAF,0BAdAE,SACAC,QAaAH,0BAbAG,OACAC,QAYAJ,0BAZAI,OACAC,WAWAL,0BAXAK,UACAC,aAUAN,0BAVAM,YACAC,QASAP,0BATAO,OACAC,aAQAR,0BARAQ,YACAC,cAOAT,0BAPAS,aACAC,mBAMAV,0BANAU,kBAC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BAACkC,YAAMK;QAAMC,IAAG;OAASvC;kBACpBD;wBAGL,qBAACyC;QAAMC,GAAE;;IAGb,IAAMC,UACFV,UAAUG,6BACN,sBAACQ;;YACIX;YACAG;;SAEL;IAER,IAAMS,yBACF,sBAACC;QAAMC,UAAS;QAAQC,SAAS;;0BAC7B,qBAACC;gBAAOrB,cAAcA;;0BACtB,qBAACsB;gBAAgBtD,OAAOiB;;;;IAIhC,IAAMsC,UAAU3C,uBACZ,qBAACoC;QAAIQ,GAAE;QAAKC,IAAG;QAAKC,WAAW5C,QAAQlC;kBACnC,cAAA,qBAAC+E;YACGC,iBAAiBpE;YACjBd,OAAOA,MAAMS,gBAAgB,UAAU,UAAU;YACjD0E,SAAS;gBACLC,SAAS;oBAACC,SAAS;gBAAK;gBACxBC,UAAU;gBACVC,kBAAkB;gBAClBC,sBAAsB;gBACtBC,eAAe;gBACfC,UAAUC,IAAAA,UAAG3F,MAAM4F,UAAUC;gBAC7BC,UAAU/D;gBACVgE,SAAS;YACb;YACAzE,OAAOiB;YACPnB,UAAUoB;YACVwD,SAAS,SAAC9F,QAAQgD;gBACdN,UAAUW,UAAUrD;gBACpBiD,kBAAkBD;gBAClBhD,OAAO+F,qBAAqB5E;gBAC5BnB,OAAOgG,kCAAoB,sBAAA;;;;gCACvB;;oCAAMhG,OAAOiG,UAAU,gCAAgCC;;;gCAAvD;;;;;;gBACJ;YACJ;;uBAIR,qBAACC;QAAOrB,WAAW5C,QAAQlC;kBACvB,cAAA,qBAACoG;;IAIT,qBACI,sBAACC;QACGC,SAAQ;QACRxB,WAAW5C,QAAQnC;QACnByE,SAAS;QACT+B,IAAI;YAAC7F,QAAQ8F,KAAKC,IAAIjE,cAAczB;YAAYa,WAAAA;QAAS;QACzDa,KAAKA;OACDX;;YAEHqC;YACAE;YACAM;YACAb;;;AAGb"}
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export interface SearchProps {
3
+ handleSearch: () => void;
4
+ }
5
+ export declare const Search: React.FunctionComponent<SearchProps>;
6
+ //# sourceMappingURL=Search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Search.d.ts","sourceRoot":"","sources":["../../../../../src/components/code-editor/search/Search.tsx"],"names":[],"mappings":";AAGA,MAAM,WAAW,WAAW;IACxB,YAAY,EAAE,MAAM,IAAI,CAAC;CAC5B;AAQD,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,iBAAiB,CAAC,WAAW,CAAiD,CAAC"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "Search", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return Search;
9
+ }
10
+ });
11
+ var _extends = require("@swc/helpers/_/_extends");
12
+ var _object_destructuring_empty = require("@swc/helpers/_/_object_destructuring_empty");
13
+ var _object_spread = require("@swc/helpers/_/_object_spread");
14
+ var _jsxruntime = require("react/jsx-runtime");
15
+ var _plasmareacticons = require("@coveord/plasma-react-icons");
16
+ var _core = require("@mantine/core");
17
+ var SearchButton = function(param) {
18
+ var handleSearch = param.handleSearch;
19
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_core.ActionIcon, {
20
+ onClick: handleSearch,
21
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_plasmareacticons.SearchSize16Px, {
22
+ height: 16
23
+ })
24
+ });
25
+ };
26
+ var Search = function(_param) /*#__PURE__*/ {
27
+ var params = _extends._({}, _object_destructuring_empty._(_param));
28
+ return (0, _jsxruntime.jsx)(SearchButton, _object_spread._({}, params));
29
+ };
30
+
31
+ //# sourceMappingURL=Search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/components/code-editor/search/Search.tsx"],"sourcesContent":["import {SearchSize16Px} from '@coveord/plasma-react-icons';\nimport {ActionIcon} from '@mantine/core';\n\nexport interface SearchProps {\n handleSearch: () => void;\n}\n\nconst SearchButton: React.FunctionComponent<SearchProps> = ({handleSearch}) => (\n <ActionIcon onClick={handleSearch}>\n <SearchSize16Px height={16}></SearchSize16Px>\n </ActionIcon>\n);\n\nexport const Search: React.FunctionComponent<SearchProps> = ({...params}) => <SearchButton {...params} />;\n"],"names":["Search","SearchButton","handleSearch","ActionIcon","onClick","SearchSize16Px","height","params"],"mappings":";;;;+BAaaA;;;eAAAA;;;;;;;gCAbgB;oBACJ;AAMzB,IAAMC,eAAqD;QAAEC,qBAAAA;yBACzD,qBAACC;QAAWC,SAASF;kBACjB,cAAA,qBAACG;YAAeC,QAAQ;;;;AAIzB,IAAMN,SAA+C;QAAKO;WAAY,qBAACN,mCAAiBM;AAAS"}
@@ -0,0 +1,2 @@
1
+ export * from './Search';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/code-editor/search/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ var _export_star = require("@swc/helpers/_/_export_star");
6
+ _export_star._(require("./Search"), exports);
7
+
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/components/code-editor/search/index.ts"],"sourcesContent":["export * from './Search';\n"],"names":[],"mappings":";;;;;uBAAc"}
@@ -1,5 +1,5 @@
1
1
  export * from './Table';
2
2
  export { useTable } from './TableContext';
3
- export { type onTableChangeEvent, type InitialTableState, type TableState, type TableProps } from './Table.types';
4
- export { TableLayouts } from './layouts/TableLayouts';
3
+ export { type onTableChangeEvent, type InitialTableState, type TableState, type TableProps, type TableLayout, type TableLayoutProps, } from './Table.types';
4
+ export { flexRender as renderTableCell } from '@tanstack/react-table';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAC,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAC,MAAM,eAAe,CAAC;AAChH,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACxC,OAAO,EACH,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,gBAAgB,GACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,UAAU,IAAI,eAAe,EAAC,MAAM,uBAAuB,CAAC"}
@@ -12,13 +12,13 @@ _export(exports, {
12
12
  useTable: function() {
13
13
  return _TableContext.useTable;
14
14
  },
15
- TableLayouts: function() {
16
- return _TableLayouts.TableLayouts;
15
+ renderTableCell: function() {
16
+ return _reacttable.flexRender;
17
17
  }
18
18
  });
19
19
  var _export_star = require("@swc/helpers/_/_export_star");
20
20
  _export_star._(require("./Table"), exports);
21
21
  var _TableContext = require("./TableContext");
22
- var _TableLayouts = require("./layouts/TableLayouts");
22
+ var _reacttable = require("@tanstack/react-table");
23
23
 
24
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/table/index.ts"],"sourcesContent":["export * from './Table';\nexport {useTable} from './TableContext';\nexport {type onTableChangeEvent, type InitialTableState, type TableState, type TableProps} from './Table.types';\nexport {TableLayouts} from './layouts/TableLayouts';\n"],"names":["useTable","TableLayouts"],"mappings":";;;;;;;;;;;IACQA,QAAQ;eAARA;;IAEAC,YAAY;eAAZA;;;;uBAHM;4BACS;4BAEI"}
1
+ {"version":3,"sources":["../../../../src/components/table/index.ts"],"sourcesContent":["export * from './Table';\nexport {useTable} from './TableContext';\nexport {\n type onTableChangeEvent,\n type InitialTableState,\n type TableState,\n type TableProps,\n type TableLayout,\n type TableLayoutProps,\n} from './Table.types';\nexport {flexRender as renderTableCell} from '@tanstack/react-table';\n"],"names":["useTable","renderTableCell","flexRender"],"mappings":";;;;;;;;;;;IACQA,QAAQ;eAARA;;IAScC,eAAe;eAA7BC;;;;uBAVM;4BACS;0BASqB"}
@@ -1,4 +1,4 @@
1
1
  export declare const TableLayouts: {
2
- Rows: import("../Table.types").TableLayout;
2
+ Rows: import("..").TableLayout;
3
3
  };
4
4
  //# sourceMappingURL=TableLayouts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../../../src/components/code-editor/CodeEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIH,YAAY,EAGZ,qBAAqB,EAGrB,SAAS,EAIZ,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAC,iBAAiB,EAAsB,MAAM,OAAO,CAAC;AAM7D,QAAA,MAAM,SAAS;;;;;;;CAQZ,CAAC;AAEJ,UAAU,eACN,SAAQ,IAAI,CAAC,qBAAqB,EAAE,gBAAgB,GAAG,mBAAmB,CAAC,EACvE,YAAY,CAAC,SAAS,CAAC,OAAO,SAAS,CAAC,CAAC;IAC7C;;;;OAIG;IACH,QAAQ,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,KAAK,CAAC;IAChE,2CAA2C;IAC3C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,qDAAqD;IACrD,OAAO,CAAC,IAAI,IAAI,CAAC;IACjB;;;;;;;OAOG;IACH,S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AAiB,CAAC,eAAe,CAyIzD,CAAC"}
@@ -8,10 +8,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
8
  import { Box, Center, createStyles, Group, Input, Loader, px, Space, Stack, useComponentDefaultProps } from "@mantine/core";
9
9
  import { useUncontrolled } from "@mantine/hooks";
10
10
  import Editor, { loader } from "@monaco-editor/react";
11
- import { useEffect, useState } from "react";
11
+ import { useEffect, useState, useRef } from "react";
12
12
  import { useParentHeight } from "../../hooks";
13
13
  import { XML } from "./languages/xml";
14
14
  import { CopyToClipboard } from "../copyToClipboard";
15
+ import { Search } from "./search";
15
16
  var useStyles = createStyles(function(theme) {
16
17
  return {
17
18
  root: {},
@@ -57,6 +58,7 @@ export var CodeEditor = function(props) {
57
58
  finalValue: ""
58
59
  }), 2), _value = _useUncontrolled[0], handleChange = _useUncontrolled[1];
59
60
  var _useParentHeight = _sliced_to_array(useParentHeight(), 2), parentHeight = _useParentHeight[0], ref = _useParentHeight[1];
61
+ var editorRef = useRef(null);
60
62
  var loadLocalMonaco = function() {
61
63
  var _ref = _async_to_generator(function() {
62
64
  var monacoInstance;
@@ -88,6 +90,10 @@ export var CodeEditor = function(props) {
88
90
  XML.register(monaco);
89
91
  }
90
92
  };
93
+ var handleSearch = function() {
94
+ editorRef.current.focus();
95
+ editorRef.current.trigger("editor", "actions.find", "");
96
+ };
91
97
  useEffect(function() {
92
98
  if (monacoLoader === "local") {
93
99
  loadLocalMonaco();
@@ -116,11 +122,17 @@ export var CodeEditor = function(props) {
116
122
  _description
117
123
  ]
118
124
  }) : null;
119
- var _copyButton = /*#__PURE__*/ _jsx(Group, {
125
+ var _buttons = /*#__PURE__*/ _jsxs(Group, {
120
126
  position: "right",
121
- children: /*#__PURE__*/ _jsx(CopyToClipboard, {
122
- value: _value
123
- })
127
+ spacing: 0,
128
+ children: [
129
+ /*#__PURE__*/ _jsx(Search, {
130
+ handleSearch: handleSearch
131
+ }),
132
+ /*#__PURE__*/ _jsx(CopyToClipboard, {
133
+ value: _value
134
+ })
135
+ ]
124
136
  });
125
137
  var _editor = loaded ? /*#__PURE__*/ _jsx(Box, {
126
138
  p: "md",
@@ -144,6 +156,7 @@ export var CodeEditor = function(props) {
144
156
  value: _value,
145
157
  onChange: handleChange,
146
158
  onMount: function(editor, monaco) {
159
+ editorRef.current = editor;
147
160
  registerLanguages(monaco);
148
161
  editor.onDidFocusEditorText(onFocus);
149
162
  editor.onDidBlurEditorText(/*#__PURE__*/ _async_to_generator(function() {
@@ -180,7 +193,7 @@ export var CodeEditor = function(props) {
180
193
  }, others), {
181
194
  children: [
182
195
  _header,
183
- _copyButton,
196
+ _buttons,
184
197
  _editor,
185
198
  _error
186
199
  ]
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/code-editor/CodeEditor.tsx"],"sourcesContent":["import {\n Box,\n Center,\n createStyles,\n DefaultProps,\n Group,\n Input,\n InputWrapperBaseProps,\n Loader,\n px,\n Selectors,\n Space,\n Stack,\n useComponentDefaultProps,\n} from '@mantine/core';\nimport {useUncontrolled} from '@mantine/hooks';\nimport Editor, {loader, Monaco} from '@monaco-editor/react';\nimport {FunctionComponent, useEffect, useState} from 'react';\n\nimport {useParentHeight} from '../../hooks';\nimport {XML} from './languages/xml';\nimport {CopyToClipboard} from '../copyToClipboard';\n\nconst useStyles = createStyles((theme) => ({\n root: {},\n editor: {\n border: `1px solid ${theme.colors.gray[2]}`,\n borderRadius: theme.defaultRadius,\n backgroundColor: theme.colorScheme === 'light' ? theme.white : theme.black,\n height: '100%',\n },\n}));\n\ninterface CodeEditorProps\n extends Omit<InputWrapperBaseProps, 'inputContainer' | 'inputWrapperOrder'>,\n DefaultProps<Selectors<typeof useStyles>> {\n /**\n * The language syntax of the editor\n *\n * @default 'plaintext'\n */\n language?: 'plaintext' | 'json' | 'markdown' | 'python' | 'xml';\n /** Default value for uncontrolled input */\n defaultValue?: string;\n /** Value for controlled input */\n value?: string;\n /** onChange value for controlled input */\n onChange?(value: string): void;\n /** Called whenever the code editor gets the focus */\n onFocus?(): void;\n /**\n * The minimal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height is too short, it will use this value as minimum.\n *\n * @default 300\n */\n minHeight?: number;\n /**\n * The maximal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height would be too high for your liking, you can use this prop to set a maximum.\n */\n maxHeight?: number;\n disabled?: boolean;\n /**\n * Defines how the monaco editor files will be loaded.\n * Note that using `'local'` requires [some additional configuration](https://github.com/suren-atoyan/monaco-react#use-monaco-editor-as-an-npm-package).\n *\n * @default 'local'\n */\n monacoLoader?: 'cdn' | 'local';\n}\n\nconst defaultProps: Partial<CodeEditorProps> = {\n language: 'plaintext',\n monacoLoader: 'local',\n defaultValue: '',\n minHeight: 300,\n};\n\nexport const CodeEditor: FunctionComponent<CodeEditorProps> = (props) => {\n const {\n language,\n defaultValue,\n onChange,\n onFocus,\n value,\n label,\n required,\n labelProps,\n error,\n errorProps,\n description,\n descriptionProps,\n minHeight,\n maxHeight,\n disabled,\n monacoLoader,\n ...others\n } = useComponentDefaultProps('CodeEditor', defaultProps, props);\n const [loaded, setLoaded] = useState(false);\n const {classes, theme} = useStyles();\n const [_value, handleChange] = useUncontrolled<string>({\n value,\n defaultValue,\n onChange,\n finalValue: '',\n });\n const [parentHeight, ref] = useParentHeight();\n\n const loadLocalMonaco = async () => {\n const monacoInstance = await import('monaco-editor');\n loader.config({monaco: monacoInstance});\n setLoaded(true);\n };\n\n const registerLanguages = (monaco: Monaco) => {\n if (monaco && language === 'xml') {\n XML.register(monaco);\n }\n };\n\n useEffect(() => {\n if (monacoLoader === 'local') {\n loadLocalMonaco();\n } else {\n setLoaded(true);\n }\n }, []);\n\n const _label = label ? (\n <Input.Label required={required} {...labelProps}>\n {label}\n </Input.Label>\n ) : null;\n\n const _description = description ? (\n <Input.Description {...descriptionProps}>{description}</Input.Description>\n ) : null;\n\n const _error = error ? (\n <Input.Error mt=\"xs\" {...errorProps}>\n {error}\n </Input.Error>\n ) : (\n <Space h=\"xs\" />\n );\n\n const _header =\n _label || _description ? (\n <Box>\n {_label}\n {_description}\n </Box>\n ) : null;\n\n const _copyButton = (\n <Group position=\"right\">\n <CopyToClipboard value={_value} />\n </Group>\n );\n\n const _editor = loaded ? (\n <Box p=\"md\" pl=\"xs\" className={classes.editor}>\n <Editor\n defaultLanguage={language}\n theme={theme.colorScheme === 'light' ? 'light' : 'vs-dark'}\n options={{\n minimap: {enabled: false},\n wordWrap: 'on',\n wrappingStrategy: 'advanced',\n scrollBeyondLastLine: false,\n formatOnPaste: true,\n fontSize: px(theme.fontSizes.xs),\n readOnly: disabled,\n tabSize: 2,\n }}\n value={_value}\n onChange={handleChange}\n onMount={(editor, monaco) => {\n registerLanguages(monaco);\n editor.onDidFocusEditorText(onFocus);\n editor.onDidBlurEditorText(async () => {\n await editor.getAction('editor.action.formatDocument').run();\n });\n }}\n />\n </Box>\n ) : (\n <Center className={classes.editor}>\n <Loader />\n </Center>\n );\n\n return (\n <Stack\n justify=\"flex-start\"\n className={classes.root}\n spacing={0}\n sx={{height: Math.max(parentHeight, minHeight), maxHeight}}\n ref={ref}\n {...others}\n >\n {_header}\n {_copyButton}\n {_editor}\n {_error}\n </Stack>\n );\n};\n"],"names":["Box","Center","createStyles","Group","Input","Loader","px","Space","Stack","useComponentDefaultProps","useUncontrolled","Editor","loader","useEffect","useState","useParentHeight","XML","CopyToClipboard","useStyles","theme","root","editor","border","colors","gray","borderRadius","defaultRadius","backgroundColor","colorScheme","white","black","height","defaultProps","language","monacoLoader","defaultValue","minHeight","CodeEditor","props","onChange","onFocus","value","label","required","labelProps","error","errorProps","description","descriptionProps","maxHeight","disabled","others","loaded","setLoaded","classes","finalValue","_value","handleChange","parentHeight","ref","loadLocalMonaco","monacoInstance","config","monaco","registerLanguages","register","_label","Label","_description","Description","_error","Error","mt","h","_header","_copyButton","position","_editor","p","pl","className","defaultLanguage","options","minimap","enabled","wordWrap","wrappingStrategy","scrollBeyondLastLine","formatOnPaste","fontSize","fontSizes","xs","readOnly","tabSize","onMount","onDidFocusEditorText","onDidBlurEditorText","getAction","run","justify","spacing","sx","Math","max"],"mappings":";;;;;;;AAAA,SACIA,GAAG,EACHC,MAAM,EACNC,YAAY,EAEZC,KAAK,EACLC,KAAK,EAELC,MAAM,EACNC,EAAE,EAEFC,KAAK,EACLC,KAAK,EACLC,wBAAwB,QACrB,gBAAgB;AACvB,SAAQC,eAAe,QAAO,iBAAiB;AAC/C,OAAOC,UAASC,MAAM,QAAe,uBAAuB;AAC5D,SAA2BC,SAAS,EAAEC,QAAQ,QAAO,QAAQ;AAE7D,SAAQC,eAAe,QAAO,cAAc;AAC5C,SAAQC,GAAG,QAAO,kBAAkB;AACpC,SAAQC,eAAe,QAAO,qBAAqB;AAEnD,IAAMC,YAAYhB,aAAa,SAACiB;WAAW;QACvCC,MAAM,CAAC;QACPC,QAAQ;YACJC,QAAQ,AAAC,aAAiC,OAArBH,MAAMI,OAAOC,IAAI,CAAC,EAAE;YACzCC,cAAcN,MAAMO;YACpBC,iBAAiBR,MAAMS,gBAAgB,UAAUT,MAAMU,QAAQV,MAAMW;YACrEC,QAAQ;QACZ;IACJ;;AA6CA,IAAMC,eAAyC;IAC3CC,UAAU;IACVC,cAAc;IACdC,cAAc;IACdC,WAAW;AACf;AAEA,OAAO,IAAMC,aAAiD,SAACC;IAC3D,IAkBI7B,4BAAAA,yBAAyB,cAAcuB,cAAcM,QAjBrDL,WAiBAxB,0BAjBAwB,UACAE,eAgBA1B,0BAhBA0B,cACAI,WAeA9B,0BAfA8B,UACAC,UAcA/B,0BAdA+B,SACAC,QAaAhC,0BAbAgC,OACAC,QAYAjC,0BAZAiC,OACAC,WAWAlC,0BAXAkC,UACAC,aAUAnC,0BAVAmC,YACAC,QASApC,0BATAoC,OACAC,aAQArC,0BARAqC,YACAC,cAOAtC,0BAPAsC,aACAC,mBAMAvC,0BANAuC,kBACAZ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,IAAMO,4BACF,KAACxE;QAAMyE,UAAS;kBACZ,cAAA,KAAC3D;YAAgBwB,OAAOe;;;IAIhC,IAAMqB,UAAUzB,uBACZ,KAACpD;QAAI8E,GAAE;QAAKC,IAAG;QAAKC,WAAW1B,QAAQjC;kBACnC,cAAA,KAACV;YACGsE,iBAAiBhD;YACjBd,OAAOA,MAAMS,gBAAgB,UAAU,UAAU;YACjDsD,SAAS;gBACLC,SAAS;oBAACC,SAAS;gBAAK;gBACxBC,UAAU;gBACVC,kBAAkB;gBAClBC,sBAAsB;gBACtBC,eAAe;gBACfC,UAAUnF,GAAGa,MAAMuE,UAAUC;gBAC7BC,UAAU1C;gBACV2C,SAAS;YACb;YACApD,OAAOe;YACPjB,UAAUkB;YACVqC,SAAS,SAACzE,QAAQ0C;gBACdC,kBAAkBD;gBAClB1C,OAAO0E,qBAAqBvD;gBAC5BnB,OAAO2E,kCAAoB,oBAAA;;;;gCACvB;;oCAAM3E,OAAO4E,UAAU,gCAAgCC;;;gCAAvD;;;;;;gBACJ;YACJ;;uBAIR,KAACjG;QAAO+E,WAAW1B,QAAQjC;kBACvB,cAAA,KAAChB;;IAIT,qBACI,MAACG;QACG2F,SAAQ;QACRnB,WAAW1B,QAAQlC;QACnBgF,SAAS;QACTC,IAAI;YAACtE,QAAQuE,KAAKC,IAAI7C,cAActB;YAAYa,WAAAA;QAAS;QACzDU,KAAKA;OACDR;;YAEHuB;YACAC;YACAE;YACAP;;;AAGb,EAAE"}
1
+ {"version":3,"sources":["../../../../src/components/code-editor/CodeEditor.tsx"],"sourcesContent":["import {\n Box,\n Center,\n createStyles,\n DefaultProps,\n Group,\n Input,\n InputWrapperBaseProps,\n Loader,\n px,\n Selectors,\n Space,\n Stack,\n useComponentDefaultProps,\n} from '@mantine/core';\nimport {useUncontrolled} from '@mantine/hooks';\nimport Editor, {loader, Monaco} from '@monaco-editor/react';\nimport {FunctionComponent, useEffect, useState, useRef} from 'react';\n\nimport {useParentHeight} from '../../hooks';\nimport {XML} from './languages/xml';\nimport {CopyToClipboard} from '../copyToClipboard';\nimport {Search} from './search';\n\nconst useStyles = createStyles((theme) => ({\n root: {},\n editor: {\n border: `1px solid ${theme.colors.gray[2]}`,\n borderRadius: theme.defaultRadius,\n backgroundColor: theme.colorScheme === 'light' ? theme.white : theme.black,\n height: '100%',\n },\n}));\n\ninterface CodeEditorProps\n extends Omit<InputWrapperBaseProps, 'inputContainer' | 'inputWrapperOrder'>,\n DefaultProps<Selectors<typeof useStyles>> {\n /**\n * The language syntax of the editor\n *\n * @default 'plaintext'\n */\n language?: 'plaintext' | 'json' | 'markdown' | 'python' | 'xml';\n /** Default value for uncontrolled input */\n defaultValue?: string;\n /** Value for controlled input */\n value?: string;\n /** onChange value for controlled input */\n onChange?(value: string): void;\n /** Called whenever the code editor gets the focus */\n onFocus?(): void;\n /**\n * The minimal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height is too short, it will use this value as minimum.\n *\n * @default 300\n */\n minHeight?: number;\n /**\n * The maximal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height would be too high for your liking, you can use this prop to set a maximum.\n */\n maxHeight?: number;\n disabled?: boolean;\n /**\n * Defines how the monaco editor files will be loaded.\n * Note that using `'local'` requires [some additional configuration](https://github.com/suren-atoyan/monaco-react#use-monaco-editor-as-an-npm-package).\n *\n * @default 'local'\n */\n monacoLoader?: 'cdn' | 'local';\n}\n\nconst defaultProps: Partial<CodeEditorProps> = {\n language: 'plaintext',\n monacoLoader: 'local',\n defaultValue: '',\n minHeight: 300,\n};\n\nexport const CodeEditor: FunctionComponent<CodeEditorProps> = (props) => {\n const {\n language,\n defaultValue,\n onChange,\n onFocus,\n value,\n label,\n required,\n labelProps,\n error,\n errorProps,\n description,\n descriptionProps,\n minHeight,\n maxHeight,\n disabled,\n monacoLoader,\n ...others\n } = useComponentDefaultProps('CodeEditor', defaultProps, props);\n const [loaded, setLoaded] = useState(false);\n const {classes, theme} = useStyles();\n const [_value, handleChange] = useUncontrolled<string>({\n value,\n defaultValue,\n onChange,\n finalValue: '',\n });\n const [parentHeight, ref] = useParentHeight();\n const editorRef = useRef(null);\n\n const loadLocalMonaco = async () => {\n const monacoInstance = await import('monaco-editor');\n loader.config({monaco: monacoInstance});\n setLoaded(true);\n };\n\n const registerLanguages = (monaco: Monaco) => {\n if (monaco && language === 'xml') {\n XML.register(monaco);\n }\n };\n\n const handleSearch = () => {\n editorRef.current.focus();\n editorRef.current.trigger('editor', 'actions.find', '');\n };\n\n useEffect(() => {\n if (monacoLoader === 'local') {\n loadLocalMonaco();\n } else {\n setLoaded(true);\n }\n }, []);\n\n const _label = label ? (\n <Input.Label required={required} {...labelProps}>\n {label}\n </Input.Label>\n ) : null;\n\n const _description = description ? (\n <Input.Description {...descriptionProps}>{description}</Input.Description>\n ) : null;\n\n const _error = error ? (\n <Input.Error mt=\"xs\" {...errorProps}>\n {error}\n </Input.Error>\n ) : (\n <Space h=\"xs\" />\n );\n\n const _header =\n _label || _description ? (\n <Box>\n {_label}\n {_description}\n </Box>\n ) : null;\n\n const _buttons = (\n <Group position=\"right\" spacing={0}>\n <Search handleSearch={handleSearch} />\n <CopyToClipboard value={_value} />\n </Group>\n );\n\n const _editor = loaded ? (\n <Box p=\"md\" pl=\"xs\" className={classes.editor}>\n <Editor\n defaultLanguage={language}\n theme={theme.colorScheme === 'light' ? 'light' : 'vs-dark'}\n options={{\n minimap: {enabled: false},\n wordWrap: 'on',\n wrappingStrategy: 'advanced',\n scrollBeyondLastLine: false,\n formatOnPaste: true,\n fontSize: px(theme.fontSizes.xs),\n readOnly: disabled,\n tabSize: 2,\n }}\n value={_value}\n onChange={handleChange}\n onMount={(editor, monaco) => {\n editorRef.current = editor;\n registerLanguages(monaco);\n editor.onDidFocusEditorText(onFocus);\n editor.onDidBlurEditorText(async () => {\n await editor.getAction('editor.action.formatDocument').run();\n });\n }}\n />\n </Box>\n ) : (\n <Center className={classes.editor}>\n <Loader />\n </Center>\n );\n\n return (\n <Stack\n justify=\"flex-start\"\n className={classes.root}\n spacing={0}\n sx={{height: Math.max(parentHeight, minHeight), maxHeight}}\n ref={ref}\n {...others}\n >\n {_header}\n {_buttons}\n {_editor}\n {_error}\n </Stack>\n );\n};\n"],"names":["Box","Center","createStyles","Group","Input","Loader","px","Space","Stack","useComponentDefaultProps","useUncontrolled","Editor","loader","useEffect","useState","useRef","useParentHeight","XML","CopyToClipboard","Search","useStyles","theme","root","editor","border","colors","gray","borderRadius","defaultRadius","backgroundColor","colorScheme","white","black","height","defaultProps","language","monacoLoader","defaultValue","minHeight","CodeEditor","props","onChange","onFocus","value","label","required","labelProps","error","errorProps","description","descriptionProps","maxHeight","disabled","others","loaded","setLoaded","classes","finalValue","_value","handleChange","parentHeight","ref","editorRef","loadLocalMonaco","monacoInstance","config","monaco","registerLanguages","register","handleSearch","current","focus","trigger","_label","Label","_description","Description","_error","Error","mt","h","_header","_buttons","position","spacing","_editor","p","pl","className","defaultLanguage","options","minimap","enabled","wordWrap","wrappingStrategy","scrollBeyondLastLine","formatOnPaste","fontSize","fontSizes","xs","readOnly","tabSize","onMount","onDidFocusEditorText","onDidBlurEditorText","getAction","run","justify","sx","Math","max"],"mappings":";;;;;;;AAAA,SACIA,GAAG,EACHC,MAAM,EACNC,YAAY,EAEZC,KAAK,EACLC,KAAK,EAELC,MAAM,EACNC,EAAE,EAEFC,KAAK,EACLC,KAAK,EACLC,wBAAwB,QACrB,gBAAgB;AACvB,SAAQC,eAAe,QAAO,iBAAiB;AAC/C,OAAOC,UAASC,MAAM,QAAe,uBAAuB;AAC5D,SAA2BC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,QAAO,QAAQ;AAErE,SAAQC,eAAe,QAAO,cAAc;AAC5C,SAAQC,GAAG,QAAO,kBAAkB;AACpC,SAAQC,eAAe,QAAO,qBAAqB;AACnD,SAAQC,MAAM,QAAO,WAAW;AAEhC,IAAMC,YAAYlB,aAA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Ge,MAAM6E,UAAUC;gBAC7BC,UAAUhD;gBACViD,SAAS;YACb;YACA1D,OAAOe;YACPjB,UAAUkB;YACV2C,SAAS,SAAC/E,QAAQ2C;gBACdJ,UAAUQ,UAAU/C;gBACpB4C,kBAAkBD;gBAClB3C,OAAOgF,qBAAqB7D;gBAC5BnB,OAAOiF,kCAAoB,oBAAA;;;;gCACvB;;oCAAMjF,OAAOkF,UAAU,gCAAgCC;;;gCAAvD;;;;;;gBACJ;YACJ;;uBAIR,KAACzG;QAAOuF,WAAWhC,QAAQjC;kBACvB,cAAA,KAAClB;;IAIT,qBACI,MAACG;QACGmG,SAAQ;QACRnB,WAAWhC,QAAQlC;QACnB8D,SAAS;QACTwB,IAAI;YAAC3E,QAAQ4E,KAAKC,IAAIlD,cAActB;YAAYa,WAAAA;QAAS;QACzDU,KAAKA;OACDR;;YAEH4B;YACAC;YACAG;YACAR;;;AAGb,EAAE"}
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export interface SearchProps {
3
+ handleSearch: () => void;
4
+ }
5
+ export declare const Search: React.FunctionComponent<SearchProps>;
6
+ //# sourceMappingURL=Search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Search.d.ts","sourceRoot":"","sources":["../../../../../src/components/code-editor/search/Search.tsx"],"names":[],"mappings":";AAGA,MAAM,WAAW,WAAW;IACxB,YAAY,EAAE,MAAM,IAAI,CAAC;CAC5B;AAQD,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,iBAAiB,CAAC,WAAW,CAAiD,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ import { _ as _object_destructuring_empty } from "@swc/helpers/_/_object_destructuring_empty";
3
+ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { SearchSize16Px } from "@coveord/plasma-react-icons";
6
+ import { ActionIcon } from "@mantine/core";
7
+ var SearchButton = function(param) {
8
+ var handleSearch = param.handleSearch;
9
+ return /*#__PURE__*/ _jsx(ActionIcon, {
10
+ onClick: handleSearch,
11
+ children: /*#__PURE__*/ _jsx(SearchSize16Px, {
12
+ height: 16
13
+ })
14
+ });
15
+ };
16
+ export var Search = function(_param) /*#__PURE__*/ {
17
+ var params = _extends({}, _object_destructuring_empty(_param));
18
+ return _jsx(SearchButton, _object_spread({}, params));
19
+ };
20
+
21
+ //# sourceMappingURL=Search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/components/code-editor/search/Search.tsx"],"sourcesContent":["import {SearchSize16Px} from '@coveord/plasma-react-icons';\nimport {ActionIcon} from '@mantine/core';\n\nexport interface SearchProps {\n handleSearch: () => void;\n}\n\nconst SearchButton: React.FunctionComponent<SearchProps> = ({handleSearch}) => (\n <ActionIcon onClick={handleSearch}>\n <SearchSize16Px height={16}></SearchSize16Px>\n </ActionIcon>\n);\n\nexport const Search: React.FunctionComponent<SearchProps> = ({...params}) => <SearchButton {...params} />;\n"],"names":["SearchSize16Px","ActionIcon","SearchButton","handleSearch","onClick","height","Search","params"],"mappings":";;;;AAAA,SAAQA,cAAc,QAAO,8BAA8B;AAC3D,SAAQC,UAAU,QAAO,gBAAgB;AAMzC,IAAMC,eAAqD;QAAEC,qBAAAA;yBACzD,KAACF;QAAWG,SAASD;kBACjB,cAAA,KAACH;YAAeK,QAAQ;;;;AAIhC,OAAO,IAAMC,SAA+C;QAAKC;WAAY,KAACL,iCAAiBK;AAAS,EAAE"}
@@ -0,0 +1,2 @@
1
+ export * from './Search';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/code-editor/search/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./Search";
2
+
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/components/code-editor/search/index.ts"],"sourcesContent":["export * from './Search';\n"],"names":[],"mappings":"AAAA,cAAc,WAAW"}
@@ -1,5 +1,5 @@
1
1
  export * from './Table';
2
2
  export { useTable } from './TableContext';
3
- export { type onTableChangeEvent, type InitialTableState, type TableState, type TableProps } from './Table.types';
4
- export { TableLayouts } from './layouts/TableLayouts';
3
+ export { type onTableChangeEvent, type InitialTableState, type TableState, type TableProps, type TableLayout, type TableLayoutProps, } from './Table.types';
4
+ export { flexRender as renderTableCell } from '@tanstack/react-table';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAC,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAC,MAAM,eAAe,CAAC;AAChH,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACxC,OAAO,EACH,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,gBAAgB,GACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,UAAU,IAAI,eAAe,EAAC,MAAM,uBAAuB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  export * from "./Table";
2
2
  export { useTable } from "./TableContext";
3
- export { TableLayouts } from "./layouts/TableLayouts";
3
+ export { flexRender as renderTableCell } from "@tanstack/react-table";
4
4
 
5
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/table/index.ts"],"sourcesContent":["export * from './Table';\nexport {useTable} from './TableContext';\nexport {type onTableChangeEvent, type InitialTableState, type TableState, type TableProps} from './Table.types';\nexport {TableLayouts} from './layouts/TableLayouts';\n"],"names":["useTable","TableLayouts"],"mappings":"AAAA,cAAc,UAAU;AACxB,SAAQA,QAAQ,QAAO,iBAAiB;AAExC,SAAQC,YAAY,QAAO,yBAAyB"}
1
+ {"version":3,"sources":["../../../../src/components/table/index.ts"],"sourcesContent":["export * from './Table';\nexport {useTable} from './TableContext';\nexport {\n type onTableChangeEvent,\n type InitialTableState,\n type TableState,\n type TableProps,\n type TableLayout,\n type TableLayoutProps,\n} from './Table.types';\nexport {flexRender as renderTableCell} from '@tanstack/react-table';\n"],"names":["useTable","flexRender","renderTableCell"],"mappings":"AAAA,cAAc,UAAU;AACxB,SAAQA,QAAQ,QAAO,iBAAiB;AASxC,SAAQC,cAAcC,eAAe,QAAO,wBAAwB"}
@@ -1,4 +1,4 @@
1
1
  export declare const TableLayouts: {
2
- Rows: import("../Table.types").TableLayout;
2
+ Rows: import("..").TableLayout;
3
3
  };
4
4
  //# sourceMappingURL=TableLayouts.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coveord/plasma-mantine",
3
- "version": "52.7.0",
3
+ "version": "52.8.0",
4
4
  "description": "A Plasma flavoured Mantine theme",
5
5
  "keywords": [
6
6
  "plasma",
@@ -15,11 +15,12 @@ import {
15
15
  } from '@mantine/core';
16
16
  import {useUncontrolled} from '@mantine/hooks';
17
17
  import Editor, {loader, Monaco} from '@monaco-editor/react';
18
- import {FunctionComponent, useEffect, useState} from 'react';
18
+ import {FunctionComponent, useEffect, useState, useRef} from 'react';
19
19
 
20
20
  import {useParentHeight} from '../../hooks';
21
21
  import {XML} from './languages/xml';
22
22
  import {CopyToClipboard} from '../copyToClipboard';
23
+ import {Search} from './search';
23
24
 
24
25
  const useStyles = createStyles((theme) => ({
25
26
  root: {},
@@ -110,6 +111,7 @@ export const CodeEditor: FunctionComponent<CodeEditorProps> = (props) => {
110
111
  finalValue: '',
111
112
  });
112
113
  const [parentHeight, ref] = useParentHeight();
114
+ const editorRef = useRef(null);
113
115
 
114
116
  const loadLocalMonaco = async () => {
115
117
  const monacoInstance = await import('monaco-editor');
@@ -123,6 +125,11 @@ export const CodeEditor: FunctionComponent<CodeEditorProps> = (props) => {
123
125
  }
124
126
  };
125
127
 
128
+ const handleSearch = () => {
129
+ editorRef.current.focus();
130
+ editorRef.current.trigger('editor', 'actions.find', '');
131
+ };
132
+
126
133
  useEffect(() => {
127
134
  if (monacoLoader === 'local') {
128
135
  loadLocalMonaco();
@@ -157,8 +164,9 @@ export const CodeEditor: FunctionComponent<CodeEditorProps> = (props) => {
157
164
  </Box>
158
165
  ) : null;
159
166
 
160
- const _copyButton = (
161
- <Group position="right">
167
+ const _buttons = (
168
+ <Group position="right" spacing={0}>
169
+ <Search handleSearch={handleSearch} />
162
170
  <CopyToClipboard value={_value} />
163
171
  </Group>
164
172
  );
@@ -181,6 +189,7 @@ export const CodeEditor: FunctionComponent<CodeEditorProps> = (props) => {
181
189
  value={_value}
182
190
  onChange={handleChange}
183
191
  onMount={(editor, monaco) => {
192
+ editorRef.current = editor;
184
193
  registerLanguages(monaco);
185
194
  editor.onDidFocusEditorText(onFocus);
186
195
  editor.onDidBlurEditorText(async () => {
@@ -205,7 +214,7 @@ export const CodeEditor: FunctionComponent<CodeEditorProps> = (props) => {
205
214
  {...others}
206
215
  >
207
216
  {_header}
208
- {_copyButton}
217
+ {_buttons}
209
218
  {_editor}
210
219
  {_error}
211
220
  </Stack>
@@ -1,5 +1,5 @@
1
1
  import {loader} from '@monaco-editor/react';
2
- import {render, screen, waitForElementToBeRemoved} from '@test-utils';
2
+ import {render, screen, userEvent, waitForElementToBeRemoved} from '@test-utils';
3
3
  import {useForm} from '../../../form';
4
4
 
5
5
  import {CodeEditor} from '../CodeEditor';
@@ -13,7 +13,7 @@ describe('CodeEditor', () => {
13
13
  vi.clearAllMocks();
14
14
  });
15
15
 
16
- it('renders the monaco editor and a copy to clipboard button', async () => {
16
+ it('renders the monaco editor, a copy to clipboard button and a search button', async () => {
17
17
  render(<CodeEditor label="label" description="description" />);
18
18
 
19
19
  await waitForElementToBeRemoved(screen.queryByRole('presentation'));
@@ -22,6 +22,7 @@ describe('CodeEditor', () => {
22
22
  expect(screen.getByText(/description/)).toBeInTheDocument();
23
23
  expect(await screen.findByTestId('monaco-editor')).toBeInTheDocument();
24
24
  expect(await screen.findByRole('button', {name: /copy/i})).toBeInTheDocument();
25
+ expect(await screen.findByRole('button', {name: /search/i})).toBeInTheDocument();
25
26
  });
26
27
 
27
28
  it('shows validation errors underneath the code editor', async () => {
@@ -60,4 +61,12 @@ describe('CodeEditor', () => {
60
61
  render(<CodeEditor label="label" description="description" monacoLoader="cdn" language="xml" />);
61
62
  expect(xmlLanguageSpy).toHaveBeenCalledTimes(1);
62
63
  });
64
+
65
+ it('focus and triggers search on the Monaco editor when handleSearch is called', async () => {
66
+ const user = userEvent.setup();
67
+ render(<CodeEditor />);
68
+ await user.click(screen.getByRole('button', {name: /search/i}));
69
+ expect(screen.getByTestId('monaco-editor')).toHaveAttribute('focus');
70
+ expect(screen.getByTestId('monaco-editor')).toHaveAttribute('trigger');
71
+ });
63
72
  });
@@ -0,0 +1,14 @@
1
+ import {SearchSize16Px} from '@coveord/plasma-react-icons';
2
+ import {ActionIcon} from '@mantine/core';
3
+
4
+ export interface SearchProps {
5
+ handleSearch: () => void;
6
+ }
7
+
8
+ const SearchButton: React.FunctionComponent<SearchProps> = ({handleSearch}) => (
9
+ <ActionIcon onClick={handleSearch}>
10
+ <SearchSize16Px height={16}></SearchSize16Px>
11
+ </ActionIcon>
12
+ );
13
+
14
+ export const Search: React.FunctionComponent<SearchProps> = ({...params}) => <SearchButton {...params} />;