@react-fabric/core 1.0.0-beta.14 → 1.0.0-beta.17
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/index.js +1 -1
- package/dist/cjs/components/button/ButtonGroup.js +2 -1
- package/dist/cjs/components/button/ToggleButtonGroup.js +1 -1
- package/dist/cjs/components/menu/Menu.js +12 -14
- package/dist/esm/components/button/ButtonGroup.js +3 -2
- package/dist/esm/components/button/ToggleButtonGroup.js +3 -3
- package/dist/esm/components/menu/Menu.js +14 -16
- package/package.json +3 -3
- package/src/components/button/ButtonGroup.tsx +3 -2
- package/src/components/button/ToggleButtonGroup.tsx +3 -3
- package/src/components/menu/Menu.tsx +18 -21
package/css/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
4
|
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
5
|
+
var utilities = require('@react-fabric/utilities');
|
|
5
6
|
var classNames = require('classnames');
|
|
6
7
|
var react = require('react');
|
|
7
8
|
var Button_module = require('./Button.module.css');
|
|
@@ -25,7 +26,7 @@ var ButtonGroup = function ButtonGroup(_ref) {
|
|
|
25
26
|
"data-ref": "buttonGroup",
|
|
26
27
|
className: classNames(Button_module.buttonGroup, className, fullWidth ? "flex" : "inline-flex", "flex-nowrap align-middle rounded", vertical && Button_module.vertical, vertical && "flex-col items-stretch")
|
|
27
28
|
}, aria), {}, {
|
|
28
|
-
children:
|
|
29
|
+
children: utilities.cloneChildren(children, function (child) {
|
|
29
30
|
return /*#__PURE__*/react.cloneElement(child, _objectSpread({
|
|
30
31
|
color: color,
|
|
31
32
|
size: size,
|
|
@@ -48,7 +48,7 @@ var ToggleButtonGroup = function ToggleButtonGroup(_ref) {
|
|
|
48
48
|
return /*#__PURE__*/jsxRuntime.jsx("div", _objectSpread(_objectSpread({
|
|
49
49
|
className: classNames(Button_module.buttonGroup, className, fullWidth ? "flex" : "inline-flex", "flex-nowrap align-middle", vertical && Button_module.vertical, vertical && "flex-col")
|
|
50
50
|
}, aria), {}, {
|
|
51
|
-
children:
|
|
51
|
+
children: utilities.cloneChildren(children, function (child) {
|
|
52
52
|
return /*#__PURE__*/react.cloneElement(child, _objectSpread(_objectSpread({
|
|
53
53
|
color: color,
|
|
54
54
|
size: size,
|
|
@@ -168,20 +168,18 @@ var MenuComponent = function MenuComponent(_ref) {
|
|
|
168
168
|
onClick: isNested ? undefined : handleClick
|
|
169
169
|
})), {}, {
|
|
170
170
|
style: !isNested ? rest.style : floatingStyles,
|
|
171
|
-
children:
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
})) : {});
|
|
184
|
-
}
|
|
171
|
+
children: utilities.cloneChildren(children, function (child, index) {
|
|
172
|
+
labelsRef.current[index] = child.props.label;
|
|
173
|
+
return /*#__PURE__*/react$1.cloneElement(child, nodeCheck.nodeCheck(child, MenuItem.MenuItem, Menu, MenuComponent) ? _objectSpread({
|
|
174
|
+
minimal: !isNested && minimal,
|
|
175
|
+
"data-focus": activeIndex === index,
|
|
176
|
+
ref: function ref(el) {
|
|
177
|
+
return elementsRef.current[index] = el;
|
|
178
|
+
}
|
|
179
|
+
}, getItemProps({
|
|
180
|
+
onClick: child.props.onClick,
|
|
181
|
+
tabIndex: activeIndex === index ? 0 : -1
|
|
182
|
+
})) : {});
|
|
185
183
|
})
|
|
186
184
|
}))
|
|
187
185
|
})]
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
4
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
5
|
+
import { cloneChildren } from '@react-fabric/utilities';
|
|
5
6
|
import classNames from 'classnames';
|
|
6
|
-
import {
|
|
7
|
+
import { cloneElement } from 'react';
|
|
7
8
|
import classes from './Button.module.css';
|
|
8
9
|
import { jsx } from 'react/jsx-runtime';
|
|
9
10
|
|
|
@@ -25,7 +26,7 @@ var ButtonGroup = function ButtonGroup(_ref) {
|
|
|
25
26
|
"data-ref": "buttonGroup",
|
|
26
27
|
className: classNames(classes.buttonGroup, className, fullWidth ? "flex" : "inline-flex", "flex-nowrap align-middle rounded", vertical && classes.vertical, vertical && "flex-col items-stretch")
|
|
27
28
|
}, aria), {}, {
|
|
28
|
-
children:
|
|
29
|
+
children: cloneChildren(children, function (child) {
|
|
29
30
|
return /*#__PURE__*/cloneElement(child, _objectSpread({
|
|
30
31
|
color: color,
|
|
31
32
|
size: size,
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
4
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
5
5
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
6
|
-
import { isArray, EMPTY_ARRAY } from '@react-fabric/utilities';
|
|
6
|
+
import { isArray, EMPTY_ARRAY, cloneChildren } from '@react-fabric/utilities';
|
|
7
7
|
import classNames from 'classnames';
|
|
8
|
-
import { useMemo, useCallback,
|
|
8
|
+
import { useMemo, useCallback, cloneElement } from 'react';
|
|
9
9
|
import { useControlledValue } from '../../hooks/useControlledValue.js';
|
|
10
10
|
import classes from './Button.module.css';
|
|
11
11
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -48,7 +48,7 @@ var ToggleButtonGroup = function ToggleButtonGroup(_ref) {
|
|
|
48
48
|
return /*#__PURE__*/jsx("div", _objectSpread(_objectSpread({
|
|
49
49
|
className: classNames(classes.buttonGroup, className, fullWidth ? "flex" : "inline-flex", "flex-nowrap align-middle", vertical && classes.vertical, vertical && "flex-col")
|
|
50
50
|
}, aria), {}, {
|
|
51
|
-
children:
|
|
51
|
+
children: cloneChildren(children, function (child) {
|
|
52
52
|
return /*#__PURE__*/cloneElement(child, _objectSpread(_objectSpread({
|
|
53
53
|
color: color,
|
|
54
54
|
size: size,
|
|
@@ -4,9 +4,9 @@ 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 { useFloatingParentNodeId, FloatingTree, useFloatingTree, useFloatingNodeId, useFloating, offset, flip, shift, autoUpdate, useHover, safePolygon, useClick, useRole, useDismiss, useListNavigation, useTypeahead, useInteractions, FloatingNode, FloatingList, FloatingOverlay, FloatingFocusManager, FloatingPortal } from '@floating-ui/react';
|
|
7
|
-
import { mergeRefs } from '@react-fabric/utilities';
|
|
7
|
+
import { mergeRefs, cloneChildren } from '@react-fabric/utilities';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
|
-
import { useState, useRef, useEffect, useCallback,
|
|
9
|
+
import { useState, useRef, useEffect, useCallback, cloneElement, Fragment } from 'react';
|
|
10
10
|
import { CoreIcons } from '../../types/icons.js';
|
|
11
11
|
import { nodeCheck } from '../../utils/nodeCheck.js';
|
|
12
12
|
import { MenuItem } from './MenuItem.js';
|
|
@@ -168,20 +168,18 @@ var MenuComponent = function MenuComponent(_ref) {
|
|
|
168
168
|
onClick: isNested ? undefined : handleClick
|
|
169
169
|
})), {}, {
|
|
170
170
|
style: !isNested ? rest.style : floatingStyles,
|
|
171
|
-
children:
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
})) : {});
|
|
184
|
-
}
|
|
171
|
+
children: cloneChildren(children, function (child, index) {
|
|
172
|
+
labelsRef.current[index] = child.props.label;
|
|
173
|
+
return /*#__PURE__*/cloneElement(child, nodeCheck(child, MenuItem, Menu, MenuComponent) ? _objectSpread({
|
|
174
|
+
minimal: !isNested && minimal,
|
|
175
|
+
"data-focus": activeIndex === index,
|
|
176
|
+
ref: function ref(el) {
|
|
177
|
+
return elementsRef.current[index] = el;
|
|
178
|
+
}
|
|
179
|
+
}, getItemProps({
|
|
180
|
+
onClick: child.props.onClick,
|
|
181
|
+
tabIndex: activeIndex === index ? 0 : -1
|
|
182
|
+
})) : {});
|
|
185
183
|
})
|
|
186
184
|
}))
|
|
187
185
|
})]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-fabric/core",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.17",
|
|
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.
|
|
39
|
+
"@react-fabric/utilities": "^1.0.0-beta.17",
|
|
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": "
|
|
59
|
+
"gitHead": "a2a0f20255da48d1cbcbcfe100fd3fbd4d13da67"
|
|
60
60
|
}
|
|
@@ -21,8 +21,9 @@
|
|
|
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 { cloneChildren } from "@react-fabric/utilities";
|
|
24
25
|
import classNames from "classnames";
|
|
25
|
-
import {
|
|
26
|
+
import { cloneElement } from "react";
|
|
26
27
|
import {
|
|
27
28
|
type AriaProps,
|
|
28
29
|
type ChildrenProp,
|
|
@@ -96,7 +97,7 @@ export const ButtonGroup = ({
|
|
|
96
97
|
)}
|
|
97
98
|
{...aria}
|
|
98
99
|
>
|
|
99
|
-
{
|
|
100
|
+
{cloneChildren(children, (child: AnyObject) =>
|
|
100
101
|
cloneElement(child, {
|
|
101
102
|
color,
|
|
102
103
|
size,
|
|
@@ -21,9 +21,9 @@
|
|
|
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 { EMPTY_ARRAY, isArray } from "@react-fabric/utilities";
|
|
24
|
+
import { cloneChildren, EMPTY_ARRAY, isArray } from "@react-fabric/utilities";
|
|
25
25
|
import classNames from "classnames";
|
|
26
|
-
import {
|
|
26
|
+
import { cloneElement, useCallback, useMemo } from "react";
|
|
27
27
|
import { useControlledValue } from "../../hooks/useControlledValue";
|
|
28
28
|
import {
|
|
29
29
|
type AriaProps,
|
|
@@ -140,7 +140,7 @@ export const ToggleButtonGroup = ({
|
|
|
140
140
|
)}
|
|
141
141
|
{...aria}
|
|
142
142
|
>
|
|
143
|
-
{
|
|
143
|
+
{cloneChildren(children, (child: AnyObject) =>
|
|
144
144
|
cloneElement(child, {
|
|
145
145
|
color,
|
|
146
146
|
size,
|
|
@@ -45,10 +45,9 @@ import {
|
|
|
45
45
|
useRole,
|
|
46
46
|
useTypeahead,
|
|
47
47
|
} from "@floating-ui/react";
|
|
48
|
-
import { mergeRefs } from "@react-fabric/utilities";
|
|
48
|
+
import { cloneChildren, mergeRefs } from "@react-fabric/utilities";
|
|
49
49
|
import classNames from "classnames";
|
|
50
50
|
import {
|
|
51
|
-
Children,
|
|
52
51
|
cloneElement,
|
|
53
52
|
Fragment,
|
|
54
53
|
useCallback,
|
|
@@ -231,25 +230,23 @@ const MenuComponent = ({
|
|
|
231
230
|
// @ts-expect-error ignore
|
|
232
231
|
{...{ style: !isNested ? rest.style : floatingStyles }}
|
|
233
232
|
>
|
|
234
|
-
{
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
);
|
|
252
|
-
}
|
|
233
|
+
{cloneChildren(children, (child: AnyObject, index) => {
|
|
234
|
+
labelsRef.current[index] = child.props.label;
|
|
235
|
+
return cloneElement(
|
|
236
|
+
child,
|
|
237
|
+
nodeCheck(child, MenuItem, Menu, MenuComponent)
|
|
238
|
+
? {
|
|
239
|
+
minimal: !isNested && minimal,
|
|
240
|
+
"data-focus": activeIndex === index,
|
|
241
|
+
ref: (el: HTMLElement) =>
|
|
242
|
+
(elementsRef.current[index] = el),
|
|
243
|
+
...getItemProps({
|
|
244
|
+
onClick: child.props.onClick,
|
|
245
|
+
tabIndex: activeIndex === index ? 0 : -1,
|
|
246
|
+
}),
|
|
247
|
+
}
|
|
248
|
+
: {},
|
|
249
|
+
);
|
|
253
250
|
})}
|
|
254
251
|
</div>
|
|
255
252
|
</FloatingFocusManager>
|