@thecb/components 10.4.4-beta.6 → 10.4.4

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.
Files changed (26) hide show
  1. package/dist/index.cjs.js +168 -1017
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.esm.js +169 -1015
  4. package/dist/index.esm.js.map +1 -1
  5. package/package.json +1 -1
  6. package/src/.DS_Store +0 -0
  7. package/src/components/atoms/icons/IconAdd.js +9 -3
  8. package/src/components/atoms/icons/IconQuitLarge.js +0 -1
  9. package/src/components/atoms/icons/PropertiesAddIcon.js +0 -1
  10. package/src/components/atoms/icons/icons.stories.js +1 -9
  11. package/src/components/atoms/icons/index.js +1 -7
  12. package/src/components/atoms/placeholder/Placeholder.js +31 -93
  13. package/src/components/atoms/placeholder/Placeholder.stories.js +0 -2
  14. package/src/components/atoms/placeholder/Placeholder.theme.js +2 -8
  15. package/src/components/molecules/editable-list/EditableList.js +2 -16
  16. package/src/components/molecules/editable-list/EditableList.stories.js +3 -1
  17. package/src/components/molecules/toast-notification/ToastNotification.js +16 -12
  18. package/src/components/molecules/toast-notification/ToastNotification.stories.js +38 -0
  19. package/src/hooks/use-toast-notification/index.js +1 -1
  20. package/dist/src/apps/checkout/pages/payment/sub-pages/payment-amount/PaymentAmount_old.js +0 -49322
  21. package/src/components/.DS_Store +0 -0
  22. package/src/components/atoms/.DS_Store +0 -0
  23. package/src/components/atoms/icons/.DS_Store +0 -0
  24. package/src/components/atoms/icons/DisabledAccountsAddIcon.js +0 -200
  25. package/src/components/atoms/icons/DisabledPaymentMethodsAddIcon.js +0 -62
  26. package/src/components/atoms/icons/DisabledPropertiesAddIcon.js +0 -54
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "10.4.4-beta.6",
3
+ "version": "10.4.4",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
package/src/.DS_Store CHANGED
Binary file
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
 
3
- const IconAdd = () => (
3
+ const IconAdd = ({ strokeWidth = 1 }) => (
4
4
  <svg
5
5
  xmlns="http://www.w3.org/2000/svg"
6
6
  xmlnsXlink="http://www.w3.org/1999/xlink"
@@ -15,7 +15,7 @@ const IconAdd = () => (
15
15
  d="M7.91666623 4.78508747L4.78508747 4.78508747 4.78508747 7.91666623 3.74122788 7.91666623 3.74122788 4.78508747 0.609649123 4.78508747 0.609649123 3.74122788 3.74122788 3.74122788 3.74122788 0.609649123 4.78508747 0.609649123 4.78508747 3.74122788 7.91666623 3.74122788z"
16
16
  ></path>
17
17
  </defs>
18
- <g fill="none" fillRule="evenodd" stroke="none" strokeWidth="1">
18
+ <g fill="none" fillRule="evenodd" stroke="none" strokeWidth={strokeWidth}>
19
19
  <g transform="translate(-407 -563)">
20
20
  <g transform="translate(408 562)">
21
21
  <g transform="translate(0 2)">
@@ -25,7 +25,13 @@ const IconAdd = () => (
25
25
  </mask>
26
26
  <use className="fill" xlinkHref="#path-1"></use>
27
27
  </g>
28
- <circle className="stroke" cx="8.155" cy="8.072" r="8"></circle>
28
+ <circle
29
+ className="stroke"
30
+ strokeWidth={strokeWidth}
31
+ cx="8.155"
32
+ cy="8.072"
33
+ r="8"
34
+ ></circle>
29
35
  </g>
30
36
  </g>
31
37
  </g>
@@ -9,7 +9,6 @@ const IconQuitLarge = ({ fill = "#091325" }) => (
9
9
  xmlns="http://www.w3.org/2000/svg"
10
10
  xmlnsXlink="http://www.w3.org/1999/xlink"
11
11
  >
12
- <title>Icon/X</title>
13
12
  <defs>
14
13
  <polygon
15
14
  id="quit-large-path-1"
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
  import { fallbackValues } from "./Icons.theme";
3
3
  import { themeComponent } from "../../../util/themeUtils";
4
-
5
4
  const PropertiesAddIcon = ({ themeValues }) => {
6
5
  return (
7
6
  <svg width={100} height={100} viewBox="0 0 84 100">
@@ -42,10 +42,7 @@ import {
42
42
  KebabMenuIcon,
43
43
  MultiCartIcon,
44
44
  CloseIcon,
45
- TrashIconV2,
46
- DisabledPropertiesAddIcon,
47
- DisabledAccountsAddIcon,
48
- DisabledPaymentMethodsAddIcon
45
+ TrashIconV2
49
46
  } from "./index";
50
47
 
51
48
  const story = page({
@@ -95,8 +92,3 @@ export const kebabMenuIcon = () => <KebabMenuIcon />;
95
92
  export const multiCartIcon = () => <MultiCartIcon />;
96
93
  export const closeIcon = () => <CloseIcon />;
97
94
  export const trashIconV2 = () => <TrashIconV2 />;
98
- export const disabledPropertiesAddIcon = () => <DisabledPropertiesAddIcon />;
99
- export const disabledAccountsAddIcon = () => <DisabledAccountsAddIcon />;
100
- export const disabledPaymentMethodsAddIcon = () => (
101
- <DisabledPaymentMethodsAddIcon />
102
- );
@@ -90,9 +90,6 @@ import KebabMenuIcon from "./KebabMenuIcon";
90
90
  import MultiCartIcon from "./MultiCartIcon";
91
91
  import CloseIcon from "./CloseIcon";
92
92
  import TrashIconV2 from "./TrashIconV2";
93
- import DisabledAccountsAddIcon from "./DisabledAccountsAddIcon";
94
- import DisabledPropertiesAddIcon from "./DisabledPropertiesAddIcon";
95
- import DisabledPaymentMethodsAddIcon from "./DisabledPaymentMethodsAddIcon";
96
93
 
97
94
  export {
98
95
  AccountsIcon,
@@ -186,8 +183,5 @@ export {
186
183
  KebabMenuIcon,
187
184
  MultiCartIcon,
188
185
  CloseIcon,
189
- TrashIconV2,
190
- DisabledAccountsAddIcon,
191
- DisabledPropertiesAddIcon,
192
- DisabledPaymentMethodsAddIcon
186
+ TrashIconV2
193
187
  };
@@ -8,60 +8,39 @@ import { themeComponent } from "../../../util/themeUtils";
8
8
  import {
9
9
  STORM_GREY,
10
10
  GRECIAN_GREY,
11
- CHARADE_GREY,
12
- TRANSPARENT,
13
- WHITE,
14
- MANATEE_GREY
11
+ CHARADE_GREY
15
12
  } from "../../../constants/colors";
16
13
  import {
17
14
  AccountsAddIcon,
18
15
  PropertiesAddIcon,
19
16
  IconAdd,
20
- PaymentMethodAddIcon,
21
- DisabledAccountsAddIcon,
22
- DisabledPropertiesAddIcon,
23
- DisabledPaymentMethodsAddIcon
17
+ PaymentMethodAddIcon
24
18
  } from "../icons";
25
- import { FONT_WEIGHT_REGULAR } from "../../../constants/style_constants";
26
- import { noop } from "../../../util/general";
19
+ import { FONT_WEIGHT_SEMIBOLD } from "../../../constants/style_constants";
27
20
 
28
- const getLargeIcon = (iconName, isDisabled) => {
21
+ const getLargeIcon = iconName => {
29
22
  switch (iconName) {
30
23
  case "accounts":
31
- return isDisabled ? <DisabledAccountsAddIcon /> : <AccountsAddIcon />;
24
+ return <AccountsAddIcon />;
32
25
  case "properties":
33
- return isDisabled ? <DisabledPropertiesAddIcon /> : <PropertiesAddIcon />;
26
+ return <PropertiesAddIcon />;
34
27
  case "payments":
35
- return isDisabled ? (
36
- <DisabledPaymentMethodsAddIcon />
37
- ) : (
38
- <PaymentMethodAddIcon />
39
- );
28
+ return <PaymentMethodAddIcon />;
40
29
  default:
41
- return isDisabled ? <DisabledAccountsAddIcon /> : <AccountsAddIcon />;
30
+ return <AccountsAddIcon />;
42
31
  }
43
32
  };
44
33
 
45
- const renderDisabledContent = ({ children }) => (
46
- <Box
47
- padding="0"
48
- minHeight="100%"
49
- extraStyles="cursor: default;"
50
- aria-disabled={true}
51
- >
52
- {children}
53
- </Box>
54
- );
55
-
56
- const renderContent = ({ isLink, destination, dataQa, isDisabled, children }) =>
34
+ const PlaceholderContentWrapper = ({
35
+ isLink,
36
+ action,
37
+ destination,
38
+ children,
39
+ dataQa
40
+ }) =>
57
41
  isLink ? (
58
- <Link
59
- to={destination}
60
- data-qa={dataQa}
61
- disabled={isDisabled}
62
- style={{ textDecoration: "none" }}
63
- >
64
- <Box padding="0" minHeight="100%" extraStyles="cursor: pointer;">
42
+ <Link to={destination} data-qa={dataQa} style={{ textDecoration: "none" }}>
43
+ <Box padding="0" minHeight="100%" extraStyles={`cursor: pointer;`}>
65
44
  {children}
66
45
  </Box>
67
46
  </Link>
@@ -70,32 +49,13 @@ const renderContent = ({ isLink, destination, dataQa, isDisabled, children }) =>
70
49
  onClick={action}
71
50
  padding="0"
72
51
  minHeight="100%"
73
- extraStyles="cursor: pointer;"
52
+ extraStyles={`cursor: pointer;`}
74
53
  dataQa={dataQa}
75
54
  >
76
55
  {children}
77
56
  </Box>
78
57
  );
79
58
 
80
- const PlaceholderContentWrapper = ({
81
- isLink,
82
- action,
83
- destination,
84
- children,
85
- isDisabled = false,
86
- dataQa
87
- }) =>
88
- isDisabled
89
- ? renderDisabledContent({ children })
90
- : renderContent({
91
- children,
92
- action,
93
- isLink,
94
- destination,
95
- dataQa,
96
- isDisabled
97
- });
98
-
99
59
  const Placeholder = ({
100
60
  text,
101
61
  action,
@@ -105,7 +65,6 @@ const Placeholder = ({
105
65
  variant,
106
66
  largeIcon,
107
67
  themeValues,
108
- isDisabled = false,
109
68
  dataQa
110
69
  }) => (
111
70
  <PlaceholderContentWrapper
@@ -113,7 +72,6 @@ const Placeholder = ({
113
72
  action={action}
114
73
  destination={destination}
115
74
  dataQa={dataQa}
116
- isDisabled={isDisabled}
117
75
  >
118
76
  <Box
119
77
  padding="0"
@@ -121,13 +79,7 @@ const Placeholder = ({
121
79
  border="none"
122
80
  minHeight={themeValues.height}
123
81
  hiddenStyles={!visible}
124
- extraStyles={
125
- isDisabled
126
- ? `border: 1px dashed ${MANATEE_GREY};
127
- display: flex;
128
- justify-content: center;
129
- align-items:center;`
130
- : `
82
+ extraStyles={`
131
83
  background: linear-gradient(
132
84
  to right,
133
85
  ${variant === "large" ? STORM_GREY : themeValues.color} 40%,
@@ -147,53 +99,39 @@ const Placeholder = ({
147
99
  background-size: 5px 1px, 1px 5px;
148
100
  display: flex;
149
101
  justify-content: center;
150
- align-items:center;`
151
- }
102
+ align-items:center;`}
152
103
  hoverStyles={`background-color: ${
153
- isDisabled
154
- ? TRANSPARENT
155
- : variant === "large"
156
- ? GRECIAN_GREY
157
- : tint(0.9, themeValues.color)
104
+ variant === "large" ? GRECIAN_GREY : tint(0.9, themeValues.color)
158
105
  };`}
159
106
  >
160
107
  <Center maxWidth="300px">
161
108
  <Box
162
109
  padding="0"
163
110
  tabIndex="0"
164
- onKeyPress={e => (isDisabled ? noop : e.key === "Enter" && action())}
111
+ onKeyPress={e => e.key === "Enter" && action()}
165
112
  >
166
113
  <Cluster justify="center" align="center" minHeight="100%">
167
114
  <Switcher maxChildren={2} childGap="0">
168
115
  {variant === "large" && <div></div>}
169
116
  <Box
170
117
  padding="0"
171
- aria-disabled={isDisabled}
172
118
  extraStyles={`.fill {
173
119
  fill: ${
174
- isDisabled
175
- ? MANATEE_GREY
176
- : variant === "large"
177
- ? CHARADE_GREY
178
- : themeValues.color
120
+ variant === "large" ? CHARADE_GREY : themeValues.color
179
121
  };
180
122
  } .stroke {
181
123
  stroke: ${
182
- isDisabled
183
- ? MANATEE_GREY
184
- : variant === "large"
185
- ? CHARADE_GREY
186
- : themeValues.color
124
+ variant === "large" ? CHARADE_GREY : themeValues.color
187
125
  };
188
- }`}
126
+ } `}
189
127
  >
190
128
  {variant === "large" ? (
191
129
  <Center intrinsic>
192
- {getLargeIcon(largeIcon, isDisabled)}
130
+ {getLargeIcon(largeIcon)}
193
131
  <Text
194
132
  variant="pS"
195
- color={isDisabled ? MANATEE_GREY : themeValues.color}
196
- weight={FONT_WEIGHT_REGULAR}
133
+ color={themeValues.color}
134
+ weight={FONT_WEIGHT_SEMIBOLD}
197
135
  extraStyles={`text-align: center;`}
198
136
  >
199
137
  {text}
@@ -202,12 +140,12 @@ const Placeholder = ({
202
140
  ) : (
203
141
  <Cover singleChild minHeight="100%">
204
142
  <Cluster justify="center" align="center">
205
- <IconAdd fill={isDisabled ? MANATEE_GREY : WHITE} />
143
+ <IconAdd strokeWidth="2" />
206
144
  <Center intrinsic>
207
145
  <Text
208
146
  variant="pS"
209
- color={isDisabled ? MANATEE_GREY : themeValues.color}
210
- weight={FONT_WEIGHT_REGULAR}
147
+ color={themeValues.color}
148
+ weight={FONT_WEIGHT_SEMIBOLD}
211
149
  extraStyles={`padding: 0 0 0 8px; text-align: center;`}
212
150
  >
213
151
  {text}
@@ -28,7 +28,6 @@ export const placeholder = () => (
28
28
  destination={text("destination", "add-account", "props")}
29
29
  text={text("text", "Add an Account", "props")}
30
30
  largeIcon={select(iconLabel, icons, defaultIcon, groupId)}
31
- isDisabled={boolean("isDisabled", false, groupId)}
32
31
  key="placeholder"
33
32
  />
34
33
  );
@@ -37,5 +36,4 @@ const story = page({
37
36
  title: "Components|Atoms/Placeholder",
38
37
  Component: Placeholder
39
38
  });
40
-
41
39
  export default story;
@@ -1,13 +1,7 @@
1
1
  import { BRIGHT_GREY, CHARADE_GREY } from "../../../constants/colors";
2
2
 
3
- const color = {
4
- default: `${CHARADE_GREY}`,
5
- large: `${BRIGHT_GREY}`
6
- };
7
- const height = {
8
- default: "3rem",
9
- large: "192px"
10
- };
3
+ const color = { default: `${CHARADE_GREY}`, large: `${BRIGHT_GREY}` };
4
+ const height = { default: "3rem", large: "192px" };
11
5
 
12
6
  export const fallbackValues = {
13
7
  color,
@@ -40,8 +40,7 @@ const EditableList = ({
40
40
  listPadding = "0rem 0rem 1.5rem 0rem",
41
41
  qaPrefix,
42
42
  ariaLabel,
43
- editItemAriaRole = "",
44
- disablePlaceholder = false
43
+ editItemAriaRole = ""
45
44
  }) => {
46
45
  const addText = `Add a${
47
46
  itemName[0].match(/[aieouAIEOU]/) ? "n" : ""
@@ -162,26 +161,13 @@ const EditableList = ({
162
161
  );
163
162
  })}
164
163
  </Box>
165
- {canAdd &&
166
- (!maxItems || items.length < maxItems) &&
167
- !disablePlaceholder ? (
164
+ {canAdd && (!maxItems || items.length < maxItems) && (
168
165
  <Box padding={items.length === 0 ? "0" : "1rem 0 0"}>
169
166
  <Placeholder
170
167
  text={addText}
171
168
  action={addItem}
172
169
  dataQa={"Add " + qaPrefix}
173
170
  aria-label={addText}
174
- isDisabled={disablePlaceholder}
175
- />
176
- </Box>
177
- ) : (
178
- <Box padding={items.length === 0 ? "0" : "1rem 0 0"}>
179
- <Placeholder
180
- text={addText}
181
- action={addItem}
182
- dataQa={"Add " + qaPrefix}
183
- aria-label={addText}
184
- isDisabled={disablePlaceholder}
185
171
  />
186
172
  </Box>
187
173
  )}
@@ -1,4 +1,6 @@
1
- import React from "react";
1
+ import React, { useState } from "react";
2
+ import { boolean } from "@storybook/addon-knobs";
3
+
2
4
  import EditableList from "./EditableList";
3
5
  import page from "../../../../.storybook/page";
4
6
 
@@ -29,7 +29,8 @@ const ToastNotification = ({
29
29
  maxWidth = "350px",
30
30
  height = "56px",
31
31
  childGap = "1rem",
32
- backgroundColor
32
+ backgroundColor,
33
+ role = "alert"
33
34
  }) => (
34
35
  <Box
35
36
  onClick={closeToastNotification}
@@ -55,18 +56,21 @@ const ToastNotification = ({
55
56
  ${extraStyles};
56
57
  cursor: pointer;
57
58
  `}
59
+ role={role}
58
60
  >
59
- <Cluster align="center" childGap={childGap}>
60
- {variant === VARIANTS.SUCCESS && <SuccessfulIconMedium />}
61
- {variant === VARIANTS.ERROR && <ErroredIcon />}
62
- <Box padding="1rem 0" maxWidth={maxWidth}>
63
- <Paragraph
64
- weight={FONT_WEIGHT_SEMIBOLD}
65
- extraStyles={"word-break: break-word;"}
66
- >
67
- {message}
68
- </Paragraph>
69
- </Box>
61
+ <Cluster align="center" childGap={childGap} justify="space-between">
62
+ <Cluster align="center" childGap={childGap}>
63
+ {variant === VARIANTS.SUCCESS && <SuccessfulIconMedium />}
64
+ {variant === VARIANTS.ERROR && <ErroredIcon />}
65
+ <Box padding="1rem 0" maxWidth={maxWidth}>
66
+ <Paragraph
67
+ weight={FONT_WEIGHT_SEMIBOLD}
68
+ extraStyles={"word-break: break-word;"}
69
+ >
70
+ {message}
71
+ </Paragraph>
72
+ </Box>
73
+ </Cluster>
70
74
  <IconQuitLarge />
71
75
  </Cluster>
72
76
  </Box>
@@ -3,6 +3,9 @@ import ToastNotification from "./ToastNotification";
3
3
  import page from "../../../../.storybook/page";
4
4
  import { useToastNotification } from "../../../hooks";
5
5
  import { ToastVariants } from "../../../types/common";
6
+ import { text } from "@storybook/addon-knobs";
7
+
8
+ const groupId = "props";
6
9
 
7
10
  export const toastNotificationSuccess = () => {
8
11
  const {
@@ -26,6 +29,9 @@ export const toastNotificationSuccess = () => {
26
29
  message={toastMessage}
27
30
  toastOpen={isToastOpen}
28
31
  closeToastNotification={() => hideToast()}
32
+ role={text("role", "alert", groupId)}
33
+ minWidth={text("minWidth", null, groupId)}
34
+ maxWidth={text("maxWidth", null, groupId)}
29
35
  />
30
36
  );
31
37
  };
@@ -54,11 +60,43 @@ export const toastNotificationError = () => {
54
60
  message={toastMessage}
55
61
  toastOpen={isToastOpen}
56
62
  closeToastNotification={() => hideToast()}
63
+ role={text("role", "alert", groupId)}
64
+ minWidth={text("minWidth", null, groupId)}
65
+ maxWidth={text("maxWidth", null, groupId)}
57
66
  />
58
67
  );
59
68
  };
60
69
  toastNotificationError.storyName = "Error Toast";
61
70
 
71
+ export const toastNotificationNoAutoHide = () => {
72
+ const {
73
+ isToastOpen,
74
+ toastMessage,
75
+ showToast,
76
+ hideToast
77
+ } = useToastNotification({ timeout: 0 });
78
+
79
+ useEffect(() => {
80
+ showToast({
81
+ message: "Success!",
82
+ variant: ToastVariants.SUCCESS
83
+ });
84
+ }, []);
85
+
86
+ return (
87
+ <ToastNotification
88
+ message={toastMessage}
89
+ toastOpen={isToastOpen}
90
+ closeToastNotification={() => hideToast()}
91
+ role={text("role", "alert", groupId)}
92
+ minWidth={text("minWidth", null, groupId)}
93
+ maxWidth={text("maxWidth", null, groupId)}
94
+ />
95
+ );
96
+ };
97
+
98
+ toastNotificationNoAutoHide.storyName = "No auto-hide";
99
+
62
100
  const story = page({
63
101
  title: "Components|Molecules/ToastNotification",
64
102
  Component: ToastNotification
@@ -10,7 +10,7 @@ const useToastNotification = ({ timeout = 5000 } = {}) => {
10
10
  const [toastState, setToastState] = useState(initialToastState);
11
11
 
12
12
  useEffect(() => {
13
- if (toastState.isOpen) {
13
+ if (toastState.isOpen && timeout > 0) {
14
14
  setTimeout(() => {
15
15
  setToastState(initialToastState);
16
16
  }, timeout);