@react-fabric/core 1.0.0-beta.19 → 1.0.0-beta.21
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/components/panel/Panel.js +1 -1
- package/dist/cjs/overlays/flyout/Flyout.js +40 -42
- package/dist/cjs/overlays/modal/Modal.js +3 -4
- package/dist/esm/components/panel/Panel.js +1 -1
- package/dist/esm/overlays/flyout/Flyout.js +41 -43
- package/dist/esm/overlays/modal/Modal.js +4 -5
- package/dist/types/components/tabpanel/TabPanel.d.ts +3 -3
- package/dist/types/hooks/useOverlayService.d.ts +3 -3
- package/dist/types/index.d.ts +1 -0
- package/dist/types/overlays/flyout/Flyout.d.ts +3 -2
- package/dist/types/overlays/modal/Modal.d.ts +3 -2
- package/dist/types/types/index.d.ts +4 -1
- package/package.json +3 -3
- package/src/components/panel/Panel.tsx +1 -1
- package/src/components/tabpanel/TabPanel.tsx +3 -3
- package/src/hooks/useOverlayService.tsx +12 -4
- package/src/index.ts +1 -0
- package/src/overlays/flyout/Flyout.tsx +63 -62
- package/src/overlays/modal/Modal.tsx +11 -6
- package/src/types/index.ts +5 -9
|
@@ -91,7 +91,7 @@ var Panel = function Panel(_ref) {
|
|
|
91
91
|
className: classNames(titleClassName, "flex-1 select-none truncate", title && "py-1 first:px-2"),
|
|
92
92
|
children: title
|
|
93
93
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
94
|
-
className: "px-1",
|
|
94
|
+
className: "px-1 leading-none",
|
|
95
95
|
children: actions
|
|
96
96
|
}), hasTools && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
97
97
|
role: "none",
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
4
|
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
5
5
|
var react = require('@floating-ui/react');
|
|
6
|
+
var utilities = require('@react-fabric/utilities');
|
|
6
7
|
var classNames = require('classnames');
|
|
7
8
|
var react$1 = require('react');
|
|
8
9
|
var Animations = require('../../components/animations/Animations.js');
|
|
@@ -47,6 +48,7 @@ var Flyout = function Flyout(_ref) {
|
|
|
47
48
|
context = _useFloating.context;
|
|
48
49
|
var dismiss = react.useDismiss(context, {
|
|
49
50
|
outsidePressEvent: "mousedown",
|
|
51
|
+
outsidePress: !hideMask,
|
|
50
52
|
escapeKey: true
|
|
51
53
|
});
|
|
52
54
|
var role = react.useRole(context);
|
|
@@ -73,9 +75,7 @@ var Flyout = function Flyout(_ref) {
|
|
|
73
75
|
}, [onBeforeClose, onClose]);
|
|
74
76
|
react$1.useEffect(function () {
|
|
75
77
|
setTimeout(function () {
|
|
76
|
-
var _refs$floating$curren2;
|
|
77
78
|
refs.floating.current && (refs.floating.current.dataset.show = "true");
|
|
78
|
-
(_refs$floating$curren2 = refs.floating.current) === null || _refs$floating$curren2 === void 0 || (_refs$floating$curren2 = _refs$floating$curren2.querySelector('[role="dialog"]')) === null || _refs$floating$curren2 === void 0 || _refs$floating$curren2.focus();
|
|
79
79
|
}, 50);
|
|
80
80
|
}, []);
|
|
81
81
|
var tryClosing = react$1.useCallback(function (e) {
|
|
@@ -103,47 +103,45 @@ var Flyout = function Flyout(_ref) {
|
|
|
103
103
|
children: /*#__PURE__*/jsxRuntime.jsx(Wrapper, {
|
|
104
104
|
children: /*#__PURE__*/jsxRuntime.jsx(react.FloatingFocusManager, {
|
|
105
105
|
context: context,
|
|
106
|
-
children: /*#__PURE__*/jsxRuntime.jsx(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
children: /*#__PURE__*/jsxRuntime.jsxs(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
})]
|
|
138
|
-
}), loading && /*#__PURE__*/jsxRuntime.jsx(Animations.Loading, {}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
139
|
-
role: "dialog",
|
|
140
|
-
className: classNames(Flyout_module.flyoutBody, "flex-1 grid overflow-hidden"),
|
|
141
|
-
tabIndex: 0,
|
|
142
|
-
children: children
|
|
106
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
107
|
+
"data-align": align,
|
|
108
|
+
className: classNames(Flyout_module.flyout, "fixed inset-y-0 overflow-hidden flex flex-col flex-nowrap pointer-events-auto shadow-xl", align === "start" ? "start-0" : "end-0", size === "sm" && "w-[20rem]", size === "md" && "w-[40rem]", size === "lg" && "w-[60vw]", size === "xl" && "w-[80vw]"),
|
|
109
|
+
style: {
|
|
110
|
+
width: width,
|
|
111
|
+
minWidth: minWidth
|
|
112
|
+
},
|
|
113
|
+
onMouseUpCapture: tryClosing,
|
|
114
|
+
ref: refs.setFloating
|
|
115
|
+
}, getFloatingProps()), aria), aria), {}, {
|
|
116
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(HotKeyWrapper.HotKeyWrapper, {
|
|
117
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs(HeadFoot.Header, {
|
|
118
|
+
flex: true,
|
|
119
|
+
className: classNames(Flyout_module.flyoutHeader, headerClassName),
|
|
120
|
+
children: [utilities.isString(icon) && /*#__PURE__*/jsxRuntime.jsx(Icon.Icon, {
|
|
121
|
+
icon: icon,
|
|
122
|
+
bg: iconBg,
|
|
123
|
+
color: iconColor,
|
|
124
|
+
className: classNames(iconClassName, "p-1"),
|
|
125
|
+
rtlFlip: rtlFlip
|
|
126
|
+
}), /*#__PURE__*/react$1.isValidElement(icon) && icon, /*#__PURE__*/jsxRuntime.jsx("label", {
|
|
127
|
+
className: "flex-1 truncate py-2 px-1",
|
|
128
|
+
children: title
|
|
129
|
+
}), actions, /*#__PURE__*/jsxRuntime.jsx(Icon.Icon, {
|
|
130
|
+
"data-ref": "panelClose",
|
|
131
|
+
className: classNames(Flyout_module.panelAction, "cursor-pointer p-1 text-xl self-stretch"),
|
|
132
|
+
icon: icons.CoreIcons.close,
|
|
133
|
+
onClick: function onClick() {
|
|
134
|
+
return handleClose(false);
|
|
135
|
+
}
|
|
143
136
|
})]
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
|
|
137
|
+
}), loading && /*#__PURE__*/jsxRuntime.jsx(Animations.Loading, {}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
138
|
+
role: "dialog",
|
|
139
|
+
className: classNames(Flyout_module.flyoutBody, "flex-1 grid overflow-hidden"),
|
|
140
|
+
tabIndex: 0,
|
|
141
|
+
children: children
|
|
142
|
+
})]
|
|
143
|
+
})
|
|
144
|
+
}))
|
|
147
145
|
})
|
|
148
146
|
})
|
|
149
147
|
});
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
4
|
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
5
5
|
var react = require('@floating-ui/react');
|
|
6
|
+
var utilities = require('@react-fabric/utilities');
|
|
6
7
|
var classNames = require('classnames');
|
|
7
8
|
var react$1 = require('react');
|
|
8
9
|
var Animations = require('../../components/animations/Animations.js');
|
|
@@ -71,9 +72,7 @@ var Modal = function Modal(_ref) {
|
|
|
71
72
|
}, [onBeforeClose, onClose]);
|
|
72
73
|
react$1.useEffect(function () {
|
|
73
74
|
setTimeout(function () {
|
|
74
|
-
var _refs$floating$curren2;
|
|
75
75
|
refs.floating.current && (refs.floating.current.dataset.show = "true");
|
|
76
|
-
(_refs$floating$curren2 = refs.floating.current) === null || _refs$floating$curren2 === void 0 || (_refs$floating$curren2 = _refs$floating$curren2.querySelector("[role='dialog']")) === null || _refs$floating$curren2 === void 0 || _refs$floating$curren2.focus();
|
|
77
76
|
}, 50);
|
|
78
77
|
}, []);
|
|
79
78
|
return /*#__PURE__*/jsxRuntime.jsx(react.FloatingPortal, {
|
|
@@ -99,13 +98,13 @@ var Modal = function Modal(_ref) {
|
|
|
99
98
|
children: [/*#__PURE__*/jsxRuntime.jsxs(HeadFoot.Header, {
|
|
100
99
|
flex: true,
|
|
101
100
|
className: classNames(Modal_module.modalHeader, headerClassName),
|
|
102
|
-
children: [icon && /*#__PURE__*/jsxRuntime.jsx(Icon.Icon, {
|
|
101
|
+
children: [utilities.isString(icon) && /*#__PURE__*/jsxRuntime.jsx(Icon.Icon, {
|
|
103
102
|
icon: icon,
|
|
104
103
|
bg: iconBg,
|
|
105
104
|
color: iconColor,
|
|
106
105
|
className: classNames(iconClassName, "p-1"),
|
|
107
106
|
rtlFlip: rtlFlip
|
|
108
|
-
}), /*#__PURE__*/jsxRuntime.jsx("label", {
|
|
107
|
+
}), /*#__PURE__*/react$1.isValidElement(icon) && icon, /*#__PURE__*/jsxRuntime.jsx("label", {
|
|
109
108
|
className: "flex-1 truncate py-2 px-1",
|
|
110
109
|
children: title
|
|
111
110
|
}), actions, /*#__PURE__*/jsxRuntime.jsx(Icon.Icon, {
|
|
@@ -91,7 +91,7 @@ var Panel = function Panel(_ref) {
|
|
|
91
91
|
className: classNames(titleClassName, "flex-1 select-none truncate", title && "py-1 first:px-2"),
|
|
92
92
|
children: title
|
|
93
93
|
}), /*#__PURE__*/jsx("div", {
|
|
94
|
-
className: "px-1",
|
|
94
|
+
className: "px-1 leading-none",
|
|
95
95
|
children: actions
|
|
96
96
|
}), hasTools && /*#__PURE__*/jsxs("div", {
|
|
97
97
|
role: "none",
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
4
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
5
5
|
import { useFloating, useDismiss, useRole, useInteractions, FloatingOverlay, FloatingPortal, FloatingFocusManager } from '@floating-ui/react';
|
|
6
|
+
import { isString } from '@react-fabric/utilities';
|
|
6
7
|
import classNames from 'classnames';
|
|
7
|
-
import { useCallback, useEffect, Fragment } from 'react';
|
|
8
|
+
import { useCallback, useEffect, Fragment, isValidElement } from 'react';
|
|
8
9
|
import { Loading } from '../../components/animations/Animations.js';
|
|
9
10
|
import { Icon } from '../../components/icon/Icon.js';
|
|
10
11
|
import { Header } from '../../core/headfoot/HeadFoot.js';
|
|
@@ -47,6 +48,7 @@ var Flyout = function Flyout(_ref) {
|
|
|
47
48
|
context = _useFloating.context;
|
|
48
49
|
var dismiss = useDismiss(context, {
|
|
49
50
|
outsidePressEvent: "mousedown",
|
|
51
|
+
outsidePress: !hideMask,
|
|
50
52
|
escapeKey: true
|
|
51
53
|
});
|
|
52
54
|
var role = useRole(context);
|
|
@@ -73,9 +75,7 @@ var Flyout = function Flyout(_ref) {
|
|
|
73
75
|
}, [onBeforeClose, onClose]);
|
|
74
76
|
useEffect(function () {
|
|
75
77
|
setTimeout(function () {
|
|
76
|
-
var _refs$floating$curren2;
|
|
77
78
|
refs.floating.current && (refs.floating.current.dataset.show = "true");
|
|
78
|
-
(_refs$floating$curren2 = refs.floating.current) === null || _refs$floating$curren2 === void 0 || (_refs$floating$curren2 = _refs$floating$curren2.querySelector('[role="dialog"]')) === null || _refs$floating$curren2 === void 0 || _refs$floating$curren2.focus();
|
|
79
79
|
}, 50);
|
|
80
80
|
}, []);
|
|
81
81
|
var tryClosing = useCallback(function (e) {
|
|
@@ -103,47 +103,45 @@ var Flyout = function Flyout(_ref) {
|
|
|
103
103
|
children: /*#__PURE__*/jsx(Wrapper, {
|
|
104
104
|
children: /*#__PURE__*/jsx(FloatingFocusManager, {
|
|
105
105
|
context: context,
|
|
106
|
-
children: /*#__PURE__*/jsx(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
children: /*#__PURE__*/jsxs(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
})]
|
|
138
|
-
}), loading && /*#__PURE__*/jsx(Loading, {}), /*#__PURE__*/jsx("div", {
|
|
139
|
-
role: "dialog",
|
|
140
|
-
className: classNames(classes.flyoutBody, "flex-1 grid overflow-hidden"),
|
|
141
|
-
tabIndex: 0,
|
|
142
|
-
children: children
|
|
106
|
+
children: /*#__PURE__*/jsx("div", _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
107
|
+
"data-align": align,
|
|
108
|
+
className: classNames(classes.flyout, "fixed inset-y-0 overflow-hidden flex flex-col flex-nowrap pointer-events-auto shadow-xl", align === "start" ? "start-0" : "end-0", size === "sm" && "w-[20rem]", size === "md" && "w-[40rem]", size === "lg" && "w-[60vw]", size === "xl" && "w-[80vw]"),
|
|
109
|
+
style: {
|
|
110
|
+
width: width,
|
|
111
|
+
minWidth: minWidth
|
|
112
|
+
},
|
|
113
|
+
onMouseUpCapture: tryClosing,
|
|
114
|
+
ref: refs.setFloating
|
|
115
|
+
}, getFloatingProps()), aria), aria), {}, {
|
|
116
|
+
children: /*#__PURE__*/jsxs(HotKeyWrapper, {
|
|
117
|
+
children: [/*#__PURE__*/jsxs(Header, {
|
|
118
|
+
flex: true,
|
|
119
|
+
className: classNames(classes.flyoutHeader, headerClassName),
|
|
120
|
+
children: [isString(icon) && /*#__PURE__*/jsx(Icon, {
|
|
121
|
+
icon: icon,
|
|
122
|
+
bg: iconBg,
|
|
123
|
+
color: iconColor,
|
|
124
|
+
className: classNames(iconClassName, "p-1"),
|
|
125
|
+
rtlFlip: rtlFlip
|
|
126
|
+
}), /*#__PURE__*/isValidElement(icon) && icon, /*#__PURE__*/jsx("label", {
|
|
127
|
+
className: "flex-1 truncate py-2 px-1",
|
|
128
|
+
children: title
|
|
129
|
+
}), actions, /*#__PURE__*/jsx(Icon, {
|
|
130
|
+
"data-ref": "panelClose",
|
|
131
|
+
className: classNames(classes.panelAction, "cursor-pointer p-1 text-xl self-stretch"),
|
|
132
|
+
icon: CoreIcons.close,
|
|
133
|
+
onClick: function onClick() {
|
|
134
|
+
return handleClose(false);
|
|
135
|
+
}
|
|
143
136
|
})]
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
|
|
137
|
+
}), loading && /*#__PURE__*/jsx(Loading, {}), /*#__PURE__*/jsx("div", {
|
|
138
|
+
role: "dialog",
|
|
139
|
+
className: classNames(classes.flyoutBody, "flex-1 grid overflow-hidden"),
|
|
140
|
+
tabIndex: 0,
|
|
141
|
+
children: children
|
|
142
|
+
})]
|
|
143
|
+
})
|
|
144
|
+
}))
|
|
147
145
|
})
|
|
148
146
|
})
|
|
149
147
|
});
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
4
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
5
5
|
import { useFloating, useDismiss, useRole, useInteractions, FloatingPortal, FloatingOverlay, FloatingFocusManager } from '@floating-ui/react';
|
|
6
|
+
import { isString } from '@react-fabric/utilities';
|
|
6
7
|
import classNames from 'classnames';
|
|
7
|
-
import { useCallback, useEffect } from 'react';
|
|
8
|
+
import { useCallback, useEffect, isValidElement } from 'react';
|
|
8
9
|
import { Loading } from '../../components/animations/Animations.js';
|
|
9
10
|
import { Icon } from '../../components/icon/Icon.js';
|
|
10
11
|
import { Header } from '../../core/headfoot/HeadFoot.js';
|
|
@@ -71,9 +72,7 @@ var Modal = function Modal(_ref) {
|
|
|
71
72
|
}, [onBeforeClose, onClose]);
|
|
72
73
|
useEffect(function () {
|
|
73
74
|
setTimeout(function () {
|
|
74
|
-
var _refs$floating$curren2;
|
|
75
75
|
refs.floating.current && (refs.floating.current.dataset.show = "true");
|
|
76
|
-
(_refs$floating$curren2 = refs.floating.current) === null || _refs$floating$curren2 === void 0 || (_refs$floating$curren2 = _refs$floating$curren2.querySelector("[role='dialog']")) === null || _refs$floating$curren2 === void 0 || _refs$floating$curren2.focus();
|
|
77
76
|
}, 50);
|
|
78
77
|
}, []);
|
|
79
78
|
return /*#__PURE__*/jsx(FloatingPortal, {
|
|
@@ -99,13 +98,13 @@ var Modal = function Modal(_ref) {
|
|
|
99
98
|
children: [/*#__PURE__*/jsxs(Header, {
|
|
100
99
|
flex: true,
|
|
101
100
|
className: classNames(classes.modalHeader, headerClassName),
|
|
102
|
-
children: [icon && /*#__PURE__*/jsx(Icon, {
|
|
101
|
+
children: [isString(icon) && /*#__PURE__*/jsx(Icon, {
|
|
103
102
|
icon: icon,
|
|
104
103
|
bg: iconBg,
|
|
105
104
|
color: iconColor,
|
|
106
105
|
className: classNames(iconClassName, "p-1"),
|
|
107
106
|
rtlFlip: rtlFlip
|
|
108
|
-
}), /*#__PURE__*/jsx("label", {
|
|
107
|
+
}), /*#__PURE__*/isValidElement(icon) && icon, /*#__PURE__*/jsx("label", {
|
|
109
108
|
className: "flex-1 truncate py-2 px-1",
|
|
110
109
|
children: title
|
|
111
110
|
}), actions, /*#__PURE__*/jsx(Icon, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
2
|
import { type CallbackReturn, type ChildrenProp } from "../../types";
|
|
3
3
|
import { Tab } from "./Tab";
|
|
4
4
|
export interface TabPanelProps extends ChildrenProp<typeof Tab> {
|
|
@@ -33,11 +33,11 @@ export interface TabPanelProps extends ChildrenProp<typeof Tab> {
|
|
|
33
33
|
/**
|
|
34
34
|
* append element
|
|
35
35
|
*/
|
|
36
|
-
append?:
|
|
36
|
+
append?: ReactNode;
|
|
37
37
|
/**
|
|
38
38
|
* prepend element
|
|
39
39
|
*/
|
|
40
|
-
prepend?:
|
|
40
|
+
prepend?: ReactNode;
|
|
41
41
|
/**
|
|
42
42
|
* change handler
|
|
43
43
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
type OverlayComponent =
|
|
3
|
-
onClose: (args
|
|
1
|
+
import { type ElementType, type ReactNode } from "react";
|
|
2
|
+
type OverlayComponent = ElementType<{
|
|
3
|
+
onClose: (...args: AnyObject) => void;
|
|
4
4
|
[key: string]: AnyObject;
|
|
5
5
|
}>;
|
|
6
6
|
export declare const useOverlayService: (ModalOrFlyout: OverlayComponent) => [
|
package/dist/types/index.d.ts
CHANGED
|
@@ -15,5 +15,6 @@ export * from "./hooks/useResizeObserver";
|
|
|
15
15
|
export * from "./hooks/useStorage";
|
|
16
16
|
export { HotKey } from "./hotkeys/HotKey";
|
|
17
17
|
export { HotKeyLabel } from "./hotkeys/HotKeyLabel";
|
|
18
|
+
export { type ModalProps } from "./types";
|
|
18
19
|
export { CoreIcons } from "./types/icons";
|
|
19
20
|
export { ApplicationProvider, useApplicationContext, useGlobals, useNotificationService, } from "./context/Global";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { type ElementType } from "react";
|
|
2
2
|
import { type AriaProps, type CallbackReturn, type ChildrenProp, type Elements, type IconProps, type TestProps } from "../../types";
|
|
3
|
-
export interface FlyoutProps extends AriaProps, TestProps, IconProps, ChildrenProp {
|
|
3
|
+
export interface FlyoutProps extends AriaProps, TestProps, Omit<IconProps, "icon">, ChildrenProp {
|
|
4
|
+
icon?: string | ElementType<IconProps>;
|
|
4
5
|
/**
|
|
5
6
|
* flyout alignment
|
|
6
7
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { type ElementType } from "react";
|
|
2
2
|
import { type AriaProps, type CallbackReturn, type ChildrenProp, type Elements, type IconProps, type TestProps } from "../../types";
|
|
3
|
-
export interface ModalProps extends AriaProps, TestProps, IconProps, ChildrenProp {
|
|
3
|
+
export interface ModalProps extends AriaProps, TestProps, Omit<IconProps, "icon">, ChildrenProp {
|
|
4
|
+
icon?: string | ElementType<IconProps>;
|
|
4
5
|
/**
|
|
5
6
|
* header className
|
|
6
7
|
*/
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { type Placement } from "@floating-ui/react";
|
|
2
2
|
import { type JSXElementConstructor, type Ref } from "react";
|
|
3
|
+
export type ModalProps<P = unknown> = P & {
|
|
4
|
+
onClose: (...args: AnyObject) => void;
|
|
5
|
+
};
|
|
3
6
|
export type SizeType = "xs" | "sm" | "md" | "lg" | "xl";
|
|
4
7
|
export type SizeTypeWithZero = "xs" | "sm" | "md" | "lg" | "xl" | 0;
|
|
5
8
|
export type ColorType = "primary" | "accent" | "info" | "danger" | "success" | "warning";
|
|
@@ -54,7 +57,7 @@ export interface TestProps {
|
|
|
54
57
|
*/
|
|
55
58
|
"data-test-value"?: AnyObject;
|
|
56
59
|
}
|
|
57
|
-
export type Elements<T> = React.ReactElement<T> | React.
|
|
60
|
+
export type Elements<T> = React.ReactElement<T> | React.ReactNode;
|
|
58
61
|
export type AriaProps = React.AriaAttributes;
|
|
59
62
|
/**
|
|
60
63
|
* For wrapping components
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-fabric/core",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.21",
|
|
4
4
|
"description": "RUF: Core package",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@floating-ui/react": "^0.26.24",
|
|
39
|
-
"@react-fabric/utilities": "^1.0.0-beta.
|
|
39
|
+
"@react-fabric/utilities": "^1.0.0-beta.21",
|
|
40
40
|
"@tailwindcss/container-queries": "^0.1.1",
|
|
41
41
|
"@tailwindcss/forms": "^0.5.7",
|
|
42
42
|
"@tailwindcss/typography": "^0.5.13",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"node": ">=18.12.0",
|
|
57
57
|
"npm": ">=8.19.0"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "31c3d5c19bce7df519a62bd43efd1c9e6341be04"
|
|
60
60
|
}
|
|
@@ -25,7 +25,7 @@ import classNames from "classnames";
|
|
|
25
25
|
import {
|
|
26
26
|
Children,
|
|
27
27
|
cloneElement,
|
|
28
|
-
type
|
|
28
|
+
type ReactNode,
|
|
29
29
|
useCallback,
|
|
30
30
|
useEffect,
|
|
31
31
|
useMemo,
|
|
@@ -68,11 +68,11 @@ export interface TabPanelProps extends ChildrenProp<typeof Tab> {
|
|
|
68
68
|
/**
|
|
69
69
|
* append element
|
|
70
70
|
*/
|
|
71
|
-
append?:
|
|
71
|
+
append?: ReactNode;
|
|
72
72
|
/**
|
|
73
73
|
* prepend element
|
|
74
74
|
*/
|
|
75
|
-
prepend?:
|
|
75
|
+
prepend?: ReactNode;
|
|
76
76
|
/**
|
|
77
77
|
* change handler
|
|
78
78
|
*/
|
|
@@ -21,10 +21,15 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
useState,
|
|
26
|
+
type ComponentProps,
|
|
27
|
+
type ElementType,
|
|
28
|
+
type ReactNode,
|
|
29
|
+
} from "react";
|
|
25
30
|
|
|
26
|
-
type OverlayComponent =
|
|
27
|
-
onClose: (args
|
|
31
|
+
type OverlayComponent = ElementType<{
|
|
32
|
+
onClose: (...args: AnyObject) => void;
|
|
28
33
|
[key: string]: AnyObject;
|
|
29
34
|
}>;
|
|
30
35
|
|
|
@@ -36,7 +41,10 @@ export const useOverlayService = (
|
|
|
36
41
|
] => {
|
|
37
42
|
const [Overlay, setOverlay] = useState<ReactNode | null>(null);
|
|
38
43
|
|
|
39
|
-
const openOverlay = async ({
|
|
44
|
+
const openOverlay = async ({
|
|
45
|
+
onClose,
|
|
46
|
+
...props
|
|
47
|
+
}: ComponentProps<typeof ModalOrFlyout> = {}) => {
|
|
40
48
|
return await new Promise((resolve) => {
|
|
41
49
|
const handleClose = (args: AnyObject) => {
|
|
42
50
|
setOverlay(null);
|
package/src/index.ts
CHANGED
|
@@ -30,11 +30,14 @@ import {
|
|
|
30
30
|
useInteractions,
|
|
31
31
|
useRole,
|
|
32
32
|
} from "@floating-ui/react";
|
|
33
|
+
import { isString } from "@react-fabric/utilities";
|
|
33
34
|
import classNames from "classnames";
|
|
34
35
|
import {
|
|
35
36
|
Fragment,
|
|
37
|
+
isValidElement,
|
|
36
38
|
useCallback,
|
|
37
39
|
useEffect,
|
|
40
|
+
type ElementType,
|
|
38
41
|
type PropsWithChildren,
|
|
39
42
|
} from "react";
|
|
40
43
|
import { Loading } from "../../components/animations/Animations";
|
|
@@ -55,8 +58,9 @@ import classes from "./Flyout.module.css";
|
|
|
55
58
|
export interface FlyoutProps
|
|
56
59
|
extends AriaProps,
|
|
57
60
|
TestProps,
|
|
58
|
-
IconProps,
|
|
61
|
+
Omit<IconProps, "icon">,
|
|
59
62
|
ChildrenProp {
|
|
63
|
+
icon?: string | ElementType<IconProps>;
|
|
60
64
|
/**
|
|
61
65
|
* flyout alignment
|
|
62
66
|
*/
|
|
@@ -140,6 +144,7 @@ export const Flyout = ({
|
|
|
140
144
|
});
|
|
141
145
|
const dismiss = useDismiss(context, {
|
|
142
146
|
outsidePressEvent: "mousedown",
|
|
147
|
+
outsidePress: !hideMask,
|
|
143
148
|
escapeKey: true,
|
|
144
149
|
});
|
|
145
150
|
const role = useRole(context);
|
|
@@ -173,9 +178,6 @@ export const Flyout = ({
|
|
|
173
178
|
useEffect(() => {
|
|
174
179
|
setTimeout(() => {
|
|
175
180
|
refs.floating.current && (refs.floating.current.dataset.show = "true");
|
|
176
|
-
refs.floating.current
|
|
177
|
-
?.querySelector<HTMLElement>('[role="dialog"]')
|
|
178
|
-
?.focus();
|
|
179
181
|
}, 50);
|
|
180
182
|
}, []);
|
|
181
183
|
|
|
@@ -214,68 +216,67 @@ export const Flyout = ({
|
|
|
214
216
|
<FloatingPortal>
|
|
215
217
|
<Wrapper>
|
|
216
218
|
<FloatingFocusManager context={context}>
|
|
217
|
-
<
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
>
|
|
239
|
-
<
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
{icon && (
|
|
245
|
-
<Icon
|
|
246
|
-
icon={icon}
|
|
247
|
-
bg={iconBg}
|
|
248
|
-
color={iconColor}
|
|
249
|
-
className={classNames(iconClassName, "p-1")}
|
|
250
|
-
rtlFlip={rtlFlip}
|
|
251
|
-
/>
|
|
252
|
-
)}
|
|
253
|
-
<label className="flex-1 truncate py-2 px-1">{title}</label>
|
|
254
|
-
{actions}
|
|
219
|
+
<div
|
|
220
|
+
data-align={align}
|
|
221
|
+
className={classNames(
|
|
222
|
+
classes.flyout,
|
|
223
|
+
"fixed inset-y-0 overflow-hidden flex flex-col flex-nowrap pointer-events-auto shadow-xl",
|
|
224
|
+
align === "start" ? "start-0" : "end-0",
|
|
225
|
+
size === "sm" && "w-[20rem]",
|
|
226
|
+
size === "md" && "w-[40rem]",
|
|
227
|
+
size === "lg" && "w-[60vw]",
|
|
228
|
+
size === "xl" && "w-[80vw]",
|
|
229
|
+
)}
|
|
230
|
+
style={{
|
|
231
|
+
width,
|
|
232
|
+
minWidth,
|
|
233
|
+
}}
|
|
234
|
+
onMouseUpCapture={tryClosing}
|
|
235
|
+
ref={refs.setFloating}
|
|
236
|
+
{...getFloatingProps()}
|
|
237
|
+
{...aria}
|
|
238
|
+
{...aria}
|
|
239
|
+
>
|
|
240
|
+
<HotKeyWrapper>
|
|
241
|
+
<Header
|
|
242
|
+
flex
|
|
243
|
+
className={classNames(classes.flyoutHeader, headerClassName)}
|
|
244
|
+
>
|
|
245
|
+
{isString(icon) && (
|
|
255
246
|
<Icon
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
icon={CoreIcons.close}
|
|
262
|
-
onClick={() => handleClose(false)}
|
|
247
|
+
icon={icon}
|
|
248
|
+
bg={iconBg}
|
|
249
|
+
color={iconColor}
|
|
250
|
+
className={classNames(iconClassName, "p-1")}
|
|
251
|
+
rtlFlip={rtlFlip}
|
|
263
252
|
/>
|
|
264
|
-
|
|
265
|
-
{
|
|
266
|
-
<
|
|
267
|
-
|
|
253
|
+
)}
|
|
254
|
+
{isValidElement(icon) && icon}
|
|
255
|
+
<label className="flex-1 truncate py-2 px-1">{title}</label>
|
|
256
|
+
{actions}
|
|
257
|
+
<Icon
|
|
258
|
+
data-ref="panelClose"
|
|
268
259
|
className={classNames(
|
|
269
|
-
classes.
|
|
270
|
-
"
|
|
260
|
+
classes.panelAction,
|
|
261
|
+
"cursor-pointer p-1 text-xl self-stretch",
|
|
271
262
|
)}
|
|
272
|
-
{
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
263
|
+
icon={CoreIcons.close}
|
|
264
|
+
onClick={() => handleClose(false)}
|
|
265
|
+
/>
|
|
266
|
+
</Header>
|
|
267
|
+
{loading && <Loading />}
|
|
268
|
+
<div
|
|
269
|
+
role="dialog"
|
|
270
|
+
className={classNames(
|
|
271
|
+
classes.flyoutBody,
|
|
272
|
+
"flex-1 grid overflow-hidden",
|
|
273
|
+
)}
|
|
274
|
+
{...({ tabIndex: 0 } as AnyObject)}
|
|
275
|
+
>
|
|
276
|
+
{children}
|
|
277
|
+
</div>
|
|
278
|
+
</HotKeyWrapper>
|
|
279
|
+
</div>
|
|
279
280
|
</FloatingFocusManager>
|
|
280
281
|
</Wrapper>
|
|
281
282
|
</FloatingPortal>
|
|
@@ -30,8 +30,14 @@ import {
|
|
|
30
30
|
useInteractions,
|
|
31
31
|
useRole,
|
|
32
32
|
} from "@floating-ui/react";
|
|
33
|
+
import { isString } from "@react-fabric/utilities";
|
|
33
34
|
import classNames from "classnames";
|
|
34
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
type ElementType,
|
|
37
|
+
isValidElement,
|
|
38
|
+
useCallback,
|
|
39
|
+
useEffect,
|
|
40
|
+
} from "react";
|
|
35
41
|
import { Loading } from "../../components/animations/Animations";
|
|
36
42
|
import { Icon } from "../../components/icon/Icon";
|
|
37
43
|
import { Header } from "../../core/headfoot/HeadFoot";
|
|
@@ -50,8 +56,9 @@ import classes from "./Modal.module.css";
|
|
|
50
56
|
export interface ModalProps
|
|
51
57
|
extends AriaProps,
|
|
52
58
|
TestProps,
|
|
53
|
-
IconProps,
|
|
59
|
+
Omit<IconProps, "icon">,
|
|
54
60
|
ChildrenProp {
|
|
61
|
+
icon?: string | ElementType<IconProps>;
|
|
55
62
|
/**
|
|
56
63
|
* header className
|
|
57
64
|
*/
|
|
@@ -163,9 +170,6 @@ export const Modal = ({
|
|
|
163
170
|
useEffect(() => {
|
|
164
171
|
setTimeout(() => {
|
|
165
172
|
refs.floating.current && (refs.floating.current.dataset.show = "true");
|
|
166
|
-
refs.floating.current
|
|
167
|
-
?.querySelector<HTMLElement>("[role='dialog']")
|
|
168
|
-
?.focus();
|
|
169
173
|
}, 50);
|
|
170
174
|
}, []);
|
|
171
175
|
|
|
@@ -203,7 +207,7 @@ export const Modal = ({
|
|
|
203
207
|
flex
|
|
204
208
|
className={classNames(classes.modalHeader, headerClassName)}
|
|
205
209
|
>
|
|
206
|
-
{icon && (
|
|
210
|
+
{isString(icon) && (
|
|
207
211
|
<Icon
|
|
208
212
|
icon={icon}
|
|
209
213
|
bg={iconBg}
|
|
@@ -212,6 +216,7 @@ export const Modal = ({
|
|
|
212
216
|
rtlFlip={rtlFlip}
|
|
213
217
|
/>
|
|
214
218
|
)}
|
|
219
|
+
{isValidElement(icon) && icon}
|
|
215
220
|
<label className="flex-1 truncate py-2 px-1">{title}</label>
|
|
216
221
|
{actions}
|
|
217
222
|
<Icon
|
package/src/types/index.ts
CHANGED
|
@@ -25,6 +25,10 @@
|
|
|
25
25
|
import { type Placement } from "@floating-ui/react";
|
|
26
26
|
import { type JSXElementConstructor, type Ref } from "react";
|
|
27
27
|
|
|
28
|
+
export type ModalProps<P = unknown> = P & {
|
|
29
|
+
onClose: (...args: AnyObject) => void;
|
|
30
|
+
};
|
|
31
|
+
|
|
28
32
|
export type SizeType = "xs" | "sm" | "md" | "lg" | "xl";
|
|
29
33
|
|
|
30
34
|
export type SizeTypeWithZero = "xs" | "sm" | "md" | "lg" | "xl" | 0;
|
|
@@ -122,15 +126,7 @@ export interface TestProps {
|
|
|
122
126
|
"data-test-value"?: AnyObject;
|
|
123
127
|
}
|
|
124
128
|
|
|
125
|
-
export type Elements<T> =
|
|
126
|
-
| React.ReactElement<T>
|
|
127
|
-
| React.ReactPortal
|
|
128
|
-
| React.ReactNode
|
|
129
|
-
| string
|
|
130
|
-
| number
|
|
131
|
-
| boolean
|
|
132
|
-
| null
|
|
133
|
-
| undefined;
|
|
129
|
+
export type Elements<T> = React.ReactElement<T> | React.ReactNode;
|
|
134
130
|
|
|
135
131
|
export type AriaProps = React.AriaAttributes;
|
|
136
132
|
|