@react-fabric/core 1.0.0-beta.61 → 1.0.0-beta.62
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/css/components/_breadcrumbs.css +2 -0
- package/css/components/_button.css +8 -2
- package/css/components/_modal.css +2 -2
- package/css/core/_theme.css +1 -1
- package/css/reset/_reset.css +6 -2
- package/dist/cjs/components/button/Button.js +1 -1
- package/dist/cjs/components/dropdown/Dropdown.js +13 -1
- package/dist/cjs/components/icon/Icon.js +24 -24
- package/dist/cjs/components/menu/Menu.js +4 -3
- package/dist/cjs/components/menu/MenuItem.js +1 -1
- package/dist/cjs/components/navigator/Navigator.js +2 -2
- package/dist/cjs/components/tabpanel/TabPanel.js +3 -2
- package/dist/cjs/core/theme/ThemeProvider.js +3 -2
- package/dist/cjs/hooks/useNavigator.js +9 -8
- package/dist/cjs/hooks/useOverlayService.js +34 -13
- package/dist/cjs/i18n/index.js +4 -4
- package/dist/cjs/index.js +1 -0
- package/dist/esm/components/button/Button.js +1 -1
- package/dist/esm/components/dropdown/Dropdown.js +14 -2
- package/dist/esm/components/icon/Icon.js +24 -24
- package/dist/esm/components/menu/Menu.js +4 -3
- package/dist/esm/components/menu/MenuItem.js +1 -1
- package/dist/esm/components/navigator/Navigator.js +2 -2
- package/dist/esm/components/tabpanel/TabPanel.js +3 -2
- package/dist/esm/core/theme/ThemeProvider.js +3 -2
- package/dist/esm/hooks/useNavigator.js +10 -9
- package/dist/esm/hooks/useOverlayService.js +35 -14
- package/dist/esm/i18n/index.js +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/types/components/index.d.ts +2 -2
- package/dist/types/components/menu/types.d.ts +6 -1
- package/dist/types/components/navigator/Navigator.d.ts +6 -0
- package/dist/types/core/theme/ThemeProvider.d.ts +2 -2
- package/dist/types/hooks/useOverlayService.d.ts +3 -5
- package/package.json +3 -3
- package/src/components/button/Button.tsx +3 -1
- package/src/components/dropdown/Dropdown.tsx +23 -6
- package/src/components/icon/Icon.tsx +22 -22
- package/src/components/index.ts +4 -3
- package/src/components/menu/Menu.tsx +3 -2
- package/src/components/menu/MenuItem.tsx +1 -1
- package/src/components/menu/types.ts +6 -1
- package/src/components/navigator/Navigator.tsx +9 -2
- package/src/components/tabpanel/TabPanel.tsx +2 -1
- package/src/core/theme/ThemeProvider.tsx +4 -2
- package/src/hooks/useNavigator.tsx +10 -11
- package/src/hooks/useOverlayService.tsx +29 -16
- package/src/i18n/index.ts +2 -2
- /package/dist/cjs/i18n/{ar.json.js → ar/core.json.js} +0 -0
- /package/dist/cjs/i18n/{en.json.js → en/core.json.js} +0 -0
- /package/dist/esm/i18n/{ar.json.js → ar/core.json.js} +0 -0
- /package/dist/esm/i18n/{en.json.js → en/core.json.js} +0 -0
- /package/src/i18n/{ar.json → ar/core.json} +0 -0
- /package/src/i18n/{en.json → en/core.json} +0 -0
|
@@ -21,7 +21,7 @@
|
|
|
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 { useCallback, useMemo,
|
|
24
|
+
import { useCallback, useMemo, useState } from "react";
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Custom hook to manage navigation through a list of items.
|
|
@@ -43,19 +43,18 @@ import { useCallback, useMemo, useRef, useState } from "react";
|
|
|
43
43
|
*/
|
|
44
44
|
export const useNavigator = (totalCount = 0, defaultIndex = 0) => {
|
|
45
45
|
const [currentIndex, setCurrentIndex] = useState(defaultIndex);
|
|
46
|
-
const refCurrent = useRef(defaultIndex);
|
|
47
46
|
|
|
48
47
|
const onNavigate = useCallback(
|
|
49
48
|
(dir: 1 | -1) => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
49
|
+
setCurrentIndex((prevValue) => {
|
|
50
|
+
if (dir === -1) {
|
|
51
|
+
return prevValue > 0 ? prevValue - 1 : totalCount - 1;
|
|
52
|
+
}
|
|
53
|
+
if (dir === 1) {
|
|
54
|
+
return prevValue + 1 < totalCount ? prevValue + 1 : 0;
|
|
55
|
+
}
|
|
56
|
+
return prevValue;
|
|
57
|
+
});
|
|
59
58
|
},
|
|
60
59
|
[totalCount],
|
|
61
60
|
);
|
|
@@ -21,10 +21,11 @@
|
|
|
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 { useRef, useState } from "react";
|
|
25
25
|
import { type ModalProps } from "../types";
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
// return the blank function since state functionality will execute if the value is function
|
|
28
|
+
const EMPTY_FC = () => () => null;
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
31
|
* Hook to manage overlay components like modals or flyouts.
|
|
@@ -36,7 +37,8 @@ type OverlayComponent = ElementType<ModalProps<AnyObject>>;
|
|
|
36
37
|
* of the overlay when it is closed, allowing you to handle the result in a controlled manner.
|
|
37
38
|
*
|
|
38
39
|
* @param ModalOrFlyout - The component to be used as an overlay.
|
|
39
|
-
* @
|
|
40
|
+
* @param toggleOpen - If true, calling `openOverlay` while an overlay is already open will close the existing one instead of opening a new one.
|
|
41
|
+
* @returns An array containing the current overlay, a function to open it, and a boolean indicating if the overlay is open.
|
|
40
42
|
*
|
|
41
43
|
* @example
|
|
42
44
|
* ```jsx
|
|
@@ -50,27 +52,38 @@ type OverlayComponent = ElementType<ModalProps<AnyObject>>;
|
|
|
50
52
|
* <Overlay />
|
|
51
53
|
* ```
|
|
52
54
|
*/
|
|
53
|
-
export const useOverlayService = (
|
|
54
|
-
ModalOrFlyout:
|
|
55
|
+
export const useOverlayService = <T extends AnyObject = AnyObject>(
|
|
56
|
+
ModalOrFlyout: React.FunctionComponent<ModalProps<T>>,
|
|
55
57
|
): [
|
|
56
|
-
Overlay: React.
|
|
57
|
-
openOverlay: (props?:
|
|
58
|
+
Overlay: React.FunctionComponent<Partial<T>>,
|
|
59
|
+
openOverlay: (props?: Partial<T>) => Promise<AnyObject>,
|
|
60
|
+
closeOverlay: ((args?: AnyObject) => void) | null,
|
|
58
61
|
] => {
|
|
59
|
-
const [Overlay, setOverlay] =
|
|
62
|
+
const [Overlay, setOverlay] =
|
|
63
|
+
useState<React.FunctionComponent<Partial<T>>>(EMPTY_FC);
|
|
60
64
|
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
const existingOpenPromise = useRef<AnyObject | null>(null);
|
|
66
|
+
const openOverlay = async ({ onClose, ...outerProps }: AnyObject = {}) => {
|
|
67
|
+
if (existingOpenPromise.current) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
65
70
|
return await new Promise((resolve) => {
|
|
66
|
-
|
|
67
|
-
setOverlay(
|
|
71
|
+
existingOpenPromise.current = (args: AnyObject) => {
|
|
72
|
+
setOverlay(EMPTY_FC);
|
|
68
73
|
resolve(args);
|
|
69
74
|
onClose?.(args);
|
|
75
|
+
existingOpenPromise.current = null;
|
|
70
76
|
};
|
|
71
|
-
|
|
77
|
+
// eslint-disable-next-line react/display-name
|
|
78
|
+
setOverlay(() => (overrideProps: Partial<T>) => (
|
|
79
|
+
<ModalOrFlyout
|
|
80
|
+
{...outerProps}
|
|
81
|
+
{...(overrideProps as any)}
|
|
82
|
+
onClose={existingOpenPromise.current}
|
|
83
|
+
/>
|
|
84
|
+
));
|
|
72
85
|
});
|
|
73
86
|
};
|
|
74
87
|
|
|
75
|
-
return [Overlay, openOverlay];
|
|
88
|
+
return [Overlay, openOverlay, existingOpenPromise.current];
|
|
76
89
|
};
|
package/src/i18n/index.ts
CHANGED
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
/* istanbul ignore file */
|
|
24
24
|
|
|
25
25
|
import i18n from "i18next";
|
|
26
|
-
import ar from "./ar.json";
|
|
27
|
-
import en from "./en.json";
|
|
26
|
+
import ar from "./ar/core.json";
|
|
27
|
+
import en from "./en/core.json";
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* add language bundles using bundle keys as namespaces
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|