Skip to content

Commit 8f19421

Browse files
MarcusNotheisLukas742
andauthoredSep 27, 2023
chore(cypress-commands): fix typedoc generation (#5092)
Co-authored-by: Lukas Harbarth <[email protected]>
1 parent 3bfe091 commit 8f19421

File tree

8 files changed

+475
-385
lines changed

8 files changed

+475
-385
lines changed
 

‎package.json

+11-10
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131
"create-cypress-commands-docs": "typedoc && rimraf temp/typedoc"
3232
},
3333
"dependencies": {
34-
"@storybook/addon-a11y": "7.4.2",
35-
"@storybook/addon-essentials": "7.4.2",
36-
"@storybook/blocks": "7.4.2",
37-
"@storybook/react": "7.4.2",
38-
"@storybook/react-vite": "7.4.2",
39-
"@storybook/theming": "7.4.2",
34+
"@storybook/addon-a11y": "7.4.5",
35+
"@storybook/addon-essentials": "7.4.5",
36+
"@storybook/blocks": "7.4.5",
37+
"@storybook/react": "7.4.5",
38+
"@storybook/react-vite": "7.4.5",
39+
"@storybook/theming": "7.4.5",
4040
"@ui5/webcomponents": "1.17.0",
4141
"@ui5/webcomponents-fiori": "1.17.0",
4242
"@ui5/webcomponents-icons": "1.17.0",
@@ -55,8 +55,8 @@
5555
"@semantic-release/github": "^9.0.0",
5656
"@testing-library/cypress": "^10.0.0",
5757
"@types/node": "^18.0.0",
58-
"@types/react": "^18.0.6",
59-
"@types/react-dom": "^18.0.0",
58+
"@types/react": "^18.2.23",
59+
"@types/react-dom": "^18.2.7",
6060
"@typescript-eslint/eslint-plugin": "^6.0.0",
6161
"@typescript-eslint/parser": "^6.0.0",
6262
"@ui5/webcomponents-tools": "1.17.0",
@@ -75,7 +75,7 @@
7575
"eslint-plugin-prettier": "^5.0.0",
7676
"eslint-plugin-react": "^7.32.2",
7777
"eslint-plugin-react-hooks": "^4.6.0",
78-
"eslint-plugin-storybook": "^0.6.11",
78+
"eslint-plugin-storybook": "^0.6.14",
7979
"handlebars": "^4.7.7",
8080
"husky": "^8.0.0",
8181
"identity-obj-proxy": "^3.0.0",
@@ -87,8 +87,9 @@
8787
"postcss-import": "^15.1.0",
8888
"postcss-modules": "^6.0.0",
8989
"prettier": "^3.0.0",
90+
"react-textarea-autosize": "^8.5.3",
9091
"rimraf": "^5.0.0",
91-
"storybook": "7.4.2",
92+
"storybook": "7.4.5",
9293
"turndown": "^7.0.0",
9394
"typedoc": "^0.25.0",
9495
"typescript": "5.2.2",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"rootDir": "."
5+
},
6+
"include": ["src", "CommandsAndQueries.tsx"]
7+
}

‎packages/main/src/components/FilterBar/index.tsx

+23-16
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ const resizeObserverEntryWidth = (entry) => {
200200
return entry.target.getBoundingClientRect().width;
201201
};
202202

203+
type ReactKeyWithoutBigInt = string | number;
204+
203205
const useStyles = createUseStyles(styles, { name: 'FilterBar' });
204206
/**
205207
* The `FilterBar` displays filters in a user-friendly manner to populate values for a query. It consists of a row containing the `VariantManagement` or a title, the related buttons, and an area underneath displaying the filters. The filters are arranged in a logical row that is divided depending on the space available and the width of the filters. The area containing the filters can be hidden or shown using the "Hide FilterBar / Show FilterBar" button, the "Filters" button shows the filter dialog.
@@ -279,12 +281,13 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
279281
useEffect(() => {
280282
Children.toArray(children).forEach((item) => {
281283
if (isValidElement(item)) {
284+
const key = item.key as ReactKeyWithoutBigInt;
282285
setToggledFilters((prev) => {
283-
if (!item.props.hasOwnProperty('visibleInFilterBar') && prev?.[item.key] === undefined) {
284-
return { ...prev, [item.key]: true };
286+
if (!item.props.hasOwnProperty('visibleInFilterBar') && prev?.[key] === undefined) {
287+
return { ...prev, [key]: true };
285288
}
286289
if (item.props.hasOwnProperty('visibleInFilterBar')) {
287-
return { ...prev, [item.key]: item.props.visibleInFilterBar };
290+
return { ...prev, [key]: item.props.visibleInFilterBar };
288291
}
289292
return prev;
290293
});
@@ -365,11 +368,14 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
365368
const safeChildren = () => {
366369
if (Object.keys(toggledFilters).length > 0) {
367370
return Children.toArray(children).map((child) => {
368-
if (isValidElement(child) && toggledFilters?.[child.key] !== undefined) {
369-
// @ts-expect-error: child should always be a FilterGroupItem w/o portal
370-
return cloneElement<FilterGroupItemPropTypes, HTMLDivElement>(child, {
371-
visibleInFilterBar: toggledFilters[child.key]
372-
});
371+
if (isValidElement(child)) {
372+
const key = child.key as ReactKeyWithoutBigInt;
373+
if (toggledFilters?.[key] !== undefined) {
374+
// @ts-expect-error: child should always be a FilterGroupItem w/o portal
375+
return cloneElement<FilterGroupItemPropTypes, HTMLDivElement>(child, {
376+
visibleInFilterBar: toggledFilters[key]
377+
});
378+
}
373379
}
374380
return child;
375381
});
@@ -389,17 +395,18 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
389395
return item?.props?.visible && item.props?.visibleInFilterBar;
390396
})
391397
.map((child) => {
398+
const key = child.key as ReactKeyWithoutBigInt;
392399
// necessary because of varying widths of input elements
393400
if (filterContainerWidth) {
394401
childProps.style = { width: filterContainerWidth, ...child.props.style };
395402
}
396403
if (hideFilterConfiguration) {
397404
return cloneElement(child, { ...childProps });
398405
}
399-
prevVisibleInFilterBarProps.current[child.key] = child.props.visibleInFilterBar;
406+
prevVisibleInFilterBarProps.current[key] = child.props.visibleInFilterBar;
400407
let filterItemProps = {};
401408
if (Object.keys(dialogRefs).length > 0) {
402-
const dialogItemRef = dialogRefs[child.key];
409+
const dialogItemRef = dialogRefs[key];
403410
if (dialogItemRef) {
404411
filterItemProps = filterValue(dialogItemRef, child);
405412
}
@@ -410,22 +417,22 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
410417
});
411418
}
412419
if (
413-
prevChildren.current?.[child.key] &&
420+
prevChildren.current?.[key] &&
414421
//Input
415-
(child.props.children?.props?.value !== prevChildren.current?.[child.key]?.value ||
422+
(child.props.children?.props?.value !== prevChildren.current?.[key]?.value ||
416423
//Checkbox
417-
child.props.children?.props?.checked !== prevChildren.current?.[child.key]?.checked ||
424+
child.props.children?.props?.checked !== prevChildren.current?.[key]?.checked ||
418425
//Selectable
419426
(Array.isArray(child.props.children?.props?.children) &&
420427
child.props.children?.props?.children?.map((item) => item.props.selected).join(',') !==
421-
prevChildren?.current?.[child.key]?.children?.map((item) => item.props.selected).join(',')))
428+
prevChildren?.current?.[key]?.children?.map((item) => item.props.selected).join(',')))
422429
) {
423430
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
424431
// @ts-ignore
425432
const { [child.key]: _omit, ...rest } = dialogRefs;
426433
setDialogRefs(rest);
427434
}
428-
prevChildren.current[child.key] = child.props.children.props;
435+
prevChildren.current[key] = child.props.children.props;
429436

430437
return cloneElement(child, {
431438
...childProps,
@@ -436,7 +443,7 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
436443
...filterItemProps
437444
},
438445
ref: (node) => {
439-
filterRefs.current[child.key] = node;
446+
filterRefs.current[key] = node;
440447
if (!dialogOpen) syncRef(child.props.children.ref, node);
441448
}
442449
}

‎packages/main/src/components/Grid/Grid.cy.tsx

+14-8
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,8 @@ describe('Grid', () => {
108108
);
109109
cy.findByTestId('grid').should('have.css', 'grid-row-gap', '42px').should('have.css', 'grid-column-gap', '7px');
110110
});
111-
112-
it('position', () => {
113-
[...Object.values(GridPosition), undefined].forEach((pos) => {
111+
[...Object.values(GridPosition), undefined].forEach((pos: GridPosition | undefined) => {
112+
it(`position-${pos}`, () => {
114113
cy.mount(
115114
<div style={{ width: '400px' }}>
116115
<Grid data-testid="grid" position={pos} style={{ width: '200px' }}>
@@ -120,15 +119,22 @@ describe('Grid', () => {
120119
);
121120
switch (pos) {
122121
case 'Center':
123-
cy.findByTestId('grid')
124-
.should('have.css', 'margin-left', '100px')
125-
.should('have.css', 'margin-right', '100px');
122+
cy.findByTestId('grid').should('satisfy', ($el) => {
123+
const classList = Array.from($el[0].classList);
124+
return classList.some((item) => item.includes('positionCenter'));
125+
});
126126
break;
127127
case 'Right':
128-
cy.findByTestId('grid').should('have.css', 'margin-left', '200px').should('have.css', 'margin-right', '0px');
128+
cy.findByTestId('grid').should('satisfy', ($el) => {
129+
const classList = Array.from($el[0].classList);
130+
return classList.some((item) => item.includes('positionRight'));
131+
});
129132
break;
130133
default:
131-
cy.findByTestId('grid').should('have.css', 'margin-left', '0px').should('have.css', 'margin-right', '0px');
134+
cy.findByTestId('grid').should('satisfy', ($el) => {
135+
const classList = Array.from($el[0].classList);
136+
return classList.every((item) => !item.includes('position'));
137+
});
132138
break;
133139
}
134140
});

‎packages/main/src/components/Grid/Grid.jss.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ export const styles = {
1313
},
1414
...generateGridSpans(),
1515
positionCenter: {
16-
marginLeft: 'auto',
17-
marginRight: 'auto'
16+
marginInline: 'auto'
1817
},
1918
positionRight: {
20-
marginLeft: 'auto',
21-
marginRight: 0
19+
marginInline: 'auto 0px'
2220
}
2321
};

‎typedoc.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"$schema": "https://typedoc.org/schema.json",
33
"entryPoints": ["packages/cypress-commands"],
4+
"tsconfig": "./packages/cypress-commands/tsconfig.typedoc.json",
45
"entryPointStrategy": "expand",
56
"out": "temp/typedoc",
67
"exclude": ["**/dist/**/*", "**/test/**/*"],

‎vite.config.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ export default defineConfig(() => {
2929
tsconfigPaths({
3030
projects: [fileURLToPath(new URL('tsconfig.base.json', import.meta.url))]
3131
})
32-
].filter(Boolean)
32+
].filter(Boolean),
33+
server: {
34+
watch: {
35+
ignored: ['**/packages/cra-template/**', '**/packages/cra-template-seed/**']
36+
}
37+
}
3338
};
3439
});

‎yarn.lock

+411-346
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.