@kaizen/components 1.79.10 → 1.80.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 (36) hide show
  1. package/dist/cjs/src/Filter/FilterMultiSelect/FilterMultiSelect.cjs +11 -4
  2. package/dist/cjs/src/Filter/FilterMultiSelect/subcomponents/ListBox/ListBox.cjs +1 -1
  3. package/dist/cjs/src/Filter/FilterMultiSelect/subcomponents/ListBox/ListBox.module.css.cjs +9 -0
  4. package/dist/cjs/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/MenuPopup.cjs +1 -1
  5. package/dist/cjs/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/{MenuPopup.module.scss.cjs → MenuPopup.module.css.cjs} +1 -1
  6. package/dist/cjs/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/ResponsiveMenuPopup.cjs +91 -0
  7. package/dist/esm/src/Filter/FilterMultiSelect/FilterMultiSelect.mjs +12 -5
  8. package/dist/esm/src/Filter/FilterMultiSelect/subcomponents/ListBox/ListBox.mjs +1 -1
  9. package/dist/esm/src/Filter/FilterMultiSelect/subcomponents/ListBox/ListBox.module.css.mjs +7 -0
  10. package/dist/esm/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/MenuPopup.mjs +1 -1
  11. package/dist/esm/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/MenuPopup.module.css.mjs +4 -0
  12. package/dist/esm/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/ResponsiveMenuPopup.mjs +85 -0
  13. package/dist/styles.css +9098 -9089
  14. package/dist/types/Filter/FilterMultiSelect/FilterMultiSelect.d.ts +7 -1
  15. package/dist/types/Filter/FilterMultiSelect/_docs/MockData.d.ts +1 -0
  16. package/dist/types/Filter/FilterMultiSelect/subcomponents/MenuPopup/ResponsiveMenuPopup.d.ts +22 -0
  17. package/dist/types/Filter/FilterMultiSelect/subcomponents/MenuPopup/index.d.ts +1 -0
  18. package/package.json +36 -36
  19. package/src/Filter/FilterBar/subcomponents/FilterBarMultiSelect/FilterBarMultiSelect.spec.tsx +1 -0
  20. package/src/Filter/FilterMultiSelect/FilterMultiSelect.tsx +10 -4
  21. package/src/Filter/FilterMultiSelect/_docs/FilterMultiSelect.mdx +9 -1
  22. package/src/Filter/FilterMultiSelect/_docs/FilterMultiSelect.stories.tsx +113 -2
  23. package/src/Filter/FilterMultiSelect/_docs/MockData.ts +39 -0
  24. package/src/Filter/FilterMultiSelect/context/MenuTriggerProvider/MenuTriggerProvider.spec.tsx +2 -18
  25. package/src/Filter/FilterMultiSelect/subcomponents/ListBox/ListBox.module.css +22 -0
  26. package/src/Filter/FilterMultiSelect/subcomponents/ListBox/ListBox.tsx +1 -1
  27. package/src/Filter/FilterMultiSelect/subcomponents/ListBoxSection/ListBoxSection.module.scss +1 -0
  28. package/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/MenuPopup.module.css +23 -0
  29. package/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/MenuPopup.tsx +1 -1
  30. package/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/ResponsiveMenuPopup.tsx +115 -0
  31. package/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/index.ts +1 -0
  32. package/dist/cjs/src/Filter/FilterMultiSelect/subcomponents/ListBox/ListBox.module.scss.cjs +0 -9
  33. package/dist/esm/src/Filter/FilterMultiSelect/subcomponents/ListBox/ListBox.module.scss.mjs +0 -7
  34. package/dist/esm/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/MenuPopup.module.scss.mjs +0 -4
  35. package/src/Filter/FilterMultiSelect/subcomponents/ListBox/ListBox.module.scss +0 -25
  36. package/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/MenuPopup.module.scss +0 -24
@@ -15,11 +15,13 @@ type SelectionProps = {
15
15
  export type FilterMultiSelectProps = {
16
16
  trigger: (value?: MenuTriggerProviderContextType) => React.ReactNode;
17
17
  children: (value?: SelectionProviderContextType) => React.ReactNode;
18
+ /** Replaces the MenuPopup. Should only be used for changing how the floating element is positioned, ie: with the `<ResponsiveMenuPopup />` primitive. */
19
+ customMenuPopup?: React.ComponentType<MenuPopupProps>;
18
20
  triggerRef?: React.RefObject<HTMLButtonElement>;
19
21
  className?: string;
20
22
  } & Omit<MenuPopupProps, 'children'> & Omit<MenuTriggerProviderProps, 'children'> & SelectionProps;
21
23
  export declare const FilterMultiSelect: {
22
- ({ trigger, children, isOpen, defaultOpen, onOpenChange, isLoading, loadingSkeleton, label, items, selectedKeys, defaultSelectedKeys, onSelectionChange, selectionMode, onSearchInputChange, triggerRef, className, }: FilterMultiSelectProps): JSX.Element;
24
+ ({ trigger, children, customMenuPopup, isOpen, defaultOpen, onOpenChange, isLoading, loadingSkeleton, label, items, selectedKeys, defaultSelectedKeys, onSelectionChange, selectionMode, onSearchInputChange, triggerRef, className, ...restProps }: FilterMultiSelectProps): JSX.Element;
23
25
  displayName: string;
24
26
  TriggerButton: {
25
27
  ({ selectedOptionLabels, label, classNameOverride, labelCharacterLimitBeforeTruncate, }: import("./subcomponents/Trigger").FilterTriggerButtonProps): JSX.Element;
@@ -70,5 +72,9 @@ export declare const FilterMultiSelect: {
70
72
  ({ children, ...restProps }: import("./subcomponents/NoResults").NoResultsProps): JSX.Element;
71
73
  displayName: string;
72
74
  };
75
+ ResponsiveMenuPopup: {
76
+ ({ children, floatingConfig, classNameOverride, isLoading, loadingSkeleton, ...restProps }: import("./subcomponents/MenuPopup").ResponsiveMenuPopupProps): JSX.Element;
77
+ displayName: string;
78
+ };
73
79
  };
74
80
  export {};
@@ -8,3 +8,4 @@ export declare const locationDemographicValues: {
8
8
  demographicValueId: string;
9
9
  label: string;
10
10
  }[];
11
+ export declare const mockManyItems: ItemType[];
@@ -0,0 +1,22 @@
1
+ import { type HTMLAttributes } from 'react';
2
+ import { type UseFloatingOptions } from '@floating-ui/react-dom';
3
+ import { type OverrideClassName } from "../../../../types/OverrideClassName";
4
+ import { type MenuPopupProps } from './MenuPopup';
5
+ export type FloatingConfig = Pick<UseFloatingOptions, 'placement' | 'strategy' | 'whileElementsMounted'> & {
6
+ /** Whether the component should automatically resize based on the available window height.
7
+ * @default true
8
+ */
9
+ shouldResize?: boolean;
10
+ /** Whether the component should automatically flip to the top of the input based on the available window height.
11
+ * @default true
12
+ */
13
+ shouldFlip?: boolean;
14
+ };
15
+ export type ResponsiveMenuPopupProps = MenuPopupProps & {
16
+ floatingConfig?: FloatingConfig;
17
+ } & OverrideClassName<HTMLAttributes<HTMLDivElement>>;
18
+ /** This is a popup primitive that can be used with the FilterMultiSelect when there are overflow issues with the original implementation. This uses the floating-ui */
19
+ export declare const ResponsiveMenuPopup: {
20
+ ({ children, floatingConfig, classNameOverride, isLoading, loadingSkeleton, ...restProps }: ResponsiveMenuPopupProps): JSX.Element;
21
+ displayName: string;
22
+ };
@@ -1 +1,2 @@
1
1
  export * from './MenuPopup';
2
+ export * from './ResponsiveMenuPopup';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaizen/components",
3
- "version": "1.79.10",
3
+ "version": "1.80.1",
4
4
  "description": "Kaizen component library",
5
5
  "author": "Geoffrey Chong <geoff.chong@cultureamp.com>",
6
6
  "homepage": "https://cultureamp.design",
@@ -102,26 +102,26 @@
102
102
  "kaizen-codemod": "./bin/codemod.sh"
103
103
  },
104
104
  "dependencies": {
105
- "@floating-ui/react-dom": "^2.1.2",
106
- "@headlessui/react": "^2.2.4",
107
- "@internationalized/date": "^3.8.1",
105
+ "@floating-ui/react-dom": "^2.1.4",
106
+ "@headlessui/react": "^2.2.6",
107
+ "@internationalized/date": "^3.8.2",
108
108
  "@popperjs/core": "^2.11.8",
109
109
  "@reach/tabs": "^0.18.0",
110
- "@react-aria/button": "^3.13.1",
111
- "@react-aria/datepicker": "^3.14.3",
112
- "@react-aria/focus": "^3.20.3",
113
- "@react-aria/i18n": "^3.12.9",
114
- "@react-aria/listbox": "^3.14.4",
115
- "@react-aria/menu": "^3.18.3",
116
- "@react-aria/overlays": "^3.27.1",
117
- "@react-aria/select": "^3.15.5",
118
- "@react-aria/utils": "^3.29.0",
119
- "@react-stately/collections": "^3.12.4",
120
- "@react-stately/datepicker": "^3.14.1",
121
- "@react-stately/list": "^3.12.2",
122
- "@react-stately/menu": "^3.9.4",
123
- "@react-stately/select": "^3.6.13",
124
- "@react-types/shared": "^3.29.1",
110
+ "@react-aria/button": "^3.13.3",
111
+ "@react-aria/datepicker": "^3.14.5",
112
+ "@react-aria/focus": "^3.20.5",
113
+ "@react-aria/i18n": "^3.12.10",
114
+ "@react-aria/listbox": "^3.14.6",
115
+ "@react-aria/menu": "^3.18.5",
116
+ "@react-aria/overlays": "^3.27.3",
117
+ "@react-aria/select": "^3.15.7",
118
+ "@react-aria/utils": "^3.29.1",
119
+ "@react-stately/collections": "^3.12.5",
120
+ "@react-stately/datepicker": "^3.14.2",
121
+ "@react-stately/list": "^3.12.3",
122
+ "@react-stately/menu": "^3.9.5",
123
+ "@react-stately/select": "^3.6.14",
124
+ "@react-types/shared": "^3.30.0",
125
125
  "classnames": "^2.5.1",
126
126
  "date-fns": "^4.1.0",
127
127
  "lodash.debounce": "^4.0.8",
@@ -130,24 +130,24 @@
130
130
  "prosemirror-history": "^1.4.1",
131
131
  "prosemirror-inputrules": "^1.5.0",
132
132
  "prosemirror-keymap": "^1.2.3",
133
- "prosemirror-model": "^1.25.1",
133
+ "prosemirror-model": "^1.25.2",
134
134
  "prosemirror-schema-basic": "^1.2.4",
135
135
  "prosemirror-schema-list": "^1.5.1",
136
136
  "prosemirror-state": "^1.4.3",
137
137
  "prosemirror-transform": "^1.10.4",
138
138
  "prosemirror-utils": "^1.2.2",
139
- "prosemirror-view": "^1.39.3",
139
+ "prosemirror-view": "^1.40.1",
140
140
  "react-animate-height": "^3.2.3",
141
- "react-aria": "^3.40.0",
142
- "react-aria-components": "^1.9.0",
141
+ "react-aria": "^3.41.1",
142
+ "react-aria-components": "^1.10.1",
143
143
  "react-day-picker": "9.6.7",
144
144
  "react-focus-lock": "^2.13.6",
145
- "react-focus-on": "^3.9.4",
145
+ "react-focus-on": "^3.10.0",
146
146
  "react-popper": "^2.3.0",
147
- "react-select": "^5.10.1",
147
+ "react-select": "^5.10.2",
148
148
  "react-textfit": "^1.1.1",
149
149
  "resize-observer-polyfill": "^1.5.1",
150
- "use-debounce": "^10.0.4",
150
+ "use-debounce": "^10.0.5",
151
151
  "uuid": "^11.1.0"
152
152
  },
153
153
  "dependenciesComments": {
@@ -155,9 +155,9 @@
155
155
  },
156
156
  "devDependencies": {
157
157
  "@cultureamp/frontend-apis": "13.3.0",
158
- "@cultureamp/i18n-react-intl": "^2.9.1",
158
+ "@cultureamp/i18n-react-intl": "^2.12.2",
159
159
  "@cultureamp/package-bundler": "^2.3.2",
160
- "@testing-library/dom": "^10.4.0",
160
+ "@testing-library/dom": "^10.4.1",
161
161
  "@types/jest-axe": "^3.5.9",
162
162
  "@types/lodash.debounce": "^4.0.9",
163
163
  "@types/react-highlight": "^0.12.8",
@@ -169,23 +169,23 @@
169
169
  "jest-axe": "^10.0.0",
170
170
  "lodash.isempty": "^4.4.0",
171
171
  "normalize.css": "^8.0.1",
172
- "postcss": "^8.5.3",
172
+ "postcss": "^8.5.6",
173
173
  "postcss-cli": "^11.0.1",
174
- "postcss-import": "^16.1.0",
175
- "postcss-preset-env": "^10.1.6",
174
+ "postcss-import": "^16.1.1",
175
+ "postcss-preset-env": "^10.2.4",
176
176
  "postcss-scss": "^4.0.9",
177
- "query-string": "^9.2.0",
178
- "react": "^19.0.0",
179
- "react-dom": "^19.0.0",
177
+ "query-string": "^9.2.2",
178
+ "react": "^19.1.0",
179
+ "react-dom": "^19.1.0",
180
180
  "react-highlight": "^0.15.0",
181
181
  "react-intl": "^7.1.11",
182
- "rollup": "^4.40.2",
182
+ "rollup": "^4.46.1",
183
183
  "sass": "1.79.6",
184
184
  "serialize-query-params": "^2.0.2",
185
185
  "svgo": "^3.3.2",
186
186
  "tslib": "^2.8.1",
187
187
  "ts-patch": "^3.3.0",
188
- "tsx": "^4.19.4",
188
+ "tsx": "^4.20.3",
189
189
  "@kaizen/design-tokens": "10.10.0"
190
190
  },
191
191
  "devDependenciesComments": {
@@ -180,6 +180,7 @@ describe('<FilterBarMultiSelect />', () => {
180
180
  })
181
181
 
182
182
  await user.click(getByRole('option', { name: 'Fruit Jelly' }))
183
+ await user.keyboard('{Escape}')
183
184
  await waitFor(() => {
184
185
  expect(getByRole('button', { name: 'Toppings : Pearls, Fruit Jelly' })).toBeInTheDocument()
185
186
  })
@@ -13,7 +13,7 @@ import { ListBox } from './subcomponents/ListBox'
13
13
  import { ListBoxSection } from './subcomponents/ListBoxSection'
14
14
  import { LoadMoreButton } from './subcomponents/LoadMoreButton'
15
15
  import { MenuFooter, MenuLoadingSkeleton } from './subcomponents/MenuLayout'
16
- import { MenuPopup, type MenuPopupProps } from './subcomponents/MenuPopup'
16
+ import { MenuPopup, ResponsiveMenuPopup, type MenuPopupProps } from './subcomponents/MenuPopup'
17
17
  import { MultiSelectOption } from './subcomponents/MultiSelectOption'
18
18
  import { NoResults } from './subcomponents/NoResults'
19
19
  import { SearchInput } from './subcomponents/SearchInput'
@@ -35,6 +35,8 @@ type SelectionProps = {
35
35
  export type FilterMultiSelectProps = {
36
36
  trigger: (value?: MenuTriggerProviderContextType) => React.ReactNode
37
37
  children: (value?: SelectionProviderContextType) => React.ReactNode // the content of the menu
38
+ /** Replaces the MenuPopup. Should only be used for changing how the floating element is positioned, ie: with the `<ResponsiveMenuPopup />` primitive. */
39
+ customMenuPopup?: React.ComponentType<MenuPopupProps>
38
40
  triggerRef?: React.RefObject<HTMLButtonElement>
39
41
  className?: string
40
42
  } & Omit<MenuPopupProps, 'children'> &
@@ -44,6 +46,7 @@ export type FilterMultiSelectProps = {
44
46
  export const FilterMultiSelect = ({
45
47
  trigger,
46
48
  children,
49
+ customMenuPopup,
47
50
  isOpen,
48
51
  defaultOpen,
49
52
  onOpenChange,
@@ -58,9 +61,11 @@ export const FilterMultiSelect = ({
58
61
  onSearchInputChange,
59
62
  triggerRef,
60
63
  className,
64
+ ...restProps
61
65
  }: FilterMultiSelectProps): JSX.Element => {
66
+ const MenuComponent = customMenuPopup ?? MenuPopup
62
67
  const menuTriggerProps = { isOpen, defaultOpen, onOpenChange, triggerRef }
63
- const menuPopupProps = { isLoading, loadingSkeleton }
68
+ const menuPopupProps = { isLoading, loadingSkeleton, ...restProps }
64
69
  const disabledKeys: Selection = new Set(
65
70
  items?.filter((item) => item.isDisabled === true).map((disabledItem) => disabledItem.value),
66
71
  )
@@ -79,11 +84,11 @@ export const FilterMultiSelect = ({
79
84
  <MenuTriggerProvider {...menuTriggerProps}>
80
85
  <div className={className}>
81
86
  <MenuTriggerConsumer>{trigger}</MenuTriggerConsumer>
82
- <MenuPopup {...menuPopupProps}>
87
+ <MenuComponent aria-label={label} {...menuPopupProps}>
83
88
  <SelectionProvider {...selectionProps}>
84
89
  <SelectionConsumer>{children}</SelectionConsumer>
85
90
  </SelectionProvider>
86
- </MenuPopup>
91
+ </MenuComponent>
87
92
  </div>
88
93
  </MenuTriggerProvider>
89
94
  )
@@ -104,3 +109,4 @@ FilterMultiSelect.MenuFooter = MenuFooter // For layout
104
109
  FilterMultiSelect.MenuLoadingSkeleton = MenuLoadingSkeleton // Menu Loading Skeleton example
105
110
  FilterMultiSelect.LoadMoreButton = LoadMoreButton
106
111
  FilterMultiSelect.NoResults = NoResults
112
+ FilterMultiSelect.ResponsiveMenuPopup = ResponsiveMenuPopup
@@ -1,4 +1,4 @@
1
- import { Controls, Meta, Canvas } from '@storybook/blocks'
1
+ import { Controls, Meta, Canvas, DocsStory } from '@storybook/blocks'
2
2
  import { ResourceLinks, KAIOInstallation, NoClipCanvas } from '~storybook/components'
3
3
  import * as FilterMultiSelectStories from './FilterMultiSelect.stories'
4
4
 
@@ -30,6 +30,14 @@ The FilterMultiSelect is a component relies heavily on consumer implemntation. I
30
30
 
31
31
  <Canvas of={FilterMultiSelectStories.WithSectionHeaders} />
32
32
 
33
+ ### With customMenuPopup component
34
+
35
+ You can replace the `MenuPopup` component within the FilterMultiSelect to allow flexibility in how the popup's placement is determined. While the default behavior should satisfy most scenarios, this can be used when there is limited vertical space available in the viewport.
36
+
37
+ <Canvas of={FilterMultiSelectStories.AboveIfAvailable} />
38
+
39
+ For convenience, a primitive called `ResponsiveMenuPopup` that can be accessed via dot notation that will automatically adjust the placement and size of the popup based on the available window height. This implementation uses `floating-ui` and the [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API) instead of `react-aria` hooks. It also locks scroll when the popup is active.
40
+
33
41
  ### Async
34
42
 
35
43
  The following is an example of how you may create an async FilterMultiSelect using `@tanstack/react-query`.
@@ -1,11 +1,13 @@
1
1
  import React, { useState } from 'react'
2
2
  import type { Selection } from '@react-types/shared'
3
3
  import type { Meta, StoryObj } from '@storybook/react'
4
+ import { expect, userEvent, waitFor, within } from '@storybook/test'
4
5
  import isChromatic from 'chromatic'
6
+ import { Card } from '~components/Card'
5
7
  import { InlineNotification } from '~components/Notification'
6
8
  import { TextField } from '~components/TextField'
7
9
  import { FilterMultiSelect, getSelectedOptionLabels } from '..'
8
- import { mockItems } from './MockData'
10
+ import { mockItems, mockManyItems } from './MockData'
9
11
 
10
12
  const IS_CHROMATIC = isChromatic()
11
13
 
@@ -14,7 +16,7 @@ const meta = {
14
16
  component: FilterMultiSelect,
15
17
  parameters: {
16
18
  docs: {
17
- source: { type: 'code' },
19
+ source: { type: 'auto' },
18
20
  },
19
21
  },
20
22
  args: {
@@ -178,6 +180,7 @@ export const WithSectionHeaders: Story = {
178
180
  ...FilterMultiSelectTemplate,
179
181
  args: {
180
182
  isOpen: IS_CHROMATIC || undefined,
183
+ items: mockManyItems,
181
184
  children: (): JSX.Element => (
182
185
  <>
183
186
  <FilterMultiSelect.SearchInput />
@@ -308,3 +311,111 @@ export const WithSectionNotification: Story = {
308
311
  chromatic: { disable: false },
309
312
  },
310
313
  }
314
+
315
+ const sourceCode = `
316
+ <FilterMultiSelect
317
+ {...filterMultiSelectProps}
318
+ customMenuPopup={(props): JSX.Element => (
319
+ // This will replace the default MenuPopup with a custom one. The rest of the component should still be implemented as the FilterMultiSelect pattern.
320
+ <FilterMultiSelect.ResponsiveMenuPopup {...props} />
321
+ )}
322
+ >
323
+ {/* FilterMultiSelect children */}
324
+ </FilterMultiSelect>
325
+ `
326
+
327
+ export const WithContentBelow: Story = {
328
+ ...FilterMultiSelectTemplate,
329
+ decorators: [
330
+ (Story) => (
331
+ <div>
332
+ <Story />
333
+ <Card classNameOverride="mt-24 p-12" isElevated>
334
+ <p>
335
+ Lorem ipsum dolor, sit amet consectetur adipisicing elit. Veritatis libero dolore
336
+ pariatur enim voluptates aperiam, delectus, harum cum earum quibusdam quos porro
337
+ explicabo quisquam sapiente cupiditate quae hic, minus nam.
338
+ </p>
339
+ </Card>
340
+ </div>
341
+ ),
342
+ ],
343
+ parameters: {
344
+ chromatic: {
345
+ disable: false,
346
+ },
347
+ },
348
+ play: async ({ canvasElement, step }) => {
349
+ const canvas = within(canvasElement.parentElement!)
350
+ const triggerButton = await canvas.findByRole('button', {
351
+ name: /Engineer/i,
352
+ })
353
+ await step('Trigger opens the FilterMultiSelect dialog', async () => {
354
+ await userEvent.click(triggerButton)
355
+ await waitFor(() => expect(canvas.getByRole('option', { name: /Front-End/i })).toBeVisible())
356
+ })
357
+ },
358
+ }
359
+
360
+ export const AboveIfAvailable: Story = {
361
+ ...WithSectionNotification,
362
+ name: 'With customMenuPopup and vertical placement',
363
+ parameters: {
364
+ viewport: {
365
+ viewports: {
366
+ LimitedViewportAutoPlace: {
367
+ name: 'Limited vertical space',
368
+ styles: {
369
+ width: '1024px',
370
+ height: '650px',
371
+ },
372
+ },
373
+ },
374
+ defaultViewport: 'LimitedViewportAutoPlace',
375
+ },
376
+ docs: { source: { code: sourceCode } },
377
+ },
378
+ args: {
379
+ customMenuPopup: (props): JSX.Element => <FilterMultiSelect.ResponsiveMenuPopup {...props} />,
380
+ },
381
+ decorators: [
382
+ (Story) => (
383
+ <div>
384
+ <div style={{ height: '80vh', maxHeight: '500px' }}>Content above</div>
385
+ <Story />
386
+ </div>
387
+ ),
388
+ ],
389
+ }
390
+
391
+ export const ShouldResize: Story = {
392
+ ...AboveIfAvailable,
393
+ name: 'With customMenuPopup, vertical placement and resized popup',
394
+ parameters: {
395
+ chromatic: {
396
+ disable: false,
397
+ },
398
+ viewport: {
399
+ viewports: {
400
+ LimitedViewportAutoPlace: {
401
+ name: 'Limited vertical space',
402
+ styles: {
403
+ width: '1024px',
404
+ height: '450px',
405
+ },
406
+ },
407
+ },
408
+ defaultViewport: 'LimitedViewportAutoPlace',
409
+ },
410
+ },
411
+ play: async ({ canvasElement, step }) => {
412
+ const canvas = within(canvasElement.parentElement!)
413
+ const triggerButton = await canvas.findByRole('button', {
414
+ name: /Engineer/i,
415
+ })
416
+ await step('Trigger opens the FilterMultiSelect dialog', async () => {
417
+ await userEvent.click(triggerButton)
418
+ await waitFor(() => expect(canvas.getByRole('dialog')).toBeVisible())
419
+ })
420
+ },
421
+ }
@@ -58,3 +58,42 @@ export const locationDemographicValues = [
58
58
  label: 'London',
59
59
  },
60
60
  ]
61
+
62
+ export const mockManyItems: ItemType[] = [
63
+ { label: 'Front-End', value: 'id-fe', count: '1245' },
64
+ { label: 'Back-End', value: 'id-be', count: '4', isDisabled: true },
65
+ { label: 'SRE', value: 'id-sre', count: '4', isDisabled: true },
66
+ { label: 'Dev-ops', value: 'id-devops' },
67
+ { label: 'Others', value: 'id-others' },
68
+ {
69
+ label: 'Engineer-type-1 has a really really long label',
70
+ value: 'id-type-1',
71
+ },
72
+ {
73
+ label: 'Engineer-type-2 also has a really really long label',
74
+ value: 'id-type-2',
75
+ count: '156',
76
+ },
77
+ { label: 'Engineer-type-3', value: 'id-type-3' },
78
+ {
79
+ label: 'Engineer-type-4',
80
+ value: 'id-type-4',
81
+ count: '4',
82
+ isDisabled: true,
83
+ },
84
+ { label: 'Engineer-type-5', value: 'id-type-5' },
85
+ { label: 'UI Designer', value: 'id-ui', count: '42' },
86
+ { label: 'UX Researcher', value: 'id-ux', count: '15' },
87
+ { label: 'Product Manager', value: 'id-pm', count: '28' },
88
+ { label: 'Project Manager', value: 'id-project', count: '19', isDisabled: true },
89
+ { label: 'Data Scientist', value: 'id-ds', count: '11' },
90
+ { label: 'Machine Learning Engineer', value: 'id-ml', count: '7' },
91
+ { label: 'QA Tester', value: 'id-qa', count: '22' },
92
+ {
93
+ label: 'Technical Writer with documentation expertise',
94
+ value: 'id-tech-writer',
95
+ count: '5',
96
+ },
97
+ { label: 'DevSecOps Engineer', value: 'id-devsecops', count: '3', isDisabled: true },
98
+ { label: 'Cloud Architect', value: 'id-cloud', count: '8' },
99
+ ]
@@ -1,7 +1,6 @@
1
1
  import React from 'react'
2
2
  import { render, screen, waitFor } from '@testing-library/react'
3
3
  import userEvent from '@testing-library/user-event'
4
- import { vi } from 'vitest'
5
4
  import { FilterTriggerButton } from '~components/Filter/FilterMultiSelect/subcomponents/Trigger'
6
5
  import { MenuPopup } from '../../subcomponents/MenuPopup'
7
6
  import { MenuTriggerProvider, type MenuTriggerProviderProps } from './MenuTriggerProvider'
@@ -53,15 +52,11 @@ describe('<MenuTriggerProvider /> - Visual content', () => {
53
52
  rerender(<MenuTriggerProviderWrapper isOpen={false} />)
54
53
  expect(screen.queryByText('menu-content-mock')).not.toBeInTheDocument()
55
54
  })
56
-
57
- it('fires the onOpenChange callback when the trigger is interacted', async () => {
55
+ it('fires the onOpenChange callback on user interaction to close the menu', async () => {
58
56
  const onOpenChange = vi.fn()
59
57
  render(<MenuTriggerProviderWrapper isOpen onOpenChange={onOpenChange} />)
60
58
 
61
- const trigger = screen.getByRole('button', {
62
- name: 'trigger-display-label-mock',
63
- })
64
- await user.click(trigger)
59
+ await user.keyboard('{Escape}')
65
60
 
66
61
  await waitFor(() => {
67
62
  expect(onOpenChange).toBeCalledTimes(1)
@@ -86,17 +81,6 @@ describe('<MenuTriggerProvider /> - Mouse interaction', () => {
86
81
  })
87
82
 
88
83
  describe('Given the menu is opened', () => {
89
- it('is closed when user clicks on the trigger', async () => {
90
- render(<MenuTriggerProviderWrapper defaultOpen />)
91
- const trigger = screen.getByRole('button', {
92
- name: 'trigger-display-label-mock',
93
- })
94
- await user.click(trigger)
95
- await waitFor(() => {
96
- expect(screen.queryByText('menu-content-mock')).not.toBeInTheDocument()
97
- })
98
- })
99
-
100
84
  it('is closed when user clicks outside of the menu', async () => {
101
85
  render(<MenuTriggerProviderWrapper defaultOpen />)
102
86
  await user.click(document.body)
@@ -0,0 +1,22 @@
1
+ @layer kz-components {
2
+ .listBox {
3
+ list-style: none;
4
+ padding: var(--spacing-12);
5
+ margin: 0 var(--spacing-12) 0 0;
6
+ display: grid;
7
+ max-height: 22rem;
8
+ overflow-y: auto;
9
+ }
10
+
11
+ .overflown {
12
+ padding-right: var(--spacing-12);
13
+ }
14
+
15
+ .hidden {
16
+ display: none;
17
+ }
18
+
19
+ .noResultsWrapper {
20
+ list-style: none;
21
+ }
22
+ }
@@ -3,7 +3,7 @@ import { type Collection, type Key } from '@react-types/shared'
3
3
  import classnames from 'classnames'
4
4
  import { useSelectionContext } from '../../context/SelectionProvider'
5
5
  import { type MultiSelectItem } from '../../types'
6
- import styles from './ListBox.module.scss'
6
+ import styles from './ListBox.module.css'
7
7
 
8
8
  export type ListBoxItems = {
9
9
  selectedItems: MultiSelectItem[]
@@ -10,6 +10,7 @@
10
10
  }
11
11
 
12
12
  .listBoxSectionHeader {
13
+ position: relative; // this is needed to ensure the VisuallyHidden element doesn't impact the scroll height of the list
13
14
  font-family: $typography-heading-6-font-family;
14
15
  font-size: $typography-heading-6-font-size;
15
16
  font-weight: $typography-heading-6-font-weight;
@@ -0,0 +1,23 @@
1
+ @layer kz-components {
2
+ .menuPopup {
3
+ /* from $ca-z-index-dropdown */
4
+ position: absolute;
5
+ z-index: 1000;
6
+ box-sizing: border-box;
7
+ background: var(--color-white);
8
+ color: var(--color-purple-800);
9
+ border-radius: var(--border-solid-border-radius);
10
+ box-shadow: var(--shadow-large-box-shadow);
11
+ padding: var(--spacing-12) 0;
12
+ margin-top: var(--spacing-6);
13
+ text-align: start;
14
+ width: var(--menu-container-width, 294px);
15
+ }
16
+
17
+ .menuPopup[popover]:popover-open {
18
+ max-height: var(--menu-container-height, 500px);
19
+ z-index: unset;
20
+ margin: 0;
21
+ inset: unset;
22
+ }
23
+ }
@@ -2,7 +2,7 @@ import React from 'react'
2
2
  import { FocusScope } from '@react-aria/focus'
3
3
  import { DismissButton, useOverlay } from '@react-aria/overlays'
4
4
  import { useMenuTriggerContext } from '../../context'
5
- import styles from './MenuPopup.module.scss'
5
+ import styles from './MenuPopup.module.css'
6
6
 
7
7
  export type MenuPopupProps = {
8
8
  isLoading?: boolean