fix(redux-devtools-test-generator): fix devui's Select component (#637)

* Stash

* Fix stuff

* Unused

* Update snapshot
This commit is contained in:
Nathan Bierema 2020-09-19 19:24:18 -04:00 committed by GitHub
parent d49535da03
commit f9f15a41de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 3303 additions and 3260 deletions

View File

@ -47,7 +47,6 @@
"base16": "^1.0.0",
"codemirror": "^5.56.0",
"color": "^3.1.2",
"hoist-non-react-statics": "^3.3.2",
"prop-types": "^15.7.2",
"react-icons": "^3.10.0",
"react-jsonschema-form": "^1.8.1",

View File

@ -38,6 +38,11 @@ export class Select extends (PureComponent || Component)<SelectProps> {
neutral60: this.props.theme.base06,
neutral80: this.props.theme.base07,
},
spacing: {
...theme.spacing,
baseUnit: 2,
controlHeight: this.props.theme.inputHeight,
},
})}
/>
);

View File

@ -1,5 +1,4 @@
import React, { ComponentType } from 'react';
import hoistNonReactStatics from 'hoist-non-react-statics';
import React from 'react';
import getDefaultTheme, { Theme } from '../themes/default';
import { withTheme } from 'styled-components';
import { Base16Theme } from 'base16';
@ -9,33 +8,16 @@ export default <C extends React.ComponentType<any>>(
? C
: never
) => {
const ThemedComponent = React.forwardRef<C, React.ComponentProps<C>>(
(props, ref) => {
// eslint-disable-next-line react/prop-types
if (props.theme && props.theme.type) {
const ThemedComponent = withTheme(
UnthemedComponent as ComponentType<{ theme?: Theme }>
);
return <ThemedComponent {...props} ref={ref} />;
}
const UnthemedComponentAny = UnthemedComponent as any;
return (
<UnthemedComponentAny
return withTheme((props) => {
return props.theme && props.theme.type ? (
<UnthemedComponent {...props} />
) : (
<UnthemedComponent
{...props}
ref={ref}
theme={getDefaultTheme({} as Base16Theme)}
theme={getDefaultTheme((props.theme ?? {}) as Base16Theme)}
/>
);
}
);
hoistNonReactStatics(ThemedComponent, UnthemedComponent);
ThemedComponent.displayName = `ThemedComponent(${
UnthemedComponent.displayName ?? 'Component'
})`;
return ThemedComponent;
});
};
// TODO: memoize it?

View File

@ -5,18 +5,18 @@ exports[`Select renders correctly 1`] = `
class=" css-2b097c-container"
>
<div
class=" css-1960ht7-control"
class=" css-vmgz7k-control"
>
<div
class=" css-g1d714-ValueContainer"
class=" css-be27w2-ValueContainer"
>
<div
class=" css-1wa3eu0-placeholder"
class=" css-1osw1h9-placeholder"
>
Select...
</div>
<div
class="css-ybs8ec-Input"
class="css-187dxxn-Input"
>
<div
class=""
@ -44,11 +44,11 @@ exports[`Select renders correctly 1`] = `
class=" css-1hb7zxy-IndicatorsContainer"
>
<span
class=" css-bqiiy2-indicatorSeparator"
class=" css-1urf5ax-indicatorSeparator"
/>
<div
aria-hidden="true"
class=" css-kaqmzc-indicatorContainer"
class=" css-aazq4s-indicatorContainer"
>
<svg
aria-hidden="true"
@ -73,18 +73,18 @@ exports[`Select renders with props 1`] = `
class=" css-2b097c-container"
>
<div
class=" css-1960ht7-control"
class=" css-vmgz7k-control"
>
<div
class=" css-g1d714-ValueContainer"
class=" css-be27w2-ValueContainer"
>
<div
class=" css-1wa3eu0-placeholder"
class=" css-1osw1h9-placeholder"
>
Select...
</div>
<div
class="css-ybs8ec-Input"
class="css-187dxxn-Input"
>
<div
class=""
@ -113,7 +113,7 @@ exports[`Select renders with props 1`] = `
>
<div
aria-hidden="true"
class=" css-1k7leo4-loadingIndicator"
class=" css-1gilzap-loadingIndicator"
>
<span
class="css-1yvy2vo-LoadingDot"
@ -126,11 +126,11 @@ exports[`Select renders with props 1`] = `
/>
</div>
<span
class=" css-bqiiy2-indicatorSeparator"
class=" css-1urf5ax-indicatorSeparator"
/>
<div
aria-hidden="true"
class=" css-kaqmzc-indicatorContainer"
class=" css-aazq4s-indicatorContainer"
>
<svg
aria-hidden="true"
@ -151,7 +151,7 @@ exports[`Select renders with props 1`] = `
`;
exports[`Select should select another option 1`] = `
<ThemedComponent(Component)
<WithTheme(Component)
onInputChange={
[MockFunction] {
"calls": Array [
@ -187,6 +187,42 @@ exports[`Select should select another option 1`] = `
]
}
>
<Component
onInputChange={
[MockFunction] {
"calls": Array [
Array [
"two",
Object {
"action": "input-change",
},
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
],
}
}
options={
Array [
Object {
"label": "One",
"value": "one",
},
Object {
"label": "Two",
"value": "two",
},
Object {
"label": "One hundred",
"value": "hundred",
},
]
}
>
<Select
onInputChange={
[MockFunction] {
@ -455,8 +491,8 @@ exports[`Select should select another option 1`] = `
"primary75": "#4C9AFF",
},
"spacing": Object {
"baseUnit": 4,
"controlHeight": 38,
"baseUnit": 2,
"controlHeight": 30,
"menuGutter": 8,
},
}
@ -600,8 +636,8 @@ exports[`Select should select another option 1`] = `
"primary75": "#4C9AFF",
},
"spacing": Object {
"baseUnit": 4,
"controlHeight": 38,
"baseUnit": 2,
"controlHeight": 30,
"menuGutter": 8,
},
}
@ -629,7 +665,7 @@ exports[`Select should select another option 1`] = `
"flexWrap": "wrap",
"justifyContent": "space-between",
"label": "control",
"minHeight": 38,
"minHeight": 30,
"outline": "0 !important",
"position": "relative",
"transition": "all 100ms",
@ -639,7 +675,7 @@ exports[`Select should select another option 1`] = `
onTouchEnd={[Function]}
>
<div
className=" css-1960ht7-control"
className=" css-vmgz7k-control"
onMouseDown={[Function]}
onTouchEnd={[Function]}
>
@ -753,8 +789,8 @@ exports[`Select should select another option 1`] = `
"primary75": "#4C9AFF",
},
"spacing": Object {
"baseUnit": 4,
"controlHeight": 38,
"baseUnit": 2,
"controlHeight": 30,
"menuGutter": 8,
},
}
@ -773,13 +809,13 @@ exports[`Select should select another option 1`] = `
"flex": 1,
"flexWrap": "wrap",
"overflow": "hidden",
"padding": "2px 8px",
"padding": "1px 4px",
"position": "relative",
}
}
>
<div
className=" css-g1d714-ValueContainer"
className=" css-be27w2-ValueContainer"
>
<Input
aria-autocomplete="list"
@ -880,8 +916,8 @@ exports[`Select should select another option 1`] = `
"primary75": "#4C9AFF",
},
"spacing": Object {
"baseUnit": 4,
"controlHeight": 38,
"baseUnit": 2,
"controlHeight": 30,
"menuGutter": 8,
},
}
@ -896,15 +932,15 @@ exports[`Select should select another option 1`] = `
Object {
"boxSizing": "border-box",
"color": undefined,
"margin": 2,
"paddingBottom": 2,
"paddingTop": 2,
"margin": 1,
"paddingBottom": 1,
"paddingTop": 1,
"visibility": "visible",
}
}
>
<div
className="css-ybs8ec-Input"
className="css-187dxxn-Input"
>
<AutosizeInput
aria-autocomplete="list"
@ -1107,8 +1143,8 @@ exports[`Select should select another option 1`] = `
"primary75": "#4C9AFF",
},
"spacing": Object {
"baseUnit": 4,
"controlHeight": 38,
"baseUnit": 2,
"controlHeight": 30,
"menuGutter": 8,
},
}
@ -1242,8 +1278,8 @@ exports[`Select should select another option 1`] = `
"primary75": "#4C9AFF",
},
"spacing": Object {
"baseUnit": 4,
"controlHeight": 38,
"baseUnit": 2,
"controlHeight": 30,
"menuGutter": 8,
},
}
@ -1259,14 +1295,14 @@ exports[`Select should select another option 1`] = `
"backgroundColor": undefined,
"boxSizing": "border-box",
"label": "indicatorSeparator",
"marginBottom": 8,
"marginTop": 8,
"marginBottom": 4,
"marginTop": 4,
"width": 1,
}
}
>
<span
className=" css-bqiiy2-indicatorSeparator"
className=" css-1urf5ax-indicatorSeparator"
/>
</EmotionCssPropInternal>
</IndicatorSeparator>
@ -1388,8 +1424,8 @@ exports[`Select should select another option 1`] = `
"primary75": "#4C9AFF",
},
"spacing": Object {
"baseUnit": 4,
"controlHeight": 38,
"baseUnit": 2,
"controlHeight": 30,
"menuGutter": 8,
},
}
@ -1409,7 +1445,7 @@ exports[`Select should select another option 1`] = `
"color": undefined,
"display": "flex",
"label": "indicatorContainer",
"padding": 8,
"padding": 4,
"transition": "color 150ms",
}
}
@ -1418,7 +1454,7 @@ exports[`Select should select another option 1`] = `
>
<div
aria-hidden="true"
className=" css-kaqmzc-indicatorContainer"
className=" css-aazq4s-indicatorContainer"
onMouseDown={[Function]}
onTouchEnd={[Function]}
>
@ -1580,8 +1616,8 @@ exports[`Select should select another option 1`] = `
"primary75": "#4C9AFF",
},
"spacing": Object {
"baseUnit": 4,
"controlHeight": 38,
"baseUnit": 2,
"controlHeight": 30,
"menuGutter": 8,
},
}
@ -1710,8 +1746,8 @@ exports[`Select should select another option 1`] = `
"primary75": "#4C9AFF",
},
"spacing": Object {
"baseUnit": 4,
"controlHeight": 38,
"baseUnit": 2,
"controlHeight": 30,
"menuGutter": 8,
},
}
@ -1862,8 +1898,8 @@ exports[`Select should select another option 1`] = `
"primary75": "#4C9AFF",
},
"spacing": Object {
"baseUnit": 4,
"controlHeight": 38,
"baseUnit": 2,
"controlHeight": 30,
"menuGutter": 8,
},
}
@ -1879,14 +1915,14 @@ exports[`Select should select another option 1`] = `
"boxSizing": "border-box",
"maxHeight": 300,
"overflowY": "auto",
"paddingBottom": 4,
"paddingTop": 4,
"paddingBottom": 2,
"paddingTop": 2,
"position": "relative",
}
}
>
<div
className=" css-4ljt47-MenuList"
className=" css-87spde-MenuList"
>
<Option
clearValue={[Function]}
@ -2018,8 +2054,8 @@ exports[`Select should select another option 1`] = `
"primary75": "#4C9AFF",
},
"spacing": Object {
"baseUnit": 4,
"controlHeight": 38,
"baseUnit": 2,
"controlHeight": 30,
"menuGutter": 8,
},
}
@ -2044,7 +2080,7 @@ exports[`Select should select another option 1`] = `
"display": "block",
"fontSize": "inherit",
"label": "option",
"padding": "8px 12px",
"padding": "4px 6px",
"userSelect": "none",
"width": "100%",
}
@ -2056,7 +2092,7 @@ exports[`Select should select another option 1`] = `
tabIndex={-1}
>
<div
className=" css-1gm74v5-option"
className=" css-1npzjqc-option"
id="react-select-4-option-1"
onClick={[Function]}
onMouseMove={[Function]}
@ -2082,11 +2118,12 @@ exports[`Select should select another option 1`] = `
</Select>
</StateManager>
</Select>
</ThemedComponent(Component)>
</Component>
</WithTheme(Component)>
`;
exports[`Select shouldn't find any results 1`] = `
<ThemedComponent(Component)
<WithTheme(Component)
onChange={[MockFunction]}
options={
Array [
@ -2105,6 +2142,25 @@ exports[`Select shouldn't find any results 1`] = `
]
}
>
<Component
onChange={[MockFunction]}
options={
Array [
Object {
"label": "One",
"value": "one",
},
Object {
"label": "Two",
"value": "two",
},
Object {
"label": "One hundred",
"value": "hundred",
},
]
}
>
<Select
onChange={[MockFunction]}
options={
@ -2339,8 +2395,8 @@ exports[`Select shouldn't find any results 1`] = `
"primary75": "#4C9AFF",
},
"spacing": Object {
"baseUnit": 4,
"controlHeight": 38,
"baseUnit": 2,
"controlHeight": 30,
"menuGutter": 8,
},
}
@ -2484,8 +2540,8 @@ exports[`Select shouldn't find any results 1`] = `
"primary75": "#4C9AFF",
},
"spacing": Object {
"baseUnit": 4,
"controlHeight": 38,
"baseUnit": 2,
"controlHeight": 30,
"menuGutter": 8,
},
}
@ -2513,7 +2569,7 @@ exports[`Select shouldn't find any results 1`] = `
"flexWrap": "wrap",
"justifyContent": "space-between",
"label": "control",
"minHeight": 38,
"minHeight": 30,
"outline": "0 !important",
"position": "relative",
"transition": "all 100ms",
@ -2523,7 +2579,7 @@ exports[`Select shouldn't find any results 1`] = `
onTouchEnd={[Function]}
>
<div
className=" css-1960ht7-control"
className=" css-vmgz7k-control"
onMouseDown={[Function]}
onTouchEnd={[Function]}
>
@ -2637,8 +2693,8 @@ exports[`Select shouldn't find any results 1`] = `
"primary75": "#4C9AFF",
},
"spacing": Object {
"baseUnit": 4,
"controlHeight": 38,
"baseUnit": 2,
"controlHeight": 30,
"menuGutter": 8,
},
}
@ -2657,13 +2713,13 @@ exports[`Select shouldn't find any results 1`] = `
"flex": 1,
"flexWrap": "wrap",
"overflow": "hidden",
"padding": "2px 8px",
"padding": "1px 4px",
"position": "relative",
}
}
>
<div
className=" css-g1d714-ValueContainer"
className=" css-be27w2-ValueContainer"
>
<Input
aria-autocomplete="list"
@ -2764,8 +2820,8 @@ exports[`Select shouldn't find any results 1`] = `
"primary75": "#4C9AFF",
},
"spacing": Object {
"baseUnit": 4,
"controlHeight": 38,
"baseUnit": 2,
"controlHeight": 30,
"menuGutter": 8,
},
}
@ -2780,15 +2836,15 @@ exports[`Select shouldn't find any results 1`] = `
Object {
"boxSizing": "border-box",
"color": undefined,
"margin": 2,
"paddingBottom": 2,
"paddingTop": 2,
"margin": 1,
"paddingBottom": 1,
"paddingTop": 1,
"visibility": "visible",
}
}
>
<div
className="css-ybs8ec-Input"
className="css-187dxxn-Input"
>
<AutosizeInput
aria-autocomplete="list"
@ -2991,8 +3047,8 @@ exports[`Select shouldn't find any results 1`] = `
"primary75": "#4C9AFF",
},
"spacing": Object {
"baseUnit": 4,
"controlHeight": 38,
"baseUnit": 2,
"controlHeight": 30,
"menuGutter": 8,
},
}
@ -3126,8 +3182,8 @@ exports[`Select shouldn't find any results 1`] = `
"primary75": "#4C9AFF",
},
"spacing": Object {
"baseUnit": 4,
"controlHeight": 38,
"baseUnit": 2,
"controlHeight": 30,
"menuGutter": 8,
},
}
@ -3143,14 +3199,14 @@ exports[`Select shouldn't find any results 1`] = `
"backgroundColor": undefined,
"boxSizing": "border-box",
"label": "indicatorSeparator",
"marginBottom": 8,
"marginTop": 8,
"marginBottom": 4,
"marginTop": 4,
"width": 1,
}
}
>
<span
className=" css-bqiiy2-indicatorSeparator"
className=" css-1urf5ax-indicatorSeparator"
/>
</EmotionCssPropInternal>
</IndicatorSeparator>
@ -3272,8 +3328,8 @@ exports[`Select shouldn't find any results 1`] = `
"primary75": "#4C9AFF",
},
"spacing": Object {
"baseUnit": 4,
"controlHeight": 38,
"baseUnit": 2,
"controlHeight": 30,
"menuGutter": 8,
},
}
@ -3293,7 +3349,7 @@ exports[`Select shouldn't find any results 1`] = `
"color": undefined,
"display": "flex",
"label": "indicatorContainer",
"padding": 8,
"padding": 4,
"transition": "color 150ms",
}
}
@ -3302,7 +3358,7 @@ exports[`Select shouldn't find any results 1`] = `
>
<div
aria-hidden="true"
className=" css-kaqmzc-indicatorContainer"
className=" css-aazq4s-indicatorContainer"
onMouseDown={[Function]}
onTouchEnd={[Function]}
>
@ -3464,8 +3520,8 @@ exports[`Select shouldn't find any results 1`] = `
"primary75": "#4C9AFF",
},
"spacing": Object {
"baseUnit": 4,
"controlHeight": 38,
"baseUnit": 2,
"controlHeight": 30,
"menuGutter": 8,
},
}
@ -3594,8 +3650,8 @@ exports[`Select shouldn't find any results 1`] = `
"primary75": "#4C9AFF",
},
"spacing": Object {
"baseUnit": 4,
"controlHeight": 38,
"baseUnit": 2,
"controlHeight": 30,
"menuGutter": 8,
},
}
@ -3746,8 +3802,8 @@ exports[`Select shouldn't find any results 1`] = `
"primary75": "#4C9AFF",
},
"spacing": Object {
"baseUnit": 4,
"controlHeight": 38,
"baseUnit": 2,
"controlHeight": 30,
"menuGutter": 8,
},
}
@ -3763,14 +3819,14 @@ exports[`Select shouldn't find any results 1`] = `
"boxSizing": "border-box",
"maxHeight": 300,
"overflowY": "auto",
"paddingBottom": 4,
"paddingTop": 4,
"paddingBottom": 2,
"paddingTop": 2,
"position": "relative",
}
}
>
<div
className=" css-4ljt47-MenuList"
className=" css-87spde-MenuList"
>
<NoOptionsMessage
clearValue={[Function]}
@ -3881,8 +3937,8 @@ exports[`Select shouldn't find any results 1`] = `
"primary75": "#4C9AFF",
},
"spacing": Object {
"baseUnit": 4,
"controlHeight": 38,
"baseUnit": 2,
"controlHeight": 30,
"menuGutter": 8,
},
}
@ -3896,13 +3952,13 @@ exports[`Select shouldn't find any results 1`] = `
Object {
"boxSizing": "border-box",
"color": undefined,
"padding": "8px 12px",
"padding": "4px 6px",
"textAlign": "center",
}
}
>
<div
className=" css-mzubzw-NoOptionsMessage"
className=" css-36co7-NoOptionsMessage"
>
No options
</div>
@ -3923,5 +3979,6 @@ exports[`Select shouldn't find any results 1`] = `
</Select>
</StateManager>
</Select>
</ThemedComponent(Component)>
</Component>
</WithTheme(Component)>
`;

View File

@ -1,5 +1,4 @@
import React, { PureComponent, Component, ReactNode } from 'react';
import PropTypes from 'prop-types';
import { stringify } from 'javascript-stringify';
import objectPath from 'object-path';
import jsan from 'jsan';

View File

@ -130,14 +130,15 @@ export default class TestTab<S, A extends Action<unknown>> extends Component<
return (
<Container>
<Toolbar>
<div style={{ flexGrow: 1, zIndex: 100 }}>
<Select
options={templates}
valueKey="name"
labelKey="name"
value={name}
simpleValue={false}
getOptionValue={(template: Template) => template.name}
getOptionLabel={(template: Template) => template.name}
value={templates.filter((template) => template.name === name)}
onChange={this.handleSelectTemplate}
/>
</div>
<Button onClick={this.editTemplate}>
<MdEdit />
</Button>

View File

@ -9357,7 +9357,7 @@ hmac-drbg@^1.0.0:
minimalistic-assert "^1.0.0"
minimalistic-crypto-utils "^1.0.1"
hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.2:
hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0:
version "3.3.2"
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45"
integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==