@babylonlabs-io/core-ui 1.30.0 → 1.32.0
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/Icons/common/ThemeIcon.d.ts +2 -0
- package/dist/components/Icons/common/ThemeIcon.js +7 -0
- package/dist/components/Icons/index.d.ts +1 -0
- package/dist/components/Icons/index.js +1 -0
- package/dist/components/Menu/MenuItem.d.ts +14 -0
- package/dist/components/Menu/MenuItem.js +14 -7
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +800 -763
- package/dist/index.es.js.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/widgets/sections/PreviewModal/PreviewModal.d.ts +3 -3
- package/dist/widgets/sections/PreviewModal/PreviewModal.js +2 -2
- package/dist/widgets/sections/PreviewModal/PreviewModal.stories.d.ts +1 -0
- package/dist/widgets/sections/PreviewModal/PreviewModal.stories.js +40 -1
- package/dist/widgets/sections/SettingMenu/SettingMenu.stories.d.ts +1 -0
- package/dist/widgets/sections/SettingMenu/SettingMenu.stories.js +15 -1
- package/dist/widgets/sections/SettingMenu/components/SettingMenuItem.d.ts +15 -0
- package/dist/widgets/sections/SettingMenu/components/SettingMenuItem.js +3 -3
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { iconColorVariants } from "../index";
|
|
3
|
+
import { twJoin } from "tailwind-merge";
|
|
4
|
+
export const ThemeIcon = ({ className = "", size = 40, variant = "default", color, }) => {
|
|
5
|
+
const colorClass = color || iconColorVariants[variant];
|
|
6
|
+
return (_jsxs("svg", { style: { width: size, height: size }, viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: twJoin("transition-opacity duration-200", className), children: [_jsx("rect", { width: "40", height: "40", rx: "20", fill: "currentColor", fillOpacity: "0.12" }), _jsx("path", { d: "M20 30C25.52 30 30 25.52 30 20C30 14.48 25.52 10 20 10C14.48 10 10 14.48 10 20C10 25.52 14.48 30 20 30ZM21 12.07C24.94 12.56 28 15.92 28 20C28 24.08 24.95 27.44 21 27.93V12.07Z", fill: "currentColor", className: colorClass })] }));
|
|
7
|
+
};
|
|
@@ -26,3 +26,4 @@ export { CollapseIcon } from "./common/CollapseIcon";
|
|
|
26
26
|
export { OpenIcon } from "./common/OpenIcon";
|
|
27
27
|
export { ChevronLeftIcon } from "./common/ChevronLeftIcon";
|
|
28
28
|
export { BugReportIcon } from "./common/BugReportIcon";
|
|
29
|
+
export { ThemeIcon } from "./common/ThemeIcon";
|
|
@@ -21,3 +21,4 @@ export { CollapseIcon } from "./common/CollapseIcon";
|
|
|
21
21
|
export { OpenIcon } from "./common/OpenIcon";
|
|
22
22
|
export { ChevronLeftIcon } from "./common/ChevronLeftIcon";
|
|
23
23
|
export { BugReportIcon } from "./common/BugReportIcon";
|
|
24
|
+
export { ThemeIcon } from "./common/ThemeIcon";
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
interface MenuItemToggleProps {
|
|
3
|
+
/** Current toggle value */
|
|
4
|
+
value?: boolean;
|
|
5
|
+
/** Default toggle value */
|
|
6
|
+
defaultValue?: boolean;
|
|
7
|
+
/** Toggle change handler */
|
|
8
|
+
onChange?: (value: boolean) => void;
|
|
9
|
+
/** Icon to show when toggle is active */
|
|
10
|
+
activeIcon?: React.ReactNode;
|
|
11
|
+
/** Icon to show when toggle is inactive */
|
|
12
|
+
inactiveIcon?: React.ReactNode;
|
|
13
|
+
}
|
|
2
14
|
interface MenuItemProps {
|
|
3
15
|
/** Leading icon or element */
|
|
4
16
|
icon?: React.ReactNode;
|
|
@@ -20,6 +32,8 @@ interface MenuItemProps {
|
|
|
20
32
|
selected?: boolean;
|
|
21
33
|
/** Role attribute for accessibility */
|
|
22
34
|
role?: string;
|
|
35
|
+
/** Toggle configuration - when provided, renders a toggle switch as suffix */
|
|
36
|
+
toggle?: MenuItemToggleProps;
|
|
23
37
|
}
|
|
24
38
|
export declare const MenuItem: React.FC<MenuItemProps>;
|
|
25
39
|
export {};
|
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { twJoin } from "tailwind-merge";
|
|
3
3
|
import { useMenuContext } from "./MenuContext";
|
|
4
|
-
|
|
4
|
+
import { Toggle } from "../Toggle/Toggle";
|
|
5
|
+
export const MenuItem = ({ icon, name, description, onClick, disabled = false, className, children, suffix, selected = false, role = "menuitem", toggle, }) => {
|
|
5
6
|
const menuContext = useMenuContext();
|
|
7
|
+
const toggleElement = toggle ? (_jsx(Toggle, { value: toggle.value, defaultValue: toggle.defaultValue, onChange: toggle.onChange })) : null;
|
|
8
|
+
const finalSuffix = toggleElement || suffix;
|
|
6
9
|
const handleClick = () => {
|
|
7
|
-
if (disabled
|
|
10
|
+
if (disabled)
|
|
8
11
|
return;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (
|
|
12
|
+
if (toggleElement)
|
|
13
|
+
return;
|
|
14
|
+
if (onClick) {
|
|
15
|
+
onClick();
|
|
16
|
+
}
|
|
17
|
+
if (menuContext && !finalSuffix) {
|
|
12
18
|
menuContext.onClose();
|
|
13
19
|
}
|
|
14
20
|
};
|
|
15
|
-
// If children are provided, render them instead of the default layout
|
|
16
21
|
if (children) {
|
|
17
22
|
return (_jsx("button", { onClick: handleClick, disabled: disabled, className: twJoin("w-full text-left", disabled && "cursor-not-allowed opacity-50", className), children: children }));
|
|
18
23
|
}
|
|
19
|
-
return (_jsxs("
|
|
24
|
+
return (_jsxs("div", { className: twJoin("flex w-full items-center justify-between p-6", "transition-colors", !toggleElement && "cursor-pointer hover:bg-accent-secondary/5", // Only hover if no toggle
|
|
25
|
+
"text-left", selected && "bg-accent-secondary/10", disabled && "cursor-not-allowed opacity-50", toggleElement && "cursor-default", // Disable pointer cursor when toggle is present
|
|
26
|
+
className), role: role, "aria-selected": selected, onClick: handleClick, children: [_jsxs("div", { className: "flex items-center gap-3", children: [icon && _jsx("div", { className: "flex-shrink-0", children: icon }), _jsxs("div", { className: "flex flex-col", children: [_jsx("div", { className: "text-sm font-medium text-accent-primary", children: name }), description && _jsx("div", { className: "text-xs text-accent-secondary", children: description })] })] }), finalSuffix && (_jsx("div", { className: "flex-shrink-0", children: finalSuffix }))] }));
|
|
20
27
|
};
|