@spark-ui/components 14.1.2 → 15.1.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/FormFieldRequiredIndicator-CHfcoT2y.js +2 -0
- package/dist/FormFieldRequiredIndicator-CHfcoT2y.js.map +1 -0
- package/dist/FormFieldRequiredIndicator-DTnCGiX2.mjs +13 -0
- package/dist/FormFieldRequiredIndicator-DTnCGiX2.mjs.map +1 -0
- package/dist/dialog/Dialog.d.ts +1 -0
- package/dist/dialog/index.js +1 -1
- package/dist/dialog/index.js.map +1 -1
- package/dist/dialog/index.mjs +19 -18
- package/dist/dialog/index.mjs.map +1 -1
- package/dist/form-field/index.js +1 -1
- package/dist/form-field/index.js.map +1 -1
- package/dist/form-field/index.mjs +76 -81
- package/dist/form-field/index.mjs.map +1 -1
- package/dist/slider/Slider.d.ts +8 -13
- package/dist/slider/SliderContext.d.ts +7 -1
- package/dist/slider/SliderControl.d.ts +7 -0
- package/dist/slider/SliderIndicator.d.ts +7 -0
- package/dist/slider/SliderLabel.d.ts +13 -0
- package/dist/slider/SliderMaxValue.d.ts +6 -0
- package/dist/slider/SliderMinValue.d.ts +6 -0
- package/dist/slider/SliderThumb.d.ts +4 -11
- package/dist/slider/SliderThumbContext.d.ts +5 -0
- package/dist/slider/SliderTrack.d.ts +4 -11
- package/dist/slider/SliderTrack.styles.d.ts +1 -4
- package/dist/slider/SliderValue.d.ts +10 -0
- package/dist/slider/index.d.mts +13 -1
- package/dist/slider/index.d.ts +13 -1
- package/dist/slider/index.js +1 -1
- package/dist/slider/index.js.map +1 -1
- package/dist/slider/index.mjs +290 -127
- package/dist/slider/index.mjs.map +1 -1
- package/dist/slider/useSliderValueBoundaries.d.ts +12 -0
- package/dist/toast/index.js +1 -1
- package/dist/toast/index.js.map +1 -1
- package/dist/toast/index.mjs +154 -129
- package/dist/toast/index.mjs.map +1 -1
- package/dist/toast/types.d.ts +4 -1
- package/package.json +4 -4
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),a=require("class-variance-authority"),c=require("./label/index.js"),e=({className:r,ref:i,...s})=>t.jsx(c.Label.RequiredIndicator,{ref:i,className:a.cx("ml-sm",r),...s});e.displayName="FormField.RequiredIndicator";exports.FormFieldRequiredIndicator=e;
|
|
2
|
+
//# sourceMappingURL=FormFieldRequiredIndicator-CHfcoT2y.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormFieldRequiredIndicator-CHfcoT2y.js","sources":["../src/form-field/FormFieldRequiredIndicator.tsx"],"sourcesContent":["import { cx } from 'class-variance-authority'\nimport { Ref } from 'react'\n\nimport { Label, LabelRequiredIndicatorProps } from '../label'\n\nexport type FormFieldRequiredIndicatorProps = LabelRequiredIndicatorProps & {\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldRequiredIndicator = ({\n className,\n ref,\n ...props\n}: FormFieldRequiredIndicatorProps) => {\n return <Label.RequiredIndicator ref={ref} className={cx('ml-sm', className)} {...props} />\n}\n\nFormFieldRequiredIndicator.displayName = 'FormField.RequiredIndicator'\n"],"names":["FormFieldRequiredIndicator","className","ref","props","jsx","Label","cx"],"mappings":"sHASaA,EAA6B,CAAC,CACzC,UAAAC,EACA,IAAAC,EACA,GAAGC,CACL,IACSC,MAACC,EAAAA,MAAM,kBAAN,CAAwB,IAAAH,EAAU,UAAWI,EAAAA,GAAG,QAASL,CAAS,EAAI,GAAGE,CAAA,CAAO,EAG1FH,EAA2B,YAAc"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { cx as m } from "class-variance-authority";
|
|
3
|
+
import { Label as a } from "./label/index.mjs";
|
|
4
|
+
const d = ({
|
|
5
|
+
className: r,
|
|
6
|
+
ref: e,
|
|
7
|
+
...o
|
|
8
|
+
}) => /* @__PURE__ */ i(a.RequiredIndicator, { ref: e, className: m("ml-sm", r), ...o });
|
|
9
|
+
d.displayName = "FormField.RequiredIndicator";
|
|
10
|
+
export {
|
|
11
|
+
d as F
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=FormFieldRequiredIndicator-DTnCGiX2.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormFieldRequiredIndicator-DTnCGiX2.mjs","sources":["../src/form-field/FormFieldRequiredIndicator.tsx"],"sourcesContent":["import { cx } from 'class-variance-authority'\nimport { Ref } from 'react'\n\nimport { Label, LabelRequiredIndicatorProps } from '../label'\n\nexport type FormFieldRequiredIndicatorProps = LabelRequiredIndicatorProps & {\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldRequiredIndicator = ({\n className,\n ref,\n ...props\n}: FormFieldRequiredIndicatorProps) => {\n return <Label.RequiredIndicator ref={ref} className={cx('ml-sm', className)} {...props} />\n}\n\nFormFieldRequiredIndicator.displayName = 'FormField.RequiredIndicator'\n"],"names":["FormFieldRequiredIndicator","className","ref","props","jsx","Label","cx"],"mappings":";;;AASO,MAAMA,IAA6B,CAAC;AAAA,EACzC,WAAAC;AAAA,EACA,KAAAC;AAAA,EACA,GAAGC;AACL,MACS,gBAAAC,EAACC,EAAM,mBAAN,EAAwB,KAAAH,GAAU,WAAWI,EAAG,SAASL,CAAS,GAAI,GAAGE,EAAA,CAAO;AAG1FH,EAA2B,cAAc;"}
|
package/dist/dialog/Dialog.d.ts
CHANGED
|
@@ -28,5 +28,6 @@ export interface DialogProps extends Omit<ComponentProps<typeof BaseDialog.Root>
|
|
|
28
28
|
}
|
|
29
29
|
export declare const Dialog: {
|
|
30
30
|
({ withFade, onOpenChange, ...props }: DialogProps): ReactElement;
|
|
31
|
+
createHandle: typeof BaseDialog.createHandle;
|
|
31
32
|
displayName: string;
|
|
32
33
|
};
|
package/dist/dialog/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),r=require("@base-ui/react/dialog"),d=require("react"),w=require("@spark-ui/hooks/use-merge-refs"),B=require("@spark-ui/hooks/use-scroll-overflow"),n=require("class-variance-authority"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),r=require("@base-ui/react/dialog"),d=require("react"),w=require("@spark-ui/hooks/use-merge-refs"),B=require("@spark-ui/hooks/use-scroll-overflow"),n=require("class-variance-authority"),x=require("../useRenderSlot-DATwjgpo.js"),O=require("@spark-ui/icons/Close"),P=require("../Icon-CF0W0LKr.js"),I=require("../IconButton-D3g86WpZ.js"),T=require("../DialogContent.styles-CziMQtYr.js"),m=d.createContext(null),F=({children:e,withFade:o=!1})=>{const[t,l]=d.useState(!1);return a.jsx(m.Provider,{value:{isFullScreen:t,setIsFullScreen:l,withFade:o},children:e})},f=()=>{const e=d.useContext(m);if(!e)throw Error("useDialog must be used within a Dialog provider");return e},p=({withFade:e=!1,onOpenChange:o,...t})=>{const l=o?(i,s)=>{o(i)}:void 0;return a.jsx(F,{withFade:e,children:a.jsx(r.Dialog.Root,{"data-spark-component":"dialog",onOpenChange:l,...t})})};p.createHandle=r.Dialog.createHandle;p.displayName="Dialog.Root";const y=({children:e,className:o,inset:t=!1,ref:l,...i})=>{const s=d.useRef(null),c=w.useMergeRefs(l,s),{withFade:g}=f(),{overflow:u}=B.useScrollOverflow(s);return a.jsx("div",{"data-spark-component":"dialog-body",ref:c,className:n.cx("focus-visible:u-outline relative grow overflow-y-auto outline-hidden","transition-all duration-300",{"px-xl py-lg":!t},o),style:{...g&&{maskImage:"linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1) 44px, rgba(0, 0, 0, 1) calc(100% - 44px), rgba(0, 0, 0, 0))",maskSize:`100% calc(100% + ${u.top?"0px":"44px"} + ${u.bottom?"0px":"44px"})`,maskPosition:`0 ${u.top?"0px":"-44px"}`}},...i,children:e})};y.displayName="Dialog.Body";const D=({asChild:e=!1,...o})=>{const t=x.useRenderSlot(e,"button");return a.jsx(r.Dialog.Close,{"data-spark-component":"dialog-close",render:t,...o})},b=({"aria-label":e,className:o,size:t="md",intent:l="neutral",design:i="ghost",children:s=a.jsx(O.Close,{}),ref:c,...g})=>a.jsx(D,{"data-spark-component":"dialog-close-button","data-part":"close",ref:c,className:n.cx(["absolute","top-md","right-xl"],o),asChild:!0,...g,children:a.jsx(I.IconButton,{intent:l,size:t,design:i,"aria-label":e,children:a.jsx(P.Icon,{children:s})})}),$=Object.assign(b,{id:"CloseButton"});b.displayName="Dialog.CloseButton";const j=({className:e,isNarrow:o=!1,size:t="md",ref:l,...i})=>{const{setIsFullScreen:s}=f();return d.useEffect(()=>(t==="fullscreen"&&s(!0),()=>s(!1)),[s,t]),a.jsx(r.Dialog.Popup,{ref:l,"data-spark-component":"dialog-content",role:"dialog",className:c=>n.cx(T.dialogContentStyles({isNarrow:o,size:t,className:typeof e=="function"?e(c):e})),...i})};j.displayName="Dialog.Content";const h=e=>a.jsx(r.Dialog.Description,{"data-spark-component":"dialog-description",...e});h.displayName="Dialog.Description";const v=({children:e,className:o,ref:t,...l})=>a.jsx("footer",{"data-spark-component":"dialog-footer",ref:t,className:n.cx(o,["px-xl","py-lg"]),...l,children:e});v.displayName="Dialog.Footer";const N=({children:e,className:o,ref:t,...l})=>a.jsx("header",{"data-spark-component":"dialog-header",ref:t,className:n.cx(o,["px-xl","py-lg"]),...l,children:e});N.displayName="Dialog.Header";const k=({className:e,...o})=>a.jsx(r.Dialog.Backdrop,{"data-spark-component":"dialog-overlay",className:t=>n.cx("z-overlay size-screen fixed inset-0","bg-overlay/dim-1","data-starting-style:animate-fade-in","data-ending-style:animate-fade-out",typeof e=="function"?e(t):e),...o});k.displayName="Dialog.Overlay";const C=({className:e,...o})=>a.jsx(r.Dialog.Portal,{"data-spark-component":"dialog-portal",className:n.cx(e,"z-modal absolute"),...o});C.displayName="Dialog.Portal";const S=({className:e,ref:o,...t})=>a.jsx(r.Dialog.Title,{"data-spark-component":"dialog-title",ref:o,className:n.cx("text-headline-1 text-on-surface","group-has-data-[part=close]:pr-3xl",e),...t});S.displayName="Dialog.Title";const R=({asChild:e=!1,...o})=>{const t=x.useRenderSlot(e,"button");return a.jsx(r.Dialog.Trigger,{"data-spark-component":"dialog-trigger",render:t,...o})};R.displayName="Dialog.Trigger";const q=Object.assign(p,{Trigger:R,Portal:C,Overlay:k,Content:j,Header:N,Body:y,Footer:v,Close:D,CloseButton:$,Title:S,Description:h});q.displayName="Dialog";exports.Dialog=q;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/dialog/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/dialog/DialogContext.tsx","../../src/dialog/Dialog.tsx","../../src/dialog/DialogBody.tsx","../../src/dialog/DialogClose.tsx","../../src/dialog/DialogCloseButton.tsx","../../src/dialog/DialogContent.tsx","../../src/dialog/DialogDescription.tsx","../../src/dialog/DialogFooter.tsx","../../src/dialog/DialogHeader.tsx","../../src/dialog/DialogOverlay.tsx","../../src/dialog/DialogPortal.tsx","../../src/dialog/DialogTitle.tsx","../../src/dialog/DialogTrigger.tsx","../../src/dialog/index.ts"],"sourcesContent":["import { createContext, type ReactNode, useContext, useState } from 'react'\n\nexport interface DialogContextState {\n isFullScreen: boolean\n setIsFullScreen: (value: boolean) => void\n withFade: boolean\n}\n\nconst DialogContext = createContext<DialogContextState | null>(null)\n\nexport const DialogProvider = ({\n children: childrenProp,\n withFade = false,\n}: {\n children: ReactNode\n withFade?: boolean\n}) => {\n const [isFullScreen, setIsFullScreen] = useState(false)\n\n return (\n <DialogContext.Provider\n value={{\n isFullScreen,\n setIsFullScreen,\n withFade,\n }}\n >\n {childrenProp}\n </DialogContext.Provider>\n )\n}\n\nexport const useDialog = () => {\n const context = useContext(DialogContext)\n\n if (!context) {\n throw Error('useDialog must be used within a Dialog provider')\n }\n\n return context\n}\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, type ReactElement } from 'react'\n\nimport { DialogProvider } from './DialogContext'\n\nexport interface DialogProps\n extends Omit<ComponentProps<typeof BaseDialog.Root>, 'onOpenChange' | 'render'> {\n /**\n * Specifies if the dialog is open or not.\n */\n open?: boolean\n /**\n * Default open state.\n */\n defaultOpen?: boolean\n /**\n * Handler executed on every dialog open state change.\n */\n onOpenChange?: (open: boolean) => void\n /**\n * Specifies if the dialog is a modal.\n */\n modal?: boolean\n /**\n * Specifies if the dialog should have a fade animation on its body (in case it is scrollable).\n */\n withFade?: boolean\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n}\n\nexport const Dialog = ({ withFade = false, onOpenChange, ...props }: DialogProps): ReactElement => {\n const handleOpenChange = onOpenChange\n ? (open: boolean, _eventDetails: unknown) => {\n onOpenChange(open)\n }\n : undefined\n\n return (\n <DialogProvider withFade={withFade}>\n <BaseDialog.Root data-spark-component=\"dialog\" onOpenChange={handleOpenChange} {...props} />\n </DialogProvider>\n )\n}\n\nDialog.displayName = 'Dialog.Root'\n","import { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\nimport { useScrollOverflow } from '@spark-ui/hooks/use-scroll-overflow'\nimport { cx } from 'class-variance-authority'\nimport { type ReactElement, type ReactNode, Ref, useRef } from 'react'\n\nimport { useDialog } from './DialogContext'\n\nexport interface BodyProps {\n children: ReactNode\n className?: string\n tabIndex?: number\n ref?: Ref<HTMLDivElement>\n inset?: boolean\n}\n\nexport const Body = ({\n children,\n className,\n inset = false,\n ref: forwardedRef,\n ...rest\n}: BodyProps): ReactElement => {\n const scrollAreaRef = useRef<HTMLDivElement>(null)\n const ref = useMergeRefs(forwardedRef, scrollAreaRef)\n\n const { withFade } = useDialog()\n\n const { overflow } = useScrollOverflow(scrollAreaRef)\n\n return (\n <div\n data-spark-component=\"dialog-body\"\n ref={ref}\n className={cx(\n 'focus-visible:u-outline relative grow overflow-y-auto outline-hidden',\n 'transition-all duration-300',\n {\n ['px-xl py-lg']: !inset,\n },\n className\n )}\n style={{\n ...(withFade && {\n maskImage:\n 'linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1) 44px, rgba(0, 0, 0, 1) calc(100% - 44px), rgba(0, 0, 0, 0))',\n maskSize: `100% calc(100% + ${overflow.top ? '0px' : '44px'} + ${overflow.bottom ? '0px' : '44px'})`,\n maskPosition: `0 ${overflow.top ? '0px' : '-44px'}`,\n }),\n }}\n {...rest}\n >\n {children}\n </div>\n )\n}\n\nBody.displayName = 'Dialog.Body'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, Ref } from 'react'\n\nimport { useRenderSlot } from '../drawer/useRenderSlot'\n\nexport interface CloseProps extends Omit<ComponentProps<typeof BaseDialog.Close>, 'render'> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n ref?: Ref<HTMLButtonElement>\n}\n\nexport const Close = ({ asChild = false, ...props }: CloseProps) => {\n const renderSlot = useRenderSlot(asChild, 'button')\n\n return <BaseDialog.Close data-spark-component=\"dialog-close\" render={renderSlot} {...props} />\n}\n","import { Close as CloseSVG } from '@spark-ui/icons/Close'\nimport { cx } from 'class-variance-authority'\n\nimport { Icon } from '../icon'\nimport { IconButton, type IconButtonProps } from '../icon-button'\nimport { Close, CloseProps } from './DialogClose'\n\nexport type CloseButtonProps = CloseProps &\n Pick<IconButtonProps, 'size' | 'intent' | 'design' | 'aria-label'>\n\nconst Root = ({\n 'aria-label': ariaLabel,\n className,\n size = 'md',\n intent = 'neutral',\n design = 'ghost',\n children = <CloseSVG />,\n ref,\n ...rest\n}: CloseButtonProps) => {\n return (\n <Close\n data-spark-component=\"dialog-close-button\"\n data-part=\"close\"\n ref={ref}\n className={cx(['absolute', 'top-md', 'right-xl'], className)}\n asChild\n {...rest}\n >\n <IconButton intent={intent} size={size} design={design} aria-label={ariaLabel}>\n <Icon>{children}</Icon>\n </IconButton>\n </Close>\n )\n}\n\nexport const CloseButton = Object.assign(Root, {\n id: 'CloseButton',\n})\n\nRoot.displayName = 'Dialog.CloseButton'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref, useEffect } from 'react'\n\nimport { dialogContentStyles, type DialogContentStylesProps } from './DialogContent.styles'\nimport { useDialog } from './DialogContext'\n\nexport interface ContentProps\n extends Omit<ComponentProps<typeof BaseDialog.Popup>, 'render'>,\n DialogContentStylesProps {\n /**\n * When set to true, the content will adjust its width to fit the content rather than taking up the full available width.\n */\n isNarrow?: boolean\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Content = ({\n className,\n isNarrow = false,\n size = 'md',\n ref,\n ...rest\n}: ContentProps) => {\n const { setIsFullScreen } = useDialog()\n\n useEffect(() => {\n if (size === 'fullscreen') setIsFullScreen(true)\n\n return () => setIsFullScreen(false)\n }, [setIsFullScreen, size])\n\n return (\n <BaseDialog.Popup\n ref={ref}\n data-spark-component=\"dialog-content\"\n role=\"dialog\"\n className={state =>\n cx(\n dialogContentStyles({\n isNarrow,\n size,\n className: typeof className === 'function' ? className(state) : className,\n })\n )\n }\n {...rest}\n />\n )\n}\n\nContent.displayName = 'Dialog.Content'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, Ref } from 'react'\n\nexport type DescriptionProps = ComponentProps<typeof BaseDialog.Description> & {\n ref?: Ref<HTMLParagraphElement>\n}\n\nexport const Description = (props: DescriptionProps) => (\n <BaseDialog.Description data-spark-component=\"dialog-description\" {...props} />\n)\n\nDescription.displayName = 'Dialog.Description'\n","import { cx } from 'class-variance-authority'\nimport { type ReactElement, type ReactNode, Ref } from 'react'\n\nexport interface FooterProps {\n children: ReactNode\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Footer = ({ children, className, ref, ...rest }: FooterProps): ReactElement => (\n <footer\n data-spark-component=\"dialog-footer\"\n ref={ref}\n className={cx(className, ['px-xl', 'py-lg'])}\n {...rest}\n >\n {children}\n </footer>\n)\n\nFooter.displayName = 'Dialog.Footer'\n","import { cx } from 'class-variance-authority'\nimport { type ReactElement, type ReactNode, Ref } from 'react'\n\nexport interface HeaderProps {\n children: ReactNode\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Header = ({ children, className, ref, ...rest }: HeaderProps): ReactElement => (\n <header\n data-spark-component=\"dialog-header\"\n ref={ref}\n className={cx(className, ['px-xl', 'py-lg'])}\n {...rest}\n >\n {children}\n </header>\n)\n\nHeader.displayName = 'Dialog.Header'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nexport interface OverlayProps extends Omit<ComponentProps<typeof BaseDialog.Backdrop>, 'render'> {\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Overlay = ({ className, ...props }: OverlayProps) => {\n return (\n <BaseDialog.Backdrop\n data-spark-component=\"dialog-overlay\"\n className={state =>\n cx(\n 'z-overlay size-screen fixed inset-0',\n 'bg-overlay/dim-1',\n 'data-starting-style:animate-fade-in',\n 'data-ending-style:animate-fade-out',\n typeof className === 'function' ? className(state) : className\n )\n }\n {...props}\n />\n )\n}\n\nOverlay.displayName = 'Dialog.Overlay'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps } from 'react'\n\nexport type PortalProps = ComponentProps<typeof BaseDialog.Portal>\n\nexport const Portal = ({ className, ...props }: PortalProps) => {\n return (\n <BaseDialog.Portal\n data-spark-component=\"dialog-portal\"\n className={cx(className, 'z-modal absolute')}\n {...props}\n />\n )\n}\n\nPortal.displayName = 'Dialog.Portal'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nexport type TitleProps = ComponentProps<typeof BaseDialog.Title> & {\n ref?: Ref<HTMLHeadingElement>\n}\n\nexport const Title = ({ className, ref, ...others }: TitleProps) => {\n return (\n <BaseDialog.Title\n data-spark-component=\"dialog-title\"\n ref={ref}\n className={cx(\n 'text-headline-1 text-on-surface',\n 'group-has-data-[part=close]:pr-3xl',\n className\n )}\n {...others}\n />\n )\n}\n\nTitle.displayName = 'Dialog.Title'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, Ref } from 'react'\n\nimport { useRenderSlot } from '../drawer/useRenderSlot'\n\nexport interface TriggerProps extends Omit<ComponentProps<typeof BaseDialog.Trigger>, 'render'> {\n /**\n * Change the component to the HTML tag or custom component of the only child.\n */\n asChild?: boolean\n ref?: Ref<HTMLButtonElement>\n}\n\nexport const Trigger = ({ asChild = false, ...props }: TriggerProps) => {\n const renderSlot = useRenderSlot(asChild, 'button')\n\n return <BaseDialog.Trigger data-spark-component=\"dialog-trigger\" render={renderSlot} {...props} />\n}\n\nTrigger.displayName = 'Dialog.Trigger'\n","import { Dialog as Root } from './Dialog'\nimport { Body } from './DialogBody'\nimport { Close } from './DialogClose'\nimport { CloseButton } from './DialogCloseButton'\nimport { Content } from './DialogContent'\nimport { Description } from './DialogDescription' // aria-describedby\nimport { Footer } from './DialogFooter'\nimport { Header } from './DialogHeader'\nimport { Overlay } from './DialogOverlay'\nimport { Portal } from './DialogPortal'\nimport { Title } from './DialogTitle' // aria-labelledby\nimport { Trigger } from './DialogTrigger'\n\nexport const Dialog: typeof Root & {\n Trigger: typeof Trigger\n Portal: typeof Portal\n Overlay: typeof Overlay\n Content: typeof Content\n Header: typeof Header\n Body: typeof Body\n Footer: typeof Footer\n Close: typeof Close\n CloseButton: typeof CloseButton\n Title: typeof Title\n Description: typeof Description\n} = Object.assign(Root, {\n Trigger,\n Portal,\n Overlay,\n Content,\n Header,\n Body,\n Footer,\n Close,\n CloseButton,\n Title,\n Description,\n})\n\nDialog.displayName = 'Dialog'\n\nexport { type DialogProps } from './Dialog'\nexport { type ContentProps as DialogContentProps } from './DialogContent'\nexport { type HeaderProps as DialogHeaderProps } from './DialogHeader'\nexport { type BodyProps as DialogBodyProps } from './DialogBody'\nexport { type FooterProps as DialogFooterProps } from './DialogFooter'\nexport { type TriggerProps as DialogTriggerProps } from './DialogTrigger'\nexport { type OverlayProps as DialogOverlayProps } from './DialogOverlay'\nexport { type PortalProps as DialogPortalProps } from './DialogPortal'\nexport { type TitleProps as DialogTitleProps } from './DialogTitle'\nexport { type DescriptionProps as DialogDescriptionProps } from './DialogDescription'\nexport { type CloseProps as DialogCloseProps } from './DialogClose'\nexport { type CloseButtonProps as DialogCloseButtonProps } from './DialogCloseButton'\n"],"names":["DialogContext","createContext","DialogProvider","childrenProp","withFade","isFullScreen","setIsFullScreen","useState","jsx","useDialog","context","useContext","Dialog","onOpenChange","props","handleOpenChange","open","_eventDetails","BaseDialog","Body","children","className","inset","forwardedRef","rest","scrollAreaRef","useRef","ref","useMergeRefs","overflow","useScrollOverflow","cx","Close","asChild","renderSlot","useRenderSlot","Root","ariaLabel","size","intent","design","CloseSVG","IconButton","Icon","CloseButton","Content","isNarrow","useEffect","state","dialogContentStyles","Description","Footer","Header","Overlay","Portal","Title","others","Trigger"],"mappings":"ofAQMA,EAAgBC,EAAAA,cAAyC,IAAI,EAEtDC,EAAiB,CAAC,CAC7B,SAAUC,EACV,SAAAC,EAAW,EACb,IAGM,CACJ,KAAM,CAACC,EAAcC,CAAe,EAAIC,EAAAA,SAAS,EAAK,EAEtD,OACEC,EAAAA,IAACR,EAAc,SAAd,CACC,MAAO,CACL,aAAAK,EACA,gBAAAC,EACA,SAAAF,CAAA,EAGD,SAAAD,CAAA,CAAA,CAGP,EAEaM,EAAY,IAAM,CAC7B,MAAMC,EAAUC,EAAAA,WAAWX,CAAa,EAExC,GAAI,CAACU,EACH,MAAM,MAAM,iDAAiD,EAG/D,OAAOA,CACT,ECPaE,EAAS,CAAC,CAAE,SAAAR,EAAW,GAAO,aAAAS,EAAc,GAAGC,KAAuC,CACjG,MAAMC,EAAmBF,EAC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AAQ,EAElD,OAAOzB,EAAAA,IAACU,SAAW,QAAX,CAAmB,uBAAqB,iBAAiB,OAAQgB,EAAa,GAAGpB,EAAO,CAClG,EAEA2C,EAAQ,YAAc,iBCNf,MAAM7C,EAYT,OAAO,OAAOwB,EAAM,CACtB,QAAAqB,EACA,OAAAH,EACA,QAAAD,EACA,QAAAR,EACA,OAAAO,EACA,KAAAjC,EACA,OAAAgC,EACA,MAAAnB,EACA,YAAAY,EACA,MAAAW,EACA,YAAAL,CACF,CAAC,EAEDtC,EAAO,YAAc"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/dialog/DialogContext.tsx","../../src/dialog/Dialog.tsx","../../src/dialog/DialogBody.tsx","../../src/dialog/DialogClose.tsx","../../src/dialog/DialogCloseButton.tsx","../../src/dialog/DialogContent.tsx","../../src/dialog/DialogDescription.tsx","../../src/dialog/DialogFooter.tsx","../../src/dialog/DialogHeader.tsx","../../src/dialog/DialogOverlay.tsx","../../src/dialog/DialogPortal.tsx","../../src/dialog/DialogTitle.tsx","../../src/dialog/DialogTrigger.tsx","../../src/dialog/index.ts"],"sourcesContent":["import { createContext, type ReactNode, useContext, useState } from 'react'\n\nexport interface DialogContextState {\n isFullScreen: boolean\n setIsFullScreen: (value: boolean) => void\n withFade: boolean\n}\n\nconst DialogContext = createContext<DialogContextState | null>(null)\n\nexport const DialogProvider = ({\n children: childrenProp,\n withFade = false,\n}: {\n children: ReactNode\n withFade?: boolean\n}) => {\n const [isFullScreen, setIsFullScreen] = useState(false)\n\n return (\n <DialogContext.Provider\n value={{\n isFullScreen,\n setIsFullScreen,\n withFade,\n }}\n >\n {childrenProp}\n </DialogContext.Provider>\n )\n}\n\nexport const useDialog = () => {\n const context = useContext(DialogContext)\n\n if (!context) {\n throw Error('useDialog must be used within a Dialog provider')\n }\n\n return context\n}\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, type ReactElement } from 'react'\n\nimport { DialogProvider } from './DialogContext'\n\nexport interface DialogProps\n extends Omit<ComponentProps<typeof BaseDialog.Root>, 'onOpenChange' | 'render'> {\n /**\n * Specifies if the dialog is open or not.\n */\n open?: boolean\n /**\n * Default open state.\n */\n defaultOpen?: boolean\n /**\n * Handler executed on every dialog open state change.\n */\n onOpenChange?: (open: boolean) => void\n /**\n * Specifies if the dialog is a modal.\n */\n modal?: boolean\n /**\n * Specifies if the dialog should have a fade animation on its body (in case it is scrollable).\n */\n withFade?: boolean\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n}\n\nexport const Dialog = ({ withFade = false, onOpenChange, ...props }: DialogProps): ReactElement => {\n const handleOpenChange = onOpenChange\n ? (open: boolean, _eventDetails: unknown) => {\n onOpenChange(open)\n }\n : undefined\n\n return (\n <DialogProvider withFade={withFade}>\n <BaseDialog.Root data-spark-component=\"dialog\" onOpenChange={handleOpenChange} {...props} />\n </DialogProvider>\n )\n}\n\nDialog.createHandle = BaseDialog.createHandle\nDialog.displayName = 'Dialog.Root'\n","import { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\nimport { useScrollOverflow } from '@spark-ui/hooks/use-scroll-overflow'\nimport { cx } from 'class-variance-authority'\nimport { type ReactElement, type ReactNode, Ref, useRef } from 'react'\n\nimport { useDialog } from './DialogContext'\n\nexport interface BodyProps {\n children: ReactNode\n className?: string\n tabIndex?: number\n ref?: Ref<HTMLDivElement>\n inset?: boolean\n}\n\nexport const Body = ({\n children,\n className,\n inset = false,\n ref: forwardedRef,\n ...rest\n}: BodyProps): ReactElement => {\n const scrollAreaRef = useRef<HTMLDivElement>(null)\n const ref = useMergeRefs(forwardedRef, scrollAreaRef)\n\n const { withFade } = useDialog()\n\n const { overflow } = useScrollOverflow(scrollAreaRef)\n\n return (\n <div\n data-spark-component=\"dialog-body\"\n ref={ref}\n className={cx(\n 'focus-visible:u-outline relative grow overflow-y-auto outline-hidden',\n 'transition-all duration-300',\n {\n ['px-xl py-lg']: !inset,\n },\n className\n )}\n style={{\n ...(withFade && {\n maskImage:\n 'linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1) 44px, rgba(0, 0, 0, 1) calc(100% - 44px), rgba(0, 0, 0, 0))',\n maskSize: `100% calc(100% + ${overflow.top ? '0px' : '44px'} + ${overflow.bottom ? '0px' : '44px'})`,\n maskPosition: `0 ${overflow.top ? '0px' : '-44px'}`,\n }),\n }}\n {...rest}\n >\n {children}\n </div>\n )\n}\n\nBody.displayName = 'Dialog.Body'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, Ref } from 'react'\n\nimport { useRenderSlot } from '../drawer/useRenderSlot'\n\nexport interface CloseProps extends Omit<ComponentProps<typeof BaseDialog.Close>, 'render'> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n ref?: Ref<HTMLButtonElement>\n}\n\nexport const Close = ({ asChild = false, ...props }: CloseProps) => {\n const renderSlot = useRenderSlot(asChild, 'button')\n\n return <BaseDialog.Close data-spark-component=\"dialog-close\" render={renderSlot} {...props} />\n}\n","import { Close as CloseSVG } from '@spark-ui/icons/Close'\nimport { cx } from 'class-variance-authority'\n\nimport { Icon } from '../icon'\nimport { IconButton, type IconButtonProps } from '../icon-button'\nimport { Close, CloseProps } from './DialogClose'\n\nexport type CloseButtonProps = CloseProps &\n Pick<IconButtonProps, 'size' | 'intent' | 'design' | 'aria-label'>\n\nconst Root = ({\n 'aria-label': ariaLabel,\n className,\n size = 'md',\n intent = 'neutral',\n design = 'ghost',\n children = <CloseSVG />,\n ref,\n ...rest\n}: CloseButtonProps) => {\n return (\n <Close\n data-spark-component=\"dialog-close-button\"\n data-part=\"close\"\n ref={ref}\n className={cx(['absolute', 'top-md', 'right-xl'], className)}\n asChild\n {...rest}\n >\n <IconButton intent={intent} size={size} design={design} aria-label={ariaLabel}>\n <Icon>{children}</Icon>\n </IconButton>\n </Close>\n )\n}\n\nexport const CloseButton = Object.assign(Root, {\n id: 'CloseButton',\n})\n\nRoot.displayName = 'Dialog.CloseButton'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref, useEffect } from 'react'\n\nimport { dialogContentStyles, type DialogContentStylesProps } from './DialogContent.styles'\nimport { useDialog } from './DialogContext'\n\nexport interface ContentProps\n extends Omit<ComponentProps<typeof BaseDialog.Popup>, 'render'>,\n DialogContentStylesProps {\n /**\n * When set to true, the content will adjust its width to fit the content rather than taking up the full available width.\n */\n isNarrow?: boolean\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Content = ({\n className,\n isNarrow = false,\n size = 'md',\n ref,\n ...rest\n}: ContentProps) => {\n const { setIsFullScreen } = useDialog()\n\n useEffect(() => {\n if (size === 'fullscreen') setIsFullScreen(true)\n\n return () => setIsFullScreen(false)\n }, [setIsFullScreen, size])\n\n return (\n <BaseDialog.Popup\n ref={ref}\n data-spark-component=\"dialog-content\"\n role=\"dialog\"\n className={state =>\n cx(\n dialogContentStyles({\n isNarrow,\n size,\n className: typeof className === 'function' ? className(state) : className,\n })\n )\n }\n {...rest}\n />\n )\n}\n\nContent.displayName = 'Dialog.Content'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, Ref } from 'react'\n\nexport type DescriptionProps = ComponentProps<typeof BaseDialog.Description> & {\n ref?: Ref<HTMLParagraphElement>\n}\n\nexport const Description = (props: DescriptionProps) => (\n <BaseDialog.Description data-spark-component=\"dialog-description\" {...props} />\n)\n\nDescription.displayName = 'Dialog.Description'\n","import { cx } from 'class-variance-authority'\nimport { type ReactElement, type ReactNode, Ref } from 'react'\n\nexport interface FooterProps {\n children: ReactNode\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Footer = ({ children, className, ref, ...rest }: FooterProps): ReactElement => (\n <footer\n data-spark-component=\"dialog-footer\"\n ref={ref}\n className={cx(className, ['px-xl', 'py-lg'])}\n {...rest}\n >\n {children}\n </footer>\n)\n\nFooter.displayName = 'Dialog.Footer'\n","import { cx } from 'class-variance-authority'\nimport { type ReactElement, type ReactNode, Ref } from 'react'\n\nexport interface HeaderProps {\n children: ReactNode\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Header = ({ children, className, ref, ...rest }: HeaderProps): ReactElement => (\n <header\n data-spark-component=\"dialog-header\"\n ref={ref}\n className={cx(className, ['px-xl', 'py-lg'])}\n {...rest}\n >\n {children}\n </header>\n)\n\nHeader.displayName = 'Dialog.Header'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nexport interface OverlayProps extends Omit<ComponentProps<typeof BaseDialog.Backdrop>, 'render'> {\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Overlay = ({ className, ...props }: OverlayProps) => {\n return (\n <BaseDialog.Backdrop\n data-spark-component=\"dialog-overlay\"\n className={state =>\n cx(\n 'z-overlay size-screen fixed inset-0',\n 'bg-overlay/dim-1',\n 'data-starting-style:animate-fade-in',\n 'data-ending-style:animate-fade-out',\n typeof className === 'function' ? className(state) : className\n )\n }\n {...props}\n />\n )\n}\n\nOverlay.displayName = 'Dialog.Overlay'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps } from 'react'\n\nexport type PortalProps = ComponentProps<typeof BaseDialog.Portal>\n\nexport const Portal = ({ className, ...props }: PortalProps) => {\n return (\n <BaseDialog.Portal\n data-spark-component=\"dialog-portal\"\n className={cx(className, 'z-modal absolute')}\n {...props}\n />\n )\n}\n\nPortal.displayName = 'Dialog.Portal'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nexport type TitleProps = ComponentProps<typeof BaseDialog.Title> & {\n ref?: Ref<HTMLHeadingElement>\n}\n\nexport const Title = ({ className, ref, ...others }: TitleProps) => {\n return (\n <BaseDialog.Title\n data-spark-component=\"dialog-title\"\n ref={ref}\n className={cx(\n 'text-headline-1 text-on-surface',\n 'group-has-data-[part=close]:pr-3xl',\n className\n )}\n {...others}\n />\n )\n}\n\nTitle.displayName = 'Dialog.Title'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, Ref } from 'react'\n\nimport { useRenderSlot } from '../drawer/useRenderSlot'\n\nexport interface TriggerProps extends Omit<ComponentProps<typeof BaseDialog.Trigger>, 'render'> {\n /**\n * Change the component to the HTML tag or custom component of the only child.\n */\n asChild?: boolean\n ref?: Ref<HTMLButtonElement>\n}\n\nexport const Trigger = ({ asChild = false, ...props }: TriggerProps) => {\n const renderSlot = useRenderSlot(asChild, 'button')\n\n return <BaseDialog.Trigger data-spark-component=\"dialog-trigger\" render={renderSlot} {...props} />\n}\n\nTrigger.displayName = 'Dialog.Trigger'\n","import { Dialog as Root } from './Dialog'\nimport { Body } from './DialogBody'\nimport { Close } from './DialogClose'\nimport { CloseButton } from './DialogCloseButton'\nimport { Content } from './DialogContent'\nimport { Description } from './DialogDescription' // aria-describedby\nimport { Footer } from './DialogFooter'\nimport { Header } from './DialogHeader'\nimport { Overlay } from './DialogOverlay'\nimport { Portal } from './DialogPortal'\nimport { Title } from './DialogTitle' // aria-labelledby\nimport { Trigger } from './DialogTrigger'\n\nexport const Dialog: typeof Root & {\n Trigger: typeof Trigger\n Portal: typeof Portal\n Overlay: typeof Overlay\n Content: typeof Content\n Header: typeof Header\n Body: typeof Body\n Footer: typeof Footer\n Close: typeof Close\n CloseButton: typeof CloseButton\n Title: typeof Title\n Description: typeof Description\n} = Object.assign(Root, {\n Trigger,\n Portal,\n Overlay,\n Content,\n Header,\n Body,\n Footer,\n Close,\n CloseButton,\n Title,\n Description,\n})\n\nDialog.displayName = 'Dialog'\n\nexport { type DialogProps } from './Dialog'\nexport { type ContentProps as DialogContentProps } from './DialogContent'\nexport { type HeaderProps as DialogHeaderProps } from './DialogHeader'\nexport { type BodyProps as DialogBodyProps } from './DialogBody'\nexport { type FooterProps as DialogFooterProps } from './DialogFooter'\nexport { type TriggerProps as DialogTriggerProps } from './DialogTrigger'\nexport { type OverlayProps as DialogOverlayProps } from './DialogOverlay'\nexport { type PortalProps as DialogPortalProps } from './DialogPortal'\nexport { type TitleProps as DialogTitleProps } from './DialogTitle'\nexport { type DescriptionProps as DialogDescriptionProps } from './DialogDescription'\nexport { type CloseProps as DialogCloseProps } from './DialogClose'\nexport { type CloseButtonProps as DialogCloseButtonProps } from './DialogCloseButton'\n"],"names":["DialogContext","createContext","DialogProvider","childrenProp","withFade","isFullScreen","setIsFullScreen","useState","jsx","useDialog","context","useContext","Dialog","onOpenChange","props","handleOpenChange","open","_eventDetails","BaseDialog","Body","children","className","inset","forwardedRef","rest","scrollAreaRef","useRef","ref","useMergeRefs","overflow","useScrollOverflow","cx","Close","asChild","renderSlot","useRenderSlot","Root","ariaLabel","size","intent","design","CloseSVG","IconButton","Icon","CloseButton","Content","isNarrow","useEffect","state","dialogContentStyles","Description","Footer","Header","Overlay","Portal","Title","others","Trigger"],"mappings":"ofAQMA,EAAgBC,EAAAA,cAAyC,IAAI,EAEtDC,EAAiB,CAAC,CAC7B,SAAUC,EACV,SAAAC,EAAW,EACb,IAGM,CACJ,KAAM,CAACC,EAAcC,CAAe,EAAIC,EAAAA,SAAS,EAAK,EAEtD,OACEC,EAAAA,IAACR,EAAc,SAAd,CACC,MAAO,CACL,aAAAK,EACA,gBAAAC,EACA,SAAAF,CAAA,EAGD,SAAAD,CAAA,CAAA,CAGP,EAEaM,EAAY,IAAM,CAC7B,MAAMC,EAAUC,EAAAA,WAAWX,CAAa,EAExC,GAAI,CAACU,EACH,MAAM,MAAM,iDAAiD,EAG/D,OAAOA,CACT,ECPaE,EAAS,CAAC,CAAE,SAAAR,EAAW,GAAO,aAAAS,EAAc,GAAGC,KAAuC,CACjG,MAAMC,EAAmBF,EACrB,CAACG,EAAeC,IAA2B,CACzCJ,EAAaG,CAAI,CACnB,EACA,OAE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A,IAACU,SAAW,QAAX,CAAmB,uBAAqB,iBAAiB,OAAQgB,EAAa,GAAGpB,EAAO,CAClG,EAEA2C,EAAQ,YAAc,iBCNf,MAAM7C,EAYT,OAAO,OAAOwB,EAAM,CACtB,QAAAqB,EACA,OAAAH,EACA,QAAAD,EACA,QAAAR,EACA,OAAAO,EACA,KAAAjC,EACA,OAAAgC,EACA,MAAAnB,EACA,YAAAY,EACA,MAAAW,EACA,YAAAL,CACF,CAAC,EAEDtC,EAAO,YAAc"}
|
package/dist/dialog/index.mjs
CHANGED
|
@@ -4,18 +4,18 @@ import { createContext as B, useState as I, useContext as P, useRef as R, useEff
|
|
|
4
4
|
import { useMergeRefs as O } from "@spark-ui/hooks/use-merge-refs";
|
|
5
5
|
import { useScrollOverflow as T } from "@spark-ui/hooks/use-scroll-overflow";
|
|
6
6
|
import { cx as s } from "class-variance-authority";
|
|
7
|
-
import { u as
|
|
7
|
+
import { u as g } from "../useRenderSlot-LwWj8QbC.mjs";
|
|
8
8
|
import { Close as $ } from "@spark-ui/icons/Close";
|
|
9
|
-
import { I as
|
|
10
|
-
import { I as
|
|
11
|
-
import { d as
|
|
12
|
-
const
|
|
9
|
+
import { I as H } from "../Icon-Ck-dhfLd.mjs";
|
|
10
|
+
import { I as j } from "../IconButton-C62-axzv.mjs";
|
|
11
|
+
import { d as z } from "../DialogContent.styles-Du7_Dkde.mjs";
|
|
12
|
+
const u = B(null), E = ({
|
|
13
13
|
children: o,
|
|
14
14
|
withFade: e = !1
|
|
15
15
|
}) => {
|
|
16
16
|
const [a, r] = I(!1);
|
|
17
17
|
return /* @__PURE__ */ t(
|
|
18
|
-
|
|
18
|
+
u.Provider,
|
|
19
19
|
{
|
|
20
20
|
value: {
|
|
21
21
|
isFullScreen: a,
|
|
@@ -25,18 +25,19 @@ const g = B(null), H = ({
|
|
|
25
25
|
children: o
|
|
26
26
|
}
|
|
27
27
|
);
|
|
28
|
-
},
|
|
29
|
-
const o = P(
|
|
28
|
+
}, f = () => {
|
|
29
|
+
const o = P(u);
|
|
30
30
|
if (!o)
|
|
31
31
|
throw Error("useDialog must be used within a Dialog provider");
|
|
32
32
|
return o;
|
|
33
|
-
},
|
|
33
|
+
}, m = ({ withFade: o = !1, onOpenChange: e, ...a }) => {
|
|
34
34
|
const r = e ? (i, l) => {
|
|
35
35
|
e(i);
|
|
36
36
|
} : void 0;
|
|
37
|
-
return /* @__PURE__ */ t(
|
|
37
|
+
return /* @__PURE__ */ t(E, { withFade: o, children: /* @__PURE__ */ t(n.Root, { "data-spark-component": "dialog", onOpenChange: r, ...a }) });
|
|
38
38
|
};
|
|
39
|
-
|
|
39
|
+
m.createHandle = n.createHandle;
|
|
40
|
+
m.displayName = "Dialog.Root";
|
|
40
41
|
const y = ({
|
|
41
42
|
children: o,
|
|
42
43
|
className: e,
|
|
@@ -44,7 +45,7 @@ const y = ({
|
|
|
44
45
|
ref: r,
|
|
45
46
|
...i
|
|
46
47
|
}) => {
|
|
47
|
-
const l = R(null), d = O(r, l), { withFade: c } =
|
|
48
|
+
const l = R(null), d = O(r, l), { withFade: c } = f(), { overflow: p } = T(l);
|
|
48
49
|
return /* @__PURE__ */ t(
|
|
49
50
|
"div",
|
|
50
51
|
{
|
|
@@ -72,7 +73,7 @@ const y = ({
|
|
|
72
73
|
};
|
|
73
74
|
y.displayName = "Dialog.Body";
|
|
74
75
|
const x = ({ asChild: o = !1, ...e }) => {
|
|
75
|
-
const a =
|
|
76
|
+
const a = g(o, "button");
|
|
76
77
|
return /* @__PURE__ */ t(n.Close, { "data-spark-component": "dialog-close", render: a, ...e });
|
|
77
78
|
}, D = ({
|
|
78
79
|
"aria-label": o,
|
|
@@ -92,7 +93,7 @@ const x = ({ asChild: o = !1, ...e }) => {
|
|
|
92
93
|
className: s(["absolute", "top-md", "right-xl"], e),
|
|
93
94
|
asChild: !0,
|
|
94
95
|
...c,
|
|
95
|
-
children: /* @__PURE__ */ t(
|
|
96
|
+
children: /* @__PURE__ */ t(j, { intent: r, size: a, design: i, "aria-label": o, children: /* @__PURE__ */ t(H, { children: l }) })
|
|
96
97
|
}
|
|
97
98
|
), A = Object.assign(D, {
|
|
98
99
|
id: "CloseButton"
|
|
@@ -105,7 +106,7 @@ const b = ({
|
|
|
105
106
|
ref: r,
|
|
106
107
|
...i
|
|
107
108
|
}) => {
|
|
108
|
-
const { setIsFullScreen: l } =
|
|
109
|
+
const { setIsFullScreen: l } = f();
|
|
109
110
|
return F(() => (a === "fullscreen" && l(!0), () => l(!1)), [l, a]), /* @__PURE__ */ t(
|
|
110
111
|
n.Popup,
|
|
111
112
|
{
|
|
@@ -113,7 +114,7 @@ const b = ({
|
|
|
113
114
|
"data-spark-component": "dialog-content",
|
|
114
115
|
role: "dialog",
|
|
115
116
|
className: (d) => s(
|
|
116
|
-
|
|
117
|
+
z({
|
|
117
118
|
isNarrow: e,
|
|
118
119
|
size: a,
|
|
119
120
|
className: typeof o == "function" ? o(d) : o
|
|
@@ -187,11 +188,11 @@ const S = ({ className: o, ref: e, ...a }) => /* @__PURE__ */ t(
|
|
|
187
188
|
);
|
|
188
189
|
S.displayName = "Dialog.Title";
|
|
189
190
|
const w = ({ asChild: o = !1, ...e }) => {
|
|
190
|
-
const a =
|
|
191
|
+
const a = g(o, "button");
|
|
191
192
|
return /* @__PURE__ */ t(n.Trigger, { "data-spark-component": "dialog-trigger", render: a, ...e });
|
|
192
193
|
};
|
|
193
194
|
w.displayName = "Dialog.Trigger";
|
|
194
|
-
const M = Object.assign(
|
|
195
|
+
const M = Object.assign(m, {
|
|
195
196
|
Trigger: w,
|
|
196
197
|
Portal: C,
|
|
197
198
|
Overlay: k,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/dialog/DialogContext.tsx","../../src/dialog/Dialog.tsx","../../src/dialog/DialogBody.tsx","../../src/dialog/DialogClose.tsx","../../src/dialog/DialogCloseButton.tsx","../../src/dialog/DialogContent.tsx","../../src/dialog/DialogDescription.tsx","../../src/dialog/DialogFooter.tsx","../../src/dialog/DialogHeader.tsx","../../src/dialog/DialogOverlay.tsx","../../src/dialog/DialogPortal.tsx","../../src/dialog/DialogTitle.tsx","../../src/dialog/DialogTrigger.tsx","../../src/dialog/index.ts"],"sourcesContent":["import { createContext, type ReactNode, useContext, useState } from 'react'\n\nexport interface DialogContextState {\n isFullScreen: boolean\n setIsFullScreen: (value: boolean) => void\n withFade: boolean\n}\n\nconst DialogContext = createContext<DialogContextState | null>(null)\n\nexport const DialogProvider = ({\n children: childrenProp,\n withFade = false,\n}: {\n children: ReactNode\n withFade?: boolean\n}) => {\n const [isFullScreen, setIsFullScreen] = useState(false)\n\n return (\n <DialogContext.Provider\n value={{\n isFullScreen,\n setIsFullScreen,\n withFade,\n }}\n >\n {childrenProp}\n </DialogContext.Provider>\n )\n}\n\nexport const useDialog = () => {\n const context = useContext(DialogContext)\n\n if (!context) {\n throw Error('useDialog must be used within a Dialog provider')\n }\n\n return context\n}\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, type ReactElement } from 'react'\n\nimport { DialogProvider } from './DialogContext'\n\nexport interface DialogProps\n extends Omit<ComponentProps<typeof BaseDialog.Root>, 'onOpenChange' | 'render'> {\n /**\n * Specifies if the dialog is open or not.\n */\n open?: boolean\n /**\n * Default open state.\n */\n defaultOpen?: boolean\n /**\n * Handler executed on every dialog open state change.\n */\n onOpenChange?: (open: boolean) => void\n /**\n * Specifies if the dialog is a modal.\n */\n modal?: boolean\n /**\n * Specifies if the dialog should have a fade animation on its body (in case it is scrollable).\n */\n withFade?: boolean\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n}\n\nexport const Dialog = ({ withFade = false, onOpenChange, ...props }: DialogProps): ReactElement => {\n const handleOpenChange = onOpenChange\n ? (open: boolean, _eventDetails: unknown) => {\n onOpenChange(open)\n }\n : undefined\n\n return (\n <DialogProvider withFade={withFade}>\n <BaseDialog.Root data-spark-component=\"dialog\" onOpenChange={handleOpenChange} {...props} />\n </DialogProvider>\n )\n}\n\nDialog.displayName = 'Dialog.Root'\n","import { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\nimport { useScrollOverflow } from '@spark-ui/hooks/use-scroll-overflow'\nimport { cx } from 'class-variance-authority'\nimport { type ReactElement, type ReactNode, Ref, useRef } from 'react'\n\nimport { useDialog } from './DialogContext'\n\nexport interface BodyProps {\n children: ReactNode\n className?: string\n tabIndex?: number\n ref?: Ref<HTMLDivElement>\n inset?: boolean\n}\n\nexport const Body = ({\n children,\n className,\n inset = false,\n ref: forwardedRef,\n ...rest\n}: BodyProps): ReactElement => {\n const scrollAreaRef = useRef<HTMLDivElement>(null)\n const ref = useMergeRefs(forwardedRef, scrollAreaRef)\n\n const { withFade } = useDialog()\n\n const { overflow } = useScrollOverflow(scrollAreaRef)\n\n return (\n <div\n data-spark-component=\"dialog-body\"\n ref={ref}\n className={cx(\n 'focus-visible:u-outline relative grow overflow-y-auto outline-hidden',\n 'transition-all duration-300',\n {\n ['px-xl py-lg']: !inset,\n },\n className\n )}\n style={{\n ...(withFade && {\n maskImage:\n 'linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1) 44px, rgba(0, 0, 0, 1) calc(100% - 44px), rgba(0, 0, 0, 0))',\n maskSize: `100% calc(100% + ${overflow.top ? '0px' : '44px'} + ${overflow.bottom ? '0px' : '44px'})`,\n maskPosition: `0 ${overflow.top ? '0px' : '-44px'}`,\n }),\n }}\n {...rest}\n >\n {children}\n </div>\n )\n}\n\nBody.displayName = 'Dialog.Body'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, Ref } from 'react'\n\nimport { useRenderSlot } from '../drawer/useRenderSlot'\n\nexport interface CloseProps extends Omit<ComponentProps<typeof BaseDialog.Close>, 'render'> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n ref?: Ref<HTMLButtonElement>\n}\n\nexport const Close = ({ asChild = false, ...props }: CloseProps) => {\n const renderSlot = useRenderSlot(asChild, 'button')\n\n return <BaseDialog.Close data-spark-component=\"dialog-close\" render={renderSlot} {...props} />\n}\n","import { Close as CloseSVG } from '@spark-ui/icons/Close'\nimport { cx } from 'class-variance-authority'\n\nimport { Icon } from '../icon'\nimport { IconButton, type IconButtonProps } from '../icon-button'\nimport { Close, CloseProps } from './DialogClose'\n\nexport type CloseButtonProps = CloseProps &\n Pick<IconButtonProps, 'size' | 'intent' | 'design' | 'aria-label'>\n\nconst Root = ({\n 'aria-label': ariaLabel,\n className,\n size = 'md',\n intent = 'neutral',\n design = 'ghost',\n children = <CloseSVG />,\n ref,\n ...rest\n}: CloseButtonProps) => {\n return (\n <Close\n data-spark-component=\"dialog-close-button\"\n data-part=\"close\"\n ref={ref}\n className={cx(['absolute', 'top-md', 'right-xl'], className)}\n asChild\n {...rest}\n >\n <IconButton intent={intent} size={size} design={design} aria-label={ariaLabel}>\n <Icon>{children}</Icon>\n </IconButton>\n </Close>\n )\n}\n\nexport const CloseButton = Object.assign(Root, {\n id: 'CloseButton',\n})\n\nRoot.displayName = 'Dialog.CloseButton'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref, useEffect } from 'react'\n\nimport { dialogContentStyles, type DialogContentStylesProps } from './DialogContent.styles'\nimport { useDialog } from './DialogContext'\n\nexport interface ContentProps\n extends Omit<ComponentProps<typeof BaseDialog.Popup>, 'render'>,\n DialogContentStylesProps {\n /**\n * When set to true, the content will adjust its width to fit the content rather than taking up the full available width.\n */\n isNarrow?: boolean\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Content = ({\n className,\n isNarrow = false,\n size = 'md',\n ref,\n ...rest\n}: ContentProps) => {\n const { setIsFullScreen } = useDialog()\n\n useEffect(() => {\n if (size === 'fullscreen') setIsFullScreen(true)\n\n return () => setIsFullScreen(false)\n }, [setIsFullScreen, size])\n\n return (\n <BaseDialog.Popup\n ref={ref}\n data-spark-component=\"dialog-content\"\n role=\"dialog\"\n className={state =>\n cx(\n dialogContentStyles({\n isNarrow,\n size,\n className: typeof className === 'function' ? className(state) : className,\n })\n )\n }\n {...rest}\n />\n )\n}\n\nContent.displayName = 'Dialog.Content'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, Ref } from 'react'\n\nexport type DescriptionProps = ComponentProps<typeof BaseDialog.Description> & {\n ref?: Ref<HTMLParagraphElement>\n}\n\nexport const Description = (props: DescriptionProps) => (\n <BaseDialog.Description data-spark-component=\"dialog-description\" {...props} />\n)\n\nDescription.displayName = 'Dialog.Description'\n","import { cx } from 'class-variance-authority'\nimport { type ReactElement, type ReactNode, Ref } from 'react'\n\nexport interface FooterProps {\n children: ReactNode\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Footer = ({ children, className, ref, ...rest }: FooterProps): ReactElement => (\n <footer\n data-spark-component=\"dialog-footer\"\n ref={ref}\n className={cx(className, ['px-xl', 'py-lg'])}\n {...rest}\n >\n {children}\n </footer>\n)\n\nFooter.displayName = 'Dialog.Footer'\n","import { cx } from 'class-variance-authority'\nimport { type ReactElement, type ReactNode, Ref } from 'react'\n\nexport interface HeaderProps {\n children: ReactNode\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Header = ({ children, className, ref, ...rest }: HeaderProps): ReactElement => (\n <header\n data-spark-component=\"dialog-header\"\n ref={ref}\n className={cx(className, ['px-xl', 'py-lg'])}\n {...rest}\n >\n {children}\n </header>\n)\n\nHeader.displayName = 'Dialog.Header'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nexport interface OverlayProps extends Omit<ComponentProps<typeof BaseDialog.Backdrop>, 'render'> {\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Overlay = ({ className, ...props }: OverlayProps) => {\n return (\n <BaseDialog.Backdrop\n data-spark-component=\"dialog-overlay\"\n className={state =>\n cx(\n 'z-overlay size-screen fixed inset-0',\n 'bg-overlay/dim-1',\n 'data-starting-style:animate-fade-in',\n 'data-ending-style:animate-fade-out',\n typeof className === 'function' ? className(state) : className\n )\n }\n {...props}\n />\n )\n}\n\nOverlay.displayName = 'Dialog.Overlay'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps } from 'react'\n\nexport type PortalProps = ComponentProps<typeof BaseDialog.Portal>\n\nexport const Portal = ({ className, ...props }: PortalProps) => {\n return (\n <BaseDialog.Portal\n data-spark-component=\"dialog-portal\"\n className={cx(className, 'z-modal absolute')}\n {...props}\n />\n )\n}\n\nPortal.displayName = 'Dialog.Portal'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nexport type TitleProps = ComponentProps<typeof BaseDialog.Title> & {\n ref?: Ref<HTMLHeadingElement>\n}\n\nexport const Title = ({ className, ref, ...others }: TitleProps) => {\n return (\n <BaseDialog.Title\n data-spark-component=\"dialog-title\"\n ref={ref}\n className={cx(\n 'text-headline-1 text-on-surface',\n 'group-has-data-[part=close]:pr-3xl',\n className\n )}\n {...others}\n />\n )\n}\n\nTitle.displayName = 'Dialog.Title'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, Ref } from 'react'\n\nimport { useRenderSlot } from '../drawer/useRenderSlot'\n\nexport interface TriggerProps extends Omit<ComponentProps<typeof BaseDialog.Trigger>, 'render'> {\n /**\n * Change the component to the HTML tag or custom component of the only child.\n */\n asChild?: boolean\n ref?: Ref<HTMLButtonElement>\n}\n\nexport const Trigger = ({ asChild = false, ...props }: TriggerProps) => {\n const renderSlot = useRenderSlot(asChild, 'button')\n\n return <BaseDialog.Trigger data-spark-component=\"dialog-trigger\" render={renderSlot} {...props} />\n}\n\nTrigger.displayName = 'Dialog.Trigger'\n","import { Dialog as Root } from './Dialog'\nimport { Body } from './DialogBody'\nimport { Close } from './DialogClose'\nimport { CloseButton } from './DialogCloseButton'\nimport { Content } from './DialogContent'\nimport { Description } from './DialogDescription' // aria-describedby\nimport { Footer } from './DialogFooter'\nimport { Header } from './DialogHeader'\nimport { Overlay } from './DialogOverlay'\nimport { Portal } from './DialogPortal'\nimport { Title } from './DialogTitle' // aria-labelledby\nimport { Trigger } from './DialogTrigger'\n\nexport const Dialog: typeof Root & {\n Trigger: typeof Trigger\n Portal: typeof Portal\n Overlay: typeof Overlay\n Content: typeof Content\n Header: typeof Header\n Body: typeof Body\n Footer: typeof Footer\n Close: typeof Close\n CloseButton: typeof CloseButton\n Title: typeof Title\n Description: typeof Description\n} = Object.assign(Root, {\n Trigger,\n Portal,\n Overlay,\n Content,\n Header,\n Body,\n Footer,\n Close,\n CloseButton,\n Title,\n Description,\n})\n\nDialog.displayName = 'Dialog'\n\nexport { type DialogProps } from './Dialog'\nexport { type ContentProps as DialogContentProps } from './DialogContent'\nexport { type HeaderProps as DialogHeaderProps } from './DialogHeader'\nexport { type BodyProps as DialogBodyProps } from './DialogBody'\nexport { type FooterProps as DialogFooterProps } from './DialogFooter'\nexport { type TriggerProps as DialogTriggerProps } from './DialogTrigger'\nexport { type OverlayProps as DialogOverlayProps } from './DialogOverlay'\nexport { type PortalProps as DialogPortalProps } from './DialogPortal'\nexport { type TitleProps as DialogTitleProps } from './DialogTitle'\nexport { type DescriptionProps as DialogDescriptionProps } from './DialogDescription'\nexport { type CloseProps as DialogCloseProps } from './DialogClose'\nexport { type CloseButtonProps as DialogCloseButtonProps } from './DialogCloseButton'\n"],"names":["DialogContext","createContext","DialogProvider","childrenProp","withFade","isFullScreen","setIsFullScreen","useState","jsx","useDialog","context","useContext","Dialog","onOpenChange","props","handleOpenChange","open","_eventDetails","BaseDialog","Body","children","className","inset","forwardedRef","rest","scrollAreaRef","useRef","ref","useMergeRefs","overflow","useScrollOverflow","cx","Close","asChild","renderSlot","useRenderSlot","Root","ariaLabel","size","intent","design","CloseSVG","IconButton","Icon","CloseButton","Content","isNarrow","useEffect","state","dialogContentStyles","Description","Footer","Header","Overlay","Portal","Title","others","Trigger"],"mappings":";;;;;;;;;;;AAQA,MAAMA,IAAgBC,EAAyC,IAAI,GAEtDC,IAAiB,CAAC;AAAA,EAC7B,UAAUC;AAAA,EACV,UAAAC,IAAW;AACb,MAGM;AACJ,QAAM,CAACC,GAAcC,CAAe,IAAIC,EAAS,EAAK;AAEtD,SACE,gBAAAC;AAAA,IAACR,EAAc;AAAA,IAAd;AAAA,MACC,OAAO;AAAA,QACL,cAAAK;AAAA,QACA,iBAAAC;AAAA,QACA,UAAAF;AAAA,MAAA;AAAA,MAGD,UAAAD;AAAA,IAAA;AAAA,EAAA;AAGP,GAEaM,IAAY,MAAM;AAC7B,QAAMC,IAAUC,EAAWX,CAAa;AAExC,MAAI,CAACU;AACH,UAAM,MAAM,iDAAiD;AAG/D,SAAOA;AACT,GCPaE,IAAS,CAAC,EAAE,UAAAR,IAAW,IAAO,cAAAS,GAAc,GAAGC,QAAuC;AACjG,QAAMC,IAAmBF,IACrB,CAACG,GAAeC,MAA2B;AACzC,IAAAJ,EAAaG,CAAI;AAAA,EACnB,IACA;AAEJ,SACE,gBAAAR,EAACN,GAAA,EAAe,UAAAE,GACd,UAAA,gBAAAI,EAACU,EAAW,MAAX,EAAgB,wBAAqB,UAAS,cAAcH,GAAmB,GAAGD,GAAO,GAC5F;AAEJ;AAEAF,EAAO,cAAc;AChCd,MAAMO,IAAO,CAAC;AAAA,EACnB,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,KAAKC;AAAA,EACL,GAAGC;AACL,MAA+B;AAC7B,QAAMC,IAAgBC,EAAuB,IAAI,GAC3CC,IAAMC,EAAaL,GAAcE,CAAa,GAE9C,EAAE,UAAArB,EAAA,IAAaK,EAAA,GAEf,EAAE,UAAAoB,EAAA,IAAaC,EAAkBL,CAAa;AAEpD,SACE,gBAAAjB;AAAA,I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,SAAX,EAAmB,wBAAqB,kBAAiB,QAAQgB,GAAa,GAAGpB,GAAO;AAClG;AAEA2C,EAAQ,cAAc;ACNf,MAAM7C,IAYT,OAAO,OAAOwB,GAAM;AAAA,EACtB,SAAAqB;AAAA,EACA,QAAAH;AAAA,EACA,SAAAD;AAAA,EACA,SAAAR;AAAA,EACA,QAAAO;AAAA,EACA,MAAAjC;AAAA,EACA,QAAAgC;AAAA,EACA,OAAAnB;AAAA,EACA,aAAAY;AAAA,EACA,OAAAW;AAAA,EACA,aAAAL;AACF,CAAC;AAEDtC,EAAO,cAAc;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/dialog/DialogContext.tsx","../../src/dialog/Dialog.tsx","../../src/dialog/DialogBody.tsx","../../src/dialog/DialogClose.tsx","../../src/dialog/DialogCloseButton.tsx","../../src/dialog/DialogContent.tsx","../../src/dialog/DialogDescription.tsx","../../src/dialog/DialogFooter.tsx","../../src/dialog/DialogHeader.tsx","../../src/dialog/DialogOverlay.tsx","../../src/dialog/DialogPortal.tsx","../../src/dialog/DialogTitle.tsx","../../src/dialog/DialogTrigger.tsx","../../src/dialog/index.ts"],"sourcesContent":["import { createContext, type ReactNode, useContext, useState } from 'react'\n\nexport interface DialogContextState {\n isFullScreen: boolean\n setIsFullScreen: (value: boolean) => void\n withFade: boolean\n}\n\nconst DialogContext = createContext<DialogContextState | null>(null)\n\nexport const DialogProvider = ({\n children: childrenProp,\n withFade = false,\n}: {\n children: ReactNode\n withFade?: boolean\n}) => {\n const [isFullScreen, setIsFullScreen] = useState(false)\n\n return (\n <DialogContext.Provider\n value={{\n isFullScreen,\n setIsFullScreen,\n withFade,\n }}\n >\n {childrenProp}\n </DialogContext.Provider>\n )\n}\n\nexport const useDialog = () => {\n const context = useContext(DialogContext)\n\n if (!context) {\n throw Error('useDialog must be used within a Dialog provider')\n }\n\n return context\n}\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, type ReactElement } from 'react'\n\nimport { DialogProvider } from './DialogContext'\n\nexport interface DialogProps\n extends Omit<ComponentProps<typeof BaseDialog.Root>, 'onOpenChange' | 'render'> {\n /**\n * Specifies if the dialog is open or not.\n */\n open?: boolean\n /**\n * Default open state.\n */\n defaultOpen?: boolean\n /**\n * Handler executed on every dialog open state change.\n */\n onOpenChange?: (open: boolean) => void\n /**\n * Specifies if the dialog is a modal.\n */\n modal?: boolean\n /**\n * Specifies if the dialog should have a fade animation on its body (in case it is scrollable).\n */\n withFade?: boolean\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n}\n\nexport const Dialog = ({ withFade = false, onOpenChange, ...props }: DialogProps): ReactElement => {\n const handleOpenChange = onOpenChange\n ? (open: boolean, _eventDetails: unknown) => {\n onOpenChange(open)\n }\n : undefined\n\n return (\n <DialogProvider withFade={withFade}>\n <BaseDialog.Root data-spark-component=\"dialog\" onOpenChange={handleOpenChange} {...props} />\n </DialogProvider>\n )\n}\n\nDialog.createHandle = BaseDialog.createHandle\nDialog.displayName = 'Dialog.Root'\n","import { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\nimport { useScrollOverflow } from '@spark-ui/hooks/use-scroll-overflow'\nimport { cx } from 'class-variance-authority'\nimport { type ReactElement, type ReactNode, Ref, useRef } from 'react'\n\nimport { useDialog } from './DialogContext'\n\nexport interface BodyProps {\n children: ReactNode\n className?: string\n tabIndex?: number\n ref?: Ref<HTMLDivElement>\n inset?: boolean\n}\n\nexport const Body = ({\n children,\n className,\n inset = false,\n ref: forwardedRef,\n ...rest\n}: BodyProps): ReactElement => {\n const scrollAreaRef = useRef<HTMLDivElement>(null)\n const ref = useMergeRefs(forwardedRef, scrollAreaRef)\n\n const { withFade } = useDialog()\n\n const { overflow } = useScrollOverflow(scrollAreaRef)\n\n return (\n <div\n data-spark-component=\"dialog-body\"\n ref={ref}\n className={cx(\n 'focus-visible:u-outline relative grow overflow-y-auto outline-hidden',\n 'transition-all duration-300',\n {\n ['px-xl py-lg']: !inset,\n },\n className\n )}\n style={{\n ...(withFade && {\n maskImage:\n 'linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1) 44px, rgba(0, 0, 0, 1) calc(100% - 44px), rgba(0, 0, 0, 0))',\n maskSize: `100% calc(100% + ${overflow.top ? '0px' : '44px'} + ${overflow.bottom ? '0px' : '44px'})`,\n maskPosition: `0 ${overflow.top ? '0px' : '-44px'}`,\n }),\n }}\n {...rest}\n >\n {children}\n </div>\n )\n}\n\nBody.displayName = 'Dialog.Body'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, Ref } from 'react'\n\nimport { useRenderSlot } from '../drawer/useRenderSlot'\n\nexport interface CloseProps extends Omit<ComponentProps<typeof BaseDialog.Close>, 'render'> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n ref?: Ref<HTMLButtonElement>\n}\n\nexport const Close = ({ asChild = false, ...props }: CloseProps) => {\n const renderSlot = useRenderSlot(asChild, 'button')\n\n return <BaseDialog.Close data-spark-component=\"dialog-close\" render={renderSlot} {...props} />\n}\n","import { Close as CloseSVG } from '@spark-ui/icons/Close'\nimport { cx } from 'class-variance-authority'\n\nimport { Icon } from '../icon'\nimport { IconButton, type IconButtonProps } from '../icon-button'\nimport { Close, CloseProps } from './DialogClose'\n\nexport type CloseButtonProps = CloseProps &\n Pick<IconButtonProps, 'size' | 'intent' | 'design' | 'aria-label'>\n\nconst Root = ({\n 'aria-label': ariaLabel,\n className,\n size = 'md',\n intent = 'neutral',\n design = 'ghost',\n children = <CloseSVG />,\n ref,\n ...rest\n}: CloseButtonProps) => {\n return (\n <Close\n data-spark-component=\"dialog-close-button\"\n data-part=\"close\"\n ref={ref}\n className={cx(['absolute', 'top-md', 'right-xl'], className)}\n asChild\n {...rest}\n >\n <IconButton intent={intent} size={size} design={design} aria-label={ariaLabel}>\n <Icon>{children}</Icon>\n </IconButton>\n </Close>\n )\n}\n\nexport const CloseButton = Object.assign(Root, {\n id: 'CloseButton',\n})\n\nRoot.displayName = 'Dialog.CloseButton'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref, useEffect } from 'react'\n\nimport { dialogContentStyles, type DialogContentStylesProps } from './DialogContent.styles'\nimport { useDialog } from './DialogContext'\n\nexport interface ContentProps\n extends Omit<ComponentProps<typeof BaseDialog.Popup>, 'render'>,\n DialogContentStylesProps {\n /**\n * When set to true, the content will adjust its width to fit the content rather than taking up the full available width.\n */\n isNarrow?: boolean\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Content = ({\n className,\n isNarrow = false,\n size = 'md',\n ref,\n ...rest\n}: ContentProps) => {\n const { setIsFullScreen } = useDialog()\n\n useEffect(() => {\n if (size === 'fullscreen') setIsFullScreen(true)\n\n return () => setIsFullScreen(false)\n }, [setIsFullScreen, size])\n\n return (\n <BaseDialog.Popup\n ref={ref}\n data-spark-component=\"dialog-content\"\n role=\"dialog\"\n className={state =>\n cx(\n dialogContentStyles({\n isNarrow,\n size,\n className: typeof className === 'function' ? className(state) : className,\n })\n )\n }\n {...rest}\n />\n )\n}\n\nContent.displayName = 'Dialog.Content'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, Ref } from 'react'\n\nexport type DescriptionProps = ComponentProps<typeof BaseDialog.Description> & {\n ref?: Ref<HTMLParagraphElement>\n}\n\nexport const Description = (props: DescriptionProps) => (\n <BaseDialog.Description data-spark-component=\"dialog-description\" {...props} />\n)\n\nDescription.displayName = 'Dialog.Description'\n","import { cx } from 'class-variance-authority'\nimport { type ReactElement, type ReactNode, Ref } from 'react'\n\nexport interface FooterProps {\n children: ReactNode\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Footer = ({ children, className, ref, ...rest }: FooterProps): ReactElement => (\n <footer\n data-spark-component=\"dialog-footer\"\n ref={ref}\n className={cx(className, ['px-xl', 'py-lg'])}\n {...rest}\n >\n {children}\n </footer>\n)\n\nFooter.displayName = 'Dialog.Footer'\n","import { cx } from 'class-variance-authority'\nimport { type ReactElement, type ReactNode, Ref } from 'react'\n\nexport interface HeaderProps {\n children: ReactNode\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Header = ({ children, className, ref, ...rest }: HeaderProps): ReactElement => (\n <header\n data-spark-component=\"dialog-header\"\n ref={ref}\n className={cx(className, ['px-xl', 'py-lg'])}\n {...rest}\n >\n {children}\n </header>\n)\n\nHeader.displayName = 'Dialog.Header'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nexport interface OverlayProps extends Omit<ComponentProps<typeof BaseDialog.Backdrop>, 'render'> {\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Overlay = ({ className, ...props }: OverlayProps) => {\n return (\n <BaseDialog.Backdrop\n data-spark-component=\"dialog-overlay\"\n className={state =>\n cx(\n 'z-overlay size-screen fixed inset-0',\n 'bg-overlay/dim-1',\n 'data-starting-style:animate-fade-in',\n 'data-ending-style:animate-fade-out',\n typeof className === 'function' ? className(state) : className\n )\n }\n {...props}\n />\n )\n}\n\nOverlay.displayName = 'Dialog.Overlay'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps } from 'react'\n\nexport type PortalProps = ComponentProps<typeof BaseDialog.Portal>\n\nexport const Portal = ({ className, ...props }: PortalProps) => {\n return (\n <BaseDialog.Portal\n data-spark-component=\"dialog-portal\"\n className={cx(className, 'z-modal absolute')}\n {...props}\n />\n )\n}\n\nPortal.displayName = 'Dialog.Portal'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nexport type TitleProps = ComponentProps<typeof BaseDialog.Title> & {\n ref?: Ref<HTMLHeadingElement>\n}\n\nexport const Title = ({ className, ref, ...others }: TitleProps) => {\n return (\n <BaseDialog.Title\n data-spark-component=\"dialog-title\"\n ref={ref}\n className={cx(\n 'text-headline-1 text-on-surface',\n 'group-has-data-[part=close]:pr-3xl',\n className\n )}\n {...others}\n />\n )\n}\n\nTitle.displayName = 'Dialog.Title'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, Ref } from 'react'\n\nimport { useRenderSlot } from '../drawer/useRenderSlot'\n\nexport interface TriggerProps extends Omit<ComponentProps<typeof BaseDialog.Trigger>, 'render'> {\n /**\n * Change the component to the HTML tag or custom component of the only child.\n */\n asChild?: boolean\n ref?: Ref<HTMLButtonElement>\n}\n\nexport const Trigger = ({ asChild = false, ...props }: TriggerProps) => {\n const renderSlot = useRenderSlot(asChild, 'button')\n\n return <BaseDialog.Trigger data-spark-component=\"dialog-trigger\" render={renderSlot} {...props} />\n}\n\nTrigger.displayName = 'Dialog.Trigger'\n","import { Dialog as Root } from './Dialog'\nimport { Body } from './DialogBody'\nimport { Close } from './DialogClose'\nimport { CloseButton } from './DialogCloseButton'\nimport { Content } from './DialogContent'\nimport { Description } from './DialogDescription' // aria-describedby\nimport { Footer } from './DialogFooter'\nimport { Header } from './DialogHeader'\nimport { Overlay } from './DialogOverlay'\nimport { Portal } from './DialogPortal'\nimport { Title } from './DialogTitle' // aria-labelledby\nimport { Trigger } from './DialogTrigger'\n\nexport const Dialog: typeof Root & {\n Trigger: typeof Trigger\n Portal: typeof Portal\n Overlay: typeof Overlay\n Content: typeof Content\n Header: typeof Header\n Body: typeof Body\n Footer: typeof Footer\n Close: typeof Close\n CloseButton: typeof CloseButton\n Title: typeof Title\n Description: typeof Description\n} = Object.assign(Root, {\n Trigger,\n Portal,\n Overlay,\n Content,\n Header,\n Body,\n Footer,\n Close,\n CloseButton,\n Title,\n Description,\n})\n\nDialog.displayName = 'Dialog'\n\nexport { type DialogProps } from './Dialog'\nexport { type ContentProps as DialogContentProps } from './DialogContent'\nexport { type HeaderProps as DialogHeaderProps } from './DialogHeader'\nexport { type BodyProps as DialogBodyProps } from './DialogBody'\nexport { type FooterProps as DialogFooterProps } from './DialogFooter'\nexport { type TriggerProps as DialogTriggerProps } from './DialogTrigger'\nexport { type OverlayProps as DialogOverlayProps } from './DialogOverlay'\nexport { type PortalProps as DialogPortalProps } from './DialogPortal'\nexport { type TitleProps as DialogTitleProps } from './DialogTitle'\nexport { type DescriptionProps as DialogDescriptionProps } from './DialogDescription'\nexport { type CloseProps as DialogCloseProps } from './DialogClose'\nexport { type CloseButtonProps as DialogCloseButtonProps } from './DialogCloseButton'\n"],"names":["DialogContext","createContext","DialogProvider","childrenProp","withFade","isFullScreen","setIsFullScreen","useState","jsx","useDialog","context","useContext","Dialog","onOpenChange","props","handleOpenChange","open","_eventDetails","BaseDialog","Body","children","className","inset","forwardedRef","rest","scrollAreaRef","useRef","ref","useMergeRefs","overflow","useScrollOverflow","cx","Close","asChild","renderSlot","useRenderSlot","Root","ariaLabel","size","intent","design","CloseSVG","IconButton","Icon","CloseButton","Content","isNarrow","useEffect","state","dialogContentStyles","Description","Footer","Header","Overlay","Portal","Title","others","Trigger"],"mappings":";;;;;;;;;;;AAQA,MAAMA,IAAgBC,EAAyC,IAAI,GAEtDC,IAAiB,CAAC;AAAA,EAC7B,UAAUC;AAAA,EACV,UAAAC,IAAW;AACb,MAGM;AACJ,QAAM,CAACC,GAAcC,CAAe,IAAIC,EAAS,EAAK;AAEtD,SACE,gBAAAC;AAAA,IAACR,EAAc;AAAA,IAAd;AAAA,MACC,OAAO;AAAA,QACL,cAAAK;AAAA,QACA,iBAAAC;AAAA,QACA,UAAAF;AAAA,MAAA;AAAA,MAGD,UAAAD;AAAA,IAAA;AAAA,EAAA;AAGP,GAEaM,IAAY,MAAM;AAC7B,QAAMC,IAAUC,EAAWX,CAAa;AAExC,MAAI,CAACU;AACH,UAAM,MAAM,iDAAiD;AAG/D,SAAOA;AACT,GCPaE,IAAS,CAAC,EAAE,UAAAR,IAAW,IAAO,cAAAS,GAAc,G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AMC,IAAS,CAAC,EAAE,WAAAjC,GAAW,GAAGP,QAEnC,gBAAAN;AAAA,EAACU,EAAW;AAAA,EAAX;AAAA,IACC,wBAAqB;AAAA,IACrB,WAAWa,EAAGV,GAAW,kBAAkB;AAAA,IAC1C,GAAGP;AAAA,EAAA;AAAA;AAKVwC,EAAO,cAAc;ACRd,MAAMC,IAAQ,CAAC,EAAE,WAAAlC,GAAW,KAAAM,GAAK,GAAG6B,QAEvC,gBAAAhD;AAAA,EAACU,EAAW;AAAA,EAAX;AAAA,IACC,wBAAqB;AAAA,IACrB,KAAAS;AAAA,IACA,WAAWI;AAAA,MACT;AAAA,MACA;AAAA,MACAV;AAAA,IAAA;AAAA,IAED,GAAGmC;AAAA,EAAA;AAAA;AAKVD,EAAM,cAAc;ACVb,MAAME,IAAU,CAAC,EAAE,SAAAxB,IAAU,IAAO,GAAGnB,QAA0B;AACtE,QAAMoB,IAAaC,EAAcF,GAAS,QAAQ;AAElD,SAAO,gBAAAzB,EAACU,EAAW,SAAX,EAAmB,wBAAqB,kBAAiB,QAAQgB,GAAa,GAAGpB,GAAO;AAClG;AAEA2C,EAAQ,cAAc;ACNf,MAAM7C,IAYT,OAAO,OAAOwB,GAAM;AAAA,EACtB,SAAAqB;AAAA,EACA,QAAAH;AAAA,EACA,SAAAD;AAAA,EACA,SAAAR;AAAA,EACA,QAAAO;AAAA,EACA,MAAAjC;AAAA,EACA,QAAAgC;AAAA,EACA,OAAAnB;AAAA,EACA,aAAAY;AAAA,EACA,OAAAW;AAAA,EACA,aAAAL;AACF,CAAC;AAEDtC,EAAO,cAAc;"}
|
package/dist/form-field/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),u=require("class-variance-authority"),n=require("react"),$=require("../Slot-DQ8z2zsy.js"),z=require("@spark-ui/icons/AlertOutline"),V=require("@spark-ui/icons/Check"),w=require("@spark-ui/icons/WarningOutline"),I=require("../Icon-CF0W0LKr.js"),W=require("../label/index.js"),M=require("../FormFieldRequiredIndicator-CHfcoT2y.js"),N=n.createContext(null),j=":form-field",y=()=>{const s=n.useContext(N);if(!s)throw Error("useFormField must be used within a FormField provider");return s},E=({id:s,name:e,disabled:t=!1,readOnly:l=!1,state:o,isRequired:i,children:d})=>{const a=`${j}-label-${n.useId()}`,[c,m]=n.useState([]),F=c.length>0?c.join(" "):void 0,g=n.useCallback(x=>{m(h=>[...h,x])},[]),A=n.useCallback(x=>{m(h=>h.filter(T=>T!==x))},[]),L=n.useMemo(()=>({id:s,labelId:a,name:e,disabled:t,readOnly:l,state:o,isRequired:i,isInvalid:o==="error",description:F,onMessageIdAdd:g,onMessageIdRemove:A}),[s,a,e,t,l,F,o,i,g,A]);return r.jsx(N.Provider,{value:L,children:d})};E.displayName="FormFieldProvider";const O=({className:s,disabled:e=!1,readOnly:t=!1,name:l,state:o,isRequired:i=!1,asChild:d=!1,ref:a,...c})=>{const m=`${j}-${n.useId()}`,F=d?$.Slot:"div";return r.jsx(E,{id:m,name:l,isRequired:i,disabled:e,readOnly:t,state:o,children:r.jsx(F,{ref:a,"data-spark-component":"form-field",className:u.cx(s,"gap-sm flex flex-col"),...c})})};O.displayName="FormField";const f=({id:s,className:e,ref:t,...l})=>{const{onMessageIdAdd:o,onMessageIdRemove:i}=y(),d=`${j}-message-${n.useId()}`,a=s||d;return n.useEffect(()=>(o(a),()=>{i(a)}),[a,o,i]),r.jsx("span",{ref:t,id:a,"data-spark-component":"form-field-message",className:u.cx(e,"text-caption"),...l})};f.displayName="FormField.Message";const p=({className:s,state:e,children:t,ref:l,...o})=>y().state!==e?null:r.jsxs(f,{ref:l,"data-spark-component":"form-field-state-message",className:u.cx("gap-sm flex items-center",e==="error"?"text-error":"text-on-surface/dim-1",s),...o,children:[e==="alert"&&r.jsx(I.Icon,{size:"sm",children:r.jsx(w.WarningOutline,{})}),e==="error"&&r.jsx(I.Icon,{size:"sm",intent:"error",children:r.jsx(z.AlertOutline,{})}),e==="success"&&r.jsx(I.Icon,{size:"sm",children:r.jsx(V.Check,{})}),t]});p.displayName="FormField.StateMessage";const C=({ref:s,...e})=>r.jsx(p,{ref:s,"data-spark-component":"form-field-alert-message",state:"alert",...e});C.displayName="FormField.AlertMessage";const b=({className:s,value:e="",maxLength:t,description:l,liveAnnouncement:o,ref:i,...d})=>{const[a,c]=n.useState(e);return n.useEffect(()=>{const m=setTimeout(()=>{c(e)},1e3);return()=>clearTimeout(m)},[e]),r.jsxs("span",{className:"ml-auto self-start",children:[l&&r.jsx(f,{className:"default:sr-only",children:l}),r.jsx("span",{ref:i,"aria-hidden":!0,"data-spark-component":"form-field-characters-count",className:u.cx(s,"text-caption","text-neutral"),...d,children:`${e.length}/${t}`}),o&&r.jsx("span",{className:"sr-only","aria-live":"polite",children:o({remainingChars:t-a.length})})]})};b.displayName="FormField.CharactersCount";const P=()=>{const{id:s,name:e,description:t,disabled:l,readOnly:o,state:i,labelId:d,isInvalid:a,isRequired:c}=n.useContext(N)||{};return{id:s,name:e,description:t,disabled:l,readOnly:o,state:i,labelId:d,isInvalid:a,isRequired:c}},q=({children:s})=>{const e=P();return r.jsx(r.Fragment,{children:s(e)})};q.displayName="FormField.Control";const S=({ref:s,...e})=>r.jsx(p,{ref:s,"data-spark-component":"form-field-error-message",state:"error",...e});S.displayName="FormField.ErrorMessage";const v=({className:s,ref:e,...t})=>r.jsx(f,{ref:e,"data-spark-component":"form-field-helper-message",className:u.cx("text-on-surface/dim-1",s),...t});v.displayName="FormField.HelperMessage";const k=({htmlFor:s,className:e,children:t,requiredIndicator:l=r.jsx(M.FormFieldRequiredIndicator,{}),asChild:o,ref:i,...d})=>{const a=y(),{disabled:c,labelId:m,isRequired:F}=a,g=o?void 0:s||a.id;return r.jsx(W.Label,{ref:i,id:m,"data-spark-component":"form-field-label",htmlFor:g,className:u.cx(e,c?"text-on-surface/dim-3 pointer-events-none":void 0),asChild:o,...d,children:r.jsxs(r.Fragment,{children:[r.jsx($.Slottable,{children:t}),F&&l]})})};k.displayName="FormField.Label";const R=({ref:s,...e})=>r.jsx(p,{ref:s,"data-spark-component":"form-field-success-message",state:"success",...e});R.displayName="FormField.SuccessMessage";const H=Object.assign(O,{Label:k,Control:q,StateMessage:p,SuccessMessage:R,AlertMessage:C,ErrorMessage:S,HelperMessage:v,RequiredIndicator:M.FormFieldRequiredIndicator,CharactersCount:b});H.displayName="FormField";k.displayName="FormField.Label";q.displayName="FormField.Control";p.displayName="FormField.StateMessage";R.displayName="FormField.SuccessMessage";C.displayName="FormField.AlertMessage";S.displayName="FormField.ErrorMessage";v.displayName="FormField.HelperMessage";M.FormFieldRequiredIndicator.displayName="FormField.RequiredIndicator";b.displayName="FormField.CharactersCount";exports.FormField=H;exports.useFormFieldControl=P;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/form-field/FormFieldContext.tsx","../../src/form-field/FormFieldProvider.tsx","../../src/form-field/FormField.tsx","../../src/form-field/FormFieldMessage.tsx","../../src/form-field/FormFieldStateMessage.tsx","../../src/form-field/FormFieldAlertMessage.tsx","../../src/form-field/FormFieldCharactersCount.tsx","../../src/form-field/FormFieldControl.tsx","../../src/form-field/FormFieldErrorMessage.tsx","../../src/form-field/FormFieldHelperMessage.tsx","../../src/form-field/FormFieldRequiredIndicator.tsx","../../src/form-field/FormFieldLabel.tsx","../../src/form-field/FormFieldSuccessMessage.tsx","../../src/form-field/index.ts"],"sourcesContent":["import { createContext, useContext } from 'react'\n\nexport interface FormFieldContextState {\n /**\n * Generated id for the input component.\n */\n id: string\n /**\n * Generated id for the label component.\n */\n labelId?: string\n /**\n * The name of the input. Submitted with its owning form as part of a name/value pair.\n */\n name?: string\n /**\n * A set of ids separated by a space used to describe the input component given by a set of messages.\n */\n description?: string\n /**\n * Disables the field and its associated input\n */\n disabled?: boolean\n /**\n * Marks the field and its associated input as read only\n */\n readOnly?: boolean\n /**\n * The validation state of the input.\n */\n state?: 'error' | 'success' | 'alert'\n /**\n * If true, the form field will be invalid.\n */\n isInvalid?: boolean\n /**\n * If true, the form field will be required.\n */\n isRequired?: boolean\n /**\n * Callback used to store a descriptive message.\n */\n onMessageIdAdd: (id: string) => void\n /**\n * Callback used to remove a descriptive message.\n */\n onMessageIdRemove: (id: string) => void\n}\n\nexport const FormFieldContext = createContext<FormFieldContextState | null>(null)\n\nexport const ID_PREFIX = ':form-field'\n\nexport const useFormField = () => {\n const context = useContext(FormFieldContext)\n\n if (!context) {\n throw Error('useFormField must be used within a FormField provider')\n }\n\n return context\n}\n","import { ReactNode, useCallback, useId, useMemo, useState } from 'react'\n\nimport { FormFieldContext, FormFieldContextState, ID_PREFIX } from './FormFieldContext'\n\nexport interface FormFieldProviderProps\n extends Pick<\n FormFieldContextState,\n 'id' | 'name' | 'disabled' | 'readOnly' | 'state' | 'isRequired'\n > {\n children: ReactNode\n}\n\nexport const FormFieldProvider = ({\n id,\n name,\n disabled = false,\n readOnly = false,\n state,\n isRequired,\n children,\n}: FormFieldProviderProps) => {\n const labelId = `${ID_PREFIX}-label-${useId()}`\n const [messageIds, setMessageIds] = useState<string[]>([])\n const description = messageIds.length > 0 ? messageIds.join(' ') : undefined\n\n const handleMessageIdAdd = useCallback((msgId: string) => {\n setMessageIds(ids => [...ids, msgId])\n }, [])\n\n const handleMessageIdRemove = useCallback((msgId: string) => {\n setMessageIds(ids => ids.filter(current => current !== msgId))\n }, [])\n\n const value = useMemo(() => {\n const isInvalid = state === 'error'\n\n return {\n id,\n labelId,\n name,\n disabled,\n readOnly,\n state,\n isRequired,\n isInvalid,\n description,\n onMessageIdAdd: handleMessageIdAdd,\n onMessageIdRemove: handleMessageIdRemove,\n }\n }, [\n id,\n labelId,\n name,\n disabled,\n readOnly,\n description,\n state,\n isRequired,\n handleMessageIdAdd,\n handleMessageIdRemove,\n ])\n\n return <FormFieldContext.Provider value={value}>{children}</FormFieldContext.Provider>\n}\n\nFormFieldProvider.displayName = 'FormFieldProvider'\n","import { cx } from 'class-variance-authority'\nimport { ComponentPropsWithoutRef, Ref, useId } from 'react'\n\nimport { Slot } from '../slot'\nimport { FormFieldContextState, ID_PREFIX } from './FormFieldContext'\nimport { FormFieldProvider } from './FormFieldProvider'\n\nexport interface FormFieldProps\n extends ComponentPropsWithoutRef<'div'>,\n Pick<FormFieldContextState, 'name' | 'state' | 'isRequired'> {\n /**\n * Change the component to the HTML tag or custom component of the only child. This will merge the original component props with the props of the supplied element/component and change the underlying DOM node.\n */\n asChild?: boolean\n /**\n * When `true`, prevents the user from interacting.\n */\n disabled?: boolean\n /**\n * Sets the component as interactive or not.\n */\n readOnly?: boolean\n ref?: Ref<HTMLDivElement>\n}\n\nexport const FormField = ({\n className,\n disabled = false,\n readOnly = false,\n name,\n state,\n isRequired = false,\n asChild = false,\n ref,\n ...others\n}: FormFieldProps) => {\n const id = `${ID_PREFIX}-${useId()}`\n const Component = asChild ? Slot : 'div'\n\n return (\n <FormFieldProvider\n id={id}\n name={name}\n isRequired={isRequired}\n disabled={disabled}\n readOnly={readOnly}\n state={state}\n >\n <Component\n ref={ref}\n data-spark-component=\"form-field\"\n className={cx(className, 'gap-sm flex flex-col')}\n {...others}\n />\n </FormFieldProvider>\n )\n}\n\nFormField.displayName = 'FormField'\n","import { cx } from 'class-variance-authority'\nimport { ComponentPropsWithoutRef, Ref, useEffect, useId } from 'react'\n\nimport { ID_PREFIX, useFormField } from './FormFieldContext'\n\nexport type FormFieldMessageProps = ComponentPropsWithoutRef<'span'> & {\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldMessage = ({\n id: idProp,\n className,\n ref,\n ...others\n}: FormFieldMessageProps) => {\n const { onMessageIdAdd, onMessageIdRemove } = useFormField()\n const currentId = `${ID_PREFIX}-message-${useId()}`\n const id = idProp || currentId\n\n useEffect(() => {\n onMessageIdAdd(id)\n\n return () => {\n onMessageIdRemove(id)\n }\n }, [id, onMessageIdAdd, onMessageIdRemove])\n\n return (\n <span\n ref={ref}\n id={id}\n data-spark-component=\"form-field-message\"\n className={cx(className, 'text-caption')}\n {...others}\n />\n )\n}\n\nFormFieldMessage.displayName = 'FormField.Message'\n","import { AlertOutline } from '@spark-ui/icons/AlertOutline'\nimport { Check } from '@spark-ui/icons/Check'\nimport { WarningOutline } from '@spark-ui/icons/WarningOutline'\nimport { cx } from 'class-variance-authority'\nimport { Ref } from 'react'\n\nimport { Icon } from '../icon'\nimport { useFormField } from './FormFieldContext'\nimport { FormFieldMessage, FormFieldMessageProps } from './FormFieldMessage'\n\nexport interface FormFieldStateMessageProps extends FormFieldMessageProps {\n state: 'error' | 'alert' | 'success'\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldStateMessage = ({\n className,\n state,\n children,\n ref,\n ...others\n}: FormFieldStateMessageProps) => {\n const field = useFormField()\n\n if (field.state !== state) {\n return null\n }\n\n return (\n <FormFieldMessage\n ref={ref}\n data-spark-component=\"form-field-state-message\"\n className={cx(\n 'gap-sm flex items-center',\n state === 'error' ? 'text-error' : 'text-on-surface/dim-1',\n className\n )}\n {...others}\n >\n {state === 'alert' && (\n <Icon size=\"sm\">\n <WarningOutline />\n </Icon>\n )}\n {state === 'error' && (\n <Icon size=\"sm\" intent=\"error\">\n <AlertOutline />\n </Icon>\n )}\n {state === 'success' && (\n <Icon size=\"sm\">\n <Check />\n </Icon>\n )}\n\n {children}\n </FormFieldMessage>\n )\n}\n\nFormFieldStateMessage.displayName = 'FormField.StateMessage'\n","import { Ref } from 'react'\n\nimport { FormFieldStateMessage, FormFieldStateMessageProps } from './FormFieldStateMessage'\n\nexport type FormFieldAlertMessageProps = Omit<FormFieldStateMessageProps, 'state'> & {\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldAlertMessage = ({ ref, ...props }: FormFieldAlertMessageProps) => {\n return (\n <FormFieldStateMessage\n ref={ref}\n data-spark-component=\"form-field-alert-message\"\n state=\"alert\"\n {...props}\n />\n )\n}\n\nFormFieldAlertMessage.displayName = 'FormField.AlertMessage'\n","import { cx } from 'class-variance-authority'\nimport { ComponentPropsWithoutRef, Ref, useEffect, useState } from 'react'\n\nimport { FormFieldMessage } from './FormFieldMessage'\n\nexport type FormFieldCharactersCountProps = ComponentPropsWithoutRef<'span'> & {\n /**\n * This description is for the screen reader, read when the input is focused.\n */\n description?: string\n /**\n * The live announcement is for the screen read after a delay once the input value changes.\n */\n liveAnnouncement?: ({ remainingChars }: { remainingChars: number }) => string\n /**\n * Current value for the input this component belongs to.\n */\n value?: string\n /**\n * Maximum numeric value to be displayed.\n */\n maxLength: number\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldCharactersCount = ({\n className,\n value = '',\n maxLength,\n description,\n liveAnnouncement,\n ref,\n ...others\n}: FormFieldCharactersCountProps) => {\n const [throttledValue, setThrottledValue] = useState(value)\n\n /**\n * The value is throttled to avoid spamming the aria-live region (and consequently the screen reader).\n */\n useEffect(() => {\n const timeoutId = setTimeout(() => {\n setThrottledValue(value)\n }, 1000)\n\n return () => clearTimeout(timeoutId)\n }, [value])\n\n return (\n <span className=\"ml-auto self-start\">\n {description && (\n <FormFieldMessage className=\"default:sr-only\">{description}</FormFieldMessage>\n )}\n <span\n ref={ref}\n aria-hidden\n data-spark-component=\"form-field-characters-count\"\n className={cx(className, 'text-caption', 'text-neutral')}\n {...others}\n >\n {`${value.length}/${maxLength}`}\n </span>\n\n {liveAnnouncement && (\n <span className=\"sr-only\" aria-live=\"polite\">\n {liveAnnouncement({ remainingChars: maxLength - throttledValue.length })}\n </span>\n )}\n </span>\n )\n}\n\nFormFieldCharactersCount.displayName = 'FormField.CharactersCount'\n","import { ReactNode, useContext } from 'react'\n\nimport { FormFieldContext, FormFieldContextState } from './FormFieldContext'\n\ntype State = Partial<\n Pick<\n FormFieldContextState,\n | 'id'\n | 'name'\n | 'description'\n | 'labelId'\n | 'disabled'\n | 'readOnly'\n | 'state'\n | 'isInvalid'\n | 'isRequired'\n >\n>\n\nexport interface FormFieldControlProps {\n children: (state: State) => ReactNode\n}\n\nexport const useFormFieldControl = () => {\n const { id, name, description, disabled, readOnly, state, labelId, isInvalid, isRequired } =\n useContext(FormFieldContext) || {}\n\n return {\n id,\n name,\n description,\n disabled,\n readOnly,\n state,\n labelId,\n isInvalid,\n isRequired,\n } as State\n}\n\nexport const FormFieldControl = ({ children }: FormFieldControlProps) => {\n const props = useFormFieldControl()\n\n return <>{children(props)}</>\n}\n\nFormFieldControl.displayName = 'FormField.Control'\n","import { Ref } from 'react'\n\nimport { FormFieldStateMessage, FormFieldStateMessageProps } from './FormFieldStateMessage'\n\nexport type FormFieldErrorMessageProps = Omit<FormFieldStateMessageProps, 'state'> & {\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldErrorMessage = ({ ref, ...props }: FormFieldErrorMessageProps) => {\n return (\n <FormFieldStateMessage\n ref={ref}\n data-spark-component=\"form-field-error-message\"\n state=\"error\"\n {...props}\n />\n )\n}\n\nFormFieldErrorMessage.displayName = 'FormField.ErrorMessage'\n","import { cx } from 'class-variance-authority'\nimport { Ref } from 'react'\n\nimport { FormFieldMessage, FormFieldMessageProps } from './FormFieldMessage'\n\nexport type FormFieldHelperMessageProps = FormFieldMessageProps & {\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldHelperMessage = ({\n className,\n ref,\n ...others\n}: FormFieldHelperMessageProps) => {\n return (\n <FormFieldMessage\n ref={ref}\n data-spark-component=\"form-field-helper-message\"\n className={cx('text-on-surface/dim-1', className)}\n {...others}\n />\n )\n}\n\nFormFieldHelperMessage.displayName = 'FormField.HelperMessage'\n","import { cx } from 'class-variance-authority'\nimport { Ref } from 'react'\n\nimport { Label, LabelRequiredIndicatorProps } from '../label'\n\nexport type FormFieldRequiredIndicatorProps = LabelRequiredIndicatorProps & {\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldRequiredIndicator = ({\n className,\n ref,\n ...props\n}: FormFieldRequiredIndicatorProps) => {\n return <Label.RequiredIndicator ref={ref} className={cx('ml-sm', className)} {...props} />\n}\n\nFormFieldRequiredIndicator.displayName = 'FormField.RequiredIndicator'\n","import { cx } from 'class-variance-authority'\nimport { ReactNode, Ref } from 'react'\n\nimport { Label, LabelProps } from '../label'\nimport { Slottable } from '../slot'\nimport { useFormField } from './FormFieldContext'\nimport { FormFieldRequiredIndicator } from './FormFieldRequiredIndicator'\n\nexport interface FormFieldLabelProps extends LabelProps {\n /**\n * Element shown when the input is required inside the label.\n */\n requiredIndicator?: ReactNode\n ref?: Ref<HTMLLabelElement>\n}\n\nexport const FormFieldLabel = ({\n htmlFor: htmlForProp,\n className,\n children,\n requiredIndicator = <FormFieldRequiredIndicator />,\n asChild,\n ref,\n ...others\n}: FormFieldLabelProps) => {\n const control = useFormField()\n\n const { disabled, labelId, isRequired } = control\n const htmlFor = asChild ? undefined : htmlForProp || control.id\n\n return (\n <Label\n ref={ref}\n id={labelId}\n data-spark-component=\"form-field-label\"\n htmlFor={htmlFor}\n className={cx(className, disabled ? 'text-on-surface/dim-3 pointer-events-none' : undefined)}\n asChild={asChild}\n {...others}\n >\n <>\n <Slottable>{children}</Slottable>\n {isRequired && requiredIndicator}\n </>\n </Label>\n )\n}\n\nFormFieldLabel.displayName = 'FormField.Label'\n","import { Ref } from 'react'\n\nimport { FormFieldStateMessage, FormFieldStateMessageProps } from './FormFieldStateMessage'\n\nexport type FormFieldSuccessMessageProps = Omit<FormFieldStateMessageProps, 'state'> & {\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldSuccessMessage = ({ ref, ...props }: FormFieldSuccessMessageProps) => {\n return (\n <FormFieldStateMessage\n ref={ref}\n data-spark-component=\"form-field-success-message\"\n state=\"success\"\n {...props}\n />\n )\n}\n\nFormFieldSuccessMessage.displayName = 'FormField.SuccessMessage'\n","import { FormField as Root } from './FormField'\nimport { FormFieldAlertMessage } from './FormFieldAlertMessage'\nimport { FormFieldCharactersCount } from './FormFieldCharactersCount'\nimport { FormFieldControl } from './FormFieldControl'\nimport { FormFieldErrorMessage } from './FormFieldErrorMessage'\nimport { FormFieldHelperMessage } from './FormFieldHelperMessage'\nimport { FormFieldLabel } from './FormFieldLabel'\nimport { FormFieldRequiredIndicator } from './FormFieldRequiredIndicator'\nimport { FormFieldStateMessage } from './FormFieldStateMessage'\nimport { FormFieldSuccessMessage } from './FormFieldSuccessMessage'\n\nexport const FormField: typeof Root & {\n Label: typeof FormFieldLabel\n Control: typeof FormFieldControl\n StateMessage: typeof FormFieldStateMessage\n SuccessMessage: typeof FormFieldSuccessMessage\n AlertMessage: typeof FormFieldAlertMessage\n ErrorMessage: typeof FormFieldErrorMessage\n HelperMessage: typeof FormFieldHelperMessage\n RequiredIndicator: typeof FormFieldRequiredIndicator\n CharactersCount: typeof FormFieldCharactersCount\n} = Object.assign(Root, {\n Label: FormFieldLabel,\n Control: FormFieldControl,\n StateMessage: FormFieldStateMessage,\n SuccessMessage: FormFieldSuccessMessage,\n AlertMessage: FormFieldAlertMessage,\n ErrorMessage: FormFieldErrorMessage,\n HelperMessage: FormFieldHelperMessage,\n RequiredIndicator: FormFieldRequiredIndicator,\n CharactersCount: FormFieldCharactersCount,\n})\n\nFormField.displayName = 'FormField'\nFormFieldLabel.displayName = 'FormField.Label'\nFormFieldControl.displayName = 'FormField.Control'\nFormFieldStateMessage.displayName = 'FormField.StateMessage'\nFormFieldSuccessMessage.displayName = 'FormField.SuccessMessage'\nFormFieldAlertMessage.displayName = 'FormField.AlertMessage'\nFormFieldErrorMessage.displayName = 'FormField.ErrorMessage'\nFormFieldHelperMessage.displayName = 'FormField.HelperMessage'\nFormFieldRequiredIndicator.displayName = 'FormField.RequiredIndicator'\nFormFieldCharactersCount.displayName = 'FormField.CharactersCount'\n\nexport { type FormFieldProps } from './FormField'\nexport { type FormFieldStateMessageProps } from './FormFieldStateMessage'\nexport { type FormFieldControl, useFormFieldControl } from './FormFieldControl'\nexport { type FormFieldHelperMessageProps } from './FormFieldHelperMessage'\nexport { type FormFieldSuccessMessageProps } from './FormFieldSuccessMessage'\nexport { type FormFieldAlertMessageProps } from './FormFieldAlertMessage'\nexport { type FormFieldErrorMessageProps } from './FormFieldErrorMessage'\nexport { type FormFieldLabelProps } from './FormFieldLabel'\nexport { type FormFieldRequiredIndicatorProps } from './FormFieldRequiredIndicator'\nexport { type FormFieldCharactersCountProps } from './FormFieldCharactersCount'\n"],"names":["FormFieldContext","createContext","ID_PREFIX","useFormField","context","useContext","FormFieldProvider","id","name","disabled","readOnly","state","isRequired","children","labelId","useId","messageIds","setMessageIds","useState","description","handleMessageIdAdd","useCallback","msgId","ids","handleMessageIdRemove","current","value","useMemo","jsx","FormField","className","asChild","ref","others","Component","Slot","cx","FormFieldMessage","idProp","onMessageIdAdd","onMessageIdRemove","currentId","useEffect","FormFieldStateMessage","jsxs","Icon","WarningOutline","AlertOutline","Check","FormFieldAlertMessage","props","FormFieldCharactersCount","maxLength","liveAnnouncement","throttledValue","setThrottledValue","timeoutId","useFormFieldControl","isInvalid","FormFieldControl","Fragment","FormFieldErrorMessage","FormFieldHelperMessage","FormFieldRequiredIndicator","Label","FormFieldLabel","htmlForProp","requiredIndicator","control","htmlFor","Slottable","FormFieldSuccessMessage","Root"],"mappings":"wYAiDaA,EAAmBC,EAAAA,cAA4C,IAAI,EAEnEC,EAAY,cAEZC,EAAe,IAAM,CAChC,MAAMC,EAAUC,EAAAA,WAAWL,CAAgB,EAE3C,GAAI,CAACI,EACH,MAAM,MAAM,uDAAuD,EAGrE,OAAOA,CACT,ECjDaE,EAAoB,CAAC,CAChC,GAAAC,EACA,KAAAC,EACA,SAAAC,EAAW,GACX,SAAAC,EAAW,GACX,MAAAC,EACA,WAAAC,EACA,SAAAC,CACF,IAA8B,CAC5B,MAAMC,EAAU,GAAGZ,CAAS,UAAUa,EAAAA,OAAO,GACvC,CAACC,EAAYC,CAAa,EAAIC,EAA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AAuD,EACA,UAAWjC,EAAAA,GAAGN,EAAWrB,EAAW,4CAA8C,MAAS,EAC3F,QAAAsB,EACC,GAAGE,EAEJ,SAAAW,EAAAA,KAAAgB,WAAA,CACE,SAAA,CAAAhC,MAAC0C,EAAAA,WAAW,SAAAzD,EAAS,EACpBD,GAAcuD,CAAA,CAAA,CACjB,CAAA,CAAA,CAGN,EAEAF,EAAe,YAAc,kBCxCtB,MAAMM,EAA0B,CAAC,CAAE,IAAAvC,EAAK,GAAGkB,KAE9CtB,EAAAA,IAACe,EAAA,CACC,IAAAX,EACA,uBAAqB,6BACrB,MAAM,UACL,GAAGkB,CAAA,CAAA,EAKVqB,EAAwB,YAAc,2BCR/B,MAAM1C,EAUT,OAAO,OAAO2C,EAAM,CACtB,MAAOP,EACP,QAASN,EACT,aAAchB,EACd,eAAgB4B,EAChB,aAActB,EACd,aAAcY,EACd,cAAeC,EACf,kBAAmBC,EACnB,gBAAiBZ,CACnB,CAAC,EAEDtB,EAAU,YAAc,YACxBoC,EAAe,YAAc,kBAC7BN,EAAiB,YAAc,oBAC/BhB,EAAsB,YAAc,yBACpC4B,EAAwB,YAAc,2BACtCtB,EAAsB,YAAc,yBACpCY,EAAsB,YAAc,yBACpCC,EAAuB,YAAc,0BACrCC,EAA2B,YAAc,8BACzCZ,EAAyB,YAAc"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/form-field/FormFieldContext.tsx","../../src/form-field/FormFieldProvider.tsx","../../src/form-field/FormField.tsx","../../src/form-field/FormFieldMessage.tsx","../../src/form-field/FormFieldStateMessage.tsx","../../src/form-field/FormFieldAlertMessage.tsx","../../src/form-field/FormFieldCharactersCount.tsx","../../src/form-field/FormFieldControl.tsx","../../src/form-field/FormFieldErrorMessage.tsx","../../src/form-field/FormFieldHelperMessage.tsx","../../src/form-field/FormFieldLabel.tsx","../../src/form-field/FormFieldSuccessMessage.tsx","../../src/form-field/index.ts"],"sourcesContent":["import { createContext, useContext } from 'react'\n\nexport interface FormFieldContextState {\n /**\n * Generated id for the input component.\n */\n id: string\n /**\n * Generated id for the label component.\n */\n labelId?: string\n /**\n * The name of the input. Submitted with its owning form as part of a name/value pair.\n */\n name?: string\n /**\n * A set of ids separated by a space used to describe the input component given by a set of messages.\n */\n description?: string\n /**\n * Disables the field and its associated input\n */\n disabled?: boolean\n /**\n * Marks the field and its associated input as read only\n */\n readOnly?: boolean\n /**\n * The validation state of the input.\n */\n state?: 'error' | 'success' | 'alert'\n /**\n * If true, the form field will be invalid.\n */\n isInvalid?: boolean\n /**\n * If true, the form field will be required.\n */\n isRequired?: boolean\n /**\n * Callback used to store a descriptive message.\n */\n onMessageIdAdd: (id: string) => void\n /**\n * Callback used to remove a descriptive message.\n */\n onMessageIdRemove: (id: string) => void\n}\n\nexport const FormFieldContext = createContext<FormFieldContextState | null>(null)\n\nexport const ID_PREFIX = ':form-field'\n\nexport const useFormField = () => {\n const context = useContext(FormFieldContext)\n\n if (!context) {\n throw Error('useFormField must be used within a FormField provider')\n }\n\n return context\n}\n","import { ReactNode, useCallback, useId, useMemo, useState } from 'react'\n\nimport { FormFieldContext, FormFieldContextState, ID_PREFIX } from './FormFieldContext'\n\nexport interface FormFieldProviderProps\n extends Pick<\n FormFieldContextState,\n 'id' | 'name' | 'disabled' | 'readOnly' | 'state' | 'isRequired'\n > {\n children: ReactNode\n}\n\nexport const FormFieldProvider = ({\n id,\n name,\n disabled = false,\n readOnly = false,\n state,\n isRequired,\n children,\n}: FormFieldProviderProps) => {\n const labelId = `${ID_PREFIX}-label-${useId()}`\n const [messageIds, setMessageIds] = useState<string[]>([])\n const description = messageIds.length > 0 ? messageIds.join(' ') : undefined\n\n const handleMessageIdAdd = useCallback((msgId: string) => {\n setMessageIds(ids => [...ids, msgId])\n }, [])\n\n const handleMessageIdRemove = useCallback((msgId: string) => {\n setMessageIds(ids => ids.filter(current => current !== msgId))\n }, [])\n\n const value = useMemo(() => {\n const isInvalid = state === 'error'\n\n return {\n id,\n labelId,\n name,\n disabled,\n readOnly,\n state,\n isRequired,\n isInvalid,\n description,\n onMessageIdAdd: handleMessageIdAdd,\n onMessageIdRemove: handleMessageIdRemove,\n }\n }, [\n id,\n labelId,\n name,\n disabled,\n readOnly,\n description,\n state,\n isRequired,\n handleMessageIdAdd,\n handleMessageIdRemove,\n ])\n\n return <FormFieldContext.Provider value={value}>{children}</FormFieldContext.Provider>\n}\n\nFormFieldProvider.displayName = 'FormFieldProvider'\n","import { cx } from 'class-variance-authority'\nimport { ComponentPropsWithoutRef, Ref, useId } from 'react'\n\nimport { Slot } from '../slot'\nimport { FormFieldContextState, ID_PREFIX } from './FormFieldContext'\nimport { FormFieldProvider } from './FormFieldProvider'\n\nexport interface FormFieldProps\n extends ComponentPropsWithoutRef<'div'>,\n Pick<FormFieldContextState, 'name' | 'state' | 'isRequired'> {\n /**\n * Change the component to the HTML tag or custom component of the only child. This will merge the original component props with the props of the supplied element/component and change the underlying DOM node.\n */\n asChild?: boolean\n /**\n * When `true`, prevents the user from interacting.\n */\n disabled?: boolean\n /**\n * Sets the component as interactive or not.\n */\n readOnly?: boolean\n ref?: Ref<HTMLDivElement>\n}\n\nexport const FormField = ({\n className,\n disabled = false,\n readOnly = false,\n name,\n state,\n isRequired = false,\n asChild = false,\n ref,\n ...others\n}: FormFieldProps) => {\n const id = `${ID_PREFIX}-${useId()}`\n const Component = asChild ? Slot : 'div'\n\n return (\n <FormFieldProvider\n id={id}\n name={name}\n isRequired={isRequired}\n disabled={disabled}\n readOnly={readOnly}\n state={state}\n >\n <Component\n ref={ref}\n data-spark-component=\"form-field\"\n className={cx(className, 'gap-sm flex flex-col')}\n {...others}\n />\n </FormFieldProvider>\n )\n}\n\nFormField.displayName = 'FormField'\n","import { cx } from 'class-variance-authority'\nimport { ComponentPropsWithoutRef, Ref, useEffect, useId } from 'react'\n\nimport { ID_PREFIX, useFormField } from './FormFieldContext'\n\nexport type FormFieldMessageProps = ComponentPropsWithoutRef<'span'> & {\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldMessage = ({\n id: idProp,\n className,\n ref,\n ...others\n}: FormFieldMessageProps) => {\n const { onMessageIdAdd, onMessageIdRemove } = useFormField()\n const currentId = `${ID_PREFIX}-message-${useId()}`\n const id = idProp || currentId\n\n useEffect(() => {\n onMessageIdAdd(id)\n\n return () => {\n onMessageIdRemove(id)\n }\n }, [id, onMessageIdAdd, onMessageIdRemove])\n\n return (\n <span\n ref={ref}\n id={id}\n data-spark-component=\"form-field-message\"\n className={cx(className, 'text-caption')}\n {...others}\n />\n )\n}\n\nFormFieldMessage.displayName = 'FormField.Message'\n","import { AlertOutline } from '@spark-ui/icons/AlertOutline'\nimport { Check } from '@spark-ui/icons/Check'\nimport { WarningOutline } from '@spark-ui/icons/WarningOutline'\nimport { cx } from 'class-variance-authority'\nimport { Ref } from 'react'\n\nimport { Icon } from '../icon'\nimport { useFormField } from './FormFieldContext'\nimport { FormFieldMessage, FormFieldMessageProps } from './FormFieldMessage'\n\nexport interface FormFieldStateMessageProps extends FormFieldMessageProps {\n state: 'error' | 'alert' | 'success'\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldStateMessage = ({\n className,\n state,\n children,\n ref,\n ...others\n}: FormFieldStateMessageProps) => {\n const field = useFormField()\n\n if (field.state !== state) {\n return null\n }\n\n return (\n <FormFieldMessage\n ref={ref}\n data-spark-component=\"form-field-state-message\"\n className={cx(\n 'gap-sm flex items-center',\n state === 'error' ? 'text-error' : 'text-on-surface/dim-1',\n className\n )}\n {...others}\n >\n {state === 'alert' && (\n <Icon size=\"sm\">\n <WarningOutline />\n </Icon>\n )}\n {state === 'error' && (\n <Icon size=\"sm\" intent=\"error\">\n <AlertOutline />\n </Icon>\n )}\n {state === 'success' && (\n <Icon size=\"sm\">\n <Check />\n </Icon>\n )}\n\n {children}\n </FormFieldMessage>\n )\n}\n\nFormFieldStateMessage.displayName = 'FormField.StateMessage'\n","import { Ref } from 'react'\n\nimport { FormFieldStateMessage, FormFieldStateMessageProps } from './FormFieldStateMessage'\n\nexport type FormFieldAlertMessageProps = Omit<FormFieldStateMessageProps, 'state'> & {\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldAlertMessage = ({ ref, ...props }: FormFieldAlertMessageProps) => {\n return (\n <FormFieldStateMessage\n ref={ref}\n data-spark-component=\"form-field-alert-message\"\n state=\"alert\"\n {...props}\n />\n )\n}\n\nFormFieldAlertMessage.displayName = 'FormField.AlertMessage'\n","import { cx } from 'class-variance-authority'\nimport { ComponentPropsWithoutRef, Ref, useEffect, useState } from 'react'\n\nimport { FormFieldMessage } from './FormFieldMessage'\n\nexport type FormFieldCharactersCountProps = ComponentPropsWithoutRef<'span'> & {\n /**\n * This description is for the screen reader, read when the input is focused.\n */\n description?: string\n /**\n * The live announcement is for the screen read after a delay once the input value changes.\n */\n liveAnnouncement?: ({ remainingChars }: { remainingChars: number }) => string\n /**\n * Current value for the input this component belongs to.\n */\n value?: string\n /**\n * Maximum numeric value to be displayed.\n */\n maxLength: number\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldCharactersCount = ({\n className,\n value = '',\n maxLength,\n description,\n liveAnnouncement,\n ref,\n ...others\n}: FormFieldCharactersCountProps) => {\n const [throttledValue, setThrottledValue] = useState(value)\n\n /**\n * The value is throttled to avoid spamming the aria-live region (and consequently the screen reader).\n */\n useEffect(() => {\n const timeoutId = setTimeout(() => {\n setThrottledValue(value)\n }, 1000)\n\n return () => clearTimeout(timeoutId)\n }, [value])\n\n return (\n <span className=\"ml-auto self-start\">\n {description && (\n <FormFieldMessage className=\"default:sr-only\">{description}</FormFieldMessage>\n )}\n <span\n ref={ref}\n aria-hidden\n data-spark-component=\"form-field-characters-count\"\n className={cx(className, 'text-caption', 'text-neutral')}\n {...others}\n >\n {`${value.length}/${maxLength}`}\n </span>\n\n {liveAnnouncement && (\n <span className=\"sr-only\" aria-live=\"polite\">\n {liveAnnouncement({ remainingChars: maxLength - throttledValue.length })}\n </span>\n )}\n </span>\n )\n}\n\nFormFieldCharactersCount.displayName = 'FormField.CharactersCount'\n","import { ReactNode, useContext } from 'react'\n\nimport { FormFieldContext, FormFieldContextState } from './FormFieldContext'\n\ntype State = Partial<\n Pick<\n FormFieldContextState,\n | 'id'\n | 'name'\n | 'description'\n | 'labelId'\n | 'disabled'\n | 'readOnly'\n | 'state'\n | 'isInvalid'\n | 'isRequired'\n >\n>\n\nexport interface FormFieldControlProps {\n children: (state: State) => ReactNode\n}\n\nexport const useFormFieldControl = () => {\n const { id, name, description, disabled, readOnly, state, labelId, isInvalid, isRequired } =\n useContext(FormFieldContext) || {}\n\n return {\n id,\n name,\n description,\n disabled,\n readOnly,\n state,\n labelId,\n isInvalid,\n isRequired,\n } as State\n}\n\nexport const FormFieldControl = ({ children }: FormFieldControlProps) => {\n const props = useFormFieldControl()\n\n return <>{children(props)}</>\n}\n\nFormFieldControl.displayName = 'FormField.Control'\n","import { Ref } from 'react'\n\nimport { FormFieldStateMessage, FormFieldStateMessageProps } from './FormFieldStateMessage'\n\nexport type FormFieldErrorMessageProps = Omit<FormFieldStateMessageProps, 'state'> & {\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldErrorMessage = ({ ref, ...props }: FormFieldErrorMessageProps) => {\n return (\n <FormFieldStateMessage\n ref={ref}\n data-spark-component=\"form-field-error-message\"\n state=\"error\"\n {...props}\n />\n )\n}\n\nFormFieldErrorMessage.displayName = 'FormField.ErrorMessage'\n","import { cx } from 'class-variance-authority'\nimport { Ref } from 'react'\n\nimport { FormFieldMessage, FormFieldMessageProps } from './FormFieldMessage'\n\nexport type FormFieldHelperMessageProps = FormFieldMessageProps & {\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldHelperMessage = ({\n className,\n ref,\n ...others\n}: FormFieldHelperMessageProps) => {\n return (\n <FormFieldMessage\n ref={ref}\n data-spark-component=\"form-field-helper-message\"\n className={cx('text-on-surface/dim-1', className)}\n {...others}\n />\n )\n}\n\nFormFieldHelperMessage.displayName = 'FormField.HelperMessage'\n","import { cx } from 'class-variance-authority'\nimport { ReactNode, Ref } from 'react'\n\nimport { Label, LabelProps } from '../label'\nimport { Slottable } from '../slot'\nimport { useFormField } from './FormFieldContext'\nimport { FormFieldRequiredIndicator } from './FormFieldRequiredIndicator'\n\nexport interface FormFieldLabelProps extends LabelProps {\n /**\n * Element shown when the input is required inside the label.\n */\n requiredIndicator?: ReactNode\n ref?: Ref<HTMLLabelElement>\n}\n\nexport const FormFieldLabel = ({\n htmlFor: htmlForProp,\n className,\n children,\n requiredIndicator = <FormFieldRequiredIndicator />,\n asChild,\n ref,\n ...others\n}: FormFieldLabelProps) => {\n const control = useFormField()\n\n const { disabled, labelId, isRequired } = control\n const htmlFor = asChild ? undefined : htmlForProp || control.id\n\n return (\n <Label\n ref={ref}\n id={labelId}\n data-spark-component=\"form-field-label\"\n htmlFor={htmlFor}\n className={cx(className, disabled ? 'text-on-surface/dim-3 pointer-events-none' : undefined)}\n asChild={asChild}\n {...others}\n >\n <>\n <Slottable>{children}</Slottable>\n {isRequired && requiredIndicator}\n </>\n </Label>\n )\n}\n\nFormFieldLabel.displayName = 'FormField.Label'\n","import { Ref } from 'react'\n\nimport { FormFieldStateMessage, FormFieldStateMessageProps } from './FormFieldStateMessage'\n\nexport type FormFieldSuccessMessageProps = Omit<FormFieldStateMessageProps, 'state'> & {\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const FormFieldSuccessMessage = ({ ref, ...props }: FormFieldSuccessMessageProps) => {\n return (\n <FormFieldStateMessage\n ref={ref}\n data-spark-component=\"form-field-success-message\"\n state=\"success\"\n {...props}\n />\n )\n}\n\nFormFieldSuccessMessage.displayName = 'FormField.SuccessMessage'\n","import { FormField as Root } from './FormField'\nimport { FormFieldAlertMessage } from './FormFieldAlertMessage'\nimport { FormFieldCharactersCount } from './FormFieldCharactersCount'\nimport { FormFieldControl } from './FormFieldControl'\nimport { FormFieldErrorMessage } from './FormFieldErrorMessage'\nimport { FormFieldHelperMessage } from './FormFieldHelperMessage'\nimport { FormFieldLabel } from './FormFieldLabel'\nimport { FormFieldRequiredIndicator } from './FormFieldRequiredIndicator'\nimport { FormFieldStateMessage } from './FormFieldStateMessage'\nimport { FormFieldSuccessMessage } from './FormFieldSuccessMessage'\n\nexport const FormField: typeof Root & {\n Label: typeof FormFieldLabel\n Control: typeof FormFieldControl\n StateMessage: typeof FormFieldStateMessage\n SuccessMessage: typeof FormFieldSuccessMessage\n AlertMessage: typeof FormFieldAlertMessage\n ErrorMessage: typeof FormFieldErrorMessage\n HelperMessage: typeof FormFieldHelperMessage\n RequiredIndicator: typeof FormFieldRequiredIndicator\n CharactersCount: typeof FormFieldCharactersCount\n} = Object.assign(Root, {\n Label: FormFieldLabel,\n Control: FormFieldControl,\n StateMessage: FormFieldStateMessage,\n SuccessMessage: FormFieldSuccessMessage,\n AlertMessage: FormFieldAlertMessage,\n ErrorMessage: FormFieldErrorMessage,\n HelperMessage: FormFieldHelperMessage,\n RequiredIndicator: FormFieldRequiredIndicator,\n CharactersCount: FormFieldCharactersCount,\n})\n\nFormField.displayName = 'FormField'\nFormFieldLabel.displayName = 'FormField.Label'\nFormFieldControl.displayName = 'FormField.Control'\nFormFieldStateMessage.displayName = 'FormField.StateMessage'\nFormFieldSuccessMessage.displayName = 'FormField.SuccessMessage'\nFormFieldAlertMessage.displayName = 'FormField.AlertMessage'\nFormFieldErrorMessage.displayName = 'FormField.ErrorMessage'\nFormFieldHelperMessage.displayName = 'FormField.HelperMessage'\nFormFieldRequiredIndicator.displayName = 'FormField.RequiredIndicator'\nFormFieldCharactersCount.displayName = 'FormField.CharactersCount'\n\nexport { type FormFieldProps } from './FormField'\nexport { type FormFieldStateMessageProps } from './FormFieldStateMessage'\nexport { type FormFieldControl, useFormFieldControl } from './FormFieldControl'\nexport { type FormFieldHelperMessageProps } from './FormFieldHelperMessage'\nexport { type FormFieldSuccessMessageProps } from './FormFieldSuccessMessage'\nexport { type FormFieldAlertMessageProps } from './FormFieldAlertMessage'\nexport { type FormFieldErrorMessageProps } from './FormFieldErrorMessage'\nexport { type FormFieldLabelProps } from './FormFieldLabel'\nexport { type FormFieldRequiredIndicatorProps } from './FormFieldRequiredIndicator'\nexport { type FormFieldCharactersCountProps } from './FormFieldCharactersCount'\n"],"names":["FormFieldContext","createContext","ID_PREFIX","useFormField","context","useContext","FormFieldProvider","id","name","disabled","readOnly","state","isRequired","children","labelId","useId","messageIds","setMessageIds","useState","description","handleMessageIdAdd","useCallback","msgId","ids","handleMessageIdRemove","current","value","useMemo","jsx","FormField","className","asChild","ref","others","Component","Slot","cx","FormFieldMessage","idProp","onMessageIdAdd","onMessageIdRemove","currentId","useEffect","FormFieldStateMessage","jsxs","Icon","WarningOutline","AlertOutline","Check","FormFieldAlertMessage","props","FormFieldCharactersCount","maxLength","liveAnnouncement","throttledValue","setThrottledValue","timeoutId","useFormFieldControl","isInvalid","FormFieldControl","Fragment","FormFieldErrorMessage","FormFieldHelperMessage","FormFieldLabel","htmlForProp","requiredIndicator","FormFieldRequiredIndicator","control","htmlFor","Label","Slottable","FormFieldSuccessMessage","Root"],"mappings":"+bAiDaA,EAAmBC,EAAAA,cAA4C,IAAI,EAEnEC,EAAY,cAEZC,EAAe,IAAM,CAChC,MAAMC,EAAUC,EAAAA,WAAWL,CAAgB,EAE3C,GAAI,CAACI,EACH,MAAM,MAAM,uDAAuD,EAGrE,OAAOA,CACT,ECjDaE,EAAoB,CAAC,CAChC,GAAAC,EACA,KAAAC,EACA,SAAAC,EAAW,GACX,SAAAC,EAAW,GACX,MAAAC,EACA,WAAAC,EACA,SAAAC,CACF,IAA8B,CAC5B,MAAMC,EAAU,GAAGZ,CAAS,UAAUa,EAAAA,OAAO,GACvC,CAACC,EAAYC,CAAa,EAAIC,EAAAA,SAAmB,CAAA,CAAE,EACnDC,EAAcH,EAAW,OAAS,EAAIA,EAAW,KAAK,GAAG,EAAI,OAE7DI,EAAqBC,cAAaC,GAAkB,CACxDL,EAAcM,GAAO,CAAC,GAAGA,EAAKD,CAAK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