@jobber/components 6.80.0 → 6.82.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/Autocomplete/constants.d.ts +0 -1
- package/dist/Autocomplete/index.cjs +2 -1
- package/dist/Autocomplete/index.mjs +2 -1
- package/dist/Autocomplete-cjs.js +5 -7
- package/dist/Autocomplete-es.js +5 -7
- package/dist/Card/index.cjs +1 -1
- package/dist/Card/index.mjs +1 -1
- package/dist/Chips/InternalChipDismissible/hooks/index.cjs +1 -0
- package/dist/Chips/InternalChipDismissible/hooks/index.mjs +1 -0
- package/dist/Chips/InternalChipDismissible/index.cjs +1 -0
- package/dist/Chips/InternalChipDismissible/index.mjs +1 -0
- package/dist/Chips/index.cjs +1 -0
- package/dist/Chips/index.mjs +1 -0
- package/dist/Combobox/hooks/useComboboxAccessibility.d.ts +2 -2
- package/dist/ComboboxContent-cjs.js +11 -15
- package/dist/ComboboxContent-es.js +12 -16
- package/dist/DataDump/index.cjs +1 -1
- package/dist/DataDump/index.mjs +1 -1
- package/dist/DataTable/DataTable.d.ts +16 -0
- package/dist/DataTable/components/DataTableActions.d.ts +2 -0
- package/dist/DataTable/components/DataTableBody.d.ts +2 -0
- package/dist/DataTable/components/DataTableCell.d.ts +2 -0
- package/dist/DataTable/components/DataTableContainer.d.ts +2 -0
- package/dist/DataTable/components/DataTableFooter.d.ts +9 -0
- package/dist/DataTable/components/DataTableHeader.d.ts +2 -0
- package/dist/DataTable/components/DataTableHeaderCell.d.ts +5 -0
- package/dist/DataTable/components/DataTablePagination.d.ts +5 -0
- package/dist/DataTable/components/DataTablePaginationButton.d.ts +21 -0
- package/dist/DataTable/components/DataTableRow.d.ts +2 -0
- package/dist/DataTable/components/DataTableRowActions.d.ts +4 -0
- package/dist/DataTable/components/DataTableSortableHeader.d.ts +18 -0
- package/dist/DataTable/components/DataTableTable.d.ts +2 -0
- package/dist/DataTable/components/index.cjs +27 -0
- package/dist/DataTable/components/index.d.ts +13 -0
- package/dist/DataTable/components/index.mjs +9 -0
- package/dist/DataTable/index.cjs +6 -0
- package/dist/DataTable/index.d.ts +1 -0
- package/dist/DataTable/index.mjs +1 -0
- package/dist/DataTable-cjs.js +40 -60
- package/dist/DataTable-es.js +37 -57
- package/dist/DataTableTable-cjs.js +127 -0
- package/dist/DataTableTable-es.js +112 -0
- package/dist/Menu/index.cjs +1 -1
- package/dist/Menu/index.mjs +1 -1
- package/dist/Menu-cjs.js +10 -16
- package/dist/Menu-es.js +10 -16
- package/dist/Modal/index.mjs +1 -1
- package/dist/Page/index.cjs +1 -1
- package/dist/Page/index.mjs +1 -1
- package/dist/Popover/PopoverContext.d.ts +2 -2
- package/dist/Popover/index.cjs +1 -1
- package/dist/Popover/index.mjs +1 -1
- package/dist/Popover/usePopover.d.ts +3 -6
- package/dist/Popover-cjs.js +17 -17
- package/dist/Popover-es.js +18 -18
- package/dist/floating-ui.react-es.js +1 -1
- package/dist/index.cjs +3 -1
- package/dist/index.mjs +3 -1
- package/dist/maxHeight-cjs.js +24 -0
- package/dist/maxHeight-es.js +22 -0
- package/dist/styles.css +134 -0
- package/dist/useScrollToActive-cjs.js +5 -2
- package/dist/useScrollToActive-es.js +5 -2
- package/dist/utils/maxHeight.d.ts +23 -0
- package/dist/utils/meta/meta.json +13 -0
- package/package.json +2 -2
package/dist/Menu/index.cjs
CHANGED
|
@@ -4,7 +4,6 @@ var Menu = require('../Menu-cjs.js');
|
|
|
4
4
|
require('react');
|
|
5
5
|
require('classnames');
|
|
6
6
|
require('framer-motion');
|
|
7
|
-
require('../useOnKeyDown-cjs.js');
|
|
8
7
|
require('../useRefocusOnActivator-cjs.js');
|
|
9
8
|
require('../floating-ui.react-cjs.js');
|
|
10
9
|
require('react-dom');
|
|
@@ -18,6 +17,7 @@ require('../Icon-cjs.js');
|
|
|
18
17
|
require('@jobber/design');
|
|
19
18
|
require('../Typography-cjs.js');
|
|
20
19
|
require('../useFormFieldFocus-cjs.js');
|
|
20
|
+
require('../maxHeight-cjs.js');
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
package/dist/Menu/index.mjs
CHANGED
|
@@ -2,7 +2,6 @@ export { M as Menu } from '../Menu-es.js';
|
|
|
2
2
|
import 'react';
|
|
3
3
|
import 'classnames';
|
|
4
4
|
import 'framer-motion';
|
|
5
|
-
import '../useOnKeyDown-es.js';
|
|
6
5
|
import '../useRefocusOnActivator-es.js';
|
|
7
6
|
import '../floating-ui.react-es.js';
|
|
8
7
|
import 'react-dom';
|
|
@@ -16,3 +15,4 @@ import '../Icon-es.js';
|
|
|
16
15
|
import '@jobber/design';
|
|
17
16
|
import '../Typography-es.js';
|
|
18
17
|
import '../useFormFieldFocus-es.js';
|
|
18
|
+
import '../maxHeight-es.js';
|
package/dist/Menu-cjs.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var classnames = require('classnames');
|
|
5
5
|
var framerMotion = require('framer-motion');
|
|
6
|
-
var useOnKeyDown = require('./useOnKeyDown-cjs.js');
|
|
7
6
|
var useRefocusOnActivator = require('./useRefocusOnActivator-cjs.js');
|
|
8
7
|
var floatingUi_react = require('./floating-ui.react-cjs.js');
|
|
9
8
|
var useFocusTrap = require('./useFocusTrap-cjs.js');
|
|
@@ -12,6 +11,7 @@ var Button = require('./Button-cjs.js');
|
|
|
12
11
|
var Typography = require('./Typography-cjs.js');
|
|
13
12
|
var Icon = require('./Icon-cjs.js');
|
|
14
13
|
var useFormFieldFocus = require('./useFormFieldFocus-cjs.js');
|
|
14
|
+
var maxHeight = require('./maxHeight-cjs.js');
|
|
15
15
|
|
|
16
16
|
var useWindowDimensions$1 = {};
|
|
17
17
|
|
|
@@ -47,7 +47,7 @@ var styles = {"wrapper":"fpi0W91w2ag-","floatingContainer":"ba-Kj6mvQUw-","menu"
|
|
|
47
47
|
|
|
48
48
|
const SMALL_SCREEN_BREAKPOINT = 490;
|
|
49
49
|
const MENU_OFFSET = 6;
|
|
50
|
-
const
|
|
50
|
+
const MENU_MAX_HEIGHT_PERCENTAGE = 72;
|
|
51
51
|
const variation = {
|
|
52
52
|
overlayStartStop: { opacity: 0 },
|
|
53
53
|
startOrStop: (placement) => {
|
|
@@ -72,7 +72,6 @@ function Menu({ activator, items, UNSAFE_className, UNSAFE_style, }) {
|
|
|
72
72
|
const wrapperClasses = classnames(styles.wrapper, {
|
|
73
73
|
[styles.fullWidth]: fullWidth,
|
|
74
74
|
});
|
|
75
|
-
useOnKeyDown.useOnKeyDown_2(handleKeyboardShortcut, ["Escape"]);
|
|
76
75
|
// useRefocusOnActivator must come before useFocusTrap for them both to work
|
|
77
76
|
useRefocusOnActivator.useRefocusOnActivator_2(visible);
|
|
78
77
|
const menuRef = useFocusTrap.useFocusTrap_2(visible);
|
|
@@ -90,11 +89,12 @@ function Menu({ activator, items, UNSAFE_className, UNSAFE_style, }) {
|
|
|
90
89
|
const menuElement = elements.floating.querySelector('[role="menu"]');
|
|
91
90
|
if (menuElement) {
|
|
92
91
|
const viewportHeight = window.innerHeight;
|
|
93
|
-
const maxHeightVh = (viewportHeight *
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
const maxHeightVh = (viewportHeight * MENU_MAX_HEIGHT_PERCENTAGE) / 100;
|
|
93
|
+
const maxHeight$1 = maxHeight.calculateMaxHeight(availableHeight, {
|
|
94
|
+
maxHeight: maxHeightVh,
|
|
95
|
+
});
|
|
96
96
|
Object.assign(menuElement.style, {
|
|
97
|
-
maxHeight: `${maxHeight}px`,
|
|
97
|
+
maxHeight: `${maxHeight$1}px`,
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
100
|
},
|
|
@@ -105,6 +105,8 @@ function Menu({ activator, items, UNSAFE_className, UNSAFE_style, }) {
|
|
|
105
105
|
},
|
|
106
106
|
whileElementsMounted: floatingUi_react.autoUpdate,
|
|
107
107
|
});
|
|
108
|
+
const dismiss = floatingUi_react.useDismiss(context);
|
|
109
|
+
const { getFloatingProps } = floatingUi_react.useInteractions([dismiss]);
|
|
108
110
|
const positionAttributes = width >= SMALL_SCREEN_BREAKPOINT
|
|
109
111
|
? {
|
|
110
112
|
style: floatingStyles,
|
|
@@ -127,7 +129,7 @@ function Menu({ activator, items, UNSAFE_className, UNSAFE_style, }) {
|
|
|
127
129
|
type: "tween",
|
|
128
130
|
duration: 0.15,
|
|
129
131
|
} }),
|
|
130
|
-
React.createElement("div", Object.assign({ ref: refs.setFloating, className: styles.floatingContainer }, positionAttributes, useFormFieldFocus.formFieldFocusAttribute), items.length > 0 && (React.createElement(framerMotion.motion.div, { className: classnames(styles.menu, UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.menu), role: "menu", "data-elevation": "elevated", "aria-labelledby": buttonID, id: menuID, onClick: hide, variants: variation, initial: "startOrStop", animate: "done", exit: "startOrStop", custom: context === null || context === void 0 ? void 0 : context.placement, ref: menuRef, transition: {
|
|
132
|
+
React.createElement("div", Object.assign({ ref: refs.setFloating, className: styles.floatingContainer }, getFloatingProps(), positionAttributes, useFormFieldFocus.formFieldFocusAttribute), items.length > 0 && (React.createElement(framerMotion.motion.div, { className: classnames(styles.menu, UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.menu), role: "menu", "data-elevation": "elevated", "aria-labelledby": buttonID, id: menuID, onClick: hide, variants: variation, initial: "startOrStop", animate: "done", exit: "startOrStop", custom: context === null || context === void 0 ? void 0 : context.placement, ref: menuRef, transition: {
|
|
131
133
|
type: "tween",
|
|
132
134
|
duration: 0.25,
|
|
133
135
|
}, style: UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.menu }, items.map((item, key) => (React.createElement("div", { key: key, className: styles.section },
|
|
@@ -142,14 +144,6 @@ function Menu({ activator, items, UNSAFE_className, UNSAFE_style, }) {
|
|
|
142
144
|
function hide() {
|
|
143
145
|
setVisible(false);
|
|
144
146
|
}
|
|
145
|
-
function handleKeyboardShortcut(event) {
|
|
146
|
-
const { key } = event;
|
|
147
|
-
if (!visible)
|
|
148
|
-
return;
|
|
149
|
-
event.preventDefault();
|
|
150
|
-
event.stopPropagation();
|
|
151
|
-
key === "Escape" && hide();
|
|
152
|
-
}
|
|
153
147
|
function handleParentClick(event) {
|
|
154
148
|
// Since the menu is being rendered within the same parent as the activator,
|
|
155
149
|
// we need to stop the click event from bubbling up. If the Menu component
|
package/dist/Menu-es.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import React__default, { useState, useId, useRef } from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
3
|
import { AnimatePresence, motion } from 'framer-motion';
|
|
4
|
-
import { u as useOnKeyDown_2 } from './useOnKeyDown-es.js';
|
|
5
4
|
import { u as useRefocusOnActivator_2 } from './useRefocusOnActivator-es.js';
|
|
6
|
-
import { u as useFloating, F as FloatingPortal, o as offset, f as flip,
|
|
5
|
+
import { u as useFloating, c as useDismiss, d as useInteractions, F as FloatingPortal, o as offset, f as flip, e as size, b as autoUpdate } from './floating-ui.react-es.js';
|
|
7
6
|
import { u as useFocusTrap_2 } from './useFocusTrap-es.js';
|
|
8
7
|
import { u as useIsMounted_2 } from './useIsMounted-es.js';
|
|
9
8
|
import { B as Button } from './Button-es.js';
|
|
10
9
|
import { T as Typography } from './Typography-es.js';
|
|
11
10
|
import { I as Icon } from './Icon-es.js';
|
|
12
11
|
import { f as formFieldFocusAttribute } from './useFormFieldFocus-es.js';
|
|
12
|
+
import { c as calculateMaxHeight } from './maxHeight-es.js';
|
|
13
13
|
|
|
14
14
|
var useWindowDimensions$1 = {};
|
|
15
15
|
|
|
@@ -45,7 +45,7 @@ var styles = {"wrapper":"fpi0W91w2ag-","floatingContainer":"ba-Kj6mvQUw-","menu"
|
|
|
45
45
|
|
|
46
46
|
const SMALL_SCREEN_BREAKPOINT = 490;
|
|
47
47
|
const MENU_OFFSET = 6;
|
|
48
|
-
const
|
|
48
|
+
const MENU_MAX_HEIGHT_PERCENTAGE = 72;
|
|
49
49
|
const variation = {
|
|
50
50
|
overlayStartStop: { opacity: 0 },
|
|
51
51
|
startOrStop: (placement) => {
|
|
@@ -70,7 +70,6 @@ function Menu({ activator, items, UNSAFE_className, UNSAFE_style, }) {
|
|
|
70
70
|
const wrapperClasses = classnames(styles.wrapper, {
|
|
71
71
|
[styles.fullWidth]: fullWidth,
|
|
72
72
|
});
|
|
73
|
-
useOnKeyDown_2(handleKeyboardShortcut, ["Escape"]);
|
|
74
73
|
// useRefocusOnActivator must come before useFocusTrap for them both to work
|
|
75
74
|
useRefocusOnActivator_2(visible);
|
|
76
75
|
const menuRef = useFocusTrap_2(visible);
|
|
@@ -88,9 +87,10 @@ function Menu({ activator, items, UNSAFE_className, UNSAFE_style, }) {
|
|
|
88
87
|
const menuElement = elements.floating.querySelector('[role="menu"]');
|
|
89
88
|
if (menuElement) {
|
|
90
89
|
const viewportHeight = window.innerHeight;
|
|
91
|
-
const maxHeightVh = (viewportHeight *
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
const maxHeightVh = (viewportHeight * MENU_MAX_HEIGHT_PERCENTAGE) / 100;
|
|
91
|
+
const maxHeight = calculateMaxHeight(availableHeight, {
|
|
92
|
+
maxHeight: maxHeightVh,
|
|
93
|
+
});
|
|
94
94
|
Object.assign(menuElement.style, {
|
|
95
95
|
maxHeight: `${maxHeight}px`,
|
|
96
96
|
});
|
|
@@ -103,6 +103,8 @@ function Menu({ activator, items, UNSAFE_className, UNSAFE_style, }) {
|
|
|
103
103
|
},
|
|
104
104
|
whileElementsMounted: autoUpdate,
|
|
105
105
|
});
|
|
106
|
+
const dismiss = useDismiss(context);
|
|
107
|
+
const { getFloatingProps } = useInteractions([dismiss]);
|
|
106
108
|
const positionAttributes = width >= SMALL_SCREEN_BREAKPOINT
|
|
107
109
|
? {
|
|
108
110
|
style: floatingStyles,
|
|
@@ -125,7 +127,7 @@ function Menu({ activator, items, UNSAFE_className, UNSAFE_style, }) {
|
|
|
125
127
|
type: "tween",
|
|
126
128
|
duration: 0.15,
|
|
127
129
|
} }),
|
|
128
|
-
React__default.createElement("div", Object.assign({ ref: refs.setFloating, className: styles.floatingContainer }, positionAttributes, formFieldFocusAttribute), items.length > 0 && (React__default.createElement(motion.div, { className: classnames(styles.menu, UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.menu), role: "menu", "data-elevation": "elevated", "aria-labelledby": buttonID, id: menuID, onClick: hide, variants: variation, initial: "startOrStop", animate: "done", exit: "startOrStop", custom: context === null || context === void 0 ? void 0 : context.placement, ref: menuRef, transition: {
|
|
130
|
+
React__default.createElement("div", Object.assign({ ref: refs.setFloating, className: styles.floatingContainer }, getFloatingProps(), positionAttributes, formFieldFocusAttribute), items.length > 0 && (React__default.createElement(motion.div, { className: classnames(styles.menu, UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.menu), role: "menu", "data-elevation": "elevated", "aria-labelledby": buttonID, id: menuID, onClick: hide, variants: variation, initial: "startOrStop", animate: "done", exit: "startOrStop", custom: context === null || context === void 0 ? void 0 : context.placement, ref: menuRef, transition: {
|
|
129
131
|
type: "tween",
|
|
130
132
|
duration: 0.25,
|
|
131
133
|
}, style: UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.menu }, items.map((item, key) => (React__default.createElement("div", { key: key, className: styles.section },
|
|
@@ -140,14 +142,6 @@ function Menu({ activator, items, UNSAFE_className, UNSAFE_style, }) {
|
|
|
140
142
|
function hide() {
|
|
141
143
|
setVisible(false);
|
|
142
144
|
}
|
|
143
|
-
function handleKeyboardShortcut(event) {
|
|
144
|
-
const { key } = event;
|
|
145
|
-
if (!visible)
|
|
146
|
-
return;
|
|
147
|
-
event.preventDefault();
|
|
148
|
-
event.stopPropagation();
|
|
149
|
-
key === "Escape" && hide();
|
|
150
|
-
}
|
|
151
145
|
function handleParentClick(event) {
|
|
152
146
|
// Since the menu is being rendered within the same parent as the activator,
|
|
153
147
|
// we need to stop the click event from bubbling up. If the Menu component
|
package/dist/Modal/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { H as Heading } from '../Heading-es.js';
|
|
|
9
9
|
import { B as Button } from '../Button-es.js';
|
|
10
10
|
import { B as ButtonDismiss } from '../ButtonDismiss-es.js';
|
|
11
11
|
import { n as noop } from '../noop-es.js';
|
|
12
|
-
import {
|
|
12
|
+
import { h as useFloatingNodeId, u as useFloating, m as useClick, c as useDismiss, n as useRole, d as useInteractions, g as useFloatingParentNodeId, i as FloatingTree, j as FloatingNode, F as FloatingPortal, p as FloatingOverlay, q as FloatingFocusManager } from '../floating-ui.react-es.js';
|
|
13
13
|
import { b as identity } from '../identity-es.js';
|
|
14
14
|
import { A as AtlantisPortalContent } from '../AtlantisPortalContent-es.js';
|
|
15
15
|
import '../Typography-es.js';
|
package/dist/Page/index.cjs
CHANGED
|
@@ -23,7 +23,6 @@ require('../Icon-cjs.js');
|
|
|
23
23
|
require('@jobber/design');
|
|
24
24
|
require('../Menu-cjs.js');
|
|
25
25
|
require('framer-motion');
|
|
26
|
-
require('../useOnKeyDown-cjs.js');
|
|
27
26
|
require('../useRefocusOnActivator-cjs.js');
|
|
28
27
|
require('../floating-ui.react-cjs.js');
|
|
29
28
|
require('react-dom');
|
|
@@ -31,6 +30,7 @@ require('../useFocusTrap-cjs.js');
|
|
|
31
30
|
require('../useIsMounted-cjs.js');
|
|
32
31
|
require('../useSafeLayoutEffect-cjs.js');
|
|
33
32
|
require('../useFormFieldFocus-cjs.js');
|
|
33
|
+
require('../maxHeight-cjs.js');
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
|
package/dist/Page/index.mjs
CHANGED
|
@@ -21,7 +21,6 @@ import '../Icon-es.js';
|
|
|
21
21
|
import '@jobber/design';
|
|
22
22
|
import '../Menu-es.js';
|
|
23
23
|
import 'framer-motion';
|
|
24
|
-
import '../useOnKeyDown-es.js';
|
|
25
24
|
import '../useRefocusOnActivator-es.js';
|
|
26
25
|
import '../floating-ui.react-es.js';
|
|
27
26
|
import 'react-dom';
|
|
@@ -29,3 +28,4 @@ import '../useFocusTrap-es.js';
|
|
|
29
28
|
import '../useIsMounted-es.js';
|
|
30
29
|
import '../useSafeLayoutEffect-es.js';
|
|
31
30
|
import '../useFormFieldFocus-es.js';
|
|
31
|
+
import '../maxHeight-es.js';
|
|
@@ -3,8 +3,8 @@ import React, { CSSProperties } from "react";
|
|
|
3
3
|
import { PopoverProviderProps } from "./Popover.types";
|
|
4
4
|
interface PopoverContextProps {
|
|
5
5
|
setArrowElement: (element: HTMLElement | null) => void;
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
floatingStyles: {
|
|
7
|
+
float: CSSProperties;
|
|
8
8
|
arrow?: {
|
|
9
9
|
x?: number;
|
|
10
10
|
y?: number;
|
package/dist/Popover/index.cjs
CHANGED
|
@@ -4,8 +4,8 @@ var Popover = require('../Popover-cjs.js');
|
|
|
4
4
|
require('../tslib.es6-cjs.js');
|
|
5
5
|
require('react');
|
|
6
6
|
require('classnames');
|
|
7
|
-
require('react-dom');
|
|
8
7
|
require('../floating-ui.react-cjs.js');
|
|
8
|
+
require('react-dom');
|
|
9
9
|
require('../useRefocusOnActivator-cjs.js');
|
|
10
10
|
require('../AtlantisPortalContent-cjs.js');
|
|
11
11
|
require('../AtlantisThemeContext-cjs.js');
|
package/dist/Popover/index.mjs
CHANGED
|
@@ -2,8 +2,8 @@ export { P as Popover, u as usePopoverContext, a as usePopoverStyles } from '../
|
|
|
2
2
|
import '../tslib.es6-es.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'classnames';
|
|
5
|
-
import 'react-dom';
|
|
6
5
|
import '../floating-ui.react-es.js';
|
|
6
|
+
import 'react-dom';
|
|
7
7
|
import '../useRefocusOnActivator-es.js';
|
|
8
8
|
import '../AtlantisPortalContent-es.js';
|
|
9
9
|
import '../AtlantisThemeContext-es.js';
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { PopoverProps } from "./Popover.types";
|
|
2
2
|
export declare const usePopover: ({ preferredPlacement, attachTo, open, }: Pick<PopoverProps, "preferredPlacement" | "attachTo" | "open">) => {
|
|
3
|
-
|
|
3
|
+
setFloatingElement: ((node: HTMLElement | null) => void) & ((node: HTMLElement | null) => void);
|
|
4
4
|
setArrowElement: import("react").Dispatch<import("react").SetStateAction<HTMLElement | null | undefined>>;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
floatingStyles: {
|
|
6
|
+
float: import("react").CSSProperties;
|
|
7
7
|
arrow: (Partial<import("@floating-ui/core").Coords> & {
|
|
8
8
|
centerOffset: number;
|
|
9
9
|
alignmentOffset?: number;
|
|
10
10
|
}) | undefined;
|
|
11
11
|
};
|
|
12
12
|
placement: import("@floating-ui/utils").Placement;
|
|
13
|
-
attributes: {
|
|
14
|
-
popper: {};
|
|
15
|
-
};
|
|
16
13
|
};
|
package/dist/Popover-cjs.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
var tslib_es6 = require('./tslib.es6-cjs.js');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var classnames = require('classnames');
|
|
6
|
-
var ReactDOM = require('react-dom');
|
|
7
6
|
var floatingUi_react = require('./floating-ui.react-cjs.js');
|
|
8
7
|
var useRefocusOnActivator = require('./useRefocusOnActivator-cjs.js');
|
|
9
8
|
var AtlantisPortalContent = require('./AtlantisPortalContent-cjs.js');
|
|
@@ -56,14 +55,13 @@ const usePopover = ({ preferredPlacement, attachTo, open, }) => {
|
|
|
56
55
|
});
|
|
57
56
|
useRefocusOnActivator.useRefocusOnActivator_2(open);
|
|
58
57
|
return {
|
|
59
|
-
|
|
58
|
+
setFloatingElement: refs.setFloating,
|
|
60
59
|
setArrowElement,
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
floatingStyles: {
|
|
61
|
+
float: floatingStyles,
|
|
63
62
|
arrow: middlewareData.arrow,
|
|
64
63
|
},
|
|
65
64
|
placement,
|
|
66
|
-
attributes: { popper: {} },
|
|
67
65
|
};
|
|
68
66
|
};
|
|
69
67
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -82,7 +80,7 @@ const usePopoverStyles = () => {
|
|
|
82
80
|
};
|
|
83
81
|
|
|
84
82
|
const PopoverContext = React.createContext({
|
|
85
|
-
|
|
83
|
+
floatingStyles: { float: {} },
|
|
86
84
|
setArrowElement: () => {
|
|
87
85
|
// noop
|
|
88
86
|
},
|
|
@@ -91,7 +89,7 @@ function usePopoverContext() {
|
|
|
91
89
|
return React.useContext(PopoverContext);
|
|
92
90
|
}
|
|
93
91
|
function PopoverProvider({ children, preferredPlacement = "auto", attachTo, open, UNSAFE_className, UNSAFE_style, }) {
|
|
94
|
-
const {
|
|
92
|
+
const { setFloatingElement, setArrowElement, floatingStyles, placement } = usePopover({
|
|
95
93
|
preferredPlacement,
|
|
96
94
|
attachTo,
|
|
97
95
|
open,
|
|
@@ -100,18 +98,18 @@ function PopoverProvider({ children, preferredPlacement = "auto", attachTo, open
|
|
|
100
98
|
return null;
|
|
101
99
|
return (React.createElement(PopoverContext.Provider, { value: {
|
|
102
100
|
setArrowElement,
|
|
103
|
-
|
|
101
|
+
floatingStyles,
|
|
104
102
|
placement,
|
|
105
103
|
} },
|
|
106
|
-
React.createElement(PopoverWrapper, { UNSAFE_className: UNSAFE_className, UNSAFE_style: UNSAFE_style,
|
|
104
|
+
React.createElement(PopoverWrapper, { UNSAFE_className: UNSAFE_className, UNSAFE_style: UNSAFE_style, setFloatingElement: setFloatingElement, placement: placement }, children)));
|
|
107
105
|
}
|
|
108
|
-
function PopoverWrapper({ children,
|
|
106
|
+
function PopoverWrapper({ children, setFloatingElement, UNSAFE_className, UNSAFE_style, placement, }) {
|
|
109
107
|
const popoverStyles = usePopoverStyles();
|
|
110
|
-
const {
|
|
108
|
+
const { floatingStyles } = usePopoverContext();
|
|
111
109
|
const classes = classnames(popoverStyles.container, UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.container);
|
|
112
110
|
const content = (React.createElement(AtlantisPortalContent.AtlantisPortalContent, null,
|
|
113
|
-
React.createElement("div", { role: "dialog", "data-elevation": "elevated", ref:
|
|
114
|
-
return
|
|
111
|
+
React.createElement("div", { role: "dialog", "data-elevation": "elevated", ref: setFloatingElement, style: Object.assign(Object.assign({}, floatingStyles.float), UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.container), className: classes, "data-popover-placement": placement, "data-testid": "ATL-Popover-Container" }, children)));
|
|
112
|
+
return React.createElement(floatingUi_react.FloatingPortal, null, content);
|
|
115
113
|
}
|
|
116
114
|
|
|
117
115
|
function Popover({ onRequestClose, children, attachTo, open, preferredPlacement = "auto", UNSAFE_className, UNSAFE_style, }) {
|
|
@@ -122,8 +120,8 @@ function Popover({ onRequestClose, children, attachTo, open, preferredPlacement
|
|
|
122
120
|
}
|
|
123
121
|
Popover.Provider = PopoverProvider;
|
|
124
122
|
Popover.Arrow = function PopoverArrow({ UNSAFE_className, UNSAFE_style, }) {
|
|
125
|
-
var _a, _b
|
|
126
|
-
const { setArrowElement,
|
|
123
|
+
var _a, _b;
|
|
124
|
+
const { setArrowElement, floatingStyles, placement } = usePopoverContext();
|
|
127
125
|
const popoverStyles = usePopoverStyles();
|
|
128
126
|
const classes = classnames(popoverStyles.arrow, UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.arrow);
|
|
129
127
|
// the arrow will get positioned opposite to the placement side
|
|
@@ -134,11 +132,13 @@ Popover.Arrow = function PopoverArrow({ UNSAFE_className, UNSAFE_style, }) {
|
|
|
134
132
|
left: "right",
|
|
135
133
|
};
|
|
136
134
|
const staticSide = staticSideMap[placement];
|
|
135
|
+
const arrowX = (_a = floatingStyles.arrow) === null || _a === void 0 ? void 0 : _a.x;
|
|
136
|
+
const arrowY = (_b = floatingStyles.arrow) === null || _b === void 0 ? void 0 : _b.y;
|
|
137
137
|
const arrowStyles = {
|
|
138
138
|
position: "absolute",
|
|
139
139
|
// only left or top will be defined at a time
|
|
140
|
-
left:
|
|
141
|
-
top:
|
|
140
|
+
left: arrowX !== null && arrowX !== undefined ? `${arrowX}px` : "",
|
|
141
|
+
top: arrowY !== null && arrowY !== undefined ? `${arrowY}px` : "",
|
|
142
142
|
right: "",
|
|
143
143
|
bottom: "",
|
|
144
144
|
[staticSide]: "var(--popover--position--offset)",
|
package/dist/Popover-es.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { _ as __rest } from './tslib.es6-es.js';
|
|
2
2
|
import React__default, { useState, useMemo, createContext, useContext } from 'react';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
|
-
import
|
|
5
|
-
import { o as offset, s as shift, l as limitShift, g as autoPlacement, f as flip, a as arrow, u as useFloating, b as autoUpdate } from './floating-ui.react-es.js';
|
|
4
|
+
import { o as offset, s as shift, l as limitShift, k as autoPlacement, f as flip, a as arrow, u as useFloating, b as autoUpdate, F as FloatingPortal } from './floating-ui.react-es.js';
|
|
6
5
|
import { u as useRefocusOnActivator_2 } from './useRefocusOnActivator-es.js';
|
|
7
6
|
import { A as AtlantisPortalContent } from './AtlantisPortalContent-es.js';
|
|
8
7
|
import { B as ButtonDismiss } from './ButtonDismiss-es.js';
|
|
@@ -54,14 +53,13 @@ const usePopover = ({ preferredPlacement, attachTo, open, }) => {
|
|
|
54
53
|
});
|
|
55
54
|
useRefocusOnActivator_2(open);
|
|
56
55
|
return {
|
|
57
|
-
|
|
56
|
+
setFloatingElement: refs.setFloating,
|
|
58
57
|
setArrowElement,
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
floatingStyles: {
|
|
59
|
+
float: floatingStyles,
|
|
61
60
|
arrow: middlewareData.arrow,
|
|
62
61
|
},
|
|
63
62
|
placement,
|
|
64
|
-
attributes: { popper: {} },
|
|
65
63
|
};
|
|
66
64
|
};
|
|
67
65
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -80,7 +78,7 @@ const usePopoverStyles = () => {
|
|
|
80
78
|
};
|
|
81
79
|
|
|
82
80
|
const PopoverContext = createContext({
|
|
83
|
-
|
|
81
|
+
floatingStyles: { float: {} },
|
|
84
82
|
setArrowElement: () => {
|
|
85
83
|
// noop
|
|
86
84
|
},
|
|
@@ -89,7 +87,7 @@ function usePopoverContext() {
|
|
|
89
87
|
return useContext(PopoverContext);
|
|
90
88
|
}
|
|
91
89
|
function PopoverProvider({ children, preferredPlacement = "auto", attachTo, open, UNSAFE_className, UNSAFE_style, }) {
|
|
92
|
-
const {
|
|
90
|
+
const { setFloatingElement, setArrowElement, floatingStyles, placement } = usePopover({
|
|
93
91
|
preferredPlacement,
|
|
94
92
|
attachTo,
|
|
95
93
|
open,
|
|
@@ -98,18 +96,18 @@ function PopoverProvider({ children, preferredPlacement = "auto", attachTo, open
|
|
|
98
96
|
return null;
|
|
99
97
|
return (React__default.createElement(PopoverContext.Provider, { value: {
|
|
100
98
|
setArrowElement,
|
|
101
|
-
|
|
99
|
+
floatingStyles,
|
|
102
100
|
placement,
|
|
103
101
|
} },
|
|
104
|
-
React__default.createElement(PopoverWrapper, { UNSAFE_className: UNSAFE_className, UNSAFE_style: UNSAFE_style,
|
|
102
|
+
React__default.createElement(PopoverWrapper, { UNSAFE_className: UNSAFE_className, UNSAFE_style: UNSAFE_style, setFloatingElement: setFloatingElement, placement: placement }, children)));
|
|
105
103
|
}
|
|
106
|
-
function PopoverWrapper({ children,
|
|
104
|
+
function PopoverWrapper({ children, setFloatingElement, UNSAFE_className, UNSAFE_style, placement, }) {
|
|
107
105
|
const popoverStyles = usePopoverStyles();
|
|
108
|
-
const {
|
|
106
|
+
const { floatingStyles } = usePopoverContext();
|
|
109
107
|
const classes = classnames(popoverStyles.container, UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.container);
|
|
110
108
|
const content = (React__default.createElement(AtlantisPortalContent, null,
|
|
111
|
-
React__default.createElement("div", { role: "dialog", "data-elevation": "elevated", ref:
|
|
112
|
-
return
|
|
109
|
+
React__default.createElement("div", { role: "dialog", "data-elevation": "elevated", ref: setFloatingElement, style: Object.assign(Object.assign({}, floatingStyles.float), UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.container), className: classes, "data-popover-placement": placement, "data-testid": "ATL-Popover-Container" }, children)));
|
|
110
|
+
return React__default.createElement(FloatingPortal, null, content);
|
|
113
111
|
}
|
|
114
112
|
|
|
115
113
|
function Popover({ onRequestClose, children, attachTo, open, preferredPlacement = "auto", UNSAFE_className, UNSAFE_style, }) {
|
|
@@ -120,8 +118,8 @@ function Popover({ onRequestClose, children, attachTo, open, preferredPlacement
|
|
|
120
118
|
}
|
|
121
119
|
Popover.Provider = PopoverProvider;
|
|
122
120
|
Popover.Arrow = function PopoverArrow({ UNSAFE_className, UNSAFE_style, }) {
|
|
123
|
-
var _a, _b
|
|
124
|
-
const { setArrowElement,
|
|
121
|
+
var _a, _b;
|
|
122
|
+
const { setArrowElement, floatingStyles, placement } = usePopoverContext();
|
|
125
123
|
const popoverStyles = usePopoverStyles();
|
|
126
124
|
const classes = classnames(popoverStyles.arrow, UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.arrow);
|
|
127
125
|
// the arrow will get positioned opposite to the placement side
|
|
@@ -132,11 +130,13 @@ Popover.Arrow = function PopoverArrow({ UNSAFE_className, UNSAFE_style, }) {
|
|
|
132
130
|
left: "right",
|
|
133
131
|
};
|
|
134
132
|
const staticSide = staticSideMap[placement];
|
|
133
|
+
const arrowX = (_a = floatingStyles.arrow) === null || _a === void 0 ? void 0 : _a.x;
|
|
134
|
+
const arrowY = (_b = floatingStyles.arrow) === null || _b === void 0 ? void 0 : _b.y;
|
|
135
135
|
const arrowStyles = {
|
|
136
136
|
position: "absolute",
|
|
137
137
|
// only left or top will be defined at a time
|
|
138
|
-
left:
|
|
139
|
-
top:
|
|
138
|
+
left: arrowX !== null && arrowX !== undefined ? `${arrowX}px` : "",
|
|
139
|
+
top: arrowY !== null && arrowY !== undefined ? `${arrowY}px` : "",
|
|
140
140
|
right: "",
|
|
141
141
|
bottom: "",
|
|
142
142
|
[staticSide]: "var(--popover--position--offset)",
|
|
@@ -6029,4 +6029,4 @@ function useRole(context, props) {
|
|
|
6029
6029
|
} : {}, [enabled, reference, floating, item]);
|
|
6030
6030
|
}
|
|
6031
6031
|
|
|
6032
|
-
export { FloatingPortal as F, arrow as a, autoUpdate as b,
|
|
6032
|
+
export { FloatingPortal as F, arrow as a, autoUpdate as b, useDismiss as c, useInteractions as d, size as e, flip as f, useFloatingParentNodeId as g, useFloatingNodeId as h, FloatingTree as i, FloatingNode as j, autoPlacement as k, limitShift as l, useClick as m, useRole as n, offset as o, FloatingOverlay as p, FloatingFocusManager as q, shift as s, useFloating as u };
|
package/dist/index.cjs
CHANGED
|
@@ -12,6 +12,7 @@ var Heading = require('./Heading-cjs.js');
|
|
|
12
12
|
var Text = require('./Text-cjs.js');
|
|
13
13
|
var Icon = require('./Icon-cjs.js');
|
|
14
14
|
require('./useSafeLayoutEffect-cjs.js');
|
|
15
|
+
require('@jobber/design');
|
|
15
16
|
require('./useIsMounted-cjs.js');
|
|
16
17
|
var Avatar = require('./Avatar-cjs.js');
|
|
17
18
|
var Banner = require('./Banner-cjs.js');
|
|
@@ -36,6 +37,7 @@ var DataDump = require('./DataDump-cjs.js');
|
|
|
36
37
|
var DataList = require('./DataList-cjs.js');
|
|
37
38
|
var DataTable = require('./DataTable-cjs.js');
|
|
38
39
|
require('./useResizeObserver-cjs.js');
|
|
40
|
+
require('./DataTableTable-cjs.js');
|
|
39
41
|
var reactTable = require('@tanstack/react-table');
|
|
40
42
|
var DatePicker = require('./DatePicker-cjs.js');
|
|
41
43
|
var DescriptionList = require('./DescriptionList-cjs.js');
|
|
@@ -99,7 +101,6 @@ var showToast = require('./showToast-cjs.js');
|
|
|
99
101
|
var Tooltip = require('./Tooltip-cjs.js');
|
|
100
102
|
var Typography = require('./Typography-cjs.js');
|
|
101
103
|
require('framer-motion');
|
|
102
|
-
require('@jobber/design');
|
|
103
104
|
require('./_commonjsHelpers-cjs.js');
|
|
104
105
|
require('./identity-cjs.js');
|
|
105
106
|
require('./isTypedArray-cjs.js');
|
|
@@ -113,6 +114,7 @@ require('./tslib.es6-cjs.js');
|
|
|
113
114
|
require('./useDebounce-cjs.js');
|
|
114
115
|
require('./floating-ui.react-cjs.js');
|
|
115
116
|
require('react-dom');
|
|
117
|
+
require('./maxHeight-cjs.js');
|
|
116
118
|
require('./useOnKeyDown-cjs.js');
|
|
117
119
|
require('color');
|
|
118
120
|
require('react-router-dom');
|
package/dist/index.mjs
CHANGED
|
@@ -10,6 +10,7 @@ export { H as Heading } from './Heading-es.js';
|
|
|
10
10
|
export { T as Text } from './Text-es.js';
|
|
11
11
|
export { I as Icon } from './Icon-es.js';
|
|
12
12
|
import './useSafeLayoutEffect-es.js';
|
|
13
|
+
import '@jobber/design';
|
|
13
14
|
import './useIsMounted-es.js';
|
|
14
15
|
export { A as Avatar } from './Avatar-es.js';
|
|
15
16
|
export { B as Banner } from './Banner-es.js';
|
|
@@ -34,6 +35,7 @@ export { D as DataDump } from './DataDump-es.js';
|
|
|
34
35
|
export { D as DataList } from './DataList-es.js';
|
|
35
36
|
export { D as DataTable } from './DataTable-es.js';
|
|
36
37
|
import './useResizeObserver-es.js';
|
|
38
|
+
import './DataTableTable-es.js';
|
|
37
39
|
export { createColumnHelper } from '@tanstack/react-table';
|
|
38
40
|
export { D as DatePicker } from './DatePicker-es.js';
|
|
39
41
|
export { D as DescriptionList } from './DescriptionList-es.js';
|
|
@@ -97,7 +99,6 @@ export { T as Toast, s as showToast } from './showToast-es.js';
|
|
|
97
99
|
export { T as Tooltip } from './Tooltip-es.js';
|
|
98
100
|
export { T as Typography } from './Typography-es.js';
|
|
99
101
|
import 'framer-motion';
|
|
100
|
-
import '@jobber/design';
|
|
101
102
|
import './_commonjsHelpers-es.js';
|
|
102
103
|
import './identity-es.js';
|
|
103
104
|
import './isTypedArray-es.js';
|
|
@@ -111,6 +112,7 @@ import './tslib.es6-es.js';
|
|
|
111
112
|
import './useDebounce-es.js';
|
|
112
113
|
import './floating-ui.react-es.js';
|
|
113
114
|
import 'react-dom';
|
|
115
|
+
import './maxHeight-es.js';
|
|
114
116
|
import './useOnKeyDown-es.js';
|
|
115
117
|
import 'color';
|
|
116
118
|
import 'react-router-dom';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var design = require('@jobber/design');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Calculates the appropriate max height for floating elements based on available space.
|
|
7
|
+
*
|
|
8
|
+
* This utility encapsulates the common pattern of:
|
|
9
|
+
* - Using a preferred max height when space allows
|
|
10
|
+
* - Falling back to available height minus edge padding when constrained
|
|
11
|
+
*
|
|
12
|
+
* @param availableHeight - The available height from FloatingUI's size middleware
|
|
13
|
+
* @param options - Configuration for max height, and edge padding
|
|
14
|
+
* @returns The calculated max height in pixels
|
|
15
|
+
*/
|
|
16
|
+
function calculateMaxHeight(availableHeight, options) {
|
|
17
|
+
const { maxHeight, edgePadding = design.tokens["space-base"] } = options;
|
|
18
|
+
if (availableHeight > maxHeight) {
|
|
19
|
+
return maxHeight;
|
|
20
|
+
}
|
|
21
|
+
return Math.min(maxHeight, Math.max(availableHeight - edgePadding, 0));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.calculateMaxHeight = calculateMaxHeight;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { tokens } from '@jobber/design';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Calculates the appropriate max height for floating elements based on available space.
|
|
5
|
+
*
|
|
6
|
+
* This utility encapsulates the common pattern of:
|
|
7
|
+
* - Using a preferred max height when space allows
|
|
8
|
+
* - Falling back to available height minus edge padding when constrained
|
|
9
|
+
*
|
|
10
|
+
* @param availableHeight - The available height from FloatingUI's size middleware
|
|
11
|
+
* @param options - Configuration for max height, and edge padding
|
|
12
|
+
* @returns The calculated max height in pixels
|
|
13
|
+
*/
|
|
14
|
+
function calculateMaxHeight(availableHeight, options) {
|
|
15
|
+
const { maxHeight, edgePadding = tokens["space-base"] } = options;
|
|
16
|
+
if (availableHeight > maxHeight) {
|
|
17
|
+
return maxHeight;
|
|
18
|
+
}
|
|
19
|
+
return Math.min(maxHeight, Math.max(availableHeight - edgePadding, 0));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { calculateMaxHeight as c };
|