@progress/kendo-react-buttons
Version:
All you need in React Button in one package: disabled/enabled states, built-in styles and more. KendoReact Buttons package
90 lines (89 loc) • 2.28 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
import * as e from "react";
import t from "prop-types";
import { classNames as R, getTabIndex as T, IconWrap as h, svgIconPropType as D } from "@progress/kendo-react-common";
const f = e.forwardRef((p, I) => {
const {
className: c,
disabled: n,
text: s,
icon: i,
style: g,
id: k,
focused: m,
tabIndex: x,
index: o,
dataItem: y,
item: C,
svgIcon: r,
onDown: d,
onClick: l,
...N
} = p, a = e.useRef(null), u = e.useCallback(() => {
a.current && a.current.focus();
}, []), v = e.useCallback(
() => ({
element: a.current,
focus: u
}),
[u]
);
e.useImperativeHandle(I, v);
const E = e.useCallback(
(P) => {
l && o !== void 0 && !n && l(P, o);
},
[l, o]
), w = e.useMemo(
() => R(
"k-fab-item",
{
"k-focus": m,
"k-disabled": n
},
c
),
[c, n, m]
), b = C;
return /* @__PURE__ */ e.createElement(
"li",
{
ref: a,
id: k,
className: w,
style: g,
role: "menuitem",
tabIndex: T(x, n),
"aria-disabled": n,
"aria-label": `${s || ""} floatingactionbutton item`,
onClick: E,
onMouseDown: d,
onPointerDown: d,
...N
},
b ? /* @__PURE__ */ e.createElement(b, { itemIndex: o, item: y }) : /* @__PURE__ */ e.createElement(e.Fragment, null, s && /* @__PURE__ */ e.createElement("span", { className: "k-fab-item-text" }, s), i || r ? /* @__PURE__ */ e.createElement(h, { className: "k-fab-item-icon", name: i, icon: r }) : null)
);
});
f.propTypes = {
className: t.string,
style: t.object,
children: t.any,
disabled: t.bool,
focused: t.bool,
index: t.number,
icon: t.string,
svgIcon: D,
text: t.string,
tabIndex: t.number,
customProp: t.any
};
f.displayName = "KendoFloatingActionButtonItem";
export {
f as FloatingActionButtonItem
};