Skip to content

Commit 575bece

Browse files
authored
Merge pull request #166 from eccenca/release/v23.7.0
Release v23.7.0 into main branch
2 parents 874813e + 91463a7 commit 575bece

54 files changed

Lines changed: 2011 additions & 555 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
]
3131
}
3232
],
33-
"@typescript-eslint/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }]
33+
"@typescript-eslint/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
34+
"no-console": "error"
3435
}
3536
}

CHANGELOG.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,61 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
66

77
## [Unreleased]
88

9+
### Added
10+
11+
- `<ReactFlow/>`, `<StickyNoteModal/>`, `<EdgeDefault/>`, `<EdgeLabel/>`, `<HandleContent/>`, `<HandleTools/>`, `<MiniMap/>`
12+
- all react flow components are now be able to process test ids as data attributes, e.g. `data-test-id` and `data-testid`, sometimes as direct property, in other cases as part of properties routed to the wrapper elements
13+
- storybook documentation was enhanced by demonstration the usage of test ids
14+
- `<Markdown />`
15+
- Do syntax highlighting when a class name is set in the form `language-<LANGUAGE_NAME>`.
16+
- `<StickyTarget/>`
17+
- Element wraps the content that need to be displayed sticky.
18+
- `utils`
19+
- `getScrollParent`: method to find the scroll parent of an element
20+
- `<AutoCompleteField />`
21+
- Support loading more results when scrolling to the end of the result list.
22+
- `<TextArea />`
23+
- `intent` property to set the state, formerly used `hasStatePrimary`, `hasStateSuccess`, `hasStateWarning` and `hasStateDanger` properties are now deprecated
24+
- `leftIcon`: set the left aligned icon
25+
- `rightElement`: renders on right side
26+
- `<Depiction />`
27+
- `disabled` property could be used if the element is used inside a disabled interactive element or form control but the state is not adapted automatically to the depiction
28+
- new icons: `navigation-extern`, `toggler-list`, `toggler-table`, `data-boolean`
29+
30+
### Fixed
31+
32+
- `<MultiSuggestField />`
33+
- Updated the interface with the ability to use either `selectedItems` or `prePopulateWithItems` properties, which is more logical.
34+
- Fixed deferred `selectedItems` setting.
35+
- `<StickyNoteModal/>`
36+
- static test id `data-test-id="sticky-note-modal"` will be removed with next major version
37+
- `<BreadcrumbsList />`
38+
- `onItemClick` handler is only executed if breadcrumb has `href` set because this is one callback parameter and the handler would not have any information otherwise
39+
- `<Depiction />`
40+
- position fixed when element is used as icon in `<Button />`
41+
- `<Tooltip />`
42+
- fix font sizes and background colors
43+
- `<NodeContent />`
44+
- node introduction is only processed one time even if a node update still provides a `introductionTime` property
45+
46+
### Changed
47+
48+
- `<BreadcrumbsList />`
49+
- `onItemClick` handler is only executed when the breadcrumb has no own `onClick` handler defined
50+
- `<Card />`
51+
- `elevation` allows now `-1` as value, the card is borderless then
52+
- `<MultiSuggestField />`
53+
- use "Search for item, or enter term to create new one..." as default `placeholder` if `createNewItemFromQuery` is given
54+
- `<SilkActivityControl />`
55+
- interface of `initialStatus` property has been updated with the so far missing `lastUpdateTime` property. If you run in problems because of that you could use `Date.now()` as fix. Or consider to use `<ActivityControlWidget />` directly, what is probably even better.
56+
- `<Depiction />`
57+
- opcaity is reduced automatically when element is used as icon in a disabled `<Button />`
58+
59+
### Deprecated
60+
61+
- `<TextArea />`
62+
- `hasStatePrimary`, `hasStateSuccess`, `hasStateWarning` and `hasStateDanger` properties: use the `intent` property instead.
63+
964
## [23.6.0] - 2024-04-17
1065

1166
### Added

package.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@eccenca/gui-elements",
33
"description": "GUI elements based on other libraries, usable in React application, written in Typescript.",
4-
"version": "23.6.0",
4+
"version": "23.7.0-rc.5",
55
"license": "Apache-2.0",
66
"homepage": "https://github.com/eccenca/gui-elements",
77
"bugs": "https://github.com/eccenca/gui-elements/issues",
@@ -65,9 +65,9 @@
6565
"autolint:all": "yarn autolint:scripts && yarn autolint:styles && yarn autolint:prettier"
6666
},
6767
"dependencies": {
68-
"@blueprintjs/colors": "^5.1.0",
69-
"@blueprintjs/core": "^5.9.1",
70-
"@blueprintjs/select": "^5.1.1",
68+
"@blueprintjs/colors": "^5.1.1",
69+
"@blueprintjs/core": "^5.10.3",
70+
"@blueprintjs/select": "^5.1.5",
7171
"@carbon/icons": "^11.19.0",
7272
"@carbon/icons-react": "11.19.0",
7373
"@carbon/styles": "1.32.0",
@@ -85,6 +85,7 @@
8585
"react-flow-renderer-lts": "npm:react-flow-renderer@^10.3.17",
8686
"react-inlinesvg": "^3.0.3",
8787
"react-markdown": "^8.0.7",
88+
"react-syntax-highlighter": "15.5.0",
8889
"rehype-raw": "^6.1.1",
8990
"remark-definition-list": "^1.2.0",
9091
"remark-gfm": "^3.0.1",
@@ -117,6 +118,7 @@
117118
"@types/color": "^3.0.6",
118119
"@types/jest": "^29.5.12",
119120
"@types/lodash": "^4.14.202",
121+
"@types/react-syntax-highlighter": "15.5.11",
120122
"@typescript-eslint/eslint-plugin": "^5.62.0",
121123
"@typescript-eslint/parser": "^5.62.0",
122124
"babel-jest": "^29.7.0",
@@ -162,7 +164,9 @@
162164
"**/jackspeak": "2.1.1",
163165
"node-sass-package-importer/**/postcss": "^8.4.31",
164166
"**/word-wrap": "^1.2.4",
165-
"**/webpack-dev-middleware": "^6.1.2"
167+
"**/webpack-dev-middleware": "^6.1.2",
168+
"**/braces": "^3.0.3",
169+
"**/ws": "^8.17.1"
166170
},
167171
"husky": {
168172
"hooks": {

src/cmem/ActivityControl/ActivityControlTypes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export interface IActivityStatus {
1616
statusName: "Waiting" | "Finished" | "Idle" | "Running" | "Canceling";
1717
// A number between 0 and 100
1818
progress: number;
19+
// timestamp for last update
20+
lastUpdateTime: number;
1921
// More information corresponding to the status
2022
message: string;
2123
// If the activity has been cancelled

src/cmem/markdown/Markdown.stories.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from "react";
2+
import { Blockquote } from "@blueprintjs/core";
23
import { ComponentMeta, ComponentStory } from "@storybook/react";
34

45
import { Markdown } from "./../../../index";
@@ -44,11 +45,17 @@ This is a paragraph with a [text link](http://example.com/) and a footnote refer
4445
##### Headline level 5
4546
###### Headline level 6
4647
47-
This is a code block.
48+
This is a code block.
49+
50+
\`\`\`
51+
another code block
52+
{{templateVar}}
53+
\`\`\`
4854
4955
> This is a block quote.
5056
>
5157
> With 2 paragraphs.
58+
> And some code like \`{{showThisNotItsValue}}\`
5259
5360
A line with some <strong>HTML code</strong> inside.
5461

src/cmem/markdown/Markdown.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import React from "react";
22
import ReactMarkdown from "react-markdown";
33
import { PluggableList } from "react-markdown/lib/react-markdown";
4-
//@ts-ignore
4+
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
5+
import { materialLight } from "react-syntax-highlighter/dist/esm/styles/prism";
6+
// @ts-ignore: No declaration file for module (TODO: should be @ts-expect-error but GUI elements is used inside project with `noImplicitAny=false`)
57
import remarkTypograf from "@mavrin/remark-typograf";
68
import rehypeRaw from "rehype-raw";
79
import { remarkDefinitionList } from "remark-definition-list";
@@ -132,6 +134,25 @@ export const Markdown = ({
132134
return linkTarget as React.HTMLAttributeAnchorTarget;
133135
}
134136
: undefined,
137+
components: {
138+
code(props: any) {
139+
const { children, className, node, ...rest } = props;
140+
const match = /language-(\w+)/.exec(className || "");
141+
return match ? (
142+
<SyntaxHighlighter
143+
{...rest}
144+
PreTag="div"
145+
children={String(children).replace(/\n$/, "")}
146+
language={match[1]}
147+
style={materialLight}
148+
/>
149+
) : (
150+
<code {...rest} className={className}>
151+
{children}
152+
</code>
153+
);
154+
},
155+
},
135156
};
136157
allowedElements && (reactMarkdownProperties.allowedElements = allowedElements);
137158
reHypePlugins &&

src/cmem/react-flow/ReactFlow/ReactFlow.stories.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { FC, useCallback, useEffect, useState } from "react";
22
import { Elements, FlowElement } from "react-flow-renderer";
3-
import { ComponentMeta, ComponentStory } from "@storybook/react";
3+
import { Meta, StoryFn } from "@storybook/react";
44

55
import { EdgeTools, NodeTools, ReactFlow } from "./../../../index";
66
import { ReactFlowProps } from "./ReactFlow";
@@ -361,7 +361,7 @@ export default {
361361
options: Object.keys(nodeExamples),
362362
},
363363
},
364-
} as ComponentMeta<typeof ReactFlow>;
364+
} as Meta<typeof ReactFlow>;
365365

366366
const ReactFlowExample: FC<ReactFlowProps> = (args) => {
367367
const [reactflowInstance, setReactflowInstance] = useState(null);
@@ -402,10 +402,13 @@ const ReactFlowExample: FC<ReactFlowProps> = (args) => {
402402
[reactflowInstance]
403403
);
404404

405+
const { configuration, ...otherArgs } = args;
406+
405407
return (
406408
<>
407409
<ReactFlow
408-
configuration={args.configuration}
410+
{...otherArgs}
411+
configuration={configuration}
409412
elements={elements}
410413
style={{ height: "400px" }}
411414
onLoad={onLoad}
@@ -418,9 +421,12 @@ const ReactFlowExample: FC<ReactFlowProps> = (args) => {
418421
);
419422
};
420423

421-
const Template: ComponentStory<typeof ReactFlow> = (args) => <ReactFlowExample {...args} />;
424+
const Template: StoryFn<typeof ReactFlow> = (args) => <ReactFlowExample {...args} />;
422425

423426
export const Default = Template.bind({});
424427
Default.args = {
425428
configuration: "unspecified",
429+
"data-test-id": "reactflow-test-id",
430+
"data-testid": "reactflow-testid",
426431
};
432+
Default.nodeExamples = nodeExamples;

src/cmem/react-flow/StickyNoteModal/StickyNoteModal.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import getColorConfiguration from "../../../common/utils/getColorConfiguration";
44
import { CodeEditor } from "../../../extensions";
55
import { ReactFlowHotkeyContext } from "../extensions/ReactFlowHotkeyContext";
66

7-
import { Button, FieldItem, Icon, SimpleDialog, Tag, TagList } from "./../../../index";
7+
import { Button, FieldItem, Icon, SimpleDialog, SimpleDialogProps, Tag, TagList } from "./../../../index";
88

99
export type StickyNoteModalTranslationKeys = "modalTitle" | "noteLabel" | "colorLabel" | "saveButton" | "cancelButton";
1010

@@ -28,10 +28,14 @@ export interface StickyNoteModalProps {
2828
* translation utility for language compatibility
2929
*/
3030
translate: (key: StickyNoteModalTranslationKeys) => string;
31+
/**
32+
* Forward other properties to the `SimpleModal` element that is used for this dialog.
33+
*/
34+
simpleDialogProps?: Omit<SimpleDialogProps, "size" | "title" | "hasBorder" | "isOpen" | "onClose" | "actions">;
3135
}
3236

3337
export const StickyNoteModal: React.FC<StickyNoteModalProps> = React.memo(
34-
({ metaData, onClose, onSubmit, translate }) => {
38+
({ metaData, onClose, onSubmit, translate, simpleDialogProps }) => {
3539
const refNote = React.useRef<string>(metaData?.note ?? "");
3640
const [color, setSelectedColor] = React.useState<string>(metaData?.color ?? "");
3741
const noteColors: [string, string][] = Object.entries(getColorConfiguration("stickynotes")).map(
@@ -79,7 +83,6 @@ export const StickyNoteModal: React.FC<StickyNoteModalProps> = React.memo(
7983

8084
return (
8185
<SimpleDialog
82-
data-test-id={"sticky-note-modal"}
8386
size="small"
8487
title={translate("modalTitle")}
8588
hasBorder
@@ -101,6 +104,8 @@ export const StickyNoteModal: React.FC<StickyNoteModalProps> = React.memo(
101104
{translate("cancelButton")}
102105
</Button>,
103106
]}
107+
{...simpleDialogProps}
108+
data-test-id={(simpleDialogProps ?? {})["data-test-id"] ?? "sticky-note-modal"} // @deprecated we remove this automatically set testid with the next major release
104109
>
105110
<FieldItem
106111
key="note"

src/common/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { invisibleZeroWidthCharacters } from "./utils/characters";
22
import decideContrastColorValue from "./utils/colorDecideContrastvalue";
33
import getColorConfiguration from "./utils/getColorConfiguration";
4+
import { getScrollParent } from "./utils/getScrollParent";
45
import { getGlobalVar, setGlobalVar } from "./utils/globalVars";
56
import { openInNewTab } from "./utils/openInNewTab";
67

@@ -11,6 +12,8 @@ export const utils = {
1112
invisibleZeroWidthCharacters,
1213
getGlobalVar,
1314
setGlobalVar,
15+
getScrollParent,
1416
};
17+
1518
// @deprecated use `utils`
1619
export const Utilities = utils;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Find the scroll parent of an element, returns `false` if it cannot be found.
3+
* In case of a `false` return the very probably `document.documentElement` is the parent.
4+
* In this case `window` object should be used for scroll event listeners.
5+
* See `src/components/Sticky/StickyTarget.tsx` for an usage example.
6+
* @param element
7+
* @returns HTMLElement | false
8+
*/
9+
export const getScrollParent = (element: Element): HTMLElement | false => {
10+
let scrollParent = element.parentElement;
11+
while (scrollParent) {
12+
const { overflow } = window.getComputedStyle(scrollParent);
13+
if (overflow.split(" ").every((value) => value === "auto" || value === "scroll")) {
14+
return scrollParent;
15+
}
16+
scrollParent = scrollParent.parentElement;
17+
}
18+
19+
return false;
20+
};

0 commit comments

Comments
 (0)