@react-fabric/core 1.0.0-beta.43 → 1.0.0-beta.45

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.
@@ -134,7 +134,7 @@
134
134
  --text: color-mix(in lab, var(--color) 80%, var(--fabric-text));
135
135
  --bg-hover: color-mix(in lab, var(--color) 18%, var(--fabric-bg));
136
136
  --bg-click: color-mix(in lab, var(--color) 25%, var(--fabric-bg));
137
- --bg-active: color-mix(in lab, var(--color) 36%, var(--fabric-bg));
137
+ --bg-active: color-mix(in lab, var(--color) 24%, var(--fabric-bg));
138
138
 
139
139
  &[data-color="accent"] {
140
140
  --color: var(--color-accent-500);
@@ -56,20 +56,20 @@
56
56
  }
57
57
 
58
58
  &[data-focus="true"] {
59
- background-color: color(from var(--color) srgb r g b / 15%);
59
+ background-color: color-mix(in lab, var(--color) 15%, var(--fabric-bg));
60
60
  }
61
61
 
62
62
  &:active {
63
- background-color: color(from var(--color) srgb r g b / 35%);
63
+ background-color: color-mix(in lab, var(--color) 35%, var(--fabric-bg));
64
64
  }
65
65
 
66
66
  &[data-open="true"] {
67
- background-color: color(from var(--color) srgb r g b / 10%);
67
+ background-color: color-mix(in lab, var(--color) 10%, var(--fabric-bg));
68
68
  }
69
69
 
70
70
  &.active {
71
71
  pointer-events: none;
72
- background-color: color(from var(--color) srgb r g b / 20%);
72
+ background-color: color-mix(in lab, var(--color) 20%, var(--fabric-bg));
73
73
 
74
74
  & > div {
75
75
  box-shadow: 4px 0 0 var(--color) inset;
@@ -11,7 +11,7 @@ var jsxRuntime = require('react/jsx-runtime');
11
11
  require('@react-fabric/utilities');
12
12
  var nodeCheck = require('../../utils/nodeCheck.js');
13
13
 
14
- var _excluded = ["children", "className", "bodyClassName", "selected", "selectedRibbon", "onClick", "flex", "draggable", "dragKey", "dragData", "ref"];
14
+ var _excluded = ["children", "className", "bodyClassName", "selected", "selectedRibbon", "onClick", "onDragStart", "flex", "draggable", "dragKey", "dragData", "ref"];
15
15
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
16
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
17
  var Card = function Card(_ref) {
@@ -21,6 +21,7 @@ var Card = function Card(_ref) {
21
21
  selected = _ref.selected,
22
22
  selectedRibbon = _ref.selectedRibbon,
23
23
  onClick = _ref.onClick,
24
+ onDragStart = _ref.onDragStart,
24
25
  flex = _ref.flex,
25
26
  draggable = _ref.draggable,
26
27
  dragKey = _ref.dragKey,
@@ -37,16 +38,18 @@ var Card = function Card(_ref) {
37
38
  header = _useMemo2[0],
38
39
  body = _useMemo2[1],
39
40
  footer = _useMemo2[2];
41
+ var handleDragStart = react.useCallback(function (event) {
42
+ var _event$dataTransfer;
43
+ dragKey && ((_event$dataTransfer = event.dataTransfer) === null || _event$dataTransfer === void 0 ? void 0 : _event$dataTransfer.setData(dragKey, JSON.stringify(dragData)));
44
+ dragKey && (onDragStart === null || onDragStart === void 0 ? void 0 : onDragStart(event, dragKey, dragData));
45
+ }, [onDragStart, dragKey, dragData]);
40
46
  return /*#__PURE__*/jsxRuntime.jsx("div", {
41
47
  className: classNames("fabric-cardWrapper", "rounded-capped relative grid", flex && "flex-1", selected && selectedRibbon && "selected", selected && "outline-2 outline-accent-500 outline-offset-2"),
42
48
  children: /*#__PURE__*/jsxRuntime.jsx(ErrorBoundary.ErrorBoundary, {
43
49
  children: /*#__PURE__*/jsxRuntime.jsxs("div", _objectSpread(_objectSpread({
44
50
  className: classNames("fabric-card", className, "rounded-capped flex flex-col flex-nowrap overflow-hidden", onClick && "clickable"),
45
51
  draggable: draggable,
46
- onDragStart: !draggable ? undefined : function (e) {
47
- var _e$dataTransfer;
48
- return dragKey && ((_e$dataTransfer = e.dataTransfer) === null || _e$dataTransfer === void 0 ? void 0 : _e$dataTransfer.setData(dragKey, JSON.stringify(dragData)));
49
- },
52
+ onDragStart: !draggable ? undefined : handleDragStart,
50
53
  ref: ref
51
54
  }, aria), {}, {
52
55
  children: [header, /*#__PURE__*/jsxRuntime.jsx("div", {
@@ -61,7 +61,7 @@ var Tab = function Tab(_ref) {
61
61
  disabled: disabled,
62
62
  "data-color": color,
63
63
  "data-inner-clickable": true,
64
- className: classNames("fabric-tabButton", className, active && "active pointer-events-none", active && activeClassName, disabled && "text-tint-500 pointer-events-none", tabFlex ? "flex-1" : "flex-initial max-w-36", minimal ? "min-w-6" : "min-w-18", "flex items-center justify-center px-1 rounded overflow-hidden"),
64
+ className: classNames("fabric-tabButton", className, active && "active pointer-events-none", active && activeClassName, disabled && "text-tint-500 pointer-events-none", tabFlex ? "flex-1" : "flex-initial max-w-36", minimal ? "min-w-6" : "min-w-18", "flex items-center justify-center px-1 rounded overflow-hidden cursor-pointer"),
65
65
  onClick: function onClick() {
66
66
  return !active && (_onClick === null || _onClick === void 0 ? void 0 : _onClick(id));
67
67
  },
@@ -30,9 +30,9 @@ var loggerM = utilities.useLogger("useMemoDebugger");
30
30
  var loggerE = utilities.useLogger("useEffectDebugger");
31
31
  var loggerLE = utilities.useLogger("useLayoutEffectDebugger");
32
32
  var compareInputs = function compareInputs(oldInputs, newInputs, prefix, logger) {
33
- if (process.env.NODE_ENV === "production" && typeof window !== "undefined" &&
33
+ if (typeof window !== "undefined" &&
34
34
  // @ts-expect-error ignore
35
- window.DEBUG_HOOKS !== true) return;
35
+ window.DEBUG_EFFECTS !== true) return;
36
36
 
37
37
  // Edge-case: different array lengths
38
38
  if (oldInputs.length !== newInputs.length) {
@@ -92,8 +92,9 @@ var Tooltip = function Tooltip(_ref) {
92
92
  var copyEl = react.useMemo(function () {
93
93
  if (copyContent) {
94
94
  var copyText = utilities.isString(copyContent) ? copyContent : content;
95
- var handler = function handler() {
95
+ var handler = function handler(e) {
96
96
  setIsOpen(false);
97
+ e.stopPropagation();
97
98
  void navigator.clipboard.writeText(copyText.toString());
98
99
  };
99
100
  return /*#__PURE__*/jsxRuntime.jsx("span", {
@@ -4,14 +4,14 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
4
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
5
5
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
6
6
  import classNames from 'classnames';
7
- import { useMemo, Children } from 'react';
7
+ import { useMemo, Children, useCallback } from 'react';
8
8
  import { ErrorBoundary } from '../../core/boundary/ErrorBoundary.js';
9
9
  import { Header, Footer } from '../../core/headfoot/HeadFoot.js';
10
10
  import { jsx, jsxs } from 'react/jsx-runtime';
11
11
  import '@react-fabric/utilities';
12
12
  import { nodeCheck } from '../../utils/nodeCheck.js';
13
13
 
14
- var _excluded = ["children", "className", "bodyClassName", "selected", "selectedRibbon", "onClick", "flex", "draggable", "dragKey", "dragData", "ref"];
14
+ var _excluded = ["children", "className", "bodyClassName", "selected", "selectedRibbon", "onClick", "onDragStart", "flex", "draggable", "dragKey", "dragData", "ref"];
15
15
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
16
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
17
  var Card = function Card(_ref) {
@@ -21,6 +21,7 @@ var Card = function Card(_ref) {
21
21
  selected = _ref.selected,
22
22
  selectedRibbon = _ref.selectedRibbon,
23
23
  onClick = _ref.onClick,
24
+ onDragStart = _ref.onDragStart,
24
25
  flex = _ref.flex,
25
26
  draggable = _ref.draggable,
26
27
  dragKey = _ref.dragKey,
@@ -37,16 +38,18 @@ var Card = function Card(_ref) {
37
38
  header = _useMemo2[0],
38
39
  body = _useMemo2[1],
39
40
  footer = _useMemo2[2];
41
+ var handleDragStart = useCallback(function (event) {
42
+ var _event$dataTransfer;
43
+ dragKey && ((_event$dataTransfer = event.dataTransfer) === null || _event$dataTransfer === void 0 ? void 0 : _event$dataTransfer.setData(dragKey, JSON.stringify(dragData)));
44
+ dragKey && (onDragStart === null || onDragStart === void 0 ? void 0 : onDragStart(event, dragKey, dragData));
45
+ }, [onDragStart, dragKey, dragData]);
40
46
  return /*#__PURE__*/jsx("div", {
41
47
  className: classNames("fabric-cardWrapper", "rounded-capped relative grid", flex && "flex-1", selected && selectedRibbon && "selected", selected && "outline-2 outline-accent-500 outline-offset-2"),
42
48
  children: /*#__PURE__*/jsx(ErrorBoundary, {
43
49
  children: /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread({
44
50
  className: classNames("fabric-card", className, "rounded-capped flex flex-col flex-nowrap overflow-hidden", onClick && "clickable"),
45
51
  draggable: draggable,
46
- onDragStart: !draggable ? undefined : function (e) {
47
- var _e$dataTransfer;
48
- return dragKey && ((_e$dataTransfer = e.dataTransfer) === null || _e$dataTransfer === void 0 ? void 0 : _e$dataTransfer.setData(dragKey, JSON.stringify(dragData)));
49
- },
52
+ onDragStart: !draggable ? undefined : handleDragStart,
50
53
  ref: ref
51
54
  }, aria), {}, {
52
55
  children: [header, /*#__PURE__*/jsx("div", {
@@ -61,7 +61,7 @@ var Tab = function Tab(_ref) {
61
61
  disabled: disabled,
62
62
  "data-color": color,
63
63
  "data-inner-clickable": true,
64
- className: classNames("fabric-tabButton", className, active && "active pointer-events-none", active && activeClassName, disabled && "text-tint-500 pointer-events-none", tabFlex ? "flex-1" : "flex-initial max-w-36", minimal ? "min-w-6" : "min-w-18", "flex items-center justify-center px-1 rounded overflow-hidden"),
64
+ className: classNames("fabric-tabButton", className, active && "active pointer-events-none", active && activeClassName, disabled && "text-tint-500 pointer-events-none", tabFlex ? "flex-1" : "flex-initial max-w-36", minimal ? "min-w-6" : "min-w-18", "flex items-center justify-center px-1 rounded overflow-hidden cursor-pointer"),
65
65
  onClick: function onClick() {
66
66
  return !active && (_onClick === null || _onClick === void 0 ? void 0 : _onClick(id));
67
67
  },
@@ -30,9 +30,9 @@ var loggerM = useLogger("useMemoDebugger");
30
30
  var loggerE = useLogger("useEffectDebugger");
31
31
  var loggerLE = useLogger("useLayoutEffectDebugger");
32
32
  var compareInputs = function compareInputs(oldInputs, newInputs, prefix, logger) {
33
- if (process.env.NODE_ENV === "production" && typeof window !== "undefined" &&
33
+ if (typeof window !== "undefined" &&
34
34
  // @ts-expect-error ignore
35
- window.DEBUG_HOOKS !== true) return;
35
+ window.DEBUG_EFFECTS !== true) return;
36
36
 
37
37
  // Edge-case: different array lengths
38
38
  if (oldInputs.length !== newInputs.length) {
@@ -92,8 +92,9 @@ var Tooltip = function Tooltip(_ref) {
92
92
  var copyEl = useMemo(function () {
93
93
  if (copyContent) {
94
94
  var copyText = isString(copyContent) ? copyContent : content;
95
- var handler = function handler() {
95
+ var handler = function handler(e) {
96
96
  setIsOpen(false);
97
+ e.stopPropagation();
97
98
  void navigator.clipboard.writeText(copyText.toString());
98
99
  };
99
100
  return /*#__PURE__*/jsx("span", {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type AriaProps, type ChildrenProp, type ColorState, type CssProp, type TestProps } from "../../types";
2
3
  export interface CalloutProps extends AriaProps, ChildrenProp, CssProp, TestProps {
3
4
  /**
@@ -7,7 +8,7 @@ export interface CalloutProps extends AriaProps, ChildrenProp, CssProp, TestProp
7
8
  /**
8
9
  * legend title
9
10
  */
10
- legend?: string;
11
+ legend?: string | React.ReactElement;
11
12
  /**
12
13
  * callout icon
13
14
  */
@@ -1,4 +1,4 @@
1
- import { type MouseEventHandler } from "react";
1
+ import { type DragEvent, type MouseEventHandler } from "react";
2
2
  import { type ContentProps } from "../../core/content/Content";
3
3
  import { type HeadFootProps } from "../../core/headfoot/HeadFoot";
4
4
  import { type AriaProps, type ChildrenProp, type CssProp, type RefProp, type TestProps } from "../../types";
@@ -11,6 +11,10 @@ export interface CardProps extends CssProp, AriaProps, TestProps, RefProp<HTMLDi
11
11
  * click handler
12
12
  */
13
13
  onClick?: MouseEventHandler;
14
+ /**
15
+ * drag start handler
16
+ */
17
+ onDragStart?: (event: DragEvent, dragKey: string, dragData?: KeyValue) => void;
14
18
  /**
15
19
  * body css classname(s)
16
20
  */
@@ -36,4 +40,4 @@ export interface CardProps extends CssProp, AriaProps, TestProps, RefProp<HTMLDi
36
40
  */
37
41
  dragData?: KeyValue;
38
42
  }
39
- export declare const Card: ({ children, className, bodyClassName, selected, selectedRibbon, onClick, flex, draggable, dragKey, dragData, ref, ...aria }: CardProps) => import("react/jsx-runtime").JSX.Element;
43
+ export declare const Card: ({ children, className, bodyClassName, selected, selectedRibbon, onClick, onDragStart, flex, draggable, dragKey, dragData, ref, ...aria }: CardProps) => import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-fabric/core",
3
- "version": "1.0.0-beta.43",
3
+ "version": "1.0.0-beta.45",
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.43",
39
+ "@react-fabric/utilities": "^1.0.0-beta.45",
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": "92cd2fc5c71e3f0e00a9cff83ff924c51d7adb57"
57
+ "gitHead": "37d7cbcd99da40553f4ac775c3332d5281565936"
58
58
  }
@@ -44,7 +44,7 @@ export interface CalloutProps
44
44
  /**
45
45
  * legend title
46
46
  */
47
- legend?: string;
47
+ legend?: string | React.ReactElement;
48
48
  /**
49
49
  * callout icon
50
50
  */
@@ -24,9 +24,10 @@
24
24
  import classNames from "classnames";
25
25
  import {
26
26
  Children,
27
- useMemo,
28
27
  type DragEvent,
29
28
  type MouseEventHandler,
29
+ useCallback,
30
+ useMemo,
30
31
  } from "react";
31
32
  import { ErrorBoundary } from "../../core/boundary/ErrorBoundary";
32
33
  import { type ContentProps } from "../../core/content/Content";
@@ -58,6 +59,14 @@ export interface CardProps
58
59
  * click handler
59
60
  */
60
61
  onClick?: MouseEventHandler;
62
+ /**
63
+ * drag start handler
64
+ */
65
+ onDragStart?: (
66
+ event: DragEvent,
67
+ dragKey: string,
68
+ dragData?: KeyValue,
69
+ ) => void;
61
70
  /**
62
71
  * body css classname(s)
63
72
  */
@@ -91,6 +100,7 @@ export const Card = ({
91
100
  selected,
92
101
  selectedRibbon,
93
102
  onClick,
103
+ onDragStart,
94
104
  flex,
95
105
  draggable,
96
106
  dragKey,
@@ -112,6 +122,14 @@ export const Card = ({
112
122
  );
113
123
  }, [children]);
114
124
 
125
+ const handleDragStart = useCallback(
126
+ (event: DragEvent) => {
127
+ dragKey && event.dataTransfer?.setData(dragKey, JSON.stringify(dragData));
128
+ dragKey && onDragStart?.(event, dragKey, dragData);
129
+ },
130
+ [onDragStart, dragKey, dragData],
131
+ );
132
+
115
133
  return (
116
134
  <div
117
135
  className={classNames(
@@ -131,13 +149,7 @@ export const Card = ({
131
149
  onClick && "clickable",
132
150
  )}
133
151
  draggable={draggable}
134
- onDragStart={
135
- !draggable
136
- ? undefined
137
- : (e: DragEvent) =>
138
- dragKey &&
139
- e.dataTransfer?.setData(dragKey, JSON.stringify(dragData))
140
- }
152
+ onDragStart={!draggable ? undefined : handleDragStart}
141
153
  ref={ref}
142
154
  {...aria}
143
155
  >
@@ -144,7 +144,7 @@ export const Tab = <Tag extends React.ElementType = "button">({
144
144
  disabled && "text-tint-500 pointer-events-none",
145
145
  tabFlex ? "flex-1" : "flex-initial max-w-36",
146
146
  minimal ? "min-w-6" : "min-w-18",
147
- "flex items-center justify-center px-1 rounded overflow-hidden",
147
+ "flex items-center justify-center px-1 rounded overflow-hidden cursor-pointer",
148
148
  )}
149
149
  onClick={() => !active && onClick?.(id)}
150
150
  ref={ref as AnyObject}
@@ -44,10 +44,9 @@ const compareInputs = (
44
44
  logger: ReturnType<typeof useLogger>,
45
45
  ) => {
46
46
  if (
47
- process.env.NODE_ENV === "production" &&
48
47
  typeof window !== "undefined" &&
49
48
  // @ts-expect-error ignore
50
- window.DEBUG_HOOKS !== true
49
+ window.DEBUG_EFFECTS !== true
51
50
  )
52
51
  return;
53
52
 
@@ -45,6 +45,7 @@ import {
45
45
  useMemo,
46
46
  useRef,
47
47
  useState,
48
+ type MouseEvent,
48
49
  type ReactElement,
49
50
  } from "react";
50
51
  import { Icon } from "../../components/icon/Icon";
@@ -147,8 +148,9 @@ export const Tooltip = ({
147
148
  const copyEl = useMemo(() => {
148
149
  if (copyContent) {
149
150
  const copyText: AnyObject = isString(copyContent) ? copyContent : content;
150
- const handler = () => {
151
+ const handler = (e: MouseEvent) => {
151
152
  setIsOpen(false);
153
+ e.stopPropagation();
152
154
  void navigator.clipboard.writeText(copyText.toString());
153
155
  };
154
156
  return (