@rebasepro/ui 0.17.3 → 0.18.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.
- package/README.md +4 -0
- package/dist/components/MultiSelect.d.ts +10 -0
- package/dist/index.es.js +2 -1
- package/dist/index.es.js.map +1 -1
- package/package.json +32 -23
- package/src/components/Alert.tsx +0 -118
- package/src/components/Autocomplete.tsx +0 -93
- package/src/components/Avatar.tsx +0 -73
- package/src/components/Badge.tsx +0 -44
- package/src/components/BooleanSwitch.tsx +0 -116
- package/src/components/BooleanSwitchWithLabel.tsx +0 -120
- package/src/components/Button.tsx +0 -110
- package/src/components/Card.tsx +0 -43
- package/src/components/CenteredView.tsx +0 -35
- package/src/components/Checkbox.tsx +0 -129
- package/src/components/Chip.tsx +0 -131
- package/src/components/CircularProgress.tsx +0 -53
- package/src/components/CircularProgressCenter.tsx +0 -27
- package/src/components/Collapse.tsx +0 -66
- package/src/components/ColorPicker.tsx +0 -140
- package/src/components/Container.tsx +0 -51
- package/src/components/DateTimeField.tsx +0 -363
- package/src/components/DebouncedTextField.tsx +0 -76
- package/src/components/Dialog.tsx +0 -159
- package/src/components/DialogActions.tsx +0 -29
- package/src/components/DialogContent.tsx +0 -27
- package/src/components/DialogTitle.tsx +0 -41
- package/src/components/ErrorBoundary.tsx +0 -236
- package/src/components/ExpandablePanel.tsx +0 -130
- package/src/components/FileUpload.tsx +0 -103
- package/src/components/FilterChip.tsx +0 -89
- package/src/components/IconButton.tsx +0 -101
- package/src/components/InfoLabel.tsx +0 -23
- package/src/components/InputLabel.tsx +0 -40
- package/src/components/Label.tsx +0 -32
- package/src/components/LoadingButton.tsx +0 -32
- package/src/components/Markdown.tsx +0 -55
- package/src/components/Menu.tsx +0 -114
- package/src/components/Menubar.tsx +0 -355
- package/src/components/MultiSelect.tsx +0 -433
- package/src/components/Paper.tsx +0 -23
- package/src/components/Popover.tsx +0 -162
- package/src/components/RadioGroup.tsx +0 -74
- package/src/components/ResizablePanels.tsx +0 -189
- package/src/components/SearchBar.tsx +0 -136
- package/src/components/Select.tsx +0 -326
- package/src/components/Separator.tsx +0 -28
- package/src/components/Sheet.tsx +0 -135
- package/src/components/Skeleton.tsx +0 -54
- package/src/components/Slider.tsx +0 -110
- package/src/components/Table.tsx +0 -178
- package/src/components/Tabs.tsx +0 -185
- package/src/components/TextField.tsx +0 -270
- package/src/components/TextareaAutosize.tsx +0 -368
- package/src/components/ToggleButtonGroup.tsx +0 -69
- package/src/components/Tooltip.tsx +0 -153
- package/src/components/Typography.tsx +0 -132
- package/src/components/VirtualTable/VirtualTable.performance.test.tsx +0 -90
- package/src/components/VirtualTable/VirtualTable.tsx +0 -700
- package/src/components/VirtualTable/VirtualTableCell.tsx +0 -59
- package/src/components/VirtualTable/VirtualTableHeader.tsx +0 -327
- package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +0 -250
- package/src/components/VirtualTable/VirtualTableProps.tsx +0 -339
- package/src/components/VirtualTable/VirtualTableRow.tsx +0 -51
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +0 -44
- package/src/components/VirtualTable/fields/VirtualTableInput.tsx +0 -89
- package/src/components/VirtualTable/fields/VirtualTableNumberInput.tsx +0 -71
- package/src/components/VirtualTable/fields/VirtualTableSelect.tsx +0 -107
- package/src/components/VirtualTable/fields/VirtualTableSwitch.tsx +0 -28
- package/src/components/VirtualTable/index.tsx +0 -10
- package/src/components/VirtualTable/selection/SelectionContext.tsx +0 -36
- package/src/components/VirtualTable/selection/SelectionStore.ts +0 -54
- package/src/components/VirtualTable/types.tsx +0 -47
- package/src/components/common/SelectInputLabel.tsx +0 -23
- package/src/components/index.tsx +0 -62
- package/src/hooks/PortalContainerContext.tsx +0 -50
- package/src/hooks/index.ts +0 -7
- package/src/hooks/useDebounceCallback.tsx +0 -21
- package/src/hooks/useDebounceValue.tsx +0 -20
- package/src/hooks/useDebouncedCallback.ts +0 -39
- package/src/hooks/useInjectStyles.tsx +0 -31
- package/src/hooks/useOutsideAlerter.tsx +0 -46
- package/src/icons/GitHubIcon.tsx +0 -21
- package/src/icons/HandleIcon.tsx +0 -23
- package/src/icons/Icon.tsx +0 -33
- package/src/icons/LucideIconByName.tsx +0 -117
- package/src/icons/cool_icon_keys.ts +0 -12
- package/src/icons/icon_keys.ts +0 -1936
- package/src/icons/index.ts +0 -179
- package/src/index.css +0 -169
- package/src/index.ts +0 -47
- package/src/scripts/fixIconSizes.cjs +0 -92
- package/src/scripts/fixIconSizesToConst.cjs +0 -106
- package/src/scripts/generateIconKeys.ts +0 -41
- package/src/scripts/generateIcons.ts +0 -4
- package/src/scripts/saveIconFiles.ts +0 -89
- package/src/styles.ts +0 -141
- package/src/theme.css +0 -168
- package/src/util/chip_colors.ts +0 -242
- package/src/util/cls.ts +0 -8
- package/src/util/debounce.ts +0 -28
- package/src/util/hash.ts +0 -11
- package/src/util/index.ts +0 -4
- package/src/util/key_to_icon_component.ts +0 -11
- package/src/util/lazy_chunk.ts +0 -101
- package/src/views/CardView.tsx +0 -281
- package/src/views/CollectionView/CollectionCardView.tsx +0 -265
- package/src/views/CollectionView/CollectionKanbanView.tsx +0 -246
- package/src/views/CollectionView/CollectionListView.tsx +0 -240
- package/src/views/CollectionView/CollectionTableView.tsx +0 -229
- package/src/views/CollectionView/CollectionView.tsx +0 -450
- package/src/views/CollectionView/CollectionViewToolbar.tsx +0 -242
- package/src/views/CollectionView/CollectionViewTypes.ts +0 -181
- package/src/views/CollectionView/DefaultCellRenderer.tsx +0 -404
- package/src/views/CollectionView/index.ts +0 -39
- package/src/views/CollectionView/resolveTitleProperty.ts +0 -52
- package/src/views/CollectionView/utils.ts +0 -14
- package/src/views/Kanban/Board.tsx +0 -384
- package/src/views/Kanban/BoardColumn.tsx +0 -138
- package/src/views/Kanban/BoardColumnTitle.tsx +0 -47
- package/src/views/Kanban/BoardSortableList.tsx +0 -182
- package/src/views/Kanban/board_types.ts +0 -80
- package/src/views/Kanban/index.tsx +0 -5
- package/src/views/Kanban/placement.ts +0 -62
- package/src/views/KanbanView.tsx +0 -32
- package/src/views/ListView.tsx +0 -296
- package/src/views/index.ts +0 -5
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
4
|
-
|
|
5
|
-
import { cls } from "../util";
|
|
6
|
-
import { useInjectStyles } from "../hooks";
|
|
7
|
-
import { usePortalContainer } from "../hooks/PortalContainerContext";
|
|
8
|
-
|
|
9
|
-
export type TooltipProps = {
|
|
10
|
-
open?: boolean,
|
|
11
|
-
defaultOpen?: boolean,
|
|
12
|
-
onOpenChange?: (open: boolean) => void,
|
|
13
|
-
side?: "top" | "bottom" | "left" | "right",
|
|
14
|
-
align?: "start" | "center" | "end",
|
|
15
|
-
sideOffset?: number,
|
|
16
|
-
title?: string | React.ReactNode,
|
|
17
|
-
delayDuration?: number;
|
|
18
|
-
asChild?: boolean;
|
|
19
|
-
tooltipClassName?: string,
|
|
20
|
-
tooltipStyle?: React.CSSProperties;
|
|
21
|
-
children: React.ReactNode,
|
|
22
|
-
className?: string,
|
|
23
|
-
container?: HTMLElement,
|
|
24
|
-
style?: React.CSSProperties;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const Tooltip = ({
|
|
28
|
-
open,
|
|
29
|
-
defaultOpen,
|
|
30
|
-
side = "bottom",
|
|
31
|
-
delayDuration = 200,
|
|
32
|
-
sideOffset,
|
|
33
|
-
align,
|
|
34
|
-
onOpenChange,
|
|
35
|
-
title,
|
|
36
|
-
tooltipClassName,
|
|
37
|
-
tooltipStyle,
|
|
38
|
-
children,
|
|
39
|
-
asChild = false,
|
|
40
|
-
container,
|
|
41
|
-
className,
|
|
42
|
-
style
|
|
43
|
-
}: TooltipProps) => {
|
|
44
|
-
|
|
45
|
-
useInjectStyles("Tooltip", styles);
|
|
46
|
-
|
|
47
|
-
// Get the portal container from context
|
|
48
|
-
const contextContainer = usePortalContainer();
|
|
49
|
-
|
|
50
|
-
// Prioritize manual prop, fallback to context container
|
|
51
|
-
const finalContainer = (container ?? contextContainer ?? undefined) as HTMLElement | undefined;
|
|
52
|
-
|
|
53
|
-
if (!title)
|
|
54
|
-
return <>{children}</>;
|
|
55
|
-
|
|
56
|
-
const trigger = asChild
|
|
57
|
-
? <TooltipPrimitive.Trigger asChild={true}>
|
|
58
|
-
{children}
|
|
59
|
-
</TooltipPrimitive.Trigger>
|
|
60
|
-
: <TooltipPrimitive.Trigger asChild={true}>
|
|
61
|
-
<div style={style} className={className}>
|
|
62
|
-
{children}
|
|
63
|
-
</div>
|
|
64
|
-
</TooltipPrimitive.Trigger>;
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<TooltipPrimitive.Provider delayDuration={delayDuration}>
|
|
68
|
-
<TooltipPrimitive.Root {...(open !== undefined ? { open,
|
|
69
|
-
onOpenChange } : {})} defaultOpen={defaultOpen}>
|
|
70
|
-
{trigger}
|
|
71
|
-
<TooltipPrimitive.Portal container={finalContainer}>
|
|
72
|
-
<TooltipPrimitive.Content
|
|
73
|
-
className={cls("TooltipContent",
|
|
74
|
-
"max-w-lg leading-relaxed",
|
|
75
|
-
"z-50 rounded-md px-3 py-2 text-xs leading-none bg-surface-accent-700 dark:bg-surface-accent-800 bg-opacity-90 bg-surface-accent-700/90 dark:bg-surface-accent-800/90 font-medium text-surface-accent-50 shadow-2xl select-none duration-400 ease-in transform opacity-100",
|
|
76
|
-
tooltipClassName)}
|
|
77
|
-
style={tooltipStyle}
|
|
78
|
-
sideOffset={sideOffset === undefined ? 4 : sideOffset}
|
|
79
|
-
align={align}
|
|
80
|
-
side={side}>
|
|
81
|
-
{title}
|
|
82
|
-
</TooltipPrimitive.Content>
|
|
83
|
-
</TooltipPrimitive.Portal>
|
|
84
|
-
</TooltipPrimitive.Root>
|
|
85
|
-
</TooltipPrimitive.Provider>
|
|
86
|
-
);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const styles = `
|
|
90
|
-
|
|
91
|
-
.TooltipContent {
|
|
92
|
-
animation-duration: 220ms;
|
|
93
|
-
animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
|
|
94
|
-
will-change: transform, opacity;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.TooltipContent[data-state='delayed-open'][data-side='top'] {
|
|
98
|
-
animation-name: slideDownAndFade;
|
|
99
|
-
}
|
|
100
|
-
.TooltipContent[data-state='delayed-open'][data-side='right'] {
|
|
101
|
-
animation-name: slideLeftAndFade;
|
|
102
|
-
}
|
|
103
|
-
.TooltipContent[data-state='delayed-open'][data-side='bottom'] {
|
|
104
|
-
animation-name: slideUpAndFade;
|
|
105
|
-
}
|
|
106
|
-
.TooltipContent[data-state='delayed-open'][data-side='left'] {
|
|
107
|
-
animation-name: slideRightAndFade;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
@keyframes slideUpAndFade {
|
|
112
|
-
from {
|
|
113
|
-
opacity: 0;
|
|
114
|
-
transform: translateY(4px);
|
|
115
|
-
}
|
|
116
|
-
to {
|
|
117
|
-
opacity: 1;
|
|
118
|
-
transform: translateY(0);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
@keyframes slideRightAndFade {
|
|
123
|
-
from {
|
|
124
|
-
opacity: 0;
|
|
125
|
-
transform: translateX(-4px);
|
|
126
|
-
}
|
|
127
|
-
to {
|
|
128
|
-
opacity: 1;
|
|
129
|
-
transform: translateX(0);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
@keyframes slideDownAndFade {
|
|
134
|
-
from {
|
|
135
|
-
opacity: 0;
|
|
136
|
-
transform: translateY(-4px);
|
|
137
|
-
}
|
|
138
|
-
to {
|
|
139
|
-
opacity: 1;
|
|
140
|
-
transform: translateY(0);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
@keyframes slideLeftAndFade {
|
|
145
|
-
from {
|
|
146
|
-
opacity: 0;
|
|
147
|
-
transform: translateX(4px);
|
|
148
|
-
}
|
|
149
|
-
to {
|
|
150
|
-
opacity: 1;
|
|
151
|
-
transform: translateX(0);
|
|
152
|
-
}
|
|
153
|
-
}`;
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import React, { ReactEventHandler } from "react";
|
|
2
|
-
import { cls } from "../util";
|
|
3
|
-
|
|
4
|
-
export type TypographyVariant = keyof typeof typographyVariants;
|
|
5
|
-
export type TypographyProps<C extends React.ElementType = "span"> = {
|
|
6
|
-
align?: "center" | "inherit" | "justify" | "left" | "right";
|
|
7
|
-
children?: React.ReactNode;
|
|
8
|
-
className?: string;
|
|
9
|
-
component?: C;
|
|
10
|
-
gutterBottom?: boolean;
|
|
11
|
-
noWrap?: boolean;
|
|
12
|
-
paragraph?: boolean;
|
|
13
|
-
variant?: TypographyVariant;
|
|
14
|
-
variantMapping?: { [key: string]: string };
|
|
15
|
-
color?: "inherit" | "initial" | "primary" | "secondary" | "disabled" | "error";
|
|
16
|
-
onClick?: ReactEventHandler<HTMLElement>;
|
|
17
|
-
style?: React.CSSProperties;
|
|
18
|
-
} & React.ComponentPropsWithoutRef<C>;
|
|
19
|
-
|
|
20
|
-
const typographyVariants = {
|
|
21
|
-
h1: "h1",
|
|
22
|
-
h2: "h2",
|
|
23
|
-
h3: "h3",
|
|
24
|
-
h4: "h4",
|
|
25
|
-
h5: "h5",
|
|
26
|
-
h6: "h6",
|
|
27
|
-
subtitle1: "h6",
|
|
28
|
-
subtitle2: "h6",
|
|
29
|
-
label: "label",
|
|
30
|
-
body1: "p",
|
|
31
|
-
body2: "p",
|
|
32
|
-
inherit: "p",
|
|
33
|
-
caption: "p",
|
|
34
|
-
button: "span",
|
|
35
|
-
lead: "p",
|
|
36
|
-
micro: "span",
|
|
37
|
-
mono: "span",
|
|
38
|
-
stat: "span"
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const colorToClasses = {
|
|
42
|
-
inherit: "text-inherit",
|
|
43
|
-
initial: "text-current",
|
|
44
|
-
primary: "text-text-primary dark:text-text-primary-dark",
|
|
45
|
-
secondary: "text-text-secondary dark:text-text-secondary-dark",
|
|
46
|
-
disabled: "text-text-disabled dark:text-text-disabled-dark",
|
|
47
|
-
error: "text-red-600 dark:text-red-500"
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const gutterBottomClasses = {
|
|
51
|
-
h1: "mb-5",
|
|
52
|
-
h2: "mb-4",
|
|
53
|
-
h3: "mb-4",
|
|
54
|
-
h4: "mb-4",
|
|
55
|
-
h5: "mb-3",
|
|
56
|
-
h6: "mb-3",
|
|
57
|
-
subtitle1: "mb-3",
|
|
58
|
-
subtitle2: "mb-3",
|
|
59
|
-
body1: "mb-3",
|
|
60
|
-
body2: "mb-3",
|
|
61
|
-
inherit: "mb-3",
|
|
62
|
-
caption: "mb-2",
|
|
63
|
-
button: "mb-2",
|
|
64
|
-
label: "mb-2",
|
|
65
|
-
lead: "mb-4",
|
|
66
|
-
micro: "mb-1",
|
|
67
|
-
mono: "mb-2",
|
|
68
|
-
stat: "mb-1"
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const variantToClasses = {
|
|
72
|
-
h1: "typography-h1",
|
|
73
|
-
h2: "typography-h2",
|
|
74
|
-
h3: "typography-h3",
|
|
75
|
-
h4: "typography-h4",
|
|
76
|
-
h5: "typography-h5",
|
|
77
|
-
h6: "typography-h6",
|
|
78
|
-
subtitle1: "typography-subtitle1",
|
|
79
|
-
subtitle2: "typography-subtitle2",
|
|
80
|
-
body1: "typography-body1",
|
|
81
|
-
body2: "typography-body2",
|
|
82
|
-
label: "typography-label",
|
|
83
|
-
inherit: "typography-inherit",
|
|
84
|
-
caption: "typography-caption",
|
|
85
|
-
button: "typography-button",
|
|
86
|
-
lead: "typography-lead",
|
|
87
|
-
micro: "typography-micro",
|
|
88
|
-
mono: "typography-mono",
|
|
89
|
-
stat: "typography-stat"
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export function Typography<C extends React.ElementType = "span">(
|
|
93
|
-
{
|
|
94
|
-
align = "inherit",
|
|
95
|
-
color = "primary",
|
|
96
|
-
children,
|
|
97
|
-
className,
|
|
98
|
-
component,
|
|
99
|
-
gutterBottom = false,
|
|
100
|
-
noWrap = false,
|
|
101
|
-
paragraph = false,
|
|
102
|
-
variant = "body1",
|
|
103
|
-
variantMapping = typographyVariants,
|
|
104
|
-
style,
|
|
105
|
-
onClick,
|
|
106
|
-
...other
|
|
107
|
-
}: TypographyProps<C>
|
|
108
|
-
) {
|
|
109
|
-
const Component =
|
|
110
|
-
component ||
|
|
111
|
-
(paragraph ? "p" : variantMapping[variant] || typographyVariants[variant]) ||
|
|
112
|
-
"span";
|
|
113
|
-
|
|
114
|
-
const classes = cls(
|
|
115
|
-
variantToClasses[variant],
|
|
116
|
-
color ? colorToClasses[color] : "",
|
|
117
|
-
align !== "inherit" && `text-${align}`,
|
|
118
|
-
gutterBottom && gutterBottomClasses[variant],
|
|
119
|
-
noWrap && "truncate",
|
|
120
|
-
paragraph && "mb-3",
|
|
121
|
-
className
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
return (
|
|
125
|
-
<Component className={classes}
|
|
126
|
-
onClick={onClick}
|
|
127
|
-
style={style}
|
|
128
|
-
{...other}>
|
|
129
|
-
{children}
|
|
130
|
-
</Component>
|
|
131
|
-
);
|
|
132
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jest-environment jsdom
|
|
3
|
-
*/
|
|
4
|
-
import React from "react";
|
|
5
|
-
import { render } from "@testing-library/react";
|
|
6
|
-
import { VirtualTable } from "./VirtualTable";
|
|
7
|
-
import { VirtualTableProps } from "./VirtualTableProps";
|
|
8
|
-
|
|
9
|
-
// Counts executions of the row component body. The real VirtualTableRow is
|
|
10
|
-
// swapped for a memoized stub so the count reflects React's bail-out decision
|
|
11
|
-
// and nothing else.
|
|
12
|
-
const renderCallback = jest.fn();
|
|
13
|
-
jest.mock("./VirtualTableRow", () => {
|
|
14
|
-
const React = require("react");
|
|
15
|
-
// Memoized like the real component: without this the stub would re-render
|
|
16
|
-
// on any parent render and the count would say nothing about the context.
|
|
17
|
-
const VirtualTableRow = React.memo((props: any) => {
|
|
18
|
-
renderCallback();
|
|
19
|
-
return <div data-testid="row">{props.children}</div>;
|
|
20
|
-
});
|
|
21
|
-
VirtualTableRow.displayName = "VirtualTableRow";
|
|
22
|
-
return { VirtualTableRow };
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// Fixed bounds: the real hook measures nothing in jsdom, so the list would
|
|
26
|
-
// render zero rows.
|
|
27
|
-
jest.mock("react-use-measure", () => {
|
|
28
|
-
return () => [
|
|
29
|
-
(element: any) => {},
|
|
30
|
-
{ width: 500,
|
|
31
|
-
height: 500,
|
|
32
|
-
top: 0,
|
|
33
|
-
left: 0,
|
|
34
|
-
bottom: 0,
|
|
35
|
-
right: 0,
|
|
36
|
-
x: 0,
|
|
37
|
-
y: 0 }
|
|
38
|
-
];
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// jsdom has no ResizeObserver, and VirtualTable passes the global in as the
|
|
42
|
-
// `react-use-measure` polyfill — the identifier has to resolve even though the
|
|
43
|
-
// mock above means it is never constructed.
|
|
44
|
-
global.ResizeObserver = class ResizeObserver {
|
|
45
|
-
observe() {}
|
|
46
|
-
unobserve() {}
|
|
47
|
-
disconnect() {}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
describe("VirtualTable Performance", () => {
|
|
51
|
-
|
|
52
|
-
beforeEach(() => {
|
|
53
|
-
renderCallback.mockClear();
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it("does not re-render rows when VirtualTable re-renders but data is unchanged", async () => {
|
|
57
|
-
const columns = [{ key: "col1",
|
|
58
|
-
title: "Column 1",
|
|
59
|
-
width: 100 }];
|
|
60
|
-
const data = Array.from({ length: 10 }).map((_, i) => ({ col1: `Value ${i}` }));
|
|
61
|
-
const cellRenderer = () => <div>Cell</div>;
|
|
62
|
-
|
|
63
|
-
const props: VirtualTableProps<any> = {
|
|
64
|
-
data,
|
|
65
|
-
columns,
|
|
66
|
-
rowHeight: 50,
|
|
67
|
-
cellRenderer
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const { rerender } = render(<VirtualTable {...props}
|
|
71
|
-
className={"a"}/>);
|
|
72
|
-
|
|
73
|
-
const initialRenderCount = renderCallback.mock.calls.length;
|
|
74
|
-
expect(initialRenderCount).toBe(data.length);
|
|
75
|
-
|
|
76
|
-
// `className` is deliberately NOT one of the context memo's dependencies:
|
|
77
|
-
// changing it forces VirtualTable's body to run again (React.memo on the
|
|
78
|
-
// table itself would otherwise bail out) while every value the rows read
|
|
79
|
-
// stays identical.
|
|
80
|
-
rerender(<VirtualTable {...props}
|
|
81
|
-
className={"b"}/>);
|
|
82
|
-
|
|
83
|
-
// Rows read everything through VirtualListContext, and the value handed
|
|
84
|
-
// to the provider is memoized. If that memo goes away the provider gets a
|
|
85
|
-
// fresh object, every Consumer re-runs, and each one hands the row a new
|
|
86
|
-
// `style` object and a new children array — which defeats React.memo and
|
|
87
|
-
// re-renders all 10 rows. So an unchanged count is the whole assertion.
|
|
88
|
-
expect(renderCallback.mock.calls.length).toBe(initialRenderCount);
|
|
89
|
-
});
|
|
90
|
-
});
|