@thecb/components 9.0.0-beta.7 → 9.0.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.
Files changed (25) hide show
  1. package/dist/index.cjs.js +314 -1371
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.d.ts +2 -2
  4. package/dist/index.esm.js +314 -1372
  5. package/dist/index.esm.js.map +1 -1
  6. package/package.json +2 -2
  7. package/src/components/atoms/checkbox/Checkbox.js +1 -0
  8. package/src/components/atoms/country-dropdown/CountryDropdown.js +1 -1
  9. package/src/components/atoms/country-dropdown/CountryDropdown.stories.js +0 -1
  10. package/src/components/atoms/dropdown/Dropdown.js +9 -9
  11. package/src/components/atoms/form-layouts/FormInput.js +2 -3
  12. package/src/components/atoms/form-layouts/index.d.ts +1 -1
  13. package/src/components/atoms/form-select/FormSelect.js +1 -1
  14. package/src/components/atoms/form-select/index.d.ts +1 -1
  15. package/src/components/molecules/account-and-routing-modal/AccountAndRoutingModal.js +0 -1
  16. package/src/components/molecules/link-card/index.d.ts +1 -1
  17. package/src/components/molecules/modal/Modal.js +1 -1
  18. package/src/components/molecules/partial-amount-form/PartialAmountForm.state.js +40 -22
  19. package/src/components/molecules/partial-amount-form/index.js +9 -2
  20. package/src/components/molecules/payment-details/PaymentDetails.js +36 -16
  21. package/src/components/molecules/phone-form/PhoneForm.js +1 -0
  22. package/src/components/molecules/terms-and-conditions/TermsAndConditionsControlV1.js +1 -2
  23. package/src/components/molecules/terms-and-conditions/TermsAndConditionsControlV2.js +0 -1
  24. package/src/components/atoms/dropdown/index.d.ts +0 -32
  25. package/src/components/atoms/state-province-dropdown/index.d.ts +0 -26
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "9.0.0-beta.7",
3
+ "version": "9.0.0",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -90,6 +90,6 @@
90
90
  "ramda": "^0.27.0",
91
91
  "react-aria-modal": "^4.0.0",
92
92
  "react-pose": "^4.0.10",
93
- "redux-freeform": "^5.6.0"
93
+ "redux-freeform": "^5.8.0"
94
94
  }
95
95
  }
@@ -134,6 +134,7 @@ const Checkbox = ({
134
134
  error={error}
135
135
  disabled={disabled}
136
136
  checked={checked}
137
+ aria-checked={checked}
137
138
  focused={focused}
138
139
  defaultStyles={themeValues.defaultStyles}
139
140
  checkedStyles={themeValues.checkedStyles}
@@ -4,7 +4,7 @@ import FormSelect from "../form-select";
4
4
  import { options } from "./options";
5
5
 
6
6
  const CountryDropdown = ({
7
- labelTextWhenNoError,
7
+ labelTextWhenNoError = "Country",
8
8
  errorMessages,
9
9
  field,
10
10
  fieldActions,
@@ -26,7 +26,6 @@ const story = page({
26
26
  const CountryFormWrapper = ({ fields, actions }) => (
27
27
  <Box minHeight="300px">
28
28
  <CountryDropdown
29
- labelTextWhenNoError="Country"
30
29
  errorMessages={errorMessages}
31
30
  options={options}
32
31
  field={fields.country}
@@ -3,7 +3,6 @@ import { Box, Stack } from "../layouts";
3
3
  import Text from "../text";
4
4
  import {
5
5
  noop,
6
- createIdFromString,
7
6
  inputDisabledStyle,
8
7
  inputPlaceholderTextStyle
9
8
  } from "../../../util/general";
@@ -383,6 +382,7 @@ const Dropdown = ({
383
382
  data-qa={choice.text}
384
383
  themeValues={themeValues}
385
384
  title={hasTitles ? choice.text : null}
385
+ role="option"
386
386
  onFocus={() => setFocusedRef(optionRefs.current[i])}
387
387
  >
388
388
  <Text
@@ -395,14 +395,14 @@ const Dropdown = ({
395
395
  : MINESHAFT_GREY
396
396
  }
397
397
  extraStyles={`padding-left: 16px;
398
- cursor: ${
399
- disabledValues.includes(choice.value)
400
- ? "default"
401
- : "pointer"
402
- };
403
- white-space: nowrap;
404
- overflow: hidden;
405
- text-overflow: ellipsis;`}
398
+ cursor: ${
399
+ disabledValues.includes(choice.value)
400
+ ? "default"
401
+ : "pointer"
402
+ };
403
+ white-space: nowrap;
404
+ overflow: hidden;
405
+ text-overflow: ellipsis;`}
406
406
  >
407
407
  {choice.text}
408
408
  </Text>
@@ -112,10 +112,10 @@ const FormInput = ({
112
112
  themeValues,
113
113
  background,
114
114
  customHeight,
115
- autocompleteValue = "",
115
+ autocompleteValue = null,
116
116
  extraStyles,
117
117
  removeFromValue, // regex of characters to remove before setting value
118
- dataQa,
118
+ dataQa = null,
119
119
  ...props
120
120
  }) => {
121
121
  const [showPassword, setShowPassword] = useState(false);
@@ -256,7 +256,6 @@ const FormInput = ({
256
256
  justify="space-between"
257
257
  aria-live="polite"
258
258
  aria-atomic={true}
259
- data-qa={`${labelTextWhenNoError} error message`}
260
259
  >
261
260
  {(field.hasErrors && field.dirty) || (field.hasErrors && showErrors) ? (
262
261
  <Text
@@ -23,7 +23,7 @@ export interface FormInputProps {
23
23
  themeValues?: object;
24
24
  background?: string;
25
25
  customHeight?: string;
26
- autocompleteValue?: string;
26
+ autocompleteValue?: string | null;
27
27
  removeFromValue?: RegExp;
28
28
  dataQa?: string | null;
29
29
  }
@@ -68,7 +68,7 @@ const FormSelect = ({
68
68
  </Box>
69
69
  <Dropdown
70
70
  ariaLabelledby={createIdFromString(labelTextWhenNoError)}
71
- ariaDescribedBy={createIdFromString(
71
+ ariaDescribedby={createIdFromString(
72
72
  labelTextWhenNoError,
73
73
  "error message"
74
74
  )}
@@ -20,7 +20,7 @@ export interface FormSelectProps {
20
20
  disabledValues?: string[];
21
21
  themeValues?: object;
22
22
  hasTitles?: boolean;
23
- autocompleteValue?: string;
23
+ autocompleteValue?: string | null;
24
24
  smoothScroll?: boolean;
25
25
  dataQa?: string | null;
26
26
  }
@@ -52,7 +52,6 @@ const AccountAndRoutingModal = ({
52
52
  }}
53
53
  >
54
54
  <Text
55
- role="button"
56
55
  variant="pS"
57
56
  onClick={() => toggleOpen(true)}
58
57
  onKeyPress={e => e.key === "Enter" && toggleOpen(true)}
@@ -5,7 +5,7 @@ export interface LinkCardProps {
5
5
  variant?: string; // "default" is only one
6
6
  title?: string; // title
7
7
  subtitle?: string; // beneath title
8
- themeValues?: object;
8
+ themeValues?: any;
9
9
  showLeft?: boolean;
10
10
  leftContent?: JSX.Element;
11
11
  showRight?: boolean;
@@ -45,7 +45,7 @@ const Modal = ({
45
45
  isLoading,
46
46
  buttonExtraStyles,
47
47
  children,
48
- dataQa = ""
48
+ dataQa = null
49
49
  }) => {
50
50
  const { isMobile } = useContext(ThemeContext);
51
51
  const modalContainerRef = useRef(null);
@@ -14,28 +14,13 @@ export const createPartialAmountFormState = (
14
14
  blockPartialPaymentOverpay = false
15
15
  ) => {
16
16
  const formConfig = lineItems.reduce((acc, item) => {
17
- const validators = [
18
- required(),
19
- validateSum(
20
- numberGreaterThanOrEqualTo(minimum),
21
- lineItems
22
- .filter(lineItem => lineItem != item)
23
- .reduce((acc, curr) => [...acc, curr.id], [])
24
- )
25
- ];
26
- if (!!maximum) {
27
- validators.push(
28
- validateSum(
29
- numberLessThanOrEqualTo(maximum),
30
- lineItems
31
- .filter(lineItem => lineItem != item)
32
- .reduce((acc, curr) => [...acc, curr.id], [])
33
- )
34
- );
35
- }
36
- if (blockPartialPaymentOverpay) {
37
- validators.push(numberLessThanOrEqualTo(item.amount));
38
- }
17
+ const validators = createPartialAmountFormValidators(
18
+ item,
19
+ lineItems,
20
+ maximum,
21
+ minimum,
22
+ blockPartialPaymentOverpay
23
+ );
39
24
  return {
40
25
  ...acc,
41
26
  [item.id]: {
@@ -54,3 +39,36 @@ export const createPartialAmountFormState = (
54
39
  partialAmountFormMapDispatchToProps: mapDispatchToProps
55
40
  };
56
41
  };
42
+
43
+ export const createPartialAmountFormValidators = (
44
+ item,
45
+ lineItems,
46
+ maximum,
47
+ minimum = 1,
48
+ blockPartialPaymentOverpay = false
49
+ ) => {
50
+ const validators = [
51
+ required(),
52
+ validateSum(
53
+ numberGreaterThanOrEqualTo(minimum),
54
+ lineItems
55
+ .filter(lineItem => lineItem != item)
56
+ .reduce((acc, curr) => [...acc, curr.id], [])
57
+ )
58
+ ];
59
+ if (!!maximum) {
60
+ validators.push(
61
+ validateSum(
62
+ numberLessThanOrEqualTo(maximum),
63
+ lineItems
64
+ .filter(lineItem => lineItem != item)
65
+ .reduce((acc, curr) => [...acc, curr.id], [])
66
+ )
67
+ );
68
+ }
69
+ if (blockPartialPaymentOverpay) {
70
+ validators.push(numberLessThanOrEqualTo(item.amount));
71
+ }
72
+
73
+ return validators;
74
+ };
@@ -1,4 +1,11 @@
1
1
  import PartialAmountForm from "./PartialAmountForm";
2
- import { createPartialAmountFormState } from "./PartialAmountForm.state";
2
+ import {
3
+ createPartialAmountFormState,
4
+ createPartialAmountFormValidators
5
+ } from "./PartialAmountForm.state";
3
6
 
4
- export { PartialAmountForm, createPartialAmountFormState };
7
+ export {
8
+ PartialAmountForm,
9
+ createPartialAmountFormState,
10
+ createPartialAmountFormValidators
11
+ };
@@ -13,6 +13,7 @@ import { displayCurrency } from "../../../util/general";
13
13
  import { themeComponent } from "../../../util/themeUtils";
14
14
  import CollapsibleSection from "../collapsible-section";
15
15
 
16
+ import LoadingLine from "../../atoms/loading-line";
16
17
  import LabeledAmount from "../../atoms/labeled-amount";
17
18
  import LineItem from "../../atoms/line-item";
18
19
  import Title from "../../atoms/title";
@@ -120,22 +121,41 @@ const PaymentDetailsContent = ({
120
121
  );
121
122
 
122
123
  const LoadingDetails = () => (
123
- <Box
124
- padding="0"
125
- background={GRECIAN_GREY}
126
- borderRadius="4px"
127
- minHeight="196px"
128
- >
129
- <Cover minHeight="196px" singleChild fillCenter>
130
- <Center intrinsic>
131
- <Box
132
- padding="0"
133
- extraStyles={`flex-grow: 1; display: flex; justify-content: center; align-items: center;`}
134
- >
135
- <Spinner size="100" centerSpinner />
136
- </Box>
137
- </Center>
138
- </Cover>
124
+ <Box padding="0" minHeight="196px">
125
+ <Box
126
+ padding="0"
127
+ extraStyles={`position: absolute;
128
+ height: 200px;
129
+ width: 100%;
130
+ display: flex;
131
+ justify-content: center;
132
+ align-items: center;`}
133
+ >
134
+ <Spinner size="100" centerSpinner />
135
+ </Box>
136
+ <Stack childGap="16px">
137
+ <Cluster nowrap justify="space-between" align="start">
138
+ <LoadingLine exactWidth="110" height="27px" />
139
+ <LoadingLine exactWidth="60" height="27px" />
140
+ </Cluster>
141
+ <SolidDivider />
142
+ <Box padding="0.5rem 0">
143
+ <Cluster justify="space-between" align="start">
144
+ <LoadingLine exactWidth="80" height="27px" />
145
+ <LoadingLine exactWidth="60" height="27px" />
146
+ </Cluster>
147
+ <Box padding="4px 0" />
148
+ <Cluster justify="space-between" align="start">
149
+ <LoadingLine exactWidth="100" height="27px" />
150
+ <LoadingLine exactWidth="50" height="27px" />
151
+ </Cluster>
152
+ </Box>
153
+ <SolidDivider />
154
+ <Stack justify="space-between" direction="row">
155
+ <LoadingLine exactWidth="55" height="30px" />
156
+ <LoadingLine exactWidth="70" height="30px" />
157
+ </Stack>
158
+ </Stack>
139
159
  </Box>
140
160
  );
141
161
 
@@ -42,6 +42,7 @@ const PhoneForm = ({
42
42
  onKeyUp={e => e.key === "Enter" && handleSubmit(e)}
43
43
  autocompleteValue="tel"
44
44
  dataQa="Phone number"
45
+ isNum={true}
45
46
  />
46
47
  {showWalletCheckbox && (
47
48
  <Checkbox
@@ -14,12 +14,11 @@ const TermsAndConditionsControlV1 = ({
14
14
  }) => {
15
15
  const [showTerms, toggleShowTerms] = useState(false);
16
16
  return (
17
- <DisplayBox dataQa="TermsAndConditionsControlV1">
17
+ <DisplayBox>
18
18
  <Stack>
19
19
  <Checkbox
20
20
  name="terms"
21
21
  title="Terms and Conditions"
22
- dataQa="Terms and Conditions"
23
22
  error={error}
24
23
  checked={isChecked}
25
24
  onChange={onCheck}
@@ -45,7 +45,6 @@ const TermsAndConditionsControlV2 = ({
45
45
  background={displayInline ? "transparent" : containerBackground}
46
46
  boxShadow={displayInline ? "none" : standardBoxShadow}
47
47
  borderRadius={displayInline ? "0" : "4px"}
48
- dataQa="TermsAndConditionsControlV2"
49
48
  >
50
49
  <Stack childGap="0">
51
50
  {html && <Box padding="0">{html}</Box>}
@@ -1,32 +0,0 @@
1
- import React from "react";
2
- import Expand from "../../../util/expand";
3
-
4
- export interface DropdownOption {
5
- text: string;
6
- value: string;
7
- }
8
-
9
- export interface DropdownProps {
10
- placeholder?: string;
11
- options?: DropdownOption[];
12
- value?: string;
13
- isOpen?: boolean;
14
- isError?: boolean;
15
- onSelect?: (event: React.SyntheticEvent<HTMLElement>) => void;
16
- disabledValues?: string[];
17
- onClick?: (event: React.MouseEvent<HTMLElement>) => void;
18
- themeValues?: object;
19
- maxHeight?: string;
20
- widthFitOptions?: boolean;
21
- disabled?: boolean;
22
- hasTitles?: boolean;
23
- autoEraseTypeAhead?: true;
24
- ariaLabelledby?: string;
25
- ariaDescribedby?: string;
26
- autocompleteValue?: string;
27
- smoothScroll?: boolean;
28
- ariaInvalid?: boolean;
29
- }
30
-
31
- export const Dropdown: React.FC<Expand<DropdownProps> &
32
- React.HTMLAttributes<HTMLElement>>;
@@ -1,26 +0,0 @@
1
- import React from "react";
2
-
3
- import {
4
- ErrorMessageDictionary,
5
- Field,
6
- FieldActions,
7
- FormSelectOption
8
- } from "../../../types/common";
9
- import Expand from "../../../util/expand";
10
-
11
- export interface StateProvinceDropdownProps {
12
- labelTextWhenNoError?: string;
13
- errorMessages?: ErrorMessageDictionary;
14
- field?: Field;
15
- fieldActions?: FieldActions;
16
- options?: FormSelectOption[];
17
- showErrors?: boolean;
18
- countryCode?: string;
19
- autocompleteValue?: string;
20
- dataQa?: string;
21
- }
22
-
23
- export const StateProvinceDropdown: React.FC<Expand<
24
- StateProvinceDropdownProps
25
- > &
26
- React.HTMLAttributes<HTMLElement>>;