react-shadcn-kit 0.2.4 → 0.2.5

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.
Files changed (110) hide show
  1. package/dist/assets/global.css +1 -1
  2. package/dist/components/composites/ComponentSearch.d.ts +43 -0
  3. package/dist/components/composites/action-button.d.ts +16 -0
  4. package/dist/components/composites/sidebar-wrapper.d.ts +27 -0
  5. package/dist/components/composites/theme-toggle.d.ts +9 -0
  6. package/dist/components/composites/user-menu.d.ts +18 -0
  7. package/dist/components/data-table/data-table-column-header.d.ts +7 -0
  8. package/dist/components/data-table/data-table-faceted-filter.d.ts +15 -0
  9. package/dist/components/data-table/data-table-pagination.d.ts +6 -0
  10. package/dist/components/data-table/data-table-toolbar.d.ts +20 -0
  11. package/dist/components/data-table/data-table-view-options.d.ts +6 -0
  12. package/dist/components/data-table/data-table.d.ts +30 -0
  13. package/dist/components/kanban/KanbanBoard.d.ts +2 -0
  14. package/dist/components/kanban/KanbanCard.d.ts +9 -0
  15. package/dist/components/kanban/KanbanColumn.d.ts +10 -0
  16. package/dist/components/kanban/KanbanDialog.d.ts +12 -0
  17. package/dist/components/kanban/kanban-types.d.ts +17 -0
  18. package/dist/components/kanban/kanban.d.ts +45 -0
  19. package/dist/components/marketing/hero.d.ts +12 -0
  20. package/dist/components/marketing/social-proof.d.ts +10 -0
  21. package/dist/components/marketing/value-props.d.ts +14 -0
  22. package/dist/components/primitives/accordion.d.ts +7 -0
  23. package/dist/components/primitives/action-button.d.ts +10 -0
  24. package/dist/components/primitives/alert-dialog.d.ts +14 -0
  25. package/dist/components/primitives/alert.d.ts +9 -0
  26. package/dist/components/primitives/aspect-ratio.d.ts +3 -0
  27. package/dist/components/primitives/avatar.d.ts +6 -0
  28. package/dist/components/primitives/badge-variants.d.ts +3 -0
  29. package/dist/components/primitives/badge.d.ts +9 -0
  30. package/dist/components/primitives/breadcrumb.d.ts +11 -0
  31. package/dist/components/primitives/button-group-variants.d.ts +3 -0
  32. package/dist/components/primitives/button-group.d.ts +13 -0
  33. package/dist/components/primitives/button-variants.d.ts +4 -0
  34. package/dist/components/primitives/button.d.ts +9 -0
  35. package/dist/components/primitives/calendar.d.ts +8 -0
  36. package/dist/components/primitives/card.d.ts +9 -0
  37. package/dist/components/primitives/carousel.d.ts +19 -0
  38. package/dist/components/primitives/chart.d.ts +54 -0
  39. package/dist/components/primitives/checkbox.d.ts +4 -0
  40. package/dist/components/primitives/collapsible.d.ts +5 -0
  41. package/dist/components/primitives/command.d.ts +18 -0
  42. package/dist/components/primitives/context-menu.d.ts +25 -0
  43. package/dist/components/primitives/context-menu.js +3 -3
  44. package/dist/components/primitives/context-menu.js.map +1 -1
  45. package/dist/components/primitives/custom-button-variants.d.ts +5 -0
  46. package/dist/components/primitives/custom-button.d.ts +22 -0
  47. package/dist/components/primitives/dialog.d.ts +15 -0
  48. package/dist/components/primitives/drawer.d.ts +13 -0
  49. package/dist/components/primitives/dropdown-menu.d.ts +25 -0
  50. package/dist/components/primitives/dropdown-menu.js +1 -1
  51. package/dist/components/primitives/dropdown-menu.js.map +1 -1
  52. package/dist/components/primitives/empty.d.ts +11 -0
  53. package/dist/components/primitives/field.d.ts +24 -0
  54. package/dist/components/primitives/field.js +3 -3
  55. package/dist/components/primitives/field.js.map +1 -1
  56. package/dist/components/primitives/form-context.d.ts +23 -0
  57. package/dist/components/primitives/form.d.ts +11 -0
  58. package/dist/components/primitives/hover-card.d.ts +6 -0
  59. package/dist/components/primitives/input-group.d.ts +16 -0
  60. package/dist/components/primitives/input-otp.d.ts +11 -0
  61. package/dist/components/primitives/input.d.ts +3 -0
  62. package/dist/components/primitives/item.d.ts +23 -0
  63. package/dist/components/primitives/kbd.d.ts +3 -0
  64. package/dist/components/primitives/label.d.ts +4 -0
  65. package/dist/components/primitives/loading-swap.d.ts +8 -0
  66. package/dist/components/primitives/menubar.d.ts +26 -0
  67. package/dist/components/primitives/menubar.js +3 -3
  68. package/dist/components/primitives/menubar.js.map +1 -1
  69. package/dist/components/primitives/navigation-menu-variants.d.ts +1 -0
  70. package/dist/components/primitives/navigation-menu.d.ts +13 -0
  71. package/dist/components/primitives/pagination.d.ts +13 -0
  72. package/dist/components/primitives/popover.d.ts +7 -0
  73. package/dist/components/primitives/progress.d.ts +4 -0
  74. package/dist/components/primitives/radio-group.d.ts +5 -0
  75. package/dist/components/primitives/resizable.d.ts +8 -0
  76. package/dist/components/primitives/scroll-area.d.ts +5 -0
  77. package/dist/components/primitives/select.d.ts +15 -0
  78. package/dist/components/primitives/select.js +30 -30
  79. package/dist/components/primitives/select.js.map +1 -1
  80. package/dist/components/primitives/separator.d.ts +4 -0
  81. package/dist/components/primitives/sheet.d.ts +13 -0
  82. package/dist/components/primitives/sidebar-context.d.ts +12 -0
  83. package/dist/components/primitives/sidebar-variants.d.ts +4 -0
  84. package/dist/components/primitives/sidebar.d.ts +56 -0
  85. package/dist/components/primitives/skeleton.d.ts +2 -0
  86. package/dist/components/primitives/slider.d.ts +4 -0
  87. package/dist/components/primitives/sonner.d.ts +3 -0
  88. package/dist/components/primitives/spinner.d.ts +2 -0
  89. package/dist/components/primitives/switch.d.ts +4 -0
  90. package/dist/components/primitives/table.d.ts +10 -0
  91. package/dist/components/primitives/tabs.d.ts +7 -0
  92. package/dist/components/primitives/textarea.d.ts +3 -0
  93. package/dist/components/primitives/theme-provider.d.ts +3 -0
  94. package/dist/components/primitives/theme-toggle.d.ts +3 -0
  95. package/dist/components/primitives/toggle-group.d.ts +9 -0
  96. package/dist/components/primitives/toggle-variants.d.ts +4 -0
  97. package/dist/components/primitives/toggle.d.ts +9 -0
  98. package/dist/components/primitives/tooltip.d.ts +7 -0
  99. package/dist/hooks/use-aria-live.d.ts +22 -0
  100. package/dist/hooks/use-browser-cache-image.d.ts +4 -0
  101. package/dist/hooks/use-focus-visible.d.ts +15 -0
  102. package/dist/hooks/use-mobile.d.ts +1 -0
  103. package/dist/hooks/use-screen-reader-only.d.ts +14 -0
  104. package/dist/hooks/use-theme.d.ts +7 -0
  105. package/dist/index.d.ts +14 -145
  106. package/dist/lib/browser-image-cache.d.ts +1 -0
  107. package/dist/lib/utils-enhanced.d.ts +27 -0
  108. package/dist/lib/utils-enhanced.test.d.ts +1 -0
  109. package/dist/lib/utils.d.ts +2 -0
  110. package/package.json +1 -1
@@ -0,0 +1,22 @@
1
+ /**
2
+ * useAriaLive
3
+ *
4
+ * Provides a simple way to announce dynamic content to screen readers using an
5
+ * `aria-live` region. The hook returns a ref that should be attached to a hidden
6
+ * element and a function to update the live message.
7
+ *
8
+ * Example usage:
9
+ * ```tsx
10
+ * const { liveRef, announce } = useAriaLive();
11
+ * return (
12
+ * <>
13
+ * <div ref={liveRef} aria-live="polite" className="sr-only" />
14
+ * <button onClick={() => announce('Item added')}>Add</button>
15
+ * </>
16
+ * );
17
+ * ```
18
+ */
19
+ export declare function useAriaLive(): {
20
+ readonly liveRef: import('react').RefObject<HTMLDivElement | null>;
21
+ readonly announce: (message: string) => void;
22
+ };
@@ -0,0 +1,4 @@
1
+ export declare function useBrowserCachedImage(imageUrl: string, cacheName?: string): {
2
+ src: string | null;
3
+ loading: boolean;
4
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * useFocusVisible
3
+ *
4
+ * Detects when the user is navigating via keyboard (focus-visible) and provides a
5
+ * boolean flag that can be used to apply a visual focus style only for keyboard
6
+ * users. This mirrors the behavior of the `:focus-visible` CSS pseudo‑class but
7
+ * works in browsers that lack native support.
8
+ *
9
+ * Example usage:
10
+ * ```tsx
11
+ * const isFocusVisible = useFocusVisible();
12
+ * return <button className={isFocusVisible ? 'focus-visible' : ''}>Click</button>;
13
+ * ```
14
+ */
15
+ export declare function useFocusVisible(): boolean;
@@ -0,0 +1 @@
1
+ export declare function useIsMobile(): boolean;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * useScreenReaderOnly
3
+ *
4
+ * Provides a utility hook that returns a className string for visually hidden
5
+ * elements that are still accessible to screen readers. It mirrors the common
6
+ * `sr-only` utility from Tailwind but can be used without Tailwind.
7
+ *
8
+ * Example usage:
9
+ * ```tsx
10
+ * const srOnly = useScreenReaderOnly();
11
+ * return <span className={srOnly}>Only for screen readers</span>;
12
+ * ```
13
+ */
14
+ export declare function useScreenReaderOnly(): string;
@@ -0,0 +1,7 @@
1
+ export declare function useTheme(): {
2
+ theme: string | undefined;
3
+ setTheme: import('react').Dispatch<import('react').SetStateAction<string>>;
4
+ systemTheme: "light" | "dark" | undefined;
5
+ toggleTheme: () => void;
6
+ isDark: boolean;
7
+ };
package/dist/index.d.ts CHANGED
@@ -1,145 +1,14 @@
1
- import { ClassProp } from 'class-variance-authority/types';
2
- import { JSX } from 'react/jsx-runtime';
3
- import * as React_2 from 'react';
4
- import { VariantProps } from 'class-variance-authority';
5
-
6
- export declare const ActionButton: React_2.ForwardRefExoticComponent<ActionButtonProps & React_2.RefAttributes<HTMLButtonElement>>;
7
-
8
- export declare interface ActionButtonProps extends CustomButtonProps {
9
- action: () => Promise<{
10
- error: boolean;
11
- message?: string;
12
- }>;
13
- requireAreYouSure?: boolean;
14
- areYouSureTitle?: React_2.ReactNode;
15
- areYouSureDescription?: React_2.ReactNode;
16
- showSuccessToast?: boolean;
17
- showErrorToast?: boolean;
18
- }
19
-
20
- export declare function ComponentSearch({ placeholder, onSearch, onSelect, minQueryLength, debounceMs, className, showOnMobile, }: ComponentSearchProps): JSX.Element;
21
-
22
- declare interface ComponentSearchProps {
23
- /**
24
- * Placeholder text for the search input
25
- * @default "Search components..."
26
- */
27
- placeholder?: string;
28
- /**
29
- * Async function to fetch search results based on query
30
- */
31
- onSearch?: (query: string) => Promise<SearchResult[]>;
32
- /**
33
- * Callback when a search result is selected
34
- */
35
- onSelect?: (result: SearchResult) => void;
36
- /**
37
- * Minimum characters required before triggering search
38
- * @default 2
39
- */
40
- minQueryLength?: number;
41
- /**
42
- * Debounce delay in milliseconds
43
- * @default 300
44
- */
45
- debounceMs?: number;
46
- /**
47
- * Custom className for the container
48
- */
49
- className?: string;
50
- /**
51
- * Whether to show the component on mobile
52
- * @default false
53
- */
54
- showOnMobile?: boolean;
55
- }
56
-
57
- declare interface CustomButtonProps extends React_2.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof customButtonVariants> {
58
- asChild?: boolean;
59
- loading?: boolean;
60
- loadingText?: string;
61
- loadingIcon?: React_2.ElementType;
62
- loadingIconPlacement?: "left" | "right";
63
- icon?: React_2.ElementType;
64
- iconPlacement?: "left" | "right";
65
- }
66
-
67
- declare const customButtonVariants: (props?: ({
68
- variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
69
- effect?: "none" | "expandIcon" | "ringHover" | "underline" | "hoverUnderline" | null | undefined;
70
- size?: "default" | "sm" | "lg" | "icon" | null | undefined;
71
- } & ClassProp) | undefined) => string;
72
-
73
- declare interface SearchResult {
74
- id: string;
75
- title: string;
76
- description?: string;
77
- icon?: React.ReactNode;
78
- href?: string;
79
- category?: string;
80
- }
81
-
82
- declare const Sidebar: React_2.ForwardRefExoticComponent<Omit<React_2.ClassAttributes<HTMLDivElement> & React_2.HTMLAttributes<HTMLDivElement> & {
83
- side?: "left" | "right";
84
- variant?: "sidebar" | "floating" | "inset";
85
- collapsible?: "offcanvas" | "icon" | "none";
86
- scrollable?: boolean;
87
- }, "ref"> & React_2.RefAttributes<HTMLDivElement>>;
88
-
89
- /**
90
- * SidebarWrapper
91
- *
92
- * A composable wrapper around the shadcn/ui `Sidebar` components tailored for the
93
- * `mcomposites` package. It provides a ready‑to‑use layout consisting of a
94
- * `SidebarProvider`, a `Sidebar` with optional custom trigger, and a content
95
- * area. The wrapper can be dropped into any page to instantly gain a fully
96
- * functional, accessible sidebar.
97
- *
98
- * Example usage:
99
- * ```tsx
100
- * <SidebarWrapper trigger={<MyTrigger />}>...</SidebarWrapper>
101
- * ```
102
- */
103
- export declare function SidebarWrapper({ trigger, children, className, ...sidebarProps }: SidebarWrapperProps): JSX.Element;
104
-
105
- export declare interface SidebarWrapperProps extends React_2.ComponentPropsWithoutRef<typeof Sidebar> {
106
- /**
107
- * Optional custom trigger component. If not provided, a default trigger button is rendered.
108
- */
109
- trigger?: React_2.ReactNode;
110
- /**
111
- * Children rendered inside the SidebarContent area.
112
- */
113
- children: React_2.ReactNode;
114
- }
115
-
116
- export declare function ThemeToggle({ align, side, sideOffset, className, trigger, }: ThemeToggleProps): JSX.Element;
117
-
118
- export declare interface ThemeToggleProps {
119
- align?: "center" | "start" | "end";
120
- side?: "top" | "right" | "bottom" | "left";
121
- sideOffset?: number;
122
- className?: string;
123
- trigger?: React_2.ReactNode;
124
- }
125
-
126
- export declare function UserMenu({ user, items, className }: UserMenuProps): JSX.Element;
127
-
128
- export declare interface UserMenuProps {
129
- user: {
130
- name: string;
131
- email: string;
132
- avatar?: string;
133
- };
134
- items?: Array<{
135
- label: string;
136
- href?: string;
137
- onClick?: () => void;
138
- icon?: React_2.ComponentType<{
139
- className?: string;
140
- }>;
141
- }>;
142
- className?: string;
143
- }
144
-
145
- export { }
1
+ export * from './components/primitives';
2
+ export * from './components/composites';
3
+ export * from './components/marketing';
4
+ export * from './components/data-table';
5
+ export * from './components/kanban';
6
+ export * from './hooks';
7
+ export * from './lib';
8
+ export type * from './components/primitives';
9
+ export type * from './components/composites';
10
+ export type * from './components/marketing';
11
+ export type * from './components/data-table';
12
+ export type * from './components/kanban';
13
+ export type * from './hooks';
14
+ export type * from './lib';
@@ -0,0 +1 @@
1
+ export declare function getCachedImage(cacheName: string, imageUrl: string): Promise<Blob>;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Format a date into a human-readable string.
3
+ * @example "Oct 24, 2023"
4
+ */
5
+ export declare function formatDate(date: Date | string | number): string;
6
+ /**
7
+ * Format a date into a long human-readable string with time.
8
+ * @example "October 24, 2023 at 10:00 AM"
9
+ */
10
+ export declare function formatDateTime(date: Date | string | number): string;
11
+ /**
12
+ * Format a date relative to now.
13
+ * @example "2 days ago"
14
+ */
15
+ export declare function formatRelative(date: Date | string | number): string;
16
+ /**
17
+ * Generate a URL-friendly slug from a string.
18
+ */
19
+ export declare function generateSlug(text: string): string;
20
+ /**
21
+ * Map database errors to user-friendly messages.
22
+ * Generic template for common DB constraints.
23
+ */
24
+ export declare function mapDatabaseError(error: unknown): {
25
+ error: true;
26
+ message: string;
27
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { ClassValue } from 'clsx';
2
+ export declare function cn(...inputs: ClassValue[]): string;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "react-shadcn-kit",
3
3
  "author": "Tushar Yadav",
4
4
  "private": false,
5
- "version": "0.2.4",
5
+ "version": "0.2.5",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.js",