@react-fabric/core 1.0.0-beta.40 → 1.0.0-beta.42

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.
@@ -42,6 +42,14 @@ export interface ModalProps extends AriaProps, TestProps, Omit<IconProps, "icon"
42
42
  * minimum width
43
43
  */
44
44
  minWidth?: string | number;
45
+ /**
46
+ * portal root element
47
+ */
48
+ root?: HTMLElement;
49
+ /**
50
+ * hide mask background
51
+ */
52
+ noMask?: boolean;
45
53
  /**
46
54
  * close handler
47
55
  */
@@ -51,4 +59,4 @@ export interface ModalProps extends AriaProps, TestProps, Omit<IconProps, "icon"
51
59
  */
52
60
  onBeforeClose?: (...args: AnyObject) => CallbackReturn;
53
61
  }
54
- export declare const Modal: ({ icon, iconBg, iconColor, iconClassName, rtlFlip, title, actions, headerClassName, onClose, onBeforeClose, children, loading, size, width, height, minHeight, minWidth, ...aria }: ModalProps) => import("react/jsx-runtime").JSX.Element;
62
+ export declare const Modal: ({ icon, iconBg, iconColor, iconClassName, rtlFlip, title, actions, headerClassName, onClose, onBeforeClose, children, loading, root, size, noMask, width, height, minHeight, minWidth, ...aria }: ModalProps) => import("react/jsx-runtime").JSX.Element;
@@ -6,8 +6,8 @@ export type ModalProps<P = unknown> = P & {
6
6
  export type SizeType = "xs" | "sm" | "md" | "lg" | "xl";
7
7
  export type SizeTypeWithZero = "xs" | "sm" | "md" | "lg" | "xl" | 0;
8
8
  export type ColorState = "primary" | "accent" | "info" | "danger" | "success" | "warning";
9
- export type ColorType = "primary-50" | "accent-50" | "info-50" | "danger-50" | "success-50" | "warning-50" | "primary-100" | "accent-100" | "info-100" | "danger-100" | "success-100" | "warning-100" | "primary-200" | "accent-200" | "info-200" | "danger-200" | "success-200" | "warning-200" | "primary-300" | "accent-300" | "info-300" | "danger-300" | "success-300" | "warning-300" | "primary-400" | "accent-400" | "info-400" | "danger-400" | "success-400" | "warning-400" | "primary-500" | "accent-500" | "info-500" | "danger-500" | "success-500" | "warning-500" | "primary-600" | "accent-600" | "info-600" | "danger-600" | "success-600" | "warning-600" | "primary-700" | "accent-700" | "info-700" | "danger-700" | "success-700" | "warning-700" | "primary-800" | "accent-800" | "info-800" | "danger-800" | "success-800" | "warning-800" | "primary-900" | "accent-900" | "info-900" | "danger-900" | "success-900" | "warning-900" | "primary-950" | "accent-950" | "info-950" | "danger-950" | "success-950" | "warning-950";
10
- export type PaletteType = "scarlet-50" | "pumpkin-50" | "marigold-50" | "avacado-50" | "jade-50" | "denim-50" | "iris-50" | "lilac-50" | "coral-50" | "wood-50" | "silver-50" | "steel-50" | "olive-50" | "sand-50" | "scarlet-100" | "pumpkin-100" | "marigold-100" | "avacado-100" | "jade-100" | "denim-100" | "iris-100" | "lilac-100" | "coral-100" | "wood-100" | "silver-100" | "steel-100" | "olive-100" | "sand-100" | "scarlet-200" | "pumpkin-200" | "marigold-200" | "avacado-200" | "jade-200" | "denim-200" | "iris-200" | "lilac-200" | "coral-200" | "wood-200" | "silver-200" | "steel-200" | "olive-200" | "sand-200" | "scarlet-300" | "pumpkin-300" | "marigold-300" | "avacado-300" | "jade-300" | "denim-300" | "iris-300" | "lilac-300" | "coral-300" | "wood-300" | "silver-300" | "steel-300" | "olive-300" | "sand-300" | "scarlet-400" | "pumpkin-400" | "marigold-400" | "avacado-400" | "jade-400" | "denim-400" | "iris-400" | "lilac-400" | "coral-400" | "wood-400" | "silver-400" | "steel-400" | "olive-400" | "sand-400" | "scarlet-500" | "pumpkin-500" | "marigold-500" | "avacado-500" | "jade-500" | "denim-500" | "iris-500" | "lilac-500" | "coral-500" | "wood-500" | "silver-500" | "steel-500" | "olive-500" | "sand-500" | "scarlet-600" | "pumpkin-600" | "marigold-600" | "avacado-600" | "jade-600" | "denim-600" | "iris-600" | "lilac-600" | "coral-600" | "wood-600" | "silver-600" | "steel-600" | "olive-600" | "sand-600" | "scarlet-700" | "pumpkin-700" | "marigold-700" | "avacado-700" | "jade-700" | "denim-700" | "iris-700" | "lilac-700" | "coral-700" | "wood-700" | "silver-700" | "steel-700" | "olive-700" | "sand-700" | "scarlet-800" | "pumpkin-800" | "marigold-800" | "avacado-800" | "jade-800" | "denim-800" | "iris-800" | "lilac-800" | "coral-800" | "wood-800" | "silver-800" | "steel-800" | "olive-800" | "sand-800" | "scarlet-900" | "pumpkin-900" | "marigold-900" | "avacado-900" | "jade-900" | "denim-900" | "iris-900" | "lilac-900" | "coral-900" | "wood-900" | "silver-900" | "steel-900" | "olive-900" | "sand-900" | "scarlet-950" | "pumpkin-950" | "marigold-950" | "avacado-950" | "jade-950" | "denim-950" | "iris-950" | "lilac-950" | "coral-950" | "wood-950" | "silver-950" | "steel-950" | "olive-950" | "sand-950";
9
+ export type ColorType = "primary-50" | "primary-100" | "primary-200" | "primary-300" | "primary-400" | "primary-500" | "primary-600" | "primary-700" | "primary-800" | "primary-900" | "primary-950" | "accent-50" | "accent-100" | "accent-200" | "accent-300" | "accent-400" | "accent-500" | "accent-600" | "accent-700" | "accent-800" | "accent-900" | "accent-950" | "info-50" | "info-100" | "info-200" | "info-300" | "info-400" | "info-500" | "info-600" | "info-700" | "info-800" | "info-900" | "info-950" | "danger-50" | "danger-100" | "danger-200" | "danger-300" | "danger-400" | "danger-500" | "danger-600" | "danger-700" | "danger-800" | "danger-900" | "danger-950" | "success-50" | "success-100" | "success-200" | "success-300" | "success-400" | "success-500" | "success-600" | "success-700" | "success-800" | "success-900" | "success-950" | "warning-50" | "warning-100" | "warning-200" | "warning-300" | "warning-400" | "warning-500" | "warning-600" | "warning-700" | "warning-800" | "warning-900" | "warning-950";
10
+ export type PaletteType = "scarlet-50" | "scarlet-100" | "scarlet-200" | "scarlet-300" | "scarlet-400" | "scarlet-500" | "scarlet-600" | "scarlet-700" | "scarlet-800" | "scarlet-900" | "scarlet-950" | "pumpkin-50" | "pumpkin-100" | "pumpkin-200" | "pumpkin-300" | "pumpkin-400" | "pumpkin-500" | "pumpkin-600" | "pumpkin-700" | "pumpkin-800" | "pumpkin-900" | "pumpkin-950" | "marigold-50" | "marigold-100" | "marigold-200" | "marigold-300" | "marigold-400" | "marigold-500" | "marigold-600" | "marigold-700" | "marigold-800" | "marigold-900" | "marigold-950" | "avacado-50" | "avacado-100" | "avacado-200" | "avacado-300" | "avacado-400" | "avacado-500" | "avacado-600" | "avacado-700" | "avacado-800" | "avacado-900" | "avacado-950" | "jade-50" | "jade-100" | "jade-200" | "jade-300" | "jade-400" | "jade-500" | "jade-600" | "jade-700" | "jade-800" | "jade-900" | "jade-950" | "denim-50" | "denim-100" | "denim-200" | "denim-300" | "denim-400" | "denim-500" | "denim-600" | "denim-700" | "denim-800" | "denim-900" | "denim-950" | "iris-50" | "iris-100" | "iris-200" | "iris-300" | "iris-400" | "iris-500" | "iris-600" | "iris-700" | "iris-800" | "iris-900" | "iris-950" | "lilac-50" | "lilac-100" | "lilac-200" | "lilac-300" | "lilac-400" | "lilac-500" | "lilac-600" | "lilac-700" | "lilac-800" | "lilac-900" | "lilac-950" | "coral-50" | "coral-100" | "coral-200" | "coral-300" | "coral-400" | "coral-500" | "coral-600" | "coral-700" | "coral-800" | "coral-900" | "coral-950" | "wood-50" | "wood-100" | "wood-200" | "wood-300" | "wood-400" | "wood-500" | "wood-600" | "wood-700" | "wood-800" | "wood-900" | "wood-950" | "silver-50" | "silver-100" | "silver-200" | "silver-300" | "silver-400" | "silver-500" | "silver-600" | "silver-700" | "silver-800" | "silver-900" | "silver-950" | "steel-50" | "steel-100" | "steel-200" | "steel-300" | "steel-400" | "steel-500" | "steel-600" | "steel-700" | "steel-800" | "steel-900" | "steel-950" | "olive-50" | "olive-100" | "olive-200" | "olive-300" | "olive-400" | "olive-500" | "olive-600" | "olive-700" | "olive-800" | "olive-900" | "olive-950" | "sand-50" | "sand-100" | "sand-200" | "sand-300" | "sand-400" | "sand-500" | "sand-600" | "sand-700" | "sand-800" | "sand-900" | "sand-950" | "tint-50" | "tint-100" | "tint-200" | "tint-300" | "tint-400" | "tint-500" | "tint-600" | "tint-700" | "tint-800" | "tint-900" | "tint-950";
11
11
  export type ColorWithGrays = ColorType | "invert" | "dimmed" | "muted";
12
12
  export declare const ThemeColors: string[];
13
13
  export interface TooltipType {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-fabric/core",
3
- "version": "1.0.0-beta.40",
3
+ "version": "1.0.0-beta.42",
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.40",
39
+ "@react-fabric/utilities": "^1.0.0-beta.42",
40
40
  "@tailwindcss/postcss": "~4.0.14",
41
41
  "boring-avatars": "^1.10.2",
42
42
  "classnames": "^2.5.1",
@@ -54,5 +54,5 @@
54
54
  "node": ">=18.12.0",
55
55
  "npm": ">=8.19.0"
56
56
  },
57
- "gitHead": "ede05c84683697d85e28a0ae380cb9b74d693f51"
57
+ "gitHead": "61c9612bb2c7bc9a807f46922881432748c9e7a3"
58
58
  }
@@ -24,7 +24,14 @@
24
24
  import { isString } from "@react-fabric/utilities";
25
25
  import classNames from "classnames";
26
26
  import { isValidElement } from "react";
27
- import { type ChildrenProp, type CssProp, type TestProps } from "../../types";
27
+ import {
28
+ type ChildrenProp,
29
+ type ColorType,
30
+ type CssProp,
31
+ type PaletteType,
32
+ type TestProps,
33
+ } from "../../types";
34
+ import { getColor } from "../../utils";
28
35
  import { Icon } from "../icon/Icon";
29
36
 
30
37
  export interface EmptyContentProps
@@ -47,6 +54,10 @@ export interface EmptyContentProps
47
54
  * empty icon
48
55
  */
49
56
  icon?: string | React.ReactElement;
57
+ /**
58
+ * icon color
59
+ */
60
+ iconColor?: ColorType | PaletteType;
50
61
  }
51
62
 
52
63
  const SizeMap: KeyValue = {
@@ -101,6 +112,7 @@ export const EmptyContent = ({
101
112
  icon,
102
113
  className,
103
114
  size,
115
+ iconColor,
104
116
  ...test
105
117
  }: EmptyContentProps) => {
106
118
  return (
@@ -116,7 +128,10 @@ export const EmptyContent = ({
116
128
  }
117
129
  {...test}
118
130
  >
119
- <div className="leading-none" style={{ fontSize: "4em" }}>
131
+ <div
132
+ className="leading-none"
133
+ style={{ fontSize: "4em", color: getColor(iconColor ?? "tint-700") }}
134
+ >
120
135
  {isString(icon) && <Icon icon={icon} />}
121
136
  {isValidElement(icon) && icon}
122
137
  {!icon && <DefaultIcon />}
@@ -24,9 +24,18 @@
24
24
  import classNames from "classnames";
25
25
  import { Loading } from "../../components/animations/Animations";
26
26
  import { Icon } from "../../components/icon/Icon";
27
- import { type ChildrenProp, type IconProps, type TestProps } from "../../types";
27
+ import {
28
+ type ChildrenProp,
29
+ type IconProps,
30
+ type RefProp,
31
+ type TestProps,
32
+ } from "../../types";
28
33
 
29
- export interface PageProps extends IconProps, ChildrenProp, TestProps {
34
+ export interface PageProps
35
+ extends IconProps,
36
+ ChildrenProp,
37
+ TestProps,
38
+ RefProp<HTMLDivElement> {
30
39
  /**
31
40
  * page title
32
41
  */
@@ -49,6 +58,7 @@ export interface PageProps extends IconProps, ChildrenProp, TestProps {
49
58
  * The page component used typically for routes, is a structured layout used within an application to organize and display content in a sectioned format, ensuring a consistent and intuitive user experience.
50
59
  */
51
60
  export const Page = ({
61
+ ref,
52
62
  children,
53
63
  paper,
54
64
  title,
@@ -60,6 +70,7 @@ export const Page = ({
60
70
  loading,
61
71
  "data-testid": testId,
62
72
  "data-test-value": testValue,
73
+ ...rest
63
74
  }: PageProps) => {
64
75
  return (
65
76
  <div
@@ -67,10 +78,12 @@ export const Page = ({
67
78
  data-test-value={testValue}
68
79
  data-loading={loading}
69
80
  className={classNames(
70
- "fabric-page",
81
+ "fabric-page relative",
71
82
  "overflow-hidden grid area-content",
72
83
  paper && "shadow-paper m-[6px] rounded-capped",
73
84
  )}
85
+ ref={ref}
86
+ {...rest}
74
87
  >
75
88
  {title && (
76
89
  <div
@@ -33,12 +33,10 @@ import {
33
33
  import { isString } from "@react-fabric/utilities";
34
34
  import classNames from "classnames";
35
35
  import {
36
- Fragment,
37
36
  isValidElement,
38
37
  useCallback,
39
38
  useEffect,
40
39
  type ElementType,
41
- type PropsWithChildren,
42
40
  } from "react";
43
41
  import { Loading } from "../../components/animations/Animations";
44
42
  import { Icon } from "../../components/icon/Icon";
@@ -194,91 +192,79 @@ export const Flyout = ({
194
192
  [closeOnClick, handleClose],
195
193
  );
196
194
 
197
- const Wrapper = useCallback(
198
- ({ children }: PropsWithChildren) => {
199
- if (hideMask) return <Fragment>{children}</Fragment>;
200
-
201
- return (
195
+ return (
196
+ <FloatingPortal>
197
+ {!hideMask && (
202
198
  <FloatingOverlay
203
199
  lockScroll
204
- style={{ zIndex: "var(--z-overlay-mask)" }}
200
+ style={{ zIndex: "var(--z-overlay-mask)", overflow: "hidden" }}
205
201
  className="bg-tint-100/10 backdrop-blur-sm transition-all"
202
+ />
203
+ )}
204
+ <FloatingFocusManager context={context}>
205
+ <div
206
+ data-align={align}
207
+ className={classNames(
208
+ "fabric-flyout",
209
+ "fixed inset-y-0 overflow-hidden flex flex-col flex-nowrap pointer-events-auto shadow-xl",
210
+ align === "start" ? "start-0" : "end-0",
211
+ size === "sm" && "w-[20rem]",
212
+ size === "md" && "w-[40rem]",
213
+ size === "lg" && "w-[60vw]",
214
+ size === "xl" && "w-[80vw]",
215
+ )}
216
+ style={{
217
+ width,
218
+ minWidth,
219
+ }}
220
+ onMouseUpCapture={tryClosing}
221
+ ref={refs.setFloating}
222
+ {...getFloatingProps()}
223
+ {...aria}
224
+ {...aria}
206
225
  >
207
- {children}
208
- </FloatingOverlay>
209
- );
210
- },
211
- [hideMask, handleClose],
212
- );
213
-
214
- return (
215
- <FloatingPortal>
216
- <Wrapper>
217
- <FloatingFocusManager context={context}>
218
- <div
219
- data-align={align}
220
- className={classNames(
221
- "fabric-flyout",
222
- "fixed inset-y-0 overflow-hidden flex flex-col flex-nowrap pointer-events-auto shadow-xl",
223
- align === "start" ? "start-0" : "end-0",
224
- size === "sm" && "w-[20rem]",
225
- size === "md" && "w-[40rem]",
226
- size === "lg" && "w-[60vw]",
227
- size === "xl" && "w-[80vw]",
228
- )}
229
- style={{
230
- width,
231
- minWidth,
232
- }}
233
- onMouseUpCapture={tryClosing}
234
- ref={refs.setFloating}
235
- {...getFloatingProps()}
236
- {...aria}
237
- {...aria}
238
- >
239
- <HotKeyWrapper>
240
- <Header
241
- flex
242
- align="center"
243
- className={classNames("fabric-flyoutHeader", headerClassName)}
244
- >
245
- {isString(icon) && (
246
- <Icon
247
- icon={icon}
248
- bg={iconBg}
249
- color={iconColor}
250
- className={classNames(iconClassName, "p-1")}
251
- rtlFlip={rtlFlip}
252
- />
253
- )}
254
- {isValidElement(icon) && icon}
255
- <label className="flex-1 truncate py-2 px-1">{title}</label>
256
- {actions}
226
+ <HotKeyWrapper>
227
+ <Header
228
+ flex
229
+ align="center"
230
+ className={classNames("fabric-flyoutHeader", headerClassName)}
231
+ >
232
+ {isString(icon) && (
257
233
  <Icon
258
- data-ref="panelClose"
259
- className={classNames(
260
- "fabric-panelAction",
261
- "cursor-pointer p-1 text-xl self-stretch",
262
- )}
263
- icon={CoreIcons.close}
264
- onClick={() => handleClose(false)}
234
+ icon={icon}
235
+ bg={iconBg}
236
+ color={iconColor}
237
+ className={classNames(iconClassName, "p-1")}
238
+ rtlFlip={rtlFlip}
265
239
  />
266
- </Header>
267
- {loading && <Loading />}
268
- <div
269
- role="dialog"
240
+ )}
241
+ {isValidElement(icon) && icon}
242
+ <label className="flex-1 truncate py-2 px-1">{title}</label>
243
+ {actions}
244
+ <Icon
245
+ data-ref="panelClose"
270
246
  className={classNames(
271
- "fabric-flyoutBody",
272
- "flex-1 grid overflow-hidden",
247
+ "fabric-panelAction",
248
+ "cursor-pointer p-1 text-xl self-stretch",
273
249
  )}
274
- {...({ tabIndex: 0 } as AnyObject)}
275
- >
276
- {children}
277
- </div>
278
- </HotKeyWrapper>
279
- </div>
280
- </FloatingFocusManager>
281
- </Wrapper>
250
+ icon={CoreIcons.close}
251
+ onClick={() => handleClose(false)}
252
+ />
253
+ </Header>
254
+ {loading && <Loading />}
255
+ <div
256
+ role="dialog"
257
+ className={classNames(
258
+ "fabric-flyoutBody",
259
+ "flex-1 grid overflow-hidden",
260
+ )}
261
+ {...({ tabIndex: 0 } as AnyObject)}
262
+ >
263
+ {children}
264
+ </div>
265
+ </HotKeyWrapper>
266
+ </div>
267
+ </FloatingFocusManager>
282
268
  </FloatingPortal>
283
269
  );
284
270
  };
@@ -98,6 +98,14 @@ export interface ModalProps
98
98
  * minimum width
99
99
  */
100
100
  minWidth?: string | number;
101
+ /**
102
+ * portal root element
103
+ */
104
+ root?: HTMLElement;
105
+ /**
106
+ * hide mask background
107
+ */
108
+ noMask?: boolean;
101
109
  /**
102
110
  * close handler
103
111
  */
@@ -121,7 +129,9 @@ export const Modal = ({
121
129
  onBeforeClose,
122
130
  children,
123
131
  loading,
132
+ root,
124
133
  size,
134
+ noMask,
125
135
  width,
126
136
  height,
127
137
  minHeight,
@@ -173,18 +183,25 @@ export const Modal = ({
173
183
  }, []);
174
184
 
175
185
  return (
176
- <FloatingPortal>
186
+ <FloatingPortal root={root}>
177
187
  <FloatingOverlay
178
188
  lockScroll
179
- style={{ zIndex: "var(--z-overlay-mask)" }}
180
- className="bg-tint-100/20 backdrop-blur-sm grid place-items-center"
189
+ style={{
190
+ zIndex: "var(--z-overlay-mask)",
191
+ position: "absolute",
192
+ overflow: "hidden",
193
+ }}
194
+ className={classNames(
195
+ "grid place-items-center p-16",
196
+ !noMask && "bg-tint-100/20 backdrop-blur-sm",
197
+ )}
181
198
  >
182
199
  <FloatingFocusManager context={context}>
183
200
  <dialog
184
201
  className={classNames(
185
202
  "fabric-modal",
186
203
  "rounded-capped relative overflow-hidden flex flex-col flex-nowrap",
187
- "ring-1 ring-tint-100 ring-offset-1 focus-within:ring-primary-300 shadow-xl",
204
+ "ring-2 ring-offset-2 ring-tint-100 focus-within:ring-primary-300 shadow-xl",
188
205
  size === "sm" && "w-[20rem]",
189
206
  size === "md" && "w-[40rem]",
190
207
  size === "lg" && "w-[60vw]",
@@ -186,22 +186,24 @@ export const Tooltip = ({
186
186
  }}
187
187
  {...getFloatingProps()}
188
188
  >
189
- <span
190
- className={classNames(
191
- "font-medium flex-1 break-all",
192
- !textColor && "contrast",
193
- isString(content) && "whitespace-pre-wrap mixed-lang",
194
- )}
195
- style={{
196
- color: textColor
197
- ? undefined
198
- : color
199
- ? getColor(color)
200
- : "var(--bg-color-muted)",
201
- }}
202
- >
203
- {content}
204
- </span>
189
+ {isValidElement(content) && content}
190
+ {isString(content) && (
191
+ <span
192
+ className={classNames(
193
+ "font-medium flex-1 break-all whitespace-pre-wrap mixed-lang",
194
+ !textColor && "contrast",
195
+ )}
196
+ style={{
197
+ color: textColor
198
+ ? undefined
199
+ : color
200
+ ? getColor(color)
201
+ : "var(--bg-color-muted)",
202
+ }}
203
+ >
204
+ {content}
205
+ </span>
206
+ )}
205
207
  {copyEl}
206
208
  <FloatingArrow
207
209
  ref={arrowRef}