art-bd-ui 1.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/README.md +1 -0
- package/dist/cjs/components/buttons/button/button.js +43 -0
- package/dist/cjs/components/buttons/icon-button/icon-button.js +33 -0
- package/dist/cjs/components/buttons/toggle/toggle.js +34 -0
- package/dist/cjs/components/buttons/toggle-group/toggle-group.js +31 -0
- package/dist/cjs/components/forms/checkbox/checkbox.js +52 -0
- package/dist/cjs/components/forms/input/input.js +38 -0
- package/dist/cjs/components/forms/label/label.js +38 -0
- package/dist/cjs/components/forms/radio/radio.js +22 -0
- package/dist/cjs/components/forms/select/select.js +72 -0
- package/dist/cjs/components/forms/switch/switch.js +51 -0
- package/dist/cjs/components/forms/textarea/textarea.js +37 -0
- package/dist/cjs/components/layout/box/box.js +19 -0
- package/dist/cjs/components/layout/flex/flex.js +14 -0
- package/dist/cjs/components/layout/grid/grid.js +14 -0
- package/dist/cjs/components/media/aspect-ratio/aspect-ratio.js +31 -0
- package/dist/cjs/components/media/avatar/avatar.js +27 -0
- package/dist/cjs/components/media/icon/icon.js +27 -0
- package/dist/cjs/components/popovers/dialog/dialog.js +69 -0
- package/dist/cjs/components/popovers/drawer/drawer.js +82 -0
- package/dist/cjs/components/popovers/popover/popover.js +66 -0
- package/dist/cjs/components/popovers/sheet/sheet.js +94 -0
- package/dist/cjs/components/popovers/toast/toast.js +75 -0
- package/dist/cjs/components/popovers/tooltip/tooltip.js +45 -0
- package/dist/cjs/components/typography/heading/heading.js +55 -0
- package/dist/cjs/components/typography/text/text.js +57 -0
- package/dist/cjs/components/ui/alert/alert.js +34 -0
- package/dist/cjs/components/ui/badge/badge.js +31 -0
- package/dist/cjs/components/ui/button/button.js +42 -0
- package/dist/cjs/components/ui/calendar/calendar.js +24 -0
- package/dist/cjs/components/ui/command/command.js +83 -0
- package/dist/cjs/components/ui/data-table/components/cell.js +24 -0
- package/dist/cjs/components/ui/data-table/components/column-group.js +45 -0
- package/dist/cjs/components/ui/data-table/components/table-body.js +47 -0
- package/dist/cjs/components/ui/data-table/components/table-fallback.js +28 -0
- package/dist/cjs/components/ui/data-table/components/table-head.js +56 -0
- package/dist/cjs/components/ui/data-table/components/table-placeholder.js +18 -0
- package/dist/cjs/components/ui/data-table/data-table.js +97 -0
- package/dist/cjs/components/ui/data-table/hooks/contextHooks.js +75 -0
- package/dist/cjs/components/ui/data-table/hooks/useStickyColumns.js +98 -0
- package/dist/cjs/components/ui/data-table/utils.js +26 -0
- package/dist/cjs/components/ui/date-picker/date-picker.js +15 -0
- package/dist/cjs/components/ui/dropdown-menu/dropdown-menu.js +100 -0
- package/dist/cjs/components/ui/icon/icon.js +27 -0
- package/dist/cjs/components/ui/link/link.js +32 -0
- package/dist/cjs/components/ui/pagination/pagination.js +51 -0
- package/dist/cjs/components/ui/progress/progress.js +13 -0
- package/dist/cjs/components/ui/sidebar/sidebar.js +331 -0
- package/dist/cjs/components/ui/table/components/cell.js +30 -0
- package/dist/cjs/components/ui/table/components/row.js +25 -0
- package/dist/cjs/components/ui/table/components/table-body.js +13 -0
- package/dist/cjs/components/ui/table/components/table-caption.js +13 -0
- package/dist/cjs/components/ui/table/components/table-footer.js +13 -0
- package/dist/cjs/components/ui/table/components/table-head.js +30 -0
- package/dist/cjs/components/ui/table/components/table-header.js +13 -0
- package/dist/cjs/components/ui/table/table.js +36 -0
- package/dist/cjs/components/ui/tabs/tabs.js +47 -0
- package/dist/cjs/components/utility/empty-state/empty-state.js +29 -0
- package/dist/cjs/components/utility/separator/separator.js +14 -0
- package/dist/cjs/components/utility/skeleton/skeleton.js +13 -0
- package/dist/cjs/components/utility/status-controller/status-controller.js +12 -0
- package/dist/cjs/hooks/use-mobile.js +21 -0
- package/dist/cjs/hooks/useControlled.js +19 -0
- package/dist/cjs/hooks/useFirstMountState.js +16 -0
- package/dist/cjs/hooks/useForkRef.js +23 -0
- package/dist/cjs/hooks/useLatest.js +12 -0
- package/dist/cjs/hooks/usePrevious.js +14 -0
- package/dist/cjs/hooks/useScrollState.js +39 -0
- package/dist/cjs/hooks/useStateRef.js +12 -0
- package/dist/cjs/hooks/useUpdateEffect.js +17 -0
- package/dist/cjs/index.js +237 -0
- package/dist/cjs/lib/utils.js +16 -0
- package/dist/cjs/styles/responsive.js +84 -0
- package/dist/cjs/styles/typography.js +25 -0
- package/dist/cjs/utils/addIf.js +5 -0
- package/dist/cjs/utils/chain.js +30 -0
- package/dist/cjs/utils/getBoundingRect.js +19 -0
- package/dist/cjs/utils/mergeProps.js +42 -0
- package/dist/cjs/utils/mergeRefs.js +18 -0
- package/dist/cjs/utils/toggle.js +16 -0
- package/dist/esm/components/buttons/button/button.js +40 -0
- package/dist/esm/components/buttons/icon-button/icon-button.js +31 -0
- package/dist/esm/components/buttons/toggle/toggle.js +31 -0
- package/dist/esm/components/buttons/toggle-group/toggle-group.js +28 -0
- package/dist/esm/components/forms/checkbox/checkbox.js +50 -0
- package/dist/esm/components/forms/input/input.js +36 -0
- package/dist/esm/components/forms/label/label.js +36 -0
- package/dist/esm/components/forms/radio/radio.js +19 -0
- package/dist/esm/components/forms/select/select.js +61 -0
- package/dist/esm/components/forms/switch/switch.js +49 -0
- package/dist/esm/components/forms/textarea/textarea.js +35 -0
- package/dist/esm/components/layout/box/box.js +17 -0
- package/dist/esm/components/layout/flex/flex.js +12 -0
- package/dist/esm/components/layout/grid/grid.js +12 -0
- package/dist/esm/components/media/aspect-ratio/aspect-ratio.js +10 -0
- package/dist/esm/components/media/avatar/avatar.js +23 -0
- package/dist/esm/components/media/icon/icon.js +25 -0
- package/dist/esm/components/popovers/dialog/dialog.js +60 -0
- package/dist/esm/components/popovers/drawer/drawer.js +74 -0
- package/dist/esm/components/popovers/popover/popover.js +61 -0
- package/dist/esm/components/popovers/sheet/sheet.js +86 -0
- package/dist/esm/components/popovers/toast/toast.js +67 -0
- package/dist/esm/components/popovers/tooltip/tooltip.js +40 -0
- package/dist/esm/components/typography/heading/heading.js +53 -0
- package/dist/esm/components/typography/text/text.js +55 -0
- package/dist/esm/components/ui/alert/alert.js +30 -0
- package/dist/esm/components/ui/badge/badge.js +28 -0
- package/dist/esm/components/ui/button/button.js +40 -0
- package/dist/esm/components/ui/calendar/calendar.js +22 -0
- package/dist/esm/components/ui/command/command.js +73 -0
- package/dist/esm/components/ui/data-table/components/cell.js +22 -0
- package/dist/esm/components/ui/data-table/components/column-group.js +43 -0
- package/dist/esm/components/ui/data-table/components/table-body.js +45 -0
- package/dist/esm/components/ui/data-table/components/table-fallback.js +26 -0
- package/dist/esm/components/ui/data-table/components/table-head.js +54 -0
- package/dist/esm/components/ui/data-table/components/table-placeholder.js +16 -0
- package/dist/esm/components/ui/data-table/data-table.js +95 -0
- package/dist/esm/components/ui/data-table/hooks/contextHooks.js +60 -0
- package/dist/esm/components/ui/data-table/hooks/useStickyColumns.js +96 -0
- package/dist/esm/components/ui/data-table/utils.js +22 -0
- package/dist/esm/components/ui/date-picker/date-picker.js +13 -0
- package/dist/esm/components/ui/dropdown-menu/dropdown-menu.js +84 -0
- package/dist/esm/components/ui/icon/icon.js +25 -0
- package/dist/esm/components/ui/link/link.js +30 -0
- package/dist/esm/components/ui/pagination/pagination.js +43 -0
- package/dist/esm/components/ui/progress/progress.js +11 -0
- package/dist/esm/components/ui/sidebar/sidebar.js +306 -0
- package/dist/esm/components/ui/table/components/cell.js +28 -0
- package/dist/esm/components/ui/table/components/row.js +23 -0
- package/dist/esm/components/ui/table/components/table-body.js +11 -0
- package/dist/esm/components/ui/table/components/table-caption.js +11 -0
- package/dist/esm/components/ui/table/components/table-footer.js +11 -0
- package/dist/esm/components/ui/table/components/table-head.js +28 -0
- package/dist/esm/components/ui/table/components/table-header.js +11 -0
- package/dist/esm/components/ui/table/table.js +26 -0
- package/dist/esm/components/ui/tabs/tabs.js +23 -0
- package/dist/esm/components/utility/empty-state/empty-state.js +27 -0
- package/dist/esm/components/utility/separator/separator.js +12 -0
- package/dist/esm/components/utility/skeleton/skeleton.js +11 -0
- package/dist/esm/components/utility/status-controller/status-controller.js +10 -0
- package/dist/esm/hooks/use-mobile.js +19 -0
- package/dist/esm/hooks/useControlled.js +17 -0
- package/dist/esm/hooks/useFirstMountState.js +14 -0
- package/dist/esm/hooks/useForkRef.js +21 -0
- package/dist/esm/hooks/useLatest.js +10 -0
- package/dist/esm/hooks/usePrevious.js +12 -0
- package/dist/esm/hooks/useScrollState.js +37 -0
- package/dist/esm/hooks/useStateRef.js +10 -0
- package/dist/esm/hooks/useUpdateEffect.js +15 -0
- package/dist/esm/index.js +63 -0
- package/dist/esm/lib/utils.js +13 -0
- package/dist/esm/styles/responsive.js +81 -0
- package/dist/esm/styles/typography.js +21 -0
- package/dist/esm/utils/addIf.js +3 -0
- package/dist/esm/utils/chain.js +28 -0
- package/dist/esm/utils/getBoundingRect.js +16 -0
- package/dist/esm/utils/mergeProps.js +40 -0
- package/dist/esm/utils/mergeRefs.js +15 -0
- package/dist/esm/utils/toggle.js +14 -0
- package/dist/styles.css +1 -0
- package/dist/types/index.d.ts +1418 -0
- package/package.json +114 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { cn } from '../../../lib/utils.js';
|
|
4
|
+
|
|
5
|
+
const Skeleton = (_a) => {
|
|
6
|
+
var { className } = _a, props = __rest(_a, ["className"]);
|
|
7
|
+
return jsx("div", Object.assign({ "data-slot": "skeleton", className: cn("bg-accent animate-pulse rounded-md", className) }, props));
|
|
8
|
+
};
|
|
9
|
+
Skeleton.displayName = "Skeleton";
|
|
10
|
+
|
|
11
|
+
export { Skeleton };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Fragment } from 'react';
|
|
3
|
+
|
|
4
|
+
const Show = ({ when, fallback, children }) => when ? children : jsx(Fragment, { children: fallback });
|
|
5
|
+
const StatusController = ({ loading = false, error = false, empty = false, loadingFallback, errorFallback, emptyFallback, children, }) => {
|
|
6
|
+
return (jsxs(Fragment, { children: [jsx(Show, { when: loading, children: loadingFallback }), jsx(Show, { when: !loading && error, children: errorFallback }), jsx(Show, { when: !loading && !error && empty, children: emptyFallback }), jsx(Show, { when: !loading && !error && !empty, children: children })] }));
|
|
7
|
+
};
|
|
8
|
+
StatusController.displayName = "StatusController";
|
|
9
|
+
|
|
10
|
+
export { StatusController };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
const MOBILE_BREAKPOINT = 768;
|
|
5
|
+
function useIsMobile() {
|
|
6
|
+
const [isMobile, setIsMobile] = useState(undefined);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
9
|
+
const onChange = () => {
|
|
10
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
11
|
+
};
|
|
12
|
+
mql.addEventListener("change", onChange);
|
|
13
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
14
|
+
return () => mql.removeEventListener("change", onChange);
|
|
15
|
+
}, []);
|
|
16
|
+
return !!isMobile;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { useIsMobile };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useRef, useState, useCallback } from 'react';
|
|
3
|
+
|
|
4
|
+
const useControlled = (controlledValue, defaultValue) => {
|
|
5
|
+
const controlledRef = useRef(false);
|
|
6
|
+
controlledRef.current = controlledValue !== undefined;
|
|
7
|
+
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
|
|
8
|
+
const value = (controlledRef.current ? controlledValue : uncontrolledValue);
|
|
9
|
+
const setValue = useCallback((nextValue) => {
|
|
10
|
+
if (!controlledRef.current) {
|
|
11
|
+
setUncontrolledValue(nextValue);
|
|
12
|
+
}
|
|
13
|
+
}, [controlledRef]);
|
|
14
|
+
return [value, setValue, controlledRef.current];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { useControlled };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
|
|
4
|
+
// Read more - https://github.com/streamich/react-use/blob/master/src/useFirstMountState.ts
|
|
5
|
+
const useFirstMountState = () => {
|
|
6
|
+
const isFirst = useRef(true);
|
|
7
|
+
if (isFirst.current) {
|
|
8
|
+
isFirst.current = false;
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
return isFirst.current;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { useFirstMountState };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import 'clsx';
|
|
4
|
+
import { assignRef } from '../utils/mergeRefs.js';
|
|
5
|
+
|
|
6
|
+
function useForkRef(...refs) {
|
|
7
|
+
return useMemo(() => {
|
|
8
|
+
if (refs.every((ref) => ref == null)) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
return (instance) => {
|
|
12
|
+
refs.forEach((ref) => {
|
|
13
|
+
if (ref) {
|
|
14
|
+
assignRef(ref, instance);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
}, [refs]);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { useForkRef };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState, useMemo, useLayoutEffect } from 'react';
|
|
3
|
+
import throttle from 'lodash/throttle';
|
|
4
|
+
|
|
5
|
+
const useScrollState = (containerRef) => {
|
|
6
|
+
const [isScrolledToLeftCorner, setLeftScrollCornerReached] = useState(true);
|
|
7
|
+
const [isScrolledToRightCorner, setRightScrollCornerReached] = useState(true);
|
|
8
|
+
const [isScrolledToTopCorner, setTopScrollCornerReached] = useState(true);
|
|
9
|
+
const [isScrolledToBottomCorner, setBottomScrollCornerReached] = useState(true);
|
|
10
|
+
const throttledUpdate = useMemo(() => throttle(() => {
|
|
11
|
+
if (!containerRef.current)
|
|
12
|
+
return;
|
|
13
|
+
const { scrollLeft, scrollTop, scrollWidth, scrollHeight, clientWidth, clientHeight } = containerRef.current;
|
|
14
|
+
setLeftScrollCornerReached(scrollLeft === 0);
|
|
15
|
+
setRightScrollCornerReached(scrollWidth - (scrollLeft + clientWidth) <= 1);
|
|
16
|
+
setTopScrollCornerReached(scrollTop === 0);
|
|
17
|
+
setBottomScrollCornerReached(scrollHeight - (scrollTop + clientHeight) <= 1);
|
|
18
|
+
}, 150, { trailing: true }), []);
|
|
19
|
+
useLayoutEffect(() => {
|
|
20
|
+
const container = containerRef.current;
|
|
21
|
+
if (!container)
|
|
22
|
+
return;
|
|
23
|
+
throttledUpdate();
|
|
24
|
+
container.addEventListener("scroll", throttledUpdate);
|
|
25
|
+
return () => {
|
|
26
|
+
container.removeEventListener("scroll", throttledUpdate);
|
|
27
|
+
};
|
|
28
|
+
}, [containerRef]);
|
|
29
|
+
return {
|
|
30
|
+
isScrolledToLeftCorner,
|
|
31
|
+
isScrolledToRightCorner,
|
|
32
|
+
isScrolledToTopCorner,
|
|
33
|
+
isScrolledToBottomCorner,
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { useScrollState };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState, useCallback } from 'react';
|
|
3
|
+
|
|
4
|
+
const useStateRef = (defaultValue) => {
|
|
5
|
+
const [node, setNode] = useState(defaultValue !== null && defaultValue !== void 0 ? defaultValue : null);
|
|
6
|
+
const setRef = useCallback((newNode) => setNode(newNode), []);
|
|
7
|
+
return [node, setRef];
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { useStateRef };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { useFirstMountState } from './useFirstMountState.js';
|
|
4
|
+
|
|
5
|
+
// Read more -> https://github.com/streamich/react-use/blob/master/src/useUpdateEffect.ts
|
|
6
|
+
const useUpdateEffect = (effect, deps) => {
|
|
7
|
+
const isFirstMount = useFirstMountState();
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (!isFirstMount) {
|
|
10
|
+
return effect();
|
|
11
|
+
}
|
|
12
|
+
}, deps);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { useUpdateEffect };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export { Box } from './components/layout/box/box.js';
|
|
2
|
+
export { Flex } from './components/layout/flex/flex.js';
|
|
3
|
+
export { Grid } from './components/layout/grid/grid.js';
|
|
4
|
+
export { Button, buttonVariants } from './components/buttons/button/button.js';
|
|
5
|
+
export { IconButton } from './components/buttons/icon-button/icon-button.js';
|
|
6
|
+
export { Toggle, toggleVariants } from './components/buttons/toggle/toggle.js';
|
|
7
|
+
export { ToggleGroup, ToggleGroupItem } from './components/buttons/toggle-group/toggle-group.js';
|
|
8
|
+
export { Checkbox } from './components/forms/checkbox/checkbox.js';
|
|
9
|
+
export { Input } from './components/forms/input/input.js';
|
|
10
|
+
export { Label } from './components/forms/label/label.js';
|
|
11
|
+
export { RadioGroup, RadioGroupItem } from './components/forms/radio/radio.js';
|
|
12
|
+
export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue } from './components/forms/select/select.js';
|
|
13
|
+
export { Switch } from './components/forms/switch/switch.js';
|
|
14
|
+
export { Textarea } from './components/forms/textarea/textarea.js';
|
|
15
|
+
export { Icon } from './components/media/icon/icon.js';
|
|
16
|
+
export { Avatar, AvatarFallback, AvatarImage } from './components/media/avatar/avatar.js';
|
|
17
|
+
export { AspectRatio } from './components/media/aspect-ratio/aspect-ratio.js';
|
|
18
|
+
export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from './components/popovers/dialog/dialog.js';
|
|
19
|
+
export { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle } from './components/popovers/drawer/drawer.js';
|
|
20
|
+
export { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from './components/popovers/popover/popover.js';
|
|
21
|
+
export { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle } from './components/popovers/sheet/sheet.js';
|
|
22
|
+
export { Toast, ToastAction, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport } from './components/popovers/toast/toast.js';
|
|
23
|
+
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from './components/popovers/tooltip/tooltip.js';
|
|
24
|
+
export { Heading } from './components/typography/heading/heading.js';
|
|
25
|
+
export { Text } from './components/typography/text/text.js';
|
|
26
|
+
export { Alert, AlertDescription, AlertTitle } from './components/ui/alert/alert.js';
|
|
27
|
+
export { Badge, badgeVariants } from './components/ui/badge/badge.js';
|
|
28
|
+
export { Calendar } from './components/ui/calendar/calendar.js';
|
|
29
|
+
export { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut } from './components/ui/command/command.js';
|
|
30
|
+
export { DataTable } from './components/ui/data-table/data-table.js';
|
|
31
|
+
export { DatePicker } from './components/ui/date-picker/date-picker.js';
|
|
32
|
+
export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger } from './components/ui/dropdown-menu/dropdown-menu.js';
|
|
33
|
+
export { Link } from './components/ui/link/link.js';
|
|
34
|
+
export { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from './components/ui/pagination/pagination.js';
|
|
35
|
+
export { Progress } from './components/ui/progress/progress.js';
|
|
36
|
+
export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar } from './components/ui/sidebar/sidebar.js';
|
|
37
|
+
export { Table, TableContainer } from './components/ui/table/table.js';
|
|
38
|
+
export { Tabs, TabsContent, TabsList, TabsTrigger } from './components/ui/tabs/tabs.js';
|
|
39
|
+
export { EmptyState } from './components/utility/empty-state/empty-state.js';
|
|
40
|
+
export { Separator } from './components/utility/separator/separator.js';
|
|
41
|
+
export { Skeleton } from './components/utility/skeleton/skeleton.js';
|
|
42
|
+
export { StatusController } from './components/utility/status-controller/status-controller.js';
|
|
43
|
+
export { useFirstMountState } from './hooks/useFirstMountState.js';
|
|
44
|
+
export { useUpdateEffect } from './hooks/useUpdateEffect.js';
|
|
45
|
+
export { useForkRef } from './hooks/useForkRef.js';
|
|
46
|
+
export { useStateRef } from './hooks/useStateRef.js';
|
|
47
|
+
export { useControlled } from './hooks/useControlled.js';
|
|
48
|
+
export { usePrevious } from './hooks/usePrevious.js';
|
|
49
|
+
export { useLatest } from './hooks/useLatest.js';
|
|
50
|
+
export { useScrollState } from './hooks/useScrollState.js';
|
|
51
|
+
export { chain } from './utils/chain.js';
|
|
52
|
+
export { mergeProps } from './utils/mergeProps.js';
|
|
53
|
+
export { assignRef, mergeRefs } from './utils/mergeRefs.js';
|
|
54
|
+
export { toggle } from './utils/toggle.js';
|
|
55
|
+
export { addIf } from './utils/addIf.js';
|
|
56
|
+
export { DEFAULT_RECT, getBoundingRect } from './utils/getBoundingRect.js';
|
|
57
|
+
export { TableHeader } from './components/ui/table/components/table-header.js';
|
|
58
|
+
export { TableBody } from './components/ui/table/components/table-body.js';
|
|
59
|
+
export { TableFooter } from './components/ui/table/components/table-footer.js';
|
|
60
|
+
export { TableHead } from './components/ui/table/components/table-head.js';
|
|
61
|
+
export { TableRow } from './components/ui/table/components/row.js';
|
|
62
|
+
export { TableCell } from './components/ui/table/components/cell.js';
|
|
63
|
+
export { TableCaption } from './components/ui/table/components/table-caption.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import { twMerge } from 'tailwind-merge';
|
|
4
|
+
|
|
5
|
+
function cn(...inputs) {
|
|
6
|
+
return twMerge(clsx(inputs));
|
|
7
|
+
}
|
|
8
|
+
function forwardRefWithGeneric(render) {
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
return forwardRef(render);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { cn, forwardRefWithGeneric };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const responsiveProps = {
|
|
2
|
+
// Display
|
|
3
|
+
display: "",
|
|
4
|
+
// Position
|
|
5
|
+
position: "",
|
|
6
|
+
// Dimensions
|
|
7
|
+
width: "w",
|
|
8
|
+
minWidth: "min-w",
|
|
9
|
+
maxWidth: "max-w",
|
|
10
|
+
height: "h",
|
|
11
|
+
minHeight: "min-h",
|
|
12
|
+
maxHeight: "max-h",
|
|
13
|
+
// Padding
|
|
14
|
+
p: "p",
|
|
15
|
+
px: "px",
|
|
16
|
+
py: "py",
|
|
17
|
+
pt: "pt",
|
|
18
|
+
pr: "pr",
|
|
19
|
+
pb: "pb",
|
|
20
|
+
pl: "pl",
|
|
21
|
+
// Margin
|
|
22
|
+
m: "m",
|
|
23
|
+
mx: "mx",
|
|
24
|
+
my: "my",
|
|
25
|
+
mt: "mt",
|
|
26
|
+
mr: "mr",
|
|
27
|
+
mb: "mb",
|
|
28
|
+
ml: "ml",
|
|
29
|
+
// Gap
|
|
30
|
+
gap: "gap",
|
|
31
|
+
gapX: "gap-x",
|
|
32
|
+
gapY: "gap-y",
|
|
33
|
+
// Overflow
|
|
34
|
+
overflow: "overflow",
|
|
35
|
+
overflowX: "overflow-x",
|
|
36
|
+
overflowY: "overflow-y",
|
|
37
|
+
// Grid
|
|
38
|
+
columns: "grid-cols",
|
|
39
|
+
rows: "grid-rows",
|
|
40
|
+
flow: "grid-flow",
|
|
41
|
+
// Flex
|
|
42
|
+
direction: "flex",
|
|
43
|
+
wrap: "flex",
|
|
44
|
+
// Flex & Grid
|
|
45
|
+
items: "items",
|
|
46
|
+
justify: "justify",
|
|
47
|
+
};
|
|
48
|
+
function getResponsiveClass(props) {
|
|
49
|
+
const classes = [];
|
|
50
|
+
Object.entries(props).forEach(([prop, value]) => {
|
|
51
|
+
if (!value)
|
|
52
|
+
return;
|
|
53
|
+
if (!(prop in responsiveProps))
|
|
54
|
+
return;
|
|
55
|
+
const responsiveValue = typeof value === "object" ? value : { initial: value };
|
|
56
|
+
for (const [breakpoint, val] of Object.entries(responsiveValue)) {
|
|
57
|
+
if (!val)
|
|
58
|
+
continue;
|
|
59
|
+
const bpPrefix = breakpoint === "initial" ? "" : `${breakpoint}:`;
|
|
60
|
+
const prefix = responsiveProps[prop] ? `${responsiveProps[prop]}-` : "";
|
|
61
|
+
classes.push(`${bpPrefix}${prefix}${val}`);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return classes.join(" ");
|
|
65
|
+
}
|
|
66
|
+
function extractResponsiveProps(props) {
|
|
67
|
+
const classesProps = {};
|
|
68
|
+
const restProps = {};
|
|
69
|
+
for (const key in props) {
|
|
70
|
+
if (key in responsiveProps) {
|
|
71
|
+
classesProps[key] = props[key];
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
restProps[key] = props[key];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return { classesProps, restProps };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export { extractResponsiveProps, getResponsiveClass };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const fontWeights = {
|
|
2
|
+
light: "font-light",
|
|
3
|
+
regular: "font-normal",
|
|
4
|
+
medium: "font-medium",
|
|
5
|
+
bold: "font-bold",
|
|
6
|
+
};
|
|
7
|
+
const textColors = {
|
|
8
|
+
default: "text-foreground",
|
|
9
|
+
muted: "text-muted-foreground",
|
|
10
|
+
primary: "text-primary",
|
|
11
|
+
secondary: "text-secondary",
|
|
12
|
+
accent: "text-accent",
|
|
13
|
+
destructive: "text-destructive",
|
|
14
|
+
};
|
|
15
|
+
const textAlignment = {
|
|
16
|
+
left: "text-left",
|
|
17
|
+
center: "text-center",
|
|
18
|
+
right: "text-right",
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { fontWeights, textAlignment, textColors };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates function that execute callback functions together so that they are invoked in sequence
|
|
3
|
+
* with the same set of arguments.
|
|
4
|
+
*
|
|
5
|
+
* @param {...Function} callbacks - A series of callback functions to chain together.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* const sum = (a, b) => console.log(`${a} + ${b} = ${a + b}`);
|
|
9
|
+
* const multiply = (a, b) => console.log(`${a} * ${b} = ${a * b}`);
|
|
10
|
+
* const log = (...args) => console.log(`I received following arguments: ${args.join(', ')}`);
|
|
11
|
+
*
|
|
12
|
+
* const chained = chain(sum, multiply, log);
|
|
13
|
+
* chained(1, 2); // Logs:
|
|
14
|
+
* // "1 + 2 = 3"
|
|
15
|
+
* // "1 * 2 = 2"
|
|
16
|
+
* // "I received following arguments: 1, 2"
|
|
17
|
+
*/
|
|
18
|
+
function chain(...callbacks) {
|
|
19
|
+
return (...args) => {
|
|
20
|
+
for (const callback of callbacks) {
|
|
21
|
+
if (typeof callback === "function") {
|
|
22
|
+
callback(...args);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { chain };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const DEFAULT_RECT = {
|
|
2
|
+
x: 0,
|
|
3
|
+
y: 0,
|
|
4
|
+
width: 0,
|
|
5
|
+
height: 0,
|
|
6
|
+
top: 0,
|
|
7
|
+
right: 0,
|
|
8
|
+
bottom: 0,
|
|
9
|
+
left: 0,
|
|
10
|
+
};
|
|
11
|
+
const getBoundingRect = (node) => {
|
|
12
|
+
const rect = node && node.getBoundingClientRect ? node.getBoundingClientRect() : DEFAULT_RECT;
|
|
13
|
+
return rect;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { DEFAULT_RECT, getBoundingRect };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
|
+
import { chain } from './chain.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Merges multiple props objects together. Event handlers are chained,
|
|
6
|
+
* classNames are combined, all other props, the last prop object overrides all previous ones.
|
|
7
|
+
* @param args - Multiple sets of props to merge together.
|
|
8
|
+
*/
|
|
9
|
+
function mergeProps(...args) {
|
|
10
|
+
// Start with a base clone of the first argument. This is a lot faster than starting
|
|
11
|
+
// with an empty object and adding properties as we go.
|
|
12
|
+
const result = Object.assign({}, args[0]);
|
|
13
|
+
for (let i = 1; i < args.length; i++) {
|
|
14
|
+
const props = args[i];
|
|
15
|
+
for (const key in props) {
|
|
16
|
+
const a = result[key];
|
|
17
|
+
const b = props[key];
|
|
18
|
+
// Chain events
|
|
19
|
+
if (typeof a === "function" &&
|
|
20
|
+
typeof b === "function" &&
|
|
21
|
+
// This is a lot faster than a regex.
|
|
22
|
+
key[0] === "o" &&
|
|
23
|
+
key[1] === "n" &&
|
|
24
|
+
key.charCodeAt(2) >= /* 'A' */ 65 &&
|
|
25
|
+
key.charCodeAt(2) <= /* 'Z' */ 90) {
|
|
26
|
+
result[key] = chain(a, b);
|
|
27
|
+
// Merge classnames, sometimes classNames are empty string which eval to false, so we just need to do a type check
|
|
28
|
+
}
|
|
29
|
+
else if ((key === "className" || key === "UNSAFE_className") && typeof a === "string" && typeof b === "string") {
|
|
30
|
+
result[key] = clsx(a, b);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
result[key] = b !== undefined ? b : a;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { mergeProps };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function assignRef(ref, value) {
|
|
2
|
+
if (typeof ref === "function") {
|
|
3
|
+
ref(value);
|
|
4
|
+
}
|
|
5
|
+
else if (ref) {
|
|
6
|
+
ref.current = value;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function mergeRefs(...refs) {
|
|
10
|
+
return (value) => {
|
|
11
|
+
refs.forEach((ref) => assignRef(ref, value));
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { assignRef, mergeRefs };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const removeAtIndex = (arr, index) => {
|
|
2
|
+
const copy = [...arr];
|
|
3
|
+
copy.splice(index, 1);
|
|
4
|
+
return copy;
|
|
5
|
+
};
|
|
6
|
+
const toggle = (arr, item, getValue = (item) => item) => {
|
|
7
|
+
const index = arr.findIndex((i) => getValue(i) === getValue(item));
|
|
8
|
+
if (index === -1)
|
|
9
|
+
return [...arr, item];
|
|
10
|
+
else
|
|
11
|
+
return removeAtIndex(arr, index);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { toggle };
|