beez-ui 0.10.0 → 2.0.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/CHANGELOG.md +40 -1
- package/README.md +63 -16
- package/THIRD_PARTY_NOTICES.md +31 -0
- package/assets/fonts/ibmplexmono-LICENSE.txt +93 -93
- package/assets/fonts/{poppins-LICENSE.txt → inter-LICENSE.txt} +2 -2
- package/assets/fonts/inter-latin-variable.woff2 +0 -0
- package/dist/components/account-menu.d.ts +5 -2
- package/dist/components/account-menu.js +150 -145
- package/dist/components/alert-dialog.d.ts +4 -2
- package/dist/components/alert-dialog.js +78 -66
- package/dist/components/animated-collapse.js +106 -36
- package/dist/components/button-interaction.d.ts +23 -0
- package/dist/components/button-interaction.js +22 -0
- package/dist/components/button-label.d.ts +8 -0
- package/dist/components/button-label.js +322 -0
- package/dist/components/button.d.ts +23 -10
- package/dist/components/button.js +111 -64
- package/dist/components/calendar.d.ts +2 -2
- package/dist/components/calendar.js +4 -4
- package/dist/components/carousel.d.ts +3 -3
- package/dist/components/carousel.js +3 -3
- package/dist/components/control-button.d.ts +16 -0
- package/dist/components/control-button.js +215 -0
- package/dist/components/data-table.js +7 -7
- package/dist/components/dialog.js +3 -2
- package/dist/components/dropdown-menu.js +1 -1
- package/dist/components/file-upload.js +5 -5
- package/dist/components/filter-presets-bar.js +6 -6
- package/dist/components/filter-query-bar.js +2 -2
- package/dist/components/input-group.d.ts +2 -2
- package/dist/components/input-group.js +2 -2
- package/dist/components/pagination.d.ts +2 -2
- package/dist/components/pagination.js +2 -2
- package/dist/components/reaction-button.js +2 -2
- package/dist/components/rich-link-editor.js +7 -7
- package/dist/components/rich-text-content.js +1 -1
- package/dist/components/sheet.js +2 -2
- package/dist/components/sidebar-panel-context.d.ts +17 -0
- package/dist/components/sidebar-panel-context.js +14 -0
- package/dist/components/sidebar.d.ts +40 -3
- package/dist/components/sidebar.js +259 -103
- package/dist/components/typing-animation.js +1 -1
- package/dist/constants/button.d.ts +16 -0
- package/dist/constants/button.js +16 -0
- package/dist/hooks/use-sidebar-persistence.d.ts +1 -1
- package/dist/hooks/use-sidebar-persistence.js +2 -2
- package/dist/motion/arc-press.d.ts +6 -0
- package/dist/motion/arc-press.js +59 -0
- package/dist/motion/arc-tokens.d.ts +32 -0
- package/dist/motion/arc-tokens.js +42 -0
- package/dist/providers/beez-ui-provider.d.ts +1 -1
- package/dist/providers/beez-ui-provider.js +6 -1
- package/dist/styles.css +1 -1
- package/fonts.css +5 -5
- package/package.json +3 -2
- package/styles.css +4 -4
- package/theme.css +248 -87
- package/assets/fonts/poppins-latin-600.woff2 +0 -0
|
@@ -1,98 +1,145 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { c as _c } from "react/compiler-runtime";
|
|
3
|
-
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
4
3
|
import { cva } from "class-variance-authority";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { useIsPresent } from "motion/react";
|
|
5
|
+
import { usePrefersReducedMotion } from "../hooks/use-prefers-reduced-motion.js";
|
|
7
6
|
import { cn } from "../lib/utils.js";
|
|
7
|
+
import { useArcPress } from "../motion/arc-press.js";
|
|
8
|
+
import { useAttachedElement } from "../motion/use-attached-element.js";
|
|
9
|
+
import { ButtonLabel } from "./button-label.js";
|
|
10
|
+
import { LEAVING_ATTRIBUTES, LOADING_INERT_HANDLERS } from "./button-interaction.js";
|
|
8
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Arc's button recipe on its tokens. Press scale is driven by Motion alone, so `transform` never gets a CSS
|
|
14
|
+
* transition, and anchors of floating layers never scale because Radix measures them on pointerdown. Keyboard focus
|
|
15
|
+
* uses the foundation's shared outline; pointer focus draws no ring.
|
|
16
|
+
*/
|
|
17
|
+
const buttonVariants = cva("relative inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 rounded-(--radius-control) border border-transparent px-4 font-sans text-sm leading-(--leading-body) font-medium whitespace-nowrap select-none [-webkit-tap-highlight-color:transparent] transition-[color,background-color,border-color,opacity,box-shadow] duration-(--duration-fast) ease-(--ease-standard) disabled:cursor-not-allowed disabled:opacity-[.52] aria-busy:cursor-progress motion-reduce:transition-none [&:is([aria-haspopup]:not([aria-haspopup=false]),[data-state],[role=combobox])]:transform-none! [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
|
|
10
18
|
variants: {
|
|
11
19
|
variant: {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
|
|
17
|
-
link: "text-primary underline-offset-4 hover:underline"
|
|
20
|
+
primary: "border-foreground bg-foreground text-background hover-fine:not-disabled:opacity-[.91] hover-fine:not-disabled:shadow-(--shadow-resting) active:not-disabled:opacity-[.84]",
|
|
21
|
+
secondary: "border-border bg-surface text-foreground hover-fine:not-disabled:bg-surface-muted hover-fine:not-disabled:shadow-(--shadow-resting) active:not-disabled:bg-surface-muted disabled:bg-surface-muted disabled:text-text-muted disabled:opacity-100",
|
|
22
|
+
ghost: "bg-transparent text-text-secondary hover-fine:not-disabled:bg-surface-muted hover-fine:not-disabled:text-foreground active:not-disabled:bg-surface-muted active:not-disabled:text-foreground disabled:text-text-muted disabled:opacity-100",
|
|
23
|
+
danger: "border-border bg-surface text-danger hover-fine:not-disabled:border-danger hover-fine:not-disabled:bg-surface-muted active:not-disabled:border-danger active:not-disabled:bg-surface-muted disabled:bg-surface-muted disabled:text-[color-mix(in_oklab,var(--danger)_55%,var(--surface-muted))] disabled:opacity-100"
|
|
18
24
|
},
|
|
19
25
|
size: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",
|
|
24
|
-
icon: "size-8",
|
|
25
|
-
"icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
|
26
|
-
"icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
|
|
27
|
-
"icon-lg": "size-9"
|
|
26
|
+
sm: "min-h-(--control-height-sm) px-3",
|
|
27
|
+
md: "min-h-(--control-height-md)",
|
|
28
|
+
lg: "min-h-(--control-height-lg) px-5"
|
|
28
29
|
}
|
|
29
30
|
},
|
|
30
31
|
defaultVariants: {
|
|
31
|
-
variant: "
|
|
32
|
-
size: "
|
|
32
|
+
variant: "primary",
|
|
33
|
+
size: "md"
|
|
33
34
|
}
|
|
34
35
|
});
|
|
36
|
+
/**
|
|
37
|
+
* A single action on a page, form or dialog. Defaults to `type="button"`, so it only submits a form when asked to.
|
|
38
|
+
* @param props - Variant, size, loading state and native button attributes, including `ref`.
|
|
39
|
+
* @returns The native button.
|
|
40
|
+
*/
|
|
35
41
|
function Button(t0) {
|
|
36
|
-
const $ = _c(
|
|
42
|
+
const $ = _c(29);
|
|
43
|
+
let children;
|
|
37
44
|
let className;
|
|
38
45
|
let props;
|
|
46
|
+
let ref;
|
|
39
47
|
let t1;
|
|
40
48
|
let t2;
|
|
41
49
|
let t3;
|
|
50
|
+
let t4;
|
|
42
51
|
if ($[0] !== t0) {
|
|
43
|
-
({className, variant: t1, size: t2,
|
|
52
|
+
({className, variant: t1, size: t2, loading: t3, type: t4, children, ref, ...props} = t0);
|
|
44
53
|
$[0] = t0;
|
|
45
|
-
$[1] =
|
|
46
|
-
$[2] =
|
|
47
|
-
$[3] =
|
|
48
|
-
$[4] =
|
|
49
|
-
$[5] =
|
|
54
|
+
$[1] = children;
|
|
55
|
+
$[2] = className;
|
|
56
|
+
$[3] = props;
|
|
57
|
+
$[4] = ref;
|
|
58
|
+
$[5] = t1;
|
|
59
|
+
$[6] = t2;
|
|
60
|
+
$[7] = t3;
|
|
61
|
+
$[8] = t4;
|
|
50
62
|
} else {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
63
|
+
children = $[1];
|
|
64
|
+
className = $[2];
|
|
65
|
+
props = $[3];
|
|
66
|
+
ref = $[4];
|
|
67
|
+
t1 = $[5];
|
|
68
|
+
t2 = $[6];
|
|
69
|
+
t3 = $[7];
|
|
70
|
+
t4 = $[8];
|
|
56
71
|
}
|
|
57
|
-
const variant = t1 === undefined ? "
|
|
58
|
-
const size = t2 === undefined ? "
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
72
|
+
const variant = t1 === undefined ? "primary" : t1;
|
|
73
|
+
const size = t2 === undefined ? "md" : t2;
|
|
74
|
+
const loading = t3 === undefined ? false : t3;
|
|
75
|
+
const type = t4 === undefined ? "button" : t4;
|
|
76
|
+
const reduceMotion = usePrefersReducedMotion();
|
|
77
|
+
const isPresent = useIsPresent();
|
|
78
|
+
const [element, attach] = useAttachedElement(ref);
|
|
79
|
+
useArcPress(element, !reduceMotion);
|
|
80
|
+
let t5;
|
|
81
|
+
if ($[9] !== className || $[10] !== size || $[11] !== variant) {
|
|
82
|
+
t5 = cn(buttonVariants({
|
|
64
83
|
variant,
|
|
65
84
|
size,
|
|
66
85
|
className
|
|
67
86
|
}));
|
|
68
|
-
$[
|
|
69
|
-
$[
|
|
70
|
-
$[
|
|
71
|
-
$[
|
|
87
|
+
$[9] = className;
|
|
88
|
+
$[10] = size;
|
|
89
|
+
$[11] = variant;
|
|
90
|
+
$[12] = t5;
|
|
72
91
|
} else {
|
|
73
|
-
|
|
92
|
+
t5 = $[12];
|
|
74
93
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
94
|
+
const t6 = loading || undefined;
|
|
95
|
+
const t7 = loading || props["aria-disabled"] || undefined;
|
|
96
|
+
const t8 = loading ? LOADING_INERT_HANDLERS : undefined;
|
|
97
|
+
const t9 = isPresent ? undefined : LEAVING_ATTRIBUTES;
|
|
98
|
+
let t10;
|
|
99
|
+
if ($[13] !== children || $[14] !== loading || $[15] !== reduceMotion) {
|
|
100
|
+
t10 = /* @__PURE__ */ _jsx(ButtonLabel, {
|
|
101
|
+
loading,
|
|
102
|
+
reduceMotion,
|
|
103
|
+
children
|
|
104
|
+
});
|
|
105
|
+
$[13] = children;
|
|
106
|
+
$[14] = loading;
|
|
107
|
+
$[15] = reduceMotion;
|
|
108
|
+
$[16] = t10;
|
|
109
|
+
} else {
|
|
110
|
+
t10 = $[16];
|
|
111
|
+
}
|
|
112
|
+
let t11;
|
|
113
|
+
if ($[17] !== attach || $[18] !== props || $[19] !== size || $[20] !== t10 || $[21] !== t5 || $[22] !== t6 || $[23] !== t7 || $[24] !== t8 || $[25] !== t9 || $[26] !== type || $[27] !== variant) {
|
|
114
|
+
t11 = /* @__PURE__ */ _jsx("button", {
|
|
115
|
+
ref: attach,
|
|
116
|
+
type,
|
|
117
|
+
"data-slot": "button",
|
|
118
|
+
"data-variant": variant,
|
|
119
|
+
"data-size": size,
|
|
120
|
+
className: t5,
|
|
121
|
+
"aria-busy": t6,
|
|
122
|
+
...props,
|
|
123
|
+
"aria-disabled": t7,
|
|
124
|
+
...t8,
|
|
125
|
+
...t9,
|
|
126
|
+
children: t10
|
|
86
127
|
});
|
|
87
|
-
$[
|
|
88
|
-
$[
|
|
89
|
-
$[
|
|
90
|
-
$[
|
|
91
|
-
$[
|
|
92
|
-
$[
|
|
128
|
+
$[17] = attach;
|
|
129
|
+
$[18] = props;
|
|
130
|
+
$[19] = size;
|
|
131
|
+
$[20] = t10;
|
|
132
|
+
$[21] = t5;
|
|
133
|
+
$[22] = t6;
|
|
134
|
+
$[23] = t7;
|
|
135
|
+
$[24] = t8;
|
|
136
|
+
$[25] = t9;
|
|
137
|
+
$[26] = type;
|
|
138
|
+
$[27] = variant;
|
|
139
|
+
$[28] = t11;
|
|
93
140
|
} else {
|
|
94
|
-
|
|
141
|
+
t11 = $[28];
|
|
95
142
|
}
|
|
96
|
-
return
|
|
143
|
+
return t11;
|
|
97
144
|
}
|
|
98
|
-
export { Button
|
|
145
|
+
export { Button };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { DayPicker, type DayButton, type Locale } from "react-day-picker";
|
|
3
|
-
import {
|
|
3
|
+
import { ControlButton } from "./control-button.js";
|
|
4
4
|
declare function Calendar({ className, classNames, showOutsideDays, captionLayout, buttonVariant, locale, formatters, components, ...props }: React.ComponentProps<typeof DayPicker> & {
|
|
5
|
-
buttonVariant?: React.ComponentProps<typeof
|
|
5
|
+
buttonVariant?: React.ComponentProps<typeof ControlButton>["variant"];
|
|
6
6
|
}): React.JSX.Element;
|
|
7
7
|
declare function CalendarDayButton({ className, day, modifiers, locale, ...props }: React.ComponentProps<typeof DayButton> & {
|
|
8
8
|
locale?: Partial<Locale>;
|
|
@@ -7,7 +7,7 @@ import { animate, frame } from "motion/react";
|
|
|
7
7
|
import { usePrefersReducedMotion } from "../hooks/use-prefers-reduced-motion.js";
|
|
8
8
|
import { MOTION_EASE, MOTION_MONTH_DISTANCE, MOTION_TIMING } from "../motion/tokens.js";
|
|
9
9
|
import { cn } from "../lib/utils.js";
|
|
10
|
-
import {
|
|
10
|
+
import { ControlButton, controlButtonVariants } from "./control-button.js";
|
|
11
11
|
import { ChevronLeft, ChevronRight, ChevronDown } from "lucide-react";
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
function Calendar(t0) {
|
|
@@ -75,8 +75,8 @@ function Calendar(t0) {
|
|
|
75
75
|
const t9 = cn("relative flex flex-col gap-4 md:flex-row", defaultClassNames.months);
|
|
76
76
|
const t10 = cn("flex w-full flex-col gap-4", defaultClassNames.month);
|
|
77
77
|
const t11 = cn("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1", defaultClassNames.nav);
|
|
78
|
-
const t12 = cn(
|
|
79
|
-
const t13 = cn(
|
|
78
|
+
const t12 = cn(controlButtonVariants({ variant: buttonVariant }), "size-(--cell-size) p-0 select-none aria-disabled:opacity-50", defaultClassNames.button_previous);
|
|
79
|
+
const t13 = cn(controlButtonVariants({ variant: buttonVariant }), "size-(--cell-size) p-0 select-none aria-disabled:opacity-50", defaultClassNames.button_next);
|
|
80
80
|
const t14 = cn("flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)", defaultClassNames.month_caption);
|
|
81
81
|
const t15 = cn("flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium", defaultClassNames.dropdowns);
|
|
82
82
|
const t16 = cn("relative rounded-(--cell-radius)", defaultClassNames.dropdown_root);
|
|
@@ -390,7 +390,7 @@ function CalendarDayButton(t0) {
|
|
|
390
390
|
t2 = $[8];
|
|
391
391
|
}
|
|
392
392
|
React.useEffect(t1, t2);
|
|
393
|
-
const T0 =
|
|
393
|
+
const T0 = ControlButton;
|
|
394
394
|
const t3 = "ghost";
|
|
395
395
|
const t4 = "icon";
|
|
396
396
|
let t5;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import useEmblaCarousel, { type UseEmblaCarouselType } from "embla-carousel-react";
|
|
3
|
-
import {
|
|
3
|
+
import { ControlButton } from "./control-button.js";
|
|
4
4
|
type CarouselApi = UseEmblaCarouselType[1];
|
|
5
5
|
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
|
|
6
6
|
type CarouselOptions = UseCarouselParameters[0];
|
|
@@ -23,6 +23,6 @@ declare function useCarousel(): CarouselContextProps;
|
|
|
23
23
|
declare function Carousel({ orientation, opts, setApi, plugins, className, children, ...props }: React.ComponentProps<"div"> & CarouselProps): React.JSX.Element;
|
|
24
24
|
declare function CarouselContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
25
25
|
declare function CarouselItem({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
26
|
-
declare function CarouselPrevious({ className, variant, size, ...props }: React.ComponentProps<typeof
|
|
27
|
-
declare function CarouselNext({ className, variant, size, ...props }: React.ComponentProps<typeof
|
|
26
|
+
declare function CarouselPrevious({ className, variant, size, ...props }: React.ComponentProps<typeof ControlButton>): React.JSX.Element;
|
|
27
|
+
declare function CarouselNext({ className, variant, size, ...props }: React.ComponentProps<typeof ControlButton>): React.JSX.Element;
|
|
28
28
|
export { type CarouselApi, Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext, useCarousel, };
|
|
@@ -4,7 +4,7 @@ import * as React from "react";
|
|
|
4
4
|
import useEmblaCarousel from "embla-carousel-react";
|
|
5
5
|
import { usePrefersReducedMotion } from "../hooks/use-prefers-reduced-motion.js";
|
|
6
6
|
import { cn } from "../lib/utils.js";
|
|
7
|
-
import {
|
|
7
|
+
import { ControlButton } from "./control-button.js";
|
|
8
8
|
import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
|
|
9
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
10
|
/** Arrow keys that move to the previous and next slide along each axis. */
|
|
@@ -389,7 +389,7 @@ function CarouselPrevious(t0) {
|
|
|
389
389
|
}
|
|
390
390
|
let t8;
|
|
391
391
|
if ($[10] !== props || $[11] !== scrollPrev || $[12] !== size || $[13] !== t4 || $[14] !== t5 || $[15] !== variant) {
|
|
392
|
-
t8 = /* @__PURE__ */ _jsxs(
|
|
392
|
+
t8 = /* @__PURE__ */ _jsxs(ControlButton, {
|
|
393
393
|
"data-slot": "carousel-previous",
|
|
394
394
|
variant,
|
|
395
395
|
size,
|
|
@@ -460,7 +460,7 @@ function CarouselNext(t0) {
|
|
|
460
460
|
}
|
|
461
461
|
let t8;
|
|
462
462
|
if ($[10] !== props || $[11] !== scrollNext || $[12] !== size || $[13] !== t4 || $[14] !== t5 || $[15] !== variant) {
|
|
463
|
-
t8 = /* @__PURE__ */ _jsxs(
|
|
463
|
+
t8 = /* @__PURE__ */ _jsxs(ControlButton, {
|
|
464
464
|
"data-slot": "carousel-next",
|
|
465
465
|
variant,
|
|
466
466
|
size,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
/**
|
|
4
|
+
* Class recipe. Press scale is driven by Motion alone, so `transform` never gets a CSS transition,
|
|
5
|
+
* and anchors of floating layers never scale because Radix measures them on pointerdown.
|
|
6
|
+
*/
|
|
7
|
+
declare const controlButtonVariants: (props?: ({
|
|
8
|
+
variant?: "default" | "destructive" | "ghost" | "link" | "outline" | "secondary" | null | undefined;
|
|
9
|
+
size?: "default" | "icon" | "icon-lg" | "icon-sm" | "icon-xs" | "lg" | "sm" | "xs" | null | undefined;
|
|
10
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
11
|
+
declare function ControlButton({ className, variant, size, asChild, loading, children, ref, ...props }: ButtonPrimitive.Props & VariantProps<typeof controlButtonVariants> & {
|
|
12
|
+
asChild?: boolean;
|
|
13
|
+
/** Shows a spinner, sets `aria-busy` and swallows clicks while keeping keyboard focus. */
|
|
14
|
+
loading?: boolean;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
16
|
+
export { ControlButton, controlButtonVariants };
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c as _c } from "react/compiler-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Internal compact control for composite components (dialog close buttons, carousel and pagination arrows, calendar
|
|
5
|
+
* cells, table and editor actions) that need icon sizes, a link variant or `asChild`, which the public Arc `Button`
|
|
6
|
+
* leaves out. Keeps Arc's press feedback and label motion (https://uiarc.dev, MIT License, see THIRD_PARTY_NOTICES.md).
|
|
7
|
+
* Not exported from the package: consumers use `Button`.
|
|
8
|
+
*/
|
|
9
|
+
import { Children, cloneElement, isValidElement } from "react";
|
|
10
|
+
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
11
|
+
import { cva } from "class-variance-authority";
|
|
12
|
+
import { Slot } from "radix-ui";
|
|
13
|
+
import { useIsPresent } from "motion/react";
|
|
14
|
+
import { usePrefersReducedMotion } from "../hooks/use-prefers-reduced-motion.js";
|
|
15
|
+
import { cn } from "../lib/utils.js";
|
|
16
|
+
import { useArcPress } from "../motion/arc-press.js";
|
|
17
|
+
import { useAttachedElement } from "../motion/use-attached-element.js";
|
|
18
|
+
import { ButtonLabel } from "./button-label.js";
|
|
19
|
+
import { LEAVING_ATTRIBUTES, LOADING_INERT_HANDLERS } from "./button-interaction.js";
|
|
20
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
|
+
/**
|
|
22
|
+
* Class recipe. Press scale is driven by Motion alone, so `transform` never gets a CSS transition,
|
|
23
|
+
* and anchors of floating layers never scale because Radix measures them on pointerdown.
|
|
24
|
+
*/
|
|
25
|
+
const controlButtonVariants = cva("group/button relative inline-flex shrink-0 cursor-pointer items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap outline-none select-none [-webkit-tap-highlight-color:transparent] transition-[color,background-color,border-color,opacity,box-shadow] duration-150 ease-out focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-busy:cursor-progress aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 motion-reduce:transition-none dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&:is([aria-haspopup]:not([aria-haspopup=false]),[data-state],[role=combobox])]:transform-none! [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
|
|
26
|
+
variants: {
|
|
27
|
+
variant: {
|
|
28
|
+
default: "border-foreground bg-foreground text-background hover:not-disabled:opacity-90 hover:not-disabled:shadow-xs active:not-disabled:opacity-85",
|
|
29
|
+
outline: "border-border bg-background text-foreground hover:not-disabled:bg-muted hover:not-disabled:shadow-xs active:not-disabled:bg-muted aria-expanded:bg-muted disabled:bg-muted disabled:text-muted-foreground disabled:opacity-100",
|
|
30
|
+
secondary: "bg-muted text-foreground hover:not-disabled:bg-muted/70 active:not-disabled:bg-muted/70 aria-expanded:bg-muted/70",
|
|
31
|
+
ghost: "text-muted-foreground hover:not-disabled:bg-muted hover:not-disabled:text-foreground active:not-disabled:bg-muted active:not-disabled:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground disabled:text-muted-foreground/60 disabled:opacity-100",
|
|
32
|
+
destructive: "border-border bg-background text-destructive hover:not-disabled:border-destructive hover:not-disabled:bg-muted active:not-disabled:border-destructive active:not-disabled:bg-muted focus-visible:border-destructive/40 focus-visible:ring-destructive/20 disabled:bg-muted disabled:text-destructive/55 disabled:opacity-100 dark:focus-visible:ring-destructive/40",
|
|
33
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
34
|
+
},
|
|
35
|
+
size: {
|
|
36
|
+
default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
37
|
+
xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
38
|
+
sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
|
39
|
+
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",
|
|
40
|
+
icon: "size-8",
|
|
41
|
+
"icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
|
42
|
+
"icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
|
|
43
|
+
"icon-lg": "size-9"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
defaultVariants: {
|
|
47
|
+
variant: "default",
|
|
48
|
+
size: "default"
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Wraps the content of an `asChild` element in the Arc label, so links morph and spin like buttons.
|
|
53
|
+
* While loading, the child's own activation handlers are dropped too, because Slot runs them before ours.
|
|
54
|
+
* Children given as render functions keep their content untouched.
|
|
55
|
+
*/
|
|
56
|
+
function withArcLabel(children, loading, renderLabel) {
|
|
57
|
+
const child = Children.only(children);
|
|
58
|
+
if (!isValidElement(child)) return child;
|
|
59
|
+
const content = child.props.children;
|
|
60
|
+
const overrides = loading ? LOADING_INERT_HANDLERS : undefined;
|
|
61
|
+
const label = typeof content === "function" ? content : renderLabel(content);
|
|
62
|
+
return cloneElement(child, overrides, label);
|
|
63
|
+
}
|
|
64
|
+
function ControlButton(t0) {
|
|
65
|
+
const $ = _c(40);
|
|
66
|
+
let children;
|
|
67
|
+
let className;
|
|
68
|
+
let props;
|
|
69
|
+
let ref;
|
|
70
|
+
let t1;
|
|
71
|
+
let t2;
|
|
72
|
+
let t3;
|
|
73
|
+
let t4;
|
|
74
|
+
if ($[0] !== t0) {
|
|
75
|
+
({className, variant: t1, size: t2, asChild: t3, loading: t4, children, ref, ...props} = t0);
|
|
76
|
+
$[0] = t0;
|
|
77
|
+
$[1] = children;
|
|
78
|
+
$[2] = className;
|
|
79
|
+
$[3] = props;
|
|
80
|
+
$[4] = ref;
|
|
81
|
+
$[5] = t1;
|
|
82
|
+
$[6] = t2;
|
|
83
|
+
$[7] = t3;
|
|
84
|
+
$[8] = t4;
|
|
85
|
+
} else {
|
|
86
|
+
children = $[1];
|
|
87
|
+
className = $[2];
|
|
88
|
+
props = $[3];
|
|
89
|
+
ref = $[4];
|
|
90
|
+
t1 = $[5];
|
|
91
|
+
t2 = $[6];
|
|
92
|
+
t3 = $[7];
|
|
93
|
+
t4 = $[8];
|
|
94
|
+
}
|
|
95
|
+
const variant = t1 === undefined ? "default" : t1;
|
|
96
|
+
const size = t2 === undefined ? "default" : t2;
|
|
97
|
+
const asChild = t3 === undefined ? false : t3;
|
|
98
|
+
const loading = t4 === undefined ? false : t4;
|
|
99
|
+
const reduceMotion = usePrefersReducedMotion();
|
|
100
|
+
const isPresent = useIsPresent();
|
|
101
|
+
const [element, attach] = useAttachedElement(ref);
|
|
102
|
+
useArcPress(element, !reduceMotion && variant !== "link");
|
|
103
|
+
let t5;
|
|
104
|
+
if ($[9] !== loading || $[10] !== reduceMotion) {
|
|
105
|
+
t5 = (content) => /* @__PURE__ */ _jsx(ButtonLabel, {
|
|
106
|
+
loading,
|
|
107
|
+
reduceMotion,
|
|
108
|
+
children: content
|
|
109
|
+
});
|
|
110
|
+
$[9] = loading;
|
|
111
|
+
$[10] = reduceMotion;
|
|
112
|
+
$[11] = t5;
|
|
113
|
+
} else {
|
|
114
|
+
t5 = $[11];
|
|
115
|
+
}
|
|
116
|
+
const renderLabel = t5;
|
|
117
|
+
let t6;
|
|
118
|
+
if ($[12] !== className || $[13] !== size || $[14] !== variant) {
|
|
119
|
+
t6 = cn(controlButtonVariants({
|
|
120
|
+
variant,
|
|
121
|
+
size,
|
|
122
|
+
className
|
|
123
|
+
}));
|
|
124
|
+
$[12] = className;
|
|
125
|
+
$[13] = size;
|
|
126
|
+
$[14] = variant;
|
|
127
|
+
$[15] = t6;
|
|
128
|
+
} else {
|
|
129
|
+
t6 = $[15];
|
|
130
|
+
}
|
|
131
|
+
const t7 = loading || undefined;
|
|
132
|
+
const t8 = loading || props["aria-disabled"] || undefined;
|
|
133
|
+
const t9 = loading ? LOADING_INERT_HANDLERS : undefined;
|
|
134
|
+
const t10 = isPresent ? undefined : LEAVING_ATTRIBUTES;
|
|
135
|
+
let t11;
|
|
136
|
+
if ($[16] !== props || $[17] !== size || $[18] !== t10 || $[19] !== t6 || $[20] !== t7 || $[21] !== t8 || $[22] !== t9 || $[23] !== variant) {
|
|
137
|
+
t11 = {
|
|
138
|
+
"data-slot": "button",
|
|
139
|
+
"data-variant": variant,
|
|
140
|
+
"data-size": size,
|
|
141
|
+
className: t6,
|
|
142
|
+
"aria-busy": t7,
|
|
143
|
+
...props,
|
|
144
|
+
"aria-disabled": t8,
|
|
145
|
+
...t9,
|
|
146
|
+
...t10
|
|
147
|
+
};
|
|
148
|
+
$[16] = props;
|
|
149
|
+
$[17] = size;
|
|
150
|
+
$[18] = t10;
|
|
151
|
+
$[19] = t6;
|
|
152
|
+
$[20] = t7;
|
|
153
|
+
$[21] = t8;
|
|
154
|
+
$[22] = t9;
|
|
155
|
+
$[23] = variant;
|
|
156
|
+
$[24] = t11;
|
|
157
|
+
} else {
|
|
158
|
+
t11 = $[24];
|
|
159
|
+
}
|
|
160
|
+
const sharedProps = t11;
|
|
161
|
+
if (asChild) {
|
|
162
|
+
const t12 = sharedProps;
|
|
163
|
+
let t13;
|
|
164
|
+
if ($[25] !== children || $[26] !== loading || $[27] !== renderLabel) {
|
|
165
|
+
t13 = withArcLabel(children, loading, renderLabel);
|
|
166
|
+
$[25] = children;
|
|
167
|
+
$[26] = loading;
|
|
168
|
+
$[27] = renderLabel;
|
|
169
|
+
$[28] = t13;
|
|
170
|
+
} else {
|
|
171
|
+
t13 = $[28];
|
|
172
|
+
}
|
|
173
|
+
let t14;
|
|
174
|
+
if ($[29] !== attach || $[30] !== t12 || $[31] !== t13) {
|
|
175
|
+
t14 = /* @__PURE__ */ _jsx(Slot.Root, {
|
|
176
|
+
ref: attach,
|
|
177
|
+
...t12,
|
|
178
|
+
children: t13
|
|
179
|
+
});
|
|
180
|
+
$[29] = attach;
|
|
181
|
+
$[30] = t12;
|
|
182
|
+
$[31] = t13;
|
|
183
|
+
$[32] = t14;
|
|
184
|
+
} else {
|
|
185
|
+
t14 = $[32];
|
|
186
|
+
}
|
|
187
|
+
return t14;
|
|
188
|
+
}
|
|
189
|
+
const t12 = sharedProps;
|
|
190
|
+
let t13;
|
|
191
|
+
if ($[33] !== children || $[34] !== renderLabel) {
|
|
192
|
+
t13 = renderLabel(children);
|
|
193
|
+
$[33] = children;
|
|
194
|
+
$[34] = renderLabel;
|
|
195
|
+
$[35] = t13;
|
|
196
|
+
} else {
|
|
197
|
+
t13 = $[35];
|
|
198
|
+
}
|
|
199
|
+
let t14;
|
|
200
|
+
if ($[36] !== attach || $[37] !== t12 || $[38] !== t13) {
|
|
201
|
+
t14 = /* @__PURE__ */ _jsx(ButtonPrimitive, {
|
|
202
|
+
ref: attach,
|
|
203
|
+
...t12,
|
|
204
|
+
children: t13
|
|
205
|
+
});
|
|
206
|
+
$[36] = attach;
|
|
207
|
+
$[37] = t12;
|
|
208
|
+
$[38] = t13;
|
|
209
|
+
$[39] = t14;
|
|
210
|
+
} else {
|
|
211
|
+
t14 = $[39];
|
|
212
|
+
}
|
|
213
|
+
return t14;
|
|
214
|
+
}
|
|
215
|
+
export { ControlButton, controlButtonVariants };
|
|
@@ -5,7 +5,7 @@ import { CircleAlert, ChevronDown, ChevronRight, Ellipsis, Eraser, X } from "luc
|
|
|
5
5
|
import { cn } from "../lib/utils.js";
|
|
6
6
|
import { matchesColumnFilterValue, normalizeFilterToken } from "../lib/column-filter-value.js";
|
|
7
7
|
import { MotionSlot } from "../motion/motion-slot.js";
|
|
8
|
-
import {
|
|
8
|
+
import { ControlButton } from "./control-button.js";
|
|
9
9
|
import { Badge } from "./badge.js";
|
|
10
10
|
import { FilterQueryBar } from "./filter-query-bar.js";
|
|
11
11
|
import { parseFilterQuery, serializeFilterQuery } from "./filter-query-grammar.js";
|
|
@@ -649,7 +649,7 @@ export function DataTable({ columns, data, emptyMessage, toolbarActions, onVisib
|
|
|
649
649
|
value: resolvedFilterValue
|
|
650
650
|
}), /* @__PURE__ */ _jsxs("div", {
|
|
651
651
|
className: "absolute right-1 top-1/2 flex -translate-y-1/2 items-center gap-0.5",
|
|
652
|
-
children: [resolvedFilterValue ? /* @__PURE__ */ _jsx(
|
|
652
|
+
children: [resolvedFilterValue ? /* @__PURE__ */ _jsx(ControlButton, {
|
|
653
653
|
"aria-label": CLEAR_FILTER_ARIA_LABEL,
|
|
654
654
|
className: "active:-translate-y-0",
|
|
655
655
|
onClick: handleClearMainFilter,
|
|
@@ -657,7 +657,7 @@ export function DataTable({ columns, data, emptyMessage, toolbarActions, onVisib
|
|
|
657
657
|
type: "button",
|
|
658
658
|
variant: "ghost",
|
|
659
659
|
children: /* @__PURE__ */ _jsx(X, { "aria-hidden": "true" })
|
|
660
|
-
}) : null, showExcludeFilterToggle ? /* @__PURE__ */ _jsxs(
|
|
660
|
+
}) : null, showExcludeFilterToggle ? /* @__PURE__ */ _jsxs(ControlButton, {
|
|
661
661
|
"aria-expanded": isExcludeFilterInputVisible,
|
|
662
662
|
"aria-label": isExcludeFilterInputVisible ? HIDE_EXCLUDE_FILTERS_ARIA_LABEL : excludeFilterToggleLabel,
|
|
663
663
|
className: "relative",
|
|
@@ -707,7 +707,7 @@ export function DataTable({ columns, data, emptyMessage, toolbarActions, onVisib
|
|
|
707
707
|
placeholder: excludeFilterPlaceholder,
|
|
708
708
|
type: "text",
|
|
709
709
|
value: excludeFilterInputValue
|
|
710
|
-
}), /* @__PURE__ */ _jsx(
|
|
710
|
+
}), /* @__PURE__ */ _jsx(ControlButton, {
|
|
711
711
|
"aria-label": CLEAR_ALL_EXCLUSIONS_FROM_INPUT_ARIA_LABEL,
|
|
712
712
|
className: "shrink-0",
|
|
713
713
|
disabled: !hasActiveExcludeFilterValues,
|
|
@@ -748,7 +748,7 @@ export function DataTable({ columns, data, emptyMessage, toolbarActions, onVisib
|
|
|
748
748
|
children: [
|
|
749
749
|
/* @__PURE__ */ _jsx("span", { children: `${EXCLUDED_ROWS_SUMMARY_LABEL}:` }),
|
|
750
750
|
/* @__PURE__ */ _jsx("span", {
|
|
751
|
-
className: "inline-flex min-w-5 items-center justify-center rounded-full bg-destructive/20 px-1.5 text-[10px] leading-4 font-
|
|
751
|
+
className: "inline-flex min-w-5 items-center justify-center rounded-full bg-destructive/20 px-1.5 text-[10px] leading-4 font-medium",
|
|
752
752
|
children: excludeFilterUniqueRowsCount
|
|
753
753
|
}),
|
|
754
754
|
/* @__PURE__ */ _jsx("button", {
|
|
@@ -771,7 +771,7 @@ export function DataTable({ columns, data, emptyMessage, toolbarActions, onVisib
|
|
|
771
771
|
/* @__PURE__ */ _jsx("span", { children: `− ${excludeFilterValue}` }),
|
|
772
772
|
excludedRowsCount != null ? /* @__PURE__ */ _jsx("span", {
|
|
773
773
|
"aria-label": `Filas excluidas por ${excludeFilterValue}: ${excludedRowsCount}`,
|
|
774
|
-
className: "inline-flex min-w-5 items-center justify-center rounded-full bg-destructive/20 px-1.5 text-[10px] leading-4 font-
|
|
774
|
+
className: "inline-flex min-w-5 items-center justify-center rounded-full bg-destructive/20 px-1.5 text-[10px] leading-4 font-medium",
|
|
775
775
|
children: excludedRowsCount
|
|
776
776
|
}) : null,
|
|
777
777
|
/* @__PURE__ */ _jsx("button", {
|
|
@@ -795,7 +795,7 @@ export function DataTable({ columns, data, emptyMessage, toolbarActions, onVisib
|
|
|
795
795
|
className: "ml-auto flex flex-wrap items-center gap-2",
|
|
796
796
|
children: [toolbarActions, shouldShowColumnVisibilityToggle ? /* @__PURE__ */ _jsxs(DropdownMenu, { children: [/* @__PURE__ */ _jsx(DropdownMenuTrigger, {
|
|
797
797
|
asChild: true,
|
|
798
|
-
children: /* @__PURE__ */ _jsxs(
|
|
798
|
+
children: /* @__PURE__ */ _jsxs(ControlButton, {
|
|
799
799
|
"aria-label": columnVisibilityButtonLabel,
|
|
800
800
|
className: "relative aria-expanded:*:data-[slot=data-table-columns-chevron]:rotate-180",
|
|
801
801
|
type: "button",
|
|
@@ -6,6 +6,7 @@ import { MotionSlot } from "../motion/motion-slot.js";
|
|
|
6
6
|
import { MotionPresence, MotionOpenProvider, useMotionOpenState } from "../motion/presence.js";
|
|
7
7
|
import { cn } from "../lib/utils.js";
|
|
8
8
|
import { Button } from "./button.js";
|
|
9
|
+
import { ControlButton } from "./control-button.js";
|
|
9
10
|
import { XIcon } from "lucide-react";
|
|
10
11
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
12
|
function Dialog(t0) {
|
|
@@ -205,7 +206,7 @@ function DialogContent(t0) {
|
|
|
205
206
|
asChild: true,
|
|
206
207
|
children: /* @__PURE__ */ _jsx(MotionSlot, {
|
|
207
208
|
kind: "delayed-pop",
|
|
208
|
-
children: /* @__PURE__ */ _jsxs(
|
|
209
|
+
children: /* @__PURE__ */ _jsxs(ControlButton, {
|
|
209
210
|
variant: "ghost",
|
|
210
211
|
className: "absolute top-2 right-2",
|
|
211
212
|
size: "icon-sm",
|
|
@@ -333,7 +334,7 @@ function DialogFooter(t0) {
|
|
|
333
334
|
t3 = showCloseButton && /* @__PURE__ */ _jsx(DialogPrimitive.Close, {
|
|
334
335
|
asChild: true,
|
|
335
336
|
children: /* @__PURE__ */ _jsx(Button, {
|
|
336
|
-
variant: "
|
|
337
|
+
variant: "secondary",
|
|
337
338
|
children: "Cerrar"
|
|
338
339
|
})
|
|
339
340
|
});
|
|
@@ -498,7 +498,7 @@ function DropdownMenuShortcut(t0) {
|
|
|
498
498
|
}
|
|
499
499
|
let t1;
|
|
500
500
|
if ($[3] !== className) {
|
|
501
|
-
t1 = cn("ml-auto text-xs
|
|
501
|
+
t1 = cn("ml-auto text-xs text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground", className);
|
|
502
502
|
$[3] = className;
|
|
503
503
|
$[4] = t1;
|
|
504
504
|
} else {
|