@youngonesworks/ui 0.1.19 → 0.1.20
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/dist/components/button/index.d.ts +6 -3
- package/dist/icons/IconLoading.d.ts +1 -1
- package/dist/index.cjs +12 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ButtonHTMLAttributes, type ReactNode } from 'react';
|
|
2
2
|
import { buttonVariants } from './buttonVariants';
|
|
3
|
-
interface
|
|
3
|
+
export interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'> {
|
|
4
4
|
variant?: keyof typeof buttonVariants;
|
|
5
5
|
ariaLabel?: string;
|
|
6
6
|
isLoading?: boolean;
|
|
@@ -8,6 +8,9 @@ interface IButton extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
8
8
|
dataTestId?: string;
|
|
9
9
|
icon?: ReactNode;
|
|
10
10
|
iconRight?: boolean;
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export declare function Button({ type, variant, ariaLabel, block, isLoading, icon: iconFromProps, iconRight, onClick, className, children, dataTestId, ...props }: ButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare namespace Button {
|
|
15
|
+
var displayName: string;
|
|
11
16
|
}
|
|
12
|
-
export declare const Button: import("react").ForwardRefExoticComponent<IButton & import("react").RefAttributes<HTMLButtonElement>>;
|
|
13
|
-
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type SVGProps } from 'react';
|
|
2
|
-
export declare const IconLoading: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const IconLoading: ({ className, ...props }: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
|
package/dist/index.cjs
CHANGED
|
@@ -103324,10 +103324,13 @@ BreadCrumb.displayName = "BreadCrumb";
|
|
|
103324
103324
|
|
|
103325
103325
|
//#endregion
|
|
103326
103326
|
//#region src/icons/IconLoading.tsx
|
|
103327
|
-
const IconLoading = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
103327
|
+
const IconLoading = ({ className,...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
103328
103328
|
"data-component": "button",
|
|
103329
103329
|
"data-testid": "loading-svg-button",
|
|
103330
103330
|
viewBox: "0 0 256 256",
|
|
103331
|
+
width: "1em",
|
|
103332
|
+
height: "1em",
|
|
103333
|
+
className,
|
|
103331
103334
|
...props,
|
|
103332
103335
|
children: [
|
|
103333
103336
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("line", {
|
|
@@ -103421,22 +103424,22 @@ const buttonVariants = {
|
|
|
103421
103424
|
|
|
103422
103425
|
//#endregion
|
|
103423
103426
|
//#region src/components/button/index.tsx
|
|
103424
|
-
|
|
103425
|
-
const
|
|
103426
|
-
const
|
|
103427
|
+
function Button({ type = "button", variant = "primary", ariaLabel, block = false, isLoading = false, icon: iconFromProps = null, iconRight = false, onClick, className, children, dataTestId,...props }) {
|
|
103428
|
+
const loadingIcon = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconLoading, { className: "animate-spin-slow mr-2 stroke-current" });
|
|
103429
|
+
const icon = isLoading ? loadingIcon : iconFromProps;
|
|
103430
|
+
const formattedIcon = icon ? formatIcon(icon, { className: clsx_default({
|
|
103427
103431
|
"-mr-2": iconRight,
|
|
103428
103432
|
"-ml-2": !iconRight
|
|
103429
|
-
}) });
|
|
103433
|
+
}, icon === loadingIcon ? "text-current" : "size-[1.125rem]") }) : null;
|
|
103430
103434
|
const handleOnClick = (event) => {
|
|
103431
|
-
onClick
|
|
103435
|
+
onClick?.(event);
|
|
103432
103436
|
};
|
|
103433
103437
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
103434
103438
|
type,
|
|
103435
103439
|
"aria-label": ariaLabel,
|
|
103436
103440
|
"data-testid": dataTestId,
|
|
103437
103441
|
className: cn(buttonVariants[variant], className, block && "w-full"),
|
|
103438
|
-
onClick:
|
|
103439
|
-
ref,
|
|
103442
|
+
onClick: handleOnClick,
|
|
103440
103443
|
...props,
|
|
103441
103444
|
children: [
|
|
103442
103445
|
!iconRight && formattedIcon,
|
|
@@ -103444,7 +103447,7 @@ const Button = (0, react.forwardRef)(({ type = "button", variant = "primary", ar
|
|
|
103444
103447
|
iconRight && formattedIcon
|
|
103445
103448
|
]
|
|
103446
103449
|
});
|
|
103447
|
-
}
|
|
103450
|
+
}
|
|
103448
103451
|
Button.displayName = "Button";
|
|
103449
103452
|
|
|
103450
103453
|
//#endregion
|