@thecb/components 5.7.0-beta.3 → 5.7.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/dist/index.cjs.js +8263 -6982
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +8263 -6983
- package/dist/index.esm.js.map +1 -1
- package/package.json +6 -2
- package/src/components/atoms/dropdown/Dropdown.js +8 -4
- package/src/components/atoms/form-layouts/FormInput.js +8 -8
- package/src/components/atoms/form-select/FormSelect.js +3 -1
- package/src/components/atoms/layouts/Box.js +8 -2
- package/src/components/atoms/layouts/Cluster.js +4 -4
- package/src/components/atoms/layouts/Cluster.styled.js +4 -4
- package/src/components/atoms/nav-footer/NavFooter.stories.js +1 -1
- package/src/components/molecules/index.js +1 -0
- package/src/components/molecules/periscope-dashboard-iframe/PeriscopeDashBoardIframe.stories.js +22 -0
- package/src/components/molecules/periscope-dashboard-iframe/PeriscopeDashboardIframe.js +124 -0
- package/src/components/molecules/periscope-dashboard-iframe/PeriscopeDashboardIframe.styled.js +9 -0
- package/src/components/molecules/periscope-dashboard-iframe/index.js +3 -0
- package/src/components/molecules/tabs/Tabs.js +3 -3
- package/src/util/general.js +17 -0
- package/src/.DS_Store +0 -0
- package/src/components/.DS_Store +0 -0
- package/src/components/molecules/.DS_Store +0 -0
- package/src/deprecated/.DS_Store +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thecb/components",
|
|
3
|
-
"version": "5.7.0
|
|
3
|
+
"version": "5.7.0",
|
|
4
4
|
"description": "Common lib for CityBase react components",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -38,6 +38,10 @@
|
|
|
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",
|
|
41
45
|
"eslint": "^6.8.0",
|
|
42
46
|
"eslint-config-prettier": "^6.11.0",
|
|
43
47
|
"eslint-plugin-babel": "^5.3.0",
|
|
@@ -81,6 +85,6 @@
|
|
|
81
85
|
"ramda": "^0.27.0",
|
|
82
86
|
"react-aria-modal": "^4.0.0",
|
|
83
87
|
"react-pose": "^4.0.10",
|
|
84
|
-
"redux-freeform": "^5.
|
|
88
|
+
"redux-freeform": "^5.5.0"
|
|
85
89
|
}
|
|
86
90
|
}
|
|
@@ -92,7 +92,8 @@ const Dropdown = ({
|
|
|
92
92
|
themeValues,
|
|
93
93
|
maxHeight,
|
|
94
94
|
widthFitOptions = false,
|
|
95
|
-
disabled
|
|
95
|
+
disabled,
|
|
96
|
+
hasTitles = false
|
|
96
97
|
}) => {
|
|
97
98
|
const [inputValue, setInputValue] = useState("");
|
|
98
99
|
const [optionsState, setOptionsState] = useState([]);
|
|
@@ -113,6 +114,9 @@ const Dropdown = ({
|
|
|
113
114
|
const optionRefs = useRef([...Array(options.length)].map(() => createRef()));
|
|
114
115
|
const dropdownRef = useRef(null);
|
|
115
116
|
|
|
117
|
+
const getSelection = () =>
|
|
118
|
+
value ? options.find(option => option.value === value)?.text : placeholder;
|
|
119
|
+
|
|
116
120
|
const onKeyDown = e => {
|
|
117
121
|
const { key, keyCode } = e;
|
|
118
122
|
const focus = document.activeElement;
|
|
@@ -210,6 +214,7 @@ const Dropdown = ({
|
|
|
210
214
|
background-color: #f7f7f7;
|
|
211
215
|
pointer-events: none;`
|
|
212
216
|
}
|
|
217
|
+
title={hasTitles ? getSelection() : null}
|
|
213
218
|
>
|
|
214
219
|
<Box
|
|
215
220
|
as="button"
|
|
@@ -253,9 +258,7 @@ const Dropdown = ({
|
|
|
253
258
|
pointer-events: none;`
|
|
254
259
|
}
|
|
255
260
|
>
|
|
256
|
-
{
|
|
257
|
-
? options.find(option => option.value === value)?.text
|
|
258
|
-
: placeholder}
|
|
261
|
+
{getSelection()}
|
|
259
262
|
</Text>
|
|
260
263
|
)}
|
|
261
264
|
<IconWrapper open={isOpen}>
|
|
@@ -287,6 +290,7 @@ const Dropdown = ({
|
|
|
287
290
|
disabled={disabledValues.includes(choice.value)}
|
|
288
291
|
data-qa={choice.text}
|
|
289
292
|
themeValues={themeValues}
|
|
293
|
+
title={hasTitles ? choice.text : null}
|
|
290
294
|
>
|
|
291
295
|
<Text
|
|
292
296
|
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,7 +18,8 @@ const FormSelect = ({
|
|
|
18
18
|
dropdownMaxHeight,
|
|
19
19
|
disabledValues,
|
|
20
20
|
disabled,
|
|
21
|
-
themeValues
|
|
21
|
+
themeValues,
|
|
22
|
+
hasTitles = false
|
|
22
23
|
}) => {
|
|
23
24
|
const [open, setOpen] = useState(false);
|
|
24
25
|
const dropdownRef = useRef(null);
|
|
@@ -59,6 +60,7 @@ const FormSelect = ({
|
|
|
59
60
|
<Dropdown
|
|
60
61
|
aria-labelledby={labelTextWhenNoError.replace(/\s+/g, "-")}
|
|
61
62
|
maxHeight={dropdownMaxHeight}
|
|
63
|
+
hasTitles={hasTitles}
|
|
62
64
|
placeholder={options[0] ? options[0].text : ""}
|
|
63
65
|
options={options}
|
|
64
66
|
value={field.rawValue}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React, { Fragment } from "react";
|
|
2
2
|
import { BoxWrapper } from "./Box.styled";
|
|
3
|
-
import { safeChildren } from "../../../util/general";
|
|
3
|
+
import { safeChildren, screenReaderOnlyStyle } 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)
|
|
8
11
|
*/
|
|
9
12
|
|
|
10
13
|
const Box = ({
|
|
@@ -37,6 +40,7 @@ const Box = ({
|
|
|
37
40
|
theme,
|
|
38
41
|
hiddenStyles,
|
|
39
42
|
extraStyles,
|
|
43
|
+
srOnly = false,
|
|
40
44
|
dataQa,
|
|
41
45
|
children,
|
|
42
46
|
...rest
|
|
@@ -63,7 +67,9 @@ const Box = ({
|
|
|
63
67
|
onClick={onClick}
|
|
64
68
|
hiddenStyles={hiddenStyles}
|
|
65
69
|
onKeyDown={onKeyDown}
|
|
66
|
-
extraStyles={
|
|
70
|
+
extraStyles={
|
|
71
|
+
srOnly ? `${screenReaderOnlyStyle}${extraStyles}` : extraStyles
|
|
72
|
+
}
|
|
67
73
|
theme={theme}
|
|
68
74
|
textAlign={textAlign}
|
|
69
75
|
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,3 +33,4 @@ 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";
|
package/src/components/molecules/periscope-dashboard-iframe/PeriscopeDashBoardIframe.stories.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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;
|
|
@@ -0,0 +1,124 @@
|
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
1
|
+
import React, { useState, Fragment } 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 => {
|
|
49
|
+
{tabsConfig.tabs.map((tab, idx) => {
|
|
50
50
|
if (tab.label !== activeTab) return undefined;
|
|
51
|
-
return tab.content
|
|
51
|
+
return <Fragment key={idx}>{tab.content}</Fragment>;
|
|
52
52
|
})}
|
|
53
53
|
</Box>
|
|
54
54
|
</Box>
|
package/src/util/general.js
CHANGED
|
@@ -79,3 +79,20 @@ 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
|
+
`;
|
package/src/.DS_Store
DELETED
|
Binary file
|
package/src/components/.DS_Store
DELETED
|
Binary file
|
|
Binary file
|
package/src/deprecated/.DS_Store
DELETED
|
Binary file
|