@eccenca/gui-elements 24.0.0-rc.3 → 24.0.0-rc.4
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.
- package/CHANGELOG.md +5 -0
- package/dist/cjs/cmem/markdown/Markdown.js +6 -4
- package/dist/cjs/cmem/markdown/Markdown.js.map +1 -1
- package/dist/cjs/components/AutoSuggestion/AutoSuggestion.js +4 -2
- package/dist/cjs/components/AutoSuggestion/AutoSuggestion.js.map +1 -1
- package/dist/cjs/components/MultiSelect/MultiSelect.js +27 -1
- package/dist/cjs/components/MultiSelect/MultiSelect.js.map +1 -1
- package/dist/cjs/extensions/codemirror/CodeMirror.js +4 -3
- package/dist/cjs/extensions/codemirror/CodeMirror.js.map +1 -1
- package/dist/esm/cmem/markdown/Markdown.js +6 -4
- package/dist/esm/cmem/markdown/Markdown.js.map +1 -1
- package/dist/esm/components/AutoSuggestion/AutoSuggestion.js +4 -2
- package/dist/esm/components/AutoSuggestion/AutoSuggestion.js.map +1 -1
- package/dist/esm/components/MultiSelect/MultiSelect.js +29 -3
- package/dist/esm/components/MultiSelect/MultiSelect.js.map +1 -1
- package/dist/esm/extensions/codemirror/CodeMirror.js +4 -3
- package/dist/esm/extensions/codemirror/CodeMirror.js.map +1 -1
- package/dist/types/components/MultiSelect/MultiSelect.d.ts +7 -1
- package/dist/types/extensions/codemirror/CodeMirror.d.ts +2 -2
- package/package.json +25 -25
- package/src/cmem/markdown/Markdown.stories.tsx +6 -0
- package/src/cmem/markdown/Markdown.tsx +8 -4
- package/src/components/Application/_config.scss +1 -1
- package/src/components/AutoSuggestion/AutoSuggestion.scss +21 -8
- package/src/components/AutoSuggestion/AutoSuggestion.tsx +20 -15
- package/src/components/Breadcrumb/breadcrumb.scss +8 -1
- package/src/components/MultiSelect/MultiSelect.tsx +37 -0
- package/src/components/MultiSuggestField/MultiSuggestField.stories.tsx +22 -19
- package/src/components/MultiSuggestField/_multisuggestfield.scss +8 -0
- package/src/components/MultiSuggestField/tests/MultiSuggestField.test.tsx +103 -9
- package/src/components/TextField/textfield.scss +1 -2
- package/src/components/Typography/typography.scss +10 -0
- package/src/components/index.scss +1 -1
- package/src/extensions/_index.scss +1 -6
- package/src/extensions/codemirror/CodeMirror.tsx +10 -7
- package/src/extensions/codemirror/_codemirror.scss +1 -1
- package/src/index.scss +0 -1
|
@@ -6,10 +6,10 @@ import "@testing-library/jest-dom";
|
|
|
6
6
|
import { MultiSuggestField } from "../../../../index";
|
|
7
7
|
import { CustomSearch, Default, dropdownOnFocus, predefinedNotControlledValues } from "../MultiSuggestField.stories";
|
|
8
8
|
|
|
9
|
-
const testLabels = ["label1", "label2", "label3", "label4", "label5"];
|
|
9
|
+
//const testLabels = ["label1", "label2", "label3", "label4", "label5"];
|
|
10
10
|
|
|
11
|
-
const items = new Array(
|
|
12
|
-
const testLabel =
|
|
11
|
+
const items = new Array(50).fill(undefined).map((_, id) => {
|
|
12
|
+
const testLabel = `label${id + 1}`;
|
|
13
13
|
return { testLabel, testId: `${testLabel}-id` };
|
|
14
14
|
});
|
|
15
15
|
|
|
@@ -108,7 +108,7 @@ describe("MultiSuggestField", () => {
|
|
|
108
108
|
expect(menuItems.length).toBe(dropdownOnFocus.args.items.length);
|
|
109
109
|
});
|
|
110
110
|
|
|
111
|
-
fireEvent.change(input, { target: { value: "
|
|
111
|
+
fireEvent.change(input, { target: { value: "cras" } });
|
|
112
112
|
|
|
113
113
|
await waitFor(() => {
|
|
114
114
|
const listbox = screen.getByRole("listbox");
|
|
@@ -277,7 +277,7 @@ describe("MultiSuggestField", () => {
|
|
|
277
277
|
expect(menuItems.length).toBe(CustomSearch.args.items.length);
|
|
278
278
|
});
|
|
279
279
|
|
|
280
|
-
fireEvent.change(input, { target: { value: "
|
|
280
|
+
fireEvent.change(input, { target: { value: "label11" } });
|
|
281
281
|
|
|
282
282
|
await waitFor(() => {
|
|
283
283
|
const listbox = screen.getByRole("listbox");
|
|
@@ -289,10 +289,10 @@ describe("MultiSuggestField", () => {
|
|
|
289
289
|
const item = menuItems[0];
|
|
290
290
|
|
|
291
291
|
const [div] = item.getElementsByTagName("div");
|
|
292
|
-
expect(div.textContent).toBe("
|
|
292
|
+
expect(div.textContent).toBe("label11");
|
|
293
293
|
});
|
|
294
294
|
|
|
295
|
-
fireEvent.change(input, { target: { value: "
|
|
295
|
+
fireEvent.change(input, { target: { value: "label11-id" } });
|
|
296
296
|
|
|
297
297
|
await waitFor(() => {
|
|
298
298
|
const listbox = screen.getByRole("listbox");
|
|
@@ -304,10 +304,10 @@ describe("MultiSuggestField", () => {
|
|
|
304
304
|
const item = menuItems[0];
|
|
305
305
|
|
|
306
306
|
const [div] = item.getElementsByTagName("div");
|
|
307
|
-
expect(div.textContent).toBe("
|
|
307
|
+
expect(div.textContent).toBe("label11");
|
|
308
308
|
});
|
|
309
309
|
|
|
310
|
-
fireEvent.change(input, { target: { value: "
|
|
310
|
+
fireEvent.change(input, { target: { value: "label11-id-other" } });
|
|
311
311
|
|
|
312
312
|
await waitFor(() => {
|
|
313
313
|
const listbox = screen.getByRole("listbox");
|
|
@@ -549,5 +549,99 @@ describe("MultiSuggestField", () => {
|
|
|
549
549
|
const tagsAfterRemove = container.querySelectorAll("span[data-tag-index]");
|
|
550
550
|
expect(tagsAfterRemove.length).toBe(0);
|
|
551
551
|
});
|
|
552
|
+
|
|
553
|
+
it("should not contain the custom css property when limitHeightOpened not provided", async () => {
|
|
554
|
+
const { container } = render(
|
|
555
|
+
<MultiSuggestField {...Default.args} openOnKeyDown={false} data-testid="multi-suggest-field" />
|
|
556
|
+
);
|
|
557
|
+
|
|
558
|
+
const [inputTargetContainer] = container.getElementsByClassName("eccgui-multiselect");
|
|
559
|
+
|
|
560
|
+
fireEvent.click(inputTargetContainer);
|
|
561
|
+
|
|
562
|
+
await waitFor(() => {
|
|
563
|
+
const dropdown = screen.getByTestId("multi-suggest-field_dropdown");
|
|
564
|
+
const customProperty = (dropdown as HTMLElement)?.style?.getPropertyValue(
|
|
565
|
+
"--eccgui-multisuggestfield-max-height"
|
|
566
|
+
);
|
|
567
|
+
|
|
568
|
+
expect(customProperty).toBeFalsy();
|
|
569
|
+
});
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
it("should notcontain the custom css property when limitHeightOpened greater than 100", async () => {
|
|
573
|
+
const { container } = render(
|
|
574
|
+
<MultiSuggestField
|
|
575
|
+
{...Default.args}
|
|
576
|
+
openOnKeyDown={false}
|
|
577
|
+
limitHeightOpened={110}
|
|
578
|
+
data-testid="multi-suggest-field"
|
|
579
|
+
/>
|
|
580
|
+
);
|
|
581
|
+
|
|
582
|
+
const [inputTargetContainer] = container.getElementsByClassName("eccgui-multiselect");
|
|
583
|
+
|
|
584
|
+
fireEvent.click(inputTargetContainer);
|
|
585
|
+
|
|
586
|
+
await waitFor(() => {
|
|
587
|
+
const dropdown = screen.getByTestId("multi-suggest-field_dropdown");
|
|
588
|
+
|
|
589
|
+
const customProperty = (dropdown as HTMLElement)?.style?.getPropertyValue(
|
|
590
|
+
"--eccgui-multisuggestfield-max-height"
|
|
591
|
+
);
|
|
592
|
+
|
|
593
|
+
expect(customProperty).toBeFalsy();
|
|
594
|
+
});
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
it("should contain the custom css property when limitHeightOpened is true", async () => {
|
|
598
|
+
const { container } = render(
|
|
599
|
+
<MultiSuggestField
|
|
600
|
+
{...Default.args}
|
|
601
|
+
openOnKeyDown={false}
|
|
602
|
+
limitHeightOpened
|
|
603
|
+
data-testid="multi-suggest-field"
|
|
604
|
+
/>
|
|
605
|
+
);
|
|
606
|
+
|
|
607
|
+
const [inputTargetContainer] = container.getElementsByClassName("eccgui-multiselect");
|
|
608
|
+
|
|
609
|
+
fireEvent.click(inputTargetContainer);
|
|
610
|
+
|
|
611
|
+
await waitFor(() => {
|
|
612
|
+
const dropdown = screen.getByTestId("multi-suggest-field_dropdown");
|
|
613
|
+
|
|
614
|
+
const customProperty = (dropdown as HTMLElement)?.style?.getPropertyValue(
|
|
615
|
+
"--eccgui-multisuggestfield-max-height"
|
|
616
|
+
);
|
|
617
|
+
|
|
618
|
+
expect(customProperty).toBeDefined();
|
|
619
|
+
});
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
it("should contain the custom css property when limitHeightOpened a valid number value", async () => {
|
|
623
|
+
const { container } = render(
|
|
624
|
+
<MultiSuggestField
|
|
625
|
+
{...Default.args}
|
|
626
|
+
openOnKeyDown={false}
|
|
627
|
+
limitHeightOpened={80}
|
|
628
|
+
data-testid="multi-suggest-field"
|
|
629
|
+
/>
|
|
630
|
+
);
|
|
631
|
+
|
|
632
|
+
const [inputTargetContainer] = container.getElementsByClassName("eccgui-multiselect");
|
|
633
|
+
|
|
634
|
+
fireEvent.click(inputTargetContainer);
|
|
635
|
+
|
|
636
|
+
await waitFor(() => {
|
|
637
|
+
const dropdown = screen.getByTestId("multi-suggest-field_dropdown");
|
|
638
|
+
|
|
639
|
+
const customProperty = (dropdown as HTMLElement)?.style?.getPropertyValue(
|
|
640
|
+
"--eccgui-multisuggestfield-max-height"
|
|
641
|
+
);
|
|
642
|
+
|
|
643
|
+
expect(customProperty).toBeDefined();
|
|
644
|
+
});
|
|
645
|
+
});
|
|
552
646
|
});
|
|
553
647
|
});
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
// own vars
|
|
5
5
|
$eccgui-size-textfield-height-small: $eccgui-size-block-whitespace * 2 !default;
|
|
6
6
|
$eccgui-size-textfield-height-regular: $eccgui-size-textfield-height-small * $eccgui-size-type-levelratio !default;
|
|
7
|
-
$eccgui-size-textfield-height-large: $eccgui-size-textfield-height-regular * $eccgui-size-type-levelratio *
|
|
8
|
-
$eccgui-size-type-levelratio !default;
|
|
7
|
+
$eccgui-size-textfield-height-large: $eccgui-size-textfield-height-regular * $eccgui-size-type-levelratio * $eccgui-size-type-levelratio !default;
|
|
9
8
|
$eccgui-size-textfield-padding-horizontal-regular: $eccgui-size-inline-whitespace !default;
|
|
10
9
|
$eccgui-size-textfield-padding-horizontal-small: $eccgui-size-inline-whitespace * 0.5 !default;
|
|
11
10
|
$eccgui-typo-textfield-fontweight: $eccgui-font-weight-regular !default;
|
|
@@ -184,6 +184,16 @@ pre {
|
|
|
184
184
|
padding: $eccgui-size-block-whitespace * 0.5;
|
|
185
185
|
overflow-x: auto;
|
|
186
186
|
background-color: $eccgui-color-workspace-background;
|
|
187
|
+
|
|
188
|
+
& > div[style]:has(.#{$eccgui}-markdown__syntaxhighlighter) {
|
|
189
|
+
// remove styles like padding and font from prism div
|
|
190
|
+
padding: 0 !important;
|
|
191
|
+
margin: 0 !important;
|
|
192
|
+
font-family: inherit !important;
|
|
193
|
+
font-size: inherit !important;
|
|
194
|
+
line-height: inherit !important;
|
|
195
|
+
background-color: transparent !important;
|
|
196
|
+
}
|
|
187
197
|
}
|
|
188
198
|
}
|
|
189
199
|
|
|
@@ -38,6 +38,6 @@
|
|
|
38
38
|
@import "./Typography/typography";
|
|
39
39
|
@import "./Workspace/workspace";
|
|
40
40
|
@import "./Accordion/accordion";
|
|
41
|
-
@import "./AutoSuggestion/AutoSuggestion";
|
|
42
41
|
@import "./Badge/badge";
|
|
43
42
|
@import "./PropertyValuePair/propertyvalue";
|
|
43
|
+
@import "./MultiSuggestField/multisuggestfield";
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
@import "./react-flow/react-flow";
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
CodeMirror styles are already included by the base component styles
|
|
5
|
-
because it is used as lib for elements there already.
|
|
6
2
|
@import "./codemirror/codemirror";
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
@import "./../components/AutoSuggestion/AutoSuggestion"; // the whole element should moved to extensions forlder
|
|
9
4
|
@import "./uppy/fileupload";
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useRef } from "react";
|
|
2
2
|
import { defaultKeymap, indentWithTab } from "@codemirror/commands";
|
|
3
3
|
import { foldKeymap } from "@codemirror/language";
|
|
4
4
|
import { EditorState, Extension } from "@codemirror/state";
|
|
5
5
|
import { DOMEventHandlers, EditorView, KeyBinding, keymap, Rect, ViewUpdate } from "@codemirror/view";
|
|
6
|
-
//CodeMirror
|
|
7
6
|
import { minimalSetup } from "codemirror";
|
|
8
7
|
|
|
9
8
|
import { markField } from "../../components/AutoSuggestion/extensions/markText";
|
|
10
|
-
//constants
|
|
11
9
|
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
|
|
12
10
|
|
|
13
11
|
//hooks
|
|
@@ -27,6 +25,7 @@ import {
|
|
|
27
25
|
adaptedLineNumbers,
|
|
28
26
|
adaptedPlaceholder,
|
|
29
27
|
} from "./tests/codemirrorTestHelper";
|
|
28
|
+
|
|
30
29
|
export interface CodeEditorProps {
|
|
31
30
|
// Is called with the editor instance that allows access via the CodeMirror API
|
|
32
31
|
setEditorView?: (editor: EditorView | undefined) => any;
|
|
@@ -92,7 +91,7 @@ export interface CodeEditorProps {
|
|
|
92
91
|
/** Long lines are wrapped and displayed on multiple lines */
|
|
93
92
|
wrapLines?: boolean;
|
|
94
93
|
|
|
95
|
-
outerDivAttributes?:
|
|
94
|
+
outerDivAttributes?: Omit<React.HTMLAttributes<HTMLDivElement>, "id" | "data-test-id">;
|
|
96
95
|
|
|
97
96
|
/**
|
|
98
97
|
* Size in spaces that is used for a tabulator key.
|
|
@@ -276,11 +275,15 @@ export const CodeEditor = ({
|
|
|
276
275
|
|
|
277
276
|
return (
|
|
278
277
|
<div
|
|
279
|
-
|
|
278
|
+
{...outerDivAttributes}
|
|
279
|
+
// overwrite/extend some attributes
|
|
280
|
+
id={id ? id : name ? `codemirror-${name}` : undefined}
|
|
280
281
|
ref={parent}
|
|
281
282
|
data-test-id="codemirror-wrapper"
|
|
282
|
-
className={
|
|
283
|
-
|
|
283
|
+
className={
|
|
284
|
+
`${eccgui}-codeeditor ${eccgui}-codeeditor--mode-${mode}` +
|
|
285
|
+
(outerDivAttributes?.className ? ` ${outerDivAttributes?.className}` : "")
|
|
286
|
+
}
|
|
284
287
|
/>
|
|
285
288
|
);
|
|
286
289
|
};
|
|
@@ -29,7 +29,6 @@ $eccgui-color-codeeditor-background: $eccgui-color-textfield-background !default
|
|
|
29
29
|
// fix size to prevent wrong calculation of other elements
|
|
30
30
|
padding: 0;
|
|
31
31
|
margin: 1px;
|
|
32
|
-
cursor: text;
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
&.cm-focused {
|
|
@@ -54,6 +53,7 @@ $eccgui-color-codeeditor-background: $eccgui-color-textfield-background !default
|
|
|
54
53
|
}
|
|
55
54
|
|
|
56
55
|
.cm-content {
|
|
56
|
+
cursor: text;
|
|
57
57
|
border-right-width: $eccgui-size-inline-whitespace !important;
|
|
58
58
|
}
|
|
59
59
|
|
package/src/index.scss
CHANGED
|
@@ -50,7 +50,6 @@ $prefix-carbon: $prefix;
|
|
|
50
50
|
// == Load basic components styles =============================================
|
|
51
51
|
|
|
52
52
|
@import "./components";
|
|
53
|
-
@import "./extensions/codemirror/codemirror";
|
|
54
53
|
|
|
55
54
|
// set more readable variable for prefix
|
|
56
55
|
$prefix-eccgui: $eccgui;
|