@gv-tech/design-system 2.29.4 → 2.30.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/dist/field.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use client";"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./vendor-Ceu--gxM.js"),t=require("./label.cjs"),n=require("./separator.cjs");let r=require("react");var i=e.Ar();function a({className:t,...n}){return(0,i.jsx)(`fieldset`,{"data-slot":`field-set`,className:e.ei(`flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3`,t),...n})}function o({className:t,variant:n=`legend`,...r}){return(0,i.jsx)(`legend`,{"data-slot":`field-legend`,"data-variant":n,className:e.ei(`mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base`,t),...r})}function s({className:t,...n}){return(0,i.jsx)(`div`,{"data-slot":`field-group`,className:e.ei(`group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4`,t),...n})}var c=e.H(`group/field data-[invalid=true]:text-destructive flex w-full gap-2`,{variants:{orientation:{vertical:`flex-col *:w-full [&>.sr-only]:w-auto`,horizontal:`flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`,responsive:`flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`}},defaultVariants:{orientation:`vertical`}});function l({className:t,orientation:n=`vertical`,...r}){return(0,i.jsx)(`fieldset`,{"data-slot":`field`,"data-orientation":n,className:e.ei(c({orientation:n}),t),...r})}function u({className:t,...n}){return(0,i.jsx)(`div`,{"data-slot":`field-content`,className:e.ei(`group/field-content flex flex-1 flex-col gap-0.5 leading-snug`,t),...n})}function d({className:n,...r}){return(0,i.jsx)(t.Label,{"data-slot":`field-label`,className:e.ei(`group/field-label peer/field-label has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10 flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 *:data-[slot=field]:p-2.5`,`has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col`,n),...r})}function f({className:t,...n}){return(0,i.jsx)(`div`,{"data-slot":`field-label`,className:e.ei(`flex w-fit items-center gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50`,t),...n})}function p({className:t,...n}){return(0,i.jsx)(`p`,{"data-slot":`field-description`,className:e.ei(`text-muted-foreground text-start text-sm leading-normal font-normal group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5`,`last:mt-0 nth-last-2:-mt-1`,`[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4`,t),...n})}function m({children:t,className:r,...a}){return(0,i.jsxs)(`div`,{"data-slot":`field-separator`,"data-content":!!t,className:e.ei(`relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2`,r),...a,children:[(0,i.jsx)(n.Separator,{className:`absolute inset-0 top-1/2`}),t&&(0,i.jsx)(`span`,{className:`bg-background text-muted-foreground relative mx-auto block w-fit px-2`,"data-slot":`field-separator-content`,children:t})]})}function h({className:t,children:n,errors:a,...o}){let s=(0,r.useMemo)(()=>{if(n)return n;if(!a?.length)return null;let e=[...new Map(a.map(e=>[e?.message,e])).values()];return e?.length==1?e[0]?.message:(0,i.jsx)(`ul`,{className:`ms-4 flex list-disc flex-col gap-1`,children:e.map((e,t)=>e?.message&&(0,i.jsx)(`li`,{children:e.message},t))})},[n,a]);return s?(0,i.jsx)(`div`,{role:`alert`,"data-slot":`field-error`,className:e.ei(`text-destructive text-sm font-normal`,t),...o,children:s}):null}exports.Field=l,exports.FieldContent=u,exports.FieldDescription=p,exports.FieldError=h,exports.FieldGroup=s,exports.FieldLabel=d,exports.FieldLegend=o,exports.FieldSeparator=m,exports.FieldSet=a,exports.FieldTitle=f;
1
+ "use client";"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./vendor-Ceu--gxM.js"),t=require("./label.cjs"),n=require("./separator.cjs");let r=require("react");var i=e.Ar();function a({className:t,...n}){return(0,i.jsx)(`fieldset`,{"data-slot":`field-set`,className:e.ei(`flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3`,t),...n})}function o({className:t,variant:n=`legend`,...r}){return(0,i.jsx)(`legend`,{"data-slot":`field-legend`,"data-variant":n,className:e.ei(`mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base`,t),...r})}function s({className:t,...n}){return(0,i.jsx)(`div`,{"data-slot":`field-group`,className:e.ei(`group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4`,t),...n})}var c=e.H(`group/field data-[invalid=true]:text-destructive flex w-full gap-2`,{variants:{orientation:{vertical:`flex-col *:w-full [&>.sr-only]:w-auto`,horizontal:`flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`,responsive:`flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`}},defaultVariants:{orientation:`vertical`}});function l({className:t,orientation:n=`vertical`,...r}){return(0,i.jsx)(`fieldset`,{"data-slot":`field`,"data-orientation":n,className:e.ei(c({orientation:n}),t),...r})}function u({className:t,...n}){return(0,i.jsx)(`div`,{"data-slot":`field-content`,className:e.ei(`group/field-content flex flex-1 flex-col gap-0.5 leading-snug`,t),...n})}function d({className:n,...r}){return(0,i.jsx)(t.Label,{"data-slot":`field-label`,className:e.ei(`group/field-label peer/field-label has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10 flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 *:data-[slot=field]:p-2.5`,`has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col`,n),...r})}function f({className:t,...n}){return(0,i.jsx)(`div`,{"data-slot":`field-label`,className:e.ei(`flex w-fit items-center gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50`,t),...n})}function p({className:t,...n}){return(0,i.jsx)(`p`,{"data-slot":`field-description`,className:e.ei(`text-muted-foreground text-start text-sm leading-normal font-normal group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5`,`last:mt-0 nth-last-2:-mt-1`,`[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4`,t),...n})}function m({children:t,className:r,...a}){return(0,i.jsxs)(`div`,{"data-slot":`field-separator`,"data-content":!!t,className:e.ei(`relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2`,r),...a,children:[(0,i.jsx)(n.Separator,{className:`absolute inset-0 top-1/2`}),t&&(0,i.jsx)(`span`,{className:`bg-background text-muted-foreground relative mx-auto block w-fit px-2`,"data-slot":`field-separator-content`,children:t})]})}function h({className:t,children:n,errors:a,...o}){let s=(0,r.useMemo)(()=>{if(n)return n;if(!a?.length)return null;let e=[...new Map(a.map(e=>[e?.message,e])).values()];return e.length===1?e[0]?.message:(0,i.jsx)(`ul`,{className:`ms-4 flex list-disc flex-col gap-1`,children:e.map((e,t)=>e?.message&&(0,i.jsx)(`li`,{children:e.message},t))})},[n,a]);return s?(0,i.jsx)(`div`,{role:`alert`,"data-slot":`field-error`,className:e.ei(`text-destructive text-sm font-normal`,t),...o,children:s}):null}exports.Field=l,exports.FieldContent=u,exports.FieldDescription=p,exports.FieldError=h,exports.FieldGroup=s,exports.FieldLabel=d,exports.FieldLegend=o,exports.FieldSeparator=m,exports.FieldSet=a,exports.FieldTitle=f;
2
2
  //# sourceMappingURL=field.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"field.cjs","names":["cn","cva","Label","Separator","useMemo","require_vendor","require_label","require_separator","react","import_jsx_runtime","FieldSet","props","className","FieldLegend","variant","FieldGroup","fieldVariants","Field","orientation","FieldContent","FieldLabel","FieldTitle","FieldDescription","FieldSeparator","children","FieldError","content","errors","uniqueErrors","error","index"],"sources":["../packages/ui-web/src/field.tsx"],"sourcesContent":["'use client';\n\nimport type {\n FieldBaseProps,\n FieldContentBaseProps,\n FieldDescriptionBaseProps,\n FieldErrorBaseProps,\n FieldGroupBaseProps,\n FieldLabelBaseProps,\n FieldLegendBaseProps,\n FieldSeparatorBaseProps,\n FieldSetBaseProps,\n FieldTitleBaseProps,\n} from '@gv-tech/ui-core';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { cn } from 'cn';\nimport { useMemo } from 'react';\n\nimport { Label } from '@/./label';\nimport { Separator } from '@/./separator';\n\nfunction FieldSet({ className, ...props }: React.ComponentProps<'fieldset'> & FieldSetBaseProps) {\n return (\n <fieldset\n data-slot=\"field-set\"\n className={cn(\n 'flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction FieldLegend({\n className,\n variant = 'legend',\n ...props\n}: React.ComponentProps<'legend'> & FieldLegendBaseProps) {\n return (\n <legend\n data-slot=\"field-legend\"\n data-variant={variant}\n className={cn('mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base', className)}\n {...props}\n />\n );\n}\n\nfunction FieldGroup({ className, ...props }: React.ComponentProps<'div'> & FieldGroupBaseProps) {\n return (\n <div\n data-slot=\"field-group\"\n className={cn(\n 'group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4',\n className,\n )}\n {...props}\n />\n );\n}\n\nconst fieldVariants = cva('group/field data-[invalid=true]:text-destructive flex w-full gap-2', {\n variants: {\n orientation: {\n vertical: 'flex-col *:w-full [&>.sr-only]:w-auto',\n horizontal:\n 'flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',\n responsive:\n 'flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',\n },\n },\n defaultVariants: {\n orientation: 'vertical',\n },\n});\n\nfunction Field({\n className,\n orientation = 'vertical',\n ...props\n}: React.ComponentProps<'fieldset'> & VariantProps<typeof fieldVariants> & FieldBaseProps) {\n return (\n <fieldset\n data-slot=\"field\"\n data-orientation={orientation}\n className={cn(fieldVariants({ orientation }), className)}\n {...props}\n />\n );\n}\n\nfunction FieldContent({ className, ...props }: React.ComponentProps<'div'> & FieldContentBaseProps) {\n return (\n <div\n data-slot=\"field-content\"\n className={cn('group/field-content flex flex-1 flex-col gap-0.5 leading-snug', className)}\n {...props}\n />\n );\n}\n\nfunction FieldLabel({ className, ...props }: React.ComponentProps<typeof Label> & FieldLabelBaseProps) {\n return (\n <Label\n data-slot=\"field-label\"\n className={cn(\n 'group/field-label peer/field-label has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10 flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 *:data-[slot=field]:p-2.5',\n 'has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction FieldTitle({ className, ...props }: React.ComponentProps<'div'> & FieldTitleBaseProps) {\n return (\n <div\n data-slot=\"field-label\"\n className={cn(\n 'flex w-fit items-center gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction FieldDescription({ className, ...props }: React.ComponentProps<'p'> & FieldDescriptionBaseProps) {\n return (\n <p\n data-slot=\"field-description\"\n className={cn(\n 'text-muted-foreground text-start text-sm leading-normal font-normal group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5',\n 'last:mt-0 nth-last-2:-mt-1',\n '[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction FieldSeparator({ children, className, ...props }: React.ComponentProps<'div'> & FieldSeparatorBaseProps) {\n return (\n <div\n data-slot=\"field-separator\"\n data-content={!!children}\n className={cn('relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2', className)}\n {...props}\n >\n <Separator className=\"absolute inset-0 top-1/2\" />\n {children && (\n <span\n className=\"bg-background text-muted-foreground relative mx-auto block w-fit px-2\"\n data-slot=\"field-separator-content\"\n >\n {children}\n </span>\n )}\n </div>\n );\n}\n\nfunction FieldError({ className, children, errors, ...props }: React.ComponentProps<'div'> & FieldErrorBaseProps) {\n const content = useMemo(() => {\n if (children) {\n return children;\n }\n\n if (!errors?.length) {\n return null;\n }\n\n const uniqueErrors = [...new Map(errors.map((error) => [error?.message, error])).values()];\n\n if (uniqueErrors?.length == 1) {\n return uniqueErrors[0]?.message;\n }\n\n return (\n <ul className=\"ms-4 flex list-disc flex-col gap-1\">\n {uniqueErrors.map((error, index) => error?.message && <li key={index}>{error.message}</li>)}\n </ul>\n );\n }, [children, errors]);\n\n if (!content) {\n return null;\n }\n\n return (\n <div\n role=\"alert\"\n data-slot=\"field-error\"\n className={cn('text-destructive text-sm font-normal', className)}\n {...props}\n >\n {content}\n </div>\n );\n}\n\nexport {\n Field,\n FieldContent,\n FieldDescription,\n FieldError,\n FieldGroup,\n FieldLabel,\n FieldLegend,\n FieldSeparator,\n FieldSet,\n FieldTitle,\n};\n"],"mappings":"A,+NAqBA,SAASU,EAAS,CAAE,YAAW,GAAGC,GAA+D,CAC/F,OACE,EAAAF,EAAA,IAAA,CAAC,WAAD,CACE,YAAU,YACV,UAAWT,EAAAA,GACT,mGACAY,CACF,EACA,GAAID,CACL,CAAA,CAEL,CAEA,SAASE,EAAY,CACnB,YACA,UAAU,SACV,GAAGF,GACqD,CACxD,OACE,EAAAF,EAAA,IAAA,CAAC,SAAD,CACE,YAAU,eACV,eAAcK,EACd,UAAWd,EAAAA,GAAG,kFAAmFY,CAAS,EAC1G,GAAID,CACL,CAAA,CAEL,CAEA,SAASI,EAAW,CAAE,YAAW,GAAGJ,GAA4D,CAC9F,OACE,EAAAF,EAAA,IAAA,CAAC,MAAD,CACE,YAAU,cACV,UAAWT,EAAAA,GACT,uIACAY,CACF,EACA,GAAID,CAC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CAAS,EACpG,GAAID,EAJN,SAAA,EAME,EAAAF,EAAA,IAAA,CAACN,EAAAA,UAAD,CAAW,UAAU,0BAA4B,CAAA,EAChDqB,IACC,EAAAf,EAAA,IAAA,CAAC,OAAD,CACE,UAAU,wEACV,YAAU,0BAET,UACG,CAAA,CAEL,C,EAET,CAEA,SAASgB,EAAW,CAAE,YAAW,WAAU,SAAQ,GAAGd,GAA4D,CAChH,IAAMe,GAAA,EAAUtB,EAAAA,QAAAA,KAAc,CAC5B,GAAIoB,EACF,OAAOA,EAGT,GAAI,CAACG,GAAQ,OACX,OAAO,KAGT,IAAMC,EAAe,CAAC,GAAG,IAAI,IAAID,EAAO,IAAK,GAAU,CAACE,GAAO,QAASA,CAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAMzF,OAJID,GAAc,QAAU,EACnBA,EAAa,EAAE,EAAE,SAIxB,EAAAnB,EAAA,IAAA,CAAC,KAAD,CAAI,UAAU,qCACX,SAAAmB,EAAa,KAAK,EAAO,IAAUC,GAAO,UAAW,EAAApB,EAAA,IAAA,CAAC,KAAD,CAAA,SAAiBoB,EAAM,OAAY,EAA1BC,CAA0B,CAAC,CACxF,CAAA,CAER,EAAG,CAACN,EAAUG,CAAM,CAAC,EAMrB,OAJKD,GAKH,EAAAjB,EAAA,IAAA,CAAC,MAAD,CACE,KAAK,QACL,YAAU,cACV,UAAWT,EAAAA,GAAG,uCAAwCY,CAAS,EAC/D,GAAID,EAEH,SAAAe,CACE,CAAA,EAXE,IAaX,C"}
1
+ {"version":3,"file":"field.cjs","names":["cn","cva","Label","Separator","useMemo","require_vendor","require_label","require_separator","react","import_jsx_runtime","FieldSet","props","className","FieldLegend","variant","FieldGroup","fieldVariants","Field","orientation","FieldContent","FieldLabel","FieldTitle","FieldDescription","FieldSeparator","children","FieldError","content","errors","uniqueErrors","error","index"],"sources":["../packages/ui-web/src/field.tsx"],"sourcesContent":["'use client';\n\nimport type {\n FieldBaseProps,\n FieldContentBaseProps,\n FieldDescriptionBaseProps,\n FieldErrorBaseProps,\n FieldGroupBaseProps,\n FieldLabelBaseProps,\n FieldLegendBaseProps,\n FieldSeparatorBaseProps,\n FieldSetBaseProps,\n FieldTitleBaseProps,\n} from '@gv-tech/ui-core';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { cn } from 'cn';\nimport { useMemo } from 'react';\n\nimport { Label } from '@/./label';\nimport { Separator } from '@/./separator';\n\nfunction FieldSet({ className, ...props }: React.ComponentProps<'fieldset'> & FieldSetBaseProps) {\n return (\n <fieldset\n data-slot=\"field-set\"\n className={cn(\n 'flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction FieldLegend({\n className,\n variant = 'legend',\n ...props\n}: React.ComponentProps<'legend'> & FieldLegendBaseProps) {\n return (\n <legend\n data-slot=\"field-legend\"\n data-variant={variant}\n className={cn('mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base', className)}\n {...props}\n />\n );\n}\n\nfunction FieldGroup({ className, ...props }: React.ComponentProps<'div'> & FieldGroupBaseProps) {\n return (\n <div\n data-slot=\"field-group\"\n className={cn(\n 'group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4',\n className,\n )}\n {...props}\n />\n );\n}\n\nconst fieldVariants = cva('group/field data-[invalid=true]:text-destructive flex w-full gap-2', {\n variants: {\n orientation: {\n vertical: 'flex-col *:w-full [&>.sr-only]:w-auto',\n horizontal:\n 'flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',\n responsive:\n 'flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',\n },\n },\n defaultVariants: {\n orientation: 'vertical',\n },\n});\n\nfunction Field({\n className,\n orientation = 'vertical',\n ...props\n}: React.ComponentProps<'fieldset'> & VariantProps<typeof fieldVariants> & FieldBaseProps) {\n return (\n <fieldset\n data-slot=\"field\"\n data-orientation={orientation}\n className={cn(fieldVariants({ orientation }), className)}\n {...props}\n />\n );\n}\n\nfunction FieldContent({ className, ...props }: React.ComponentProps<'div'> & FieldContentBaseProps) {\n return (\n <div\n data-slot=\"field-content\"\n className={cn('group/field-content flex flex-1 flex-col gap-0.5 leading-snug', className)}\n {...props}\n />\n );\n}\n\nfunction FieldLabel({ className, ...props }: React.ComponentProps<typeof Label> & FieldLabelBaseProps) {\n return (\n <Label\n data-slot=\"field-label\"\n className={cn(\n 'group/field-label peer/field-label has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10 flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 *:data-[slot=field]:p-2.5',\n 'has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction FieldTitle({ className, ...props }: React.ComponentProps<'div'> & FieldTitleBaseProps) {\n return (\n <div\n data-slot=\"field-label\"\n className={cn(\n 'flex w-fit items-center gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction FieldDescription({ className, ...props }: React.ComponentProps<'p'> & FieldDescriptionBaseProps) {\n return (\n <p\n data-slot=\"field-description\"\n className={cn(\n 'text-muted-foreground text-start text-sm leading-normal font-normal group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5',\n 'last:mt-0 nth-last-2:-mt-1',\n '[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction FieldSeparator({ children, className, ...props }: React.ComponentProps<'div'> & FieldSeparatorBaseProps) {\n return (\n <div\n data-slot=\"field-separator\"\n data-content={!!children}\n className={cn('relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2', className)}\n {...props}\n >\n <Separator className=\"absolute inset-0 top-1/2\" />\n {children && (\n <span\n className=\"bg-background text-muted-foreground relative mx-auto block w-fit px-2\"\n data-slot=\"field-separator-content\"\n >\n {children}\n </span>\n )}\n </div>\n );\n}\n\nfunction FieldError({ className, children, errors, ...props }: React.ComponentProps<'div'> & FieldErrorBaseProps) {\n const content = useMemo(() => {\n if (children) {\n return children;\n }\n\n if (!errors?.length) {\n return null;\n }\n\n const uniqueErrors = [...new Map(errors.map((error) => [error?.message, error])).values()];\n\n if (uniqueErrors.length === 1) {\n return uniqueErrors[0]?.message;\n }\n\n return (\n <ul className=\"ms-4 flex list-disc flex-col gap-1\">\n {uniqueErrors.map((error, index) => error?.message && <li key={index}>{error.message}</li>)}\n </ul>\n );\n }, [children, errors]);\n\n if (!content) {\n return null;\n }\n\n return (\n <div\n role=\"alert\"\n data-slot=\"field-error\"\n className={cn('text-destructive text-sm font-normal', className)}\n {...props}\n >\n {content}\n </div>\n );\n}\n\nexport {\n Field,\n FieldContent,\n FieldDescription,\n FieldError,\n FieldGroup,\n FieldLabel,\n FieldLegend,\n FieldSeparator,\n FieldSet,\n FieldTitle,\n};\n"],"mappings":"A,+NAqBA,SAASU,EAAS,CAAE,YAAW,GAAGC,GAA+D,CAC/F,OACE,EAAAF,EAAA,IAAA,CAAC,WAAD,CACE,YAAU,YACV,UAAWT,EAAAA,GACT,mGACAY,CACF,EACA,GAAID,CACL,CAAA,C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AC/D,GAAID,EAEH,SAAAe,CACE,CAAA,EAXE,IAaX,C"}
package/dist/field.mjs CHANGED
@@ -90,7 +90,7 @@ function _({ className: e, children: t, errors: r, ...i }) {
90
90
  if (t) return t;
91
91
  if (!r?.length) return null;
92
92
  let e = [...new Map(r.map((e) => [e?.message, e])).values()];
93
- return e?.length == 1 ? e[0]?.message : /* @__PURE__ */ (0, o.jsx)("ul", {
93
+ return e.length === 1 ? e[0]?.message : /* @__PURE__ */ (0, o.jsx)("ul", {
94
94
  className: "ms-4 flex list-disc flex-col gap-1",
95
95
  children: e.map((e, t) => e?.message && /* @__PURE__ */ (0, o.jsx)("li", { children: e.message }, t))
96
96
  });
@@ -1 +1 @@
1
- {"version":3,"file":"field.mjs","names":["require_jsx_runtime","cva","cn","import_jsx_runtime","FieldSet","props","className","FieldLegend","variant","FieldGroup","fieldVariants","Field","orientation","FieldContent","FieldLabel","Label","FieldTitle","FieldDescription","FieldSeparator","children","Separator","FieldError","content","useMemo","errors","uniqueErrors","error","index"],"sources":["../packages/ui-web/src/field.tsx"],"sourcesContent":["'use client';\n\nimport type {\n FieldBaseProps,\n FieldContentBaseProps,\n FieldDescriptionBaseProps,\n FieldErrorBaseProps,\n FieldGroupBaseProps,\n FieldLabelBaseProps,\n FieldLegendBaseProps,\n FieldSeparatorBaseProps,\n FieldSetBaseProps,\n FieldTitleBaseProps,\n} from '@gv-tech/ui-core';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { cn } from 'cn';\nimport { useMemo } from 'react';\n\nimport { Label } from '@/./label';\nimport { Separator } from '@/./separator';\n\nfunction FieldSet({ className, ...props }: React.ComponentProps<'fieldset'> & FieldSetBaseProps) {\n return (\n <fieldset\n data-slot=\"field-set\"\n className={cn(\n 'flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction FieldLegend({\n className,\n variant = 'legend',\n ...props\n}: React.ComponentProps<'legend'> & FieldLegendBaseProps) {\n return (\n <legend\n data-slot=\"field-legend\"\n data-variant={variant}\n className={cn('mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base', className)}\n {...props}\n />\n );\n}\n\nfunction FieldGroup({ className, ...props }: React.ComponentProps<'div'> & FieldGroupBaseProps) {\n return (\n <div\n data-slot=\"field-group\"\n className={cn(\n 'group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4',\n className,\n )}\n {...props}\n />\n );\n}\n\nconst fieldVariants = cva('group/field data-[invalid=true]:text-destructive flex w-full gap-2', {\n variants: {\n orientation: {\n vertical: 'flex-col *:w-full [&>.sr-only]:w-auto',\n horizontal:\n 'flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',\n responsive:\n 'flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',\n },\n },\n defaultVariants: {\n orientation: 'vertical',\n },\n});\n\nfunction Field({\n className,\n orientation = 'vertical',\n ...props\n}: React.ComponentProps<'fieldset'> & VariantProps<typeof fieldVariants> & FieldBaseProps) {\n return (\n <fieldset\n data-slot=\"field\"\n data-orientation={orientation}\n className={cn(fieldVariants({ orientation }), className)}\n {...props}\n />\n );\n}\n\nfunction FieldContent({ className, ...props }: React.ComponentProps<'div'> & FieldContentBaseProps) {\n return (\n <div\n data-slot=\"field-content\"\n className={cn('group/field-content flex flex-1 flex-col gap-0.5 leading-snug', className)}\n {...props}\n />\n );\n}\n\nfunction FieldLabel({ className, ...props }: React.ComponentProps<typeof Label> & FieldLabelBaseProps) {\n return (\n <Label\n data-slot=\"field-label\"\n className={cn(\n 'group/field-label peer/field-label has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10 flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 *:data-[slot=field]:p-2.5',\n 'has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction FieldTitle({ className, ...props }: React.ComponentProps<'div'> & FieldTitleBaseProps) {\n return (\n <div\n data-slot=\"field-label\"\n className={cn(\n 'flex w-fit items-center gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction FieldDescription({ className, ...props }: React.ComponentProps<'p'> & FieldDescriptionBaseProps) {\n return (\n <p\n data-slot=\"field-description\"\n className={cn(\n 'text-muted-foreground text-start text-sm leading-normal font-normal group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5',\n 'last:mt-0 nth-last-2:-mt-1',\n '[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction FieldSeparator({ children, className, ...props }: React.ComponentProps<'div'> & FieldSeparatorBaseProps) {\n return (\n <div\n data-slot=\"field-separator\"\n data-content={!!children}\n className={cn('relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2', className)}\n {...props}\n >\n <Separator className=\"absolute inset-0 top-1/2\" />\n {children && (\n <span\n className=\"bg-background text-muted-foreground relative mx-auto block w-fit px-2\"\n data-slot=\"field-separator-content\"\n >\n {children}\n </span>\n )}\n </div>\n );\n}\n\nfunction FieldError({ className, children, errors, ...props }: React.ComponentProps<'div'> & FieldErrorBaseProps) {\n const content = useMemo(() => {\n if (children) {\n return children;\n }\n\n if (!errors?.length) {\n return null;\n }\n\n const uniqueErrors = [...new Map(errors.map((error) => [error?.message, error])).values()];\n\n if (uniqueErrors?.length == 1) {\n return uniqueErrors[0]?.message;\n }\n\n return (\n <ul className=\"ms-4 flex list-disc flex-col gap-1\">\n {uniqueErrors.map((error, index) => error?.message && <li key={index}>{error.message}</li>)}\n </ul>\n );\n }, [children, errors]);\n\n if (!content) {\n return null;\n }\n\n return (\n <div\n role=\"alert\"\n data-slot=\"field-error\"\n className={cn('text-destructive text-sm font-normal', className)}\n {...props}\n >\n {content}\n </div>\n );\n}\n\nexport {\n Field,\n FieldContent,\n FieldDescription,\n FieldError,\n FieldGroup,\n FieldLabel,\n FieldLegend,\n FieldSeparator,\n FieldSet,\n FieldTitle,\n};\n"],"mappings":";;;;;;;;AAqBA,SAASI,EAAS,EAAE,cAAW,GAAGC,KAA+D;CAC/F,OACE,iBAAA,GAAAF,EAAA,IAAA,CAAC,YAAD;EACE,aAAU;EACV,WAAWD,EACT,oGACAI,CACF;EACA,GAAID;CACL,CAAA;AAEL;AAEA,SAASE,EAAY,EACnB,cACA,aAAU,UACV,GAAGF,KACqD;CACxD,OACE,iBAAA,GAAAF,EAAA,IAAA,CAAC,UAAD;EACE,aAAU;EACV,gBAAcK;EACd,WAAWN,EAAG,mFAAmFI,CAAS;EAC1G,GAAID;CACL,CAAA;AAEL;AAEA,SAASI,EAAW,EAAE,cAAW,GAAGJ,KAA4D;CAC9F,OACE,iBAAA,GAAAF,EAAA,IAAA,CAAC,OAAD;EACE,aAAU;EACV,WAAWD,EACT,wIACAI,CACF;EACA,GAAID;CACL,CAAA;AAEL;AAEA,IAAMK,IAAgBT,EAAI,sEAAsE;CAC9F,UAAU,EACR,aAAa;EACX,UAAU;EACV,YACE;EACF,YACE;CACJ,EACF;CACA,iBAAiB,EACf,aAAa,WACf;AACF,CAAC;AAED,SAASU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AA,CAEL;;AAET;AAEA,SAASkB,EAAW,EAAE,cAAW,aAAU,WAAQ,GAAGhB,KAA4D;CAChH,IAAMiB,IAAUC,QAAc;EAC5B,IAAIJ,GACF,OAAOA;EAGT,IAAI,CAACK,GAAQ,QACX,OAAO;EAGT,IAAMC,IAAe,CAAC,GAAG,IAAI,IAAID,EAAO,KAAK,MAAU,CAACE,GAAO,SAASA,CAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;EAMzF,OAJID,GAAc,UAAU,IACnBA,EAAa,EAAE,EAAE,UAIxB,iBAAA,GAAAtB,EAAA,IAAA,CAAC,MAAD;GAAI,WAAU;GACX,UAAAsB,EAAa,KAAK,GAAO,MAAUC,GAAO,WAAW,iBAAA,GAAAvB,EAAA,IAAA,CAAC,MAAD,EAAA,UAAiBuB,EAAM,QAAY,GAA1BC,CAA0B,CAAC;EACxF,CAAA;CAER,GAAG,CAACR,GAAUK,CAAM,CAAC;CAMrB,OAJKF,IAKH,iBAAA,GAAAnB,EAAA,IAAA,CAAC,OAAD;EACE,MAAK;EACL,aAAU;EACV,WAAWD,EAAG,wCAAwCI,CAAS;EAC/D,GAAID;EAEH,UAAAiB;CACE,CAAA,IAXE;AAaX"}
1
+ {"version":3,"file":"field.mjs","names":["require_jsx_runtime","cva","cn","import_jsx_runtime","FieldSet","props","className","FieldLegend","variant","FieldGroup","fieldVariants","Field","orientation","FieldContent","FieldLabel","Label","FieldTitle","FieldDescription","FieldSeparator","children","Separator","FieldError","content","useMemo","errors","uniqueErrors","error","index"],"sources":["../packages/ui-web/src/field.tsx"],"sourcesContent":["'use client';\n\nimport type {\n FieldBaseProps,\n FieldContentBaseProps,\n FieldDescriptionBaseProps,\n FieldErrorBaseProps,\n FieldGroupBaseProps,\n FieldLabelBaseProps,\n FieldLegendBaseProps,\n FieldSeparatorBaseProps,\n FieldSetBaseProps,\n FieldTitleBaseProps,\n} from '@gv-tech/ui-core';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { cn } from 'cn';\nimport { useMemo } from 'react';\n\nimport { Label } from '@/./label';\nimport { Separator } from '@/./separator';\n\nfunction FieldSet({ className, ...props }: React.ComponentProps<'fieldset'> & FieldSetBaseProps) {\n return (\n <fieldset\n data-slot=\"field-set\"\n className={cn(\n 'flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction FieldLegend({\n className,\n variant = 'legend',\n ...props\n}: React.ComponentProps<'legend'> & FieldLegendBaseProps) {\n return (\n <legend\n data-slot=\"field-legend\"\n data-variant={variant}\n className={cn('mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base', className)}\n {...props}\n />\n );\n}\n\nfunction FieldGroup({ className, ...props }: React.ComponentProps<'div'> & FieldGroupBaseProps) {\n return (\n <div\n data-slot=\"field-group\"\n className={cn(\n 'group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4',\n className,\n )}\n {...props}\n />\n );\n}\n\nconst fieldVariants = cva('group/field data-[invalid=true]:text-destructive flex w-full gap-2', {\n variants: {\n orientation: {\n vertical: 'flex-col *:w-full [&>.sr-only]:w-auto',\n horizontal:\n 'flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',\n responsive:\n 'flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',\n },\n },\n defaultVariants: {\n orientation: 'vertical',\n },\n});\n\nfunction Field({\n className,\n orientation = 'vertical',\n ...props\n}: React.ComponentProps<'fieldset'> & VariantProps<typeof fieldVariants> & FieldBaseProps) {\n return (\n <fieldset\n data-slot=\"field\"\n data-orientation={orientation}\n className={cn(fieldVariants({ orientation }), className)}\n {...props}\n />\n );\n}\n\nfunction FieldContent({ className, ...props }: React.ComponentProps<'div'> & FieldContentBaseProps) {\n return (\n <div\n data-slot=\"field-content\"\n className={cn('group/field-content flex flex-1 flex-col gap-0.5 leading-snug', className)}\n {...props}\n />\n );\n}\n\nfunction FieldLabel({ className, ...props }: React.ComponentProps<typeof Label> & FieldLabelBaseProps) {\n return (\n <Label\n data-slot=\"field-label\"\n className={cn(\n 'group/field-label peer/field-label has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10 flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 *:data-[slot=field]:p-2.5',\n 'has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction FieldTitle({ className, ...props }: React.ComponentProps<'div'> & FieldTitleBaseProps) {\n return (\n <div\n data-slot=\"field-label\"\n className={cn(\n 'flex w-fit items-center gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction FieldDescription({ className, ...props }: React.ComponentProps<'p'> & FieldDescriptionBaseProps) {\n return (\n <p\n data-slot=\"field-description\"\n className={cn(\n 'text-muted-foreground text-start text-sm leading-normal font-normal group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5',\n 'last:mt-0 nth-last-2:-mt-1',\n '[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction FieldSeparator({ children, className, ...props }: React.ComponentProps<'div'> & FieldSeparatorBaseProps) {\n return (\n <div\n data-slot=\"field-separator\"\n data-content={!!children}\n className={cn('relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2', className)}\n {...props}\n >\n <Separator className=\"absolute inset-0 top-1/2\" />\n {children && (\n <span\n className=\"bg-background text-muted-foreground relative mx-auto block w-fit px-2\"\n data-slot=\"field-separator-content\"\n >\n {children}\n </span>\n )}\n </div>\n );\n}\n\nfunction FieldError({ className, children, errors, ...props }: React.ComponentProps<'div'> & FieldErrorBaseProps) {\n const content = useMemo(() => {\n if (children) {\n return children;\n }\n\n if (!errors?.length) {\n return null;\n }\n\n const uniqueErrors = [...new Map(errors.map((error) => [error?.message, error])).values()];\n\n if (uniqueErrors.length === 1) {\n return uniqueErrors[0]?.message;\n }\n\n return (\n <ul className=\"ms-4 flex list-disc flex-col gap-1\">\n {uniqueErrors.map((error, index) => error?.message && <li key={index}>{error.message}</li>)}\n </ul>\n );\n }, [children, errors]);\n\n if (!content) {\n return null;\n }\n\n return (\n <div\n role=\"alert\"\n data-slot=\"field-error\"\n className={cn('text-destructive text-sm font-normal', className)}\n {...props}\n >\n {content}\n </div>\n );\n}\n\nexport {\n Field,\n FieldContent,\n FieldDescription,\n FieldError,\n FieldGroup,\n FieldLabel,\n FieldLegend,\n FieldSeparator,\n FieldSet,\n FieldTitle,\n};\n"],"mappings":";;;;;;;;AAqBA,SAASI,EAAS,EAAE,cAAW,GAAGC,KAA+D;CAC/F,OACE,iBAAA,GAAAF,EAAA,IAAA,CAAC,YAAD;EACE,aAAU;EACV,WAAWD,EACT,oGACAI,CACF;EACA,GAAID;CACL,CAAA;AAEL;AAEA,SAASE,EAAY,EACnB,cACA,aAAU,UACV,GAAGF,KACqD;CACxD,OACE,iBAAA,GAAAF,EAAA,IAAA,CAAC,UAAD;EACE,aAAU;EACV,gBAAcK;EACd,WAAWN,EAAG,mFAAmFI,CAAS;EAC1G,GAAID;CACL,CAAA;AA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,GAAGb,KAAgE;CAChH,OACE,iBAAA,GAAAF,EAAA,KAAA,CAAC,OAAD;EACE,aAAU;EACV,gBAAc,CAAC,CAACgB;EAChB,WAAWjB,EAAG,6EAA6EI,CAAS;EACpG,GAAID;EAJN,UAAA,CAME,iBAAA,GAAAF,EAAA,IAAA,CAACiB,GAAD,EAAW,WAAU,2BAA4B,CAAA,GAChDD,KACC,iBAAA,GAAAhB,EAAA,IAAA,CAAC,QAAD;GACE,WAAU;GACV,aAAU;GAET;EACG,CAAA,CAEL;;AAET;AAEA,SAASkB,EAAW,EAAE,cAAW,aAAU,WAAQ,GAAGhB,KAA4D;CAChH,IAAMiB,IAAUC,QAAc;EAC5B,IAAIJ,GACF,OAAOA;EAGT,IAAI,CAACK,GAAQ,QACX,OAAO;EAGT,IAAMC,IAAe,CAAC,GAAG,IAAI,IAAID,EAAO,KAAK,MAAU,CAACE,GAAO,SAASA,CAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;EAMzF,OAJID,EAAa,WAAW,IACnBA,EAAa,EAAE,EAAE,UAIxB,iBAAA,GAAAtB,EAAA,IAAA,CAAC,MAAD;GAAI,WAAU;GACX,UAAAsB,EAAa,KAAK,GAAO,MAAUC,GAAO,WAAW,iBAAA,GAAAvB,EAAA,IAAA,CAAC,MAAD,EAAA,UAAiBuB,EAAM,QAAY,GAA1BC,CAA0B,CAAC;EACxF,CAAA;CAER,GAAG,CAACR,GAAUK,CAAM,CAAC;CAMrB,OAJKF,IAKH,iBAAA,GAAAnB,EAAA,IAAA,CAAC,OAAD;EACE,MAAK;EACL,aAAU;EACV,WAAWD,EAAG,wCAAwCI,CAAS;EAC/D,GAAID;EAEH,UAAAiB;CACE,CAAA,IAXE;AAaX"}
@@ -1,2 +1,2 @@
1
- "use client";"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-DbbDpzbe.js"),t=require("./vendor-Ceu--gxM.js"),n=require("./button.cjs"),r=require("./dialog.cjs"),i=require("./drawer.cjs"),a=require("./utils-BKlmn6yB.js");let o=require("react");o=e.r(o);var s=t.Ar(),c=`(max-width: 767px)`,l=`https://www.buymeacoffee.com`,u=new Set([`buymeacoffee.com`,`www.buymeacoffee.com`]),d=e=>{let t=e.trim();try{let n=new URL(t),r=n.hostname.toLowerCase();return n.protocol!==`https:`||!u.has(r)?(console.warn(`Invalid supportUrl: ${e}. Falling back to default.`),l):t}catch{return console.warn(`Invalid supportUrl: ${e}. Falling back to default.`),l}},f=e=>{let t=d(e);return t.endsWith(`/`)?t.slice(0,-1):t},p=e=>e.trim().replace(/^@+/,``),m=(e,t)=>`${f(e)}/${encodeURIComponent(p(t))}`,h=(e,t)=>`${f(e)}/widget/page/${encodeURIComponent(p(t))}`,g=()=>{let[e,t]=o.useState(()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(c).matches);return o.useEffect(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(c),n=e=>t(e.matches);return t(e.matches),e.addEventListener(`change`,n),()=>{e.removeEventListener(`change`,n)}},[]),e};function _({supportUrl:e=l,creatorId:c,title:u=`Buy me a coffee`,description:d=`Support the project directly from this panel.`,iframeTitle:f=`Buy Me a Coffee support form`,open:p,defaultOpen:_=!1,onOpenChange:v,positionClassName:y,buttonClassName:b,panelClassName:x,className:S,type:C,onClick:w,...T}){let E=g(),D=p!==void 0,[O,k]=o.useState(_),A=D?p:O,j=o.useCallback(e=>{D||k(e),v?.(e)},[D,v]),M=o.useMemo(()=>m(e,c),[c,e]),N=o.useMemo(()=>h(e,c),[c,e]),P=(0,s.jsxs)(`div`,{className:`flex max-h-[75vh] flex-col gap-3`,children:[(0,s.jsx)(`div`,{className:`overflow-hidden rounded-md border`,children:(0,s.jsx)(`iframe`,{title:f,src:N,className:`h-[560px] w-full border-0`,loading:`lazy`,referrerPolicy:`strict-origin-when-cross-origin`})}),(0,s.jsxs)(`div`,{className:`text-muted-foreground flex items-center justify-between gap-2 text-xs`,children:[(0,s.jsx)(`span`,{children:`If the embedded checkout is unavailable, open the support page directly.`}),(0,s.jsxs)(`a`,{href:M,target:`_blank`,rel:`noopener noreferrer`,className:`text-foreground inline-flex items-center gap-1 font-medium underline underline-offset-2`,children:[`Open Buy Me a Coffee`,(0,s.jsx)(t.Ur,{className:`h-3.5 w-3.5`})]})]})]}),F=(0,s.jsx)(`div`,{className:a.t(`fixed right-6 bottom-6 z-50`,y),children:(0,s.jsxs)(n.Button,{"aria-label":`Support this project`,type:C??`button`,className:a.t(`inline-flex h-14 w-14 items-center justify-center rounded-full border border-black/15 bg-[#ffdd00] text-black shadow-[0_16px_36px_-18px_rgba(0,0,0,0.8)] transition hover:-translate-y-0.5 hover:scale-105 hover:bg-[#ffe347] focus-visible:ring-2 focus-visible:ring-offset-2 active:translate-y-0 active:scale-95`,b,S),onClick:e=>{w?.(e),e.defaultPrevented||j(!0)},...T,children:[(0,s.jsx)(t.Gr,{className:`h-6 w-6`}),(0,s.jsx)(`span`,{className:`sr-only`,children:`Support this project`})]})});return E?(0,s.jsxs)(s.Fragment,{children:[F,(0,s.jsx)(i.Drawer,{open:A,onOpenChange:j,children:(0,s.jsxs)(i.DrawerContent,{className:a.t(`mx-auto w-full max-w-xl`,x),children:[(0,s.jsxs)(i.DrawerHeader,{children:[(0,s.jsx)(i.DrawerTitle,{children:u}),(0,s.jsx)(i.DrawerDescription,{children:d})]}),(0,s.jsx)(`div`,{className:`px-4 pb-4`,children:P})]})})]}):(0,s.jsxs)(s.Fragment,{children:[F,(0,s.jsx)(r.Dialog,{open:A,onOpenChange:j,children:(0,s.jsxs)(r.DialogContent,{className:a.t(`max-w-xl p-5`,x),children:[(0,s.jsxs)(r.DialogHeader,{children:[(0,s.jsx)(r.DialogTitle,{children:u}),(0,s.jsx)(r.DialogDescription,{children:d})]}),P]})})]})}exports.SupportFab=_;
1
+ "use client";"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-DbbDpzbe.js"),t=require("./vendor-Ceu--gxM.js"),n=require("./button.cjs"),r=require("./dialog.cjs"),i=require("./drawer.cjs"),a=require("./utils-BKlmn6yB.js");let o=require("react");o=e.r(o);var s=t.Ar(),c=`(max-width: 767px)`,l=`https://www.buymeacoffee.com`,u=new Set([`buymeacoffee.com`,`www.buymeacoffee.com`]),d=e=>{let t=e.trim();try{let n=new URL(t),r=n.hostname.toLowerCase();return n.protocol!==`https:`||!u.has(r)?(console.warn(`Invalid supportUrl: ${e}. Falling back to default.`),l):t}catch{return console.warn(`Invalid supportUrl: ${e}. Falling back to default.`),l}},f=e=>{let t=d(e);return t.endsWith(`/`)?t.slice(0,-1):t},p=e=>e.trim().replace(/^@+/,``),m=(e,t)=>`${f(e)}/${encodeURIComponent(p(t))}`,h=(e,t)=>`${f(e)}/widget/page/${encodeURIComponent(p(t))}`,g=()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(c).matches,_=()=>{let[e,t]=o.useState(g);return o.useEffect(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(c),n=e=>t(e.matches);return t(e.matches),e.addEventListener(`change`,n),()=>{e.removeEventListener(`change`,n)}},[]),e};function v({supportUrl:e=l,creatorId:c,title:u=`Buy me a coffee`,description:d=`Support the project directly from this panel.`,iframeTitle:f=`Buy Me a Coffee support form`,open:p,defaultOpen:g=!1,onOpenChange:v,positionClassName:y,buttonClassName:b,panelClassName:x,className:S,type:C,onClick:w,...T}){let E=_(),D=p!==void 0,[O,k]=o.useState(g),A=D?p:O,j=o.useCallback(e=>{D||k(e),v?.(e)},[D,v]),M=o.useMemo(()=>m(e,c),[c,e]),N=o.useMemo(()=>h(e,c),[c,e]),P=(0,s.jsxs)(`div`,{className:`flex max-h-[75vh] flex-col gap-3`,children:[(0,s.jsx)(`div`,{className:`overflow-hidden rounded-md border`,children:(0,s.jsx)(`iframe`,{title:f,src:N,className:`h-[560px] w-full border-0`,loading:`lazy`,referrerPolicy:`strict-origin-when-cross-origin`})}),(0,s.jsxs)(`div`,{className:`text-muted-foreground flex items-center justify-between gap-2 text-xs`,children:[(0,s.jsx)(`span`,{children:`If the embedded checkout is unavailable, open the support page directly.`}),(0,s.jsxs)(`a`,{href:M,target:`_blank`,rel:`noopener noreferrer`,className:`text-foreground inline-flex items-center gap-1 font-medium underline underline-offset-2`,children:[`Open Buy Me a Coffee`,(0,s.jsx)(t.Ur,{className:`h-3.5 w-3.5`})]})]})]}),F=(0,s.jsx)(`div`,{className:a.t(`fixed right-6 bottom-6 z-50`,y),children:(0,s.jsxs)(n.Button,{"aria-label":`Support this project`,type:C??`button`,className:a.t(`inline-flex h-14 w-14 items-center justify-center rounded-full border border-black/15 bg-[#ffdd00] text-black shadow-[0_16px_36px_-18px_rgba(0,0,0,0.8)] transition hover:-translate-y-0.5 hover:scale-105 hover:bg-[#ffe347] focus-visible:ring-2 focus-visible:ring-offset-2 active:translate-y-0 active:scale-95`,b,S),onClick:e=>{w?.(e),e.defaultPrevented||j(!0)},...T,children:[(0,s.jsx)(t.Gr,{className:`h-6 w-6`}),(0,s.jsx)(`span`,{className:`sr-only`,children:`Support this project`})]})});return E?(0,s.jsxs)(s.Fragment,{children:[F,(0,s.jsx)(i.Drawer,{open:A,onOpenChange:j,children:(0,s.jsxs)(i.DrawerContent,{className:a.t(`mx-auto w-full max-w-xl`,x),children:[(0,s.jsxs)(i.DrawerHeader,{children:[(0,s.jsx)(i.DrawerTitle,{children:u}),(0,s.jsx)(i.DrawerDescription,{children:d})]}),(0,s.jsx)(`div`,{className:`px-4 pb-4`,children:P})]})})]}):(0,s.jsxs)(s.Fragment,{children:[F,(0,s.jsx)(r.Dialog,{open:A,onOpenChange:j,children:(0,s.jsxs)(r.DialogContent,{className:a.t(`max-w-xl p-5`,x),children:[(0,s.jsxs)(r.DialogHeader,{children:[(0,s.jsx)(r.DialogTitle,{children:u}),(0,s.jsx)(r.DialogDescription,{children:d})]}),P]})})]})}exports.SupportFab=v;
2
2
  //# sourceMappingURL=support-fab.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"support-fab.cjs","names":["React","ExternalLink","cn","Button","Coffee","_Fragment","Drawer","DrawerContent","DrawerHeader","DrawerTitle","DrawerDescription","Dialog","DialogContent","DialogHeader","DialogTitle","DialogDescription","require_rolldown_runtime","require_vendor","require_button","require_dialog","require_drawer","require_utils","react","import_jsx_runtime","MOBILE_QUERY","DEFAULT_SUPPORT_URL","ALLOWED_SUPPORT_DOMAINS","validateSupportUrl","trimmed","url","parsed","hostname","normalizeBaseUrl","validated","sanitizeCreator","creatorId","buildPageUrl","supportUrl","buildEmbedUrl","useIsMobile","isMobile","setIsMobile","mediaQuery","onChange","event","SupportFab","buttonProps","isControlled","open","internalOpen","setInternalOpen","defaultOpen","isOpen","setOpen","nextOpen","onOpenChange","pageUrl","embedUrl","panelBody","iframeTitle","trigger","positionClassName","type","buttonClassName","className","onClick","panelClassName","title","description"],"sources":["../packages/ui-web/src/support-fab.tsx"],"sourcesContent":["'use client';\n\nimport { Coffee, ExternalLink } from 'lucide-react';\nimport * as React from 'react';\n\nimport { Button } from './button';\nimport { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from './dialog';\nimport { Drawer, DrawerContent, DrawerDescription, DrawerHeader, DrawerTitle } from './drawer';\nimport { cn } from './lib/utils';\n\nconst MOBILE_QUERY = '(max-width: 767px)';\nconst DEFAULT_SUPPORT_URL = 'https://www.buymeacoffee.com';\nconst ALLOWED_SUPPORT_DOMAINS = new Set(['buymeacoffee.com', 'www.buymeacoffee.com']);\n\nconst validateSupportUrl = (url: string) => {\n const trimmed = url.trim();\n\n try {\n const parsed = new URL(trimmed);\n const hostname = parsed.hostname.toLowerCase();\n\n if (parsed.protocol !== 'https:' || !ALLOWED_SUPPORT_DOMAINS.has(hostname)) {\n console.warn(`Invalid supportUrl: ${url}. Falling back to default.`);\n return DEFAULT_SUPPORT_URL;\n }\n\n return trimmed;\n } catch {\n console.warn(`Invalid supportUrl: ${url}. Falling back to default.`);\n return DEFAULT_SUPPORT_URL;\n }\n};\n\nconst normalizeBaseUrl = (url: string) => {\n const validated = validateSupportUrl(url);\n return validated.endsWith('/') ? validated.slice(0, -1) : validated;\n};\n\nconst sanitizeCreator = (creatorId: string) => creatorId.trim().replace(/^@+/, '');\n\nconst buildPageUrl = (supportUrl: string, creatorId: string) => {\n const base = normalizeBaseUrl(supportUrl);\n const creator = encodeURIComponent(sanitizeCreator(creatorId));\n return `${base}/${creator}`;\n};\n\nconst buildEmbedUrl = (supportUrl: string, creatorId: string) => {\n const base = normalizeBaseUrl(supportUrl);\n const creator = encodeURIComponent(sanitizeCreator(creatorId));\n return `${base}/widget/page/${creator}`;\n};\n\nconst useIsMobile = () => {\n const getInitial = () => {\n if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') {\n return false;\n }\n return window.matchMedia(MOBILE_QUERY).matches;\n };\n\n const [isMobile, setIsMobile] = React.useState(getInitial);\n\n React.useEffect(() => {\n if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') {\n return;\n }\n\n const mediaQuery = window.matchMedia(MOBILE_QUERY);\n const onChange = (event: MediaQueryListEvent) => setIsMobile(event.matches);\n const syncInitialValue = () => {\n setIsMobile(mediaQuery.matches);\n };\n\n syncInitialValue();\n mediaQuery.addEventListener('change', onChange);\n\n return () => {\n mediaQuery.removeEventListener('change', onChange);\n };\n }, []);\n\n return isMobile;\n};\n\nexport interface SupportFabProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'onChange'> {\n supportUrl?: string;\n creatorId: string;\n title?: string;\n description?: string;\n iframeTitle?: string;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n positionClassName?: string;\n buttonClassName?: string;\n panelClassName?: string;\n}\n\nexport function SupportFab({\n supportUrl = DEFAULT_SUPPORT_URL,\n creatorId,\n title = 'Buy me a coffee',\n description = 'Support the project directly from this panel.',\n iframeTitle = 'Buy Me a Coffee support form',\n open,\n defaultOpen = false,\n onOpenChange,\n positionClassName,\n buttonClassName,\n panelClassName,\n className,\n type,\n onClick,\n ...buttonProps\n}: SupportFabProps) {\n const isMobile = useIsMobile();\n const isControlled = open !== undefined;\n const [internalOpen, setInternalOpen] = React.useState(defaultOpen);\n const isOpen = isControlled ? open : internalOpen;\n\n const setOpen = React.useCallback(\n (nextOpen: boolean) => {\n if (!isControlled) {\n setInternalOpen(nextOpen);\n }\n onOpenChange?.(nextOpen);\n },\n [isControlled, onOpenChange],\n );\n\n const pageUrl = React.useMemo(() => buildPageUrl(supportUrl, creatorId), [creatorId, supportUrl]);\n const embedUrl = React.useMemo(() => buildEmbedUrl(supportUrl, creatorId), [creatorId, supportUrl]);\n\n const panelBody = (\n <div className=\"flex max-h-[75vh] flex-col gap-3\">\n <div className=\"overflow-hidden rounded-md border\">\n <iframe\n title={iframeTitle}\n src={embedUrl}\n className=\"h-[560px] w-full border-0\"\n loading=\"lazy\"\n referrerPolicy=\"strict-origin-when-cross-origin\"\n />\n </div>\n <div className=\"text-muted-foreground flex items-center justify-between gap-2 text-xs\">\n <span>If the embedded checkout is unavailable, open the support page directly.</span>\n <a\n href={pageUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"text-foreground inline-flex items-center gap-1 font-medium underline underline-offset-2\"\n >\n Open Buy Me a Coffee\n <ExternalLink className=\"h-3.5 w-3.5\" />\n </a>\n </div>\n </div>\n );\n\n const trigger = (\n <div className={cn('fixed right-6 bottom-6 z-50', positionClassName)}>\n <Button\n aria-label=\"Support this project\"\n type={type ?? 'button'}\n className={cn(\n 'inline-flex h-14 w-14 items-center justify-center rounded-full border border-black/15 bg-[#ffdd00] text-black shadow-[0_16px_36px_-18px_rgba(0,0,0,0.8)] transition hover:-translate-y-0.5 hover:scale-105 hover:bg-[#ffe347] focus-visible:ring-2 focus-visible:ring-offset-2 active:translate-y-0 active:scale-95',\n buttonClassName,\n className,\n )}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) {\n setOpen(true);\n }\n }}\n {...buttonProps}\n >\n <Coffee className=\"h-6 w-6\" />\n <span className=\"sr-only\">Support this project</span>\n </Button>\n </div>\n );\n\n if (isMobile) {\n return (\n <>\n {trigger}\n <Drawer open={isOpen} onOpenChange={setOpen}>\n <DrawerContent className={cn('mx-auto w-full max-w-xl', panelClassName)}>\n <DrawerHeader>\n <DrawerTitle>{title}</DrawerTitle>\n <DrawerDescription>{description}</DrawerDescription>\n </DrawerHeader>\n <div className=\"px-4 pb-4\">{panelBody}</div>\n </DrawerContent>\n </Drawer>\n </>\n );\n }\n\n return (\n <>\n {trigger}\n <Dialog open={isOpen} onOpenChange={setOpen}>\n <DialogContent className={cn('max-w-xl p-5', panelClassName)}>\n <DialogHeader>\n <DialogTitle>{title}</DialogTitle>\n <DialogDescription>{description}</DialogDescription>\n </DialogHeader>\n {panelBody}\n </DialogContent>\n </Dialog>\n </>\n );\n}\n"],"mappings":"A,6UAUMwB,EAAe,qBACfC,EAAsB,+BACtBC,EAA0B,IAAI,IAAI,CAAC,mBAAoB,sBAAsB,CAAC,EAE9EC,EAAsB,GAAgB,CAC1C,IAAMC,EAAUC,EAAI,KAAK,EAEzB,GAAI,CACF,IAAMC,EAAS,IAAI,IAAIF,CAAO,EACxBG,EAAWD,EAAO,SAAS,YAAY,EAO7C,OALIA,EAAO,WAAa,UAAY,CAACJ,EAAwB,IAAIK,CAAQ,GACvE,QAAQ,KAAK,uBAAuBF,EAAI,2BAA2B,EAC5DJ,GAGFG,CACT,MAAQ,CAEN,OADA,QAAQ,KAAK,uBAAuBC,EAAI,2BAA2B,EAC5DJ,CACT,CACF,EAEMO,EAAoB,GAAgB,CACxC,IAAMC,EAAYN,EAAmBE,CAAG,EACxC,OAAOI,EAAU,SAAS,GAAG,EAAIA,EAAU,MAAM,EAAG,EAAE,EAAIA,CAC5D,EAEMC,EAAmB,GAAsBC,EAAU,KAAK,CAAC,CAAC,QAAQ,MAAO,EAAE,EAE3EC,GAAgB,EAAoB,IAGjC,GAFM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A9B,EAAA,KAAA,CAAChB,EAAAA,cAAD,CAAe,UAAWL,EAAAA,EAAG,0BAA2BgE,CAAc,EAAtE,SAAA,EACE,EAAA3C,EAAA,KAAA,CAACf,EAAAA,aAAD,CAAA,SAAA,EACE,EAAAe,EAAA,IAAA,CAACd,EAAAA,YAAD,CAAA,SAAc0D,CAAmB,CAAA,GACjC,EAAA5C,EAAA,IAAA,CAACb,EAAAA,kBAAD,CAAA,SAAoB0D,CAA+B,CAAA,CACvC,CAAA,CAAA,GACd,EAAA7C,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,YAAa,SAAAmC,CAAe,CAAA,CAC9B,C,EACT,CAAA,CACR,CAAA,CAAA,GAKJ,EAAAnC,EAAA,KAAA,CAAAlB,EAAAA,SAAA,CAAA,SAAA,CACGuD,GACD,EAAArC,EAAA,IAAA,CAACZ,EAAAA,OAAD,CAAQ,KAAMyC,EAAQ,aAAcC,EAClC,UAAA,EAAA9B,EAAA,KAAA,CAACX,EAAAA,cAAD,CAAe,UAAWV,EAAAA,EAAG,eAAgBgE,CAAc,EAA3D,SAAA,EACE,EAAA3C,EAAA,KAAA,CAACV,EAAAA,aAAD,CAAA,SAAA,EACE,EAAAU,EAAA,IAAA,CAACT,EAAAA,YAAD,CAAA,SAAcqD,CAAmB,CAAA,GACjC,EAAA5C,EAAA,IAAA,CAACR,EAAAA,kBAAD,CAAA,SAAoBqD,CAA+B,CAAA,CACvC,CAAA,CAAA,EACbV,CACY,C,EACT,CAAA,CACR,CAAA,CAAA,CAEN,C"}
1
+ {"version":3,"file":"support-fab.cjs","names":["React","ExternalLink","cn","Button","Coffee","_Fragment","Drawer","DrawerContent","DrawerHeader","DrawerTitle","DrawerDescription","Dialog","DialogContent","DialogHeader","DialogTitle","DialogDescription","require_rolldown_runtime","require_vendor","require_button","require_dialog","require_drawer","require_utils","react","import_jsx_runtime","MOBILE_QUERY","DEFAULT_SUPPORT_URL","ALLOWED_SUPPORT_DOMAINS","validateSupportUrl","trimmed","url","parsed","hostname","normalizeBaseUrl","validated","sanitizeCreator","creatorId","buildPageUrl","supportUrl","buildEmbedUrl","getInitialIsMobile","useIsMobile","isMobile","setIsMobile","mediaQuery","onChange","event","SupportFab","buttonProps","isControlled","open","internalOpen","setInternalOpen","defaultOpen","isOpen","setOpen","nextOpen","onOpenChange","pageUrl","embedUrl","panelBody","iframeTitle","trigger","positionClassName","type","buttonClassName","className","onClick","panelClassName","title","description"],"sources":["../packages/ui-web/src/support-fab.tsx"],"sourcesContent":["'use client';\n\nimport { Coffee, ExternalLink } from 'lucide-react';\nimport * as React from 'react';\n\nimport { Button } from './button';\nimport { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from './dialog';\nimport { Drawer, DrawerContent, DrawerDescription, DrawerHeader, DrawerTitle } from './drawer';\nimport { cn } from './lib/utils';\n\nconst MOBILE_QUERY = '(max-width: 767px)';\nconst DEFAULT_SUPPORT_URL = 'https://www.buymeacoffee.com';\nconst ALLOWED_SUPPORT_DOMAINS = new Set(['buymeacoffee.com', 'www.buymeacoffee.com']);\n\nconst validateSupportUrl = (url: string) => {\n const trimmed = url.trim();\n\n try {\n const parsed = new URL(trimmed);\n const hostname = parsed.hostname.toLowerCase();\n\n if (parsed.protocol !== 'https:' || !ALLOWED_SUPPORT_DOMAINS.has(hostname)) {\n console.warn(`Invalid supportUrl: ${url}. Falling back to default.`);\n return DEFAULT_SUPPORT_URL;\n }\n\n return trimmed;\n } catch {\n console.warn(`Invalid supportUrl: ${url}. Falling back to default.`);\n return DEFAULT_SUPPORT_URL;\n }\n};\n\nconst normalizeBaseUrl = (url: string) => {\n const validated = validateSupportUrl(url);\n return validated.endsWith('/') ? validated.slice(0, -1) : validated;\n};\n\nconst sanitizeCreator = (creatorId: string) => creatorId.trim().replace(/^@+/, '');\n\nconst buildPageUrl = (supportUrl: string, creatorId: string) => {\n const base = normalizeBaseUrl(supportUrl);\n const creator = encodeURIComponent(sanitizeCreator(creatorId));\n return `${base}/${creator}`;\n};\n\nconst buildEmbedUrl = (supportUrl: string, creatorId: string) => {\n const base = normalizeBaseUrl(supportUrl);\n const creator = encodeURIComponent(sanitizeCreator(creatorId));\n return `${base}/widget/page/${creator}`;\n};\n\nconst getInitialIsMobile = () => {\n if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') {\n return false;\n }\n return window.matchMedia(MOBILE_QUERY).matches;\n};\n\nconst useIsMobile = () => {\n const [isMobile, setIsMobile] = React.useState(getInitialIsMobile);\n\n React.useEffect(() => {\n if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') {\n return;\n }\n\n const mediaQuery = window.matchMedia(MOBILE_QUERY);\n const onChange = (event: MediaQueryListEvent) => setIsMobile(event.matches);\n const syncInitialValue = () => {\n setIsMobile(mediaQuery.matches);\n };\n\n syncInitialValue();\n mediaQuery.addEventListener('change', onChange);\n\n return () => {\n mediaQuery.removeEventListener('change', onChange);\n };\n }, []);\n\n return isMobile;\n};\n\nexport interface SupportFabProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'onChange'> {\n supportUrl?: string;\n creatorId: string;\n title?: string;\n description?: string;\n iframeTitle?: string;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n positionClassName?: string;\n buttonClassName?: string;\n panelClassName?: string;\n}\n\nexport function SupportFab({\n supportUrl = DEFAULT_SUPPORT_URL,\n creatorId,\n title = 'Buy me a coffee',\n description = 'Support the project directly from this panel.',\n iframeTitle = 'Buy Me a Coffee support form',\n open,\n defaultOpen = false,\n onOpenChange,\n positionClassName,\n buttonClassName,\n panelClassName,\n className,\n type,\n onClick,\n ...buttonProps\n}: SupportFabProps) {\n const isMobile = useIsMobile();\n const isControlled = open !== undefined;\n const [internalOpen, setInternalOpen] = React.useState(defaultOpen);\n const isOpen = isControlled ? open : internalOpen;\n\n const setOpen = React.useCallback(\n (nextOpen: boolean) => {\n if (!isControlled) {\n setInternalOpen(nextOpen);\n }\n onOpenChange?.(nextOpen);\n },\n [isControlled, onOpenChange],\n );\n\n const pageUrl = React.useMemo(() => buildPageUrl(supportUrl, creatorId), [creatorId, supportUrl]);\n const embedUrl = React.useMemo(() => buildEmbedUrl(supportUrl, creatorId), [creatorId, supportUrl]);\n\n const panelBody = (\n <div className=\"flex max-h-[75vh] flex-col gap-3\">\n <div className=\"overflow-hidden rounded-md border\">\n <iframe\n title={iframeTitle}\n src={embedUrl}\n className=\"h-[560px] w-full border-0\"\n loading=\"lazy\"\n referrerPolicy=\"strict-origin-when-cross-origin\"\n />\n </div>\n <div className=\"text-muted-foreground flex items-center justify-between gap-2 text-xs\">\n <span>If the embedded checkout is unavailable, open the support page directly.</span>\n <a\n href={pageUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"text-foreground inline-flex items-center gap-1 font-medium underline underline-offset-2\"\n >\n Open Buy Me a Coffee\n <ExternalLink className=\"h-3.5 w-3.5\" />\n </a>\n </div>\n </div>\n );\n\n const trigger = (\n <div className={cn('fixed right-6 bottom-6 z-50', positionClassName)}>\n <Button\n aria-label=\"Support this project\"\n type={type ?? 'button'}\n className={cn(\n 'inline-flex h-14 w-14 items-center justify-center rounded-full border border-black/15 bg-[#ffdd00] text-black shadow-[0_16px_36px_-18px_rgba(0,0,0,0.8)] transition hover:-translate-y-0.5 hover:scale-105 hover:bg-[#ffe347] focus-visible:ring-2 focus-visible:ring-offset-2 active:translate-y-0 active:scale-95',\n buttonClassName,\n className,\n )}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) {\n setOpen(true);\n }\n }}\n {...buttonProps}\n >\n <Coffee className=\"h-6 w-6\" />\n <span className=\"sr-only\">Support this project</span>\n </Button>\n </div>\n );\n\n if (isMobile) {\n return (\n <>\n {trigger}\n <Drawer open={isOpen} onOpenChange={setOpen}>\n <DrawerContent className={cn('mx-auto w-full max-w-xl', panelClassName)}>\n <DrawerHeader>\n <DrawerTitle>{title}</DrawerTitle>\n <DrawerDescription>{description}</DrawerDescription>\n </DrawerHeader>\n <div className=\"px-4 pb-4\">{panelBody}</div>\n </DrawerContent>\n </Drawer>\n </>\n );\n }\n\n return (\n <>\n {trigger}\n <Dialog open={isOpen} onOpenChange={setOpen}>\n <DialogContent className={cn('max-w-xl p-5', panelClassName)}>\n <DialogHeader>\n <DialogTitle>{title}</DialogTitle>\n <DialogDescription>{description}</DialogDescription>\n </DialogHeader>\n {panelBody}\n </DialogContent>\n </Dialog>\n </>\n );\n}\n"],"mappings":"A,6UAUMwB,EAAe,qBACfC,EAAsB,+BACtBC,EAA0B,IAAI,IAAI,CAAC,mBAAoB,sBAAsB,CAAC,EAE9EC,EAAsB,GAAgB,CAC1C,IAAMC,EAAUC,EAAI,KAAK,EAEzB,GAAI,CACF,IAAMC,EAAS,IAAI,IAAIF,CAAO,EACxBG,EAAWD,EAAO,SAAS,YAAY,EAO7C,OALIA,EAAO,WAAa,UAAY,CAACJ,EAAwB,IAAIK,CAAQ,GACvE,QAAQ,KAAK,uBAAuBF,EAAI,2BAA2B,EAC5DJ,GAGFG,CACT,MAAQ,CAEN,OADA,QAAQ,KAAK,uBAAuBC,EAAI,2BAA2B,EAC5DJ,CACT,CACF,EAEMO,EAAoB,GAAgB,CACxC,IAAMC,EAAYN,EAAmBE,CAAG,EACxC,OAAOI,EAAU,SAAS,GAAG,EAAIA,EAAU,MAAM,EAAG,EAAE,EAAIA,CAC5D,EAEMC,EAAmB,GAAsBC,EAAU,KAAK,CAAC,CAAC,QAAQ,MAAO,EAAE,EAE3EC,GAAgB,EAAoB,IAGjC,GAFMJ,EAAiBK,CAEpB,EAAK,GADC,mBAAmBH,EAAgBC,CAAS,CAC1C,IAGdG,GAAiB,EAAoB,IAGlC,GAFMN,EAAiBK,CAEpB,EAAK,eADC,mBAAmBH,EAAgBC,CAAS,CAC9B,IAG1BI,MACA,OAAO,OAAW,KAAe,OAAO,OAAO,YAAe,WACzD,GAEF,OAAO,WAAWf,CAAY,CAAC,CAAC,QAGnCgB,MAAoB,CACxB,GAAM,CAACC,EAAUC,G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SAAoB2D,CAA+B,CAAA,CACvC,CAAA,CAAA,GACd,EAAA9C,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,YAAa,SAAAoC,CAAe,CAAA,CAC9B,C,EACT,CAAA,CACR,CAAA,CAAA,GAKJ,EAAApC,EAAA,KAAA,CAAAlB,EAAAA,SAAA,CAAA,SAAA,CACGwD,GACD,EAAAtC,EAAA,IAAA,CAACZ,EAAAA,OAAD,CAAQ,KAAM0C,EAAQ,aAAcC,EAClC,UAAA,EAAA/B,EAAA,KAAA,CAACX,EAAAA,cAAD,CAAe,UAAWV,EAAAA,EAAG,eAAgBiE,CAAc,EAA3D,SAAA,EACE,EAAA5C,EAAA,KAAA,CAACV,EAAAA,aAAD,CAAA,SAAA,EACE,EAAAU,EAAA,IAAA,CAACT,EAAAA,YAAD,CAAA,SAAcsD,CAAmB,CAAA,GACjC,EAAA7C,EAAA,IAAA,CAACR,EAAAA,kBAAD,CAAA,SAAoBsD,CAA+B,CAAA,CACvC,CAAA,CAAA,EACbV,CACY,C,EACT,CAAA,CACR,CAAA,CAAA,CAEN,C"}
@@ -18,8 +18,8 @@ var g = e(), _ = "(max-width: 767px)", v = "https://www.buymeacoffee.com", y = /
18
18
  }, x = (e) => {
19
19
  let t = b(e);
20
20
  return t.endsWith("/") ? t.slice(0, -1) : t;
21
- }, S = (e) => e.trim().replace(/^@+/, ""), C = (e, t) => `${x(e)}/${encodeURIComponent(S(t))}`, w = (e, t) => `${x(e)}/widget/page/${encodeURIComponent(S(t))}`, T = () => {
22
- let [e, t] = h.useState(() => typeof window > "u" || typeof window.matchMedia != "function" ? !1 : window.matchMedia(_).matches);
21
+ }, S = (e) => e.trim().replace(/^@+/, ""), C = (e, t) => `${x(e)}/${encodeURIComponent(S(t))}`, w = (e, t) => `${x(e)}/widget/page/${encodeURIComponent(S(t))}`, T = () => typeof window > "u" || typeof window.matchMedia != "function" ? !1 : window.matchMedia(_).matches, E = () => {
22
+ let [e, t] = h.useState(T);
23
23
  return h.useEffect(() => {
24
24
  if (typeof window > "u" || typeof window.matchMedia != "function") return;
25
25
  let e = window.matchMedia(_), n = (e) => t(e.matches);
@@ -28,8 +28,8 @@ var g = e(), _ = "(max-width: 767px)", v = "https://www.buymeacoffee.com", y = /
28
28
  };
29
29
  }, []), e;
30
30
  };
31
- function E({ supportUrl: e = v, creatorId: _, title: y = "Buy me a coffee", description: b = "Support the project directly from this panel.", iframeTitle: x = "Buy Me a Coffee support form", open: S, defaultOpen: E = !1, onOpenChange: D, positionClassName: O, buttonClassName: k, panelClassName: A, className: j, type: M, onClick: N, ...P }) {
32
- let F = T(), I = S !== void 0, [L, R] = h.useState(E), z = I ? S : L, B = h.useCallback((e) => {
31
+ function D({ supportUrl: e = v, creatorId: _, title: y = "Buy me a coffee", description: b = "Support the project directly from this panel.", iframeTitle: x = "Buy Me a Coffee support form", open: S, defaultOpen: T = !1, onOpenChange: D, positionClassName: O, buttonClassName: k, panelClassName: A, className: j, type: M, onClick: N, ...P }) {
32
+ let F = E(), I = S !== void 0, [L, R] = h.useState(T), z = I ? S : L, B = h.useCallback((e) => {
33
33
  I || R(e), D?.(e);
34
34
  }, [I, D]), V = h.useMemo(() => C(e, _), [_, e]), H = h.useMemo(() => w(e, _), [_, e]), U = /* @__PURE__ */ (0, g.jsxs)("div", {
35
35
  className: "flex max-h-[75vh] flex-col gap-3",
@@ -87,6 +87,6 @@ function E({ supportUrl: e = v, creatorId: _, title: y = "Buy me a coffee", desc
87
87
  })
88
88
  })] });
89
89
  }
90
- export { E as SupportFab };
90
+ export { D as SupportFab };
91
91
 
92
92
  //# sourceMappingURL=support-fab.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"support-fab.mjs","names":["React","_Fragment","require_jsx_runtime","Coffee","ExternalLink","cn","React$1","import_jsx_runtime","MOBILE_QUERY","DEFAULT_SUPPORT_URL","ALLOWED_SUPPORT_DOMAINS","validateSupportUrl","trimmed","url","parsed","hostname","normalizeBaseUrl","validated","sanitizeCreator","creatorId","buildPageUrl","supportUrl","buildEmbedUrl","useIsMobile","isMobile","setIsMobile","mediaQuery","onChange","event","SupportFab","buttonProps","isControlled","open","internalOpen","setInternalOpen","defaultOpen","isOpen","setOpen","nextOpen","onOpenChange","pageUrl","embedUrl","panelBody","iframeTitle","trigger","positionClassName","Button","type","buttonClassName","className","onClick","Drawer","DrawerContent","panelClassName","DrawerHeader","DrawerTitle","title","DrawerDescription","description","Dialog","DialogContent","DialogHeader","DialogTitle","DialogDescription"],"sources":["../packages/ui-web/src/support-fab.tsx"],"sourcesContent":["'use client';\n\nimport { Coffee, ExternalLink } from 'lucide-react';\nimport * as React from 'react';\n\nimport { Button } from './button';\nimport { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from './dialog';\nimport { Drawer, DrawerContent, DrawerDescription, DrawerHeader, DrawerTitle } from './drawer';\nimport { cn } from './lib/utils';\n\nconst MOBILE_QUERY = '(max-width: 767px)';\nconst DEFAULT_SUPPORT_URL = 'https://www.buymeacoffee.com';\nconst ALLOWED_SUPPORT_DOMAINS = new Set(['buymeacoffee.com', 'www.buymeacoffee.com']);\n\nconst validateSupportUrl = (url: string) => {\n const trimmed = url.trim();\n\n try {\n const parsed = new URL(trimmed);\n const hostname = parsed.hostname.toLowerCase();\n\n if (parsed.protocol !== 'https:' || !ALLOWED_SUPPORT_DOMAINS.has(hostname)) {\n console.warn(`Invalid supportUrl: ${url}. Falling back to default.`);\n return DEFAULT_SUPPORT_URL;\n }\n\n return trimmed;\n } catch {\n console.warn(`Invalid supportUrl: ${url}. Falling back to default.`);\n return DEFAULT_SUPPORT_URL;\n }\n};\n\nconst normalizeBaseUrl = (url: string) => {\n const validated = validateSupportUrl(url);\n return validated.endsWith('/') ? validated.slice(0, -1) : validated;\n};\n\nconst sanitizeCreator = (creatorId: string) => creatorId.trim().replace(/^@+/, '');\n\nconst buildPageUrl = (supportUrl: string, creatorId: string) => {\n const base = normalizeBaseUrl(supportUrl);\n const creator = encodeURIComponent(sanitizeCreator(creatorId));\n return `${base}/${creator}`;\n};\n\nconst buildEmbedUrl = (supportUrl: string, creatorId: string) => {\n const base = normalizeBaseUrl(supportUrl);\n const creator = encodeURIComponent(sanitizeCreator(creatorId));\n return `${base}/widget/page/${creator}`;\n};\n\nconst useIsMobile = () => {\n const getInitial = () => {\n if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') {\n return false;\n }\n return window.matchMedia(MOBILE_QUERY).matches;\n };\n\n const [isMobile, setIsMobile] = React.useState(getInitial);\n\n React.useEffect(() => {\n if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') {\n return;\n }\n\n const mediaQuery = window.matchMedia(MOBILE_QUERY);\n const onChange = (event: MediaQueryListEvent) => setIsMobile(event.matches);\n const syncInitialValue = () => {\n setIsMobile(mediaQuery.matches);\n };\n\n syncInitialValue();\n mediaQuery.addEventListener('change', onChange);\n\n return () => {\n mediaQuery.removeEventListener('change', onChange);\n };\n }, []);\n\n return isMobile;\n};\n\nexport interface SupportFabProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'onChange'> {\n supportUrl?: string;\n creatorId: string;\n title?: string;\n description?: string;\n iframeTitle?: string;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n positionClassName?: string;\n buttonClassName?: string;\n panelClassName?: string;\n}\n\nexport function SupportFab({\n supportUrl = DEFAULT_SUPPORT_URL,\n creatorId,\n title = 'Buy me a coffee',\n description = 'Support the project directly from this panel.',\n iframeTitle = 'Buy Me a Coffee support form',\n open,\n defaultOpen = false,\n onOpenChange,\n positionClassName,\n buttonClassName,\n panelClassName,\n className,\n type,\n onClick,\n ...buttonProps\n}: SupportFabProps) {\n const isMobile = useIsMobile();\n const isControlled = open !== undefined;\n const [internalOpen, setInternalOpen] = React.useState(defaultOpen);\n const isOpen = isControlled ? open : internalOpen;\n\n const setOpen = React.useCallback(\n (nextOpen: boolean) => {\n if (!isControlled) {\n setInternalOpen(nextOpen);\n }\n onOpenChange?.(nextOpen);\n },\n [isControlled, onOpenChange],\n );\n\n const pageUrl = React.useMemo(() => buildPageUrl(supportUrl, creatorId), [creatorId, supportUrl]);\n const embedUrl = React.useMemo(() => buildEmbedUrl(supportUrl, creatorId), [creatorId, supportUrl]);\n\n const panelBody = (\n <div className=\"flex max-h-[75vh] flex-col gap-3\">\n <div className=\"overflow-hidden rounded-md border\">\n <iframe\n title={iframeTitle}\n src={embedUrl}\n className=\"h-[560px] w-full border-0\"\n loading=\"lazy\"\n referrerPolicy=\"strict-origin-when-cross-origin\"\n />\n </div>\n <div className=\"text-muted-foreground flex items-center justify-between gap-2 text-xs\">\n <span>If the embedded checkout is unavailable, open the support page directly.</span>\n <a\n href={pageUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"text-foreground inline-flex items-center gap-1 font-medium underline underline-offset-2\"\n >\n Open Buy Me a Coffee\n <ExternalLink className=\"h-3.5 w-3.5\" />\n </a>\n </div>\n </div>\n );\n\n const trigger = (\n <div className={cn('fixed right-6 bottom-6 z-50', positionClassName)}>\n <Button\n aria-label=\"Support this project\"\n type={type ?? 'button'}\n className={cn(\n 'inline-flex h-14 w-14 items-center justify-center rounded-full border border-black/15 bg-[#ffdd00] text-black shadow-[0_16px_36px_-18px_rgba(0,0,0,0.8)] transition hover:-translate-y-0.5 hover:scale-105 hover:bg-[#ffe347] focus-visible:ring-2 focus-visible:ring-offset-2 active:translate-y-0 active:scale-95',\n buttonClassName,\n className,\n )}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) {\n setOpen(true);\n }\n }}\n {...buttonProps}\n >\n <Coffee className=\"h-6 w-6\" />\n <span className=\"sr-only\">Support this project</span>\n </Button>\n </div>\n );\n\n if (isMobile) {\n return (\n <>\n {trigger}\n <Drawer open={isOpen} onOpenChange={setOpen}>\n <DrawerContent className={cn('mx-auto w-full max-w-xl', panelClassName)}>\n <DrawerHeader>\n <DrawerTitle>{title}</DrawerTitle>\n <DrawerDescription>{description}</DrawerDescription>\n </DrawerHeader>\n <div className=\"px-4 pb-4\">{panelBody}</div>\n </DrawerContent>\n </Drawer>\n </>\n );\n }\n\n return (\n <>\n {trigger}\n <Dialog open={isOpen} onOpenChange={setOpen}>\n <DialogContent className={cn('max-w-xl p-5', panelClassName)}>\n <DialogHeader>\n <DialogTitle>{title}</DialogTitle>\n <DialogDescription>{description}</DialogDescription>\n </DialogHeader>\n {panelBody}\n </DialogContent>\n </Dialog>\n </>\n );\n}\n"],"mappings":";;;;;;;;;A,aAUMQ,IAAe,sBACfC,IAAsB,gCACtBC,oBAA0B,IAAI,IAAI,CAAC,oBAAoB,sBAAsB,CAAC,GAE9EC,KAAsB,MAAgB;CAC1C,IAAMC,IAAUC,EAAI,KAAK;CAEzB,IAAI;EACF,IAAMC,IAAS,IAAI,IAAIF,CAAO,GACxBG,IAAWD,EAAO,SAAS,YAAY;EAO7C,OALIA,EAAO,aAAa,YAAY,CAACJ,EAAwB,IAAIK,CAAQ,KACvE,QAAQ,KAAK,uBAAuBF,EAAI,2BAA2B,GAC5DJ,KAGFG;CACT,QAAQ;EAEN,OADA,QAAQ,KAAK,uBAAuBC,EAAI,2BAA2B,GAC5DJ;CACT;AACF,GAEMO,KAAoB,MAAgB;CACxC,IAAMC,IAAYN,EAAmBE,CAAG;CACxC,OAAOI,EAAU,SAAS,GAAG,IAAIA,EAAU,MAAM,GAAG,EAAE,IAAIA;AAC5D,GAEMC,KAAmB,MAAsBC,EAAU,KAAK,CAAC,CAAC,QAAQ,OAAO,EAAE,GAE3EC,KAAgB,GAAoB,MAGjC,GAFMJ,EAAiBK,CAEpB,EAAK,GADC,mBAAmBH,EAAgBC,CAAS,CAC1C,KAGdG,KAAiB,GAAoB,MAGlC,GAFMN,EAAiBK,CAEpB,EAAK,eADC,mBAAmBH,EAAgBC,CAAS,CAC9B,KAG1BI,UAAoB;CAQxB,IAAM,CAACC,GAAUC,KAAezB,EAAM,eANhC,OAAO,SAAW,OAAe,OAAO,OAAO,cAAe,aACzD,KAEF,OAAO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A,GACjC,iBAAA,GAAAjD,EAAA,IAAA,CAACkD,GAAD,EAAA,UAAoBC,EAA+B,CAAA,CACvC,EAAA,CAAA,GACd,iBAAA,GAAAnD,EAAA,IAAA,CAAC,OAAD;IAAK,WAAU;IAAa,UAAAmC;GAAe,CAAA,CAC9B;;CACT,CAAA,CACR,EAAA,CAAA,IAKJ,iBAAA,GAAAnC,EAAA,KAAA,CAAAN,EAAAA,UAAA,EAAA,UAAA,CACG2C,GACD,iBAAA,GAAArC,EAAA,IAAA,CAACoD,GAAD;EAAQ,MAAMvB;EAAQ,cAAcC;EAClC,UAAA,iBAAA,GAAA9B,EAAA,KAAA,CAACqD,GAAD;GAAe,WAAWvD,EAAG,gBAAgBgD,CAAc;GAA3D,UAAA,CACE,iBAAA,GAAA9C,EAAA,KAAA,CAACsD,GAAD,EAAA,UAAA,CACE,iBAAA,GAAAtD,EAAA,IAAA,CAACuD,GAAD,EAAA,UAAcN,EAAmB,CAAA,GACjC,iBAAA,GAAAjD,EAAA,IAAA,CAACwD,GAAD,EAAA,UAAoBL,EAA+B,CAAA,CACvC,EAAA,CAAA,GACbhB,CACY;;CACT,CAAA,CACR,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"support-fab.mjs","names":["React","_Fragment","require_jsx_runtime","Coffee","ExternalLink","cn","React$1","import_jsx_runtime","MOBILE_QUERY","DEFAULT_SUPPORT_URL","ALLOWED_SUPPORT_DOMAINS","validateSupportUrl","trimmed","url","parsed","hostname","normalizeBaseUrl","validated","sanitizeCreator","creatorId","buildPageUrl","supportUrl","buildEmbedUrl","getInitialIsMobile","useIsMobile","isMobile","setIsMobile","mediaQuery","onChange","event","SupportFab","buttonProps","isControlled","open","internalOpen","setInternalOpen","defaultOpen","isOpen","setOpen","nextOpen","onOpenChange","pageUrl","embedUrl","panelBody","iframeTitle","trigger","positionClassName","Button","type","buttonClassName","className","onClick","Drawer","DrawerContent","panelClassName","DrawerHeader","DrawerTitle","title","DrawerDescription","description","Dialog","DialogContent","DialogHeader","DialogTitle","DialogDescription"],"sources":["../packages/ui-web/src/support-fab.tsx"],"sourcesContent":["'use client';\n\nimport { Coffee, ExternalLink } from 'lucide-react';\nimport * as React from 'react';\n\nimport { Button } from './button';\nimport { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from './dialog';\nimport { Drawer, DrawerContent, DrawerDescription, DrawerHeader, DrawerTitle } from './drawer';\nimport { cn } from './lib/utils';\n\nconst MOBILE_QUERY = '(max-width: 767px)';\nconst DEFAULT_SUPPORT_URL = 'https://www.buymeacoffee.com';\nconst ALLOWED_SUPPORT_DOMAINS = new Set(['buymeacoffee.com', 'www.buymeacoffee.com']);\n\nconst validateSupportUrl = (url: string) => {\n const trimmed = url.trim();\n\n try {\n const parsed = new URL(trimmed);\n const hostname = parsed.hostname.toLowerCase();\n\n if (parsed.protocol !== 'https:' || !ALLOWED_SUPPORT_DOMAINS.has(hostname)) {\n console.warn(`Invalid supportUrl: ${url}. Falling back to default.`);\n return DEFAULT_SUPPORT_URL;\n }\n\n return trimmed;\n } catch {\n console.warn(`Invalid supportUrl: ${url}. Falling back to default.`);\n return DEFAULT_SUPPORT_URL;\n }\n};\n\nconst normalizeBaseUrl = (url: string) => {\n const validated = validateSupportUrl(url);\n return validated.endsWith('/') ? validated.slice(0, -1) : validated;\n};\n\nconst sanitizeCreator = (creatorId: string) => creatorId.trim().replace(/^@+/, '');\n\nconst buildPageUrl = (supportUrl: string, creatorId: string) => {\n const base = normalizeBaseUrl(supportUrl);\n const creator = encodeURIComponent(sanitizeCreator(creatorId));\n return `${base}/${creator}`;\n};\n\nconst buildEmbedUrl = (supportUrl: string, creatorId: string) => {\n const base = normalizeBaseUrl(supportUrl);\n const creator = encodeURIComponent(sanitizeCreator(creatorId));\n return `${base}/widget/page/${creator}`;\n};\n\nconst getInitialIsMobile = () => {\n if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') {\n return false;\n }\n return window.matchMedia(MOBILE_QUERY).matches;\n};\n\nconst useIsMobile = () => {\n const [isMobile, setIsMobile] = React.useState(getInitialIsMobile);\n\n React.useEffect(() => {\n if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') {\n return;\n }\n\n const mediaQuery = window.matchMedia(MOBILE_QUERY);\n const onChange = (event: MediaQueryListEvent) => setIsMobile(event.matches);\n const syncInitialValue = () => {\n setIsMobile(mediaQuery.matches);\n };\n\n syncInitialValue();\n mediaQuery.addEventListener('change', onChange);\n\n return () => {\n mediaQuery.removeEventListener('change', onChange);\n };\n }, []);\n\n return isMobile;\n};\n\nexport interface SupportFabProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'onChange'> {\n supportUrl?: string;\n creatorId: string;\n title?: string;\n description?: string;\n iframeTitle?: string;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n positionClassName?: string;\n buttonClassName?: string;\n panelClassName?: string;\n}\n\nexport function SupportFab({\n supportUrl = DEFAULT_SUPPORT_URL,\n creatorId,\n title = 'Buy me a coffee',\n description = 'Support the project directly from this panel.',\n iframeTitle = 'Buy Me a Coffee support form',\n open,\n defaultOpen = false,\n onOpenChange,\n positionClassName,\n buttonClassName,\n panelClassName,\n className,\n type,\n onClick,\n ...buttonProps\n}: SupportFabProps) {\n const isMobile = useIsMobile();\n const isControlled = open !== undefined;\n const [internalOpen, setInternalOpen] = React.useState(defaultOpen);\n const isOpen = isControlled ? open : internalOpen;\n\n const setOpen = React.useCallback(\n (nextOpen: boolean) => {\n if (!isControlled) {\n setInternalOpen(nextOpen);\n }\n onOpenChange?.(nextOpen);\n },\n [isControlled, onOpenChange],\n );\n\n const pageUrl = React.useMemo(() => buildPageUrl(supportUrl, creatorId), [creatorId, supportUrl]);\n const embedUrl = React.useMemo(() => buildEmbedUrl(supportUrl, creatorId), [creatorId, supportUrl]);\n\n const panelBody = (\n <div className=\"flex max-h-[75vh] flex-col gap-3\">\n <div className=\"overflow-hidden rounded-md border\">\n <iframe\n title={iframeTitle}\n src={embedUrl}\n className=\"h-[560px] w-full border-0\"\n loading=\"lazy\"\n referrerPolicy=\"strict-origin-when-cross-origin\"\n />\n </div>\n <div className=\"text-muted-foreground flex items-center justify-between gap-2 text-xs\">\n <span>If the embedded checkout is unavailable, open the support page directly.</span>\n <a\n href={pageUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"text-foreground inline-flex items-center gap-1 font-medium underline underline-offset-2\"\n >\n Open Buy Me a Coffee\n <ExternalLink className=\"h-3.5 w-3.5\" />\n </a>\n </div>\n </div>\n );\n\n const trigger = (\n <div className={cn('fixed right-6 bottom-6 z-50', positionClassName)}>\n <Button\n aria-label=\"Support this project\"\n type={type ?? 'button'}\n className={cn(\n 'inline-flex h-14 w-14 items-center justify-center rounded-full border border-black/15 bg-[#ffdd00] text-black shadow-[0_16px_36px_-18px_rgba(0,0,0,0.8)] transition hover:-translate-y-0.5 hover:scale-105 hover:bg-[#ffe347] focus-visible:ring-2 focus-visible:ring-offset-2 active:translate-y-0 active:scale-95',\n buttonClassName,\n className,\n )}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) {\n setOpen(true);\n }\n }}\n {...buttonProps}\n >\n <Coffee className=\"h-6 w-6\" />\n <span className=\"sr-only\">Support this project</span>\n </Button>\n </div>\n );\n\n if (isMobile) {\n return (\n <>\n {trigger}\n <Drawer open={isOpen} onOpenChange={setOpen}>\n <DrawerContent className={cn('mx-auto w-full max-w-xl', panelClassName)}>\n <DrawerHeader>\n <DrawerTitle>{title}</DrawerTitle>\n <DrawerDescription>{description}</DrawerDescription>\n </DrawerHeader>\n <div className=\"px-4 pb-4\">{panelBody}</div>\n </DrawerContent>\n </Drawer>\n </>\n );\n }\n\n return (\n <>\n {trigger}\n <Dialog open={isOpen} onOpenChange={setOpen}>\n <DialogContent className={cn('max-w-xl p-5', panelClassName)}>\n <DialogHeader>\n <DialogTitle>{title}</DialogTitle>\n <DialogDescription>{description}</DialogDescription>\n </DialogHeader>\n {panelBody}\n </DialogContent>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KAAA,CAAAN,EAAAA,UAAA,EAAA,UAAA,CACG4C,GACD,iBAAA,GAAAtC,EAAA,IAAA,CAACqD,GAAD;EAAQ,MAAMvB;EAAQ,cAAcC;EAClC,UAAA,iBAAA,GAAA/B,EAAA,KAAA,CAACsD,GAAD;GAAe,WAAWxD,EAAG,gBAAgBiD,CAAc;GAA3D,UAAA,CACE,iBAAA,GAAA/C,EAAA,KAAA,CAACuD,GAAD,EAAA,UAAA,CACE,iBAAA,GAAAvD,EAAA,IAAA,CAACwD,GAAD,EAAA,UAAcN,EAAmB,CAAA,GACjC,iBAAA,GAAAlD,EAAA,IAAA,CAACyD,GAAD,EAAA,UAAoBL,EAA+B,CAAA,CACvC,EAAA,CAAA,GACbhB,CACY;;CACT,CAAA,CACR,EAAA,CAAA;AAEN"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gv-tech/design-system",
3
- "version": "2.29.4",
3
+ "version": "2.30.0",
4
4
  "description": "Garcia Ventures react design system",
5
5
  "license": "MIT",
6
6
  "author": "Eric N. Garcia <eng618@garciaericn.com>",
@@ -135,7 +135,7 @@
135
135
  },
136
136
  "peerDependencies": {
137
137
  "lucide-react-native": "^1.8.0",
138
- "nativewind": "^5.0.0-preview.4",
138
+ "nativewind": "5.0.0-rc.1",
139
139
  "next-themes": "^0.4.0",
140
140
  "prop-types": "^15.8.1",
141
141
  "react": "^18 || ^19",