@transferwise/components 0.0.0-experimental-db313a8 → 0.0.0-experimental-d44d661

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 (82) hide show
  1. package/build/dateInput/DateInput.js +8 -33
  2. package/build/dateInput/DateInput.js.map +1 -1
  3. package/build/dateInput/DateInput.mjs +10 -35
  4. package/build/dateInput/DateInput.mjs.map +1 -1
  5. package/build/dateLookup/DateLookup.js +2 -4
  6. package/build/dateLookup/DateLookup.js.map +1 -1
  7. package/build/dateLookup/DateLookup.mjs +2 -4
  8. package/build/dateLookup/DateLookup.mjs.map +1 -1
  9. package/build/dateLookup/dateTrigger/DateTrigger.js +0 -2
  10. package/build/dateLookup/dateTrigger/DateTrigger.js.map +1 -1
  11. package/build/dateLookup/dateTrigger/DateTrigger.mjs +0 -2
  12. package/build/dateLookup/dateTrigger/DateTrigger.mjs.map +1 -1
  13. package/build/field/Field.js +2 -7
  14. package/build/field/Field.js.map +1 -1
  15. package/build/field/Field.mjs +8 -13
  16. package/build/field/Field.mjs.map +1 -1
  17. package/build/inputs/InputGroup.js +1 -1
  18. package/build/inputs/InputGroup.js.map +1 -1
  19. package/build/inputs/InputGroup.mjs +2 -2
  20. package/build/inputs/InputGroup.mjs.map +1 -1
  21. package/build/inputs/SelectInput.js +3 -9
  22. package/build/inputs/SelectInput.js.map +1 -1
  23. package/build/inputs/SelectInput.mjs +3 -9
  24. package/build/inputs/SelectInput.mjs.map +1 -1
  25. package/build/inputs/_BottomSheet.js +29 -1
  26. package/build/inputs/_BottomSheet.js.map +1 -1
  27. package/build/inputs/_BottomSheet.mjs +30 -2
  28. package/build/inputs/_BottomSheet.mjs.map +1 -1
  29. package/build/inputs/contexts.js +4 -8
  30. package/build/inputs/contexts.js.map +1 -1
  31. package/build/inputs/contexts.mjs +4 -7
  32. package/build/inputs/contexts.mjs.map +1 -1
  33. package/build/label/Label.js +8 -14
  34. package/build/label/Label.js.map +1 -1
  35. package/build/label/Label.mjs +8 -14
  36. package/build/label/Label.mjs.map +1 -1
  37. package/build/main.css +1 -0
  38. package/build/moneyInput/MoneyInput.js +5 -6
  39. package/build/moneyInput/MoneyInput.js.map +1 -1
  40. package/build/moneyInput/MoneyInput.mjs +5 -6
  41. package/build/moneyInput/MoneyInput.mjs.map +1 -1
  42. package/build/phoneNumberInput/PhoneNumberInput.js +2 -24
  43. package/build/phoneNumberInput/PhoneNumberInput.js.map +1 -1
  44. package/build/phoneNumberInput/PhoneNumberInput.mjs +4 -26
  45. package/build/phoneNumberInput/PhoneNumberInput.mjs.map +1 -1
  46. package/build/styles/dimmer/Dimmer.css +1 -0
  47. package/build/styles/main.css +1 -0
  48. package/build/types/dateInput/DateInput.d.ts +2 -2
  49. package/build/types/dateInput/DateInput.d.ts.map +1 -1
  50. package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
  51. package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts +0 -1
  52. package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts.map +1 -1
  53. package/build/types/field/Field.d.ts.map +1 -1
  54. package/build/types/inputs/InputGroup.d.ts.map +1 -1
  55. package/build/types/inputs/SelectInput.d.ts +1 -3
  56. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  57. package/build/types/inputs/_BottomSheet.d.ts.map +1 -1
  58. package/build/types/inputs/contexts.d.ts +1 -6
  59. package/build/types/inputs/contexts.d.ts.map +1 -1
  60. package/build/types/label/Label.d.ts +15 -5
  61. package/build/types/label/Label.d.ts.map +1 -1
  62. package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
  63. package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
  64. package/package.json +1 -1
  65. package/src/common/bottomSheet/BottomSheet.test.story.tsx +73 -0
  66. package/src/dateInput/DateInput.tsx +13 -43
  67. package/src/dateLookup/DateLookup.tsx +3 -5
  68. package/src/dateLookup/dateTrigger/DateTrigger.tsx +0 -3
  69. package/src/dimmer/Dimmer.css +1 -0
  70. package/src/dimmer/Dimmer.less +1 -0
  71. package/src/field/Field.tsx +5 -6
  72. package/src/inputs/InputGroup.tsx +4 -3
  73. package/src/inputs/SelectInput.spec.tsx +33 -0
  74. package/src/inputs/SelectInput.test.story.tsx +76 -0
  75. package/src/inputs/SelectInput.tsx +3 -13
  76. package/src/inputs/_BottomSheet.tsx +19 -6
  77. package/src/inputs/contexts.tsx +3 -12
  78. package/src/label/Label.tsx +20 -26
  79. package/src/main.css +1 -0
  80. package/src/moneyInput/MoneyInput.spec.tsx +1 -2
  81. package/src/moneyInput/MoneyInput.tsx +6 -7
  82. package/src/phoneNumberInput/PhoneNumberInput.tsx +10 -31
@@ -313,10 +313,10 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
313
313
  const selectedCurrencyElementId = `${inputAttributes?.id ?? amountInputId}SelectedCurrency`;
314
314
 
315
315
  return (
316
- <fieldset
317
- aria-invalid={inputAttributes?.['aria-invalid']}
318
- aria-describedby={inputAttributes?.['aria-describedby']}
319
- aria-labelledby={inputAttributes?.id ?? amountInputId}
316
+ <div
317
+ role="group"
318
+ {...inputAttributes}
319
+ aria-labelledby={ariaLabelledBy}
320
320
  className={clsx(
321
321
  this.style('tw-money-input'),
322
322
  this.style('input-group'),
@@ -324,8 +324,7 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
324
324
  )}
325
325
  >
326
326
  <Input
327
- id={inputAttributes?.id ?? amountInputId}
328
- aria-labelledby={ariaLabelledBy}
327
+ id={amountInputId}
329
328
  value={this.state.formattedAmount}
330
329
  inputMode="decimal"
331
330
  disabled={disabled}
@@ -431,7 +430,7 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
431
430
  />
432
431
  </div>
433
432
  )}
434
- </fieldset>
433
+ </div>
435
434
  );
436
435
  }
437
436
  }
@@ -1,8 +1,8 @@
1
- import { useState, useEffect, useMemo, useRef } from 'react';
1
+ import { useState, useEffect, useMemo } from 'react';
2
2
  import { useIntl } from 'react-intl';
3
3
 
4
4
  import { Size, SizeLarge, SizeMedium, SizeSmall } from '../common';
5
- import { useFieldLabelRef, useInputAttributes } from '../inputs/contexts';
5
+ import { useInputAttributes } from '../inputs/contexts';
6
6
  import { SelectInput, SelectInputOptionContent, SelectInputProps } from '../inputs/SelectInput';
7
7
  import messages from './PhoneNumberInput.messages';
8
8
  import countries from './data/countries';
@@ -58,10 +58,7 @@ const PhoneNumberInput = ({
58
58
  selectProps = defaultSelectProps,
59
59
  disabledCountries = defaultDisabledCountries,
60
60
  }: PhoneNumberInputProps) => {
61
- const countryCodeSelectRef = useRef<HTMLButtonElement>(null);
62
- const phoneNumberInputRef = useRef<HTMLInputElement>(null);
63
61
  const inputAttributes = useInputAttributes({ nonLabelable: true });
64
- const fieldLabelRef = useFieldLabelRef();
65
62
  const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes['aria-labelledby'];
66
63
 
67
64
  const { locale, formatMessage } = useIntl();
@@ -74,7 +71,6 @@ const PhoneNumberInput = ({
74
71
  return `${backup}-${random}`;
75
72
  };
76
73
 
77
- // Link the first non-disabled input to the the Field label, if present
78
74
  const ids = {
79
75
  countryCode: {
80
76
  label: createId(id, 'country-code-label'),
@@ -166,34 +162,18 @@ const PhoneNumberInput = ({
166
162
  setBroadcastedValue(internalValue);
167
163
  }, [onChange, broadcastedValue, internalValue]);
168
164
 
169
- useEffect(() => {
170
- const labelRef = fieldLabelRef?.current;
171
-
172
- if (labelRef) {
173
- const handleLabelClick = () => {
174
- if (!selectProps.disabled) {
175
- countryCodeSelectRef.current?.click();
176
- } else {
177
- phoneNumberInputRef.current?.focus();
178
- }
179
- };
180
-
181
- labelRef.addEventListener('click', handleLabelClick);
182
-
183
- return () => {
184
- labelRef?.removeEventListener('click', handleLabelClick);
185
- };
186
- }
187
- }, [fieldLabelRef, selectProps.disabled]);
188
-
189
165
  return (
190
- <fieldset {...inputAttributes} aria-labelledby={ariaLabelledBy} className="tw-telephone">
191
- <label className="sr-only" id={ids.countryCode.label} htmlFor={ids.countryCode.select}>
166
+ <div
167
+ role="group"
168
+ {...inputAttributes}
169
+ aria-labelledby={ariaLabelledBy}
170
+ className="tw-telephone"
171
+ >
172
+ <label className="sr-only" id={ids.countryCode.label}>
192
173
  {formatMessage(messages.countryCodeLabel)}
193
174
  </label>
194
175
  <div className="tw-telephone__country-select">
195
176
  <SelectInput
196
- triggerRef={countryCodeSelectRef}
197
177
  placeholder={formatMessage(messages.selectInputPlaceholder)}
198
178
  items={[...countriesByPrefix].map(([prefix, countries]) => ({
199
179
  type: 'option',
@@ -247,7 +227,6 @@ const PhoneNumberInput = ({
247
227
  <div className="tw-telephone__number-input">
248
228
  <div className={`input-group input-group-${size}`}>
249
229
  <Input
250
- ref={phoneNumberInputRef}
251
230
  id={ids.phoneNumber.input}
252
231
  autoComplete="tel-national"
253
232
  name="phoneNumber"
@@ -264,7 +243,7 @@ const PhoneNumberInput = ({
264
243
  />
265
244
  </div>
266
245
  </div>
267
- </fieldset>
246
+ </div>
268
247
  );
269
248
  };
270
249