graphen 1.9.11 → 1.10.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.
@@ -1,18 +1,17 @@
1
- // @flow
2
1
  import _ from "lodash";
3
2
  import React from "react";
4
3
  import classNames from "classnames";
5
4
 
6
5
  type Props = {
7
6
  type: string,
8
- className: string
7
+ className: string,
9
8
  };
10
9
 
11
10
  const Icon = (props: Props) => {
12
11
  const { type, className } = props;
13
12
 
14
13
  const classes = classNames("gc-icon", className, {
15
- [`gc-icon--${type}`]: !_.isEmpty(type)
14
+ [`gc-icon--${type}`]: !_.isEmpty(type),
16
15
  });
17
16
 
18
17
  return <span className={classes} />;
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  import React from "react";
3
2
  import classNames from "classnames";
4
3
 
@@ -6,10 +5,10 @@ type Props = {
6
5
  src: string,
7
6
  className?: string,
8
7
  height?: number,
9
- width?: number
8
+ width?: number,
10
9
  };
11
10
 
12
- export default function Image(props: Props) {
11
+ function Image(props: Props) {
13
12
  const { src, height, width, className } = props;
14
13
  const classes = classNames("gc-image", className);
15
14
 
@@ -24,3 +23,13 @@ export default function Image(props: Props) {
24
23
  </object>
25
24
  );
26
25
  }
26
+
27
+ // @ts-ignore
28
+ Image.defaultProps = {
29
+ className: '',
30
+ height: 200,
31
+ width: 200,
32
+ };
33
+
34
+
35
+ export default Image;
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  import React from "react";
3
2
  import classNames from "classnames";
4
3
 
@@ -7,7 +6,7 @@ type Props = {
7
6
  type?: string,
8
7
  label: string,
9
8
  validation?: string,
10
- onChange?: Event => void
9
+ onChange?: React.ChangeEventHandler<HTMLInputElement>,
11
10
  };
12
11
 
13
12
  function Input(props: Props) {
@@ -15,7 +14,7 @@ function Input(props: Props) {
15
14
  const inputClasses = classNames(className, "gc-input");
16
15
  const fieldClasses = classNames("gc-input__field", {
17
16
  "gc-input__field--success": validation === "success",
18
- "gc-input__field--danger": validation === "danger"
17
+ "gc-input__field--danger": validation === "danger",
19
18
  });
20
19
  const id = `input-${label}`;
21
20
 
@@ -29,4 +28,12 @@ function Input(props: Props) {
29
28
  );
30
29
  }
31
30
 
31
+ // @ts-ignore
32
+ Input.defaultProps = {
33
+ className: '',
34
+ type: '',
35
+ validation: undefined,
36
+ onChange: () => {},
37
+ };
38
+
32
39
  export default Input;
@@ -1,38 +1,33 @@
1
- // @flow
2
1
  import _ from "lodash";
3
- import React from "react";
2
+ import React from 'react';
4
3
  import ReactDOM from "react-dom";
5
4
 
6
5
  type Props = {
7
6
  onPositionChange: (left: number, top: number) => void,
8
- isEnabled: boolean
7
+ isEnabled: boolean,
9
8
  };
10
9
 
11
10
  type State = {
12
11
  left: number,
13
- top: number
12
+ top: number,
14
13
  };
15
14
 
16
15
  const JOYSTICK_RADIUS = 50;
17
16
 
18
17
  class Joystick extends React.PureComponent<Props, State> {
19
- static onDragOver(event: SyntheticDragEvent<HTMLDivElement>) {
18
+ static onDragOver(event: React.DragEvent<HTMLDivElement>) {
20
19
  event.preventDefault();
21
20
  }
22
21
 
23
- static defaultProps = {
24
- isEnabled: true
25
- };
26
-
27
- constructor() {
28
- super();
22
+ constructor(props: Props) {
23
+ super(props);
29
24
  this.state = {
30
25
  left: JOYSTICK_RADIUS * 0.5,
31
- top: JOYSTICK_RADIUS * 0.5
26
+ top: JOYSTICK_RADIUS * 0.5,
32
27
  };
33
28
  }
34
29
 
35
- onMove(event: SyntheticDragEvent<Element>) {
30
+ onMove(event: React.DragEvent<HTMLDivElement>) {
36
31
  event.preventDefault();
37
32
  const { clientX, clientY } = event;
38
33
 
@@ -49,7 +44,7 @@ class Joystick extends React.PureComponent<Props, State> {
49
44
  this.move(mappedX, mappedY);
50
45
  }
51
46
 
52
- onDragEnd(event: SyntheticDragEvent<Element>) {
47
+ onDragEnd(event: React.DragEvent<HTMLDivElement>) {
53
48
  event.preventDefault();
54
49
  this.move(JOYSTICK_RADIUS * 0.5, JOYSTICK_RADIUS * 0.5);
55
50
  }
@@ -63,7 +58,7 @@ class Joystick extends React.PureComponent<Props, State> {
63
58
  onPositionChange(left, top);
64
59
  this.setState({
65
60
  left,
66
- top
61
+ top,
67
62
  });
68
63
  }
69
64
 
@@ -74,26 +69,29 @@ class Joystick extends React.PureComponent<Props, State> {
74
69
  const classes = `gc-joystick${isEnabled ? "" : " gc-joystick--inactive"}`;
75
70
 
76
71
  return (
77
- <div className={classes} onDragOver={event => Joystick.onDragOver(event)}>
72
+ <div
73
+ className={classes}
74
+ onDragOver={(event) => Joystick.onDragOver(event)}
75
+ >
78
76
  <div
79
77
  className="gc-joystick__knob"
80
78
  style={{
81
79
  left,
82
- top
80
+ top,
83
81
  }}
84
82
  />
85
83
  <div
86
84
  className="gc-joystick__drag"
87
85
  draggable={isEnabled}
88
- onDrag={(event: SyntheticDragEvent<HTMLDivElement>) => {
86
+ onDrag={(event: React.DragEvent<HTMLDivElement>) => {
89
87
  this.onMove(event);
90
88
  }}
91
- onDragEnd={(event: SyntheticDragEvent<HTMLDivElement>) => {
89
+ onDragEnd={(event: React.DragEvent<HTMLDivElement>) => {
92
90
  this.onDragEnd(event);
93
91
  }}
94
92
  style={{
95
93
  left,
96
- top
94
+ top,
97
95
  }}
98
96
  />
99
97
  </div>
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  import React from "react";
3
2
  import classNames from "classnames";
4
3
  import * as constants from "src/variables/constants";
@@ -6,19 +5,19 @@ import * as constants from "src/variables/constants";
6
5
  type Props = {
7
6
  link: string,
8
7
  className?: string,
9
- children?: React.DOM,
10
- skin?: constants.Skin
8
+ children?: React.ReactNode,
9
+ skin?: constants.Skin,
11
10
  };
12
11
 
13
12
  function Link({
14
13
  link,
15
14
  className,
16
15
  children,
17
- skin = constants.SKINS.primary
16
+ skin = constants.SKINS.primary,
18
17
  }: Props) {
19
18
  const classes = classNames("gc-link", className, {
20
19
  "gc-link--primary": skin === constants.SKINS.primary,
21
- "gc-link--default": skin === constants.SKINS.default
20
+ "gc-link--default": skin === constants.SKINS.default,
22
21
  });
23
22
 
24
23
  return (
@@ -28,4 +27,11 @@ function Link({
28
27
  );
29
28
  }
30
29
 
30
+ // @ts-ignore
31
+ Link.defaultProps = {
32
+ className: '',
33
+ children: null,
34
+ skin: undefined,
35
+ };
36
+
31
37
  export default Link;
@@ -4,7 +4,7 @@ import classNames from "classnames";
4
4
 
5
5
  type Props = {
6
6
  className?: string,
7
- onClick?: () => void
7
+ onClick?: () => void,
8
8
  };
9
9
 
10
10
  function Logo(props: Props) {
@@ -21,4 +21,10 @@ function Logo(props: Props) {
21
21
  /* eslint-enable jsx-a11y/no-static-element-interactions */
22
22
  }
23
23
 
24
+ // @ts-ignore
25
+ Logo.defaultProps = {
26
+ className: '',
27
+ onClick: () => {},
28
+ };
29
+
24
30
  export default Logo;
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  import _ from "lodash";
3
2
  import React from "react";
4
3
  import ReactDOM from "react-dom";
@@ -9,28 +8,28 @@ const BORDER_SIZE = 1;
9
8
  type Props = {
10
9
  onScrollChange: (value: number) => void,
11
10
  min: number,
12
- max: number
11
+ max: number,
13
12
  };
14
13
 
15
14
  type State = {
16
- value: number
15
+ value: number,
17
16
  };
18
17
 
19
18
  class Scroller extends React.PureComponent<Props, State> {
20
- constructor() {
21
- super();
19
+ constructor(props: Props) {
20
+ super(props);
22
21
  this.state = {
23
- value: 0
22
+ value: 0,
24
23
  };
25
24
  }
26
25
 
27
- onMove(event: SyntheticDragEvent<Element>) {
26
+ onMove(event: React.DragEvent<HTMLDivElement>) {
28
27
  event.preventDefault();
29
28
  this.scroll(event);
30
29
  return false;
31
30
  }
32
31
 
33
- onDrop(event: SyntheticDragEvent<Element>) {
32
+ onDrop(event: React.DragEvent<HTMLDivElement>) {
34
33
  event.preventDefault();
35
34
  const { onScrollChange } = this.props;
36
35
  const { value } = this.state;
@@ -39,7 +38,7 @@ class Scroller extends React.PureComponent<Props, State> {
39
38
  return false;
40
39
  }
41
40
 
42
- scroll(event: SyntheticDragEvent<Element>) {
41
+ scroll(event: React.DragEvent<HTMLDivElement>) {
43
42
  const { clientX } = event;
44
43
  const { min, max } = this.props;
45
44
 
@@ -60,11 +59,11 @@ class Scroller extends React.PureComponent<Props, State> {
60
59
  move(x: number, vx: number, maxWidth: number) {
61
60
  const value = _.min([
62
61
  _.max([x, 0]),
63
- maxWidth - KNOB_SIZE - 2 * BORDER_SIZE
62
+ maxWidth - KNOB_SIZE - 2 * BORDER_SIZE,
64
63
  ]);
65
64
 
66
65
  this.setState({
67
- value
66
+ value,
68
67
  });
69
68
  }
70
69
 
@@ -74,28 +73,28 @@ class Scroller extends React.PureComponent<Props, State> {
74
73
  return (
75
74
  <div
76
75
  className="gc-scroller"
77
- onDragOver={(event: SyntheticDragEvent<HTMLDivElement>) => {
76
+ onDragOver={(event: React.DragEvent<HTMLDivElement>) => {
78
77
  event.preventDefault();
79
78
  return false;
80
79
  }}
81
- onDrop={(event: SyntheticDragEvent<HTMLDivElement>) => {
80
+ onDrop={(event: React.DragEvent<HTMLDivElement>) => {
82
81
  this.onDrop(event);
83
82
  }}
84
83
  >
85
84
  <div
86
85
  className="gc-scroller__knob"
87
86
  style={{
88
- left: value
87
+ left: value,
89
88
  }}
90
89
  />
91
90
  <div
92
91
  className="gc-scroller__drag"
93
92
  draggable="true"
94
- onDrag={(event: SyntheticDragEvent<HTMLDivElement>) => {
93
+ onDrag={(event: React.DragEvent<HTMLDivElement>) => {
95
94
  this.onMove(event);
96
95
  }}
97
96
  style={{
98
- left: value
97
+ left: value,
99
98
  }}
100
99
  />
101
100
  </div>
@@ -1,21 +1,27 @@
1
- // @flow
2
1
  import React from "react";
3
2
  import classNames from "classnames";
4
3
 
5
4
  type Props = {
6
5
  className?: string,
7
6
  children?: string,
8
- type?: string
7
+ type?: string,
9
8
  };
10
9
 
11
10
  function Tooltip(props: Props) {
12
11
  const { children, className, type } = props;
13
12
  const validationClasses = classNames(className, "gc-tooltip", {
14
13
  "gc-tooltip--success": type === "success",
15
- "gc-tooltip--danger": type === "danger"
14
+ "gc-tooltip--danger": type === "danger",
16
15
  });
17
16
 
18
17
  return <div className={validationClasses}>{children}</div>;
19
18
  }
20
19
 
20
+ // @ts-ignore
21
+ Tooltip.defaultProps = {
22
+ className: '',
23
+ children: null,
24
+ type: 'success',
25
+ };
26
+
21
27
  export default Tooltip;
@@ -1,13 +1,12 @@
1
- // @flow
2
1
  import React from "react";
3
2
  import classNames from "classnames";
4
3
  import Tooltip from "../Tooltip";
5
4
 
6
5
  type Props = {
7
6
  className?: string,
8
- children?: React$Element<any>,
7
+ children?: React.ReactNode,
9
8
  type?: string,
10
- message?: string | null
9
+ message?: string | null,
11
10
  };
12
11
 
13
12
  function Validation(props: Props) {
@@ -28,4 +27,12 @@ function Validation(props: Props) {
28
27
  );
29
28
  }
30
29
 
30
+ // @ts-ignore
31
+ Validation.defaultProps = {
32
+ className: '',
33
+ children: null,
34
+ type: 'success',
35
+ message: null,
36
+ };
37
+
31
38
  export default Validation;
@@ -1,4 +1,4 @@
1
- // @flow
1
+ /* eslint-disable */
2
2
  import _ from "lodash";
3
3
  import React from "react";
4
4
  import { render } from "react-dom";
@@ -17,7 +17,7 @@ import {
17
17
  Tooltip,
18
18
  Logo,
19
19
  Dropdown,
20
- constants
20
+ constants,
21
21
  } from "./index";
22
22
 
23
23
  const appContainer = document.querySelector(".js-example");
@@ -25,26 +25,26 @@ const appContainer = document.querySelector(".js-example");
25
25
  type Props = {};
26
26
 
27
27
  type State = {
28
- isDialogVisible: boolean
28
+ isDialogVisible: boolean,
29
29
  };
30
30
 
31
31
  class ExampleApp extends React.PureComponent<Props, State> {
32
32
  constructor(props: Props) {
33
33
  super(props);
34
34
  this.state = {
35
- isDialogVisible: false
35
+ isDialogVisible: false,
36
36
  };
37
37
  }
38
38
 
39
39
  handleShowDialog() {
40
40
  this.setState(() => ({
41
- isDialogVisible: true
41
+ isDialogVisible: true,
42
42
  }));
43
43
  }
44
44
 
45
45
  handleHideDialog() {
46
46
  this.setState(() => ({
47
- isDialogVisible: false
47
+ isDialogVisible: false,
48
48
  }));
49
49
  }
50
50
 
@@ -618,7 +618,7 @@ class ExampleApp extends React.PureComponent<Props, State> {
618
618
  label="Dropdown label"
619
619
  items={[
620
620
  { label: "Red", value: "red" },
621
- { label: "Blue", value: "blue" }
621
+ { label: "Blue", value: "blue" },
622
622
  ]}
623
623
  onChange={_.noop}
624
624
  />
@@ -637,3 +637,4 @@ if (appContainer) {
637
637
  appContainer
638
638
  );
639
639
  }
640
+ /* eslint-enable */
@@ -1,3 +1,11 @@
1
+ .gm-spacing-s {
2
+ margin: $spacing-small;
3
+ }
4
+
5
+ .gm-spacing-m {
6
+ margin: $spacing-medium;
7
+ }
8
+
1
9
  .gm-spacing-l {
2
10
  margin: $spacing-large;
3
11
  }
@@ -6,6 +14,14 @@
6
14
  margin: $spacing-very-large;
7
15
  }
8
16
 
17
+ .gm-spacing-rs {
18
+ margin-right: $spacing-small;
19
+ }
20
+
21
+ .gm-spacing-rm {
22
+ margin-right: $spacing-medium;
23
+ }
24
+
9
25
  .gm-spacing-rl {
10
26
  margin-right: $spacing-large;
11
27
  }
@@ -14,6 +30,14 @@
14
30
  margin-right: $spacing-very-large;
15
31
  }
16
32
 
33
+ .gm-spacing-bs {
34
+ margin-bottom: $spacing-small;
35
+ }
36
+
37
+ .gm-spacing-bm {
38
+ margin-bottom: $spacing-medium;
39
+ }
40
+
17
41
  .gm-spacing-bl {
18
42
  margin-bottom: $spacing-large;
19
43
  }
@@ -22,6 +46,14 @@
22
46
  margin-bottom: $spacing-very-large;
23
47
  }
24
48
 
49
+ .gm-spacing-ls {
50
+ margin-left: $spacing-small;
51
+ }
52
+
53
+ .gm-spacing-lm {
54
+ margin-left: $spacing-medium;
55
+ }
56
+
25
57
  .gm-spacing-ll {
26
58
  margin-left: $spacing-large;
27
59
  }
@@ -30,6 +62,14 @@
30
62
  margin-left: $spacing-very-large;
31
63
  }
32
64
 
65
+ .gm-spacing-ts {
66
+ margin-top: $spacing-small;
67
+ }
68
+
69
+ .gm-spacing-tm {
70
+ margin-top: $spacing-medium;
71
+ }
72
+
33
73
  .gm-spacing-tl {
34
74
  margin-top: $spacing-large;
35
75
  }
@@ -1,7 +1,7 @@
1
1
  // @flow
2
2
  export const SKINS = {
3
3
  primary: "primary",
4
- default: "default"
4
+ default: "default",
5
5
  };
6
6
 
7
7
  export type Skin = $Keys<typeof SKINS>;
@@ -1,6 +1,6 @@
1
1
  describe("Colors", () => {
2
2
  before(() => {
3
- cy.visit("localhost:3000");
3
+ cy.visit("http://localhost:3000");
4
4
  });
5
5
 
6
6
  it("should make a screenshot", () => {
File without changes
File without changes