@transferwise/components 46.135.1 → 46.135.2
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/build/common/panel/Panel.js +49 -54
- package/build/common/panel/Panel.js.map +1 -1
- package/build/common/panel/Panel.mjs +54 -59
- package/build/common/panel/Panel.mjs.map +1 -1
- package/build/main.css +4 -3
- package/build/select/Select.js +1 -1
- package/build/select/Select.js.map +1 -1
- package/build/select/Select.mjs +1 -1
- package/build/select/Select.mjs.map +1 -1
- package/build/styles/main.css +4 -3
- package/build/styles/modal/Modal.css +2 -2
- package/build/styles/select/Select.css +2 -1
- package/build/tooltip/Tooltip.js +29 -50
- package/build/tooltip/Tooltip.js.map +1 -1
- package/build/tooltip/Tooltip.mjs +30 -51
- package/build/tooltip/Tooltip.mjs.map +1 -1
- package/build/types/common/panel/Panel.d.ts.map +1 -1
- package/build/types/tooltip/Tooltip.d.ts.map +1 -1
- package/package.json +9 -11
- package/src/common/panel/Panel.tsx +56 -49
- package/src/main.css +4 -3
- package/src/modal/Modal.css +2 -2
- package/src/modal/Modal.less +1 -1
- package/src/select/Select.css +2 -1
- package/src/select/Select.less +6 -5
- package/src/select/Select.test.story.tsx +59 -0
- package/src/select/Select.tsx +1 -1
- package/src/tooltip/Tooltip.tsx +26 -45
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var react = require('@floating-ui/react');
|
|
5
6
|
var clsx = require('clsx');
|
|
6
7
|
var React = require('react');
|
|
7
|
-
var reactPopper = require('react-popper');
|
|
8
8
|
require('../theme.js');
|
|
9
9
|
require('../direction.js');
|
|
10
10
|
require('../propsValues/control.js');
|
|
@@ -32,7 +32,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
32
32
|
var Dimmer = require('../../dimmer/Dimmer.js');
|
|
33
33
|
var OverlayIdProvider = require('../../provider/overlay/OverlayIdProvider.js');
|
|
34
34
|
|
|
35
|
-
const POPOVER_OFFSET =
|
|
35
|
+
const POPOVER_OFFSET = 16;
|
|
36
36
|
// By default the flip positioning explores only the opposite alternative. So if left is passed and there's no enough space
|
|
37
37
|
// the right one gets chosen. If there's no space on both sides popover goes back to the initially chosen one left.
|
|
38
38
|
// This mapping forces popover to try the four available positions before going back to the initial chosen one.
|
|
@@ -55,60 +55,57 @@ const Panel = /*#__PURE__*/React.forwardRef(function Panel({
|
|
|
55
55
|
considerHeight = false,
|
|
56
56
|
...rest
|
|
57
57
|
}, reference) {
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
|
|
58
|
+
const arrowRef = React.useRef(null);
|
|
59
|
+
const middleware = [];
|
|
60
|
+
if (arrow) {
|
|
61
|
+
middleware.push(react.offset(POPOVER_OFFSET));
|
|
62
|
+
}
|
|
63
|
+
if (flip && fallbackPlacements[position$1]) {
|
|
64
|
+
middleware.push(react.flip({
|
|
65
|
+
fallbackPlacements: fallbackPlacements[position$1]
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
61
68
|
if (altAxis) {
|
|
62
|
-
|
|
63
|
-
// https://popper.js.org/docs/v2/modifiers/prevent-overflow
|
|
64
|
-
name: 'preventOverflow',
|
|
65
|
-
options: {
|
|
66
|
-
altAxis: true,
|
|
67
|
-
tether: false
|
|
68
|
-
}
|
|
69
|
-
});
|
|
69
|
+
middleware.push(react.shift());
|
|
70
70
|
}
|
|
71
71
|
if (arrow) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
options: {
|
|
77
|
-
padding: 8 // 8px from the edges of the popper
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
// This lets you displace a popper element from its reference element.
|
|
82
|
-
modifiers.push({
|
|
83
|
-
name: 'offset',
|
|
84
|
-
options: {
|
|
85
|
-
offset: POPOVER_OFFSET
|
|
86
|
-
}
|
|
87
|
-
});
|
|
72
|
+
middleware.push(react.arrow({
|
|
73
|
+
element: arrowRef,
|
|
74
|
+
padding: 8
|
|
75
|
+
}));
|
|
88
76
|
}
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
77
|
+
if (considerHeight) {
|
|
78
|
+
middleware.push(react.size({
|
|
79
|
+
padding: POPOVER_OFFSET,
|
|
80
|
+
apply: ({
|
|
81
|
+
elements,
|
|
82
|
+
availableHeight
|
|
83
|
+
}) => {
|
|
84
|
+
elements.floating.style.setProperty('--np-panel-available-height', `${availableHeight}px`);
|
|
94
85
|
}
|
|
95
|
-
});
|
|
86
|
+
}));
|
|
96
87
|
}
|
|
97
88
|
const {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
89
|
+
refs,
|
|
90
|
+
floatingStyles,
|
|
91
|
+
placement,
|
|
92
|
+
middlewareData
|
|
93
|
+
} = react.useFloating({
|
|
102
94
|
placement: position$1,
|
|
103
|
-
|
|
95
|
+
middleware,
|
|
96
|
+
elements: {
|
|
97
|
+
reference: anchorRef.current
|
|
98
|
+
},
|
|
99
|
+
whileElementsMounted: open ? react.autoUpdate : undefined
|
|
104
100
|
});
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
101
|
+
const arrowStyle = {
|
|
102
|
+
...(middlewareData.arrow?.x != null ? {
|
|
103
|
+
left: middlewareData.arrow.x
|
|
104
|
+
} : {}),
|
|
105
|
+
...(middlewareData.arrow?.y != null ? {
|
|
106
|
+
top: middlewareData.arrow.y
|
|
107
|
+
} : {})
|
|
108
|
+
};
|
|
112
109
|
const contentStyle = {
|
|
113
110
|
...(anchorWidth ? {
|
|
114
111
|
width: anchorRef.current?.clientWidth
|
|
@@ -124,12 +121,10 @@ const Panel = /*#__PURE__*/React.forwardRef(function Panel({
|
|
|
124
121
|
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
125
122
|
id: overlayId,
|
|
126
123
|
...rest,
|
|
127
|
-
ref:
|
|
124
|
+
ref: refs.setFloating,
|
|
128
125
|
role: "dialog",
|
|
129
|
-
style:
|
|
130
|
-
|
|
131
|
-
},
|
|
132
|
-
...attributes.popper,
|
|
126
|
+
style: floatingStyles,
|
|
127
|
+
"data-popper-placement": placement,
|
|
133
128
|
className: clsx.clsx('np-panel', {
|
|
134
129
|
'np-panel--open': open
|
|
135
130
|
}, rest.className),
|
|
@@ -138,9 +133,9 @@ const Panel = /*#__PURE__*/React.forwardRef(function Panel({
|
|
|
138
133
|
style: contentStyle,
|
|
139
134
|
className: clsx.clsx('np-panel__content'),
|
|
140
135
|
children: [children, arrow && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
141
|
-
ref:
|
|
136
|
+
ref: arrowRef,
|
|
142
137
|
className: clsx.clsx('np-panel__arrow'),
|
|
143
|
-
style:
|
|
138
|
+
style: arrowStyle
|
|
144
139
|
})]
|
|
145
140
|
})
|
|
146
141
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Panel.js","sources":["../../../src/common/panel/Panel.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport {\n CSSProperties,\n HTMLAttributes,\n MutableRefObject,\n PropsWithChildren,\n SyntheticEvent,\n forwardRef,\n useContext,\n
|
|
1
|
+
{"version":3,"file":"Panel.js","sources":["../../../src/common/panel/Panel.tsx"],"sourcesContent":["import {\n arrow as arrowMiddleware,\n autoUpdate,\n flip as flipMiddleware,\n offset,\n type Placement,\n shift,\n size as sizeMiddleware,\n useFloating,\n} from '@floating-ui/react';\nimport { clsx } from 'clsx';\nimport {\n CSSProperties,\n HTMLAttributes,\n MutableRefObject,\n PropsWithChildren,\n SyntheticEvent,\n forwardRef,\n useContext,\n useRef,\n} from 'react';\n\nimport { Position, PositionBottom, PositionLeft, PositionRight, PositionTop } from '..';\nimport Dimmer from '../../dimmer';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\n\nconst POPOVER_OFFSET = 16;\n\n// By default the flip positioning explores only the opposite alternative. So if left is passed and there's no enough space\n// the right one gets chosen. If there's no space on both sides popover goes back to the initially chosen one left.\n// This mapping forces popover to try the four available positions before going back to the initial chosen one.\nconst fallbackPlacements: Record<string, Placement[]> = {\n [Position.TOP]: [Position.BOTTOM, Position.RIGHT, Position.LEFT],\n [Position.BOTTOM]: [Position.TOP, Position.RIGHT, Position.LEFT],\n [Position.LEFT]: [Position.RIGHT, Position.TOP, Position.BOTTOM],\n [Position.RIGHT]: [Position.LEFT, Position.TOP, Position.BOTTOM],\n};\n\nexport type PanelProps = PropsWithChildren<{\n arrow?: boolean;\n flip?: boolean;\n altAxis?: boolean;\n open?: boolean;\n onClose?: (event: Event | SyntheticEvent) => void;\n position?: PositionBottom | PositionLeft | PositionRight | PositionTop;\n anchorRef: MutableRefObject<Element | null>;\n anchorWidth?: boolean;\n considerHeight?: boolean;\n}> &\n HTMLAttributes<HTMLDivElement>;\n\nconst Panel = forwardRef<HTMLDivElement, PanelProps>(function Panel(\n {\n arrow = false,\n flip = true,\n altAxis = false,\n children,\n open = false,\n onClose,\n position = Position.BOTTOM,\n anchorRef,\n anchorWidth = false,\n considerHeight = false,\n ...rest\n }: PanelProps,\n reference,\n) {\n const arrowRef = useRef<HTMLDivElement | null>(null);\n\n const middleware = [];\n\n if (arrow) {\n middleware.push(offset(POPOVER_OFFSET));\n }\n\n if (flip && fallbackPlacements[position]) {\n middleware.push(\n flipMiddleware({\n fallbackPlacements: fallbackPlacements[position],\n }),\n );\n }\n\n if (altAxis) {\n middleware.push(shift());\n }\n\n if (arrow) {\n middleware.push(arrowMiddleware({ element: arrowRef, padding: 8 }));\n }\n\n if (considerHeight) {\n middleware.push(\n sizeMiddleware({\n padding: POPOVER_OFFSET,\n apply: ({ elements, availableHeight }) => {\n elements.floating.style.setProperty(\n '--np-panel-available-height',\n `${availableHeight}px`,\n );\n },\n }),\n );\n }\n\n const { refs, floatingStyles, placement, middlewareData } = useFloating({\n placement: position,\n middleware,\n elements: {\n reference: anchorRef.current,\n },\n whileElementsMounted: open ? autoUpdate : undefined,\n });\n\n const arrowStyle: CSSProperties = {\n ...(middlewareData.arrow?.x != null ? { left: middlewareData.arrow.x } : {}),\n ...(middlewareData.arrow?.y != null ? { top: middlewareData.arrow.y } : {}),\n };\n\n const contentStyle: CSSProperties = {\n ...(anchorWidth ? { width: anchorRef.current?.clientWidth } : undefined),\n };\n\n const overlayId = useContext(OverlayIdContext);\n\n return (\n <Dimmer open={open} transparent fadeContentOnEnter fadeContentOnExit onClose={onClose}>\n <div\n id={overlayId}\n {...rest}\n ref={refs.setFloating}\n role=\"dialog\"\n style={floatingStyles}\n data-popper-placement={placement}\n className={clsx('np-panel', { 'np-panel--open': open }, rest.className)}\n >\n <div ref={reference} style={contentStyle} className={clsx('np-panel__content')}>\n {children}\n {/* Arrow has to stay inside content to get the same animations as the \"dialog\" and to get hidden when panel is closed. */}\n {arrow && <div ref={arrowRef} className={clsx('np-panel__arrow')} style={arrowStyle} />}\n </div>\n </div>\n </Dimmer>\n );\n});\n\nexport default Panel;\n"],"names":["POPOVER_OFFSET","fallbackPlacements","Position","TOP","BOTTOM","RIGHT","LEFT","Panel","forwardRef","arrow","flip","altAxis","children","open","onClose","position","anchorRef","anchorWidth","considerHeight","rest","reference","arrowRef","useRef","middleware","push","offset","flipMiddleware","shift","arrowMiddleware","element","padding","sizeMiddleware","apply","elements","availableHeight","floating","style","setProperty","refs","floatingStyles","placement","middlewareData","useFloating","current","whileElementsMounted","autoUpdate","undefined","arrowStyle","x","left","y","top","contentStyle","width","clientWidth","overlayId","useContext","OverlayIdContext","_jsx","Dimmer","transparent","fadeContentOnEnter","fadeContentOnExit","id","ref","setFloating","role","className","clsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAMA,cAAc,GAAG,EAAE;AAEzB;AACA;AACA;AACA,MAAMC,kBAAkB,GAAgC;AACtD,EAAA,CAACC,i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K,EAAEW;AAAW,SAAA,CAAG;OACpF;KACF;AACP,GAAQ,CAAC;AAEb,CAAC;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { offset, flip, shift, arrow, size, useFloating, autoUpdate } from '@floating-ui/react';
|
|
1
2
|
import { clsx } from 'clsx';
|
|
2
|
-
import { forwardRef,
|
|
3
|
-
import { usePopper } from 'react-popper';
|
|
3
|
+
import { forwardRef, useRef, useContext } from 'react';
|
|
4
4
|
import '../theme.mjs';
|
|
5
5
|
import '../direction.mjs';
|
|
6
6
|
import '../propsValues/control.mjs';
|
|
@@ -28,7 +28,7 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
28
28
|
import Dimmer from '../../dimmer/Dimmer.mjs';
|
|
29
29
|
import { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider.mjs';
|
|
30
30
|
|
|
31
|
-
const POPOVER_OFFSET =
|
|
31
|
+
const POPOVER_OFFSET = 16;
|
|
32
32
|
// By default the flip positioning explores only the opposite alternative. So if left is passed and there's no enough space
|
|
33
33
|
// the right one gets chosen. If there's no space on both sides popover goes back to the initially chosen one left.
|
|
34
34
|
// This mapping forces popover to try the four available positions before going back to the initial chosen one.
|
|
@@ -39,8 +39,8 @@ const fallbackPlacements = {
|
|
|
39
39
|
[Position.RIGHT]: [Position.LEFT, Position.TOP, Position.BOTTOM]
|
|
40
40
|
};
|
|
41
41
|
const Panel = /*#__PURE__*/forwardRef(function Panel({
|
|
42
|
-
arrow = false,
|
|
43
|
-
flip = true,
|
|
42
|
+
arrow: arrow$1 = false,
|
|
43
|
+
flip: flip$1 = true,
|
|
44
44
|
altAxis = false,
|
|
45
45
|
children,
|
|
46
46
|
open = false,
|
|
@@ -51,60 +51,57 @@ const Panel = /*#__PURE__*/forwardRef(function Panel({
|
|
|
51
51
|
considerHeight = false,
|
|
52
52
|
...rest
|
|
53
53
|
}, reference) {
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
|
|
54
|
+
const arrowRef = useRef(null);
|
|
55
|
+
const middleware = [];
|
|
56
|
+
if (arrow$1) {
|
|
57
|
+
middleware.push(offset(POPOVER_OFFSET));
|
|
58
|
+
}
|
|
59
|
+
if (flip$1 && fallbackPlacements[position]) {
|
|
60
|
+
middleware.push(flip({
|
|
61
|
+
fallbackPlacements: fallbackPlacements[position]
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
57
64
|
if (altAxis) {
|
|
58
|
-
|
|
59
|
-
// https://popper.js.org/docs/v2/modifiers/prevent-overflow
|
|
60
|
-
name: 'preventOverflow',
|
|
61
|
-
options: {
|
|
62
|
-
altAxis: true,
|
|
63
|
-
tether: false
|
|
64
|
-
}
|
|
65
|
-
});
|
|
65
|
+
middleware.push(shift());
|
|
66
66
|
}
|
|
67
|
-
if (arrow) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
options: {
|
|
73
|
-
padding: 8 // 8px from the edges of the popper
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
// This lets you displace a popper element from its reference element.
|
|
78
|
-
modifiers.push({
|
|
79
|
-
name: 'offset',
|
|
80
|
-
options: {
|
|
81
|
-
offset: POPOVER_OFFSET
|
|
82
|
-
}
|
|
83
|
-
});
|
|
67
|
+
if (arrow$1) {
|
|
68
|
+
middleware.push(arrow({
|
|
69
|
+
element: arrowRef,
|
|
70
|
+
padding: 8
|
|
71
|
+
}));
|
|
84
72
|
}
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
73
|
+
if (considerHeight) {
|
|
74
|
+
middleware.push(size({
|
|
75
|
+
padding: POPOVER_OFFSET,
|
|
76
|
+
apply: ({
|
|
77
|
+
elements,
|
|
78
|
+
availableHeight
|
|
79
|
+
}) => {
|
|
80
|
+
elements.floating.style.setProperty('--np-panel-available-height', `${availableHeight}px`);
|
|
90
81
|
}
|
|
91
|
-
});
|
|
82
|
+
}));
|
|
92
83
|
}
|
|
93
84
|
const {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
85
|
+
refs,
|
|
86
|
+
floatingStyles,
|
|
87
|
+
placement,
|
|
88
|
+
middlewareData
|
|
89
|
+
} = useFloating({
|
|
98
90
|
placement: position,
|
|
99
|
-
|
|
91
|
+
middleware,
|
|
92
|
+
elements: {
|
|
93
|
+
reference: anchorRef.current
|
|
94
|
+
},
|
|
95
|
+
whileElementsMounted: open ? autoUpdate : undefined
|
|
100
96
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
97
|
+
const arrowStyle = {
|
|
98
|
+
...(middlewareData.arrow?.x != null ? {
|
|
99
|
+
left: middlewareData.arrow.x
|
|
100
|
+
} : {}),
|
|
101
|
+
...(middlewareData.arrow?.y != null ? {
|
|
102
|
+
top: middlewareData.arrow.y
|
|
103
|
+
} : {})
|
|
104
|
+
};
|
|
108
105
|
const contentStyle = {
|
|
109
106
|
...(anchorWidth ? {
|
|
110
107
|
width: anchorRef.current?.clientWidth
|
|
@@ -120,12 +117,10 @@ const Panel = /*#__PURE__*/forwardRef(function Panel({
|
|
|
120
117
|
children: /*#__PURE__*/jsx("div", {
|
|
121
118
|
id: overlayId,
|
|
122
119
|
...rest,
|
|
123
|
-
ref:
|
|
120
|
+
ref: refs.setFloating,
|
|
124
121
|
role: "dialog",
|
|
125
|
-
style:
|
|
126
|
-
|
|
127
|
-
},
|
|
128
|
-
...attributes.popper,
|
|
122
|
+
style: floatingStyles,
|
|
123
|
+
"data-popper-placement": placement,
|
|
129
124
|
className: clsx('np-panel', {
|
|
130
125
|
'np-panel--open': open
|
|
131
126
|
}, rest.className),
|
|
@@ -133,10 +128,10 @@ const Panel = /*#__PURE__*/forwardRef(function Panel({
|
|
|
133
128
|
ref: reference,
|
|
134
129
|
style: contentStyle,
|
|
135
130
|
className: clsx('np-panel__content'),
|
|
136
|
-
children: [children, arrow && /*#__PURE__*/jsx("div", {
|
|
137
|
-
ref:
|
|
131
|
+
children: [children, arrow$1 && /*#__PURE__*/jsx("div", {
|
|
132
|
+
ref: arrowRef,
|
|
138
133
|
className: clsx('np-panel__arrow'),
|
|
139
|
-
style:
|
|
134
|
+
style: arrowStyle
|
|
140
135
|
})]
|
|
141
136
|
})
|
|
142
137
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Panel.mjs","sources":["../../../src/common/panel/Panel.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport {\n CSSProperties,\n HTMLAttributes,\n MutableRefObject,\n PropsWithChildren,\n SyntheticEvent,\n forwardRef,\n useContext,\n
|
|
1
|
+
{"version":3,"file":"Panel.mjs","sources":["../../../src/common/panel/Panel.tsx"],"sourcesContent":["import {\n arrow as arrowMiddleware,\n autoUpdate,\n flip as flipMiddleware,\n offset,\n type Placement,\n shift,\n size as sizeMiddleware,\n useFloating,\n} from '@floating-ui/react';\nimport { clsx } from 'clsx';\nimport {\n CSSProperties,\n HTMLAttributes,\n MutableRefObject,\n PropsWithChildren,\n SyntheticEvent,\n forwardRef,\n useContext,\n useRef,\n} from 'react';\n\nimport { Position, PositionBottom, PositionLeft, PositionRight, PositionTop } from '..';\nimport Dimmer from '../../dimmer';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\n\nconst POPOVER_OFFSET = 16;\n\n// By default the flip positioning explores only the opposite alternative. So if left is passed and there's no enough space\n// the right one gets chosen. If there's no space on both sides popover goes back to the initially chosen one left.\n// This mapping forces popover to try the four available positions before going back to the initial chosen one.\nconst fallbackPlacements: Record<string, Placement[]> = {\n [Position.TOP]: [Position.BOTTOM, Position.RIGHT, Position.LEFT],\n [Position.BOTTOM]: [Position.TOP, Position.RIGHT, Position.LEFT],\n [Position.LEFT]: [Position.RIGHT, Position.TOP, Position.BOTTOM],\n [Position.RIGHT]: [Position.LEFT, Position.TOP, Position.BOTTOM],\n};\n\nexport type PanelProps = PropsWithChildren<{\n arrow?: boolean;\n flip?: boolean;\n altAxis?: boolean;\n open?: boolean;\n onClose?: (event: Event | SyntheticEvent) => void;\n position?: PositionBottom | PositionLeft | PositionRight | PositionTop;\n anchorRef: MutableRefObject<Element | null>;\n anchorWidth?: boolean;\n considerHeight?: boolean;\n}> &\n HTMLAttributes<HTMLDivElement>;\n\nconst Panel = forwardRef<HTMLDivElement, PanelProps>(function Panel(\n {\n arrow = false,\n flip = true,\n altAxis = false,\n children,\n open = false,\n onClose,\n position = Position.BOTTOM,\n anchorRef,\n anchorWidth = false,\n considerHeight = false,\n ...rest\n }: PanelProps,\n reference,\n) {\n const arrowRef = useRef<HTMLDivElement | null>(null);\n\n const middleware = [];\n\n if (arrow) {\n middleware.push(offset(POPOVER_OFFSET));\n }\n\n if (flip && fallbackPlacements[position]) {\n middleware.push(\n flipMiddleware({\n fallbackPlacements: fallbackPlacements[position],\n }),\n );\n }\n\n if (altAxis) {\n middleware.push(shift());\n }\n\n if (arrow) {\n middleware.push(arrowMiddleware({ element: arrowRef, padding: 8 }));\n }\n\n if (considerHeight) {\n middleware.push(\n sizeMiddleware({\n padding: POPOVER_OFFSET,\n apply: ({ elements, availableHeight }) => {\n elements.floating.style.setProperty(\n '--np-panel-available-height',\n `${availableHeight}px`,\n );\n },\n }),\n );\n }\n\n const { refs, floatingStyles, placement, middlewareData } = useFloating({\n placement: position,\n middleware,\n elements: {\n reference: anchorRef.current,\n },\n whileElementsMounted: open ? autoUpdate : undefined,\n });\n\n const arrowStyle: CSSProperties = {\n ...(middlewareData.arrow?.x != null ? { left: middlewareData.arrow.x } : {}),\n ...(middlewareData.arrow?.y != null ? { top: middlewareData.arrow.y } : {}),\n };\n\n const contentStyle: CSSProperties = {\n ...(anchorWidth ? { width: anchorRef.current?.clientWidth } : undefined),\n };\n\n const overlayId = useContext(OverlayIdContext);\n\n return (\n <Dimmer open={open} transparent fadeContentOnEnter fadeContentOnExit onClose={onClose}>\n <div\n id={overlayId}\n {...rest}\n ref={refs.setFloating}\n role=\"dialog\"\n style={floatingStyles}\n data-popper-placement={placement}\n className={clsx('np-panel', { 'np-panel--open': open }, rest.className)}\n >\n <div ref={reference} style={contentStyle} className={clsx('np-panel__content')}>\n {children}\n {/* Arrow has to stay inside content to get the same animations as the \"dialog\" and to get hidden when panel is closed. */}\n {arrow && <div ref={arrowRef} className={clsx('np-panel__arrow')} style={arrowStyle} />}\n </div>\n </div>\n </Dimmer>\n );\n});\n\nexport default Panel;\n"],"names":["POPOVER_OFFSET","fallbackPlacements","Position","TOP","BOTTOM","RIGHT","LEFT","Panel","forwardRef","arrow","flip","altAxis","children","open","onClose","position","anchorRef","anchorWidth","considerHeight","rest","reference","arrowRef","useRef","middleware","push","offset","flipMiddleware","shift","arrowMiddleware","element","padding","sizeMiddleware","apply","elements","availableHeight","floating","style","setProperty","refs","floatingStyles","placement","middlewareData","useFloating","current","whileElementsMounted","autoUpdate","undefined","arrowStyle","x","left","y","top","contentStyle","width","clientWidth","overlayId","useContext","OverlayIdContext","_jsx","Dimmer","transparent","fadeContentOnEnter","fadeContentOnExit","id","ref","setFloating","role","className","clsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAMA,cAAc,GAAG,EAAE;AAEzB;AACA;AACA;AACA,MAAMC,kBAAkB,GAAgC;AACtD,EAAA,CAACC,QAAQ,CAACC,GAAG,GAAG,CAACD,QAAQ,CAACE,MAAM,EAAEF,QAAQ,CAACG,KAAK,EAAEH,QAAQ,CAACI,IAAI,CAAC;AAChE,EAAA,CAACJ,QAAQ,CAACE,MAAM,GAAG,CAACF,QAAQ,CAACC,GAAG,EAAED,QAAQ,CAACG,KAAK,EAAEH,QAAQ,CAACI,IAAI,CAAC;AAChE,EAAA,CAACJ,QAAQ,CAACI,IAAI,GAAG,CAACJ,QAAQ,CAACG,KAAK,EAAEH,QAAQ,CAACC,GAAG,EAAED,QAAQ,CAACE,MAAM,CAAC;AAChE,EAA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AAkB,EAAA,IAAA;IAACC,iBAAiB,EAAA,IAAA;AAAChD,IAAAA,OAAO,EAAEA,OAAQ;AAAAF,IAAAA,QAAA,eACpF8C,GAAA,CAAA,KAAA,EAAA;AACEK,MAAAA,EAAE,EAAER,SAAU;AAAA,MAAA,GACVpC,IAAI;MACR6C,GAAG,EAAE1B,IAAI,CAAC2B,WAAY;AACtBC,MAAAA,IAAI,EAAC,QAAQ;AACb9B,MAAAA,KAAK,EAAEG,cAAe;AACtB,MAAA,uBAAA,EAAuBC,SAAU;AACjC2B,MAAAA,SAAS,EAAEC,IAAI,CAAC,UAAU,EAAE;AAAE,QAAA,gBAAgB,EAAEvD;AAAI,OAAE,EAAEM,IAAI,CAACgD,SAAS,CAAE;AAAAvD,MAAAA,QAAA,eAExEyD,IAAA,CAAA,KAAA,EAAA;AAAKL,QAAAA,GAAG,EAAE5C,SAAU;AAACgB,QAAAA,KAAK,EAAEgB,YAAa;AAACe,QAAAA,SAAS,EAAEC,IAAI,CAAC,mBAAmB,CAAE;AAAAxD,QAAAA,QAAA,EAAA,CAC5EA,QAAQ,EAERH,OAAK,iBAAIiD,GAAA,CAAA,KAAA,EAAA;AAAKM,UAAAA,GAAG,EAAE3C,QAAS;AAAC8C,UAAAA,SAAS,EAAEC,IAAI,CAAC,iBAAiB,CAAE;AAAChC,UAAAA,KAAK,EAAEW;AAAW,SAAA,CAAG;OACpF;KACF;AACP,GAAQ,CAAC;AAEb,CAAC;;;;"}
|
package/build/main.css
CHANGED
|
@@ -31064,8 +31064,8 @@ button.np-link {
|
|
|
31064
31064
|
box-shadow: none;
|
|
31065
31065
|
background: #ffffff;
|
|
31066
31066
|
background: var(--color-background-elevated);
|
|
31067
|
-
border-radius:
|
|
31068
|
-
border-radius: var(--radius-
|
|
31067
|
+
border-radius: 32px;
|
|
31068
|
+
border-radius: var(--radius-xlarge);
|
|
31069
31069
|
}
|
|
31070
31070
|
|
|
31071
31071
|
.tw-modal.in .tw-modal-dialog {
|
|
@@ -32728,8 +32728,8 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
32728
32728
|
}
|
|
32729
32729
|
|
|
32730
32730
|
.np-dropdown-menu-desktop {
|
|
32731
|
-
max-height: 70vh;
|
|
32732
32731
|
max-height: 70svh;
|
|
32732
|
+
max-height: var(--np-panel-available-height, 70svh);
|
|
32733
32733
|
min-width: 160px;
|
|
32734
32734
|
max-width: calc(100vw - 32px);
|
|
32735
32735
|
}
|
|
@@ -32737,6 +32737,7 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
32737
32737
|
@media (min-height: 592px) {
|
|
32738
32738
|
.np-dropdown-menu-desktop {
|
|
32739
32739
|
max-height: 592px;
|
|
32740
|
+
max-height: var(--np-panel-available-height, 592px);
|
|
32740
32741
|
}
|
|
32741
32742
|
}
|
|
32742
32743
|
|
package/build/select/Select.js
CHANGED
|
@@ -482,8 +482,8 @@ function Select({
|
|
|
482
482
|
children: renderOptionsList()
|
|
483
483
|
}) : /*#__PURE__*/jsxRuntime.jsx(Panel.default, {
|
|
484
484
|
open: open,
|
|
485
|
-
flip: false,
|
|
486
485
|
altAxis: true,
|
|
486
|
+
considerHeight: true,
|
|
487
487
|
anchorRef: selectReference,
|
|
488
488
|
anchorWidth: isDropdownAutoWidth,
|
|
489
489
|
position: dropdownUp ? position.Position.TOP : position.Position.BOTTOM,
|