@coveord/plasma-mantine 52.17.3 → 52.19.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 (28) hide show
  1. package/.turbo/turbo-build.log +3 -3
  2. package/.turbo/turbo-test.log +32 -32
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/cjs/components/code-editor/CodeEditor.d.ts +3 -1
  5. package/dist/cjs/components/code-editor/CodeEditor.d.ts.map +1 -1
  6. package/dist/cjs/components/code-editor/CodeEditor.js +16 -3
  7. package/dist/cjs/components/code-editor/CodeEditor.js.map +1 -1
  8. package/dist/cjs/components/modal-wizard/ModalWizard.d.ts.map +1 -1
  9. package/dist/cjs/components/modal-wizard/ModalWizard.js +1 -0
  10. package/dist/cjs/components/modal-wizard/ModalWizard.js.map +1 -1
  11. package/dist/cjs/components/modal-wizard/ModalWizardStep.d.ts +4 -0
  12. package/dist/cjs/components/modal-wizard/ModalWizardStep.d.ts.map +1 -1
  13. package/dist/cjs/components/modal-wizard/ModalWizardStep.js.map +1 -1
  14. package/dist/esm/components/code-editor/CodeEditor.d.ts +3 -1
  15. package/dist/esm/components/code-editor/CodeEditor.d.ts.map +1 -1
  16. package/dist/esm/components/code-editor/CodeEditor.js +17 -4
  17. package/dist/esm/components/code-editor/CodeEditor.js.map +1 -1
  18. package/dist/esm/components/modal-wizard/ModalWizard.d.ts.map +1 -1
  19. package/dist/esm/components/modal-wizard/ModalWizard.js +1 -0
  20. package/dist/esm/components/modal-wizard/ModalWizard.js.map +1 -1
  21. package/dist/esm/components/modal-wizard/ModalWizardStep.d.ts +4 -0
  22. package/dist/esm/components/modal-wizard/ModalWizardStep.d.ts.map +1 -1
  23. package/dist/esm/components/modal-wizard/ModalWizardStep.js.map +1 -1
  24. package/package.json +3 -3
  25. package/src/components/code-editor/CodeEditor.tsx +15 -4
  26. package/src/components/modal-wizard/ModalWizard.tsx +1 -0
  27. package/src/components/modal-wizard/ModalWizardStep.tsx +5 -0
  28. package/src/components/modal-wizard/__tests__/ModalWizard.spec.tsx +53 -0
@@ -14,21 +14,25 @@ import {
14
14
  useComponentDefaultProps,
15
15
  } from '@mantine/core';
16
16
  import {useUncontrolled} from '@mantine/hooks';
17
+ import {editor as monacoEditor} from 'monaco-editor';
17
18
  import Editor, {loader, Monaco} from '@monaco-editor/react';
18
- import {FunctionComponent, useEffect, useState, useRef} from 'react';
19
+ import {FunctionComponent, useEffect, useRef, useState} from 'react';
19
20
 
20
21
  import {useParentHeight} from '../../hooks';
21
22
  import {XML} from './languages/xml';
22
23
  import {CopyToClipboard} from '../copyToClipboard';
23
24
  import {Search} from './search';
24
25
 
25
- const useStyles = createStyles((theme) => ({
26
+ const useStyles = createStyles((theme, {error}: {error?: boolean}) => ({
26
27
  root: {},
27
28
  editor: {
28
29
  border: `1px solid ${theme.colors.gray[2]}`,
29
30
  borderRadius: theme.defaultRadius,
30
31
  backgroundColor: theme.colorScheme === 'light' ? theme.white : theme.black,
31
32
  height: '100%',
33
+ outlineColor: error ? theme.colors.red[6] : null,
34
+ outlineStyle: error ? 'solid' : 'none',
35
+ outlineWidth: 'thin',
32
36
  },
33
37
  }));
34
38
 
@@ -109,7 +113,8 @@ export const CodeEditor: FunctionComponent<CodeEditorProps> = (props) => {
109
113
  ...others
110
114
  } = useComponentDefaultProps('CodeEditor', defaultProps, props);
111
115
  const [loaded, setLoaded] = useState(false);
112
- const {classes, theme} = useStyles();
116
+ const [containsError, setContainsError] = useState(false);
117
+ const {classes, theme} = useStyles({error: containsError});
113
118
  const [_value, handleChange] = useUncontrolled<string>({
114
119
  value,
115
120
  defaultValue,
@@ -118,7 +123,6 @@ export const CodeEditor: FunctionComponent<CodeEditorProps> = (props) => {
118
123
  });
119
124
  const [parentHeight, ref] = useParentHeight();
120
125
  const editorRef = useRef(null);
121
-
122
126
  const loadLocalMonaco = async () => {
123
127
  const monacoInstance = await import('monaco-editor');
124
128
  loader.config({monaco: monacoInstance});
@@ -147,6 +151,12 @@ export const CodeEditor: FunctionComponent<CodeEditorProps> = (props) => {
147
151
  }
148
152
  }, []);
149
153
 
154
+ const handleValidate = (markers: monacoEditor.IMarker[]) => {
155
+ setContainsError(
156
+ markers.some((marker) => marker.severity === loader.__getMonacoInstance().MarkerSeverity.Error),
157
+ );
158
+ };
159
+
150
160
  const _label = label ? (
151
161
  <Input.Label required={required} {...labelProps}>
152
162
  {label}
@@ -183,6 +193,7 @@ export const CodeEditor: FunctionComponent<CodeEditorProps> = (props) => {
183
193
  const _editor = loaded ? (
184
194
  <Box p="md" pl="xs" className={classes.editor}>
185
195
  <Editor
196
+ onValidate={handleValidate}
186
197
  defaultLanguage={language}
187
198
  theme={theme.colorScheme === 'light' ? 'light' : 'vs-dark'}
188
199
  options={{
@@ -230,6 +230,7 @@ export const ModalWizard: ModalWizardType = ({
230
230
  </Button>
231
231
 
232
232
  <Button
233
+ disabledTooltip={currentStep.props.disabledTooltipLabel}
233
234
  disabled={!isValid}
234
235
  onClick={() => {
235
236
  if (isLastStep) {
@@ -42,6 +42,11 @@ export interface ModalWizardStepProps {
42
42
  * @default true
43
43
  */
44
44
  countsAsProgress?: boolean;
45
+
46
+ /**
47
+ * Tooltip label of the next button when disabled
48
+ */
49
+ disabledTooltipLabel?: string;
45
50
  }
46
51
 
47
52
  const ModalWizardStep: FunctionComponent<PropsWithChildren<ModalWizardStepProps>> = ({children}) => <>{children}</>;
@@ -415,4 +415,57 @@ describe('ModalWizard', () => {
415
415
  await user.click(screen.getByRole('button', {name: /next/i}));
416
416
  expect(screen.getByRole('button', {name: /finish/i})).toBeDisabled();
417
417
  });
418
+
419
+ describe('disabledTooltipLabel props', () => {
420
+ it('display a tooltip when a step is invalid and a label is passed', async () => {
421
+ const user = userEvent.setup();
422
+
423
+ render(
424
+ <ModalWizard opened={true} onClose={vi.fn()}>
425
+ <ModalWizard.Step title="Step 1" showProgressBar={false} validateStep={() => ({isValid: true})}>
426
+ Content step 1
427
+ </ModalWizard.Step>
428
+ <ModalWizard.Step
429
+ title="Step 2"
430
+ validateStep={() => ({isValid: false})}
431
+ disabledTooltipLabel="test tooltip label"
432
+ >
433
+ Content step 2
434
+ </ModalWizard.Step>
435
+ </ModalWizard>,
436
+ );
437
+
438
+ expect(screen.getByRole('button', {name: /next/i})).toBeEnabled();
439
+ await user.click(screen.getByRole('button', {name: /next/i}));
440
+ const finishButton = screen.getByRole('button', {name: /finish/i});
441
+ expect(finishButton).toBeDisabled();
442
+ await user.hover(finishButton.parentElement);
443
+ expect(screen.getByText('test tooltip label')).toBeVisible();
444
+ });
445
+
446
+ it('does not display the tooltip if the step is validated even if the props is passed', async () => {
447
+ const user = userEvent.setup();
448
+ render(
449
+ <ModalWizard opened={true} onClose={vi.fn()}>
450
+ <ModalWizard.Step title="Step 1" showProgressBar={false} validateStep={() => ({isValid: true})}>
451
+ Content step 1
452
+ </ModalWizard.Step>
453
+ <ModalWizard.Step
454
+ title="Step 2"
455
+ validateStep={() => ({isValid: true})}
456
+ disabledTooltipLabel="test tooltip label"
457
+ >
458
+ Content step 2
459
+ </ModalWizard.Step>
460
+ </ModalWizard>,
461
+ );
462
+
463
+ expect(screen.getByRole('button', {name: /next/i})).toBeEnabled();
464
+ await user.click(screen.getByRole('button', {name: /next/i}));
465
+ const finishButton = screen.getByRole('button', {name: /finish/i});
466
+ expect(finishButton).toBeEnabled();
467
+ await user.hover(finishButton.parentElement);
468
+ expect(screen.queryByText('test tooltip label')).not.toBeInTheDocument();
469
+ });
470
+ });
418
471
  });