@kaizen/components 1.79.9 → 1.80.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.
- package/dist/cjs/src/Avatar/Avatar.cjs +2 -2
- package/dist/cjs/src/Filter/FilterMultiSelect/FilterMultiSelect.cjs +11 -4
- package/dist/cjs/src/Filter/FilterMultiSelect/subcomponents/ListBox/ListBox.cjs +1 -1
- package/dist/cjs/src/Filter/FilterMultiSelect/subcomponents/ListBox/ListBox.module.css.cjs +9 -0
- package/dist/cjs/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/MenuPopup.cjs +1 -1
- package/dist/cjs/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/{MenuPopup.module.scss.cjs → MenuPopup.module.css.cjs} +1 -1
- package/dist/cjs/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/ResponsiveMenuPopup.cjs +91 -0
- package/dist/esm/src/Avatar/Avatar.mjs +2 -2
- package/dist/esm/src/Filter/FilterMultiSelect/FilterMultiSelect.mjs +12 -5
- package/dist/esm/src/Filter/FilterMultiSelect/subcomponents/ListBox/ListBox.mjs +1 -1
- package/dist/esm/src/Filter/FilterMultiSelect/subcomponents/ListBox/ListBox.module.css.mjs +7 -0
- package/dist/esm/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/MenuPopup.mjs +1 -1
- package/dist/esm/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/MenuPopup.module.css.mjs +4 -0
- package/dist/esm/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/ResponsiveMenuPopup.mjs +85 -0
- package/dist/styles.css +9216 -9208
- package/dist/types/Filter/FilterMultiSelect/FilterMultiSelect.d.ts +7 -1
- package/dist/types/Filter/FilterMultiSelect/_docs/MockData.d.ts +1 -0
- package/dist/types/Filter/FilterMultiSelect/subcomponents/MenuPopup/ResponsiveMenuPopup.d.ts +22 -0
- package/dist/types/Filter/FilterMultiSelect/subcomponents/MenuPopup/index.d.ts +1 -0
- package/locales/de.json +17 -17
- package/package.json +1 -1
- package/src/Avatar/Avatar.spec.tsx +1 -0
- package/src/Avatar/Avatar.tsx +2 -2
- package/src/Filter/FilterBar/subcomponents/FilterBarMultiSelect/FilterBarMultiSelect.spec.tsx +1 -0
- package/src/Filter/FilterMultiSelect/FilterMultiSelect.tsx +10 -4
- package/src/Filter/FilterMultiSelect/_docs/FilterMultiSelect.mdx +9 -1
- package/src/Filter/FilterMultiSelect/_docs/FilterMultiSelect.stories.tsx +79 -2
- package/src/Filter/FilterMultiSelect/_docs/MockData.ts +39 -0
- package/src/Filter/FilterMultiSelect/context/MenuTriggerProvider/MenuTriggerProvider.spec.tsx +2 -18
- package/src/Filter/FilterMultiSelect/subcomponents/ListBox/ListBox.module.css +22 -0
- package/src/Filter/FilterMultiSelect/subcomponents/ListBox/ListBox.tsx +1 -1
- package/src/Filter/FilterMultiSelect/subcomponents/ListBoxSection/ListBoxSection.module.scss +1 -0
- package/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/MenuPopup.module.css +22 -0
- package/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/MenuPopup.tsx +1 -1
- package/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/ResponsiveMenuPopup.tsx +115 -0
- package/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/index.ts +1 -0
- package/dist/cjs/src/Filter/FilterMultiSelect/subcomponents/ListBox/ListBox.module.scss.cjs +0 -9
- package/dist/esm/src/Filter/FilterMultiSelect/subcomponents/ListBox/ListBox.module.scss.mjs +0 -7
- package/dist/esm/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/MenuPopup.module.scss.mjs +0 -4
- package/src/Filter/FilterMultiSelect/subcomponents/ListBox/ListBox.module.scss +0 -25
- package/src/Filter/FilterMultiSelect/subcomponents/MenuPopup/MenuPopup.module.scss +0 -24
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import React, { useEffect, useState, type HTMLAttributes } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
autoPlacement,
|
|
4
|
+
autoUpdate,
|
|
5
|
+
offset,
|
|
6
|
+
size,
|
|
7
|
+
useFloating,
|
|
8
|
+
type UseFloatingOptions,
|
|
9
|
+
} from '@floating-ui/react-dom'
|
|
10
|
+
import classnames from 'classnames'
|
|
11
|
+
import { FocusOn } from 'react-focus-on'
|
|
12
|
+
import { type OverrideClassName } from '~components/types/OverrideClassName'
|
|
13
|
+
import { useMenuTriggerContext } from '../../context'
|
|
14
|
+
import { type MenuPopupProps } from './MenuPopup'
|
|
15
|
+
import styles from './MenuPopup.module.css'
|
|
16
|
+
|
|
17
|
+
export type FloatingConfig = Pick<
|
|
18
|
+
UseFloatingOptions,
|
|
19
|
+
'placement' | 'strategy' | 'whileElementsMounted'
|
|
20
|
+
> & {
|
|
21
|
+
/** Whether the component should automatically resize based on the available window height.
|
|
22
|
+
* @default true
|
|
23
|
+
*/
|
|
24
|
+
shouldResize?: boolean
|
|
25
|
+
/** Whether the component should automatically flip to the top of the input based on the available window height.
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
shouldFlip?: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type ResponsiveMenuPopupProps = MenuPopupProps & {
|
|
32
|
+
floatingConfig?: FloatingConfig
|
|
33
|
+
} & OverrideClassName<HTMLAttributes<HTMLDivElement>>
|
|
34
|
+
|
|
35
|
+
/** 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 */
|
|
36
|
+
export const ResponsiveMenuPopup = ({
|
|
37
|
+
children,
|
|
38
|
+
floatingConfig = {
|
|
39
|
+
placement: 'bottom-start',
|
|
40
|
+
strategy: 'absolute',
|
|
41
|
+
whileElementsMounted: autoUpdate,
|
|
42
|
+
shouldFlip: true,
|
|
43
|
+
shouldResize: true,
|
|
44
|
+
},
|
|
45
|
+
classNameOverride,
|
|
46
|
+
isLoading,
|
|
47
|
+
loadingSkeleton,
|
|
48
|
+
...restProps
|
|
49
|
+
}: ResponsiveMenuPopupProps): JSX.Element => {
|
|
50
|
+
const [floatingElement, setFloatingElement] = useState<HTMLDivElement | null>(null)
|
|
51
|
+
const { menuTriggerState, buttonRef } = useMenuTriggerContext()
|
|
52
|
+
const referenceElement = buttonRef.current
|
|
53
|
+
|
|
54
|
+
const { floatingStyles, update } = useFloating({
|
|
55
|
+
elements: {
|
|
56
|
+
reference: referenceElement,
|
|
57
|
+
floating: floatingElement,
|
|
58
|
+
},
|
|
59
|
+
middleware: [
|
|
60
|
+
offset(6),
|
|
61
|
+
floatingConfig.shouldFlip &&
|
|
62
|
+
autoPlacement({ allowedPlacements: ['bottom-start', 'top-start'] }),
|
|
63
|
+
floatingConfig.shouldResize &&
|
|
64
|
+
size({
|
|
65
|
+
apply({ availableHeight, elements }) {
|
|
66
|
+
Object.assign(elements.floating.style, {
|
|
67
|
+
maxHeight: Math.max(250, Math.min(availableHeight - 12, 500)) + 'px',
|
|
68
|
+
})
|
|
69
|
+
},
|
|
70
|
+
}),
|
|
71
|
+
],
|
|
72
|
+
...floatingConfig,
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
const handleReturnFocus = (): void => {
|
|
76
|
+
requestAnimationFrame(() => {
|
|
77
|
+
buttonRef.current?.focus()
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
if (floatingElement && referenceElement) {
|
|
83
|
+
floatingElement.showPopover?.()
|
|
84
|
+
update()
|
|
85
|
+
}
|
|
86
|
+
}, [floatingElement, referenceElement, update])
|
|
87
|
+
|
|
88
|
+
return menuTriggerState.isOpen ? (
|
|
89
|
+
<FocusOn
|
|
90
|
+
enabled={menuTriggerState.isOpen}
|
|
91
|
+
scrollLock={true}
|
|
92
|
+
returnFocus={false}
|
|
93
|
+
onClickOutside={menuTriggerState.close}
|
|
94
|
+
onEscapeKey={menuTriggerState.close}
|
|
95
|
+
onDeactivation={handleReturnFocus}
|
|
96
|
+
>
|
|
97
|
+
<div
|
|
98
|
+
ref={setFloatingElement}
|
|
99
|
+
style={floatingStyles}
|
|
100
|
+
className={classnames(styles.menuPopup, classNameOverride)}
|
|
101
|
+
role="dialog"
|
|
102
|
+
aria-modal="true"
|
|
103
|
+
// @ts-expect-error: popover is valid in supported browsers
|
|
104
|
+
popover="manual"
|
|
105
|
+
{...restProps}
|
|
106
|
+
>
|
|
107
|
+
{isLoading && loadingSkeleton ? loadingSkeleton : children}
|
|
108
|
+
</div>
|
|
109
|
+
</FocusOn>
|
|
110
|
+
) : (
|
|
111
|
+
<></>
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
ResponsiveMenuPopup.displayName = 'FilterMultiSelect.ResponsiveMenuPopup'
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var styles = {
|
|
4
|
-
"listBox": "ListBox-module_listBox__q95MO",
|
|
5
|
-
"overflown": "ListBox-module_overflown__wChQA",
|
|
6
|
-
"hidden": "ListBox-module_hidden__eYdXv",
|
|
7
|
-
"noResultsWrapper": "ListBox-module_noResultsWrapper__WcLRm"
|
|
8
|
-
};
|
|
9
|
-
module.exports = styles;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
@import '~@kaizen/design-tokens/sass/spacing';
|
|
2
|
-
|
|
3
|
-
@layer kz-components {
|
|
4
|
-
.listBox {
|
|
5
|
-
list-style: none;
|
|
6
|
-
padding: $spacing-sm;
|
|
7
|
-
margin: 0 $spacing-sm 0 0;
|
|
8
|
-
display: grid;
|
|
9
|
-
max-height: 22rem;
|
|
10
|
-
overflow-y: auto;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.overflown {
|
|
14
|
-
padding-right: $spacing-sm;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.hidden {
|
|
18
|
-
display: none;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// this is a div but remove styles briefly flickering to a bullet list as the sections are removed
|
|
22
|
-
.noResultsWrapper {
|
|
23
|
-
list-style: none;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
@import '~@kaizen/design-tokens/sass/spacing';
|
|
2
|
-
@import '~@kaizen/design-tokens/sass/shadow';
|
|
3
|
-
@import '~@kaizen/design-tokens/sass/border';
|
|
4
|
-
@import '~@kaizen/design-tokens/sass/color';
|
|
5
|
-
|
|
6
|
-
@layer kz-components {
|
|
7
|
-
// figma hard coded: https://www.figma.com/file/eZKEE5kXbEMY3lx84oz8iN/%E2%9D%A4%EF%B8%8F-UI-Kit%3A-Heart?node-id=22814%3A96966
|
|
8
|
-
$menu-container-width: 294px;
|
|
9
|
-
$menu-container-max-height: 312px;
|
|
10
|
-
|
|
11
|
-
.menuPopup {
|
|
12
|
-
position: absolute;
|
|
13
|
-
z-index: 1000; // from $ca-z-index-dropdown
|
|
14
|
-
box-sizing: border-box;
|
|
15
|
-
background: $color-white;
|
|
16
|
-
color: $color-purple-800;
|
|
17
|
-
border-radius: $border-solid-border-radius;
|
|
18
|
-
box-shadow: $shadow-large-box-shadow;
|
|
19
|
-
padding: $spacing-sm 0;
|
|
20
|
-
margin-top: $spacing-xs;
|
|
21
|
-
text-align: start;
|
|
22
|
-
width: $menu-container-width;
|
|
23
|
-
}
|
|
24
|
-
}
|