@react-fabric/core 1.0.0-beta.49 → 1.0.0-beta.51

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.
Files changed (47) hide show
  1. package/css/components/_card.css +18 -0
  2. package/css/core/_aside.css +14 -0
  3. package/css/reset/_reset.css +1 -1
  4. package/dist/cjs/components/card/FlipContent.js +35 -0
  5. package/dist/cjs/components/progress/ProgressBar.js +4 -4
  6. package/dist/cjs/components/progress/ProgressCircle.js +3 -3
  7. package/dist/cjs/context/NotificationCenter.js +3 -3
  8. package/dist/cjs/hooks/useDebounce.js +1 -1
  9. package/dist/cjs/index.js +2 -0
  10. package/dist/cjs/overlays/alert/Alert.js +1 -1
  11. package/dist/cjs/utils/cloneElement.js +3 -0
  12. package/dist/esm/components/card/FlipContent.js +35 -0
  13. package/dist/esm/components/progress/ProgressBar.js +4 -4
  14. package/dist/esm/components/progress/ProgressCircle.js +3 -3
  15. package/dist/esm/context/NotificationCenter.js +3 -3
  16. package/dist/esm/hooks/useDebounce.js +1 -1
  17. package/dist/esm/index.js +1 -0
  18. package/dist/esm/overlays/alert/Alert.js +1 -1
  19. package/dist/esm/utils/cloneElement.js +3 -0
  20. package/dist/types/components/collapsable/Collapsable.d.ts +2 -2
  21. package/dist/types/components/index.d.ts +2 -1
  22. package/dist/types/components/panel/Panel.d.ts +0 -1
  23. package/dist/types/components/progress/ProgressBar.d.ts +1 -1
  24. package/dist/types/components/progress/ProgressCircle.d.ts +1 -1
  25. package/dist/types/core/boundary/ErrorBoundary.d.ts +1 -1
  26. package/dist/types/hooks/useResize.d.ts +1 -1
  27. package/dist/types/hooks/useResizeObserver.d.ts +1 -1
  28. package/dist/types/overlays/alert/Alert.d.ts +0 -1
  29. package/dist/types/overlays/message/Message.d.ts +0 -1
  30. package/dist/types/overlays/toast/Toast.d.ts +0 -1
  31. package/dist/types/overlays/tooltip/Tooltip.d.ts +1 -1
  32. package/dist/types/types/index.d.ts +8 -0
  33. package/dist/types/typography/Abbr.d.ts +0 -1
  34. package/dist/types/typography/Mark.d.ts +0 -1
  35. package/package.json +8 -8
  36. package/src/components/collapsable/Collapsable.tsx +2 -2
  37. package/src/components/index.ts +2 -1
  38. package/src/components/progress/ProgressBar.tsx +5 -5
  39. package/src/components/progress/ProgressCircle.tsx +4 -4
  40. package/src/context/NotificationCenter.tsx +3 -3
  41. package/src/hooks/useDebounce.ts +1 -1
  42. package/src/hooks/useResize.ts +1 -1
  43. package/src/hooks/useResizeObserver.ts +1 -1
  44. package/src/overlays/alert/Alert.tsx +3 -1
  45. package/src/overlays/tooltip/Tooltip.tsx +1 -1
  46. package/src/types/index.ts +17 -0
  47. package/src/utils/cloneElement.ts +5 -2
@@ -153,4 +153,22 @@
153
153
  }
154
154
  }
155
155
  }
156
+
157
+ [data-card-flip-face="front"] {
158
+ backface-visibility: hidden;
159
+ }
160
+
161
+ [data-card-flip-face="back"] {
162
+ transform: rotateY(180deg);
163
+ backface-visibility: hidden;
164
+ }
165
+
166
+ [data-card-flip] {
167
+ transform-style: preserve-3d;
168
+ transition: transform 0.5s;
169
+ }
170
+
171
+ [data-card-flip="true"] {
172
+ transform: rotateY(180deg);
173
+ }
156
174
  }
@@ -141,6 +141,20 @@
141
141
  }
142
142
  }
143
143
 
144
+ [dir="rtl"] .fabric-aside[data-align="start"],
145
+ [dir="ltr"] .fabric-aside[data-align="end"] {
146
+ & .fabric-asideCollapse {
147
+ transform: scaleX(-1);
148
+ }
149
+ }
150
+
151
+ [dir="ltr"] .fabric-aside[data-align="start"],
152
+ [dir="rtl"] .fabric-aside[data-align="end"] {
153
+ & .fabric-asideCollapse {
154
+ transform: scaleX(1);
155
+ }
156
+ }
157
+
144
158
  .fabric-aside[data-collapsed="true"] {
145
159
  position: relative;
146
160
  overflow: visible;
@@ -170,7 +170,7 @@
170
170
  transform: scaleY(0.5);
171
171
 
172
172
  height: auto;
173
- margin: 1rem 0;
173
+ margin: 0.25rem 0;
174
174
 
175
175
  background: none;
176
176
  border: 0;
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
4
+ var classNames = require('classnames');
5
+ var react = require('react');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+
8
+ var FlipContent = function FlipContent(_ref) {
9
+ var ref = _ref.ref,
10
+ children = _ref.children;
11
+ var _useState = react.useState(false),
12
+ _useState2 = _slicedToArray(_useState, 2),
13
+ showBack = _useState2[0],
14
+ setShowBack = _useState2[1];
15
+ react.useImperativeHandle(ref, function () {
16
+ return {
17
+ flipCard: function flipCard() {
18
+ return setShowBack(!showBack);
19
+ }
20
+ };
21
+ }, [showBack]);
22
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
23
+ className: "relative flex-1",
24
+ "data-card-flip": showBack,
25
+ children: react.Children.map(children, function (child, idx) {
26
+ var _child$props$classNam, _child$props;
27
+ return /*#__PURE__*/react.isValidElement(child) && /*#__PURE__*/react.cloneElement(child, {
28
+ className: classNames((_child$props$classNam = (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.className) !== null && _child$props$classNam !== void 0 ? _child$props$classNam : "", idx === 0 ? "bg-base relative" : "bg-base absolute inset-0"),
29
+ "data-card-flip-face": idx === 0 ? "front" : "back"
30
+ });
31
+ })
32
+ });
33
+ };
34
+
35
+ exports.FlipContent = FlipContent;
@@ -30,11 +30,11 @@ var ProgressBar = function ProgressBar(_ref) {
30
30
  animate = _ref.animate;
31
31
  /** ***************** make sure value is between 0 and 100 *******************/
32
32
  var actualValue = useEffectDebugger.useMemoDebugger(function () {
33
- return Math.min(Math.max(value, 0), 100);
33
+ return Math.min(Math.max(value, 0), 1);
34
34
  }, [value], "ProgressBar value");
35
35
  var progressVar = useEffectDebugger.useMemoDebugger(function () {
36
36
  return {
37
- "--progress": actualValue
37
+ "--progress": actualValue * 100
38
38
  };
39
39
  }, [actualValue], "ProgressBar cssVar");
40
40
 
@@ -50,12 +50,12 @@ var ProgressBar = function ProgressBar(_ref) {
50
50
  "aria-hidden": "true",
51
51
  children: [!["xxs", "xs", "sm"].includes(size !== null && size !== void 0 ? size : "") && /*#__PURE__*/jsxRuntime.jsxs("div", {
52
52
  className: "absolute inset-0 text-center z-0 align-top",
53
- children: [label, " ", utilities.Format.percent(actualValue / 100)]
53
+ children: [label, " ", utilities.Format.percent(actualValue)]
54
54
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
55
55
  className: classNames("fabric-progressTrack", animate && "fabric-progressAnimate", "h-full overflow-clip bg-current relative z-0")
56
56
  }), !["xxs", "xs", "sm"].includes(size !== null && size !== void 0 ? size : "") && /*#__PURE__*/jsxRuntime.jsx("div", {
57
57
  className: classNames("h-full absolute inset-0 overflow-hidden z-1"),
58
- "data-label": "".concat(label, " ").concat(utilities.Format.percent(actualValue / 100))
58
+ "data-label": "".concat(label, " ").concat(utilities.Format.percent(actualValue))
59
59
  })]
60
60
  });
61
61
  };
@@ -46,13 +46,13 @@ var ProgressCircle = function ProgressCircle(_ref) {
46
46
  color = _ref$color === void 0 ? "primary-500" : _ref$color;
47
47
  /** ***************** make sure value is between 0 and 100 *******************/
48
48
  var actualValue = useEffectDebugger.useMemoDebugger(function () {
49
- return Math.min(Math.max(value, 0), 100);
49
+ return Math.min(Math.max(value, 0), 1);
50
50
  }, [value], "ProgressCirle value");
51
51
 
52
52
  /** ***************** calculate stroke offset by actual value *******************/
53
53
  var strokeDashoffset = useEffectDebugger.useMemoDebugger(function () {
54
54
  var circumfrence = Math.PI * 2 * 44;
55
- return circumfrence * (1 - actualValue / 100);
55
+ return circumfrence * (1 - actualValue);
56
56
  }, [actualValue], "ProgressCirle dashOffset");
57
57
 
58
58
  /** ***************** component *******************/
@@ -90,7 +90,7 @@ var ProgressCircle = function ProgressCircle(_ref) {
90
90
  })]
91
91
  }), /*#__PURE__*/jsxRuntime.jsx("span", {
92
92
  className: "flex w-full h-full items-center justify-center select-none font-bold text-[0.625em]",
93
- children: utilities.Format.percent(actualValue / 100)
93
+ children: utilities.Format.percent(actualValue)
94
94
  })]
95
95
  });
96
96
  };
@@ -221,7 +221,7 @@ var NotificationManager = function NotificationManager(_ref) {
221
221
  style: {
222
222
  zIndex: "var(--z-overlay)"
223
223
  },
224
- className: "ruf-container__overlays pointer-events-none fixed inset-0 p-4 bg-transparent",
224
+ className: "fabric-container__overlays pointer-events-none fixed inset-0 p-4 bg-transparent",
225
225
  children: Object.values(alerts).map(function (_ref7) {
226
226
  var _ref8 = _slicedToArray(_ref7, 1),
227
227
  el = _ref8[0];
@@ -231,7 +231,7 @@ var NotificationManager = function NotificationManager(_ref) {
231
231
  style: {
232
232
  zIndex: "var(--z-notifications)"
233
233
  },
234
- className: "ruf-container__notifs flex flex-nowrap pointer-events-none fixed inset-0 p-2 bg-transparent flex-col-reverse items-center justify-end",
234
+ className: "fabric-container__notifs flex flex-nowrap pointer-events-none fixed inset-0 p-2 bg-transparent flex-col-reverse items-center justify-end",
235
235
  children: Object.values(messages).map(function (_ref9) {
236
236
  var _ref10 = _slicedToArray(_ref9, 1),
237
237
  el = _ref10[0];
@@ -241,7 +241,7 @@ var NotificationManager = function NotificationManager(_ref) {
241
241
  style: {
242
242
  zIndex: "var(--z-notifications)"
243
243
  },
244
- className: "ruf-container__toasts flex flex-nowrap pointer-events-none fixed inset-0 p-4 bg-transparent flex-col items-end justify-end overflow-auto scroll-hide",
244
+ className: "fabric-container__toasts flex flex-nowrap pointer-events-none fixed inset-0 p-4 bg-transparent flex-col items-end justify-end overflow-auto scroll-hide",
245
245
  children: Object.values(toasts).map(function (_ref11) {
246
246
  var _ref12 = _slicedToArray(_ref11, 1),
247
247
  el = _ref12[0];
@@ -27,7 +27,7 @@ var react = require('react');
27
27
 
28
28
  var useDebounce = function useDebounce(callback, deps) {
29
29
  var delay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 100;
30
- var timerRef = react.useRef();
30
+ var timerRef = react.useRef(null);
31
31
  var cb = react.useMemo(function () {
32
32
  if (typeof window !== "undefined") {
33
33
  window.clearTimeout(timerRef.current);
package/dist/cjs/index.js CHANGED
@@ -13,6 +13,7 @@ var ToggleButtonGroup = require('./components/button/ToggleButtonGroup.js');
13
13
  var Callout = require('./components/callout/Callout.js');
14
14
  var Card = require('./components/card/Card.js');
15
15
  var CardCover = require('./components/card/CardCover.js');
16
+ var FlipContent = require('./components/card/FlipContent.js');
16
17
  var Chip = require('./components/chip/Chip.js');
17
18
  var Collapsable = require('./components/collapsable/Collapsable.js');
18
19
  var Divider = require('./components/divider/Divider.js');
@@ -97,6 +98,7 @@ exports.ToggleButtonGroup = ToggleButtonGroup.ToggleButtonGroup;
97
98
  exports.Callout = Callout.Callout;
98
99
  exports.Card = Card.Card;
99
100
  exports.CardCover = CardCover.CardCover;
101
+ exports.FlipContent = FlipContent.FlipContent;
100
102
  exports.Chip = Chip.Chip;
101
103
  exports.Collapsable = Collapsable.Collapsable;
102
104
  exports.Divider = Divider.Divider;
@@ -130,7 +130,7 @@ var Alert = function Alert(_ref) {
130
130
  "--tw-ring-color": getColor.getColor("".concat(color, "-500"))
131
131
  },
132
132
  ref: function ref(e) {
133
- return e != null && setTimeout(function () {
133
+ e != null && setTimeout(function () {
134
134
  return e.focus();
135
135
  }, 100);
136
136
  },
@@ -37,6 +37,9 @@ var cloneChildren = function cloneChildren(children, callback) {
37
37
  }
38
38
  return c;
39
39
  }
40
+ if (c instanceof Promise) {
41
+ return undefined;
42
+ }
40
43
  return c;
41
44
  })) === null || _Children$map === void 0 ? void 0 : _Children$map.flat().filter(Boolean).map(callback);
42
45
  };
@@ -0,0 +1,35 @@
1
+ 'use client';
2
+
3
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
+ import classNames from 'classnames';
5
+ import { useState, useImperativeHandle, Children, isValidElement, cloneElement } from 'react';
6
+ import { jsx } from 'react/jsx-runtime';
7
+
8
+ var FlipContent = function FlipContent(_ref) {
9
+ var ref = _ref.ref,
10
+ children = _ref.children;
11
+ var _useState = useState(false),
12
+ _useState2 = _slicedToArray(_useState, 2),
13
+ showBack = _useState2[0],
14
+ setShowBack = _useState2[1];
15
+ useImperativeHandle(ref, function () {
16
+ return {
17
+ flipCard: function flipCard() {
18
+ return setShowBack(!showBack);
19
+ }
20
+ };
21
+ }, [showBack]);
22
+ return /*#__PURE__*/jsx("div", {
23
+ className: "relative flex-1",
24
+ "data-card-flip": showBack,
25
+ children: Children.map(children, function (child, idx) {
26
+ var _child$props$classNam, _child$props;
27
+ return /*#__PURE__*/isValidElement(child) && /*#__PURE__*/cloneElement(child, {
28
+ className: classNames((_child$props$classNam = (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.className) !== null && _child$props$classNam !== void 0 ? _child$props$classNam : "", idx === 0 ? "bg-base relative" : "bg-base absolute inset-0"),
29
+ "data-card-flip-face": idx === 0 ? "front" : "back"
30
+ });
31
+ })
32
+ });
33
+ };
34
+
35
+ export { FlipContent };
@@ -30,11 +30,11 @@ var ProgressBar = function ProgressBar(_ref) {
30
30
  animate = _ref.animate;
31
31
  /** ***************** make sure value is between 0 and 100 *******************/
32
32
  var actualValue = useMemoDebugger(function () {
33
- return Math.min(Math.max(value, 0), 100);
33
+ return Math.min(Math.max(value, 0), 1);
34
34
  }, [value], "ProgressBar value");
35
35
  var progressVar = useMemoDebugger(function () {
36
36
  return {
37
- "--progress": actualValue
37
+ "--progress": actualValue * 100
38
38
  };
39
39
  }, [actualValue], "ProgressBar cssVar");
40
40
 
@@ -50,12 +50,12 @@ var ProgressBar = function ProgressBar(_ref) {
50
50
  "aria-hidden": "true",
51
51
  children: [!["xxs", "xs", "sm"].includes(size !== null && size !== void 0 ? size : "") && /*#__PURE__*/jsxs("div", {
52
52
  className: "absolute inset-0 text-center z-0 align-top",
53
- children: [label, " ", Format.percent(actualValue / 100)]
53
+ children: [label, " ", Format.percent(actualValue)]
54
54
  }), /*#__PURE__*/jsx("div", {
55
55
  className: classNames("fabric-progressTrack", animate && "fabric-progressAnimate", "h-full overflow-clip bg-current relative z-0")
56
56
  }), !["xxs", "xs", "sm"].includes(size !== null && size !== void 0 ? size : "") && /*#__PURE__*/jsx("div", {
57
57
  className: classNames("h-full absolute inset-0 overflow-hidden z-1"),
58
- "data-label": "".concat(label, " ").concat(Format.percent(actualValue / 100))
58
+ "data-label": "".concat(label, " ").concat(Format.percent(actualValue))
59
59
  })]
60
60
  });
61
61
  };
@@ -46,13 +46,13 @@ var ProgressCircle = function ProgressCircle(_ref) {
46
46
  color = _ref$color === void 0 ? "primary-500" : _ref$color;
47
47
  /** ***************** make sure value is between 0 and 100 *******************/
48
48
  var actualValue = useMemoDebugger(function () {
49
- return Math.min(Math.max(value, 0), 100);
49
+ return Math.min(Math.max(value, 0), 1);
50
50
  }, [value], "ProgressCirle value");
51
51
 
52
52
  /** ***************** calculate stroke offset by actual value *******************/
53
53
  var strokeDashoffset = useMemoDebugger(function () {
54
54
  var circumfrence = Math.PI * 2 * 44;
55
- return circumfrence * (1 - actualValue / 100);
55
+ return circumfrence * (1 - actualValue);
56
56
  }, [actualValue], "ProgressCirle dashOffset");
57
57
 
58
58
  /** ***************** component *******************/
@@ -90,7 +90,7 @@ var ProgressCircle = function ProgressCircle(_ref) {
90
90
  })]
91
91
  }), /*#__PURE__*/jsx("span", {
92
92
  className: "flex w-full h-full items-center justify-center select-none font-bold text-[0.625em]",
93
- children: Format.percent(actualValue / 100)
93
+ children: Format.percent(actualValue)
94
94
  })]
95
95
  });
96
96
  };
@@ -221,7 +221,7 @@ var NotificationManager = function NotificationManager(_ref) {
221
221
  style: {
222
222
  zIndex: "var(--z-overlay)"
223
223
  },
224
- className: "ruf-container__overlays pointer-events-none fixed inset-0 p-4 bg-transparent",
224
+ className: "fabric-container__overlays pointer-events-none fixed inset-0 p-4 bg-transparent",
225
225
  children: Object.values(alerts).map(function (_ref7) {
226
226
  var _ref8 = _slicedToArray(_ref7, 1),
227
227
  el = _ref8[0];
@@ -231,7 +231,7 @@ var NotificationManager = function NotificationManager(_ref) {
231
231
  style: {
232
232
  zIndex: "var(--z-notifications)"
233
233
  },
234
- className: "ruf-container__notifs flex flex-nowrap pointer-events-none fixed inset-0 p-2 bg-transparent flex-col-reverse items-center justify-end",
234
+ className: "fabric-container__notifs flex flex-nowrap pointer-events-none fixed inset-0 p-2 bg-transparent flex-col-reverse items-center justify-end",
235
235
  children: Object.values(messages).map(function (_ref9) {
236
236
  var _ref10 = _slicedToArray(_ref9, 1),
237
237
  el = _ref10[0];
@@ -241,7 +241,7 @@ var NotificationManager = function NotificationManager(_ref) {
241
241
  style: {
242
242
  zIndex: "var(--z-notifications)"
243
243
  },
244
- className: "ruf-container__toasts flex flex-nowrap pointer-events-none fixed inset-0 p-4 bg-transparent flex-col items-end justify-end overflow-auto scroll-hide",
244
+ className: "fabric-container__toasts flex flex-nowrap pointer-events-none fixed inset-0 p-4 bg-transparent flex-col items-end justify-end overflow-auto scroll-hide",
245
245
  children: Object.values(toasts).map(function (_ref11) {
246
246
  var _ref12 = _slicedToArray(_ref11, 1),
247
247
  el = _ref12[0];
@@ -27,7 +27,7 @@ import { useRef, useMemo } from 'react';
27
27
 
28
28
  var useDebounce = function useDebounce(callback, deps) {
29
29
  var delay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 100;
30
- var timerRef = useRef();
30
+ var timerRef = useRef(null);
31
31
  var cb = useMemo(function () {
32
32
  if (typeof window !== "undefined") {
33
33
  window.clearTimeout(timerRef.current);
package/dist/esm/index.js CHANGED
@@ -13,6 +13,7 @@ export { ToggleButtonGroup } from './components/button/ToggleButtonGroup.js';
13
13
  export { Callout } from './components/callout/Callout.js';
14
14
  export { Card } from './components/card/Card.js';
15
15
  export { CardCover } from './components/card/CardCover.js';
16
+ export { FlipContent } from './components/card/FlipContent.js';
16
17
  export { Chip } from './components/chip/Chip.js';
17
18
  export { Collapsable } from './components/collapsable/Collapsable.js';
18
19
  export { Divider } from './components/divider/Divider.js';
@@ -130,7 +130,7 @@ var Alert = function Alert(_ref) {
130
130
  "--tw-ring-color": getColor("".concat(color, "-500"))
131
131
  },
132
132
  ref: function ref(e) {
133
- return e != null && setTimeout(function () {
133
+ e != null && setTimeout(function () {
134
134
  return e.focus();
135
135
  }, 100);
136
136
  },
@@ -37,6 +37,9 @@ var cloneChildren = function cloneChildren(children, callback) {
37
37
  }
38
38
  return c;
39
39
  }
40
+ if (c instanceof Promise) {
41
+ return undefined;
42
+ }
40
43
  return c;
41
44
  })) === null || _Children$map === void 0 ? void 0 : _Children$map.flat().filter(Boolean).map(callback);
42
45
  };
@@ -1,8 +1,8 @@
1
1
  import { type RefObject } from "react";
2
2
  import { type AriaProps, type ChildrenProp, type CssProp, type RefProp, type TestProps } from "../../types";
3
3
  interface CollapsableRef {
4
- button: RefObject<HTMLElement>;
5
- body: RefObject<HTMLElement>;
4
+ button: RefObject<HTMLElement | null>;
5
+ body: RefObject<HTMLElement | null>;
6
6
  open: boolean;
7
7
  }
8
8
  export interface CollapsableProps extends CssProp, AriaProps, TestProps, RefProp<CollapsableRef>, ChildrenProp {
@@ -1,5 +1,5 @@
1
1
  export { ActionLabel } from "./actionLabel/ActionLabel";
2
- export { AnimationBars, AnimationIndicator, AnimationSpinner, Skeleton, Loading, } from "./animations/Animations";
2
+ export { AnimationBars, AnimationIndicator, AnimationSpinner, Loading, Skeleton, } from "./animations/Animations";
3
3
  export { Avatar } from "./avatar/Avatar";
4
4
  export { AvatarGroup } from "./avatar/AvatarGroup";
5
5
  export { Badge, getBadgeProps } from "./badge/Badge";
@@ -11,6 +11,7 @@ export { ToggleButtonGroup } from "./button/ToggleButtonGroup";
11
11
  export { Callout } from "./callout/Callout";
12
12
  export { Card } from "./card/Card";
13
13
  export { CardCover } from "./card/CardCover";
14
+ export { FlipContent, type FlipContentRef } from "./card/FlipContent";
14
15
  export { Chip } from "./chip/Chip";
15
16
  export { Collapsable } from "./collapsable/Collapsable";
16
17
  export { Divider } from "./divider/Divider";
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type ContentProps } from "../../core/content/Content";
3
2
  import { type HeadFootProps } from "../../core/headfoot/HeadFoot";
4
3
  import { type AriaProps, type ChildrenProp, type CollapseProps, type CssProp, type ExpandProps, type IconProps, type TestProps } from "../../types";
@@ -1,7 +1,7 @@
1
1
  import { type PaletteType, type ColorType } from "../../types";
2
2
  export interface ProgressProps {
3
3
  /**
4
- * progress value (0-100)
4
+ * progress value (0-1)
5
5
  */
6
6
  value: number;
7
7
  /**
@@ -1,7 +1,7 @@
1
1
  import { type PaletteType, type ColorType } from "../../types";
2
2
  export interface ProgressProps {
3
3
  /**
4
- * progress value (0-100)
4
+ * progress value (0-1)
5
5
  */
6
6
  value: number;
7
7
  /**
@@ -22,5 +22,5 @@ export declare class ErrorBoundary extends Component<{
22
22
  };
23
23
  constructor(props: AnyObject);
24
24
  componentDidCatch(error: Error): void;
25
- render(): string | number | boolean | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
25
+ render(): string | number | bigint | boolean | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
26
26
  }
@@ -21,7 +21,7 @@ export declare const useResize: <T extends HTMLElement = HTMLDivElement>(onResiz
21
21
  x: number;
22
22
  y: number;
23
23
  }) => void, { isReverse, isVertical, onStart, onEnd }: Options) => {
24
- ref: RefObject<T>;
24
+ ref: RefObject<T | null>;
25
25
  onMouseDown: React.MouseEventHandler;
26
26
  };
27
27
  export {};
@@ -1,3 +1,3 @@
1
1
  import { type RefObject } from "react";
2
2
  import { type SizeObject } from "../types";
3
- export declare const useResizeObserver: <T extends HTMLElement = HTMLDivElement>(onResize?: (size: SizeObject) => void) => RefObject<T>;
3
+ export declare const useResizeObserver: <T extends HTMLElement = HTMLDivElement>(onResize?: (size: SizeObject) => void) => RefObject<T | null>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type ColorState, type Elements, type IconProps } from "../../types";
3
2
  export interface AlertProps extends Omit<IconProps, "iconBg" | "iconColor"> {
4
3
  /**
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type ColorState, type Elements, type IconProps } from "../../types";
3
2
  export interface MessageProps extends Omit<IconProps, "iconBg" | "iconColor"> {
4
3
  /**
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type ColorState, type Elements, type IconProps } from "../../types";
3
2
  export interface ToastProps extends Omit<IconProps, "iconBg" | "iconColor"> {
4
3
  /**
@@ -10,7 +10,7 @@ export interface TooltipProps extends TooltipType, RefProp {
10
10
  */
11
11
  copyContent?: boolean | string;
12
12
  disabled?: boolean;
13
- children: ReactElement;
13
+ children: ReactElement<KeyValue>;
14
14
  }
15
15
  export declare const getTooltipProps: (tooltip?: string | TooltipType, innerRef?: AnyObject) => (TooltipType & {
16
16
  ref: AnyObject;
@@ -51,6 +51,10 @@ export interface CssProp {
51
51
  * css classname(s)
52
52
  */
53
53
  className?: string;
54
+ /**
55
+ * direction
56
+ */
57
+ dir?: "ltr" | "rtl";
54
58
  }
55
59
  export interface TestProps {
56
60
  /**
@@ -150,3 +154,7 @@ export interface ScrollObject extends PositionObject, SizeObject {
150
154
  scrollWidth?: number;
151
155
  scrollHeight: number;
152
156
  }
157
+ export type ArrayType<T extends readonly any[] | ArrayLike<any> | undefined> = T extends readonly any[] ? T[number] : T extends ArrayLike<any> ? T[number] : undefined;
158
+ export type Complete<T> = {
159
+ [P in keyof Required<T>]: Pick<T, P> extends Required<Pick<T, P>> ? T[P] : T[P] | undefined;
160
+ };
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type ChildProp, type ColorType, type CssProp, type PaletteType } from "../types";
3
2
  export interface AbbrProps extends ChildProp<string>, CssProp {
4
3
  /**
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type ChildProp, type ColorType, type PaletteType } from "../types";
3
2
  export interface MarkProps extends ChildProp<string> {
4
3
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-fabric/core",
3
- "version": "1.0.0-beta.49",
3
+ "version": "1.0.0-beta.51",
4
4
  "description": "RUF: Core package",
5
5
  "author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
6
6
  "license": "MIT",
@@ -35,24 +35,24 @@
35
35
  "watch": "npm-run-all -p watch:rollup watch:dts"
36
36
  },
37
37
  "dependencies": {
38
- "@floating-ui/react": "^0.27.9",
39
- "@react-fabric/utilities": "^1.0.0-beta.49",
40
- "@tailwindcss/postcss": "~4.0.14",
38
+ "@floating-ui/react": "^0.27.12",
39
+ "@react-fabric/utilities": "^1.0.0-beta.50",
40
+ "@tailwindcss/postcss": "~4.1.8",
41
41
  "boring-avatars": "^1.11.2",
42
42
  "classnames": "^2.5.1",
43
43
  "color": "^4.2.3",
44
44
  "resize-observer-polyfill": "^1.5.1",
45
- "tailwindcss": "^4.0.14"
45
+ "tailwindcss": "^4.1.8"
46
46
  },
47
47
  "peerDependencies": {
48
- "i18next": "^23.15.1",
48
+ "i18next": "^25.2.1",
49
49
  "react": "^19.0.0",
50
50
  "react-dom": "^19.0.0",
51
- "react-i18next": "^15.0.2"
51
+ "react-i18next": "^15.5.2"
52
52
  },
53
53
  "engines": {
54
54
  "node": ">=18.12.0",
55
55
  "npm": ">=8.19.0"
56
56
  },
57
- "gitHead": "29b3ed65e9f9687d738dd7c6facdb9fedafb4219"
57
+ "gitHead": "a1b04de4663045f82992bff2aef8db26608eac74"
58
58
  }
@@ -42,8 +42,8 @@ import { CoreIcons } from "../../types/icons";
42
42
  import { Icon } from "../icon/Icon";
43
43
 
44
44
  interface CollapsableRef {
45
- button: RefObject<HTMLElement>;
46
- body: RefObject<HTMLElement>;
45
+ button: RefObject<HTMLElement | null>;
46
+ body: RefObject<HTMLElement | null>;
47
47
  open: boolean;
48
48
  }
49
49
 
@@ -26,8 +26,8 @@ export {
26
26
  AnimationBars,
27
27
  AnimationIndicator,
28
28
  AnimationSpinner,
29
- Skeleton,
30
29
  Loading,
30
+ Skeleton,
31
31
  } from "./animations/Animations";
32
32
  export { Avatar } from "./avatar/Avatar";
33
33
  export { AvatarGroup } from "./avatar/AvatarGroup";
@@ -40,6 +40,7 @@ export { ToggleButtonGroup } from "./button/ToggleButtonGroup";
40
40
  export { Callout } from "./callout/Callout";
41
41
  export { Card } from "./card/Card";
42
42
  export { CardCover } from "./card/CardCover";
43
+ export { FlipContent, type FlipContentRef } from "./card/FlipContent";
43
44
  export { Chip } from "./chip/Chip";
44
45
  export { Collapsable } from "./collapsable/Collapsable";
45
46
  export { Divider } from "./divider/Divider";
@@ -29,7 +29,7 @@ import { getColor } from "../../utils";
29
29
 
30
30
  export interface ProgressProps {
31
31
  /**
32
- * progress value (0-100)
32
+ * progress value (0-1)
33
33
  */
34
34
  value: number;
35
35
  /**
@@ -69,14 +69,14 @@ export const ProgressBar = ({
69
69
  }: ProgressProps) => {
70
70
  /** ***************** make sure value is between 0 and 100 *******************/
71
71
  const actualValue = useMemoDebugger(
72
- () => Math.min(Math.max(value, 0), 100),
72
+ () => Math.min(Math.max(value, 0), 1),
73
73
  [value],
74
74
  "ProgressBar value",
75
75
  );
76
76
 
77
77
  const progressVar = useMemoDebugger<KeyValue>(
78
78
  () => ({
79
- "--progress": actualValue,
79
+ "--progress": actualValue * 100,
80
80
  }),
81
81
  [actualValue],
82
82
  "ProgressBar cssVar",
@@ -100,7 +100,7 @@ export const ProgressBar = ({
100
100
  >
101
101
  {!["xxs", "xs", "sm"].includes(size ?? "") && (
102
102
  <div className="absolute inset-0 text-center z-0 align-top">
103
- {label} {Format.percent(actualValue / 100)}
103
+ {label} {Format.percent(actualValue)}
104
104
  </div>
105
105
  )}
106
106
  <div
@@ -113,7 +113,7 @@ export const ProgressBar = ({
113
113
  {!["xxs", "xs", "sm"].includes(size ?? "") && (
114
114
  <div
115
115
  className={classNames("h-full absolute inset-0 overflow-hidden z-1")}
116
- data-label={`${label} ${Format.percent(actualValue / 100)}`}
116
+ data-label={`${label} ${Format.percent(actualValue)}`}
117
117
  />
118
118
  )}
119
119
  </div>
@@ -29,7 +29,7 @@ import { getColor } from "../../utils";
29
29
 
30
30
  export interface ProgressProps {
31
31
  /**
32
- * progress value (0-100)
32
+ * progress value (0-1)
33
33
  */
34
34
  value: number;
35
35
  /**
@@ -57,7 +57,7 @@ export const ProgressCircle = ({
57
57
  }: ProgressProps) => {
58
58
  /** ***************** make sure value is between 0 and 100 *******************/
59
59
  const actualValue = useMemoDebugger(
60
- () => Math.min(Math.max(value, 0), 100),
60
+ () => Math.min(Math.max(value, 0), 1),
61
61
  [value],
62
62
  "ProgressCirle value",
63
63
  );
@@ -66,7 +66,7 @@ export const ProgressCircle = ({
66
66
  const strokeDashoffset = useMemoDebugger(
67
67
  () => {
68
68
  const circumfrence = Math.PI * 2 * 44;
69
- return circumfrence * (1 - actualValue / 100);
69
+ return circumfrence * (1 - actualValue);
70
70
  },
71
71
  [actualValue],
72
72
  "ProgressCirle dashOffset",
@@ -108,7 +108,7 @@ export const ProgressCircle = ({
108
108
  />
109
109
  </svg>
110
110
  <span className="flex w-full h-full items-center justify-center select-none font-bold text-[0.625em]">
111
- {Format.percent(actualValue / 100)}
111
+ {Format.percent(actualValue)}
112
112
  </span>
113
113
  </div>
114
114
  );
@@ -194,7 +194,7 @@ export const NotificationManager = ({ onLoad }: KeyValue) => {
194
194
  {createPortal(
195
195
  <div
196
196
  style={{ zIndex: "var(--z-overlay)" }}
197
- className="ruf-container__overlays pointer-events-none fixed inset-0 p-4 bg-transparent"
197
+ className="fabric-container__overlays pointer-events-none fixed inset-0 p-4 bg-transparent"
198
198
  >
199
199
  {Object.values(alerts).map(([el]: AnyObject) => el)}
200
200
  </div>,
@@ -203,7 +203,7 @@ export const NotificationManager = ({ onLoad }: KeyValue) => {
203
203
  {createPortal(
204
204
  <div
205
205
  style={{ zIndex: "var(--z-notifications)" }}
206
- className="ruf-container__notifs flex flex-nowrap pointer-events-none fixed inset-0 p-2 bg-transparent flex-col-reverse items-center justify-end"
206
+ className="fabric-container__notifs flex flex-nowrap pointer-events-none fixed inset-0 p-2 bg-transparent flex-col-reverse items-center justify-end"
207
207
  >
208
208
  {Object.values(messages).map(([el]: AnyObject) => el)}
209
209
  </div>,
@@ -212,7 +212,7 @@ export const NotificationManager = ({ onLoad }: KeyValue) => {
212
212
  {createPortal(
213
213
  <div
214
214
  style={{ zIndex: "var(--z-notifications)" }}
215
- className="ruf-container__toasts flex flex-nowrap pointer-events-none fixed inset-0 p-4 bg-transparent flex-col items-end justify-end overflow-auto scroll-hide"
215
+ className="fabric-container__toasts flex flex-nowrap pointer-events-none fixed inset-0 p-4 bg-transparent flex-col items-end justify-end overflow-auto scroll-hide"
216
216
  >
217
217
  {Object.values(toasts).map(([el]: AnyObject) => el)}
218
218
  </div>,
@@ -28,7 +28,7 @@ export const useDebounce = (
28
28
  deps: AnyObject[],
29
29
  delay: number = 100,
30
30
  ) => {
31
- const timerRef = useRef<AnyObject>();
31
+ const timerRef = useRef<AnyObject>(null);
32
32
 
33
33
  const cb = useMemo(() => {
34
34
  if (typeof window !== "undefined") {
@@ -46,7 +46,7 @@ interface Options {
46
46
  export const useResize = <T extends HTMLElement = HTMLDivElement>(
47
47
  onResize: (diff: { x: number; y: number }) => void,
48
48
  { isReverse = false, isVertical = false, onStart, onEnd }: Options,
49
- ): { ref: RefObject<T>; onMouseDown: React.MouseEventHandler } => {
49
+ ): { ref: RefObject<T | null>; onMouseDown: React.MouseEventHandler } => {
50
50
  const refEl = useRef<T>(null);
51
51
  const isRtl = useIsRtl();
52
52
 
@@ -28,7 +28,7 @@ import { useDebounce } from "./useDebounce";
28
28
 
29
29
  export const useResizeObserver = <T extends HTMLElement = HTMLDivElement>(
30
30
  onResize?: (size: SizeObject) => void,
31
- ): RefObject<T> => {
31
+ ): RefObject<T | null> => {
32
32
  const ref = useRef<T>(null);
33
33
  const [, startTransition] = useTransition();
34
34
 
@@ -193,7 +193,9 @@ export const Alert = ({
193
193
  "--tw-ring-color": getColor(`${color}-500`),
194
194
  } as AnyObject
195
195
  }
196
- ref={(e) => e != null && setTimeout(() => e.focus(), 100)}
196
+ ref={(e) => {
197
+ e != null && setTimeout(() => e.focus(), 100);
198
+ }}
197
199
  onBlur={(e) => e.target.focus()}
198
200
  onChange={(e) => setValue(e.target.value)}
199
201
  onKeyDown={(e) => e.key === "Enter" && handleClose(value)}
@@ -64,7 +64,7 @@ export interface TooltipProps extends TooltipType, RefProp {
64
64
  */
65
65
  copyContent?: boolean | string;
66
66
  disabled?: boolean;
67
- children: ReactElement;
67
+ children: ReactElement<KeyValue>;
68
68
  }
69
69
 
70
70
  export const getTooltipProps = (
@@ -336,6 +336,10 @@ export interface CssProp {
336
336
  * css classname(s)
337
337
  */
338
338
  className?: string;
339
+ /**
340
+ * direction
341
+ */
342
+ dir?: "ltr" | "rtl";
339
343
  }
340
344
 
341
345
  export interface TestProps {
@@ -463,3 +467,16 @@ export interface ScrollObject extends PositionObject, SizeObject {
463
467
  scrollWidth?: number;
464
468
  scrollHeight: number;
465
469
  }
470
+
471
+ export type ArrayType<T extends readonly any[] | ArrayLike<any> | undefined> =
472
+ T extends readonly any[]
473
+ ? T[number]
474
+ : T extends ArrayLike<any>
475
+ ? T[number]
476
+ : undefined;
477
+
478
+ export type Complete<T> = {
479
+ [P in keyof Required<T>]: Pick<T, P> extends Required<Pick<T, P>>
480
+ ? T[P]
481
+ : T[P] | undefined;
482
+ };
@@ -32,11 +32,14 @@ export const cloneChildren = (
32
32
  if (isValidElement(c)) {
33
33
  if (c.type === Fragment) {
34
34
  // just compare to `Fragment`
35
- return cloneChildren(c.props?.children, callback);
35
+ return cloneChildren((c.props as AnyObject)?.children, callback);
36
36
  }
37
37
  return c;
38
38
  }
39
- return c;
39
+ if (c instanceof Promise) {
40
+ return undefined;
41
+ }
42
+ return c as AnyObject;
40
43
  })
41
44
  ?.flat()
42
45
  .filter(Boolean)