@apia/components 3.0.21 → 3.0.22
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/index.d.ts +5 -0
- package/dist/index.js +28 -10
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -200,6 +200,9 @@ declare const Modal: React__default.ForwardRefExoticComponent<{
|
|
|
200
200
|
} & Pick<IDialogHeader, "hideCloseButton"> & React__default.RefAttributes<HTMLDivElement>>;
|
|
201
201
|
|
|
202
202
|
type TOpenModal = Pick<TModal, 'NavBar' | 'Portal' | 'children' | 'className' | 'hideCloseButton' | 'initialFocusGetter' | 'initialFocusConfiguration' | 'maxWidth' | 'noHeader' | 'onExited' | 'shouldCloseOnEsc' | 'shouldCloseOnOverlayClick' | 'size' | 'stretch' | 'title' | 'variant' | 'draggable' | 'onClose' | 'onDragStart' | 'defaultPosition'> & {
|
|
203
|
+
/**
|
|
204
|
+
* This id may be used to close the modal.
|
|
205
|
+
*/
|
|
203
206
|
id?: string;
|
|
204
207
|
children?: React__default.ReactNode;
|
|
205
208
|
confirmProps?: Omit<IConfirm, 'onConfirmOk' | 'onConfirmCancel' | 'children'>;
|
|
@@ -236,6 +239,7 @@ declare class ApiaUtilModalHandler {
|
|
|
236
239
|
declare class ApiaUtilModals {
|
|
237
240
|
#private;
|
|
238
241
|
constructor();
|
|
242
|
+
close(id: string): void;
|
|
239
243
|
open(props: TOpenModal): ApiaUtilModalHandler;
|
|
240
244
|
Component: () => React$1.JSX.Element;
|
|
241
245
|
}
|
|
@@ -626,6 +630,7 @@ type TSubmenu = {
|
|
|
626
630
|
items: TMenuItems;
|
|
627
631
|
};
|
|
628
632
|
type TMenuItem = (MenuItemProps & {
|
|
633
|
+
icon?: TIconName;
|
|
629
634
|
key: string;
|
|
630
635
|
}) | 'separator' | TSubmenu;
|
|
631
636
|
type TMenuItems = TMenuItem[];
|
package/dist/index.js
CHANGED
|
@@ -9,10 +9,10 @@ import { Box, getVariant, useBreakpointIndex, Close, responsive, spacing, Headin
|
|
|
9
9
|
import { uniqueId as uniqueId$1, defaultNotifier, NotificationsList } from '@apia/notifications';
|
|
10
10
|
import ReactFocusLock, { FreeFocusInside } from 'react-focus-lock';
|
|
11
11
|
import { useBreakpointIndex as useBreakpointIndex$1 } from '@theme-ui/match-media';
|
|
12
|
+
import { isIconName, Icon as Icon$1, icons } from '@apia/icons';
|
|
12
13
|
import { useMenuState, ControlledMenu, MenuItem, MenuDivider, SubMenu } from '@szhsin/react-menu';
|
|
13
14
|
import { makeAutoObservable, observable, reaction } from 'mobx';
|
|
14
15
|
import { shallowEqual } from '@apia/store';
|
|
15
|
-
import { isIconName, Icon as Icon$1, icons } from '@apia/icons';
|
|
16
16
|
import AnimateHeight from 'react-animate-height';
|
|
17
17
|
import { useUpdateEffect as useUpdateEffect$1 } from 'ahooks';
|
|
18
18
|
import dayjs from 'dayjs';
|
|
@@ -1349,7 +1349,8 @@ Modal.displayName = "Modal";
|
|
|
1349
1349
|
const OpenModal = (props) => {
|
|
1350
1350
|
const modalProps = useModal({
|
|
1351
1351
|
isDefaultOpen: true,
|
|
1352
|
-
onExited: props.onExited
|
|
1352
|
+
onExited: props.onExited,
|
|
1353
|
+
onClose: props.onClose
|
|
1353
1354
|
});
|
|
1354
1355
|
const previousOpenProp = usePrevious(props.isOpen);
|
|
1355
1356
|
if (previousOpenProp.current !== props.isOpen && !props.isOpen) {
|
|
@@ -1363,6 +1364,10 @@ const OpenModal = (props) => {
|
|
|
1363
1364
|
{
|
|
1364
1365
|
...props,
|
|
1365
1366
|
...modalProps,
|
|
1367
|
+
onClose: () => {
|
|
1368
|
+
modalProps.onClose?.();
|
|
1369
|
+
props.onClose?.();
|
|
1370
|
+
},
|
|
1366
1371
|
onExited: () => {
|
|
1367
1372
|
props.onClose?.();
|
|
1368
1373
|
if (!hasConfirmed.current) {
|
|
@@ -1451,6 +1456,7 @@ class ApiaUtilModals {
|
|
|
1451
1456
|
{
|
|
1452
1457
|
...ev,
|
|
1453
1458
|
isOpen: true,
|
|
1459
|
+
onClose: ev.onClose,
|
|
1454
1460
|
onExited: () => {
|
|
1455
1461
|
ev.onExited?.();
|
|
1456
1462
|
setModals(
|
|
@@ -1489,6 +1495,9 @@ class ApiaUtilModals {
|
|
|
1489
1495
|
this.open(cevent.detail);
|
|
1490
1496
|
});
|
|
1491
1497
|
}
|
|
1498
|
+
close(id) {
|
|
1499
|
+
__privateGet$8(this, _emitter$4).emit("close", id);
|
|
1500
|
+
}
|
|
1492
1501
|
open(props) {
|
|
1493
1502
|
const id = props.id ?? `modal_${__privateWrapper$2(this, _maxId$1)._++}`;
|
|
1494
1503
|
__privateGet$8(this, _emitter$4).emit("open", { ...props, id });
|
|
@@ -3062,19 +3071,23 @@ function calculateTooltipPosition({
|
|
|
3062
3071
|
const availableTopSpace = actualAnchorPoint.top;
|
|
3063
3072
|
const availableLeftSpace = actualAnchorPoint.left;
|
|
3064
3073
|
const availableRightSpace = window.innerWidth - actualAnchorPoint.left;
|
|
3065
|
-
const isEnoughToRight = (minSize?.width ?? 0) <= availableRightSpace;
|
|
3066
|
-
const isEnoughToLeft = (minSize?.width ?? 0) <= availableLeftSpace;
|
|
3067
|
-
const isEnoughToBottom = (minSize?.height ?? 0) <= availableBottomSpace;
|
|
3068
|
-
const isEnoughToTop = (minSize?.height ?? 0) <= availableTopSpace;
|
|
3074
|
+
const isEnoughToRight = ((preferredSize?.width !== "auto" ? preferredSize?.width : void 0) ?? minSize?.width ?? 0) <= availableRightSpace;
|
|
3075
|
+
const isEnoughToLeft = ((preferredSize?.width !== "auto" ? preferredSize?.width : void 0) ?? minSize?.width ?? 0) <= availableLeftSpace;
|
|
3076
|
+
const isEnoughToBottom = ((preferredSize?.height !== "auto" ? preferredSize?.height : void 0) ?? minSize?.height ?? 0) <= availableBottomSpace;
|
|
3077
|
+
const isEnoughToTop = ((preferredSize?.height !== "auto" ? preferredSize?.height : void 0) ?? minSize?.height ?? 0) <= availableTopSpace;
|
|
3069
3078
|
const preferredWidth = preferredSize.width === "auto" ? Infinity : preferredSize.width;
|
|
3070
3079
|
const preferredHeight = preferredSize.height === "auto" ? Infinity : preferredSize.height;
|
|
3071
3080
|
const position = {
|
|
3072
3081
|
"& > *": {
|
|
3073
3082
|
width: "100%",
|
|
3074
|
-
height: "100%"
|
|
3083
|
+
height: "100%",
|
|
3084
|
+
overflow: "auto"
|
|
3075
3085
|
},
|
|
3076
|
-
|
|
3077
|
-
|
|
3086
|
+
display: "flex",
|
|
3087
|
+
flexDirection: "column",
|
|
3088
|
+
overflow: "hidden",
|
|
3089
|
+
width: preferredSize.width === "auto" ? "auto" : void 0,
|
|
3090
|
+
height: preferredSize.height === "auto" ? "auto" : void 0
|
|
3078
3091
|
};
|
|
3079
3092
|
if (preferredOrientationX === "left") {
|
|
3080
3093
|
if (isEnoughToLeft) {
|
|
@@ -3473,7 +3486,12 @@ class ApiaUtilMenu {
|
|
|
3473
3486
|
if (isSubmenu(current)) {
|
|
3474
3487
|
return /* @__PURE__ */ jsx(SubMenu, { label: current.label, children: __privateGet$4(this, _RenderMenu).call(this, current) }, `submenu${__privateWrapper(this, _maxId)._++}`);
|
|
3475
3488
|
}
|
|
3476
|
-
|
|
3489
|
+
const children = current.icon ? /* @__PURE__ */ jsxs(Box, { className: "withIcon", children: [
|
|
3490
|
+
/* @__PURE__ */ jsx(Icon$1, { name: current.icon, title: current.title }),
|
|
3491
|
+
" ",
|
|
3492
|
+
current.children
|
|
3493
|
+
] }) : current.children;
|
|
3494
|
+
return /* @__PURE__ */ createElement(MenuItem, { ...current, key: current.key }, children);
|
|
3477
3495
|
}) });
|
|
3478
3496
|
});
|
|
3479
3497
|
__publicField$8(this, "Component", () => {
|