@dust-tt/sparkle 0.2.239 → 0.2.241

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/cjs/index.js CHANGED
@@ -71998,14 +71998,25 @@ function DropdownMenu(_a) {
71998
71998
  return (React.createElement(ButtonRefContext.Provider, { value: buttonRef },
71999
71999
  React.createElement(qe$1, { as: "div", className: classNames(className, "s-relative s-inline-block") }, children)));
72000
72000
  }
72001
- DropdownMenu.Button = function (_a) {
72002
- var label = _a.label, _b = _a.type, type = _b === void 0 ? "menu" : _b, _c = _a.size, size = _c === void 0 ? "sm" : _c, tooltip = _a.tooltip, icon = _a.icon, children = _a.children, _d = _a.tooltipPosition, tooltipPosition = _d === void 0 ? "above" : _d, _e = _a.className, className = _e === void 0 ? "" : _e, _f = _a.disabled, disabled = _f === void 0 ? false : _f;
72001
+ DropdownMenu.Button = React.forwardRef(function DropdownMenuButton(_a, forwardedRef) {
72002
+ var label = _a.label, _b = _a.type, type = _b === void 0 ? "menu" : _b, _c = _a.size, size = _c === void 0 ? "sm" : _c, tooltip = _a.tooltip, icon = _a.icon, children = _a.children, _d = _a.tooltipPosition, tooltipPosition = _d === void 0 ? "above" : _d, _e = _a.className, className = _e === void 0 ? "" : _e, _f = _a.disabled, disabled = _f === void 0 ? false : _f, onClick = _a.onClick;
72003
+ var contextRef = React.useContext(ButtonRefContext);
72003
72004
  var finalLabelClasses = classNames(labelClasses$1.base, labelSizeClasses[size], labelClasses$1.dark.base, !disabled ? labelClasses$1.active : "", !disabled ? labelClasses$1.dark.active : "", !disabled ? labelClasses$1.hover : "", !disabled ? labelClasses$1.dark.hover : "", disabled ? labelClasses$1.disabled : "");
72004
72005
  var finalIconClasses = classNames(iconClasses$3.base, iconClasses$3.dark.base, !disabled ? iconClasses$3.hover : "", !disabled ? iconClasses$3.dark.hover : "", disabled ? iconClasses$3.disabled : "");
72005
72006
  var finalChevronClasses = classNames(chevronClasses.base, !disabled ? chevronClasses.hover : "", chevronClasses.dark.base, !disabled ? chevronClasses.dark.hover : "", disabled ? chevronClasses.disabled : "");
72006
- var buttonRef = React.useContext(ButtonRefContext);
72007
+ var aggregatedRef = function (value) {
72008
+ if (contextRef) {
72009
+ contextRef.current = value;
72010
+ }
72011
+ if (typeof forwardedRef === "function") {
72012
+ forwardedRef(value);
72013
+ }
72014
+ else if (forwardedRef) {
72015
+ forwardedRef.current = value;
72016
+ }
72017
+ };
72007
72018
  if (children) {
72008
- return (React.createElement(qe$1.Button, { as: "div", disabled: disabled, ref: buttonRef, className: classNames(disabled ? "s-cursor-default" : "s-cursor-pointer", className, "s-group/dm 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: function (e) { return e.stopPropagation(); } }, tooltip ? (React.createElement(Tooltip, { position: tooltipPosition, label: tooltip }, children)) : (children)));
72019
+ return (React.createElement(qe$1.Button, { as: "div", disabled: disabled, ref: aggregatedRef, className: classNames(disabled ? "s-cursor-default" : "s-cursor-pointer", className, "s-group/dm 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: function (e) { return e.stopPropagation(); } }, tooltip ? (React.createElement(Tooltip, { position: tooltipPosition, label: tooltip }, children)) : (children)));
72009
72020
  }
72010
72021
  var chevronIcon = type === "select"
72011
72022
  ? SvgChevronUpDown$1
@@ -72013,13 +72024,23 @@ DropdownMenu.Button = function (_a) {
72013
72024
  ? SvgChevronRight$1
72014
72025
  : SvgChevronDown$1;
72015
72026
  return (React.createElement(React.Fragment, null, tooltip ? (React.createElement(Tooltip, { label: tooltip, position: tooltipPosition },
72016
- React.createElement(qe$1.Button, { disabled: disabled, ref: buttonRef, className: classNames(disabled ? "s-cursor-default" : "s-cursor-pointer", className, "s-group/dm 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"), onClick: function (e) { return e.stopPropagation(); } },
72027
+ React.createElement(qe$1.Button, { disabled: disabled, ref: aggregatedRef, className: classNames(disabled ? "s-cursor-default" : "s-cursor-pointer", className, "s-group/dm 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"), onClick: function (e) {
72028
+ e.stopPropagation();
72029
+ if (onClick) {
72030
+ onClick();
72031
+ }
72032
+ } },
72017
72033
  React.createElement(Icon, { visual: icon, size: size, className: finalIconClasses }),
72018
- React.createElement(Icon, { visual: chevronIcon, size: size === "sm" ? "xs" : "sm", className: finalChevronClasses })))) : (React.createElement(qe$1.Button, { disabled: disabled, ref: buttonRef, className: classNames(disabled ? "s-cursor-default" : "s-cursor-pointer", className, "s-group/dm 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" : ""), onClick: function (e) { return e.stopPropagation(); } },
72034
+ React.createElement(Icon, { visual: chevronIcon, size: size === "sm" ? "xs" : "sm", className: finalChevronClasses })))) : (React.createElement(qe$1.Button, { disabled: disabled, ref: aggregatedRef, className: classNames(disabled ? "s-cursor-default" : "s-cursor-pointer", className, "s-group/dm 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" : ""), onClick: function (e) {
72035
+ e.stopPropagation();
72036
+ if (onClick) {
72037
+ onClick();
72038
+ }
72039
+ } },
72019
72040
  React.createElement(Icon, { visual: icon, size: size, className: finalIconClasses }),
72020
72041
  React.createElement("span", { className: classNames(finalLabelClasses, type === "submenu" ? "s-w-full" : "") }, label),
72021
72042
  React.createElement(Icon, { visual: chevronIcon, size: size === "sm" ? "xs" : "sm", className: finalChevronClasses })))));
72022
- };
72043
+ });
72023
72044
  DropdownMenu.Item = function (_a) {
72024
72045
  var _b = _a.variant, variant = _b === void 0 ? "default" : _b, label = _a.label, description = _a.description, link = _a.link, disabled = _a.disabled, visual = _a.visual, icon = _a.icon, onClick = _a.onClick, hasChildren = _a.hasChildren, children = _a.children, _c = _a.selected, selected = _c === void 0 ? false : _c;
72025
72046
  return (
@@ -103414,38 +103435,34 @@ function shouldRenderColumn(windowWidth, breakpoint) {
103414
103435
  return windowWidth >= breakpoints[breakpoint];
103415
103436
  }
103416
103437
  function DataTable(_a) {
103417
- var data = _a.data, totalRowCount = _a.totalRowCount, columns = _a.columns, className = _a.className, _b = _a.widthClassName, widthClassName = _b === void 0 ? "s-w-full s-max-w-4xl" : _b, filter = _a.filter, filterColumn = _a.filterColumn, initialColumnOrder = _a.initialColumnOrder, _c = _a.columnsBreakpoints, columnsBreakpoints = _c === void 0 ? {} : _c, pagination = _a.pagination, setPagination = _a.setPagination;
103438
+ var data = _a.data, totalRowCount = _a.totalRowCount, columns = _a.columns, className = _a.className, _b = _a.widthClassName, widthClassName = _b === void 0 ? "s-w-full s-max-w-4xl" : _b, filter = _a.filter, filterColumn = _a.filterColumn, _c = _a.columnsBreakpoints, columnsBreakpoints = _c === void 0 ? {} : _c, pagination = _a.pagination, setPagination = _a.setPagination, sorting = _a.sorting, setSorting = _a.setSorting, _d = _a.isServerSideSorting, isServerSideSorting = _d === void 0 ? false : _d;
103418
103439
  var windowSize = useWindowSize();
103419
- var _d = __read(React.useState(initialColumnOrder !== null && initialColumnOrder !== void 0 ? initialColumnOrder : []), 2), sorting = _d[0], setSorting = _d[1];
103420
103440
  var _e = __read(React.useState([]), 2), columnFilters = _e[0], setColumnFilters = _e[1];
103421
103441
  var isServerSidePagination = !!totalRowCount && totalRowCount > data.length;
103442
+ var isClientSideSortingEnabled = !isServerSideSorting && !isServerSidePagination;
103422
103443
  var onPaginationChange = pagination && setPagination
103423
103444
  ? function (updater) {
103424
103445
  var newValue = typeof updater === "function" ? updater(pagination) : updater;
103425
103446
  setPagination(newValue);
103426
103447
  }
103427
103448
  : undefined;
103428
- var table = useReactTable({
103429
- data: data,
103430
- columns: columns,
103431
- rowCount: totalRowCount,
103432
- manualPagination: isServerSidePagination,
103433
- onSortingChange: setSorting,
103434
- getCoreRowModel: getCoreRowModel(),
103449
+ var onSortingChange = sorting && setSorting
103450
+ ? function (updater) {
103451
+ var newValue = typeof updater === "function" ? updater(sorting) : updater;
103452
+ setSorting(newValue);
103453
+ }
103454
+ : undefined;
103455
+ var table = useReactTable(__assign(__assign(__assign(__assign({ data: data, columns: columns, rowCount: totalRowCount, manualPagination: isServerSidePagination, manualSorting: isServerSideSorting }, (isServerSideSorting && {
103456
+ onSortingChange: onSortingChange,
103457
+ })), { getCoreRowModel: getCoreRowModel() }), (!isServerSideSorting && {
103435
103458
  getSortedRowModel: getSortedRowModel(),
103436
- getFilteredRowModel: getFilteredRowModel(),
103437
- getPaginationRowModel: pagination ? getPaginationRowModel() : undefined,
103438
- onColumnFiltersChange: setColumnFilters,
103439
- state: {
103440
- columnFilters: columnFilters,
103441
- sorting: isServerSidePagination ? undefined : sorting,
103442
- pagination: pagination,
103443
- },
103444
- initialState: {
103459
+ enableSorting: isClientSideSortingEnabled,
103460
+ })), { getFilteredRowModel: getFilteredRowModel(), getPaginationRowModel: pagination ? getPaginationRowModel() : undefined, onColumnFiltersChange: setColumnFilters, state: __assign(__assign({ columnFilters: columnFilters }, (isServerSideSorting && {
103461
+ sorting: sorting,
103462
+ })), { pagination: pagination }), initialState: {
103445
103463
  pagination: pagination,
103446
- },
103447
- onPaginationChange: onPaginationChange,
103448
- });
103464
+ sorting: sorting,
103465
+ }, onPaginationChange: onPaginationChange }));
103449
103466
  React.useEffect(function () {
103450
103467
  var _a;
103451
103468
  if (filterColumn) {