@dust-tt/sparkle 0.2.59 → 0.2.60

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.
@@ -8,7 +8,7 @@ export declare function DropdownMenu({ children, className }: DropdownMenuProps)
8
8
  export declare namespace DropdownMenu {
9
9
  var Button: ({ label, type, size, tooltip, icon, children, tooltipPosition, className, disabled, onClick, }: DropdownButtonProps) => React.JSX.Element;
10
10
  var Item: ({ label, description, href, disabled, visual, icon, onClick, hasChildren, children, }: DropdownItemProps) => React.JSX.Element;
11
- var Items: ({ origin, width, children, }: DropdownItemsProps) => React.JSX.Element;
11
+ var Items: ({ origin, width, marginLeft, children, }: DropdownItemsProps) => React.JSX.Element;
12
12
  }
13
13
  export interface DropdownButtonProps {
14
14
  label?: string;
@@ -36,6 +36,7 @@ interface DropdownItemProps {
36
36
  interface DropdownItemsProps {
37
37
  origin?: "topLeft" | "topRight" | "bottomLeft" | "bottomRight" | "auto";
38
38
  width?: number;
39
+ marginLeft?: number;
39
40
  children: React.ReactNode;
40
41
  }
41
42
  export {};
package/dist/esm/index.js CHANGED
@@ -32735,13 +32735,18 @@ DropdownMenu.Button = function (_a) {
32735
32735
  if (children) {
32736
32736
  return (React__default.createElement(it.Button, { as: "div", disabled: disabled, ref: buttonRef, className: classNames(disabled ? "s-cursor-default" : "s-cursor-pointer", className, "s-group s-flex s-justify-items-center s-text-sm s-font-medium focus:s-outline-none focus:s-ring-0", label ? "s-gap-1.5" : "s-gap-0"), onClick: onClick }, tooltip ? (React__default.createElement(Tooltip, { position: tooltipPosition, label: tooltip }, children)) : (children)));
32737
32737
  }
32738
+ var chevronIcon = type === "select"
32739
+ ? SvgChevronUpDown$1
32740
+ : type === "submenu"
32741
+ ? SvgChevronRight$1
32742
+ : SvgChevronDown$1;
32738
32743
  return (React__default.createElement(React__default.Fragment, null, tooltip ? (React__default.createElement(Tooltip, { label: tooltip, position: tooltipPosition },
32739
32744
  React__default.createElement(it.Button, { disabled: disabled, ref: buttonRef, className: classNames(disabled ? "s-cursor-default" : "s-cursor-pointer", className, "s-group s-flex s-justify-items-center s-text-sm s-font-medium focus:s-outline-none focus:s-ring-0", label ? (size === "md" ? "s-gap-2" : "s-gap-1.5") : "s-gap-0.5") },
32740
32745
  React__default.createElement(Icon, { visual: icon, size: size, className: finalIconClasses }),
32741
- React__default.createElement(Icon, { visual: type === "select" ? SvgChevronUpDown$1 : SvgChevronDown$1, size: size === "sm" ? "xs" : "sm", className: finalChevronClasses })))) : (React__default.createElement(it.Button, { disabled: disabled, ref: buttonRef, className: classNames(disabled ? "s-cursor-default" : "s-cursor-pointer", className, "s-group s-flex s-justify-items-center s-text-sm s-font-medium focus:s-outline-none focus:s-ring-0", label ? (size === "md" ? "s-gap-2" : "s-gap-1.5") : "s-gap-0.5", type === "submenu" ? "s-opacity-50" : "") },
32746
+ React__default.createElement(Icon, { visual: chevronIcon, size: size === "sm" ? "xs" : "sm", className: finalChevronClasses })))) : (React__default.createElement(it.Button, { disabled: disabled, ref: buttonRef, className: classNames(disabled ? "s-cursor-default" : "s-cursor-pointer", className, "s-group s-flex s-justify-items-center s-text-sm s-font-medium focus:s-outline-none focus:s-ring-0", label ? (size === "md" ? "s-gap-2" : "s-gap-1.5") : "s-gap-0.5", type === "submenu" ? "s-opacity-50" : "") },
32742
32747
  React__default.createElement(Icon, { visual: icon, size: size, className: finalIconClasses }),
32743
32748
  React__default.createElement("span", { className: classNames(finalLabelClasses, type === "submenu" ? "s-w-full" : "") }, label),
32744
- React__default.createElement(Icon, { visual: type === "select" ? SvgChevronUpDown$1 : SvgChevronDown$1, size: size === "sm" ? "xs" : "sm", className: finalChevronClasses })))));
32749
+ React__default.createElement(Icon, { visual: chevronIcon, size: size === "sm" ? "xs" : "sm", className: finalChevronClasses })))));
32745
32750
  };
32746
32751
  DropdownMenu.Item = function (_a) {
32747
32752
  var label = _a.label, description = _a.description, href = _a.href, disabled = _a.disabled, visual = _a.visual, icon = _a.icon, onClick = _a.onClick, hasChildren = _a.hasChildren, children = _a.children;
@@ -32752,9 +32757,9 @@ DropdownMenu.Item = function (_a) {
32752
32757
  children)) : (React__default.createElement(Item.Dropdown, { className: "s-w-full s-px-4", href: href, onClick: onClick, label: label, visual: visual, icon: icon, description: description }))));
32753
32758
  };
32754
32759
  DropdownMenu.Items = function (_a) {
32755
- var _b = _a.origin, origin = _b === void 0 ? "auto" : _b, _c = _a.width, width = _c === void 0 ? 160 : _c, children = _a.children;
32760
+ var _b = _a.origin, origin = _b === void 0 ? "auto" : _b, _c = _a.width, width = _c === void 0 ? 160 : _c, _d = _a.marginLeft, marginLeft = _d === void 0 ? 0 : _d, children = _a.children;
32756
32761
  var buttonRef = useContext(ButtonRefContext);
32757
- var _d = __read(useState(0), 2), buttonHeight = _d[0], setButtonHeight = _d[1];
32762
+ var _e = __read(useState(0), 2), buttonHeight = _e[0], setButtonHeight = _e[1];
32758
32763
  if (origin === "auto") {
32759
32764
  origin = findOriginFromButton(buttonRef);
32760
32765
  }
@@ -32791,18 +32796,26 @@ DropdownMenu.Items = function (_a) {
32791
32796
  return "s-origin-top-right";
32792
32797
  }
32793
32798
  };
32794
- var styleInsert = function (origin) {
32799
+ var styleInsert = function (origin, marginLeft) {
32795
32800
  switch (origin) {
32796
32801
  case "topLeft":
32797
- return { width: "".concat(width, "px"), top: "".concat(buttonHeight + 8, "px") };
32802
+ return {
32803
+ width: "".concat(width, "px"),
32804
+ top: "".concat(buttonHeight + 8, "px"),
32805
+ left: "".concat(marginLeft, "px"),
32806
+ };
32798
32807
  case "topRight":
32799
- return { width: "".concat(width, "px"), top: "".concat(buttonHeight + 8, "px") };
32808
+ return {
32809
+ width: "".concat(width, "px"),
32810
+ top: "".concat(buttonHeight + 8, "px"),
32811
+ left: "".concat(marginLeft, "px"),
32812
+ };
32800
32813
  default:
32801
- return { width: "".concat(width, "px") };
32814
+ return { width: "".concat(width, "px"), left: "".concat(marginLeft, "px") };
32802
32815
  }
32803
32816
  };
32804
32817
  return (React__default.createElement(tt, { as: Fragment, enter: "s-transition s-ease-out s-duration-200", enterFrom: getOriginTransClass(origin), enterTo: "s-transform s-opacity-100 s-scale-100 s-translate-y-0", leave: "s-transition s-ease-in s-duration-75", leaveFrom: "s-transform s-opacity-100 s-scale-100 s-translate-y-0", leaveTo: getOriginTransClass(origin) },
32805
- React__default.createElement(it.Items, { className: "s-absolute s-z-10 ".concat(getOriginClass(origin), " s-rounded-xl s-border s-border-structure-100 s-bg-structure-0 s-py-1 s-shadow-lg focus:s-outline-none dark:s-border-structure-100-dark dark:s-bg-structure-0-dark"), style: styleInsert(origin) },
32818
+ React__default.createElement(it.Items, { className: "s-absolute s-z-10 ".concat(getOriginClass(origin), " s-rounded-xl s-border s-border-structure-100 s-bg-structure-0 s-py-1 s-shadow-lg focus:s-outline-none dark:s-border-structure-100-dark dark:s-bg-structure-0-dark"), style: styleInsert(origin, marginLeft) },
32806
32819
  React__default.createElement(Item.List, null, children))));
32807
32820
  };
32808
32821
  function findOriginFromButton(buttonRef) {