@lamenna/lxp-react 0.1.0 → 0.1.1

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.
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { buttonConfig } from "@lamenna/lxp-shared-components";
3
- export const Button = ({ children, variant = "primary", size = "md", disabled = false, className, id, ariaLabel, testID, onClick, }) => {
3
+ export const Button = ({ children, label, variant = "primary", size = "md", disabled = false, className, id, ariaLabel, testID, onClick, }) => {
4
4
  const variantConfig = buttonConfig.variants[variant];
5
5
  const sizeConfig = buttonConfig.sizes[size];
6
6
  const styles = {
@@ -10,5 +10,5 @@ export const Button = ({ children, variant = "primary", size = "md", disabled =
10
10
  opacity: disabled ? 0.6 : 1,
11
11
  cursor: disabled ? "not-allowed" : "pointer",
12
12
  };
13
- return (React.createElement("button", { style: styles, type: "button", onClick: onClick, disabled: disabled, className: className, id: id, "aria-label": ariaLabel, "data-testid": testID }, children));
13
+ return (React.createElement("button", { style: styles, type: "button", onClick: onClick, disabled: disabled, className: className, id: id, "aria-label": ariaLabel, "data-testid": testID }, children ?? label));
14
14
  };
@@ -20,6 +20,15 @@ describe("Button Component (React)", () => {
20
20
  render(React.createElement(Button, null, "Test Button"));
21
21
  expect(screen.getByText("Test Button")).toBeInTheDocument();
22
22
  });
23
+ it("should display text from the label prop", () => {
24
+ render(React.createElement(Button, { label: "Sign in" }));
25
+ expect(screen.getByText("Sign in")).toBeInTheDocument();
26
+ });
27
+ it("should prefer children over label when both are provided", () => {
28
+ render(React.createElement(Button, { label: "Label text" }, "Children text"));
29
+ expect(screen.getByText("Children text")).toBeInTheDocument();
30
+ expect(screen.queryByText("Label text")).not.toBeInTheDocument();
31
+ });
23
32
  it("should apply primary variant styles by default", () => {
24
33
  render(React.createElement(Button, null, "Primary"));
25
34
  const button = screen.getByRole("button");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lamenna/lxp-react",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "React components for LXP",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",