@uxf/ui 1.0.0-beta.148 → 1.0.0-beta.149
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/button-list/button-list.js +16 -11
- package/hooks/use-dropdown.d.ts +4 -4
- package/hooks/use-dropdown.js +1 -2
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ const cx_1 = require("@uxf/core/utils/cx");
|
|
|
11
11
|
const icon_1 = require("../icon");
|
|
12
12
|
const useAnchorProps_1 = require("@uxf/core/hooks/useAnchorProps");
|
|
13
13
|
const use_dropdown_1 = require("../hooks/use-dropdown");
|
|
14
|
+
const react_3 = require("@floating-ui/react");
|
|
14
15
|
const MenuButton = (props) => {
|
|
15
16
|
// eslint-disable-next-line react/destructuring-assignment,@typescript-eslint/no-unused-vars
|
|
16
17
|
const { variant, color, isIconButton, isFullWidth, size, icon, label, className, ...restProps } = props;
|
|
@@ -23,12 +24,12 @@ const MenuButton = (props) => {
|
|
|
23
24
|
label && react_1.default.createElement("span", { className: "uxf-button-list__menu-button-label" }, label)));
|
|
24
25
|
};
|
|
25
26
|
const ButtonList = (props) => {
|
|
26
|
-
var _a, _b, _c, _d, _e, _f
|
|
27
|
+
var _a, _b, _c, _d, _e, _f;
|
|
27
28
|
const buttonsToRender = props.buttons.slice(0, props.visibleButtonsCount);
|
|
28
29
|
const restButtons = props.buttons.slice(props.visibleButtonsCount, props.buttons.length);
|
|
29
30
|
const openButtonIcon = ((_a = props.openButton) === null || _a === void 0 ? void 0 : _a.icon) === null ? null : (_c = (_b = props.openButton) === null || _b === void 0 ? void 0 : _b.icon) !== null && _c !== void 0 ? _c : "ellipsis-vertical";
|
|
30
31
|
const openButtonLabel = (_e = (_d = props.openButton) === null || _d === void 0 ? void 0 : _d.label) !== null && _e !== void 0 ? _e : null;
|
|
31
|
-
const dropdown = (0, use_dropdown_1.useDropdown)((_f = props.menuPlacement) !== null && _f !== void 0 ? _f : "bottom-start"
|
|
32
|
+
const dropdown = (0, use_dropdown_1.useDropdown)((_f = props.menuPlacement) !== null && _f !== void 0 ? _f : "bottom-start");
|
|
32
33
|
return (react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-button-list", props.className) },
|
|
33
34
|
buttonsToRender.map((button, index) => {
|
|
34
35
|
var _a, _b, _c;
|
|
@@ -37,15 +38,19 @@ const ButtonList = (props) => {
|
|
|
37
38
|
icon && react_1.default.createElement(icon_1.Icon, { name: icon, className: "uxf-button-list__button-icon" }),
|
|
38
39
|
label && react_1.default.createElement("span", { className: "uxf-button-list__button-label" }, label)));
|
|
39
40
|
}),
|
|
40
|
-
restButtons.length > 0 && (react_1.default.createElement(react_2.Menu, { as: "div", className: "uxf-button-list__menu" },
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
react_1.default.createElement(
|
|
48
|
-
|
|
41
|
+
restButtons.length > 0 && (react_1.default.createElement(react_2.Menu, { as: "div", className: "uxf-button-list__menu" }, ({ open }) => {
|
|
42
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
43
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
44
|
+
react_1.default.createElement(react_2.Menu.Button, { as: button_1.Button, ...props.openButton, color: (_b = (_a = props.openButton) === null || _a === void 0 ? void 0 : _a.color) !== null && _b !== void 0 ? _b : props.color, size: (_d = (_c = props.openButton) === null || _c === void 0 ? void 0 : _c.size) !== null && _d !== void 0 ? _d : props.size, variant: (_f = (_e = props.openButton) === null || _e === void 0 ? void 0 : _e.variant) !== null && _f !== void 0 ? _f : props.variant, className: (0, cx_1.cx)((_g = props.openButton) === null || _g === void 0 ? void 0 : _g.className, "uxf-button-list__open-button"), isIconButton: !!openButtonIcon && !openButtonLabel, ref: dropdown.reference },
|
|
45
|
+
openButtonIcon && (react_1.default.createElement(icon_1.Icon, { name: openButtonIcon, className: "uxf-button-list__open-button-icon" })),
|
|
46
|
+
openButtonLabel && (react_1.default.createElement("span", { className: "uxf-button-list__open-button-label" }, openButtonLabel))),
|
|
47
|
+
open && (react_1.default.createElement(react_3.FloatingPortal, null,
|
|
48
|
+
react_1.default.createElement(react_2.Menu.Items, { className: "uxf-button-list__menu-items", ref: dropdown.floating }, restButtons.map((button, index) => {
|
|
49
|
+
var _a, _b, _c;
|
|
50
|
+
return (react_1.default.createElement(react_2.Menu.Item, { key: index },
|
|
51
|
+
react_1.default.createElement(MenuButton, { ...button, color: (_a = button.color) !== null && _a !== void 0 ? _a : props.color, size: (_b = button.size) !== null && _b !== void 0 ? _b : props.size, variant: (_c = button.variant) !== null && _c !== void 0 ? _c : props.variant })));
|
|
52
|
+
}))))));
|
|
53
|
+
}))));
|
|
49
54
|
};
|
|
50
55
|
exports.ButtonList = ButtonList;
|
|
51
56
|
exports.ButtonList.displayName = "UxfUiButtonList";
|
package/hooks/use-dropdown.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Placement
|
|
3
|
-
export declare function useDropdown(placement: Placement, matchWidth?: boolean
|
|
2
|
+
import { Placement } from "@floating-ui/react";
|
|
3
|
+
export declare function useDropdown(placement: Placement, matchWidth?: boolean): {
|
|
4
4
|
placement: Placement;
|
|
5
|
-
strategy: Strategy;
|
|
5
|
+
strategy: import("@floating-ui/react").Strategy;
|
|
6
6
|
middlewareData: import("@floating-ui/react").MiddlewareData;
|
|
7
7
|
x: number | null;
|
|
8
8
|
y: number | null;
|
|
@@ -14,7 +14,7 @@ export declare function useDropdown(placement: Placement, matchWidth?: boolean,
|
|
|
14
14
|
x: number | null;
|
|
15
15
|
y: number | null;
|
|
16
16
|
placement: Placement;
|
|
17
|
-
strategy: Strategy;
|
|
17
|
+
strategy: import("@floating-ui/react").Strategy;
|
|
18
18
|
middlewareData: import("@floating-ui/react").MiddlewareData;
|
|
19
19
|
update: () => void;
|
|
20
20
|
reference: (node: import("@floating-ui/react").ReferenceType | null) => void;
|
package/hooks/use-dropdown.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useDropdown = void 0;
|
|
4
4
|
const react_1 = require("@floating-ui/react");
|
|
5
|
-
function useDropdown(placement, matchWidth = false
|
|
5
|
+
function useDropdown(placement, matchWidth = false) {
|
|
6
6
|
return (0, react_1.useFloating)({
|
|
7
7
|
placement,
|
|
8
8
|
middleware: [
|
|
@@ -22,7 +22,6 @@ function useDropdown(placement, matchWidth = false, floatingStrategy = "absolute
|
|
|
22
22
|
},
|
|
23
23
|
}),
|
|
24
24
|
],
|
|
25
|
-
strategy: floatingStrategy,
|
|
26
25
|
whileElementsMounted: (reference, floating, update) => (0, react_1.autoUpdate)(reference, floating, update, {
|
|
27
26
|
elementResize: typeof ResizeObserver !== "undefined",
|
|
28
27
|
}),
|