@thecb/components 10.4.4-beta.7 → 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 +146 -996
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.esm.js +147 -994
  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 +27 -96
  13. package/src/components/atoms/placeholder/Placeholder.stories.js +0 -1
  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.7",
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,67 +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 = ({
34
+ const PlaceholderContentWrapper = ({
57
35
  isLink,
36
+ action,
58
37
  destination,
59
- dataQa,
60
- isDisabled,
61
38
  children,
62
- action
39
+ dataQa
63
40
  }) =>
64
41
  isLink ? (
65
- <Link
66
- to={destination}
67
- data-qa={dataQa}
68
- disabled={isDisabled}
69
- style={{ textDecoration: "none" }}
70
- >
71
- <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;`}>
72
44
  {children}
73
45
  </Box>
74
46
  </Link>
@@ -77,32 +49,13 @@ const renderContent = ({
77
49
  onClick={action}
78
50
  padding="0"
79
51
  minHeight="100%"
80
- extraStyles="cursor: pointer;"
52
+ extraStyles={`cursor: pointer;`}
81
53
  dataQa={dataQa}
82
54
  >
83
55
  {children}
84
56
  </Box>
85
57
  );
86
58
 
87
- const PlaceholderContentWrapper = ({
88
- isLink,
89
- action,
90
- destination,
91
- children,
92
- isDisabled = false,
93
- dataQa
94
- }) =>
95
- isDisabled
96
- ? renderDisabledContent({ children })
97
- : renderContent({
98
- children,
99
- action,
100
- isLink,
101
- destination,
102
- dataQa,
103
- isDisabled
104
- });
105
-
106
59
  const Placeholder = ({
107
60
  text,
108
61
  action,
@@ -112,7 +65,6 @@ const Placeholder = ({
112
65
  variant,
113
66
  largeIcon,
114
67
  themeValues,
115
- isDisabled = false,
116
68
  dataQa
117
69
  }) => (
118
70
  <PlaceholderContentWrapper
@@ -120,7 +72,6 @@ const Placeholder = ({
120
72
  action={action}
121
73
  destination={destination}
122
74
  dataQa={dataQa}
123
- isDisabled={isDisabled}
124
75
  >
125
76
  <Box
126
77
  padding="0"
@@ -128,13 +79,7 @@ const Placeholder = ({
128
79
  border="none"
129
80
  minHeight={themeValues.height}
130
81
  hiddenStyles={!visible}
131
- extraStyles={
132
- isDisabled
133
- ? `border: 1px dashed ${MANATEE_GREY};
134
- display: flex;
135
- justify-content: center;
136
- align-items:center;`
137
- : `
82
+ extraStyles={`
138
83
  background: linear-gradient(
139
84
  to right,
140
85
  ${variant === "large" ? STORM_GREY : themeValues.color} 40%,
@@ -154,53 +99,39 @@ const Placeholder = ({
154
99
  background-size: 5px 1px, 1px 5px;
155
100
  display: flex;
156
101
  justify-content: center;
157
- align-items:center;`
158
- }
102
+ align-items:center;`}
159
103
  hoverStyles={`background-color: ${
160
- isDisabled
161
- ? TRANSPARENT
162
- : variant === "large"
163
- ? GRECIAN_GREY
164
- : tint(0.9, themeValues.color)
104
+ variant === "large" ? GRECIAN_GREY : tint(0.9, themeValues.color)
165
105
  };`}
166
106
  >
167
107
  <Center maxWidth="300px">
168
108
  <Box
169
109
  padding="0"
170
110
  tabIndex="0"
171
- onKeyPress={e => (isDisabled ? noop : e.key === "Enter" && action())}
111
+ onKeyPress={e => e.key === "Enter" && action()}
172
112
  >
173
113
  <Cluster justify="center" align="center" minHeight="100%">
174
114
  <Switcher maxChildren={2} childGap="0">
175
115
  {variant === "large" && <div></div>}
176
116
  <Box
177
117
  padding="0"
178
- aria-disabled={isDisabled}
179
118
  extraStyles={`.fill {
180
119
  fill: ${
181
- isDisabled
182
- ? MANATEE_GREY
183
- : variant === "large"
184
- ? CHARADE_GREY
185
- : themeValues.color
120
+ variant === "large" ? CHARADE_GREY : themeValues.color
186
121
  };
187
122
  } .stroke {
188
123
  stroke: ${
189
- isDisabled
190
- ? MANATEE_GREY
191
- : variant === "large"
192
- ? CHARADE_GREY
193
- : themeValues.color
124
+ variant === "large" ? CHARADE_GREY : themeValues.color
194
125
  };
195
- }`}
126
+ } `}
196
127
  >
197
128
  {variant === "large" ? (
198
129
  <Center intrinsic>
199
- {getLargeIcon(largeIcon, isDisabled)}
130
+ {getLargeIcon(largeIcon)}
200
131
  <Text
201
132
  variant="pS"
202
- color={isDisabled ? MANATEE_GREY : themeValues.color}
203
- weight={FONT_WEIGHT_REGULAR}
133
+ color={themeValues.color}
134
+ weight={FONT_WEIGHT_SEMIBOLD}
204
135
  extraStyles={`text-align: center;`}
205
136
  >
206
137
  {text}
@@ -209,12 +140,12 @@ const Placeholder = ({
209
140
  ) : (
210
141
  <Cover singleChild minHeight="100%">
211
142
  <Cluster justify="center" align="center">
212
- <IconAdd fill={isDisabled ? MANATEE_GREY : WHITE} />
143
+ <IconAdd strokeWidth="2" />
213
144
  <Center intrinsic>
214
145
  <Text
215
146
  variant="pS"
216
- color={isDisabled ? MANATEE_GREY : themeValues.color}
217
- weight={FONT_WEIGHT_REGULAR}
147
+ color={themeValues.color}
148
+ weight={FONT_WEIGHT_SEMIBOLD}
218
149
  extraStyles={`padding: 0 0 0 8px; text-align: center;`}
219
150
  >
220
151
  {text}
@@ -36,5 +36,4 @@ const story = page({
36
36
  title: "Components|Atoms/Placeholder",
37
37
  Component: Placeholder
38
38
  });
39
-
40
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);