@schandlergarcia/sf-web-components 1.6.0 → 1.7.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.
Files changed (49) hide show
  1. package/dist/components/library/heroui/Accordion.d.ts +6 -5
  2. package/dist/components/library/heroui/Accordion.js +7 -8
  3. package/dist/components/library/heroui/Accordion.js.map +1 -1
  4. package/dist/components/library/heroui/Breadcrumbs.d.ts +5 -2
  5. package/dist/components/library/heroui/Breadcrumbs.js +4 -5
  6. package/dist/components/library/heroui/Breadcrumbs.js.map +1 -1
  7. package/dist/components/library/heroui/Collapsible.d.ts +19 -30
  8. package/dist/components/library/heroui/Collapsible.js +13 -13
  9. package/dist/components/library/heroui/Collapsible.js.map +1 -1
  10. package/dist/components/library/heroui/DatePicker.d.ts +24 -52
  11. package/dist/components/library/heroui/DatePicker.js +5 -6
  12. package/dist/components/library/heroui/DatePicker.js.map +1 -1
  13. package/dist/components/library/heroui/Dialog.d.ts +18 -32
  14. package/dist/components/library/heroui/Dialog.js +6 -7
  15. package/dist/components/library/heroui/Dialog.js.map +1 -1
  16. package/dist/components/library/heroui/Drawer.d.ts +6 -2
  17. package/dist/components/library/heroui/Drawer.js +2 -3
  18. package/dist/components/library/heroui/Drawer.js.map +1 -1
  19. package/dist/components/library/heroui/Dropdown.d.ts +6 -2
  20. package/dist/components/library/heroui/Dropdown.js +2 -3
  21. package/dist/components/library/heroui/Dropdown.js.map +1 -1
  22. package/dist/components/library/heroui/Field.d.ts +19 -38
  23. package/dist/components/library/heroui/Field.js +9 -10
  24. package/dist/components/library/heroui/Field.js.map +1 -1
  25. package/dist/components/library/heroui/Meter.d.ts +7 -5
  26. package/dist/components/library/heroui/Meter.js +4 -5
  27. package/dist/components/library/heroui/Meter.js.map +1 -1
  28. package/dist/components/library/heroui/Popover.d.ts +23 -38
  29. package/dist/components/library/heroui/Popover.js +12 -12
  30. package/dist/components/library/heroui/Popover.js.map +1 -1
  31. package/dist/components/library/heroui/Select.d.ts +31 -37
  32. package/dist/components/library/heroui/Select.js +3 -4
  33. package/dist/components/library/heroui/Select.js.map +1 -1
  34. package/package.json +1 -1
  35. package/src/components/library/heroui/{Accordion.jsx → Accordion.tsx} +8 -3
  36. package/src/components/library/heroui/{Breadcrumbs.jsx → Breadcrumbs.tsx} +5 -2
  37. package/src/components/library/heroui/Collapsible.tsx +62 -0
  38. package/src/components/library/heroui/{DatePicker.jsx → DatePicker.tsx} +28 -4
  39. package/src/components/library/heroui/Dialog.tsx +43 -0
  40. package/src/components/library/heroui/{Drawer.jsx → Drawer.tsx} +6 -2
  41. package/src/components/library/heroui/{Dropdown.jsx → Dropdown.tsx} +6 -2
  42. package/src/components/library/heroui/{Field.jsx → Field.tsx} +23 -6
  43. package/src/components/library/heroui/Meter.tsx +13 -0
  44. package/src/components/library/heroui/{Popover.jsx → Popover.tsx} +29 -8
  45. package/src/components/library/heroui/Select.tsx +73 -0
  46. package/src/components/library/heroui/Collapsible.jsx +0 -42
  47. package/src/components/library/heroui/Dialog.jsx +0 -37
  48. package/src/components/library/heroui/Meter.jsx +0 -8
  49. package/src/components/library/heroui/Select.jsx +0 -37
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import * as React from "react";
2
2
 
3
3
  /**
4
4
  * HeroUI v3 Field components — simple wrappers for form field layout.
@@ -11,7 +11,11 @@ import React from "react";
11
11
  * <FieldError>Required</FieldError>
12
12
  * </Field>
13
13
  */
14
- export default function HeroUIField({ className = "", children, ...props }) {
14
+ export interface HeroUIFieldProps extends React.HTMLAttributes<HTMLDivElement> {
15
+ children?: React.ReactNode;
16
+ }
17
+
18
+ export default function HeroUIField({ className = "", children, ...props }: HeroUIFieldProps) {
15
19
  return (
16
20
  <div className={`flex flex-col gap-1.5 ${className}`} {...props}>
17
21
  {children}
@@ -21,7 +25,11 @@ export default function HeroUIField({ className = "", children, ...props }) {
21
25
 
22
26
  export const Field = HeroUIField;
23
27
 
24
- export const FieldLabel = ({ className = "", htmlFor, children, ...props }) => (
28
+ export interface FieldLabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {
29
+ children?: React.ReactNode;
30
+ }
31
+
32
+ export const FieldLabel = ({ className = "", htmlFor, children, ...props }: FieldLabelProps) => (
25
33
  <label
26
34
  htmlFor={htmlFor}
27
35
  className={`text-sm font-medium text-slate-700 dark:text-slate-200 ${className}`}
@@ -31,15 +39,24 @@ export const FieldLabel = ({ className = "", htmlFor, children, ...props }) => (
31
39
  </label>
32
40
  );
33
41
 
34
- export const FieldDescription = ({ className = "", children, ...props }) => (
42
+ export interface FieldDescriptionProps extends React.HTMLAttributes<HTMLParagraphElement> {
43
+ children?: React.ReactNode;
44
+ }
45
+
46
+ export const FieldDescription = ({ className = "", children, ...props }: FieldDescriptionProps) => (
35
47
  <p className={`text-xs text-slate-500 dark:text-slate-400 ${className}`} {...props}>
36
48
  {children}
37
49
  </p>
38
50
  );
39
51
 
40
- export const FieldError = ({ className = "", errors, children, ...props }) => {
52
+ export interface FieldErrorProps extends React.HTMLAttributes<HTMLParagraphElement> {
53
+ errors?: string[];
54
+ children?: React.ReactNode;
55
+ }
56
+
57
+ export const FieldError = ({ className = "", errors, children, ...props }: FieldErrorProps) => {
41
58
  // Support both children and errors prop
42
- const errorContent = errors?.length > 0 ? errors.join(", ") : children;
59
+ const errorContent = errors && errors.length > 0 ? errors.join(", ") : children;
43
60
 
44
61
  if (!errorContent) return null;
45
62
 
@@ -0,0 +1,13 @@
1
+ import * as React from "react";
2
+ import { Meter } from "@heroui/react";
3
+
4
+ export interface HeroUIMeterProps {
5
+ children?: React.ReactNode;
6
+ [key: string]: any;
7
+ }
8
+
9
+ export default function HeroUIMeter({ children, ...props }: HeroUIMeterProps) {
10
+ return <Meter {...props}>{children}</Meter>;
11
+ }
12
+
13
+ export { Meter };
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import * as React from "react";
2
2
 
3
3
  /**
4
4
  * HeroUI v3 Popover — simple popover for shadcn compatibility.
@@ -11,12 +11,18 @@ import React from "react";
11
11
  * <PopoverContent>Content</PopoverContent>
12
12
  * </Popover>
13
13
  */
14
- export default function HeroUIPopover({ children, open, onOpenChange, ...props }) {
14
+ export interface HeroUIPopoverProps extends React.HTMLAttributes<HTMLDivElement> {
15
+ children?: React.ReactNode;
16
+ open?: boolean;
17
+ onOpenChange?: (open: boolean) => void;
18
+ }
19
+
20
+ export default function HeroUIPopover({ children, open, onOpenChange, ...props }: HeroUIPopoverProps) {
15
21
  const [isOpen, setIsOpen] = React.useState(false);
16
22
  const isControlled = open !== undefined;
17
23
  const actualOpen = isControlled ? open : isOpen;
18
24
 
19
- const handleOpenChange = (newOpen) => {
25
+ const handleOpenChange = (newOpen: boolean) => {
20
26
  if (!isControlled) setIsOpen(newOpen);
21
27
  onOpenChange?.(newOpen);
22
28
  };
@@ -25,7 +31,7 @@ export default function HeroUIPopover({ children, open, onOpenChange, ...props }
25
31
  <div className="relative inline-block" {...props}>
26
32
  {React.Children.map(children, (child) => {
27
33
  if (React.isValidElement(child)) {
28
- return React.cloneElement(child, { open: actualOpen, onOpenChange: handleOpenChange });
34
+ return React.cloneElement(child, { open: actualOpen, onOpenChange: handleOpenChange } as any);
29
35
  }
30
36
  return child;
31
37
  })}
@@ -35,7 +41,15 @@ export default function HeroUIPopover({ children, open, onOpenChange, ...props }
35
41
 
36
42
  export const Popover = HeroUIPopover;
37
43
 
38
- export const PopoverTrigger = ({ children, open, onOpenChange, asChild, ...props }) => {
44
+ export interface PopoverTriggerProps {
45
+ children?: React.ReactNode;
46
+ open?: boolean;
47
+ onOpenChange?: (open: boolean) => void;
48
+ asChild?: boolean;
49
+ [key: string]: any;
50
+ }
51
+
52
+ export const PopoverTrigger = ({ children, open, onOpenChange, asChild, ...props }: PopoverTriggerProps) => {
39
53
  const handleClick = () => onOpenChange?.(!open);
40
54
 
41
55
  // If asChild is true, clone the child element with the props
@@ -43,7 +57,7 @@ export const PopoverTrigger = ({ children, open, onOpenChange, asChild, ...props
43
57
  return React.cloneElement(children, {
44
58
  ...props,
45
59
  onClick: handleClick,
46
- });
60
+ } as any);
47
61
  }
48
62
 
49
63
  // Otherwise, wrap in a button
@@ -54,10 +68,17 @@ export const PopoverTrigger = ({ children, open, onOpenChange, asChild, ...props
54
68
  );
55
69
  };
56
70
 
57
- export const PopoverContent = ({ children, open, className = "", align = "center", sideOffset = 4, ...props }) => {
71
+ export interface PopoverContentProps extends React.HTMLAttributes<HTMLDivElement> {
72
+ children?: React.ReactNode;
73
+ open?: boolean;
74
+ align?: "start" | "center" | "end";
75
+ sideOffset?: number;
76
+ }
77
+
78
+ export const PopoverContent = ({ children, open, className = "", align = "center", sideOffset = 4, ...props }: PopoverContentProps) => {
58
79
  if (!open) return null;
59
80
 
60
- const alignClasses = {
81
+ const alignClasses: Record<string, string> = {
61
82
  start: "left-0",
62
83
  center: "left-1/2 -translate-x-1/2",
63
84
  end: "right-0"
@@ -0,0 +1,73 @@
1
+ import * as React from "react";
2
+ import { Select as HeroSelect } from "@heroui/react";
3
+
4
+ /**
5
+ * HeroUI v3 Select wrapper with shadcn compatibility.
6
+ *
7
+ * Translates shadcn API to HeroUI:
8
+ * - onValueChange -> onSelectionChange
9
+ * - value -> selectedKeys
10
+ */
11
+ export interface HeroUISelectProps {
12
+ value?: string;
13
+ onValueChange?: (value: string) => void;
14
+ children?: React.ReactNode;
15
+ [key: string]: any;
16
+ }
17
+
18
+ export default function HeroUISelect({ value, onValueChange, children, ...props }: HeroUISelectProps) {
19
+ // Translate shadcn API to HeroUI API
20
+ const selectedKeys = value ? [value] : [];
21
+ const handleSelectionChange = (keys: any) => {
22
+ const selected = Array.from(keys)[0] as string;
23
+ onValueChange?.(selected || "");
24
+ };
25
+
26
+ const HeroSelectAny = HeroSelect as any;
27
+ return (
28
+ <HeroSelectAny
29
+ selectedKeys={selectedKeys}
30
+ onSelectionChange={handleSelectionChange}
31
+ {...props}
32
+ >
33
+ {children}
34
+ </HeroSelectAny>
35
+ );
36
+ }
37
+
38
+ // For direct HeroUI usage
39
+ export const Select = HeroUISelect;
40
+
41
+ // Shadcn-compatible subcomponents that just pass through children
42
+ export interface SelectTriggerProps {
43
+ children?: React.ReactNode;
44
+ size?: string;
45
+ [key: string]: any;
46
+ }
47
+
48
+ export const SelectTrigger = ({ children }: SelectTriggerProps) => <>{children}</>;
49
+
50
+ export interface SelectValueProps {
51
+ placeholder?: string;
52
+ [key: string]: any;
53
+ }
54
+
55
+ export const SelectValue = ({ placeholder }: SelectValueProps) => <span>{placeholder}</span>;
56
+
57
+ export interface SelectContentProps {
58
+ children?: React.ReactNode;
59
+ [key: string]: any;
60
+ }
61
+
62
+ export const SelectContent = ({ children }: SelectContentProps) => <>{children}</>;
63
+
64
+ export interface SelectItemProps {
65
+ value: string;
66
+ children?: React.ReactNode;
67
+ [key: string]: any;
68
+ }
69
+
70
+ export const SelectItem = ({ value, children, ...props }: SelectItemProps) => {
71
+ const HeroSelectAny = HeroSelect as any;
72
+ return <HeroSelectAny.Item key={value} {...props}>{children}</HeroSelectAny.Item>;
73
+ };
@@ -1,42 +0,0 @@
1
- import React from "react";
2
- import { Accordion } from "@heroui/react";
3
-
4
- /**
5
- * HeroUI v3 Collapsible — maps to Accordion for shadcn compatibility.
6
- *
7
- * @example
8
- * import { Collapsible, CollapsibleTrigger, CollapsibleContent } from "@/components/library";
9
- * <Collapsible open={isOpen} onOpenChange={setIsOpen}>
10
- * <CollapsibleTrigger>Toggle</CollapsibleTrigger>
11
- * <CollapsibleContent>Content</CollapsibleContent>
12
- * </Collapsible>
13
- */
14
- export default function HeroUICollapsible({ open, onOpenChange, children, ...props }) {
15
- // Map shadcn props to HeroUI Accordion
16
- const selectedKeys = open ? ["item"] : [];
17
-
18
- return (
19
- <Accordion
20
- selectedKeys={selectedKeys}
21
- onSelectionChange={(keys) => {
22
- const isOpen = Array.from(keys).includes("item");
23
- onOpenChange?.(isOpen);
24
- }}
25
- {...props}
26
- >
27
- <Accordion.Item key="item" aria-label="Collapsible content">
28
- {children}
29
- </Accordion.Item>
30
- </Accordion>
31
- );
32
- }
33
-
34
- export const Collapsible = HeroUICollapsible;
35
-
36
- export const CollapsibleTrigger = ({ children, ...props }) => (
37
- <Accordion.Trigger {...props}>{children}</Accordion.Trigger>
38
- );
39
-
40
- export const CollapsibleContent = ({ children, ...props }) => (
41
- <Accordion.Panel {...props}>{children}</Accordion.Panel>
42
- );
@@ -1,37 +0,0 @@
1
- import React from "react";
2
- import { Modal } from "@heroui/react";
3
-
4
- /**
5
- * HeroUI v3 Dialog — maps to Modal for shadcn compatibility.
6
- *
7
- * Sub-components via dot notation on the named `Modal` export:
8
- * Modal.Backdrop, Modal.Container, Modal.Dialog,
9
- * Modal.CloseTrigger, Modal.Header, Modal.Icon,
10
- * Modal.Heading, Modal.Body, Modal.Footer
11
- *
12
- * @example
13
- * import { Dialog, DialogTrigger, DialogContent } from "@/components/library";
14
- * <Dialog>
15
- * <DialogTrigger>Open</DialogTrigger>
16
- * <DialogContent>
17
- * <DialogHeader><DialogTitle>Title</DialogTitle></DialogHeader>
18
- * <DialogDescription>Content</DialogDescription>
19
- * <DialogFooter>Actions</DialogFooter>
20
- * </DialogContent>
21
- * </Dialog>
22
- */
23
- export default function HeroUIDialog(props) {
24
- return <Modal {...props} />;
25
- }
26
-
27
- // Shadcn-compatible exports
28
- export const Dialog = HeroUIDialog;
29
- export const DialogTrigger = Modal.Trigger || (props => <button {...props} />);
30
- export const DialogPortal = ({ children }) => <>{children}</>;
31
- export const DialogClose = Modal.CloseTrigger || (props => <button {...props} />);
32
- export const DialogOverlay = Modal.Backdrop || (props => <div {...props} />);
33
- export const DialogContent = Modal.Dialog || Modal.Container || (props => <div {...props} />);
34
- export const DialogHeader = Modal.Header || (props => <div {...props} />);
35
- export const DialogFooter = Modal.Footer || (props => <div {...props} />);
36
- export const DialogTitle = Modal.Heading || (props => <h2 {...props} />);
37
- export const DialogDescription = (props) => <p {...props} />;
@@ -1,8 +0,0 @@
1
- import React from "react";
2
- import { Meter } from "@heroui/react";
3
-
4
- export default function HeroUIMeter({ children, ...props }) {
5
- return <Meter {...props}>{children}</Meter>;
6
- }
7
-
8
- export { Meter };
@@ -1,37 +0,0 @@
1
- import React from "react";
2
- import { Select as HeroSelect } from "@heroui/react";
3
-
4
- /**
5
- * HeroUI v3 Select wrapper with shadcn compatibility.
6
- *
7
- * Translates shadcn API to HeroUI:
8
- * - onValueChange -> onSelectionChange
9
- * - value -> selectedKeys
10
- */
11
- export default function HeroUISelect({ value, onValueChange, children, ...props }) {
12
- // Translate shadcn API to HeroUI API
13
- const selectedKeys = value ? [value] : [];
14
- const handleSelectionChange = (keys) => {
15
- const selected = Array.from(keys)[0];
16
- onValueChange?.(selected || "");
17
- };
18
-
19
- return (
20
- <HeroSelect
21
- selectedKeys={selectedKeys}
22
- onSelectionChange={handleSelectionChange}
23
- {...props}
24
- >
25
- {children}
26
- </HeroSelect>
27
- );
28
- }
29
-
30
- // For direct HeroUI usage
31
- export const Select = HeroUISelect;
32
-
33
- // Shadcn-compatible subcomponents that just pass through children
34
- export const SelectTrigger = ({ children, size, ...props }) => <>{children}</>;
35
- export const SelectValue = ({ placeholder, ...props }) => <span {...props}>{placeholder}</span>;
36
- export const SelectContent = ({ children, ...props }) => <>{children}</>;
37
- export const SelectItem = ({ value, children, ...props }) => <HeroSelect.Item key={value} {...props}>{children}</HeroSelect.Item>;