@react-fabric/core 1.0.0-beta.20 → 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.
@@ -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');
@@ -116,13 +117,13 @@ var Flyout = function Flyout(_ref) {
116
117
  children: [/*#__PURE__*/jsxRuntime.jsxs(HeadFoot.Header, {
117
118
  flex: true,
118
119
  className: classNames(Flyout_module.flyoutHeader, headerClassName),
119
- children: [icon && /*#__PURE__*/jsxRuntime.jsx(Icon.Icon, {
120
+ children: [utilities.isString(icon) && /*#__PURE__*/jsxRuntime.jsx(Icon.Icon, {
120
121
  icon: icon,
121
122
  bg: iconBg,
122
123
  color: iconColor,
123
124
  className: classNames(iconClassName, "p-1"),
124
125
  rtlFlip: rtlFlip
125
- }), /*#__PURE__*/jsxRuntime.jsx("label", {
126
+ }), /*#__PURE__*/react$1.isValidElement(icon) && icon, /*#__PURE__*/jsxRuntime.jsx("label", {
126
127
  className: "flex-1 truncate py-2 px-1",
127
128
  children: title
128
129
  }), actions, /*#__PURE__*/jsxRuntime.jsx(Icon.Icon, {
@@ -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');
@@ -97,13 +98,13 @@ var Modal = function Modal(_ref) {
97
98
  children: [/*#__PURE__*/jsxRuntime.jsxs(HeadFoot.Header, {
98
99
  flex: true,
99
100
  className: classNames(Modal_module.modalHeader, headerClassName),
100
- children: [icon && /*#__PURE__*/jsxRuntime.jsx(Icon.Icon, {
101
+ children: [utilities.isString(icon) && /*#__PURE__*/jsxRuntime.jsx(Icon.Icon, {
101
102
  icon: icon,
102
103
  bg: iconBg,
103
104
  color: iconColor,
104
105
  className: classNames(iconClassName, "p-1"),
105
106
  rtlFlip: rtlFlip
106
- }), /*#__PURE__*/jsxRuntime.jsx("label", {
107
+ }), /*#__PURE__*/react$1.isValidElement(icon) && icon, /*#__PURE__*/jsxRuntime.jsx("label", {
107
108
  className: "flex-1 truncate py-2 px-1",
108
109
  children: title
109
110
  }), actions, /*#__PURE__*/jsxRuntime.jsx(Icon.Icon, {
@@ -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';
@@ -116,13 +117,13 @@ var Flyout = function Flyout(_ref) {
116
117
  children: [/*#__PURE__*/jsxs(Header, {
117
118
  flex: true,
118
119
  className: classNames(classes.flyoutHeader, headerClassName),
119
- children: [icon && /*#__PURE__*/jsx(Icon, {
120
+ children: [isString(icon) && /*#__PURE__*/jsx(Icon, {
120
121
  icon: icon,
121
122
  bg: iconBg,
122
123
  color: iconColor,
123
124
  className: classNames(iconClassName, "p-1"),
124
125
  rtlFlip: rtlFlip
125
- }), /*#__PURE__*/jsx("label", {
126
+ }), /*#__PURE__*/isValidElement(icon) && icon, /*#__PURE__*/jsx("label", {
126
127
  className: "flex-1 truncate py-2 px-1",
127
128
  children: title
128
129
  }), actions, /*#__PURE__*/jsx(Icon, {
@@ -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';
@@ -97,13 +98,13 @@ var Modal = function Modal(_ref) {
97
98
  children: [/*#__PURE__*/jsxs(Header, {
98
99
  flex: true,
99
100
  className: classNames(classes.modalHeader, headerClassName),
100
- children: [icon && /*#__PURE__*/jsx(Icon, {
101
+ children: [isString(icon) && /*#__PURE__*/jsx(Icon, {
101
102
  icon: icon,
102
103
  bg: iconBg,
103
104
  color: iconColor,
104
105
  className: classNames(iconClassName, "p-1"),
105
106
  rtlFlip: rtlFlip
106
- }), /*#__PURE__*/jsx("label", {
107
+ }), /*#__PURE__*/isValidElement(icon) && icon, /*#__PURE__*/jsx("label", {
107
108
  className: "flex-1 truncate py-2 px-1",
108
109
  children: title
109
110
  }), actions, /*#__PURE__*/jsx(Icon, {
@@ -1,6 +1,6 @@
1
- import { type FC, type ReactNode } from "react";
2
- type OverlayComponent = FC<{
3
- onClose: (args?: AnyObject) => void;
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) => [
@@ -1,6 +1,7 @@
1
- /// <reference types="react" />
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
- /// <reference types="react" />
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,7 +1,7 @@
1
1
  import { type Placement } from "@floating-ui/react";
2
2
  import { type JSXElementConstructor, type Ref } from "react";
3
3
  export type ModalProps<P = unknown> = P & {
4
- onClose?: (...args: AnyObject) => void;
4
+ onClose: (...args: AnyObject) => void;
5
5
  };
6
6
  export type SizeType = "xs" | "sm" | "md" | "lg" | "xl";
7
7
  export type SizeTypeWithZero = "xs" | "sm" | "md" | "lg" | "xl" | 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-fabric/core",
3
- "version": "1.0.0-beta.20",
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.20",
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": "b265afe1779c1654fc9cf8d9de6e7396b64515d3"
59
+ "gitHead": "31c3d5c19bce7df519a62bd43efd1c9e6341be04"
60
60
  }
@@ -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 { useState, type FC, type ReactNode } from "react";
24
+ import {
25
+ useState,
26
+ type ComponentProps,
27
+ type ElementType,
28
+ type ReactNode,
29
+ } from "react";
25
30
 
26
- type OverlayComponent = FC<{
27
- onClose: (args?: AnyObject) => void;
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 ({ onClose, ...props }: KeyValue = {}) => {
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);
@@ -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
  */
@@ -238,7 +242,7 @@ export const Flyout = ({
238
242
  flex
239
243
  className={classNames(classes.flyoutHeader, headerClassName)}
240
244
  >
241
- {icon && (
245
+ {isString(icon) && (
242
246
  <Icon
243
247
  icon={icon}
244
248
  bg={iconBg}
@@ -247,6 +251,7 @@ export const Flyout = ({
247
251
  rtlFlip={rtlFlip}
248
252
  />
249
253
  )}
254
+ {isValidElement(icon) && icon}
250
255
  <label className="flex-1 truncate py-2 px-1">{title}</label>
251
256
  {actions}
252
257
  <Icon
@@ -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 { useCallback, useEffect } from "react";
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
  */
@@ -200,7 +207,7 @@ export const Modal = ({
200
207
  flex
201
208
  className={classNames(classes.modalHeader, headerClassName)}
202
209
  >
203
- {icon && (
210
+ {isString(icon) && (
204
211
  <Icon
205
212
  icon={icon}
206
213
  bg={iconBg}
@@ -209,6 +216,7 @@ export const Modal = ({
209
216
  rtlFlip={rtlFlip}
210
217
  />
211
218
  )}
219
+ {isValidElement(icon) && icon}
212
220
  <label className="flex-1 truncate py-2 px-1">{title}</label>
213
221
  {actions}
214
222
  <Icon
@@ -26,7 +26,7 @@ import { type Placement } from "@floating-ui/react";
26
26
  import { type JSXElementConstructor, type Ref } from "react";
27
27
 
28
28
  export type ModalProps<P = unknown> = P & {
29
- onClose?: (...args: AnyObject) => void;
29
+ onClose: (...args: AnyObject) => void;
30
30
  };
31
31
 
32
32
  export type SizeType = "xs" | "sm" | "md" | "lg" | "xl";