@thecb/components 5.6.10 → 5.7.0-beta.2

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": "@thecb/components",
3
- "version": "5.6.10",
3
+ "version": "5.7.0-beta.2",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -38,10 +38,6 @@
38
38
  "@storybook/addon-storysource": "^5.3.14",
39
39
  "@storybook/addon-viewport": "^5.3.14",
40
40
  "@storybook/react": "^5.3.14",
41
- "babel-core": "^6.26.3",
42
- "babel-loader": "^8.1.0",
43
- "babel-preset-env": "^1.7.0",
44
- "babel-preset-react": "^6.24.1",
45
41
  "eslint": "^6.8.0",
46
42
  "eslint-config-prettier": "^6.11.0",
47
43
  "eslint-plugin-babel": "^5.3.0",
@@ -85,6 +81,6 @@
85
81
  "ramda": "^0.27.0",
86
82
  "react-aria-modal": "^4.0.0",
87
83
  "react-pose": "^4.0.10",
88
- "redux-freeform": "^5.4.0"
84
+ "redux-freeform": "^5.3.0"
89
85
  }
90
86
  }
package/src/.DS_Store ADDED
Binary file
Binary file
@@ -92,8 +92,7 @@ const Dropdown = ({
92
92
  themeValues,
93
93
  maxHeight,
94
94
  widthFitOptions = false,
95
- disabled,
96
- hasTitles = false
95
+ disabled
97
96
  }) => {
98
97
  const [inputValue, setInputValue] = useState("");
99
98
  const [optionsState, setOptionsState] = useState([]);
@@ -114,9 +113,6 @@ const Dropdown = ({
114
113
  const optionRefs = useRef([...Array(options.length)].map(() => createRef()));
115
114
  const dropdownRef = useRef(null);
116
115
 
117
- const getSelection = () =>
118
- value ? options.find(option => option.value === value)?.text : placeholder;
119
-
120
116
  const onKeyDown = e => {
121
117
  const { key, keyCode } = e;
122
118
  const focus = document.activeElement;
@@ -214,7 +210,6 @@ const Dropdown = ({
214
210
  background-color: #f7f7f7;
215
211
  pointer-events: none;`
216
212
  }
217
- title={hasTitles ? getSelection() : null}
218
213
  >
219
214
  <Box
220
215
  as="button"
@@ -258,7 +253,9 @@ const Dropdown = ({
258
253
  pointer-events: none;`
259
254
  }
260
255
  >
261
- {getSelection()}
256
+ {value
257
+ ? options.find(option => option.value === value)?.text
258
+ : placeholder}
262
259
  </Text>
263
260
  )}
264
261
  <IconWrapper open={isOpen}>
@@ -290,7 +287,6 @@ const Dropdown = ({
290
287
  disabled={disabledValues.includes(choice.value)}
291
288
  data-qa={choice.text}
292
289
  themeValues={themeValues}
293
- title={hasTitles ? choice.text : null}
294
290
  >
295
291
  <Text
296
292
  variant="p"
@@ -15,7 +15,7 @@ const InputField = styled.input`
15
15
  ? ERROR_COLOR
16
16
  : themeValues.borderColor};
17
17
  border-radius: 2px;
18
- height: ${({ $customHeight }) => ($customHeight ? $customHeight : "48px")};
18
+ height: ${({ customHeight }) => (customHeight ? customHeight : "48px")};
19
19
  width: 100%;
20
20
  padding: 1rem;
21
21
  min-width: 100px;
@@ -47,9 +47,9 @@ const InputField = styled.input`
47
47
  background-color: #f7f7f7;
48
48
  `}
49
49
 
50
- ${({ $extraStyles }) =>
50
+ ${({ extraStyles }) =>
51
51
  css`
52
- ${$extraStyles}
52
+ ${extraStyles}
53
53
  `}
54
54
  `;
55
55
 
@@ -63,7 +63,7 @@ const FormattedInputField = styled(({ showErrors, themeValues, ...props }) => (
63
63
  ? ERROR_COLOR
64
64
  : themeValues.borderColor};
65
65
  border-radius: 2px;
66
- height: ${({ $customHeight }) => ($customHeight ? $customHeight : "48px")};
66
+ height: ${({ customHeight }) => (customHeight ? customHeight : "48px")};
67
67
  width: 100%;
68
68
  padding: 1rem;
69
69
  min-width: 100px;
@@ -199,8 +199,8 @@ const FormInput = ({
199
199
  showErrors={showErrors}
200
200
  data-qa={labelTextWhenNoError}
201
201
  themeValues={themeValues}
202
- $customHeight={customHeight}
203
- $extraStyles={extraStyles}
202
+ customHeight={customHeight}
203
+ extraStyles={extraStyles}
204
204
  {...props}
205
205
  />
206
206
  ) : (
@@ -216,8 +216,8 @@ const FormInput = ({
216
216
  data-qa={labelTextWhenNoError}
217
217
  themeValues={themeValues}
218
218
  background={background}
219
- $customHeight={customHeight}
220
- $extraStyles={extraStyles}
219
+ customHeight={customHeight}
220
+ extraStyles={extraStyles}
221
221
  {...props}
222
222
  />
223
223
  )}
@@ -18,8 +18,7 @@ const FormSelect = ({
18
18
  dropdownMaxHeight,
19
19
  disabledValues,
20
20
  disabled,
21
- themeValues,
22
- hasTitles = false
21
+ themeValues
23
22
  }) => {
24
23
  const [open, setOpen] = useState(false);
25
24
  const dropdownRef = useRef(null);
@@ -60,7 +59,6 @@ const FormSelect = ({
60
59
  <Dropdown
61
60
  aria-labelledby={labelTextWhenNoError.replace(/\s+/g, "-")}
62
61
  maxHeight={dropdownMaxHeight}
63
- hasTitles={hasTitles}
64
62
  placeholder={options[0] ? options[0].text : ""}
65
63
  options={options}
66
64
  value={field.rawValue}
@@ -1,13 +1,10 @@
1
1
  import React, { Fragment } from "react";
2
2
  import { BoxWrapper } from "./Box.styled";
3
- import { safeChildren, screenReaderOnlyStyle } from "../../../util/general";
3
+ import { safeChildren } from "../../../util/general";
4
4
 
5
5
  /*
6
6
  Box component to create generic boxes
7
7
  Supply padding, border, background, and color values
8
-
9
- srOnly prop enables special screen-reader style that is used to position content
10
- completely off screen (only for users of screen readers)
11
8
  */
12
9
 
13
10
  const Box = ({
@@ -40,7 +37,6 @@ const Box = ({
40
37
  theme,
41
38
  hiddenStyles,
42
39
  extraStyles,
43
- srOnly = false,
44
40
  dataQa,
45
41
  children,
46
42
  ...rest
@@ -67,9 +63,7 @@ const Box = ({
67
63
  onClick={onClick}
68
64
  hiddenStyles={hiddenStyles}
69
65
  onKeyDown={onKeyDown}
70
- extraStyles={
71
- srOnly ? `${screenReaderOnlyStyle}${extraStyles}` : extraStyles
72
- }
66
+ extraStyles={extraStyles}
73
67
  theme={theme}
74
68
  textAlign={textAlign}
75
69
  data-qa={dataQa}
@@ -29,10 +29,10 @@ const Cluster = ({
29
29
  <ClusterWrapper
30
30
  overflow={overflow}
31
31
  {...rest}
32
- $justifySelf={justifySelf}
33
- $alignSelf={alignSelf}
34
- $flexGrow={flexGrow}
35
- $extraStyles={extraStyles}
32
+ justifySelf={justifySelf}
33
+ alignSelf={alignSelf}
34
+ flexGrow={flexGrow}
35
+ extraStyles={extraStyles}
36
36
  >
37
37
  <ClusterInnerWrapper
38
38
  justify={justify}
@@ -7,10 +7,10 @@ export const ClusterWrapper = styled(({ overflow, ...props }) => (
7
7
  ))`
8
8
  overflow: ${({ overflow }) => (overflow ? "visible" : "hidden")};
9
9
  box-sizing: border-box;
10
- justify-self: ${({ $justifySelf }) => $justifySelf};
11
- align-self: ${({ $alignSelf }) => $alignSelf};
12
- flex-grow: ${({ $flexGrow }) => $flexGrow};
13
- ${({ $extraStyles }) => $extraStyles};
10
+ justify-self: ${({ justifySelf }) => justifySelf};
11
+ align-self: ${({ alignSelf }) => alignSelf};
12
+ flex-grow: ${({ flexGrow }) => flexGrow};
13
+ ${({ extraStyles }) => extraStyles};
14
14
  `;
15
15
 
16
16
  export const ClusterInnerWrapper = styled.div`
@@ -23,7 +23,7 @@ export const navFooter = () => (
23
23
  <NavFooter
24
24
  leftContent={<Left />}
25
25
  rightContent={<Right />}
26
- $headerHeight={text("headerHeight", "105px", "props")}
26
+ headerHeight={text("headerHeight", "105px", "props")}
27
27
  backgroundColor={select("activeColor", colors, "white", "props")}
28
28
  footerPadding={text("footerPadding", "1.5rem 1rem", "props")}
29
29
  isMobile={boolean("isMobile", false, "props")}
@@ -33,4 +33,3 @@ export { default as TermsAndConditionsModal } from "./terms-and-conditions-modal
33
33
  export { default as Timeout } from "./timeout";
34
34
  export { default as WelcomeModule } from "./welcome-module";
35
35
  export { default as WorkflowTile } from "./workflow-tile";
36
- export { default as PeriscopeDashboardIframe } from "./periscope-dashboard-iframe";
@@ -1,4 +1,4 @@
1
- import React, { useState, Fragment } from "react";
1
+ import React, { useState } from "react";
2
2
  import { Stack, Box, Cluster } from "../../atoms/layouts";
3
3
  import { themeComponent } from "../../../util/themeUtils";
4
4
  import { fallbackValues } from "./Tabs.theme";
@@ -46,9 +46,9 @@ const Tabs = ({
46
46
  </Box>
47
47
  <Box className="tab-content">
48
48
  <Box>
49
- {tabsConfig.tabs.map((tab, idx) => {
49
+ {tabsConfig.tabs.map(tab => {
50
50
  if (tab.label !== activeTab) return undefined;
51
- return <Fragment key={idx}>{tab.content}</Fragment>;
51
+ return tab.content;
52
52
  })}
53
53
  </Box>
54
54
  </Box>
Binary file
@@ -79,20 +79,3 @@ export const checkDeniedCards = name => {
79
79
  return "";
80
80
  }
81
81
  };
82
-
83
- /*
84
- An optional style for layout atoms that positions the atom completely off screen
85
- This will *not* be visible or accessible to sighted users
86
- Use to contain text content or a11y interactive content (skip links when not visible)
87
- that is only for users of assistive technologies (screen readers)
88
-
89
- Currently implemented on the Box atom via the srOnly prop
90
- */
91
- export const screenReaderOnlyStyle = `
92
- position: absolute;
93
- left: -10000px;
94
- top: auto;
95
- width: 1px;
96
- height: 1px;
97
- overflow: hidden;
98
- `;
@@ -1,22 +0,0 @@
1
- import React from "react";
2
- import PeriscopeDashboardIframe from "./PeriscopeDashboardIframe";
3
- import page from "../../../../.storybook/page";
4
- import { boolean } from "@storybook/addon-knobs";
5
-
6
- export const periscopeDashboardIframe = () => (
7
- <PeriscopeDashboardIframe
8
- url={"www.example.com"}
9
- requestDashboardUrl={() => {}}
10
- periscopeDataPending={boolean("dataPending", true)}
11
- periscopeDataSuccess={boolean("dataSuccess", false)}
12
- periscopeDataFailure={boolean("dataFailure", false)}
13
- periscopeDataRequestSuccess={boolean("requestSuccess", false)}
14
- periscopeDataRequestFailure={boolean("requestFailure", false)}
15
- />
16
- );
17
-
18
- const story = page({
19
- title: "Components|Molecules/PeriscopeDashboardIframe",
20
- Component: PeriscopeDashboardIframe
21
- });
22
- export default story;
@@ -1,124 +0,0 @@
1
- import React, { useLayoutEffect, useState, useEffect, Fragment } from "react";
2
- import {
3
- BoxWithShadow,
4
- Center,
5
- Box,
6
- PeriscopeFailedIcon,
7
- Heading,
8
- Paragraph,
9
- Cover,
10
- Spinner
11
- } from "../../atoms";
12
- import { DashboardIframe } from "./PeriscopeDashboardIframe.styled";
13
-
14
- /**
15
- * Component: PeriscopeDashboardIframe
16
- *
17
- * Used for rendering Citybase's periscope reporting dashboards in iframes.
18
- * Receives action props to trigger a request on mount for the iframe's url.
19
- * Receives a string prop if/when we receive the url result.
20
- * And receives action props to emit errors from failed iframe loading.
21
- *
22
- * The logic and api client methods to handle requests/response,
23
- * store the url, etc. should be provided from the app consuming this library.
24
- *
25
- * If the url request is pending, render a spinner.
26
- * If the url request failed, render a UI error state.
27
- **/
28
-
29
- const DASHBOARD_SIZE_MESSAGE_TYPE = "dashboard_resize";
30
- const PERISCOPE_ORIGIN = "https://app.periscopedata.com";
31
- const isValidMessage = message =>
32
- message.isTrusted &&
33
- message.origin === PERISCOPE_ORIGIN &&
34
- message.data &&
35
- message.data.event_type === DASHBOARD_SIZE_MESSAGE_TYPE;
36
-
37
- const PeriscopeDashboardIframe = ({
38
- url,
39
- requestDashboardUrl,
40
- periscopeDataPending,
41
- periscopeDataSuccess,
42
- periscopeDataFailure,
43
- periscopeDataRequestSuccess,
44
- periscopeDataRequestFailure
45
- }) => {
46
- const [height, setHeight] = useState(0);
47
- let time = { timer: null };
48
-
49
- useEffect(() => {
50
- time.timer = setTimeout(() => {
51
- periscopeDataRequestFailure();
52
- }, 10000);
53
- }, []);
54
-
55
- const Dashboard = height => url => (
56
- <DashboardIframe
57
- src={url}
58
- width="100%"
59
- height={height}
60
- data-qa="DashboardIframe"
61
- onLoad={() => {
62
- let iframe = document.querySelector("iframe");
63
- iframe.style.display = "initial";
64
- }}
65
- />
66
- );
67
-
68
- const validatePeriscope = message => {
69
- if (isValidMessage(message)) {
70
- setHeight(message.data.dashboard_height + 100);
71
- clearTimeout(time.timer);
72
- periscopeDataRequestSuccess();
73
- }
74
- };
75
-
76
- useLayoutEffect(() => {
77
- window.addEventListener("message", validatePeriscope);
78
- requestDashboardUrl();
79
- return () => window.removeEventListener("message", validatePeriscope);
80
- }, [requestDashboardUrl]);
81
-
82
- return (
83
- <Fragment>
84
- <BoxWithShadow
85
- padding="0"
86
- minWidth="100%"
87
- minHeight="592px"
88
- variant="baseStandard"
89
- background="#fff"
90
- borderRadius="4px"
91
- extraStyles={`display: flex; justify-content: center; align-items: center; flex-direction: column;`}
92
- >
93
- {periscopeDataPending && !periscopeDataSuccess && (
94
- <Cover minHeight="100%" singleChild>
95
- <Center intrinsic>
96
- <Spinner size="100" />
97
- </Center>
98
- </Cover>
99
- )}
100
- {periscopeDataFailure && !periscopeDataSuccess && (
101
- <Box padding="64px">
102
- <Center intrinsic>
103
- <Box padding="0 0 2rem">
104
- <PeriscopeFailedIcon />
105
- </Box>
106
- <Heading variant="h3" weight="700">
107
- Something Went Wrong
108
- </Heading>
109
- <Paragraph variant="p" extraStyles={`text-align: center;`}>
110
- There was an issue trying to load the dashboard.
111
- </Paragraph>
112
- <Paragraph variant="p" extraStyles={`text-align: center;`}>
113
- Your organization may not have a dashboard configured.
114
- </Paragraph>
115
- </Center>
116
- </Box>
117
- )}
118
- {!periscopeDataFailure && url && Dashboard(height)(url)}
119
- </BoxWithShadow>
120
- </Fragment>
121
- );
122
- };
123
-
124
- export default PeriscopeDashboardIframe;
@@ -1,9 +0,0 @@
1
- import React from "react";
2
- import styled from "styled-components";
3
- import { ALTO_GREY } from "../../../constants/colors";
4
-
5
- export const DashboardIframe = styled.iframe`
6
- border: none;
7
- box-shadow: 0 0 5px 0 ${ALTO_GREY};
8
- display: none;
9
- `;
@@ -1,3 +0,0 @@
1
- import PeriscopeDashboardIframe from "./PeriscopeDashboardIframe";
2
-
3
- export default PeriscopeDashboardIframe;