@stackframe/stack-ui 2.7.13 → 2.7.14
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/CHANGELOG.md +8 -0
- package/dist/components/copy-button.d.ts +2 -2
- package/dist/components/data-table/cells.d.ts +1 -0
- package/dist/components/data-table/cells.js +2 -2
- package/dist/components/data-table/data-table.d.ts +3 -1
- package/dist/components/data-table/data-table.js +10 -5
- package/dist/components/simple-tooltip.d.ts +2 -0
- package/dist/components/simple-tooltip.js +7 -5
- package/dist/components/ui/button.d.ts +4 -4
- package/dist/components/ui/button.js +4 -2
- package/dist/components/ui/dropdown-menu.js +2 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,8 +5,8 @@ declare const CopyButton: React.FC<{
|
|
|
5
5
|
} & {
|
|
6
6
|
asChild?: boolean | undefined;
|
|
7
7
|
} & React.ButtonHTMLAttributes<HTMLButtonElement> & import("class-variance-authority").VariantProps<(props?: ({
|
|
8
|
-
variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | null | undefined;
|
|
9
|
-
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
8
|
+
variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | "plain" | null | undefined;
|
|
9
|
+
size?: "default" | "plain" | "sm" | "lg" | "icon" | null | undefined;
|
|
10
10
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string> & {
|
|
11
11
|
ref?: React.Ref<HTMLButtonElement> | undefined;
|
|
12
12
|
} & {
|
|
@@ -6,6 +6,7 @@ export declare function TextCell(props: {
|
|
|
6
6
|
}): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export declare function AvatarCell(props: {
|
|
8
8
|
src?: string;
|
|
9
|
+
fallback?: string;
|
|
9
10
|
}): import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export declare function DateCell(props: {
|
|
11
12
|
date: Date;
|
|
@@ -3,7 +3,7 @@ import { createElement as _createElement } from "react";
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { DotsHorizontalIcon } from "@radix-ui/react-icons";
|
|
5
5
|
import React, { useEffect, useRef, useState } from "react";
|
|
6
|
-
import {
|
|
6
|
+
import { Avatar, AvatarFallback, AvatarImage, Badge, Button, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, SimpleTooltip, cn } from "../..";
|
|
7
7
|
export function TextCell(props) {
|
|
8
8
|
const textRef = useRef(null);
|
|
9
9
|
const [isOverflowing, setIsOverflowing] = useState(false);
|
|
@@ -24,7 +24,7 @@ export function TextCell(props) {
|
|
|
24
24
|
return (_jsx("div", { className: "relative", style: { minWidth: props.size }, children: _jsxs("div", { className: "flex items-center gap-2 absolute inset-0", children: [_jsx("div", { className: overflowStyle, ref: textRef, children: isOverflowing ? (_jsx(SimpleTooltip, { tooltip: props.children, children: _jsx("div", { className: overflowStyle, children: props.children }) })) : props.children }), props.icon && _jsx("div", { children: props.icon })] }) }));
|
|
25
25
|
}
|
|
26
26
|
export function AvatarCell(props) {
|
|
27
|
-
return (
|
|
27
|
+
return (_jsxs(Avatar, { className: "h-6 w-6", children: [_jsx(AvatarImage, { src: props.src }), _jsx(AvatarFallback, { children: props.fallback })] }));
|
|
28
28
|
}
|
|
29
29
|
export function DateCell(props) {
|
|
30
30
|
const ignore = !!props.ignoreAfterYears && new Date(new Date().setFullYear(new Date().getFullYear() + props.ignoreAfterYears)) < props.date;
|
|
@@ -7,6 +7,7 @@ export declare function TableView<TData, TValue>(props: {
|
|
|
7
7
|
showDefaultToolbar?: boolean;
|
|
8
8
|
defaultColumnFilters: ColumnFiltersState;
|
|
9
9
|
defaultSorting: SortingState;
|
|
10
|
+
onRowClick?: (row: TData) => void;
|
|
10
11
|
}): import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
type DataTableProps<TData, TValue> = {
|
|
12
13
|
columns: ColumnDef<TData, TValue>[];
|
|
@@ -16,6 +17,7 @@ type DataTableProps<TData, TValue> = {
|
|
|
16
17
|
defaultColumnFilters: ColumnFiltersState;
|
|
17
18
|
defaultSorting: SortingState;
|
|
18
19
|
showDefaultToolbar?: boolean;
|
|
20
|
+
onRowClick?: (row: TData) => void;
|
|
19
21
|
};
|
|
20
22
|
export declare function DataTable<TData, TValue>({ columns, data, toolbarRender, defaultVisibility, defaultColumnFilters, defaultSorting, showDefaultToolbar, }: DataTableProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
|
|
21
23
|
type DataTableManualPaginationProps<TData, TValue> = DataTableProps<TData, TValue> & {
|
|
@@ -29,5 +31,5 @@ type DataTableManualPaginationProps<TData, TValue> = DataTableProps<TData, TValu
|
|
|
29
31
|
nextCursor: string | null;
|
|
30
32
|
}>;
|
|
31
33
|
};
|
|
32
|
-
export declare function DataTableManualPagination<TData, TValue>({ columns, data, toolbarRender, defaultVisibility, defaultColumnFilters, defaultSorting, onUpdate, showDefaultToolbar, }: DataTableManualPaginationProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
export declare function DataTableManualPagination<TData, TValue>({ columns, data, toolbarRender, defaultVisibility, defaultColumnFilters, defaultSorting, onRowClick, onUpdate, showDefaultToolbar, }: DataTableManualPaginationProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
|
|
33
35
|
export {};
|
|
@@ -10,7 +10,12 @@ export function TableView(props) {
|
|
|
10
10
|
return (_jsx(TableHead, { colSpan: header.colSpan, children: header.isPlaceholder
|
|
11
11
|
? null
|
|
12
12
|
: flexRender(header.column.columnDef.header, header.getContext()) }, header.id));
|
|
13
|
-
}) }, headerGroup.id))) }), _jsx(TableBody, { children: props.table.getRowModel().rows.length ? (props.table.getRowModel().rows.map((row) => (_jsx(TableRow, { "data-state": row.getIsSelected() && "selected",
|
|
13
|
+
}) }, headerGroup.id))) }), _jsx(TableBody, { children: props.table.getRowModel().rows.length ? (props.table.getRowModel().rows.map((row) => (_jsx(TableRow, { "data-state": row.getIsSelected() && "selected", onClick: (ev) => {
|
|
14
|
+
// only trigger onRowClick if the element is a direct descendant; don't trigger for portals
|
|
15
|
+
if (ev.target instanceof Node && ev.currentTarget.contains(ev.target)) {
|
|
16
|
+
props.onRowClick?.(row.original);
|
|
17
|
+
}
|
|
18
|
+
}, children: row.getVisibleCells().map((cell) => (_jsx(TableCell, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id)))) : (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: props.columns.length, className: "h-24 text-center", children: "No results." }) })) })] }) }), _jsx(DataTablePagination, { table: props.table })] }));
|
|
14
19
|
}
|
|
15
20
|
export function DataTable({ columns, data, toolbarRender, defaultVisibility, defaultColumnFilters, defaultSorting, showDefaultToolbar = true, }) {
|
|
16
21
|
const [sorting, setSorting] = React.useState(defaultSorting);
|
|
@@ -22,7 +27,7 @@ export function DataTable({ columns, data, toolbarRender, defaultVisibility, def
|
|
|
22
27
|
const [globalFilter, setGlobalFilter] = React.useState();
|
|
23
28
|
return _jsx(DataTableBase, { columns: columns, data: data, toolbarRender: toolbarRender, defaultVisibility: defaultVisibility, sorting: sorting, setSorting: setSorting, defaultSorting: defaultSorting, columnFilters: columnFilters, setColumnFilters: setColumnFilters, defaultColumnFilters: defaultColumnFilters, manualPagination: false, manualFiltering: false, pagination: pagination, setPagination: setPagination, globalFilter: globalFilter, setGlobalFilter: setGlobalFilter, showDefaultToolbar: showDefaultToolbar });
|
|
24
29
|
}
|
|
25
|
-
export function DataTableManualPagination({ columns, data, toolbarRender, defaultVisibility, defaultColumnFilters, defaultSorting, onUpdate, showDefaultToolbar = true, }) {
|
|
30
|
+
export function DataTableManualPagination({ columns, data, toolbarRender, defaultVisibility, defaultColumnFilters, defaultSorting, onRowClick, onUpdate, showDefaultToolbar = true, }) {
|
|
26
31
|
const [sorting, setSorting] = React.useState(defaultSorting);
|
|
27
32
|
const [pagination, setPagination] = React.useState({ pageIndex: 0, pageSize: 10 });
|
|
28
33
|
const [cursors, setCursors] = React.useState({});
|
|
@@ -52,9 +57,9 @@ export function DataTableManualPagination({ columns, data, toolbarRender, defaul
|
|
|
52
57
|
}, 500);
|
|
53
58
|
return () => clearTimeout(timer);
|
|
54
59
|
}, [globalFilter]);
|
|
55
|
-
return _jsx(DataTableBase, { columns: columns, data: data, toolbarRender: toolbarRender, sorting: sorting, setSorting: setSorting, pagination: pagination, setPagination: setPagination, columnFilters: columnFilters, setColumnFilters: setColumnFilters, rowCount: pagination.pageSize * Object.keys(cursors).length + (cursors[pagination.pageIndex + 1] ? 1 : 0), globalFilter: globalFilter, setGlobalFilter: setGlobalFilter, defaultColumnFilters: defaultColumnFilters, defaultSorting: defaultSorting, defaultVisibility: defaultVisibility, showDefaultToolbar: showDefaultToolbar });
|
|
60
|
+
return _jsx(DataTableBase, { columns: columns, data: data, toolbarRender: toolbarRender, sorting: sorting, setSorting: setSorting, pagination: pagination, setPagination: setPagination, columnFilters: columnFilters, setColumnFilters: setColumnFilters, rowCount: pagination.pageSize * Object.keys(cursors).length + (cursors[pagination.pageIndex + 1] ? 1 : 0), globalFilter: globalFilter, setGlobalFilter: setGlobalFilter, defaultColumnFilters: defaultColumnFilters, defaultSorting: defaultSorting, defaultVisibility: defaultVisibility, showDefaultToolbar: showDefaultToolbar, onRowClick: onRowClick });
|
|
56
61
|
}
|
|
57
|
-
function DataTableBase({ columns, data, toolbarRender, defaultVisibility, sorting, setSorting, defaultColumnFilters, defaultSorting, pagination, setPagination, rowCount, columnFilters, setColumnFilters, globalFilter, setGlobalFilter, manualPagination = true, manualFiltering = true, showDefaultToolbar = true, }) {
|
|
62
|
+
function DataTableBase({ columns, data, toolbarRender, defaultVisibility, sorting, setSorting, defaultColumnFilters, defaultSorting, pagination, setPagination, rowCount, columnFilters, setColumnFilters, globalFilter, setGlobalFilter, manualPagination = true, manualFiltering = true, showDefaultToolbar = true, onRowClick, }) {
|
|
58
63
|
const [rowSelection, setRowSelection] = React.useState({});
|
|
59
64
|
const [columnVisibility, setColumnVisibility] = React.useState(defaultVisibility || {});
|
|
60
65
|
const table = useReactTable({
|
|
@@ -87,5 +92,5 @@ function DataTableBase({ columns, data, toolbarRender, defaultVisibility, sortin
|
|
|
87
92
|
manualFiltering,
|
|
88
93
|
rowCount,
|
|
89
94
|
});
|
|
90
|
-
return _jsx(TableView, { table: table, columns: columns, toolbarRender: toolbarRender, showDefaultToolbar: showDefaultToolbar, defaultColumnFilters: defaultColumnFilters, defaultSorting: defaultSorting });
|
|
95
|
+
return _jsx(TableView, { table: table, columns: columns, toolbarRender: toolbarRender, showDefaultToolbar: showDefaultToolbar, defaultColumnFilters: defaultColumnFilters, defaultSorting: defaultSorting, onRowClick: onRowClick });
|
|
91
96
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "..";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { CircleAlert, Info } from "lucide-react";
|
|
3
|
+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, cn } from "..";
|
|
4
4
|
export function SimpleTooltip(props) {
|
|
5
|
+
const iconClassName = cn("w-4 h-4 text-zinc-500", props.inline && "inline");
|
|
5
6
|
const icon = props.type === 'warning' ?
|
|
6
|
-
_jsx(CircleAlert, { className:
|
|
7
|
+
_jsx(CircleAlert, { className: iconClassName }) :
|
|
7
8
|
props.type === 'info' ?
|
|
8
|
-
_jsx(Info, { className:
|
|
9
|
+
_jsx(Info, { className: iconClassName }) :
|
|
9
10
|
null;
|
|
10
|
-
|
|
11
|
+
const trigger = (_jsxs(_Fragment, { children: [icon, props.children] }));
|
|
12
|
+
return (_jsx(TooltipProvider, { children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: props.inline ? (_jsx("span", { className: cn(props.className), children: trigger })) : (_jsx("div", { className: cn("flex items-center gap-1", props.className), children: trigger })) }), _jsx(TooltipContent, { children: _jsx("div", { className: "max-w-60 text-center text-wrap whitespace-pre-wrap", children: props.tooltip }) })] }) }));
|
|
11
13
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type VariantProps } from "class-variance-authority";
|
|
2
2
|
import React from "react";
|
|
3
3
|
declare const buttonVariants: (props?: ({
|
|
4
|
-
variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | null | undefined;
|
|
5
|
-
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
4
|
+
variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | "plain" | null | undefined;
|
|
5
|
+
size?: "default" | "plain" | "sm" | "lg" | "icon" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
7
|
export type OriginalButtonProps = {
|
|
8
8
|
asChild?: boolean;
|
|
@@ -17,8 +17,8 @@ declare const Button: React.FC<{
|
|
|
17
17
|
} & {
|
|
18
18
|
asChild?: boolean | undefined;
|
|
19
19
|
} & React.ButtonHTMLAttributes<HTMLButtonElement> & VariantProps<(props?: ({
|
|
20
|
-
variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | null | undefined;
|
|
21
|
-
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
20
|
+
variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | "plain" | null | undefined;
|
|
21
|
+
size?: "default" | "plain" | "sm" | "lg" | "icon" | null | undefined;
|
|
22
22
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string> & {
|
|
23
23
|
ref?: React.Ref<HTMLButtonElement> | undefined;
|
|
24
24
|
}>;
|
|
@@ -15,12 +15,14 @@ const buttonVariants = cva("inline-flex items-center justify-center whitespace-n
|
|
|
15
15
|
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
16
16
|
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
17
17
|
link: "text-primary underline-offset-4 hover:underline",
|
|
18
|
+
plain: "",
|
|
18
19
|
},
|
|
19
20
|
size: {
|
|
20
21
|
default: "h-9 px-4 py-2",
|
|
21
22
|
sm: "h-8 rounded-md px-3 text-xs",
|
|
22
23
|
lg: "h-10 rounded-md px-8",
|
|
23
24
|
icon: "h-9 w-9",
|
|
25
|
+
plain: "",
|
|
24
26
|
},
|
|
25
27
|
},
|
|
26
28
|
defaultVariants: {
|
|
@@ -33,12 +35,12 @@ const OriginalButton = forwardRefIfNeeded(({ className, variant, size, asChild =
|
|
|
33
35
|
return (_jsx(Comp, { className: cn(buttonVariants({ variant, size, className })), ref: ref, ...props }));
|
|
34
36
|
});
|
|
35
37
|
OriginalButton.displayName = "Button";
|
|
36
|
-
const Button = forwardRefIfNeeded(({ onClick, loading: loadingProp, children, ...props }, ref) => {
|
|
38
|
+
const Button = forwardRefIfNeeded(({ onClick, loading: loadingProp, children, size, ...props }, ref) => {
|
|
37
39
|
const [handleClick, isLoading] = useAsyncCallback(async (e) => {
|
|
38
40
|
await onClick?.(e);
|
|
39
41
|
}, [onClick]);
|
|
40
42
|
const loading = loadingProp || isLoading;
|
|
41
|
-
return (_jsxs(OriginalButton, { ...props, ref: ref, disabled: props.disabled || loading, onClick: (e) => runAsynchronouslyWithAlert(handleClick(e)),
|
|
43
|
+
return (_jsxs(OriginalButton, { ...props, ref: ref, disabled: props.disabled || loading, onClick: (e) => runAsynchronouslyWithAlert(handleClick(e)), size: size, className: cn("relative", loading && "[&>:not(.stack-button-do-not-hide-when-siblings-are)]:invisible", props.className), children: [_jsx(Spinner, { className: cn("absolute inset-0 flex items-center justify-center stack-button-do-not-hide-when-siblings-are", !loading && "invisible") }), typeof children === "string" ? _jsx("span", { children: children }) : children] }));
|
|
42
44
|
});
|
|
43
45
|
Button.displayName = "Button";
|
|
44
46
|
export { Button, buttonVariants };
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
4
4
|
import { CheckIcon, ChevronRightIcon, DotFilledIcon } from "@radix-ui/react-icons";
|
|
5
|
-
import React from "react";
|
|
6
5
|
import { forwardRefIfNeeded } from "@stackframe/stack-shared/dist/utils/react";
|
|
6
|
+
import React from "react";
|
|
7
7
|
import { useAsyncCallback } from "@stackframe/stack-shared/dist/hooks/use-async-callback";
|
|
8
8
|
import { throwErr } from "@stackframe/stack-shared/dist/utils/errors";
|
|
9
9
|
import { runAsynchronouslyWithAlert } from "@stackframe/stack-shared/dist/utils/promises";
|
|
@@ -45,6 +45,7 @@ const DropdownMenuItem = forwardRefIfNeeded(({ className, inset, ...props }, ref
|
|
|
45
45
|
}, [props.onClick]);
|
|
46
46
|
return _jsxs(DropdownMenuPrimitive.Item, { ref: ref, className: cn("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", inset && "pl-8", className), ...props, disabled: isLoading || props.disabled, onClick: props.onClick ? (e) => {
|
|
47
47
|
e.preventDefault();
|
|
48
|
+
e.stopPropagation();
|
|
48
49
|
runAsynchronouslyWithAlert(handleClick(e));
|
|
49
50
|
} : undefined, children: [_jsx("div", { style: { visibility: isLoading ? "visible" : "hidden", position: "absolute", inset: 0, display: "flex", justifyContent: "center", alignItems: "center" }, children: _jsx(Spinner, {}) }), _jsx("div", { style: { visibility: isLoading ? "hidden" : "visible" }, children: props.children })] });
|
|
50
51
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackframe/stack-ui",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.14",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"react-hook-form": "^7.53.1",
|
|
78
78
|
"react-resizable-panels": "^2.1.6",
|
|
79
79
|
"tailwind-merge": "^2.5.4",
|
|
80
|
-
"@stackframe/stack-shared": "2.7.
|
|
80
|
+
"@stackframe/stack-shared": "2.7.14"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"@types/react": "^18.2.12",
|