tw-react-components 0.0.137 → 0.0.139
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/index.cjs.js +218 -216
- package/index.css +5 -4
- package/index.esm.js +77 -75
- package/package.json +1 -1
- package/src/components/Dialog/Dialog.d.ts +3 -3
- package/src/components/Dialog/FormDialog.d.ts +5 -1
- package/src/components/Layout/index.d.ts +1 -2
- package/src/components/Navbar/index.d.ts +1 -0
- package/src/components/Sheet/index.d.ts +12 -12
package/index.css
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
--popover: 0 0% 100%;
|
|
14
14
|
--popover-foreground: 222.2 47.4% 11.2%;
|
|
15
15
|
|
|
16
|
-
--border:
|
|
17
|
-
--input:
|
|
16
|
+
--border: 220 13% 91%;
|
|
17
|
+
--input: 220 13% 91%;
|
|
18
18
|
|
|
19
19
|
--card: 0 0% 100%;
|
|
20
20
|
--card-foreground: 222.2 47.4% 11.2%;
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
--popover: 224 71% 4%;
|
|
59
59
|
--popover-foreground: 215 20.2% 65.1%;
|
|
60
60
|
|
|
61
|
-
--border:
|
|
62
|
-
--input:
|
|
61
|
+
--border: 215 25% 27%;
|
|
62
|
+
--input: 215 25% 27%;
|
|
63
63
|
|
|
64
64
|
--card: 224 71% 4%;
|
|
65
65
|
--card-foreground: 213 31% 91%;
|
|
@@ -92,6 +92,7 @@
|
|
|
92
92
|
* {
|
|
93
93
|
@apply border-border;
|
|
94
94
|
}
|
|
95
|
+
|
|
95
96
|
body {
|
|
96
97
|
@apply bg-background text-foreground;
|
|
97
98
|
font-feature-settings:
|
package/index.esm.js
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import * as React from 'react';
|
|
3
2
|
import { forwardRef, useMemo, useState, useEffect, useId, useCallback, useRef, createContext, useContext } from 'react';
|
|
4
3
|
import { clsx } from 'clsx';
|
|
5
4
|
import { twMerge } from 'tailwind-merge';
|
|
6
5
|
import dayjs from 'dayjs';
|
|
7
6
|
import advancedFormat from 'dayjs/plugin/advancedFormat';
|
|
8
|
-
import { HelpCircle, XIcon, AtSignIcon, EyeIcon, EyeOffIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronDownIcon, CalendarIcon, ClockIcon, CheckIcon, CircleIcon, CloudUploadIcon, ChevronsLeftIcon, ChevronsRightIcon, ChevronsDownUpIcon, ChevronsUpDownIcon, ArrowUpDownIcon, SortAscIcon, SortDescIcon, MinusIcon, PlusIcon,
|
|
7
|
+
import { HelpCircle, XIcon, AtSignIcon, EyeIcon, EyeOffIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronDownIcon, CalendarIcon, ClockIcon, CheckIcon, CircleIcon, CloudUploadIcon, ChevronsLeftIcon, ChevronsRightIcon, ChevronsDownUpIcon, ChevronsUpDownIcon, ArrowUpDownIcon, SortAscIcon, SortDescIcon, MinusIcon, PlusIcon, PanelLeft, MoonIcon, SunIcon } from 'lucide-react';
|
|
9
8
|
import localeData from 'dayjs/plugin/localeData';
|
|
10
9
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
11
10
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
12
11
|
import { useFormContext, Controller, FormProvider } from 'react-hook-form';
|
|
13
12
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
13
|
+
import { cva } from 'class-variance-authority';
|
|
14
14
|
import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCenter } from '@dnd-kit/core';
|
|
15
15
|
import { restrictToFirstScrollableAncestor } from '@dnd-kit/modifiers';
|
|
16
16
|
import { sortableKeyboardCoordinates, SortableContext, verticalListSortingStrategy, useSortable } from '@dnd-kit/sortable';
|
|
17
17
|
import { CSS } from '@dnd-kit/utilities';
|
|
18
18
|
import { Link, useLocation } from 'react-router-dom';
|
|
19
19
|
import { Slot } from '@radix-ui/react-slot';
|
|
20
|
-
import { cva } from 'class-variance-authority';
|
|
21
20
|
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
|
22
21
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
23
22
|
import * as SwitchPrimitives from '@radix-ui/react-switch';
|
|
@@ -1571,18 +1570,19 @@ const ExpandButton = ({ folded, foldComponent, unfoldComponent, onClick, }) => {
|
|
|
1571
1570
|
return (jsx(Icon, { className: "h-6 w-6 cursor-pointer rounded p-1 hover:bg-slate-300 hover:dark:bg-slate-600", onClick: onClick }));
|
|
1572
1571
|
};
|
|
1573
1572
|
|
|
1574
|
-
const $Dialog = DialogPrimitive.Root;
|
|
1573
|
+
const $Dialog = (props) => (jsx(DialogPrimitive.Root, Object.assign({}, props)));
|
|
1574
|
+
$Dialog.displayName = DialogPrimitive.Root.displayName;
|
|
1575
1575
|
const DialogTrigger = DialogPrimitive.Trigger;
|
|
1576
1576
|
const DialogPortal = DialogPrimitive.Portal;
|
|
1577
1577
|
const DialogClose = DialogPrimitive.Close;
|
|
1578
1578
|
const DialogOverlay = forwardRef((_a, ref) => {
|
|
1579
1579
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1580
|
-
return (jsx(DialogPrimitive.Overlay, Object.assign({ ref: ref, className: cn('data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50
|
|
1580
|
+
return (jsx(DialogPrimitive.Overlay, Object.assign({ ref: ref, className: cn('data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80', className) }, props)));
|
|
1581
1581
|
});
|
|
1582
1582
|
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
1583
1583
|
const DialogContent = forwardRef((_a, ref) => {
|
|
1584
1584
|
var { className, fullScreen, children } = _a, props = __rest(_a, ["className", "fullScreen", "children"]);
|
|
1585
|
-
return (jsxs(DialogPortal, { children: [jsx(DialogOverlay, {}), jsxs(DialogPrimitive.Content, Object.assign({ ref: ref, className: cn('data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]', 'fixed left-[50%] top-[50%] z-50 flex w-full max-w-lg translate-x-[-50%] translate-y-[-50%] flex-col gap-
|
|
1585
|
+
return (jsxs(DialogPortal, { children: [jsx(DialogOverlay, {}), jsxs(DialogPrimitive.Content, Object.assign({ ref: ref, className: cn('bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]', 'fixed left-[50%] top-[50%] z-50 flex max-h-[95dvh] w-full max-w-lg translate-x-[-50%] translate-y-[-50%] flex-col gap-4 rounded-lg border p-4 shadow-lg duration-200', className, fullScreen && 'h-full max-h-none w-full max-w-none rounded-none'), "aria-describedby": "dialog-content" }, props, { children: [children, jsx(DialogPrimitive.Close, { className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute right-2 top-2 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:pointer-events-none", asChild: true, children: jsx(Button, { prefixIcon: XIcon, size: "small", variant: "text" }) }), jsx(DialogPrimitive.Description, { className: "hidden" })] }))] }));
|
|
1586
1586
|
});
|
|
1587
1587
|
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
1588
1588
|
const DialogHeader = (_a) => {
|
|
@@ -1597,12 +1597,12 @@ const DialogFooter = (_a) => {
|
|
|
1597
1597
|
DialogFooter.displayName = 'DialogFooter';
|
|
1598
1598
|
const DialogTitle = forwardRef((_a, ref) => {
|
|
1599
1599
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1600
|
-
return (jsx(DialogPrimitive.Title, Object.assign({ ref: ref, className: cn('text-lg font-semibold
|
|
1600
|
+
return (jsx(DialogPrimitive.Title, Object.assign({ ref: ref, className: cn('text-foreground text-lg font-semibold', className) }, props)));
|
|
1601
1601
|
});
|
|
1602
1602
|
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
1603
1603
|
const DialogDescription = forwardRef((_a, ref) => {
|
|
1604
1604
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1605
|
-
return (jsx(DialogPrimitive.Description, Object.assign({ ref: ref, className: cn('text-
|
|
1605
|
+
return (jsx(DialogPrimitive.Description, Object.assign({ ref: ref, className: cn('text-muted-foreground text-sm', className) }, props)));
|
|
1606
1606
|
});
|
|
1607
1607
|
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
1608
1608
|
const Dialog = Object.assign($Dialog, {
|
|
@@ -1617,9 +1617,69 @@ const Dialog = Object.assign($Dialog, {
|
|
|
1617
1617
|
Description: DialogDescription,
|
|
1618
1618
|
});
|
|
1619
1619
|
|
|
1620
|
-
const ConfirmDialog = ({ open, title, children, yesLabel, noLabel, onConfirm, onClose, }) => (jsx(Dialog, { open: open, onOpenChange: (value) => !value && onClose(), children: jsxs(Dialog.Content, {
|
|
1620
|
+
const ConfirmDialog = ({ open, title, children, yesLabel, noLabel, onConfirm, onClose, }) => (jsx(Dialog, { open: open, onOpenChange: (value) => !value && onClose(), children: jsxs(Dialog.Content, { children: [jsx(Dialog.Header, { children: jsx(Dialog.Title, { children: title }) }), children, jsxs(Dialog.Footer, { children: [jsx(Dialog.Close, { asChild: true, children: jsx(Button, { color: "red", children: noLabel !== null && noLabel !== void 0 ? noLabel : 'No' }) }), jsx(Dialog.Close, { asChild: true, children: jsx(Button, { color: "green", onClick: onConfirm, children: yesLabel !== null && yesLabel !== void 0 ? yesLabel : 'Yes' }) })] })] }) }));
|
|
1621
|
+
|
|
1622
|
+
const $Sheet = (props) => (jsx(DialogPrimitive.Root, Object.assign({}, props)));
|
|
1623
|
+
$Sheet.displayName = DialogPrimitive.Root.displayName;
|
|
1624
|
+
const SheetTrigger = DialogPrimitive.Trigger;
|
|
1625
|
+
const SheetClose = DialogPrimitive.Close;
|
|
1626
|
+
const SheetPortal = DialogPrimitive.Portal;
|
|
1627
|
+
const SheetOverlay = forwardRef((_a, ref) => {
|
|
1628
|
+
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1629
|
+
return (jsx(DialogPrimitive.Overlay, Object.assign({ className: cn('data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80', className) }, props, { ref: ref })));
|
|
1630
|
+
});
|
|
1631
|
+
SheetOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
1632
|
+
const sheetVariants = cva('fixed flex flex-col z-50 gap-4 bg-background p-4 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500', {
|
|
1633
|
+
variants: {
|
|
1634
|
+
side: {
|
|
1635
|
+
top: 'inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top',
|
|
1636
|
+
bottom: 'inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom',
|
|
1637
|
+
left: 'inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm',
|
|
1638
|
+
right: 'inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm',
|
|
1639
|
+
},
|
|
1640
|
+
},
|
|
1641
|
+
defaultVariants: {
|
|
1642
|
+
side: 'right',
|
|
1643
|
+
},
|
|
1644
|
+
});
|
|
1645
|
+
const SheetContent = forwardRef((_a, ref) => {
|
|
1646
|
+
var { side = 'right', className, children } = _a, props = __rest(_a, ["side", "className", "children"]);
|
|
1647
|
+
return (jsxs(SheetPortal, { children: [jsx(SheetOverlay, {}), jsxs(DialogPrimitive.Content, Object.assign({ ref: ref, className: cn(sheetVariants({ side }), className) }, props, { children: [children, jsx(DialogPrimitive.Close, { className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute right-2 top-2 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:pointer-events-none", asChild: true, children: jsx(Button, { prefixIcon: XIcon, size: "small", variant: "text" }) }), jsx(DialogPrimitive.Description, { className: "hidden" })] }))] }));
|
|
1648
|
+
});
|
|
1649
|
+
SheetContent.displayName = DialogPrimitive.Content.displayName;
|
|
1650
|
+
const SheetHeader = (_a) => {
|
|
1651
|
+
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1652
|
+
return (jsx("div", Object.assign({ className: cn('flex flex-col space-y-2 text-center sm:text-left', className) }, props)));
|
|
1653
|
+
};
|
|
1654
|
+
SheetHeader.displayName = 'SheetHeader';
|
|
1655
|
+
const SheetFooter = (_a) => {
|
|
1656
|
+
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1657
|
+
return (jsx("div", Object.assign({ className: cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className) }, props)));
|
|
1658
|
+
};
|
|
1659
|
+
SheetFooter.displayName = 'SheetFooter';
|
|
1660
|
+
const SheetTitle = forwardRef((_a, ref) => {
|
|
1661
|
+
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1662
|
+
return (jsx(DialogPrimitive.Title, Object.assign({ ref: ref, className: cn('text-foreground text-lg font-semibold', className) }, props)));
|
|
1663
|
+
});
|
|
1664
|
+
SheetTitle.displayName = DialogPrimitive.Title.displayName;
|
|
1665
|
+
const SheetDescription = forwardRef((_a, ref) => {
|
|
1666
|
+
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1667
|
+
return (jsx(DialogPrimitive.Description, Object.assign({ ref: ref, className: cn('text-muted-foreground text-sm', className) }, props)));
|
|
1668
|
+
});
|
|
1669
|
+
SheetDescription.displayName = DialogPrimitive.Description.displayName;
|
|
1670
|
+
const Sheet = Object.assign($Sheet, {
|
|
1671
|
+
Portal: SheetPortal,
|
|
1672
|
+
Overlay: SheetOverlay,
|
|
1673
|
+
Trigger: SheetTrigger,
|
|
1674
|
+
Close: SheetClose,
|
|
1675
|
+
Content: SheetContent,
|
|
1676
|
+
Header: SheetHeader,
|
|
1677
|
+
Footer: SheetFooter,
|
|
1678
|
+
Title: SheetTitle,
|
|
1679
|
+
Description: SheetDescription,
|
|
1680
|
+
});
|
|
1621
1681
|
|
|
1622
|
-
const FormDialog = ({ className, open, title, form, children, submitLabel = 'Submit', cancelLabel = 'Cancel', extraAction, onSubmit, onInvalid, onClose, }) => {
|
|
1682
|
+
const FormDialog = ({ className, formClassName, open, title, form, children, submitLabel = 'Submit', cancelLabel = 'Cancel', extraAction, as: As = Sheet, onSubmit, onInvalid, onClose, }) => {
|
|
1623
1683
|
const id = useId();
|
|
1624
1684
|
const handleSubmit = (data, event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1625
1685
|
try {
|
|
@@ -1629,7 +1689,7 @@ const FormDialog = ({ className, open, title, form, children, submitLabel = 'Sub
|
|
|
1629
1689
|
// do nothering
|
|
1630
1690
|
}
|
|
1631
1691
|
});
|
|
1632
|
-
return (jsx(
|
|
1692
|
+
return (jsx(As, { open: open, onOpenChange: (value) => !value && onClose(), children: jsxs(As.Content, { className: className, children: [jsx(As.Header, { children: jsx(As.Title, { children: title }) }), jsx(FormProvider, Object.assign({}, form, { children: jsx("form", { id: `form-${id}`, className: cn('flex h-full w-full flex-col gap-3 overflow-auto', formClassName), onSubmit: form.handleSubmit(handleSubmit, onInvalid), children: children }) })), jsxs(As.Footer, { className: "w-full sm:justify-between", children: [extraAction, jsxs(As.Footer, { className: "ml-auto", children: [jsx(As.Close, { asChild: true, children: jsx(Button, { color: "red", children: cancelLabel }) }), jsx(Button, { color: "green", type: "submit", form: `form-${id}`, disabled: form.formState.isSubmitting, children: submitLabel })] })] })] }) }));
|
|
1633
1693
|
};
|
|
1634
1694
|
|
|
1635
1695
|
function ListSorter({ className, items, idResolver, renderer, onChange, }) {
|
|
@@ -1667,11 +1727,11 @@ function ListSorterDialog({ className, open, title, items, idResolver, renderer,
|
|
|
1667
1727
|
}, [items]);
|
|
1668
1728
|
const preFinish = () => onSubmit(sortedItems);
|
|
1669
1729
|
const customRenderer = (item, index, listeners) => (jsxs(Flex, { align: "center", className: "gap-4 p-4 focus:outline-none dark:bg-slate-900 hover:dark:bg-slate-800", children: [jsx(Flex, Object.assign({ align: "center", justify: "center", className: "cursor-move rounded-lg p-2 hover:bg-slate-200 dark:hover:bg-slate-700" }, listeners, { children: jsx(ArrowUpDownIcon, { className: "h-5 w-5" }) })), renderer(item, index, listeners)] }));
|
|
1670
|
-
return (jsx(Dialog, { open: open, onOpenChange: (value) => !value && onClose(), children: jsxs(Dialog.Content, { className:
|
|
1730
|
+
return (jsx(Dialog, { open: open, onOpenChange: (value) => !value && onClose(), children: jsxs(Dialog.Content, { className: className, onPointerDownOutside: (event) => event.preventDefault(), children: [jsx(Dialog.Header, { children: jsx(Dialog.Title, { children: title }) }), jsx(ListSorter, { className: "divide-y overflow-auto rounded-lg border dark:divide-slate-700 dark:border-slate-700 dark:text-white", items: sortedItems, idResolver: idResolver, renderer: customRenderer, onChange: setSortedItems }), jsxs(Dialog.Footer, { children: [jsx(Dialog.Close, { asChild: true, children: jsx(Button, { color: "red", children: cancelLabel !== null && cancelLabel !== void 0 ? cancelLabel : 'Cancel' }) }), jsx(Button, { color: "green", onClick: preFinish, children: submitLabel !== null && submitLabel !== void 0 ? submitLabel : 'Submit' })] })] }) }));
|
|
1671
1731
|
}
|
|
1672
1732
|
|
|
1673
1733
|
const PdfViewerDialog = ({ open, title, url, data, onClose }) => {
|
|
1674
|
-
return !(url || data) ? null : (jsx(Dialog, { open: open, onOpenChange: (value) => !value && onClose(), children: jsxs(Dialog.Content, { className: "h-[
|
|
1734
|
+
return !(url || data) ? null : (jsx(Dialog, { open: open, onOpenChange: (value) => !value && onClose(), children: jsxs(Dialog.Content, { className: "h-[95dvh] max-w-[95dvw]", children: [jsx(Dialog.Header, { children: jsx(Dialog.Title, { children: title }) }), (url || data) && (jsx("embed", { className: "rounded-lg", src: url !== null && url !== void 0 ? url : `data:application/pdf;base64,${data}`, type: "application/pdf", width: "100%", height: "100%" }))] }) }));
|
|
1675
1735
|
};
|
|
1676
1736
|
|
|
1677
1737
|
const Separator = forwardRef((_a, ref) => {
|
|
@@ -1680,65 +1740,6 @@ const Separator = forwardRef((_a, ref) => {
|
|
|
1680
1740
|
});
|
|
1681
1741
|
Separator.displayName = SeparatorPrimitive.Root.displayName;
|
|
1682
1742
|
|
|
1683
|
-
const $Sheet = DialogPrimitive.Root;
|
|
1684
|
-
const SheetTrigger = DialogPrimitive.Trigger;
|
|
1685
|
-
const SheetClose = DialogPrimitive.Close;
|
|
1686
|
-
const SheetPortal = DialogPrimitive.Portal;
|
|
1687
|
-
const SheetOverlay = React.forwardRef((_a, ref) => {
|
|
1688
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1689
|
-
return (jsx(DialogPrimitive.Overlay, Object.assign({ className: cn('data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80', className) }, props, { ref: ref })));
|
|
1690
|
-
});
|
|
1691
|
-
SheetOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
1692
|
-
const sheetVariants = cva('fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500', {
|
|
1693
|
-
variants: {
|
|
1694
|
-
side: {
|
|
1695
|
-
top: 'inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top',
|
|
1696
|
-
bottom: 'inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom',
|
|
1697
|
-
left: 'inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm',
|
|
1698
|
-
right: 'inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm',
|
|
1699
|
-
},
|
|
1700
|
-
},
|
|
1701
|
-
defaultVariants: {
|
|
1702
|
-
side: 'right',
|
|
1703
|
-
},
|
|
1704
|
-
});
|
|
1705
|
-
const SheetContent = React.forwardRef((_a, ref) => {
|
|
1706
|
-
var { side = 'right', className, children } = _a, props = __rest(_a, ["side", "className", "children"]);
|
|
1707
|
-
return (jsxs(SheetPortal, { children: [jsx(SheetOverlay, {}), jsxs(DialogPrimitive.Content, Object.assign({ ref: ref, className: cn(sheetVariants({ side }), className) }, props, { children: [children, jsxs(DialogPrimitive.Close, { className: "ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:pointer-events-none", children: [jsx(X, { className: "h-4 w-4" }), jsx("span", { className: "sr-only", children: "Close" })] })] }))] }));
|
|
1708
|
-
});
|
|
1709
|
-
SheetContent.displayName = DialogPrimitive.Content.displayName;
|
|
1710
|
-
const SheetHeader = (_a) => {
|
|
1711
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1712
|
-
return (jsx("div", Object.assign({ className: cn('flex flex-col space-y-2 text-center sm:text-left', className) }, props)));
|
|
1713
|
-
};
|
|
1714
|
-
SheetHeader.displayName = 'SheetHeader';
|
|
1715
|
-
const SheetFooter = (_a) => {
|
|
1716
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1717
|
-
return (jsx("div", Object.assign({ className: cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className) }, props)));
|
|
1718
|
-
};
|
|
1719
|
-
SheetFooter.displayName = 'SheetFooter';
|
|
1720
|
-
const SheetTitle = React.forwardRef((_a, ref) => {
|
|
1721
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1722
|
-
return (jsx(DialogPrimitive.Title, Object.assign({ ref: ref, className: cn('text-foreground text-lg font-semibold', className) }, props)));
|
|
1723
|
-
});
|
|
1724
|
-
SheetTitle.displayName = DialogPrimitive.Title.displayName;
|
|
1725
|
-
const SheetDescription = React.forwardRef((_a, ref) => {
|
|
1726
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1727
|
-
return (jsx(DialogPrimitive.Description, Object.assign({ ref: ref, className: cn('text-muted-foreground text-sm', className) }, props)));
|
|
1728
|
-
});
|
|
1729
|
-
SheetDescription.displayName = DialogPrimitive.Description.displayName;
|
|
1730
|
-
const Sheet = Object.assign($Sheet, {
|
|
1731
|
-
Portal: SheetPortal,
|
|
1732
|
-
Overlay: SheetOverlay,
|
|
1733
|
-
Trigger: SheetTrigger,
|
|
1734
|
-
Close: SheetClose,
|
|
1735
|
-
Content: SheetContent,
|
|
1736
|
-
Header: SheetHeader,
|
|
1737
|
-
Footer: SheetFooter,
|
|
1738
|
-
Title: SheetTitle,
|
|
1739
|
-
Description: SheetDescription,
|
|
1740
|
-
});
|
|
1741
|
-
|
|
1742
1743
|
const Skeleton = (_a) => {
|
|
1743
1744
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1744
1745
|
return (jsx("div", Object.assign({ className: cn('bg-muted animate-pulse rounded-md', className) }, props)));
|
|
@@ -2007,10 +2008,11 @@ const Sidebar = Object.assign($Sidebar, {
|
|
|
2007
2008
|
Trigger: SidebarTrigger,
|
|
2008
2009
|
});
|
|
2009
2010
|
|
|
2010
|
-
const Navbar = ({ leftSlot, rightSlot }) => (jsx(Block, { className:
|
|
2011
|
+
const Navbar = ({ className, leftSlot, rightSlot }) => (jsx(Block, { className: cn('border-b p-3 dark:border-slate-700', className), fullWidth: true, children: jsxs(Flex, { align: "center", justify: "between", children: [jsxs(Flex, { align: "center", children: [jsx(Sidebar.Trigger, {}), leftSlot] }), rightSlot] }) }));
|
|
2011
2012
|
|
|
2012
|
-
const Layout = (
|
|
2013
|
-
|
|
2013
|
+
const Layout = (_a) => {
|
|
2014
|
+
var { children, className } = _a, _b = _a.sidebarProps, { basePath, smallLogo, fullLogo, items } = _b, sidebarProps = __rest(_b, ["basePath", "smallLogo", "fullLogo", "items"]), { navbarProps } = _a;
|
|
2015
|
+
return (jsxs(Flex, { className: "h-screen w-screen gap-0 text-black dark:bg-slate-900 dark:text-white", children: [jsxs(Sidebar, Object.assign({ collapsible: "icon" }, sidebarProps, { children: [jsx(Sidebar.Header, { children: smallLogo && fullLogo && (jsx("div", { className: "cursor-pointer overflow-hidden whitespace-nowrap py-2 text-center text-lg", children: jsxs(Link, { to: "/", children: [jsx("span", { className: "group-data-[state=collapsed]:hidden", children: fullLogo }), jsx("span", { className: "group-data-[state=expanded]:hidden", children: smallLogo })] }) })) }), jsx(Sidebar.Content, { className: "gap-0", children: items.map((item, index) => item.type === 'item' ? (jsx(Sidebar.Group, { children: jsx(Sidebar.Menu, { children: jsx(RenderSideBarItem, Object.assign({ basePath: basePath }, item)) }) }, index)) : (jsxs(Sidebar.Group, { children: [item.title && jsx(Sidebar.GroupLabel, { children: item.title }), jsx(Sidebar.GroupContent, { children: jsx(Sidebar.Menu, { children: item.items.map((item, index) => (jsx(RenderSideBarItem, Object.assign({ basePath: basePath }, item), index))) }) })] }, index))) }), jsx(Sidebar.Rail, {})] })), jsxs(Flex, { className: "gap-0 overflow-hidden", direction: "column", fullHeight: true, fullWidth: true, children: [jsx(Navbar, Object.assign({}, navbarProps)), jsx(Flex, { className: cn('overflow-hidden p-3', className), direction: "column", fullWidth: true, fullHeight: true, children: children })] })] }));
|
|
2014
2016
|
};
|
|
2015
2017
|
const RenderSideBarItem = ({ basePath = '/', pathname, title, Icon, items, }) => {
|
|
2016
2018
|
const location = useLocation();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tw-react-components",
|
|
3
3
|
"description": "A set of React components build with TailwindCSS to make a nice dashboard.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.139",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://bacali95.github.io/tw-react-components",
|
|
7
7
|
"author": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
2
|
-
import { HTMLAttributes } from 'react';
|
|
3
|
-
export declare const Dialog:
|
|
4
|
-
Portal:
|
|
2
|
+
import { FC, HTMLAttributes } from 'react';
|
|
3
|
+
export declare const Dialog: FC<DialogPrimitive.DialogProps> & {
|
|
4
|
+
Portal: FC<DialogPrimitive.DialogPortalProps>;
|
|
5
5
|
Overlay: import("react").ForwardRefExoticComponent<Omit<DialogPrimitive.DialogOverlayProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
6
6
|
Close: import("react").ForwardRefExoticComponent<DialogPrimitive.DialogCloseProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
7
7
|
Trigger: import("react").ForwardRefExoticComponent<DialogPrimitive.DialogTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { PropsWithChildren, ReactNode } from 'react';
|
|
2
2
|
import { FieldValues, SubmitErrorHandler, SubmitHandler, UseFormReturn } from 'react-hook-form';
|
|
3
|
+
import { Sheet } from '../Sheet';
|
|
4
|
+
import { Dialog } from './Dialog';
|
|
3
5
|
type Props<T extends FieldValues> = {
|
|
4
6
|
className?: string;
|
|
7
|
+
formClassName?: string;
|
|
5
8
|
open: boolean;
|
|
6
9
|
title: ReactNode;
|
|
7
10
|
form: UseFormReturn<T>;
|
|
8
11
|
submitLabel?: string;
|
|
9
12
|
cancelLabel?: string;
|
|
10
13
|
extraAction?: ReactNode;
|
|
14
|
+
as?: typeof Dialog | typeof Sheet;
|
|
11
15
|
onSubmit: SubmitHandler<T>;
|
|
12
16
|
onInvalid?: SubmitErrorHandler<T>;
|
|
13
17
|
onClose: () => void;
|
|
14
18
|
};
|
|
15
|
-
export declare const FormDialog: <T extends FieldValues>({ className, open, title, form, children, submitLabel, cancelLabel, extraAction, onSubmit, onInvalid, onClose, }: PropsWithChildren<Props<T>>) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare const FormDialog: <T extends FieldValues>({ className, formClassName, open, title, form, children, submitLabel, cancelLabel, extraAction, as: As, onSubmit, onInvalid, onClose, }: PropsWithChildren<Props<T>>) => import("react/jsx-runtime").JSX.Element;
|
|
16
20
|
export {};
|
|
@@ -9,8 +9,7 @@ export type SidebarItem = {
|
|
|
9
9
|
hidden?: boolean;
|
|
10
10
|
items?: SidebarItem[];
|
|
11
11
|
};
|
|
12
|
-
export type SidebarProps = {
|
|
13
|
-
root?: ComponentProps<typeof Sidebar>;
|
|
12
|
+
export type SidebarProps = ComponentProps<typeof Sidebar> & {
|
|
14
13
|
basePath?: string;
|
|
15
14
|
smallLogo?: ReactNode;
|
|
16
15
|
fullLogo?: ReactNode;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import * as SheetPrimitive from '@radix-ui/react-dialog';
|
|
2
2
|
import { type VariantProps } from 'class-variance-authority';
|
|
3
|
-
import
|
|
3
|
+
import { ComponentPropsWithoutRef, FC, HTMLAttributes } from 'react';
|
|
4
4
|
declare const sheetVariants: (props?: ({
|
|
5
5
|
side?: "top" | "bottom" | "left" | "right" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
7
|
-
interface SheetContentProps extends
|
|
7
|
+
interface SheetContentProps extends ComponentPropsWithoutRef<typeof SheetPrimitive.Content>, VariantProps<typeof sheetVariants> {
|
|
8
8
|
}
|
|
9
|
-
export declare const Sheet:
|
|
10
|
-
Portal:
|
|
11
|
-
Overlay:
|
|
12
|
-
Trigger:
|
|
13
|
-
Close:
|
|
14
|
-
Content:
|
|
9
|
+
export declare const Sheet: FC<SheetPrimitive.DialogProps> & {
|
|
10
|
+
Portal: FC<SheetPrimitive.DialogPortalProps>;
|
|
11
|
+
Overlay: import("react").ForwardRefExoticComponent<Omit<SheetPrimitive.DialogOverlayProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
12
|
+
Trigger: import("react").ForwardRefExoticComponent<SheetPrimitive.DialogTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
13
|
+
Close: import("react").ForwardRefExoticComponent<SheetPrimitive.DialogCloseProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
14
|
+
Content: import("react").ForwardRefExoticComponent<SheetContentProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
15
15
|
Header: {
|
|
16
|
-
({ className, ...props }:
|
|
16
|
+
({ className, ...props }: HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
17
17
|
displayName: string;
|
|
18
18
|
};
|
|
19
19
|
Footer: {
|
|
20
|
-
({ className, ...props }:
|
|
20
|
+
({ className, ...props }: HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
21
21
|
displayName: string;
|
|
22
22
|
};
|
|
23
|
-
Title:
|
|
24
|
-
Description:
|
|
23
|
+
Title: import("react").ForwardRefExoticComponent<Omit<SheetPrimitive.DialogTitleProps & import("react").RefAttributes<HTMLHeadingElement>, "ref"> & import("react").RefAttributes<HTMLHeadingElement>>;
|
|
24
|
+
Description: import("react").ForwardRefExoticComponent<Omit<SheetPrimitive.DialogDescriptionProps & import("react").RefAttributes<HTMLParagraphElement>, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
|
|
25
25
|
};
|
|
26
26
|
export {};
|