@schandlergarcia/sf-web-components 1.2.13 → 1.2.14

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.
@@ -32,14 +32,13 @@ export function Popover({ children, open, onOpenChange, ...props }: {
32
32
  open: any;
33
33
  onOpenChange: any;
34
34
  }): import("react/jsx-runtime").JSX.Element;
35
- export function PopoverTrigger({ children, open, onOpenChange, ...props }: {
35
+ export function PopoverTrigger({ children, open, onOpenChange, asChild, ...props }: {
36
36
  [x: string]: any;
37
37
  children: any;
38
38
  open: any;
39
39
  onOpenChange: any;
40
- }): React.DetailedReactHTMLElement<{
41
- onClick: () => any;
42
- }, HTMLElement>;
40
+ asChild: any;
41
+ }): import("react/jsx-runtime").JSX.Element;
43
42
  export function PopoverContent({ children, open, className, align, sideOffset, ...props }: {
44
43
  [x: string]: any;
45
44
  children: any;
@@ -48,4 +47,3 @@ export function PopoverContent({ children, open, className, align, sideOffset, .
48
47
  align?: string | undefined;
49
48
  sideOffset?: number | undefined;
50
49
  }): import("react/jsx-runtime").JSX.Element | null;
51
- import React from "react";
@@ -1,20 +1,20 @@
1
1
  import { jsx as c } from "react/jsx-runtime";
2
- import l from "react";
3
- function p({ children: n, open: e, onOpenChange: r, ...o }) {
4
- const [s, i] = l.useState(!1), a = e !== void 0, d = a ? e : s, m = (t) => {
5
- a || i(t), r?.(t);
2
+ import a from "react";
3
+ function m({ children: e, open: t, onOpenChange: l, ...s }) {
4
+ const [n, r] = a.useState(!1), i = t !== void 0, d = i ? t : n, u = (o) => {
5
+ i || r(o), l?.(o);
6
6
  };
7
- return /* @__PURE__ */ c("div", { className: "relative inline-block", ...o, children: l.Children.map(n, (t) => l.isValidElement(t) ? l.cloneElement(t, { open: d, onOpenChange: m }) : t) });
7
+ return /* @__PURE__ */ c("div", { className: "relative inline-block", ...s, children: a.Children.map(e, (o) => a.isValidElement(o) ? a.cloneElement(o, { open: d, onOpenChange: u }) : o) });
8
8
  }
9
- const g = p, v = ({ children: n, open: e, onOpenChange: r, ...o }) => {
10
- const s = () => r?.(!e);
11
- return l.cloneElement(n, {
12
- ...o,
13
- onClick: s
14
- });
15
- }, C = ({ children: n, open: e, className: r = "", align: o = "center", sideOffset: s = 4, ...i }) => {
16
- if (!e) return null;
17
- const a = {
9
+ const b = m, C = ({ children: e, open: t, onOpenChange: l, asChild: s, ...n }) => {
10
+ const r = () => l?.(!t);
11
+ return s && a.isValidElement(e) ? a.cloneElement(e, {
12
+ ...n,
13
+ onClick: r
14
+ }) : /* @__PURE__ */ c("button", { type: "button", onClick: r, ...n, children: e });
15
+ }, g = ({ children: e, open: t, className: l = "", align: s = "center", sideOffset: n = 4, ...r }) => {
16
+ if (!t) return null;
17
+ const i = {
18
18
  start: "left-0",
19
19
  center: "left-1/2 -translate-x-1/2",
20
20
  end: "right-0"
@@ -22,16 +22,16 @@ const g = p, v = ({ children: n, open: e, onOpenChange: r, ...o }) => {
22
22
  return /* @__PURE__ */ c(
23
23
  "div",
24
24
  {
25
- className: `absolute z-50 mt-${s} w-72 rounded-md border border-slate-200 bg-white p-4 text-slate-900 shadow-md dark:border-slate-800 dark:bg-slate-900 dark:text-slate-50 ${a[o] || a.center} ${r}`,
26
- ...i,
27
- children: n
25
+ className: `absolute z-50 mt-${n} w-72 rounded-md border border-slate-200 bg-white p-4 text-slate-900 shadow-md dark:border-slate-800 dark:bg-slate-900 dark:text-slate-50 ${i[s] || i.center} ${l}`,
26
+ ...r,
27
+ children: e
28
28
  }
29
29
  );
30
30
  };
31
31
  export {
32
- g as Popover,
33
- C as PopoverContent,
34
- v as PopoverTrigger,
35
- p as default
32
+ b as Popover,
33
+ g as PopoverContent,
34
+ C as PopoverTrigger,
35
+ m as default
36
36
  };
37
37
  //# sourceMappingURL=Popover.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Popover.js","sources":["../../../../src/components/library/heroui/Popover.jsx"],"sourcesContent":["import React from \"react\";\n\n/**\n * HeroUI v3 Popover — simple popover for shadcn compatibility.\n * Using native HTML/CSS since HeroUI v3 doesn't have a Popover component.\n *\n * @example\n * import { Popover, PopoverTrigger, PopoverContent } from \"@/components/library\";\n * <Popover>\n * <PopoverTrigger>Open</PopoverTrigger>\n * <PopoverContent>Content</PopoverContent>\n * </Popover>\n */\nexport default function HeroUIPopover({ children, open, onOpenChange, ...props }) {\n const [isOpen, setIsOpen] = React.useState(false);\n const isControlled = open !== undefined;\n const actualOpen = isControlled ? open : isOpen;\n\n const handleOpenChange = (newOpen) => {\n if (!isControlled) setIsOpen(newOpen);\n onOpenChange?.(newOpen);\n };\n\n return (\n <div className=\"relative inline-block\" {...props}>\n {React.Children.map(children, (child) => {\n if (React.isValidElement(child)) {\n return React.cloneElement(child, { open: actualOpen, onOpenChange: handleOpenChange });\n }\n return child;\n })}\n </div>\n );\n}\n\nexport const Popover = HeroUIPopover;\n\nexport const PopoverTrigger = ({ children, open, onOpenChange, ...props }) => {\n const handleClick = () => onOpenChange?.(!open);\n\n return React.cloneElement(children, {\n ...props,\n onClick: handleClick,\n });\n};\n\nexport const PopoverContent = ({ children, open, className = \"\", align = \"center\", sideOffset = 4, ...props }) => {\n if (!open) return null;\n\n const alignClasses = {\n start: \"left-0\",\n center: \"left-1/2 -translate-x-1/2\",\n end: \"right-0\"\n };\n\n return (\n <div\n className={`absolute z-50 mt-${sideOffset} w-72 rounded-md border border-slate-200 bg-white p-4 text-slate-900 shadow-md dark:border-slate-800 dark:bg-slate-900 dark:text-slate-50 ${alignClasses[align] || alignClasses.center} ${className}`}\n {...props}\n >\n {children}\n </div>\n );\n};\n"],"names":["HeroUIPopover","children","open","onOpenChange","props","isOpen","setIsOpen","React","isControlled","actualOpen","handleOpenChange","newOpen","jsx","child","Popover","PopoverTrigger","handleClick","PopoverContent","className","align","sideOffset","alignClasses"],"mappings":";;AAaA,SAAwBA,EAAc,EAAE,UAAAC,GAAU,MAAAC,GAAM,cAAAC,GAAc,GAAGC,KAAS;AAChF,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAM,SAAS,EAAK,GAC1CC,IAAeN,MAAS,QACxBO,IAAaD,IAAeN,IAAOG,GAEnCK,IAAmB,CAACC,MAAY;AACpC,IAAKH,KAAcF,EAAUK,CAAO,GACpCR,IAAeQ,CAAO;AAAA,EACxB;AAEA,SACE,gBAAAC,EAAC,OAAA,EAAI,WAAU,yBAAyB,GAAGR,GACxC,UAAAG,EAAM,SAAS,IAAIN,GAAU,CAACY,MACzBN,EAAM,eAAeM,CAAK,IACrBN,EAAM,aAAaM,GAAO,EAAE,MAAMJ,GAAY,cAAcC,GAAkB,IAEhFG,CACR,EAAA,CACH;AAEJ;AAEO,MAAMC,IAAUd,GAEVe,IAAiB,CAAC,EAAE,UAAAd,GAAU,MAAAC,GAAM,cAAAC,GAAc,GAAGC,QAAY;AAC5E,QAAMY,IAAc,MAAMb,IAAe,CAACD,CAAI;AAE9C,SAAOK,EAAM,aAAaN,GAAU;AAAA,IAClC,GAAGG;AAAA,IACH,SAASY;AAAA,EAAA,CACV;AACH,GAEaC,IAAiB,CAAC,EAAE,UAAAhB,GAAU,MAAAC,GAAM,WAAAgB,IAAY,IAAI,OAAAC,IAAQ,UAAU,YAAAC,IAAa,GAAG,GAAGhB,QAAY;AAChH,MAAI,CAACF,EAAM,QAAO;AAElB,QAAMmB,IAAe;AAAA,IACnB,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,KAAK;AAAA,EAAA;AAGP,SACE,gBAAAT;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW,oBAAoBQ,CAAU,6IAA6IC,EAAaF,CAAK,KAAKE,EAAa,MAAM,IAAIH,CAAS;AAAA,MAC5O,GAAGd;AAAA,MAEH,UAAAH;AAAA,IAAA;AAAA,EAAA;AAGP;"}
1
+ {"version":3,"file":"Popover.js","sources":["../../../../src/components/library/heroui/Popover.jsx"],"sourcesContent":["import React from \"react\";\n\n/**\n * HeroUI v3 Popover — simple popover for shadcn compatibility.\n * Using native HTML/CSS since HeroUI v3 doesn't have a Popover component.\n *\n * @example\n * import { Popover, PopoverTrigger, PopoverContent } from \"@/components/library\";\n * <Popover>\n * <PopoverTrigger>Open</PopoverTrigger>\n * <PopoverContent>Content</PopoverContent>\n * </Popover>\n */\nexport default function HeroUIPopover({ children, open, onOpenChange, ...props }) {\n const [isOpen, setIsOpen] = React.useState(false);\n const isControlled = open !== undefined;\n const actualOpen = isControlled ? open : isOpen;\n\n const handleOpenChange = (newOpen) => {\n if (!isControlled) setIsOpen(newOpen);\n onOpenChange?.(newOpen);\n };\n\n return (\n <div className=\"relative inline-block\" {...props}>\n {React.Children.map(children, (child) => {\n if (React.isValidElement(child)) {\n return React.cloneElement(child, { open: actualOpen, onOpenChange: handleOpenChange });\n }\n return child;\n })}\n </div>\n );\n}\n\nexport const Popover = HeroUIPopover;\n\nexport const PopoverTrigger = ({ children, open, onOpenChange, asChild, ...props }) => {\n const handleClick = () => onOpenChange?.(!open);\n\n // If asChild is true, clone the child element with the props\n if (asChild && React.isValidElement(children)) {\n return React.cloneElement(children, {\n ...props,\n onClick: handleClick,\n });\n }\n\n // Otherwise, wrap in a button\n return (\n <button type=\"button\" onClick={handleClick} {...props}>\n {children}\n </button>\n );\n};\n\nexport const PopoverContent = ({ children, open, className = \"\", align = \"center\", sideOffset = 4, ...props }) => {\n if (!open) return null;\n\n const alignClasses = {\n start: \"left-0\",\n center: \"left-1/2 -translate-x-1/2\",\n end: \"right-0\"\n };\n\n return (\n <div\n className={`absolute z-50 mt-${sideOffset} w-72 rounded-md border border-slate-200 bg-white p-4 text-slate-900 shadow-md dark:border-slate-800 dark:bg-slate-900 dark:text-slate-50 ${alignClasses[align] || alignClasses.center} ${className}`}\n {...props}\n >\n {children}\n </div>\n );\n};\n"],"names":["HeroUIPopover","children","open","onOpenChange","props","isOpen","setIsOpen","React","isControlled","actualOpen","handleOpenChange","newOpen","jsx","child","Popover","PopoverTrigger","asChild","handleClick","PopoverContent","className","align","sideOffset","alignClasses"],"mappings":";;AAaA,SAAwBA,EAA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,MAC5O,GAAGf;AAAA,MAEH,UAAAH;AAAA,IAAA;AAAA,EAAA;AAGP;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schandlergarcia/sf-web-components",
3
- "version": "1.2.13",
3
+ "version": "1.2.14",
4
4
  "description": "Reusable Salesforce web components library with Tailwind CSS v4 and shadcn/ui",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -35,13 +35,23 @@ export default function HeroUIPopover({ children, open, onOpenChange, ...props }
35
35
 
36
36
  export const Popover = HeroUIPopover;
37
37
 
38
- export const PopoverTrigger = ({ children, open, onOpenChange, ...props }) => {
38
+ export const PopoverTrigger = ({ children, open, onOpenChange, asChild, ...props }) => {
39
39
  const handleClick = () => onOpenChange?.(!open);
40
40
 
41
- return React.cloneElement(children, {
42
- ...props,
43
- onClick: handleClick,
44
- });
41
+ // If asChild is true, clone the child element with the props
42
+ if (asChild && React.isValidElement(children)) {
43
+ return React.cloneElement(children, {
44
+ ...props,
45
+ onClick: handleClick,
46
+ });
47
+ }
48
+
49
+ // Otherwise, wrap in a button
50
+ return (
51
+ <button type="button" onClick={handleClick} {...props}>
52
+ {children}
53
+ </button>
54
+ );
45
55
  };
46
56
 
47
57
  export const PopoverContent = ({ children, open, className = "", align = "center", sideOffset = 4, ...props }) => {