@yamada-ui/button
Version:
Yamada UI button components
96 lines (95 loc) • 3.16 kB
JavaScript
"use client"
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/button-group.tsx
var button_group_exports = {};
__export(button_group_exports, {
ButtonGroup: () => ButtonGroup,
useButtonGroup: () => useButtonGroup
});
module.exports = __toCommonJS(button_group_exports);
var import_core = require("@yamada-ui/core");
var import_utils = require("@yamada-ui/utils");
var import_react = require("react");
var import_jsx_runtime = require("react/jsx-runtime");
var [ButtonGroupProvider, useButtonGroup] = (0, import_utils.createContext)(
{
name: "ButtonGroupContext",
strict: false
}
);
var ButtonGroup = (0, import_core.forwardRef)(
({
className,
size,
variant,
isAttached,
attached = isAttached,
columnGap,
direction,
isDisabled,
disabled = isDisabled,
flexDirection = direction,
gap,
rowGap,
...rest
}, ref) => {
const column = flexDirection === "column" || flexDirection === "column-reverse";
const css = {
display: "inline-flex",
flexDirection
};
const context = (0, import_react.useMemo)(
() => ({ size, variant, disabled }),
[size, variant, disabled]
);
if (attached) {
Object.assign(css, {
"> *:first-of-type:not(:last-of-type)": column ? { borderBottomRadius: 0 } : { borderRightRadius: 0, borderRightWidth: "0px" },
"> *:not(:first-of-type):last-of-type": column ? { borderTopRadius: 0, borderTopWidth: "0px" } : { borderLeftRadius: 0 },
"> *:not(:first-of-type):not(:last-of-type)": column ? { borderRadius: 0, borderTopWidth: "0px" } : { borderRadius: 0, borderRightWidth: "0px" }
});
} else {
Object.assign(css, {
columnGap,
gap,
rowGap
});
}
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ButtonGroupProvider, { value: context, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_core.ui.div,
{
ref,
className: (0, import_utils.cx)("ui-button-group", className),
"data-attached": (0, import_utils.dataAttr)(attached),
role: "group",
__css: css,
...rest
}
) });
}
);
ButtonGroup.displayName = "ButtonGroup";
ButtonGroup.__ui__ = "ButtonGroup";
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ButtonGroup,
useButtonGroup
});
//# sourceMappingURL=button-group.js.map