@transferwise/components 0.0.0-experimental-17cb250 → 0.0.0-experimental-333df2c

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 (70) hide show
  1. package/build/dateLookup/dateTrigger/DateTrigger.js +4 -8
  2. package/build/dateLookup/dateTrigger/DateTrigger.js.map +1 -1
  3. package/build/dateLookup/dateTrigger/DateTrigger.mjs +4 -8
  4. package/build/dateLookup/dateTrigger/DateTrigger.mjs.map +1 -1
  5. package/build/field/Field.js +2 -9
  6. package/build/field/Field.js.map +1 -1
  7. package/build/field/Field.mjs +2 -9
  8. package/build/field/Field.mjs.map +1 -1
  9. package/build/i18n/en.json +1 -3
  10. package/build/i18n/en.json.js +1 -3
  11. package/build/i18n/en.json.js.map +1 -1
  12. package/build/i18n/en.json.mjs +1 -3
  13. package/build/i18n/en.json.mjs.map +1 -1
  14. package/build/inputs/SelectInput.js +86 -34
  15. package/build/inputs/SelectInput.js.map +1 -1
  16. package/build/inputs/SelectInput.mjs +88 -36
  17. package/build/inputs/SelectInput.mjs.map +1 -1
  18. package/build/label/Label.js +1 -29
  19. package/build/label/Label.js.map +1 -1
  20. package/build/label/Label.mjs +2 -30
  21. package/build/label/Label.mjs.map +1 -1
  22. package/build/main.css +18 -0
  23. package/build/styles/dateLookup/dateTrigger/DateTrigger.css +8 -0
  24. package/build/styles/inputs/SelectInput.css +10 -0
  25. package/build/styles/main.css +18 -0
  26. package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts.map +1 -1
  27. package/build/types/field/Field.d.ts +2 -4
  28. package/build/types/field/Field.d.ts.map +1 -1
  29. package/build/types/index.d.ts +1 -1
  30. package/build/types/index.d.ts.map +1 -1
  31. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  32. package/build/types/label/Label.d.ts +1 -10
  33. package/build/types/label/Label.d.ts.map +1 -1
  34. package/package.json +5 -4
  35. package/src/dateInput/DateInput.tests.story.tsx +32 -8
  36. package/src/dateLookup/DateLookup.rtl.spec.tsx +1 -1
  37. package/src/dateLookup/dateTrigger/DateTrigger.css +8 -0
  38. package/src/dateLookup/dateTrigger/DateTrigger.less +8 -0
  39. package/src/dateLookup/dateTrigger/DateTrigger.spec.js +1 -1
  40. package/src/dateLookup/dateTrigger/DateTrigger.tsx +4 -9
  41. package/src/field/Field.spec.tsx +3 -3
  42. package/src/field/Field.story.tsx +3 -81
  43. package/src/field/Field.tests.story.tsx +33 -0
  44. package/src/field/Field.tsx +4 -10
  45. package/src/i18n/en.json +1 -3
  46. package/src/index.ts +1 -1
  47. package/src/inlineAlert/InlineAlert.story.tsx +21 -8
  48. package/src/inputs/InputGroup.spec.tsx +1 -1
  49. package/src/inputs/SearchInput.spec.tsx +1 -1
  50. package/src/inputs/SelectInput.css +10 -0
  51. package/src/inputs/SelectInput.less +12 -0
  52. package/src/inputs/SelectInput.spec.tsx +1 -1
  53. package/src/inputs/SelectInput.story.tsx +20 -0
  54. package/src/inputs/SelectInput.tsx +116 -37
  55. package/src/label/Label.story.tsx +21 -37
  56. package/src/label/Label.tsx +2 -42
  57. package/src/main.css +18 -0
  58. package/src/radioGroup/RadioGroup.rtl.spec.tsx +1 -1
  59. package/src/select/Select.rtl.spec.tsx +1 -1
  60. package/src/switch/Switch.spec.tsx +1 -1
  61. package/build/label/Label.messages.js +0 -15
  62. package/build/label/Label.messages.js.map +0 -1
  63. package/build/label/Label.messages.mjs +0 -13
  64. package/build/label/Label.messages.mjs.map +0 -1
  65. package/build/types/label/Label.messages.d.ts +0 -12
  66. package/build/types/label/Label.messages.d.ts.map +0 -1
  67. package/build/types/label/index.d.ts +0 -3
  68. package/build/types/label/index.d.ts.map +0 -1
  69. package/src/label/Label.messages.tsx +0 -12
  70. package/src/label/index.ts +0 -2
@@ -1 +1 @@
1
- {"version":3,"file":"Label.d.ts","sourceRoot":"","sources":["../../../src/label/Label.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B,CAAC;AAEF,QAAA,MAAM,KAAK;2CAA0C,UAAU;wCAqBpB,kBAAkB;2CAkBf,qBAAqB;CAtBlE,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;AAkBhE,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;AAQnE,OAAO,EAAE,KAAK,EAAE,CAAC"}
1
+ {"version":3,"file":"Label.d.ts","sourceRoot":"","sources":["../../../src/label/Label.tsx"],"names":[],"mappings":"AAEA,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,KAAK,yCAA0C,UAAU,gCAUrE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "0.0.0-experimental-17cb250",
3
+ "version": "0.0.0-experimental-333df2c",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -93,12 +93,12 @@
93
93
  "rollup-preserve-directives": "^1.1.1",
94
94
  "storybook": "^8.2.2",
95
95
  "@transferwise/less-config": "3.1.0",
96
- "@transferwise/neptune-css": "0.0.0-experimental-17cb250",
96
+ "@transferwise/neptune-css": "14.12.1",
97
97
  "@wise/components-theming": "1.5.0"
98
98
  },
99
99
  "peerDependencies": {
100
100
  "@transferwise/icons": "^3.7.0",
101
- "@transferwise/neptune-css": "0.0.0-experimental-17cb250",
101
+ "@transferwise/neptune-css": "^14.9.6",
102
102
  "@wise/art": "^2.7.0",
103
103
  "@wise/components-theming": "^1.0.0",
104
104
  "react": ">=18",
@@ -125,7 +125,8 @@
125
125
  "merge-props": "^6.0.0",
126
126
  "prop-types": "^15.8.1",
127
127
  "react-popper": "^2.3.0",
128
- "react-transition-group": "^4.4.5"
128
+ "react-transition-group": "^4.4.5",
129
+ "virtua": "^0.33.3"
129
130
  },
130
131
  "publishConfig": {
131
132
  "access": "public"
@@ -1,7 +1,7 @@
1
1
  import { Meta, StoryObj } from '@storybook/react';
2
2
  import { userEvent, within, fn } from '@storybook/test';
3
3
 
4
- import { DateInput, Field, InlineAlert, Label } from '..';
4
+ import { DateInput, DateMode, Info, InlineAlert, Title, Typography } from '..';
5
5
  import { lorem10, storyConfig } from '../test-utils';
6
6
 
7
7
  import Provider from '../provider/Provider';
@@ -39,19 +39,43 @@ export const WithLabel = {
39
39
  },
40
40
  render: (args) => {
41
41
  const id1 = 'date-input-group-label-1';
42
+ const label = 'Date of Birth';
42
43
 
43
44
  return (
44
45
  <>
45
- <Label id={id1}>
46
- <Label.Optional>Date of Delivery</Label.Optional>
47
- </Label>
48
- <DateInput {...args} aria-labelledby={id1} aria-label="" />
46
+ <Title type={Typography.TITLE_SUBSECTION}>
47
+ label (as <code>div</code> element) is linked with <code>DateInput</code> via{' '}
48
+ <code>aria-labelledby</code> prop
49
+ </Title>
50
+ <div className="control-label" id={id1}>
51
+ Date of Delivery
52
+ </div>
53
+ <DateInput {...args} aria-labelledby={id1} />
49
54
 
50
55
  <br />
51
56
 
52
- <Field label="Date of Delivery">
53
- <DateInput {...args} />
54
- </Field>
57
+ <Title type={Typography.TITLE_SUBSECTION}>
58
+ label (as <code>div</code> element) is detached but <code>DateInput</code> has same label
59
+ via <code>aria-label</code> attribute
60
+ </Title>
61
+ <div className="control-label">
62
+ {label}{' '}
63
+ <Info aria-label="Fast transfer hint" title="Fast transfer hint" content={lorem10} />
64
+ </div>
65
+ <DateInput {...args} aria-label={label} />
66
+
67
+ <br />
68
+
69
+ <Title type={Typography.TITLE_SUBSECTION}>
70
+ <code>DateInput</code> wrapped in <code>fieldset</code> + using <code>legend</code> as
71
+ label (rare use case)
72
+ </Title>
73
+ <fieldset>
74
+ <legend className="control-label">
75
+ Expiry Date for Credit Card (example of MONTH_YEAR mode)
76
+ </legend>
77
+ <DateInput {...args} mode={DateMode.MONTH_YEAR} />
78
+ </fieldset>
55
79
  </>
56
80
  );
57
81
  },
@@ -28,7 +28,7 @@ describe('DateLookup', () => {
28
28
  </Field>,
29
29
  );
30
30
  // TODO: Replace with `.toHaveAttribute('aria-haspopup')`
31
- expect(screen.getByLabelText(/Date of birth/)).toHaveTextContent(
31
+ expect(screen.getByLabelText('Date of birth')).toHaveTextContent(
32
32
  initialValue.getFullYear().toString(),
33
33
  );
34
34
  });
@@ -4,10 +4,18 @@
4
4
  white-space: nowrap;
5
5
  width: 100%;
6
6
  }
7
+ .np-date-trigger .control-label {
8
+ font-weight: 400;
9
+ font-weight: var(--font-weight-regular);
10
+ }
7
11
  .np-theme-personal .np-date-trigger {
8
12
  padding-left: 16px;
9
13
  padding-left: var(--size-16);
10
14
  }
15
+ .np-theme-personal .np-date-trigger .control-label + span {
16
+ font-weight: 400;
17
+ font-weight: var(--font-weight-regular);
18
+ }
11
19
  .clear-btn {
12
20
  transition: color 0.15s ease-in-out;
13
21
  color: #c9cbce;
@@ -7,8 +7,16 @@
7
7
  white-space: nowrap;
8
8
  width: 100%;
9
9
 
10
+ .control-label {
11
+ font-weight: var(--font-weight-regular);
12
+ }
13
+
10
14
  .np-theme-personal & {
11
15
  padding-left: var(--size-16);
16
+
17
+ .control-label + span {
18
+ font-weight: var(--font-weight-regular);
19
+ }
12
20
  }
13
21
  }
14
22
 
@@ -119,5 +119,5 @@ describe('DateTrigger', () => {
119
119
  const button = () => component.find('.np-date-trigger');
120
120
  const clearButton = () => component.find('.clear-btn');
121
121
  const chevron = () => component.find(Chevron);
122
- const label = () => component.find('.np-date-trigger-label');
122
+ const label = () => component.find('.control-label');
123
123
  });
@@ -2,13 +2,12 @@ import { formatDate } from '@transferwise/formatting';
2
2
  import { useIntl } from 'react-intl';
3
3
 
4
4
  import Chevron from '../../chevron';
5
- import { Size, Position, SizeSmall, SizeMedium, SizeLarge, Typography } from '../../common';
5
+ import { Size, Position, SizeSmall, SizeMedium, SizeLarge } from '../../common';
6
6
  import { CloseButton } from '../../common/closeButton/CloseButton';
7
7
 
8
8
  import messages from './DateTrigger.messages';
9
9
  import { useContext } from 'react';
10
10
  import { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';
11
- import Body from '../../body';
12
11
 
13
12
  interface DateTriggerProps {
14
13
  selectedDate: Date | null;
@@ -46,19 +45,15 @@ const DateTrigger: React.FC<DateTriggerProps> = ({
46
45
  type="button"
47
46
  onClick={onClick}
48
47
  >
49
- {label && (
50
- <Body as="span" className="np-date-trigger-label m-r-1">
51
- {label}
52
- </Body>
53
- )}
48
+ {label && <span className="control-label small m-r-1">{label}</span>}
54
49
  {selectedDate ? (
55
- <Body as="span" type={Typography.BODY_LARGE}>
50
+ <span className="font-weight-normal">
56
51
  {formatDate(selectedDate, locale, {
57
52
  day: 'numeric',
58
53
  month: monthFormat,
59
54
  year: 'numeric',
60
55
  })}
61
- </Body>
56
+ </span>
62
57
  ) : (
63
58
  <span
64
59
  className="form-control-placeholder visible-xs-inline visible-sm-inline
@@ -14,7 +14,7 @@ describe('Field', () => {
14
14
  </Field>,
15
15
  );
16
16
 
17
- expect(screen.getByLabelText(/Phone number/)).toBeInTheDocument();
17
+ expect(screen.getByLabelText('Phone number')).toBeInTheDocument();
18
18
  expect(screen.getByRole('textbox')).not.toHaveAttribute('aria-describedby');
19
19
  });
20
20
 
@@ -25,7 +25,7 @@ describe('Field', () => {
25
25
  </Field>,
26
26
  );
27
27
 
28
- const textbox = screen.getByText('This is help text');
28
+ const textbox = screen.getByRole('textbox', { description: 'This is help text' });
29
29
  expect(textbox).toBeInTheDocument();
30
30
  expect(textbox).not.toBeInvalid();
31
31
  });
@@ -50,7 +50,7 @@ describe('Field', () => {
50
50
  );
51
51
 
52
52
  expect(screen.getByRole('textbox', { description: 'This is error text' })).toBeInTheDocument();
53
- expect(screen.getByText('This is help text')).toBeInTheDocument();
53
+ expect(screen.queryByText('This is help text')).not.toBeInTheDocument();
54
54
  });
55
55
 
56
56
  it('avoids triggering button within label inadvertently', async () => {
@@ -1,15 +1,8 @@
1
- /* eslint-disable jsx-a11y/label-has-associated-control */
2
1
  import { useState } from 'react';
3
2
 
4
3
  import { Input } from '../inputs/Input';
5
4
  import { Field } from './Field';
6
5
  import { Sentiment } from '../common';
7
- import DateInput from '../dateInput';
8
- import { fn } from '@storybook/test';
9
- import { lorem10, lorem100, lorem40 } from '../test-utils';
10
- import { TextArea } from '../inputs/TextArea';
11
- import { SearchInput } from '../inputs/SearchInput';
12
- import Info from '../info';
13
6
 
14
7
  export default {
15
8
  component: Field,
@@ -20,51 +13,9 @@ export default {
20
13
  export const Basic = () => {
21
14
  const [value, setValue] = useState<string | undefined>('This is some text');
22
15
  return (
23
- <div className="row">
24
- <div className="col-md-8 col-md-offset-2">
25
- <Field label="Phone number" required>
26
- <Input value={value} onChange={({ target }) => setValue(target.value)} />
27
- </Field>
28
- <Field label="Phone number">
29
- <Input value={value} onChange={({ target }) => setValue(target.value)} />
30
- </Field>
31
- <Field label="Phone number" description="Please provide you primary phone number">
32
- <Input value={value} onChange={({ target }) => setValue(target.value)} />
33
- </Field>
34
-
35
- <Field label="Date Of Birth">
36
- <DateInput onChange={fn} />
37
- </Field>
38
-
39
- <Field label="Date Of Birth" description={lorem10}>
40
- <DateInput onChange={fn} />
41
- </Field>
42
-
43
- <Field label="Search business">
44
- <SearchInput />
45
- </Field>
46
-
47
- <Field label="Date Of Birth">
48
- <TextArea />
49
- </Field>
50
-
51
- <Field label="Date Of Birth" message={lorem10} sentiment="negative">
52
- <TextArea />
53
- </Field>
54
-
55
- <Field
56
- label={
57
- <>
58
- Date Of Birth <Info content={lorem40} />
59
- </>
60
- }
61
- message={lorem10}
62
- sentiment="negative"
63
- >
64
- <TextArea />
65
- </Field>
66
- </div>
67
- </div>
16
+ <Field label="Phone number">
17
+ <Input value={value} onChange={({ target }) => setValue(target.value)} />
18
+ </Field>
68
19
  );
69
20
  };
70
21
 
@@ -81,35 +32,6 @@ export const WithStatusMessages = () => {
81
32
  <Field label="Phone number" sentiment={Sentiment.NEGATIVE} message="This is a required field">
82
33
  <Input value={value} onChange={({ target }) => setValue(target.value)} />
83
34
  </Field>
84
-
85
- {/* instance with deprecated `hint` prop */}
86
- <Field
87
- label="Phone number"
88
- hint="This is a helpful message"
89
- sentiment={Sentiment.NEGATIVE}
90
- message="Validation error, please take a look"
91
- >
92
- <Input value={value} onChange={({ target }) => setValue(target.value)} />
93
- </Field>
94
- {/* instance with deprecated `error` & `hint` props */}
95
- <Field
96
- label="Phone number"
97
- hint="This is a helpful message"
98
- error="Validation error, please take a look"
99
- >
100
- <Input value={value} onChange={({ target }) => setValue(target.value)} />
101
- </Field>
102
-
103
- <Field
104
- label="Phone number"
105
- description="This is a helpful message"
106
- sentiment={Sentiment.NEGATIVE}
107
- message="Validation error, please take a look"
108
- >
109
- <Input value={value} onChange={({ target }) => setValue(target.value)} />
110
- </Field>
111
-
112
- {/* instance of info via `message` property, this is rare case (e.g MoneyInput) */}
113
35
  <Field label="Phone number" message="This is a helpful message">
114
36
  <Input value={value} onChange={({ target }) => setValue(target.value)} />
115
37
  </Field>
@@ -0,0 +1,33 @@
1
+ import { useState } from 'react';
2
+
3
+ import { Input } from '../inputs/Input';
4
+ import { Field } from './Field';
5
+ import { Sentiment } from '../common';
6
+
7
+ export default {
8
+ component: Field,
9
+ title: 'Field/Tests',
10
+ };
11
+
12
+ export const WithHelpAndErrorOnBlur = () => {
13
+ const [value, setValue] = useState('This is some text');
14
+ const [error, setError] = useState<string | undefined>(undefined);
15
+ return (
16
+ <Field
17
+ label="Phone number"
18
+ sentiment={error ? Sentiment.NEGATIVE : Sentiment.NEUTRAL}
19
+ message={error || 'Please include country code'}
20
+ >
21
+ <Input
22
+ value={value}
23
+ onChange={({ target }) => {
24
+ setValue(target.value);
25
+ setError(undefined);
26
+ }}
27
+ onBlur={() => {
28
+ setError('Something went wrong');
29
+ }}
30
+ />
31
+ </Field>
32
+ );
33
+ };
@@ -9,18 +9,16 @@ import {
9
9
  InputIdContextProvider,
10
10
  InputInvalidProvider,
11
11
  } from '../inputs/contexts';
12
- import { Label } from '../label';
12
+ import { Label } from '../label/Label';
13
13
 
14
14
  export type FieldProps = {
15
15
  /** `null` disables auto-generating the `id` attribute, falling back to nesting-based label association over setting `htmlFor` explicitly. */
16
16
  id?: string | null;
17
17
  /** Should be specified unless the wrapped control has its own labeling mechanism, e.g. `Checkbox`. */
18
18
  label?: React.ReactNode;
19
- required?: boolean;
20
- /** @deprecated use `description` prop instead */
19
+ /** @deprecated use `message` and `type={Sentiment.NEUTRAL}` prop instead */
21
20
  hint?: React.ReactNode;
22
21
  message?: React.ReactNode;
23
- description?: React.ReactNode;
24
22
  /** @deprecated use `message` and `type={Sentiment.NEGATIVE}` prop instead */
25
23
  error?: React.ReactNode;
26
24
  sentiment?: `${Sentiment.NEGATIVE | Sentiment.NEUTRAL | Sentiment.POSITIVE | Sentiment.WARNING}`;
@@ -31,17 +29,14 @@ export type FieldProps = {
31
29
  export const Field = ({
32
30
  id,
33
31
  label,
34
- required = false,
35
32
  message: propMessage,
36
- hint,
37
- description = hint,
38
33
  sentiment: propType = Sentiment.NEUTRAL,
39
34
  className,
40
35
  children,
41
36
  ...props
42
37
  }: FieldProps) => {
43
38
  const sentiment = props.error ? Sentiment.NEGATIVE : propType;
44
- const message = propMessage || props.error;
39
+ const message = props.error || props.hint || propMessage;
45
40
  const hasError = sentiment === Sentiment.NEGATIVE;
46
41
 
47
42
  const labelId = useId();
@@ -70,8 +65,7 @@ export const Field = ({
70
65
  >
71
66
  {label != null ? (
72
67
  <Label id={labelId} htmlFor={inputId}>
73
- {required ? label : <Label.Optional>{label}</Label.Optional>}
74
- {description && <Label.Description>{description}</Label.Description>}
68
+ {label}
75
69
  {children}
76
70
  </Label>
77
71
  ) : (
package/src/i18n/en.json CHANGED
@@ -18,7 +18,6 @@
18
18
  "neptune.DateLookup.year": "year",
19
19
  "neptune.FlowNavigation.back": "back to previous step",
20
20
  "neptune.Info.ariaLabel": "More information",
21
- "neptune.Label.optional": "(Optional)",
22
21
  "neptune.Link.opensInNewTab": "(opens in new tab)",
23
22
  "neptune.MoneyInput.Select.placeholder": "Select an option...",
24
23
  "neptune.PhoneNumberInput.SelectInput.placeholder": "Select an option...",
@@ -56,6 +55,5 @@
56
55
  "neptune.UploadItem.uploaded": "Uploaded",
57
56
  "neptune.UploadItem.uploadedFile": "Uploaded file",
58
57
  "neptune.UploadItem.uploading": "Uploading...",
59
- "neptune.UploadItem.uploadingFailed": "Uploading failed",
60
- "neptune.aria.Label.optional": "This field is optional"
58
+ "neptune.UploadItem.uploadingFailed": "Uploading failed"
61
59
  }
package/src/index.ts CHANGED
@@ -44,7 +44,7 @@ export type {
44
44
  } from './inputs/SelectInput';
45
45
  export type { TextAreaProps } from './inputs/TextArea';
46
46
  export type { InstructionsListProps } from './instructionsList';
47
- export type { LabelProps, LabelOptionalProps, LabelDescriptionProps } from './label/Label';
47
+ export type { LabelProps } from './label/Label';
48
48
  export type { LoaderProps } from './loader';
49
49
  export type { MarkdownProps } from './markdown';
50
50
  export type { ModalProps } from './modal';
@@ -5,8 +5,6 @@ import { Sentiment } from '../common';
5
5
  import { Input } from '../inputs/Input';
6
6
 
7
7
  import InlineAlert, { InlineAlertProps } from './InlineAlert';
8
- import { Label } from '../label';
9
- import { lorem40 } from '../test-utils';
10
8
 
11
9
  export default {
12
10
  component: InlineAlert,
@@ -68,26 +66,41 @@ export const Basic = () => {
68
66
  this manually.
69
67
  </p>
70
68
  <div className={`form-group ${typeClass}`}>
71
- <Label htmlFor="id0">Toggleable</Label>
69
+ <label className="control-label" htmlFor="id0">
70
+ Toggleable
71
+ </label>
72
72
  <Input id="id0" value="Neptune is cool" />
73
73
  <InlineAlert type={type}>{message}</InlineAlert>
74
74
  </div>
75
75
  <div className="form-group has-error">
76
- <Label htmlFor="id1">Negative</Label>
76
+ <label className="control-label" htmlFor="id1">
77
+ Negative
78
+ </label>
77
79
  <Input id="id1" value="Neptune is cool" />
78
80
  <InlineAlert type="negative">{message}</InlineAlert>
79
81
  </div>
80
82
  <div className="form-group has-success">
81
- <Label htmlFor="id2">Positive</Label>
83
+ <label className="control-label" htmlFor="id2">
84
+ Positive
85
+ </label>
82
86
  <Input id="id2" value="Neptune is cool" />
83
- <InlineAlert type="positive">{lorem40}</InlineAlert>
87
+ <InlineAlert type="positive">
88
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
89
+ ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation
90
+ ullamco laboris nisi ut aliquip ex ea commodo consequat.
91
+ </InlineAlert>
84
92
  </div>
85
93
  <div className="form-group has-neutral">
86
- <Label htmlFor="id3">Neutral</Label>
94
+ <label className="control-label" htmlFor="id3">
95
+ Neutral
96
+ </label>
87
97
  <Input id="id3" value="Neptune is cool" />
98
+ <InlineAlert type="neutral">{message}</InlineAlert>
88
99
  </div>
89
100
  <div className="form-group">
90
- <label htmlFor="id4">No has-* class</label>
101
+ <label className="control-label" htmlFor="id4">
102
+ No has-* class
103
+ </label>
91
104
  <Input id="id4" value="Neptune is cool" />
92
105
  <InlineAlert type="negative">{message}</InlineAlert>
93
106
  </div>
@@ -26,6 +26,6 @@ describe('InputGroup', () => {
26
26
  </InputGroup>
27
27
  </Field>,
28
28
  );
29
- expect(screen.getByLabelText(/Search…/)).toHaveRole('textbox');
29
+ expect(screen.getByLabelText('Search…')).toHaveRole('textbox');
30
30
  });
31
31
  });
@@ -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
  });
@@ -206,6 +206,10 @@
206
206
  height: auto;
207
207
  }
208
208
  }
209
+ .np-select-input-listbox-container--virtualized {
210
+ /* The wrapping element shrinks this as needed */
211
+ height: 100vh;
212
+ }
209
213
  .np-select-input-listbox-container--has-group {
210
214
  scroll-padding-top: 32px;
211
215
  scroll-padding-top: var(--size-32);
@@ -224,6 +228,12 @@
224
228
  outline: var(--ring-outline-color) solid var(--ring-outline-width);
225
229
  outline-offset: var(--ring-outline-offset);
226
230
  }
231
+ .np-select-input-listbox-container--virtualized .np-select-input-listbox {
232
+ /* Adopted from `VList` in virtua: https://github.com/inokawa/virtua/blob/7f6ed5b37df6b480d4ff350f3960067c5b3519d2/src/react/VList.tsx#L113-L116 */
233
+ overflow-y: auto;
234
+ contain: strict;
235
+ height: 100%;
236
+ }
227
237
  .np-select-input-separator-item {
228
238
  margin: 8px;
229
239
  margin: var(--size-8);
@@ -60,6 +60,11 @@
60
60
  }
61
61
  }
62
62
 
63
+ &--virtualized {
64
+ /* The wrapping element shrinks this as needed */
65
+ height: 100vh;
66
+ }
67
+
63
68
  &--has-group {
64
69
  scroll-padding-top: var(--size-32);
65
70
  }
@@ -71,6 +76,13 @@
71
76
 
72
77
  .focus-ring();
73
78
  --ring-outline-offset: calc(-1 * var(--ring-outline-width));
79
+
80
+ .np-select-input-listbox-container--virtualized & {
81
+ /* Adopted from `VList` in virtua: https://github.com/inokawa/virtua/blob/7f6ed5b37df6b480d4ff350f3960067c5b3519d2/src/react/VList.tsx#L113-L116 */
82
+ overflow-y: auto;
83
+ contain: strict;
84
+ height: 100%;
85
+ }
74
86
  }
75
87
 
76
88
  .np-select-input-separator-item {
@@ -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
  });
@@ -322,6 +322,26 @@ export const Advanced: Story<Month> = {
322
322
  },
323
323
  };
324
324
 
325
+ export const ManyItems: Story<string, true> = {
326
+ args: {
327
+ multiple: true,
328
+ items: Array.from({ length: 1000 }, (_, index) => ({
329
+ type: 'option',
330
+ value: String(index + 1),
331
+ })),
332
+ renderValue: (value, withinTrigger) =>
333
+ withinTrigger ? (
334
+ value
335
+ ) : (
336
+ <SelectInputOptionContent
337
+ title={value}
338
+ description={Number(value) % 10 === 0 ? 'Divisible by 10' : undefined}
339
+ />
340
+ ),
341
+ filterable: true,
342
+ },
343
+ };
344
+
325
345
  export const WithinDrawer: Story<Currency> = {
326
346
  args: CurrenciesArgs,
327
347
  decorators: [