@bison-lab/ui 3.36.0 → 3.37.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/index.d.mts +70 -11
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +64 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { AnimatePresence, motion } from "motion/react";
|
|
|
8
8
|
import { Accordion as Accordion$1, AlertDialog as AlertDialog$1, AspectRatio as AspectRatio$1, Avatar as Avatar$1, Checkbox as Checkbox$1, Collapsible as Collapsible$1, ContextMenu as ContextMenu$1, Dialog as Dialog$1, DropdownMenu as DropdownMenu$1, Label as Label$1, NavigationMenu as NavigationMenu$1, Popover as Popover$1, Progress as Progress$1, RadioGroup as RadioGroup$1, ScrollArea as ScrollArea$1, Select as Select$1, Separator as Separator$1, Slider as Slider$1, Slot, Switch as Switch$1, Tabs as Tabs$1, Tooltip as Tooltip$1, unstable_PasswordToggleField } from "radix-ui";
|
|
9
9
|
import { cva } from "class-variance-authority";
|
|
10
10
|
import { AlignCenter, AlignLeft, AlignRight, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ArrowUpDown, Bold, Calendar as Calendar$1, Camera, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, ChevronsLeft, ChevronsRight, ChevronsUpDown, Circle, CircleAlert, CircleCheck, CircleHelp, CircleX, Code, Eye, EyeOff, Facebook, FastForward, FileQuestion, Heading1, Heading2, Heading3, Image, Inbox, Info, Instagram, Italic, Link, Linkedin, List, ListOrdered, LoaderCircle, LogOut, Mail, MapPin, Menu, Minus, MoreHorizontal, MoveUpRight, PanelLeft, Pause, Pencil, Phone, Play, Plus, Quote, Redo, Search, Server, Settings2, ShieldAlert, Star, Strikethrough, TriangleAlert, Twitter, Underline, Undo, Unlink, Wrench, X, Youtube } from "lucide-react";
|
|
11
|
-
import { DayPicker } from "react-day-picker";
|
|
11
|
+
import { DayPicker, getDefaultClassNames } from "react-day-picker";
|
|
12
12
|
import useEmblaCarousel from "embla-carousel-react";
|
|
13
13
|
import { endOfMonth, endOfWeek, format, startOfMonth, startOfWeek, startOfYear, subDays, subMonths, subYears } from "date-fns";
|
|
14
14
|
import { EditorContent, useEditor } from "@tiptap/react";
|
|
@@ -1043,16 +1043,38 @@ const inputFocusClasses = "focus-visible:outline-none focus-visible:border-prima
|
|
|
1043
1043
|
* `'md'` (the default) is byte-identical to the original fixed sizing this
|
|
1044
1044
|
* function replaced — every existing caller passes `'md'` explicitly and
|
|
1045
1045
|
* renders unchanged.
|
|
1046
|
+
*
|
|
1047
|
+
* `lg` restates its type size in the `sm:` variant because
|
|
1048
|
+
* {@link inputSurfaceClasses} sets `text-base sm:text-sm`: an unprefixed
|
|
1049
|
+
* `text-base` loses to that variant at every width from 640px up, which left
|
|
1050
|
+
* `lg` the right height at the wrong type size. tailwind-merge drops the
|
|
1051
|
+
* surface's `sm:text-sm` once the same variant is restated.
|
|
1046
1052
|
*/
|
|
1047
1053
|
const inputSizingClassesBySize = {
|
|
1048
1054
|
sm: "h-[var(--density-height-sm)] px-3 py-1 text-sm pointer-coarse:min-h-11",
|
|
1049
1055
|
md: "h-[var(--density-height-md)] px-3 py-2 pointer-coarse:min-h-11",
|
|
1050
|
-
lg: "h-[var(--density-height-lg)] px-3 py-2.5 text-base pointer-coarse:min-h-11"
|
|
1056
|
+
lg: "h-[var(--density-height-lg)] px-3 py-2.5 text-base sm:text-base pointer-coarse:min-h-11"
|
|
1051
1057
|
};
|
|
1052
1058
|
function inputSizingClasses(size = "md") {
|
|
1053
1059
|
return inputSizingClassesBySize[size];
|
|
1054
1060
|
}
|
|
1055
1061
|
/**
|
|
1062
|
+
* Multi-line sizing. A textarea cannot take a density height — locking one to
|
|
1063
|
+
* `--density-height-sm` would leave a single cramped row — so it scales its
|
|
1064
|
+
* type and padding on the same steps as {@link inputSizingClasses} and keeps a
|
|
1065
|
+
* `min-h` the author can grow with `rows` or a className.
|
|
1066
|
+
*
|
|
1067
|
+
* `'md'` is byte-identical to the fixed sizing this replaced.
|
|
1068
|
+
*/
|
|
1069
|
+
const textareaSizingClassesBySize = {
|
|
1070
|
+
sm: "min-h-[64px] px-3 py-1 text-sm",
|
|
1071
|
+
md: "min-h-[80px] px-3 py-2",
|
|
1072
|
+
lg: "min-h-[96px] px-3 py-2.5 text-base sm:text-base"
|
|
1073
|
+
};
|
|
1074
|
+
function textareaSizingClasses(size = "md") {
|
|
1075
|
+
return textareaSizingClassesBySize[size];
|
|
1076
|
+
}
|
|
1077
|
+
/**
|
|
1056
1078
|
* Minimum 44px tap target on touch (coarse) pointers, applied to the element
|
|
1057
1079
|
* itself. For standalone icon buttons that can safely grow their box on touch
|
|
1058
1080
|
* without crowding neighbors (e.g. Dialog / Sheet close). Pair with
|
|
@@ -1122,11 +1144,11 @@ const overlayScrimClasses = "fixed inset-0 z-[var(--z-modal-backdrop)] bg-black/
|
|
|
1122
1144
|
const centeredModalContentClasses = "fixed left-[50%] top-[50%] z-[var(--z-modal)] grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg rounded-lg data-[state=open]:bison-modal-in data-[state=closed]:bison-modal-out";
|
|
1123
1145
|
//#endregion
|
|
1124
1146
|
//#region src/components/input.tsx
|
|
1125
|
-
const Input = React.forwardRef(({ className, type, ...props }, ref) => {
|
|
1147
|
+
const Input = React.forwardRef(({ className, type, size = "md", ...props }, ref) => {
|
|
1126
1148
|
const fieldProps = useFieldControl(props);
|
|
1127
1149
|
return /* @__PURE__ */ jsx("input", {
|
|
1128
1150
|
type,
|
|
1129
|
-
className: cn(inputSurfaceClasses, inputSizingClasses(
|
|
1151
|
+
className: cn(inputSurfaceClasses, inputSizingClasses(size), inputFocusClasses, "file:border-0 file:bg-transparent file:text-base file:font-medium sm:file:text-sm", className),
|
|
1130
1152
|
ref,
|
|
1131
1153
|
...fieldProps
|
|
1132
1154
|
});
|
|
@@ -1134,12 +1156,12 @@ const Input = React.forwardRef(({ className, type, ...props }, ref) => {
|
|
|
1134
1156
|
Input.displayName = "Input";
|
|
1135
1157
|
//#endregion
|
|
1136
1158
|
//#region src/components/password-input.tsx
|
|
1137
|
-
const PasswordInput = React.forwardRef(({ className, toggleLabel = "Show or hide password", ...props }, ref) => {
|
|
1159
|
+
const PasswordInput = React.forwardRef(({ className, toggleLabel = "Show or hide password", size = "md", ...props }, ref) => {
|
|
1138
1160
|
const fieldProps = useFieldControl(props);
|
|
1139
1161
|
return /* @__PURE__ */ jsx(unstable_PasswordToggleField.Root, { children: /* @__PURE__ */ jsxs("div", {
|
|
1140
1162
|
className: "relative",
|
|
1141
1163
|
children: [/* @__PURE__ */ jsx(unstable_PasswordToggleField.Input, {
|
|
1142
|
-
className: cn(inputSurfaceClasses, inputSizingClasses(
|
|
1164
|
+
className: cn(inputSurfaceClasses, inputSizingClasses(size), inputFocusClasses, "pr-10 file:border-0 file:bg-transparent file:text-base file:font-medium sm:file:text-sm", className),
|
|
1143
1165
|
ref,
|
|
1144
1166
|
...fieldProps
|
|
1145
1167
|
}), /* @__PURE__ */ jsx(unstable_PasswordToggleField.Toggle, {
|
|
@@ -1237,7 +1259,7 @@ function fromCents(cents) {
|
|
|
1237
1259
|
if (cents <= 0) return "";
|
|
1238
1260
|
return (cents / 100).toFixed(2);
|
|
1239
1261
|
}
|
|
1240
|
-
const CurrencyInput = React.forwardRef(({ className, value, onChange, symbol = "$", ...props }, ref) => {
|
|
1262
|
+
const CurrencyInput = React.forwardRef(({ className, value, onChange, symbol = "$", size = "md", ...props }, ref) => {
|
|
1241
1263
|
const fieldProps = useFieldControl(props);
|
|
1242
1264
|
const [display, setDisplay] = React.useState(() => fromCents(value));
|
|
1243
1265
|
const prevValue = React.useRef(value);
|
|
@@ -1268,7 +1290,7 @@ const CurrencyInput = React.forwardRef(({ className, value, onChange, symbol = "
|
|
|
1268
1290
|
value: display,
|
|
1269
1291
|
onChange: handleChange,
|
|
1270
1292
|
onBlur: handleBlur,
|
|
1271
|
-
className: cn(inputSurfaceClasses, inputSizingClasses(
|
|
1293
|
+
className: cn(inputSurfaceClasses, inputSizingClasses(size), inputFocusClasses, "pl-7 pr-3", className),
|
|
1272
1294
|
...fieldProps
|
|
1273
1295
|
})]
|
|
1274
1296
|
});
|
|
@@ -1415,10 +1437,10 @@ const InputGroup = React.forwardRef(({ label, htmlFor, error, hint, required, la
|
|
|
1415
1437
|
InputGroup.displayName = "InputGroup";
|
|
1416
1438
|
//#endregion
|
|
1417
1439
|
//#region src/components/textarea.tsx
|
|
1418
|
-
const Textarea = React.forwardRef(({ className, ...props }, ref) => {
|
|
1440
|
+
const Textarea = React.forwardRef(({ className, size = "md", ...props }, ref) => {
|
|
1419
1441
|
const fieldProps = useFieldControl(props);
|
|
1420
1442
|
return /* @__PURE__ */ jsx("textarea", {
|
|
1421
|
-
className: cn(inputSurfaceClasses,
|
|
1443
|
+
className: cn(inputSurfaceClasses, textareaSizingClasses(size), inputFocusClasses, className),
|
|
1422
1444
|
ref,
|
|
1423
1445
|
...fieldProps
|
|
1424
1446
|
});
|
|
@@ -1429,11 +1451,11 @@ Textarea.displayName = "Textarea";
|
|
|
1429
1451
|
const Select = Select$1.Root;
|
|
1430
1452
|
const SelectGroup = Select$1.Group;
|
|
1431
1453
|
const SelectValue = Select$1.Value;
|
|
1432
|
-
const SelectTrigger = React.forwardRef(({ className, children, ...props }, ref) => {
|
|
1454
|
+
const SelectTrigger = React.forwardRef(({ className, children, size = "md", ...props }, ref) => {
|
|
1433
1455
|
const fieldProps = useFieldControl(props);
|
|
1434
1456
|
return /* @__PURE__ */ jsxs(Select$1.Trigger, {
|
|
1435
1457
|
ref,
|
|
1436
|
-
className: cn(inputSurfaceClasses, inputSizingClasses(
|
|
1458
|
+
className: cn(inputSurfaceClasses, inputSizingClasses(size), inputFocusClasses, "items-center justify-between [&>span]:line-clamp-1", className),
|
|
1437
1459
|
...fieldProps,
|
|
1438
1460
|
children: [children, /* @__PURE__ */ jsx(Select$1.Icon, {
|
|
1439
1461
|
asChild: true,
|
|
@@ -1496,31 +1518,33 @@ SelectSeparator.displayName = Select$1.Separator.displayName;
|
|
|
1496
1518
|
//#endregion
|
|
1497
1519
|
//#region src/components/calendar.tsx
|
|
1498
1520
|
const Calendar = ({ className, classNames, showOutsideDays = true, ...props }) => {
|
|
1521
|
+
const defaults = getDefaultClassNames();
|
|
1522
|
+
const navButton = cn("inline-flex size-(--cell-size) shrink-0 select-none items-center justify-center rounded-md p-0", "text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground", "aria-disabled:pointer-events-none aria-disabled:opacity-50", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 focus-visible:ring-offset-2");
|
|
1499
1523
|
return /* @__PURE__ */ jsx(DayPicker, {
|
|
1500
1524
|
showOutsideDays,
|
|
1501
|
-
className: cn("p-3", className),
|
|
1525
|
+
className: cn("p-3 [--cell-size:2.25rem]", defaults.root, className),
|
|
1502
1526
|
classNames: {
|
|
1503
|
-
months: "flex flex-col sm:flex-row
|
|
1504
|
-
month: "flex flex-col gap-4",
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
month_grid: "w-full border-collapse
|
|
1511
|
-
weekdays: "flex",
|
|
1512
|
-
weekday: "
|
|
1513
|
-
week: "flex w-full
|
|
1514
|
-
day: cn("relative p-0 text-center
|
|
1515
|
-
day_button: cn("inline-flex items-center justify-center
|
|
1516
|
-
range_start: "day-range-start rounded-l-md",
|
|
1517
|
-
range_end: "day-range-end rounded-r-md",
|
|
1518
|
-
selected: "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
|
|
1519
|
-
today: "bg-accent text-accent-foreground",
|
|
1520
|
-
outside: "day-outside text-muted-foreground aria-selected:text-muted-foreground",
|
|
1521
|
-
disabled: "text-muted-foreground",
|
|
1522
|
-
range_middle: "aria-selected:bg-accent aria-selected:text-accent-foreground",
|
|
1523
|
-
hidden: "invisible",
|
|
1527
|
+
months: cn("relative flex flex-col gap-4 sm:flex-row", defaults.months),
|
|
1528
|
+
month: cn("flex w-full flex-col gap-4", defaults.month),
|
|
1529
|
+
nav: cn("absolute inset-x-0 top-0 flex h-(--cell-size) w-full items-center justify-between gap-1", defaults.nav),
|
|
1530
|
+
button_previous: cn(navButton, defaults.button_previous),
|
|
1531
|
+
button_next: cn(navButton, defaults.button_next),
|
|
1532
|
+
month_caption: cn("flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)", defaults.month_caption),
|
|
1533
|
+
caption_label: cn("select-none text-sm font-medium", defaults.caption_label),
|
|
1534
|
+
month_grid: cn("w-full border-collapse", defaults.month_grid),
|
|
1535
|
+
weekdays: cn("flex", defaults.weekdays),
|
|
1536
|
+
weekday: cn("flex-1 select-none text-[0.8rem] font-normal text-muted-foreground", defaults.weekday),
|
|
1537
|
+
week: cn("mt-2 flex w-full", defaults.week),
|
|
1538
|
+
day: cn("relative aspect-square h-full w-full select-none p-0 text-center focus-within:relative focus-within:z-20", "[&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50", props.mode === "range" ? "[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md [&:has([aria-selected].day-range-end)]:rounded-r-md" : "[&:has([aria-selected])]:rounded-md", defaults.day),
|
|
1539
|
+
day_button: cn("inline-flex size-full min-w-(--cell-size) items-center justify-center p-0 text-sm font-normal aria-selected:opacity-100 rounded-md", "hover:bg-accent hover:text-accent-foreground", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 focus-visible:ring-offset-2", defaults.day_button),
|
|
1540
|
+
range_start: cn("day-range-start rounded-l-md", defaults.range_start),
|
|
1541
|
+
range_end: cn("day-range-end rounded-r-md", defaults.range_end),
|
|
1542
|
+
selected: cn("bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground", defaults.selected),
|
|
1543
|
+
today: cn("bg-accent text-accent-foreground", defaults.today),
|
|
1544
|
+
outside: cn("day-outside text-muted-foreground aria-selected:text-muted-foreground", defaults.outside),
|
|
1545
|
+
disabled: cn("text-muted-foreground opacity-50", defaults.disabled),
|
|
1546
|
+
range_middle: cn("aria-selected:bg-accent aria-selected:text-accent-foreground", defaults.range_middle),
|
|
1547
|
+
hidden: cn("invisible", defaults.hidden),
|
|
1524
1548
|
...classNames
|
|
1525
1549
|
},
|
|
1526
1550
|
components: { Chevron: ({ orientation }) => orientation === "left" ? /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" }) },
|
|
@@ -1667,7 +1691,7 @@ const PopoverContent = React.forwardRef(({ className, align = "center", sideOffs
|
|
|
1667
1691
|
PopoverContent.displayName = Popover$1.Content.displayName;
|
|
1668
1692
|
//#endregion
|
|
1669
1693
|
//#region src/components/date-picker.tsx
|
|
1670
|
-
const DatePicker = React.forwardRef(({ value, onChange, placeholder = "Pick a date", dateFormat = "PPP", disabled = false, className, fromDate, toDate, disabledDates }, ref) => {
|
|
1694
|
+
const DatePicker = React.forwardRef(({ value, onChange, placeholder = "Pick a date", dateFormat = "PPP", disabled = false, className, fromDate, toDate, disabledDates, calendarLabel = "Choose a date", size = "md" }, ref) => {
|
|
1671
1695
|
const fieldProps = useFieldControl({});
|
|
1672
1696
|
const [open, setOpen] = React.useState(false);
|
|
1673
1697
|
const handleSelect = (date) => {
|
|
@@ -1682,6 +1706,7 @@ const DatePicker = React.forwardRef(({ value, onChange, placeholder = "Pick a da
|
|
|
1682
1706
|
children: /* @__PURE__ */ jsxs(Button, {
|
|
1683
1707
|
ref,
|
|
1684
1708
|
variant: "outline",
|
|
1709
|
+
size,
|
|
1685
1710
|
disabled,
|
|
1686
1711
|
className: cn("w-full justify-start text-left font-normal", !value && "text-muted-foreground", className),
|
|
1687
1712
|
...fieldProps,
|
|
@@ -1690,6 +1715,7 @@ const DatePicker = React.forwardRef(({ value, onChange, placeholder = "Pick a da
|
|
|
1690
1715
|
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
1691
1716
|
className: "w-auto p-0",
|
|
1692
1717
|
align: "start",
|
|
1718
|
+
"aria-label": calendarLabel,
|
|
1693
1719
|
children: /* @__PURE__ */ jsx(Calendar, {
|
|
1694
1720
|
mode: "single",
|
|
1695
1721
|
selected: value,
|
|
@@ -1944,7 +1970,7 @@ const dateRangePresets = {
|
|
|
1944
1970
|
}
|
|
1945
1971
|
})
|
|
1946
1972
|
};
|
|
1947
|
-
const DateRangePicker = React.forwardRef(({ value, onChange, placeholder = "Pick a date range", dateFormat = "LLL dd, y", disabled = false, className, presets, numberOfMonths = 2, fromDate, toDate, clearable = true, clearLabel = "Clear date range" }, ref) => {
|
|
1973
|
+
const DateRangePicker = React.forwardRef(({ value, onChange, placeholder = "Pick a date range", dateFormat = "LLL dd, y", disabled = false, className, presets, numberOfMonths = 2, fromDate, toDate, clearable = true, clearLabel = "Clear date range", calendarLabel = "Choose a date range", size = "md" }, ref) => {
|
|
1948
1974
|
const fieldProps = useFieldControl({});
|
|
1949
1975
|
const [open, setOpen] = React.useState(false);
|
|
1950
1976
|
const handlePresetClick = (preset) => {
|
|
@@ -1967,6 +1993,7 @@ const DateRangePicker = React.forwardRef(({ value, onChange, placeholder = "Pick
|
|
|
1967
1993
|
children: /* @__PURE__ */ jsxs(Button, {
|
|
1968
1994
|
ref,
|
|
1969
1995
|
variant: "outline",
|
|
1996
|
+
size,
|
|
1970
1997
|
disabled,
|
|
1971
1998
|
className: cn("w-full justify-start text-left font-normal", !value && "text-muted-foreground", showClear && "pr-9", className),
|
|
1972
1999
|
...fieldProps,
|
|
@@ -1991,6 +2018,7 @@ const DateRangePicker = React.forwardRef(({ value, onChange, placeholder = "Pick
|
|
|
1991
2018
|
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
1992
2019
|
className: "w-auto p-0",
|
|
1993
2020
|
align: "start",
|
|
2021
|
+
"aria-label": calendarLabel,
|
|
1994
2022
|
children: /* @__PURE__ */ jsxs("div", {
|
|
1995
2023
|
className: cn("flex", presets && presets.length > 0 && "flex-row"),
|
|
1996
2024
|
children: [presets && presets.length > 0 && /* @__PURE__ */ jsxs("div", {
|