@teselagen/ui 0.4.9 → 0.4.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teselagen/ui",
3
- "version": "0.4.9",
3
+ "version": "0.4.11",
4
4
  "main": "./src/index.js",
5
5
  "exports": {
6
6
  ".": {
@@ -38,7 +38,6 @@
38
38
  "mock-fs": "5.2.0",
39
39
  "nanoid": "^4.0.0",
40
40
  "papaparse": "^5.3.2",
41
- "prop-types": "^15.6.2",
42
41
  "qs": "^6.9.6",
43
42
  "react-color": "^2.19.3",
44
43
  "react-dropzone": "^11.4.2",
@@ -1,92 +1,68 @@
1
- import React, { Component } from "react";
1
+ import React, { useState } from "react";
2
2
  import { Button, Classes, Icon } from "@blueprintjs/core";
3
3
  import classNames from "classnames";
4
4
  import "./style.css";
5
5
 
6
- export default class CollapsibleCard extends Component {
7
- state = {
8
- open: true
9
- };
10
-
11
- constructor(props) {
12
- super(props);
13
- this.state = {
14
- open: !props.initialClosed
15
- };
16
- }
6
+ export default function CollapsibleCard({
7
+ title,
8
+ icon,
9
+ openTitleElements,
10
+ noCard = false,
11
+ className,
12
+ style,
13
+ children,
14
+ initialClosed = false,
15
+ toggle,
16
+ isOpen
17
+ }) {
18
+ let [open, setOpen] = useState(!initialClosed);
19
+ if (isOpen !== undefined) open = isOpen;
17
20
 
18
- renderOpenCard() {
19
- return this.props.children;
20
- }
21
-
22
- toggleCardInfo = () => {
23
- if (this.props.toggle) this.props.toggle();
21
+ const toggleCardInfo = () => {
22
+ if (toggle) toggle();
24
23
  else {
25
- this.setState({
26
- open: !this.state.open
27
- });
28
- }
29
- };
30
-
31
- getIsOpen = () => {
32
- if (this.props.isOpen !== undefined) {
33
- return this.props.isOpen;
34
- } else {
35
- return this.state.open;
24
+ setOpen(!open);
36
25
  }
37
26
  };
38
27
 
39
- render() {
40
- const open = this.getIsOpen();
41
- const {
42
- title,
43
- icon,
44
- openTitleElements,
45
- noCard = false,
46
- className,
47
- style
48
- } = this.props;
49
-
50
- // blueprintjs card will match our table color. which looks really bad when a table is in a card.
51
- return (
52
- <div
53
- className={classNames({ "tg-card": !noCard, open }, className)}
54
- style={{
55
- paddingTop: 10,
56
- paddingBottom: 10,
57
- paddingLeft: 15,
58
- paddingRight: 15,
59
- ...style
60
- }}
61
- >
62
- <div className="tg-card-header" style={{ marginBottom: 8 }}>
63
- <div className="tg-card-header-title">
64
- {icon && <Icon icon={icon} />}
65
- <h6
66
- style={{
67
- marginBottom: 0,
68
- marginRight: 10,
69
- marginLeft: 10
70
- }}
71
- >
72
- {title}
73
- </h6>
74
- <div>{open && openTitleElements}</div>
75
- </div>
76
- <div>
77
- <Button
78
- icon={open ? "minimize" : "maximize"}
79
- className={classNames(
80
- Classes.MINIMAL,
81
- "info-btn",
82
- "tg-collapse-toggle"
83
- )}
84
- onClick={this.toggleCardInfo}
85
- />
86
- </div>
28
+ return (
29
+ <div
30
+ className={classNames({ "tg-card": !noCard, open }, className)}
31
+ style={{
32
+ paddingTop: 10,
33
+ paddingBottom: 10,
34
+ paddingLeft: 15,
35
+ paddingRight: 15,
36
+ ...style
37
+ }}
38
+ >
39
+ <div className="tg-card-header" style={{ marginBottom: 8 }}>
40
+ <div className="tg-card-header-title">
41
+ {icon && <Icon icon={icon} />}
42
+ <h6
43
+ style={{
44
+ marginBottom: 0,
45
+ marginRight: 10,
46
+ marginLeft: 10
47
+ }}
48
+ >
49
+ {title}
50
+ </h6>
51
+ <div>{open && openTitleElements}</div>
52
+ </div>
53
+ <div>
54
+ <Button
55
+ icon={open ? "minimize" : "maximize"}
56
+ className={classNames(
57
+ Classes.MINIMAL,
58
+ "info-btn",
59
+ "tg-collapse-toggle"
60
+ )}
61
+ onClick={toggleCardInfo}
62
+ />
87
63
  </div>
88
- {open && this.renderOpenCard()}
89
64
  </div>
90
- );
91
- }
65
+ {open && children}
66
+ </div>
67
+ );
92
68
  }
@@ -1,83 +1,78 @@
1
- import React, { Component } from "react";
1
+ import React from "react";
2
2
  import { Popover, Button, Tooltip, Icon } from "@blueprintjs/core";
3
3
  import classnames from "classnames";
4
4
  import "./style.css";
5
5
  import { popoverOverflowModifiers } from "..";
6
6
 
7
- export default class InfoHelper extends Component {
8
- render() {
9
- const {
10
- className,
11
- content,
12
- children,
13
- icon = "info-sign",
14
- isPopover,
15
- isButton,
16
- size,
17
- isInline,
18
- clickable,
19
- color,
20
- noMarginTop,
21
- popoverProps = {},
22
- disabled,
23
- displayToSide,
24
- style,
25
- ...rest
26
- } = this.props;
27
- const IconToUse = isButton ? Button : Icon;
28
- const iconProps = {
29
- icon,
30
- color,
31
- disabled
32
- };
33
- if (!isButton) iconProps.iconSize = size;
7
+ export default ({
8
+ className,
9
+ content,
10
+ children,
11
+ icon = "info-sign",
12
+ isPopover,
13
+ isButton,
14
+ size,
15
+ isInline,
16
+ clickable,
17
+ color,
18
+ noMarginTop,
19
+ popoverProps = {},
20
+ disabled,
21
+ displayToSide,
22
+ style,
23
+ ...rest
24
+ }) => {
25
+ const IconToUse = isButton ? Button : Icon;
26
+ const iconProps = {
27
+ icon,
28
+ color,
29
+ disabled
30
+ };
31
+ if (!isButton) iconProps.iconSize = size;
34
32
 
35
- const IconInner = <IconToUse {...iconProps} {...rest} />;
36
- let toReturn;
37
- const toolTipOrPopoverProps = {
38
- disabled:
39
- disabled ||
40
- (!isPopover &&
41
- window.Cypress &&
42
- !window.Cypress.allowInfoHelperTooltips),
43
- popoverClassName: "tg-info-helper-popover bp3-tooltip",
44
- content: content || children,
45
- modifiers: popoverOverflowModifiers,
46
- ...popoverProps
47
- };
48
- if (displayToSide) {
49
- toReturn = (
50
- <React.Fragment>
51
- {IconInner}
52
- <span style={{ paddingLeft: 5, fontStyle: "italic" }}>
53
- {content || children}
54
- </span>
55
- </React.Fragment>
56
- );
57
- } else if (isPopover) {
58
- toReturn = <Popover {...toolTipOrPopoverProps} target={IconInner} />;
59
- } else {
60
- toReturn = <Tooltip {...toolTipOrPopoverProps} target={IconInner} />;
61
- }
62
- const El = isInline ? "span" : "div";
63
- return (
64
- <El
65
- style={{
66
- ...(clickable ? { cursor: "pointer" } : {}),
67
- ...(isInline ? {} : { display: "flex" }),
68
- ...style
69
- }}
70
- className={classnames(
71
- "info-helper-wrapper",
72
- {
73
- "info-helper-wrapper-noMarginTop": noMarginTop,
74
- "info-helper-clickable": isPopover
75
- },
76
- className
77
- )}
78
- >
79
- {toReturn}
80
- </El>
33
+ const IconInner = <IconToUse {...iconProps} {...rest} />;
34
+ let toReturn;
35
+ const toolTipOrPopoverProps = {
36
+ disabled:
37
+ disabled ||
38
+ (!isPopover && window.Cypress && !window.Cypress.allowInfoHelperTooltips),
39
+ popoverClassName: "tg-info-helper-popover bp3-tooltip",
40
+ content: content || children,
41
+ modifiers: popoverOverflowModifiers,
42
+ ...popoverProps
43
+ };
44
+ if (displayToSide) {
45
+ toReturn = (
46
+ <React.Fragment>
47
+ {IconInner}
48
+ <span style={{ paddingLeft: 5, fontStyle: "italic" }}>
49
+ {content || children}
50
+ </span>
51
+ </React.Fragment>
81
52
  );
53
+ } else if (isPopover) {
54
+ toReturn = <Popover {...toolTipOrPopoverProps} target={IconInner} />;
55
+ } else {
56
+ toReturn = <Tooltip {...toolTipOrPopoverProps} target={IconInner} />;
82
57
  }
83
- }
58
+ const El = isInline ? "span" : "div";
59
+ return (
60
+ <El
61
+ style={{
62
+ ...(clickable ? { cursor: "pointer" } : {}),
63
+ ...(isInline ? {} : { display: "flex" }),
64
+ ...style
65
+ }}
66
+ className={classnames(
67
+ "info-helper-wrapper",
68
+ {
69
+ "info-helper-wrapper-noMarginTop": noMarginTop,
70
+ "info-helper-clickable": isPopover
71
+ },
72
+ className
73
+ )}
74
+ >
75
+ {toReturn}
76
+ </El>
77
+ );
78
+ };
@@ -1,74 +1,70 @@
1
- import React from "react";
1
+ import React, { useState, useEffect } from "react";
2
2
  import DNALoader from "../DNALoader";
3
3
  import "./style.css";
4
4
  import { BounceLoader } from "@teselagen/bounce-loader";
5
5
 
6
- export default class Loading extends React.Component {
7
- state = {
8
- longerThan200MS: false
9
- };
6
+ const Loading = ({
7
+ loading,
8
+ style: userStyle,
9
+ className,
10
+ containerStyle = {},
11
+ children,
12
+ displayInstantly = false,
13
+ bounce = false,
14
+ withTimeout,
15
+ inDialog,
16
+ centeredInPage
17
+ }) => {
18
+ const [longerThan200MS, setLongerThan200MS] = useState(false);
10
19
 
11
- componentDidMount() {
12
- this.timeoutId = setTimeout(() => {
13
- this.setState({
14
- longerThan200MS: true
15
- });
20
+ useEffect(() => {
21
+ const timeoutId = setTimeout(() => {
22
+ setLongerThan200MS(true);
16
23
  }, 200);
17
- }
18
24
 
19
- componentWillUnmount() {
20
- clearTimeout(this.timeoutId);
21
- }
22
-
23
- render() {
24
- const {
25
- loading,
26
- style: userStyle,
27
- className,
28
- containerStyle = {},
29
- children,
30
- displayInstantly = false,
31
- bounce = false,
32
- withTimeout,
33
- inDialog,
34
- centeredInPage
35
- } = this.props;
36
- const { longerThan200MS } = this.state;
37
- const style = {
38
- ...userStyle,
39
- ...(inDialog && { minHeight: 120 })
25
+ return () => {
26
+ clearTimeout(timeoutId);
40
27
  };
41
- const LoaderComp = bounce || inDialog ? BounceLoader : DNALoader;
42
- if (loading || !children) {
43
- if (
44
- !displayInstantly &&
45
- !longerThan200MS &&
46
- ((!bounce && !inDialog) || withTimeout)
47
- ) {
48
- return <div />;
49
- }
50
- return (
51
- <div
52
- className="tg-loader-container tg-flex justify-center align-center"
53
- style={{
54
- width: "100%",
55
- ...containerStyle,
56
- ...(centeredInPage && {
57
- width: undefined,
58
- zIndex: 20,
59
- height: 10,
60
- position: "fixed",
61
- top: "50%",
62
- left: "50%",
63
- transform: "translate(-50%, 0)"
64
- })
65
- }}
66
- >
67
- <LoaderComp style={style} className={className} />
68
- </div>
69
- );
70
- } else {
71
- return children || null;
28
+ }, []);
29
+
30
+ const style = {
31
+ ...userStyle,
32
+ ...(inDialog && { minHeight: 120 })
33
+ };
34
+
35
+ const LoaderComp = bounce || inDialog ? BounceLoader : DNALoader;
36
+
37
+ if (loading || !children) {
38
+ if (
39
+ !displayInstantly &&
40
+ !longerThan200MS &&
41
+ ((!bounce && !inDialog) || withTimeout)
42
+ ) {
43
+ return <div />;
72
44
  }
45
+ return (
46
+ <div
47
+ className="tg-loader-container tg-flex justify-center align-center"
48
+ style={{
49
+ width: "100%",
50
+ ...containerStyle,
51
+ ...(centeredInPage && {
52
+ width: undefined,
53
+ zIndex: 20,
54
+ height: 10,
55
+ position: "fixed",
56
+ top: "50%",
57
+ left: "50%",
58
+ transform: "translate(-50%, 0)"
59
+ })
60
+ }}
61
+ >
62
+ <LoaderComp style={style} className={className} />
63
+ </div>
64
+ );
65
+ } else {
66
+ return children || null;
73
67
  }
74
- }
68
+ };
69
+
70
+ export default Loading;
@@ -1,20 +1,13 @@
1
- import React, { Component } from "react";
2
- import PropTypes from "prop-types";
1
+ import React from "react";
3
2
  import "./style.css";
4
3
 
5
- class Timeline extends Component {
6
- static propTypes = {
7
- children: PropTypes.arrayOf(PropTypes.element)
8
- };
9
-
10
- render() {
11
- return (
12
- <div className="tg-timeline">
13
- {this.props.children.length > 1 && <div className="tg-timeline-line" />}
14
- {this.props.children}
15
- </div>
16
- );
17
- }
4
+ function Timeline(props) {
5
+ return (
6
+ <div className="tg-timeline">
7
+ {props.children.length > 1 && <div className="tg-timeline-line" />}
8
+ {props.children}
9
+ </div>
10
+ );
18
11
  }
19
12
 
20
13
  export { default as TimelineEvent } from "./TimelineEvent";