@transferwise/components 0.0.0-experimental-f304e2c → 0.0.0-experimental-2fa5e3f

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 (84) hide show
  1. package/build/card/Card.js +20 -13
  2. package/build/card/Card.js.map +1 -1
  3. package/build/card/Card.mjs +21 -14
  4. package/build/card/Card.mjs.map +1 -1
  5. package/build/common/Option/Option.js.map +1 -1
  6. package/build/common/Option/Option.mjs.map +1 -1
  7. package/build/dateLookup/dateTrigger/DateTrigger.js +4 -8
  8. package/build/dateLookup/dateTrigger/DateTrigger.js.map +1 -1
  9. package/build/dateLookup/dateTrigger/DateTrigger.mjs +4 -8
  10. package/build/dateLookup/dateTrigger/DateTrigger.mjs.map +1 -1
  11. package/build/field/Field.js +3 -13
  12. package/build/field/Field.js.map +1 -1
  13. package/build/field/Field.mjs +3 -13
  14. package/build/field/Field.mjs.map +1 -1
  15. package/build/i18n/en.json +1 -3
  16. package/build/i18n/en.json.js +1 -3
  17. package/build/i18n/en.json.js.map +1 -1
  18. package/build/i18n/en.json.mjs +1 -3
  19. package/build/i18n/en.json.mjs.map +1 -1
  20. package/build/inlineAlert/InlineAlert.js +6 -4
  21. package/build/inlineAlert/InlineAlert.js.map +1 -1
  22. package/build/inlineAlert/InlineAlert.mjs +6 -4
  23. package/build/inlineAlert/InlineAlert.mjs.map +1 -1
  24. package/build/label/Label.js +1 -29
  25. package/build/label/Label.js.map +1 -1
  26. package/build/label/Label.mjs +2 -30
  27. package/build/label/Label.mjs.map +1 -1
  28. package/build/main.css +8 -4
  29. package/build/styles/dateLookup/dateTrigger/DateTrigger.css +8 -0
  30. package/build/styles/main.css +8 -4
  31. package/build/types/card/Card.d.ts.map +1 -1
  32. package/build/types/common/Option/Option.d.ts +2 -0
  33. package/build/types/common/Option/Option.d.ts.map +1 -1
  34. package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts.map +1 -1
  35. package/build/types/field/Field.d.ts +2 -4
  36. package/build/types/field/Field.d.ts.map +1 -1
  37. package/build/types/index.d.ts +1 -1
  38. package/build/types/index.d.ts.map +1 -1
  39. package/build/types/inlineAlert/InlineAlert.d.ts.map +1 -1
  40. package/build/types/label/Label.d.ts +1 -10
  41. package/build/types/label/Label.d.ts.map +1 -1
  42. package/package.json +3 -3
  43. package/src/card/Card.spec.tsx +35 -3
  44. package/src/card/Card.story.tsx +56 -40
  45. package/src/card/Card.tsx +32 -14
  46. package/src/common/Option/Option.tsx +2 -0
  47. package/src/dateInput/DateInput.tests.story.tsx +31 -7
  48. package/src/dateLookup/DateLookup.rtl.spec.tsx +1 -1
  49. package/src/dateLookup/dateTrigger/DateTrigger.css +8 -0
  50. package/src/dateLookup/dateTrigger/DateTrigger.less +8 -0
  51. package/src/dateLookup/dateTrigger/DateTrigger.spec.js +1 -1
  52. package/src/dateLookup/dateTrigger/DateTrigger.tsx +4 -9
  53. package/src/field/Field.spec.tsx +3 -3
  54. package/src/field/Field.story.tsx +7 -106
  55. package/src/field/Field.tests.story.tsx +33 -0
  56. package/src/field/Field.tsx +6 -12
  57. package/src/i18n/en.json +1 -3
  58. package/src/index.ts +1 -1
  59. package/src/inlineAlert/InlineAlert.story.tsx +72 -8
  60. package/src/inlineAlert/InlineAlert.tsx +3 -5
  61. package/src/inputs/InputGroup.spec.tsx +1 -1
  62. package/src/inputs/SearchInput.spec.tsx +1 -1
  63. package/src/inputs/SelectInput.spec.tsx +1 -1
  64. package/src/label/Label.story.tsx +25 -19
  65. package/src/label/Label.tsx +2 -38
  66. package/src/main.css +8 -4
  67. package/src/main.less +0 -1
  68. package/src/moneyInput/MoneyInput.story.tsx +2 -0
  69. package/src/radioGroup/RadioGroup.rtl.spec.tsx +1 -1
  70. package/src/select/Select.rtl.spec.tsx +1 -1
  71. package/src/switch/Switch.spec.tsx +1 -1
  72. package/build/label/Label.messages.js +0 -15
  73. package/build/label/Label.messages.js.map +0 -1
  74. package/build/label/Label.messages.mjs +0 -13
  75. package/build/label/Label.messages.mjs.map +0 -1
  76. package/build/styles/field/Field.css +0 -4
  77. package/build/types/label/Label.messages.d.ts +0 -12
  78. package/build/types/label/Label.messages.d.ts.map +0 -1
  79. package/build/types/label/index.d.ts +0 -3
  80. package/build/types/label/index.d.ts.map +0 -1
  81. package/src/field/Field.css +0 -4
  82. package/src/field/Field.less +0 -5
  83. package/src/label/Label.messages.tsx +0 -12
  84. package/src/label/index.ts +0 -2
@@ -11,6 +11,6 @@ describe('SearchInput', () => {
11
11
  <SearchInput />
12
12
  </Field>,
13
13
  );
14
- expect(screen.getByLabelText(/Search…/)).toHaveRole('searchbox');
14
+ expect(screen.getByLabelText('Search…')).toHaveRole('searchbox');
15
15
  });
16
16
  });
@@ -214,6 +214,6 @@ describe('SelectInput', () => {
214
214
  <SelectInput items={[{ type: 'option', value: 'USD' }]} value="USD" />
215
215
  </Field>,
216
216
  );
217
- expect(screen.getByLabelText(/Currency/)).toHaveAttribute('aria-haspopup');
217
+ expect(screen.getByLabelText('Currency')).toHaveAttribute('aria-haspopup');
218
218
  });
219
219
  });
@@ -1,31 +1,37 @@
1
+ import { useState } from 'react';
2
+
3
+ import Info from '../info/Info';
4
+ import { Input } from '../inputs/Input';
1
5
  import { Label } from './Label';
2
6
 
3
7
  export default {
4
8
  component: Label,
5
9
  title: 'Label',
6
- tags: ['autodocs'],
7
10
  };
8
11
 
9
12
  export const Basic = () => {
13
+ const [value, setValue] = useState<string | undefined>('This is some text');
10
14
  return (
11
- <>
12
- <p>
13
- Avoid using <code>Label</code> component directly (unless for some custom use cases), for
14
- form control labels and descriptions / info messages, please use <code>Field</code>{' '}
15
- component
16
- <pre>{'<Field label={..} description={..} required={..}>'}</pre>
17
- </p>
18
-
19
- <Label className="m-b-2">Text Input</Label>
20
-
21
- <Label className="m-b-2">
22
- <Label.Optional>Text Input</Label.Optional>
23
- </Label>
15
+ <Label>
16
+ Phone number
17
+ <Input value={value} id="input" onChange={({ target }) => setValue(target.value)} />
18
+ </Label>
19
+ );
20
+ };
24
21
 
25
- <Label className="m-b-2">
26
- <Label.Optional>Text Input with Description</Label.Optional>
27
- <Label.Description>This a field Description</Label.Description>
28
- </Label>
29
- </>
22
+ export const WithInfo = () => {
23
+ const [value, setValue] = useState<string | undefined>('This is some text');
24
+ return (
25
+ <Label>
26
+ <span className="d-flex">
27
+ Phone number{' '}
28
+ <Info
29
+ content="This is some help in popover"
30
+ aria-label="The aria label"
31
+ className="m-l-1"
32
+ />
33
+ </span>
34
+ <Input value={value} id="input" onChange={({ target }) => setValue(target.value)} />
35
+ </Label>
30
36
  );
31
37
  };
@@ -1,9 +1,4 @@
1
1
  import { clsx } from 'clsx';
2
- import messages from './Label.messages';
3
- import { useIntl } from 'react-intl';
4
- import Body from '../body';
5
- import { CommonProps } from '../common';
6
- import { PropsWithChildren } from 'react';
7
2
 
8
3
  export type LabelProps = {
9
4
  id?: string;
@@ -12,45 +7,14 @@ export type LabelProps = {
12
7
  children?: React.ReactNode;
13
8
  };
14
9
 
15
- const Label = ({ id, htmlFor, className, children }: LabelProps) => {
10
+ export const Label = ({ id, htmlFor, className, children }: LabelProps) => {
16
11
  return (
17
12
  <label
18
13
  id={id}
19
14
  htmlFor={htmlFor}
20
- className={clsx(
21
- 'np-label d-flex flex-column m-b-0 np-text-body-default-bold text-primary',
22
- className,
23
- )}
15
+ className={clsx('control-label d-flex flex-column gap-y-1 m-b-0', className)}
24
16
  >
25
17
  {children}
26
18
  </label>
27
19
  );
28
20
  };
29
-
30
- export type LabelOptionalProps = PropsWithChildren<CommonProps>;
31
-
32
- const Optional = ({ children, className }: LabelOptionalProps) => {
33
- const { formatMessage } = useIntl();
34
- return (
35
- <div>
36
- {children}
37
- <Body
38
- as="span"
39
- aria-label={formatMessage(messages.optionalAriaLabel)}
40
- className={clsx('text-secondary', 'm-l-1', className)}
41
- >
42
- {formatMessage(messages.optionalLabel)}
43
- </Body>
44
- </div>
45
- );
46
- };
47
-
48
- export type LabelDescriptionProps = PropsWithChildren<CommonProps>;
49
-
50
- const Description = ({ children, className }: LabelDescriptionProps) =>
51
- children ? <Body className={clsx('text-secondary', className)}>{children}</Body> : null;
52
-
53
- Label.Optional = Optional;
54
- Label.Description = Description;
55
-
56
- export { Label };
package/src/main.css CHANGED
@@ -1719,10 +1719,18 @@ button.np-option {
1719
1719
  white-space: nowrap;
1720
1720
  width: 100%;
1721
1721
  }
1722
+ .np-date-trigger .control-label {
1723
+ font-weight: 400;
1724
+ font-weight: var(--font-weight-regular);
1725
+ }
1722
1726
  .np-theme-personal .np-date-trigger {
1723
1727
  padding-left: 16px;
1724
1728
  padding-left: var(--size-16);
1725
1729
  }
1730
+ .np-theme-personal .np-date-trigger .control-label + span {
1731
+ font-weight: 400;
1732
+ font-weight: var(--font-weight-regular);
1733
+ }
1726
1734
  .clear-btn {
1727
1735
  transition: color 0.15s ease-in-out;
1728
1736
  color: #c9cbce;
@@ -2377,10 +2385,6 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
2377
2385
  border-radius: 9999px !important;
2378
2386
  border-radius: var(--radius-full) !important;
2379
2387
  }
2380
- .np-field-control {
2381
- margin-top: 4px;
2382
- margin-top: var(--size-4);
2383
- }
2384
2388
  .np-input-group {
2385
2389
  display: inline-grid;
2386
2390
  width: 100%;
package/src/main.less CHANGED
@@ -32,7 +32,6 @@
32
32
  @import "./image/Image.less";
33
33
  @import "./info/Info.less";
34
34
  @import "./inputs/Input.less";
35
- @import "./field/Field.less";
36
35
  @import "./inputs/InputGroup.less";
37
36
  @import "./inputs/SelectInput.less";
38
37
  @import "./inputs/TextArea.less";
@@ -4,6 +4,8 @@ import { Lock } from '@transferwise/icons';
4
4
  import { useState } from 'react';
5
5
 
6
6
  import MoneyInput, { CurrencyOptionItem } from '.';
7
+ import Provider from '../provider/Provider';
8
+ import translations from '../i18n';
7
9
 
8
10
  export default {
9
11
  component: MoneyInput,
@@ -1,4 +1,4 @@
1
- import { render, screen } from '../test-utils';
1
+ import { render, screen } from '@testing-library/react';
2
2
 
3
3
  import RadioGroup from '.';
4
4
  import { Field } from '../field/Field';
@@ -12,6 +12,6 @@ describe('Select', () => {
12
12
  <Select options={options} selected={options[0]} onChange={() => {}} />
13
13
  </Field>,
14
14
  );
15
- expect(screen.getByLabelText(/Currency/)).toHaveTextContent('USD');
15
+ expect(screen.getByLabelText('Currency')).toHaveTextContent('USD');
16
16
  });
17
17
  });
@@ -89,6 +89,6 @@ describe('Switch', () => {
89
89
  <Switch checked onClick={props.onClick} />
90
90
  </Field>,
91
91
  );
92
- expect(screen.getByLabelText(/Dark mode/)).toHaveAttribute('role', 'switch');
92
+ expect(screen.getByLabelText('Dark mode')).toHaveAttribute('role', 'switch');
93
93
  });
94
94
  });
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- var reactIntl = require('react-intl');
4
-
5
- var messages = reactIntl.defineMessages({
6
- optionalLabel: {
7
- id: "neptune.Label.optional"
8
- },
9
- optionalAriaLabel: {
10
- id: "neptune.aria.Label.optional"
11
- }
12
- });
13
-
14
- module.exports = messages;
15
- //# sourceMappingURL=Label.messages.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Label.messages.js","sources":["../../src/label/Label.messages.tsx"],"sourcesContent":["import { defineMessages } from 'react-intl';\n\nexport default defineMessages({\n optionalLabel: {\n id: 'neptune.Label.optional',\n defaultMessage: '(Optional)',\n },\n optionalAriaLabel: {\n id: 'neptune.aria.Label.optional',\n defaultMessage: 'This field is optional',\n },\n});\n"],"names":["defineMessages","optionalLabel","id","optionalAriaLabel"],"mappings":";;;;AAEA,eAAeA,wBAAc,CAAC;AAC5BC,EAAAA,aAAa,EAAE;IACbC,EAAE,EAAA,wBAAA;GAEH;AACDC,EAAAA,iBAAiB,EAAE;IACjBD,EAAE,EAAA,6BAAA;AAEH,GAAA;AACF,CAAA,CAAC;;;;"}
@@ -1,13 +0,0 @@
1
- import { defineMessages } from 'react-intl';
2
-
3
- var messages = defineMessages({
4
- optionalLabel: {
5
- id: "neptune.Label.optional"
6
- },
7
- optionalAriaLabel: {
8
- id: "neptune.aria.Label.optional"
9
- }
10
- });
11
-
12
- export { messages as default };
13
- //# sourceMappingURL=Label.messages.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Label.messages.mjs","sources":["../../src/label/Label.messages.tsx"],"sourcesContent":["import { defineMessages } from 'react-intl';\n\nexport default defineMessages({\n optionalLabel: {\n id: 'neptune.Label.optional',\n defaultMessage: '(Optional)',\n },\n optionalAriaLabel: {\n id: 'neptune.aria.Label.optional',\n defaultMessage: 'This field is optional',\n },\n});\n"],"names":["defineMessages","optionalLabel","id","optionalAriaLabel"],"mappings":";;AAEA,eAAeA,cAAc,CAAC;AAC5BC,EAAAA,aAAa,EAAE;IACbC,EAAE,EAAA,wBAAA;GAEH;AACDC,EAAAA,iBAAiB,EAAE;IACjBD,EAAE,EAAA,6BAAA;AAEH,GAAA;AACF,CAAA,CAAC;;;;"}
@@ -1,4 +0,0 @@
1
- .np-field-control {
2
- margin-top: 4px;
3
- margin-top: var(--size-4);
4
- }
@@ -1,12 +0,0 @@
1
- declare const _default: {
2
- optionalLabel: {
3
- id: string;
4
- defaultMessage: string;
5
- };
6
- optionalAriaLabel: {
7
- id: string;
8
- defaultMessage: string;
9
- };
10
- };
11
- export default _default;
12
- //# sourceMappingURL=Label.messages.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Label.messages.d.ts","sourceRoot":"","sources":["../../../src/label/Label.messages.tsx"],"names":[],"mappings":";;;;;;;;;;AAEA,wBASG"}
@@ -1,3 +0,0 @@
1
- export { Label } from './Label';
2
- export type { LabelProps, LabelOptionalProps, LabelDescriptionProps } from './Label';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/label/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC"}
@@ -1,4 +0,0 @@
1
- .np-field-control {
2
- margin-top: 4px;
3
- margin-top: var(--size-4);
4
- }
@@ -1,5 +0,0 @@
1
- .np-field {
2
- &-control {
3
- margin-top: var(--size-4);
4
- }
5
- }
@@ -1,12 +0,0 @@
1
- import { defineMessages } from 'react-intl';
2
-
3
- export default defineMessages({
4
- optionalLabel: {
5
- id: 'neptune.Label.optional',
6
- defaultMessage: '(Optional)',
7
- },
8
- optionalAriaLabel: {
9
- id: 'neptune.aria.Label.optional',
10
- defaultMessage: 'This field is optional',
11
- },
12
- });
@@ -1,2 +0,0 @@
1
- export { Label } from './Label';
2
- export type { LabelProps, LabelOptionalProps, LabelDescriptionProps } from './Label';