@thecb/components 9.3.0 → 9.3.1-beta.1

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 (29) hide show
  1. package/dist/index.cjs.js +136 -202
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.d.ts +1 -3
  4. package/dist/index.esm.js +137 -202
  5. package/dist/index.esm.js.map +1 -1
  6. package/dist/src/apps/checkout/pages/payment/sub-pages/payment-amount/PaymentAmount_old.js +49322 -0
  7. package/package.json +1 -1
  8. package/src/.DS_Store +0 -0
  9. package/src/components/.DS_Store +0 -0
  10. package/src/components/atoms/.DS_Store +0 -0
  11. package/src/components/atoms/button-with-action/ButtonWithAction.js +70 -76
  12. package/src/components/atoms/icons/.DS_Store +0 -0
  13. package/src/components/atoms/icons/TrashIcon.js +40 -42
  14. package/src/components/atoms/icons/icons.stories.js +1 -3
  15. package/src/components/atoms/icons/index.d.ts +0 -1
  16. package/src/components/atoms/icons/index.js +1 -3
  17. package/src/components/molecules/radio-section/RadioSection.js +140 -131
  18. package/src/components/molecules/radio-section/RadioSection.stories.js +1 -0
  19. package/src/components/atoms/icons/KebabMenuIcon.d.ts +0 -1
  20. package/src/components/atoms/icons/KebabMenuIcon.js +0 -38
  21. package/src/components/molecules/popup-menu/PopupMenu.js +0 -152
  22. package/src/components/molecules/popup-menu/PopupMenu.stories.js +0 -40
  23. package/src/components/molecules/popup-menu/PopupMenu.styled.js +0 -20
  24. package/src/components/molecules/popup-menu/PopupMenu.theme.js +0 -11
  25. package/src/components/molecules/popup-menu/index.d.ts +0 -25
  26. package/src/components/molecules/popup-menu/index.js +0 -3
  27. package/src/components/molecules/popup-menu/popup-menu-item/PopupMenuItem.js +0 -79
  28. package/src/components/molecules/popup-menu/popup-menu-item/PopupMenuItem.styled.js +0 -27
  29. package/src/components/molecules/popup-menu/popup-menu-item/PopupMenuItem.theme.js +0 -23
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "9.3.0",
3
+ "version": "9.3.1-beta.1",
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
Binary file
Binary file
@@ -1,4 +1,4 @@
1
- import React, { useContext, forwardRef } from "react";
1
+ import React, { useContext } from "react";
2
2
  import styled, { ThemeContext } from "styled-components";
3
3
  import posed from "react-pose";
4
4
  import { linear } from "@popmotion/easing";
@@ -60,36 +60,32 @@ const Spinner = ({ color, isMobile }) => (
60
60
 
61
61
  */
62
62
 
63
- const ButtonWithAction = forwardRef(
64
- (
65
- {
66
- action = noop,
67
- variant = "primary",
68
- text,
69
- textWrap = false,
70
- isLoading = false,
71
- loadingColor = "white",
72
- dataQa = null,
73
- textExtraStyles,
74
- contentOverride = false,
75
- extraStyles = "",
76
- tabIndex,
77
- children,
78
- extraDisabledStyles,
79
- ...rest
80
- },
81
- ref
82
- ) => {
83
- const themeContext = useContext(ThemeContext);
84
- const themeValues = createThemeValues(
85
- themeContext,
86
- fallbackValues,
87
- "Button",
88
- variant
89
- );
90
- const { isMobile } = themeContext;
63
+ const ButtonWithAction = ({
64
+ action = noop,
65
+ variant = "primary",
66
+ text,
67
+ textWrap = false,
68
+ isLoading = false,
69
+ loadingColor = "white",
70
+ dataQa = null,
71
+ textExtraStyles,
72
+ contentOverride = false,
73
+ extraStyles = "",
74
+ tabIndex,
75
+ children,
76
+ extraDisabledStyles,
77
+ ...rest
78
+ }) => {
79
+ const themeContext = useContext(ThemeContext);
80
+ const themeValues = createThemeValues(
81
+ themeContext,
82
+ fallbackValues,
83
+ "Button",
84
+ variant
85
+ );
86
+ const { isMobile } = themeContext;
91
87
 
92
- const hoverStyles = `
88
+ const hoverStyles = `
93
89
  outline: none;
94
90
  background-color: ${themeValues.hoverBackgroundColor};
95
91
  border-color: ${themeValues.hoverBorderColor};
@@ -99,7 +95,7 @@ const ButtonWithAction = forwardRef(
99
95
  };
100
96
  cursor: pointer;
101
97
  `;
102
- const activeStyles = `
98
+ const activeStyles = `
103
99
  outline: none;
104
100
  background-color: ${themeValues.activeBackgroundColor};
105
101
  border-color: ${themeValues.activeBorderColor};
@@ -108,7 +104,7 @@ const ButtonWithAction = forwardRef(
108
104
  variant === "ghost" || variant === "smallGhost" ? "underline" : "none"
109
105
  };
110
106
  `;
111
- const disabledStyles = `
107
+ const disabledStyles = `
112
108
  background-color: #6D717E;
113
109
  border-color: #6D717E;
114
110
  color: #FFFFFF;
@@ -120,49 +116,47 @@ const ButtonWithAction = forwardRef(
120
116
  ${extraDisabledStyles}
121
117
  `;
122
118
 
123
- return (
124
- <Box
125
- ref={ref}
126
- variant={variant}
127
- padding={themeValues.padding}
128
- minHeight={themeValues.height}
129
- minWidth={themeValues.minWidth}
130
- background={themeValues.backgroundColor}
131
- border={themeValues.border}
132
- hoverStyles={hoverStyles}
133
- activeStyles={activeStyles}
134
- disabledStyles={disabledStyles}
135
- as="button"
136
- onClick={isLoading ? undefined : action}
137
- borderRadius="2px"
138
- theme={themeContext}
139
- extraStyles={`margin: 0.5rem; ${extraStyles}`}
140
- dataQa={dataQa}
141
- tabIndex={tabIndex}
142
- {...rest}
143
- >
144
- {contentOverride ? (
145
- children
146
- ) : (
147
- <Center intrinsic>
148
- {isLoading ? (
149
- <Spinner color={loadingColor} isMobile={isMobile} />
150
- ) : (
151
- <Text
152
- weight={themeValues.fontWeight}
153
- variant={themeValues.fontSizeVariant}
154
- color={themeValues.color}
155
- textWrap={textWrap}
156
- extraStyles={textExtraStyles}
157
- >
158
- {text}
159
- </Text>
160
- )}
161
- </Center>
162
- )}
163
- </Box>
164
- );
165
- }
166
- );
119
+ return (
120
+ <Box
121
+ variant={variant}
122
+ padding={themeValues.padding}
123
+ minHeight={themeValues.height}
124
+ minWidth={themeValues.minWidth}
125
+ background={themeValues.backgroundColor}
126
+ border={themeValues.border}
127
+ hoverStyles={hoverStyles}
128
+ activeStyles={activeStyles}
129
+ disabledStyles={disabledStyles}
130
+ as="button"
131
+ onClick={isLoading ? undefined : action}
132
+ borderRadius="2px"
133
+ theme={themeContext}
134
+ extraStyles={`margin: 0.5rem; ${extraStyles}`}
135
+ dataQa={dataQa}
136
+ tabIndex={tabIndex}
137
+ {...rest}
138
+ >
139
+ {contentOverride ? (
140
+ children
141
+ ) : (
142
+ <Center intrinsic>
143
+ {isLoading ? (
144
+ <Spinner color={loadingColor} isMobile={isMobile} />
145
+ ) : (
146
+ <Text
147
+ weight={themeValues.fontWeight}
148
+ variant={themeValues.fontSizeVariant}
149
+ color={themeValues.color}
150
+ textWrap={textWrap}
151
+ extraStyles={textExtraStyles}
152
+ >
153
+ {text}
154
+ </Text>
155
+ )}
156
+ </Center>
157
+ )}
158
+ </Box>
159
+ );
160
+ };
167
161
 
168
162
  export default ButtonWithAction;
@@ -2,48 +2,46 @@ import React from "react";
2
2
  import { fallbackValues } from "./Icons.theme";
3
3
  import { themeComponent } from "../../../util/themeUtils";
4
4
 
5
- const TrashIcon = ({ themeValues, iconFill }) => {
6
- return (
7
- <svg
8
- width="20px"
9
- height="20px"
10
- viewBox="0 0 20 20"
11
- version="1.1"
12
- xmlns="http://www.w3.org/2000/svg"
13
- xmlnsXlink="http://www.w3.org/1999/xlink"
5
+ const TrashIcon = ({ themeValues }) => (
6
+ <svg
7
+ width="20px"
8
+ height="20px"
9
+ viewBox="0 0 20 20"
10
+ version="1.1"
11
+ xmlns="http://www.w3.org/2000/svg"
12
+ xmlnsXlink="http://www.w3.org/1999/xlink"
13
+ >
14
+ <defs>
15
+ <path
16
+ d="M15,7 L14,15.5714286 C14,16.3571429 13.25,17 12.3333333,17 L12.3333333,17 L7.66666667,17 C6.75,17 6,16.3571429 6,15.5714286 L6,15.5714286 L5,7 L15,7 Z M12.1428571,3 L13,4 L16,4 L16,6 L4,6 L4,4 L7,4 L7.85714286,3 L12.1428571,3 Z"
17
+ id="trash-path-1"
18
+ ></path>
19
+ </defs>
20
+ <g
21
+ id="trash-Icons-/-Small-/-20px-S-/-Trash---Mobile---20px"
22
+ stroke="none"
23
+ strokeWidth="1"
24
+ fill="none"
25
+ fillRule="evenodd"
14
26
  >
15
- <defs>
16
- <path
17
- d="M15,7 L14,15.5714286 C14,16.3571429 13.25,17 12.3333333,17 L12.3333333,17 L7.66666667,17 C6.75,17 6,16.3571429 6,15.5714286 L6,15.5714286 L5,7 L15,7 Z M12.1428571,3 L13,4 L16,4 L16,6 L4,6 L4,4 L7,4 L7.85714286,3 L12.1428571,3 Z"
18
- id="trash-path-1"
19
- ></path>
20
- </defs>
21
- <g
22
- id="trash-Icons-/-Small-/-20px-S-/-Trash---Mobile---20px"
23
- stroke="none"
24
- strokeWidth="1"
25
- fill="none"
26
- fillRule="evenodd"
27
- >
28
- <mask id="trash-mask-2" fill="white">
29
- <use xlinkHref="#trash-path-1"></use>
30
- </mask>
31
- <use
32
- id="trash-Mask"
33
- fill={iconFill ?? themeValues.singleIconColor}
34
- fillRule="nonzero"
35
- xlinkHref="#trash-path-1"
36
- ></use>
37
- <polygon
38
- id="trash-Path"
39
- fill={iconFill ?? themeValues.singleIconColor}
40
- fillRule="nonzero"
41
- mask="url(#trash-mask-2)"
42
- points="0 0 20 0 20 20 0 20"
43
- ></polygon>
44
- </g>
45
- </svg>
46
- );
47
- };
27
+ <mask id="trash-mask-2" fill="white">
28
+ <use xlinkHref="#trash-path-1"></use>
29
+ </mask>
30
+ <use
31
+ id="trash-Mask"
32
+ fill={themeValues.singleIconColor}
33
+ fillRule="nonzero"
34
+ xlinkHref="#trash-path-1"
35
+ ></use>
36
+ <polygon
37
+ id="trash-Path"
38
+ fill={themeValues.singleIconColor}
39
+ fillRule="nonzero"
40
+ mask="url(#trash-mask-2)"
41
+ points="0 0 20 0 20 20 0 20"
42
+ ></polygon>
43
+ </g>
44
+ </svg>
45
+ );
48
46
 
49
47
  export default themeComponent(TrashIcon, "Icons", fallbackValues, "primary");
@@ -38,8 +38,7 @@ import {
38
38
  SuccessfulIcon,
39
39
  VoidedIcon,
40
40
  StatusUnknownIcon,
41
- AutopayIcon,
42
- KebabMenuIcon
41
+ AutopayIcon
43
42
  } from "./index";
44
43
 
45
44
  const story = page({
@@ -85,4 +84,3 @@ export const successfulIcon = () => <SuccessfulIcon />;
85
84
  export const voidedIcon = () => <VoidedIcon />;
86
85
  export const statusUnknownIcon = () => <StatusUnknownIcon />;
87
86
  export const autopayIcon = () => <AutopayIcon />;
88
- export const kebabMenuIcon = () => <KebabMenuIcon />;
@@ -21,4 +21,3 @@ export * from "./SuccessfulIconMedium";
21
21
  export * from "./SuccessfulIconSmall";
22
22
  export * from "./XCircleIconMedium";
23
23
  export * from "./XCircleIconSmall";
24
- export * from "./KebabMenuIcon";
@@ -86,7 +86,6 @@ import ArrowLeftCircleIconMedium from "./ArrowLeftCircleIconMedium";
86
86
  import ChargebackIconMedium from "./ChargebackIconMedium";
87
87
  import ChargebackReversalIconMedium from "./ChargebackReversalIconMedium";
88
88
  import PlusCircleIcon from "./PlusCircleIcon";
89
- import KebabMenuIcon from "./KebabMenuIcon";
90
89
 
91
90
  export {
92
91
  AccountsIcon,
@@ -176,6 +175,5 @@ export {
176
175
  ArrowLeftCircleIconMedium,
177
176
  ChargebackIconMedium,
178
177
  ChargebackReversalIconMedium,
179
- PlusCircleIcon,
180
- KebabMenuIcon
178
+ PlusCircleIcon
181
179
  };
@@ -48,7 +48,8 @@ const RadioSection = ({
48
48
  openHeight = "auto",
49
49
  containerStyles = "",
50
50
  ariaDescribedBy,
51
- isSectionRequired = false
51
+ isSectionRequired = false,
52
+ legendText = ""
52
53
  }) => {
53
54
  const handleKeyDown = (id, e) => {
54
55
  if (e?.keyCode === 13 || e?.keyCode === 32) {
@@ -106,143 +107,151 @@ const RadioSection = ({
106
107
  borderRadius="4px"
107
108
  extraStyles={containerStyles}
108
109
  >
109
- <Stack
110
- childGap="0"
111
- aria-role="radiogroup"
112
- aria-required={isSectionRequired}
113
- >
114
- {sections
115
- .filter(section => !section.hidden)
116
- .map(section => (
117
- <Motion
118
- tabIndex={
119
- section.hideRadioButton || section.disabled ? "-1" : "0"
120
- }
121
- onKeyDown={e => !section.disabled && handleKeyDown(section.id, e)}
122
- onFocus={() => !section.disabled && setFocused(section.id)}
123
- onBlur={() => !section.disabled && setFocused(null)}
124
- hoverStyles={themeValues.focusStyles}
125
- animate={openSection === section.id ? "open" : "closed"}
126
- initial={initiallyOpen ? "open" : "closed"}
127
- key={`item-${section.id}`}
128
- extraStyles={borderStyles}
129
- role="radio"
130
- aria-checked={openSection === section.id}
131
- aria-disabled={section.disabled}
132
- aria-required={section?.required}
133
- >
134
- <Stack childGap="0">
135
- <Box
136
- padding={
137
- section.hideRadioButton ? "1.5rem" : "1.25rem 1.5rem"
138
- }
139
- background={
140
- section.disabled
141
- ? themeValues.headingDisabledColor
142
- : themeValues.headingBackgroundColor
143
- }
144
- onClick={
145
- (isMobile && supportsTouch) || section.disabled
146
- ? noop
147
- : () => toggleOpenSection(section.id)
148
- }
149
- onTouchEnd={
150
- isMobile && supportsTouch && !section.disabled
151
- ? () => toggleOpenSection(section.id)
152
- : noop
153
- }
154
- key={`header-${section.id}`}
155
- borderSize="0px"
156
- borderColor={themeValues.borderColor}
157
- borderWidthOverride={
158
- openSection === section.id && !!section.content
159
- ? `0px 0px 1px 0px`
160
- : ``
161
- }
162
- extraStyles={!section.disabled ? "cursor: pointer;" : ""}
163
- dataQa={section.dataQa ? section.dataQa : section.id}
164
- >
165
- <Cluster
166
- justify="space-between"
167
- align="center"
168
- childGap="1px"
169
- nowrap
110
+ <Stack childGap="0">
111
+ <fieldset role="radiogroup" tabIndex="0" required={isSectionRequired}>
112
+ <legend>
113
+ <Box
114
+ width="0"
115
+ srOnly={true}
116
+ border="0"
117
+ padding="0"
118
+ margin="0"
119
+ ></Box>
120
+ </legend>
121
+ {sections
122
+ .filter(section => !section.hidden)
123
+ .map(section => (
124
+ <Motion
125
+ tabIndex={
126
+ section.hideRadioButton || section.disabled ? "-1" : "0"
127
+ }
128
+ onKeyDown={e =>
129
+ !section.disabled && handleKeyDown(section.id, e)
130
+ }
131
+ onFocus={() => !section.disabled && setFocused(section.id)}
132
+ onBlur={() => !section.disabled && setFocused(null)}
133
+ hoverStyles={themeValues.focusStyles}
134
+ animate={openSection === section.id ? "open" : "closed"}
135
+ initial={initiallyOpen ? "open" : "closed"}
136
+ key={`item-${section.id}`}
137
+ extraStyles={borderStyles}
138
+ role="radio"
139
+ aria-checked={openSection === section.id}
140
+ aria-disabled={section.disabled}
141
+ aria-required={section?.required}
142
+ >
143
+ <Stack childGap="0">
144
+ <Box
145
+ padding={
146
+ section.hideRadioButton ? "1.5rem" : "1.25rem 1.5rem"
147
+ }
148
+ background={
149
+ section.disabled
150
+ ? themeValues.headingDisabledColor
151
+ : themeValues.headingBackgroundColor
152
+ }
153
+ onClick={
154
+ (isMobile && supportsTouch) || section.disabled
155
+ ? noop
156
+ : () => toggleOpenSection(section.id)
157
+ }
158
+ onTouchEnd={
159
+ isMobile && supportsTouch && !section.disabled
160
+ ? () => toggleOpenSection(section.id)
161
+ : noop
162
+ }
163
+ key={`header-${section.id}`}
164
+ borderSize="0px"
165
+ borderColor={themeValues.borderColor}
166
+ borderWidthOverride={
167
+ openSection === section.id && !!section.content
168
+ ? `0px 0px 1px 0px`
169
+ : ``
170
+ }
171
+ extraStyles={!section.disabled ? "cursor: pointer;" : ""}
172
+ dataQa={section.dataQa ? section.dataQa : section.id}
170
173
  >
171
- <Cluster justify="flex-start" align="center" nowrap>
172
- {!section.hideRadioButton && (
173
- <Box padding="0">
174
- <RadioButton
175
- id={`radio-input-${idString(section)}`}
176
- name={idString(section)}
177
- ariaDescribedBy={ariaDescribedBy}
178
- radioOn={openSection === section.id}
179
- radioFocused={focused === section.id}
180
- toggleRadio={
181
- section.disabled
182
- ? noop
183
- : () => toggleOpenSection(section.id)
184
- }
185
- tabIndex="-1"
186
- isRequired={section?.required}
187
- />
174
+ <Cluster
175
+ justify="space-between"
176
+ align="center"
177
+ childGap="1px"
178
+ nowrap
179
+ >
180
+ <Cluster justify="flex-start" align="center" nowrap>
181
+ {!section.hideRadioButton && (
182
+ <Box padding="0">
183
+ <RadioButton
184
+ id={`radio-input-${idString(section)}`}
185
+ name={idString(section)}
186
+ ariaDescribedBy={ariaDescribedBy}
187
+ radioOn={openSection === section.id}
188
+ radioFocused={focused === section.id}
189
+ toggleRadio={
190
+ section.disabled
191
+ ? noop
192
+ : () => toggleOpenSection(section.id)
193
+ }
194
+ isRequired={section?.required}
195
+ />
196
+ </Box>
197
+ )}
198
+ {section.titleIcon && (
199
+ <Cluster align="center">{section.titleIcon}</Cluster>
200
+ )}
201
+ <Box padding={section.titleIcon ? "0 0 0 8px" : "0"}>
202
+ <Text
203
+ as="label"
204
+ htmlFor={`radio-input-${idString(section)}`}
205
+ color={CHARADE_GREY}
206
+ >
207
+ {section.title}
208
+ </Text>
188
209
  </Box>
210
+ </Cluster>
211
+ {section.rightIcons && (
212
+ <Cluster
213
+ childGap="0.5rem"
214
+ aria-label={section?.rightIconsLabel || null}
215
+ role={section?.rightIconsRole || null}
216
+ >
217
+ {section.rightIcons.map(icon => (
218
+ <RightIcon
219
+ src={icon.img}
220
+ key={icon.img}
221
+ fade={!icon.enabled}
222
+ isMobile={isMobile}
223
+ alt={icon.altText}
224
+ aria-disabled={!icon.enabled}
225
+ />
226
+ ))}
227
+ </Cluster>
189
228
  )}
190
- {section.titleIcon && (
191
- <Cluster align="center">{section.titleIcon}</Cluster>
229
+ {section.rightTitleContent && (
230
+ <Fragment>{section.rightTitleContent}</Fragment>
192
231
  )}
193
- <Box padding={section.titleIcon ? "0 0 0 8px" : "0"}>
194
- <Text
195
- as="label"
196
- htmlFor={`radio-input-${idString(section)}`}
197
- color={CHARADE_GREY}
198
- >
199
- {section.title}
200
- </Text>
201
- </Box>
202
232
  </Cluster>
203
- {section.rightIcons && (
204
- <Cluster
205
- childGap="0.5rem"
206
- aria-label={section?.rightIconsLabel || null}
207
- role={section?.rightIconsRole || null}
233
+ </Box>
234
+ <AnimatePresence initial={false}>
235
+ {openSection === section.id && (
236
+ <Motion
237
+ key={`content-${section.id}`}
238
+ padding="0"
239
+ background={themeValues.bodyBackgroundColor}
240
+ layoutTransition
241
+ initial="closed"
242
+ animate="open"
243
+ exit="closed"
244
+ variants={wrapper}
245
+ extraStyles={`transform-origin: 100% 0;`}
208
246
  >
209
- {section.rightIcons.map(icon => (
210
- <RightIcon
211
- src={icon.img}
212
- key={icon.img}
213
- fade={!icon.enabled}
214
- isMobile={isMobile}
215
- alt={icon.altText}
216
- aria-disabled={!icon.enabled}
217
- />
218
- ))}
219
- </Cluster>
220
- )}
221
- {section.rightTitleContent && (
222
- <Fragment>{section.rightTitleContent}</Fragment>
247
+ {section.content}
248
+ </Motion>
223
249
  )}
224
- </Cluster>
225
- </Box>
226
- <AnimatePresence initial={false}>
227
- {openSection === section.id && (
228
- <Motion
229
- key={`content-${section.id}`}
230
- padding="0"
231
- background={themeValues.bodyBackgroundColor}
232
- layoutTransition
233
- initial="closed"
234
- animate="open"
235
- exit="closed"
236
- variants={wrapper}
237
- extraStyles={`transform-origin: 100% 0;`}
238
- >
239
- {section.content}
240
- </Motion>
241
- )}
242
- </AnimatePresence>
243
- </Stack>
244
- </Motion>
245
- ))}
250
+ </AnimatePresence>
251
+ </Stack>
252
+ </Motion>
253
+ ))}
254
+ </fieldset>
246
255
  </Stack>
247
256
  </Box>
248
257
  );
@@ -60,6 +60,7 @@ export const radioSection = () => {
60
60
  const [openSection, setOpenSection] = useState("");
61
61
  return (
62
62
  <RadioSection
63
+ legendText="Storybook Story for RadioSection"
63
64
  isMobile={boolean("isMobile", false, "props")}
64
65
  supportsTouch={boolean("isMobile", false, "props")}
65
66
  toggleOpenSection={setOpenSection}
@@ -1 +0,0 @@
1
- export const KebabMenuIcon: JSX.Element;