@plexui/ui 0.28.0 → 0.28.1

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.
@@ -55,7 +55,7 @@ const Content = ({ children, width = 480, showClose = true, pill = false, classN
55
55
  return undefined;
56
56
  return attachSheetDrag(panel, () => setOpen(false));
57
57
  }, [panel, mobilePlacement, setOpen]);
58
- return (_jsx(RadixDialog.Portal, { forceMount: true, children: _jsx(TransitionGroup, { ...(crossesScreen ? overlayTimingLarge : overlayTiming), ...exitGuard.transition, className: s.Transition, overlay: true, preventInitialTransition: false, children: open && (_jsxs("div", { children: [_jsx(RadixDialog.Overlay, { className: s.Overlay }), _jsx(RadixDialog.Content, { forceMount: true, className: s.Content, style: toCssVariables({ "dialog-width": width }), "data-placement": placement === "center" ? undefined : placement, "data-mobile-placement": mobilePlacement, "data-mobile-variant": mobileVariant, "data-pill": pill ? "" : undefined, onEscapeKeyDown: preventDefaultHandler, onInteractOutside: (event) => {
58
+ return (_jsx(RadixDialog.Portal, { forceMount: true, children: _jsx(TransitionGroup, { ...(crossesScreen ? overlayTimingLarge : overlayTiming), ...exitGuard.transition, className: s.Transition, overlay: true, preventInitialTransition: false, children: open && (_jsxs("div", { children: [_jsx(RadixDialog.Overlay, { className: s.Overlay }), _jsx(RadixDialog.Content, { forceMount: true, className: s.Content, "data-plex-dialog": "", style: toCssVariables({ "dialog-width": width }), "data-placement": placement === "center" ? undefined : placement, "data-mobile-placement": mobilePlacement, "data-mobile-variant": mobileVariant, "data-pill": pill ? "" : undefined, onEscapeKeyDown: preventDefaultHandler, onInteractOutside: (event) => {
59
59
  // The second click of a double click lands on the overlay: it must not undo the first
60
60
  if (performance.now() - openedAt.current < DOUBLE_CLICK)
61
61
  event.preventDefault();
@@ -1 +1 @@
1
- {"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,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O,kBAAE,QAAQ,GAAqB,CAAA;AAClE,CAAC,CAAA;AAED,MAAM,CAAC,OAAO,GAAG,OAAO,CAAA;AACxB,MAAM,CAAC,OAAO,GAAG,OAAO,CAAA;AACxB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAA;AACtB,MAAM,CAAC,YAAY,GAAG,YAAY,CAAA;AAClC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAA;AAClB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAA;AACtB,MAAM,CAAC,KAAK,GAAG,KAAK,CAAA;AACpB,MAAM,CAAC,WAAW,GAAG,WAAW,CAAA;AAChC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { Dialog as RadixDialog } from \"radix-ui\"\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from \"react\"\nimport { useEscCloseStack } from \"../../hooks/useEscCloseStack\"\nimport { keepMovedFocus, preventDefaultHandler, toCssVariables } from \"../../lib/helpers\"\nimport { TransitionGroup } from \"../Transition\"\nimport { createExitGuard, overlayTiming, overlayTimingLarge } from \"../Transition/shared\"\nimport { attachSheetDrag } from \"./sheetDrag\"\nimport s from \"@plexui/styles/components/Dialog/Dialog.module.css\"\n\ntype DialogContextValue = {\n open: boolean\n setOpen: (nextState: boolean) => void\n}\n\nconst DOUBLE_CLICK = 300\n\nconst DialogContext = createContext<DialogContextValue | null>(null)\n\nconst useDialogContext = () => {\n const context = useContext(DialogContext)\n\n if (!context) {\n throw new Error(\"Dialog compound components must be used inside <Dialog>\")\n }\n\n return context\n}\n\nexport type DialogProps = {\n open?: boolean\n onOpenChange?: (open: boolean) => void\n children: ReactNode\n}\n\nexport const Dialog = ({\n open: controlledOpen,\n onOpenChange: controlledOnOpenChange,\n children,\n}: DialogProps) => {\n const [open, setOpen] = useState<boolean>(false)\n const isOpen = controlledOpen ?? open\n\n const handleOpenChange = useCallback(\n (nextState: boolean) => {\n controlledOnOpenChange?.(nextState)\n setOpen(nextState)\n },\n [controlledOnOpenChange],\n )\n\n const store = useMemo<DialogContextValue>(\n () => ({\n open: isOpen,\n setOpen: handleOpenChange,\n }),\n [isOpen, handleOpenChange],\n )\n\n return (\n <DialogContext value={store}>\n <RadixDialog.Root open={isOpen} onOpenChange={handleOpenChange}>\n {children}\n </RadixDialog.Root>\n </DialogContext>\n )\n}\n\nconst Trigger = ({ children }: { children: ReactNode }) => {\n return <RadixDialog.Trigger asChild>{children}</RadixDialog.Trigger>\n}\n\nexport type DialogPlacement = \"center\" | \"top\" | \"bottom\" | \"start\" | \"end\" | \"fullscreen\"\n\nexport type DialogContentProps = {\n children: ReactNode\n width?: number | string\n showClose?: boolean\n /**\n * Rounder panel and a round close button, for dialogs that sit beside pill controls.\n * @default false\n */\n pill?: boolean\n className?: string\n /**\n * Where the panel sits: centered, near the top (search, command lists),\n * a sheet along the bottom, a full-height panel on the start or end side,\n * or the whole screen.\n * @default center\n */\n placement?: DialogPlacement\n /** Placement at 640px and below, such as a bottom sheet on phones. @default placement */\n mobilePlacement?: Extract<DialogPlacement, \"center\" | \"bottom\" | \"fullscreen\">\n /** Mobile presentation at 640px and below. Sheets default to bottom placement. */\n mobileVariant?: \"alert\" | \"sheet\"\n /**\n * Called when focus moves into the dialog on open. Call\n * `event.preventDefault()` to focus something else yourself.\n */\n onOpenAutoFocus?: (event: Event) => void\n /** Called when focus returns on close. Call `event.preventDefault()` to keep it elsewhere. */\n onCloseAutoFocus?: (event: Event) => void\n}\n\nconst Content = ({\n children,\n width = 480,\n showClose = true,\n pill = false,\n className,\n placement = \"center\",\n mobilePlacement: requestedMobilePlacement,\n mobileVariant,\n onOpenAutoFocus,\n onCloseAutoFocus,\n}: DialogContentProps) => {\n const { open, setOpen } = useDialogContext()\n const mobilePlacement =\n mobileVariant === \"alert\"\n ? \"center\"\n : requestedMobilePlacement ?? (mobileVariant === \"sheet\" ? \"bottom\" : undefined)\n const [exitGuard] = useState(createExitGuard)\n const [panel, setPanel] = useState<HTMLDivElement | null>(null)\n const openedAt = useRef(0)\n const crossesScreen =\n placement === \"bottom\" || placement === \"start\" || placement === \"end\" || mobilePlacement === \"bottom\"\n\n useEscCloseStack(open, () => {\n setOpen(false)\n })\n\n useEffect(() => {\n if (open) openedAt.current = performance.now()\n }, [open])\n\n useEffect(() => {\n if (!panel || mobilePlacement !== \"bottom\") return undefined\n return attachSheetDrag(panel, () => setOpen(false))\n }, [panel, mobilePlacement, setOpen])\n\n return (\n <RadixDialog.Portal forceMount>\n {/* A dialog mounted open enters too, as `open` set with the mount does */}\n <TransitionGroup\n {...(crossesScreen ? overlayTimingLarge : overlayTiming)}\n {...exitGuard.transition}\n className={s.Transition}\n overlay\n preventInitialTransition={false}\n >\n {open && (\n <div key=\"dialog\">\n <RadixDialog.Overlay className={s.Overlay} />\n <RadixDialog.Content\n forceMount\n className={s.Content}\n style={toCssVariables({ \"dialog-width\": width })}\n data-placement={placement === \"center\" ? undefined : placement}\n data-mobile-placement={mobilePlacement}\n data-mobile-variant={mobileVariant}\n data-pill={pill ? \"\" : undefined}\n onEscapeKeyDown={preventDefaultHandler}\n onInteractOutside={(event) => {\n // The second click of a double click lands on the overlay: it must not undo the first\n if (performance.now() - openedAt.current < DOUBLE_CLICK) event.preventDefault()\n else exitGuard.onInteractOutside(event)\n }}\n onOpenAutoFocus={onOpenAutoFocus}\n onCloseAutoFocus={(event) => {\n onCloseAutoFocus?.(event)\n keepMovedFocus(event)\n }}\n >\n <div ref={setPanel} className={clsx(s.Panel, className)}>\n {showClose && (\n <RadixDialog.Close asChild>\n <button type=\"button\" className={s.CloseButton} aria-label=\"Close dialog\">\n <svg\n className={s.CloseIcon}\n viewBox=\"0 0 20 20\"\n width=\"20\"\n height=\"20\"\n aria-hidden=\"true\"\n >\n <path\n fill=\"currentColor\"\n d=\"M5.22 5.22a.75.75 0 0 1 1.06 0L10 8.94l3.72-3.72a.75.75 0 1 1 1.06 1.06L11.06 10l3.72 3.72a.75.75 0 1 1-1.06 1.06L10 11.06l-3.72 3.72a.75.75 0 1 1-1.06-1.06L8.94 10 5.22 6.28a.75.75 0 0 1 0-1.06\"\n />\n </svg>\n </button>\n </RadixDialog.Close>\n )}\n {children}\n </div>\n </RadixDialog.Content>\n </div>\n )}\n </TransitionGroup>\n </RadixDialog.Portal>\n )\n}\n\ntype DialogSlotProps = {\n children: ReactNode\n className?: string\n}\n\nconst Header = ({ children, className }: DialogSlotProps) => {\n return <div className={clsx(s.Header, className)}>{children}</div>\n}\n\nconst HeaderAction = ({ children, className }: DialogSlotProps) => {\n return <div className={clsx(s.HeaderAction, className)}>{children}</div>\n}\n\n/** The scrolling part between Header and Footer: with it, only the body scrolls */\nconst Body = ({ children, className }: DialogSlotProps) => {\n return <div className={clsx(s.Body, className)}>{children}</div>\n}\n\ntype DialogFooterProps = DialogSlotProps & {\n /** Override the mobile action layout. Alerts default to inline; sheets to stacked. */\n mobileLayout?: \"inline\" | \"stacked\"\n}\n\nconst Footer = ({ children, className, mobileLayout }: DialogFooterProps) => {\n return <div className={clsx(s.Footer, className)} data-mobile-layout={mobileLayout}>{children}</div>\n}\n\nconst Title = ({ children, className }: DialogSlotProps) => {\n return <RadixDialog.Title className={clsx(s.Title, className)}>{children}</RadixDialog.Title>\n}\n\nconst Description = ({ children, className }: DialogSlotProps) => {\n return (\n <RadixDialog.Description className={clsx(s.Description, className)}>\n {children}\n </RadixDialog.Description>\n )\n}\n\nconst Close = ({ children }: { children: ReactNode }) => {\n return <RadixDialog.Close asChild>{children}</RadixDialog.Close>\n}\n\nDialog.Trigger = Trigger\nDialog.Content = Content\nDialog.Header = Header\nDialog.HeaderAction = HeaderAction\nDialog.Body = Body\nDialog.Footer = Footer\nDialog.Title = Title\nDialog.Description = Description\nDialog.Close = Close\n"]}
1
+ {"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;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AC,WAAW,CAAC,KAAK,IAAC,OAAO,kBAAE,QAAQ,GAAqB,CAAA;AAClE,CAAC,CAAA;AAED,MAAM,CAAC,OAAO,GAAG,OAAO,CAAA;AACxB,MAAM,CAAC,OAAO,GAAG,OAAO,CAAA;AACxB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAA;AACtB,MAAM,CAAC,YAAY,GAAG,YAAY,CAAA;AAClC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAA;AAClB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAA;AACtB,MAAM,CAAC,KAAK,GAAG,KAAK,CAAA;AACpB,MAAM,CAAC,WAAW,GAAG,WAAW,CAAA;AAChC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { Dialog as RadixDialog } from \"radix-ui\"\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from \"react\"\nimport { useEscCloseStack } from \"../../hooks/useEscCloseStack\"\nimport { keepMovedFocus, preventDefaultHandler, toCssVariables } from \"../../lib/helpers\"\nimport { TransitionGroup } from \"../Transition\"\nimport { createExitGuard, overlayTiming, overlayTimingLarge } from \"../Transition/shared\"\nimport { attachSheetDrag } from \"./sheetDrag\"\nimport s from \"@plexui/styles/components/Dialog/Dialog.module.css\"\n\ntype DialogContextValue = {\n open: boolean\n setOpen: (nextState: boolean) => void\n}\n\nconst DOUBLE_CLICK = 300\n\nconst DialogContext = createContext<DialogContextValue | null>(null)\n\nconst useDialogContext = () => {\n const context = useContext(DialogContext)\n\n if (!context) {\n throw new Error(\"Dialog compound components must be used inside <Dialog>\")\n }\n\n return context\n}\n\nexport type DialogProps = {\n open?: boolean\n onOpenChange?: (open: boolean) => void\n children: ReactNode\n}\n\nexport const Dialog = ({\n open: controlledOpen,\n onOpenChange: controlledOnOpenChange,\n children,\n}: DialogProps) => {\n const [open, setOpen] = useState<boolean>(false)\n const isOpen = controlledOpen ?? open\n\n const handleOpenChange = useCallback(\n (nextState: boolean) => {\n controlledOnOpenChange?.(nextState)\n setOpen(nextState)\n },\n [controlledOnOpenChange],\n )\n\n const store = useMemo<DialogContextValue>(\n () => ({\n open: isOpen,\n setOpen: handleOpenChange,\n }),\n [isOpen, handleOpenChange],\n )\n\n return (\n <DialogContext value={store}>\n <RadixDialog.Root open={isOpen} onOpenChange={handleOpenChange}>\n {children}\n </RadixDialog.Root>\n </DialogContext>\n )\n}\n\nconst Trigger = ({ children }: { children: ReactNode }) => {\n return <RadixDialog.Trigger asChild>{children}</RadixDialog.Trigger>\n}\n\nexport type DialogPlacement = \"center\" | \"top\" | \"bottom\" | \"start\" | \"end\" | \"fullscreen\"\n\nexport type DialogContentProps = {\n children: ReactNode\n width?: number | string\n showClose?: boolean\n /**\n * Rounder panel and a round close button, for dialogs that sit beside pill controls.\n * @default false\n */\n pill?: boolean\n className?: string\n /**\n * Where the panel sits: centered, near the top (search, command lists),\n * a sheet along the bottom, a full-height panel on the start or end side,\n * or the whole screen.\n * @default center\n */\n placement?: DialogPlacement\n /** Placement at 640px and below, such as a bottom sheet on phones. @default placement */\n mobilePlacement?: Extract<DialogPlacement, \"center\" | \"bottom\" | \"fullscreen\">\n /** Mobile presentation at 640px and below. Sheets default to bottom placement. */\n mobileVariant?: \"alert\" | \"sheet\"\n /**\n * Called when focus moves into the dialog on open. Call\n * `event.preventDefault()` to focus something else yourself.\n */\n onOpenAutoFocus?: (event: Event) => void\n /** Called when focus returns on close. Call `event.preventDefault()` to keep it elsewhere. */\n onCloseAutoFocus?: (event: Event) => void\n}\n\nconst Content = ({\n children,\n width = 480,\n showClose = true,\n pill = false,\n className,\n placement = \"center\",\n mobilePlacement: requestedMobilePlacement,\n mobileVariant,\n onOpenAutoFocus,\n onCloseAutoFocus,\n}: DialogContentProps) => {\n const { open, setOpen } = useDialogContext()\n const mobilePlacement =\n mobileVariant === \"alert\"\n ? \"center\"\n : requestedMobilePlacement ?? (mobileVariant === \"sheet\" ? \"bottom\" : undefined)\n const [exitGuard] = useState(createExitGuard)\n const [panel, setPanel] = useState<HTMLDivElement | null>(null)\n const openedAt = useRef(0)\n const crossesScreen =\n placement === \"bottom\" || placement === \"start\" || placement === \"end\" || mobilePlacement === \"bottom\"\n\n useEscCloseStack(open, () => {\n setOpen(false)\n })\n\n useEffect(() => {\n if (open) openedAt.current = performance.now()\n }, [open])\n\n useEffect(() => {\n if (!panel || mobilePlacement !== \"bottom\") return undefined\n return attachSheetDrag(panel, () => setOpen(false))\n }, [panel, mobilePlacement, setOpen])\n\n return (\n <RadixDialog.Portal forceMount>\n {/* A dialog mounted open enters too, as `open` set with the mount does */}\n <TransitionGroup\n {...(crossesScreen ? overlayTimingLarge : overlayTiming)}\n {...exitGuard.transition}\n className={s.Transition}\n overlay\n preventInitialTransition={false}\n >\n {open && (\n <div key=\"dialog\">\n <RadixDialog.Overlay className={s.Overlay} />\n <RadixDialog.Content\n forceMount\n className={s.Content}\n data-plex-dialog=\"\"\n style={toCssVariables({ \"dialog-width\": width })}\n data-placement={placement === \"center\" ? undefined : placement}\n data-mobile-placement={mobilePlacement}\n data-mobile-variant={mobileVariant}\n data-pill={pill ? \"\" : undefined}\n onEscapeKeyDown={preventDefaultHandler}\n onInteractOutside={(event) => {\n // The second click of a double click lands on the overlay: it must not undo the first\n if (performance.now() - openedAt.current < DOUBLE_CLICK) event.preventDefault()\n else exitGuard.onInteractOutside(event)\n }}\n onOpenAutoFocus={onOpenAutoFocus}\n onCloseAutoFocus={(event) => {\n onCloseAutoFocus?.(event)\n keepMovedFocus(event)\n }}\n >\n <div ref={setPanel} className={clsx(s.Panel, className)}>\n {showClose && (\n <RadixDialog.Close asChild>\n <button type=\"button\" className={s.CloseButton} aria-label=\"Close dialog\">\n <svg\n className={s.CloseIcon}\n viewBox=\"0 0 20 20\"\n width=\"20\"\n height=\"20\"\n aria-hidden=\"true\"\n >\n <path\n fill=\"currentColor\"\n d=\"M5.22 5.22a.75.75 0 0 1 1.06 0L10 8.94l3.72-3.72a.75.75 0 1 1 1.06 1.06L11.06 10l3.72 3.72a.75.75 0 1 1-1.06 1.06L10 11.06l-3.72 3.72a.75.75 0 1 1-1.06-1.06L8.94 10 5.22 6.28a.75.75 0 0 1 0-1.06\"\n />\n </svg>\n </button>\n </RadixDialog.Close>\n )}\n {children}\n </div>\n </RadixDialog.Content>\n </div>\n )}\n </TransitionGroup>\n </RadixDialog.Portal>\n )\n}\n\ntype DialogSlotProps = {\n children: ReactNode\n className?: string\n}\n\nconst Header = ({ children, className }: DialogSlotProps) => {\n return <div className={clsx(s.Header, className)}>{children}</div>\n}\n\nconst HeaderAction = ({ children, className }: DialogSlotProps) => {\n return <div className={clsx(s.HeaderAction, className)}>{children}</div>\n}\n\n/** The scrolling part between Header and Footer: with it, only the body scrolls */\nconst Body = ({ children, className }: DialogSlotProps) => {\n return <div className={clsx(s.Body, className)}>{children}</div>\n}\n\ntype DialogFooterProps = DialogSlotProps & {\n /** Override the mobile action layout. Alerts default to inline; sheets to stacked. */\n mobileLayout?: \"inline\" | \"stacked\"\n}\n\nconst Footer = ({ children, className, mobileLayout }: DialogFooterProps) => {\n return <div className={clsx(s.Footer, className)} data-mobile-layout={mobileLayout}>{children}</div>\n}\n\nconst Title = ({ children, className }: DialogSlotProps) => {\n return <RadixDialog.Title className={clsx(s.Title, className)}>{children}</RadixDialog.Title>\n}\n\nconst Description = ({ children, className }: DialogSlotProps) => {\n return (\n <RadixDialog.Description className={clsx(s.Description, className)}>\n {children}\n </RadixDialog.Description>\n )\n}\n\nconst Close = ({ children }: { children: ReactNode }) => {\n return <RadixDialog.Close asChild>{children}</RadixDialog.Close>\n}\n\nDialog.Trigger = Trigger\nDialog.Content = Content\nDialog.Header = Header\nDialog.HeaderAction = HeaderAction\nDialog.Body = Body\nDialog.Footer = Footer\nDialog.Title = Title\nDialog.Description = Description\nDialog.Close = Close\n"]}
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import clsx from "clsx";
4
4
  import { RadioGroup as RadixRadioGroup } from "radix-ui";
5
5
  import React, { createContext, use, useId, useMemo } from "react";
6
+ import { CheckMd } from "../Icon/index.js";
6
7
  import s from "@plexui/styles/components/RadioGroup/RadioGroup.module.css";
7
8
  const RadioGroupContext = createContext(null);
8
9
  const useRadioGroupContext = () => {
@@ -29,7 +30,7 @@ const Item = ({ value, disabled: itemDisabled = false, required, children, descr
29
30
  const label = (_jsxs("label", { htmlFor: itemId, className: clsx(s.RadioLabel, className), "data-disabled": disabled ? "" : undefined, "data-block": block ? "" : undefined, "data-orientation": orientation, onMouseDown: (event) => {
30
31
  if (!event.defaultPrevented && event.detail > 1)
31
32
  event.preventDefault();
32
- }, children: [_jsx("div", { className: s.RadioIndicatorWrapper, children: _jsx(RadixRadioGroup.Item, { id: itemId, value: value, disabled: disabled, required: required, className: s.RadioItem, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": [descriptionId, ariaDescribedBy].filter(Boolean).join(" ") || undefined, children: _jsx(RadixRadioGroup.Indicator, { className: s.RadioIndicator }) }) }), children] }));
33
+ }, children: [_jsx("div", { className: s.RadioIndicatorWrapper, children: _jsx(RadixRadioGroup.Item, { id: itemId, value: value, disabled: disabled, required: required, className: s.RadioItem, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": [descriptionId, ariaDescribedBy].filter(Boolean).join(" ") || undefined, children: _jsx(RadixRadioGroup.Indicator, { className: s.RadioIndicator, children: _jsx(CheckMd, { className: s.Checkmark }) }) }) }), children] }));
33
34
  return (
34
35
  // Providing an extra wrapper enables `label` to be inline-flex, avoiding clickable whitespace
35
36
  // when radio options are of varied lengths.
@@ -1 +1 @@
1
- {"version":3,"file":"RadioGroup.js","sourceRoot":"","sources":["../../../../src/components/RadioGroup/RadioGroup.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OA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I,CAAC,GAAG,CAAC,IAAI,SAAS,YAEzF,KAAC,eAAe,CAAC,SAAS,IAAC,SAAS,EAAE,CAAC,CAAC,cAAc,GAAI,GACrC,GACnB,EACL,QAAQ,IACH,CACT,CAAA;IAED,OAAO;IACL,8FAA8F;IAC9F,4CAA4C;IAC5C,+GAA+G;IAC/G,cAAK,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,QAAQ,CAAC,KAAM,SAAS,YAC3D,WAAW,CAAC,CAAC,CAAC;QACb,0FAA0F;QAC1F,eAAK,SAAS,EAAE,CAAC,CAAC,cAAc,gBAAc,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,sBAAoB,WAAW,aAChG,KAAK,EACN,eAAM,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC,CAAC,gBAAgB,mBAAiB,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,YAC7F,WAAW,GACP,IACH,CACP,CAAC,CAAC,CAAC,CACF,KAAK,CACN,GACG,CACP,CAAA;AACH,CAAC,CAAA;AAED,UAAU,CAAC,IAAI,GAAG,IAAI,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { RadioGroup as RadixRadioGroup } from \"radix-ui\"\nimport React, { createContext, use, useId, useMemo } from \"react\"\nimport s from \"@plexui/styles/components/RadioGroup/RadioGroup.module.css\"\n\ntype Direction = \"col\" | \"row\"\n\ntype RadioGroupContextValue = {\n disabled: boolean\n direction: Direction\n}\n\nconst RadioGroupContext = createContext<RadioGroupContextValue | null>(null)\n\nconst useRadioGroupContext = () => {\n const context = use(RadioGroupContext)\n\n if (!context) {\n throw new Error(\"RadioGroup components must be wrapped in <RadioGroup />\")\n }\n\n return context\n}\n\nexport type RadioGroupProps<T extends string> = {\n \"defaultValue\"?: T\n \"value\"?: T\n \"name\"?: string\n \"onChange\"?: (value: T) => void\n /** Accessible label for the radio options */\n \"aria-label\"?: string\n /** Determines the layout direction of the radio items\n * @default row\n */\n \"direction\"?: Direction\n /** Controls whether the entire radio group is disabled */\n \"disabled\"?: boolean\n /** Class applied to the radio group container */\n \"className\"?: string\n \"children\": React.ReactNode\n \"required\"?: boolean\n}\n\nexport const RadioGroup = <T extends string>({\n onChange,\n children,\n className,\n direction = \"row\",\n disabled = false,\n ...restProps\n}: RadioGroupProps<T>) => {\n const store = useMemo<RadioGroupContextValue>(\n () => ({\n disabled,\n direction,\n }),\n [disabled, direction],\n )\n\n return (\n <RadioGroupContext value={store}>\n <RadixRadioGroup.Root\n className={clsx(s.RadioGroup, className)}\n data-direction={direction}\n onValueChange={onChange}\n disabled={disabled}\n {...restProps}\n >\n {children}\n </RadixRadioGroup.Root>\n </RadioGroupContext>\n )\n}\n\nexport type RadioGroupItemProps<T extends string> = {\n value: T\n /** Determines if a given radio item is disabled */\n disabled?: boolean\n required?: boolean\n block?: boolean\n className?: string\n /**\n * The orientation of the radio indicator relative to the label.\n *\n * @default \"left\"\n */\n orientation?: \"left\" | \"right\"\n /** Id of the radio, so a label outside the item can target it with `htmlFor` */\n id?: string\n \"aria-label\"?: string\n \"aria-labelledby\"?: string\n \"aria-describedby\"?: string\n /** The option's label. Leave it out when a `Field` around the item names it. */\n children?: React.ReactNode\n /** Optional second line below the option's label. Linked via `aria-describedby`. */\n description?: React.ReactNode\n}\n\nconst Item = <T extends string>({\n value,\n disabled: itemDisabled = false,\n required,\n children,\n description,\n className,\n block = false,\n orientation = \"left\",\n id: idProp,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...restProps\n}: RadioGroupItemProps<T>) => {\n const { disabled: groupDisabled } = useRadioGroupContext()\n const disabled = groupDisabled || itemDisabled\n\n const id = useId()\n // These name the radio itself: a `Field` around the item labels it through them\n const itemId = idProp ?? `${value}-${id}`\n const descriptionId = description ? `${itemId}-description` : undefined\n\n const label = (\n <label\n htmlFor={itemId}\n className={clsx(s.RadioLabel, className)}\n data-disabled={disabled ? \"\" : undefined}\n data-block={block ? \"\" : undefined}\n data-orientation={orientation}\n onMouseDown={(event) => {\n if (!event.defaultPrevented && event.detail > 1) event.preventDefault()\n }}\n >\n <div className={s.RadioIndicatorWrapper}>\n <RadixRadioGroup.Item\n id={itemId}\n value={value}\n disabled={disabled}\n required={required}\n className={s.RadioItem}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={[descriptionId, ariaDescribedBy].filter(Boolean).join(\" \") || undefined}\n >\n <RadixRadioGroup.Indicator className={s.RadioIndicator} />\n </RadixRadioGroup.Item>\n </div>\n {children}\n </label>\n )\n\n return (\n // Providing an extra wrapper enables `label` to be inline-flex, avoiding clickable whitespace\n // when radio options are of varied lengths.\n // NOTE: Important that this is `flex` to prevent the `inline-flex` label from extra, unintentional whitespace.\n <div className={clsx(\"flex\", block && \"w-full\")} {...restProps}>\n {description ? (\n // The description stays outside the label, so it describes the radio instead of naming it\n <div className={s.RadioItemGroup} data-block={block ? \"\" : undefined} data-orientation={orientation}>\n {label}\n <span id={descriptionId} className={s.RadioDescription} data-disabled={disabled ? \"\" : undefined}>\n {description}\n </span>\n </div>\n ) : (\n label\n )}\n </div>\n )\n}\n\nRadioGroup.Item = Item\n"]}
1
+ {"version":3,"file":"RadioGroup.js","sourceRoot":"","sources":["../../../../src/components/RadioGroup/RadioGroup.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,UAAU,IAAI,eAAe,EAAE,MAAM,UAAU,CAAA;AACxD,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,CAAC,MAAM,4DAA4D,CAAA;AAS1E,MAAM,iBAAiB,GAAG,aAAa,CAAgC,IAAI,CAA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AA4C;IAC5C,+GAA+G;IAC/G,cAAK,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,QAAQ,CAAC,KAAM,SAAS,YAC3D,WAAW,CAAC,CAAC,CAAC;QACb,0FAA0F;QAC1F,eAAK,SAAS,EAAE,CAAC,CAAC,cAAc,gBAAc,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,sBAAoB,WAAW,aAChG,KAAK,EACN,eAAM,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC,CAAC,gBAAgB,mBAAiB,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,YAC7F,WAAW,GACP,IACH,CACP,CAAC,CAAC,CAAC,CACF,KAAK,CACN,GACG,CACP,CAAA;AACH,CAAC,CAAA;AAED,UAAU,CAAC,IAAI,GAAG,IAAI,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { RadioGroup as RadixRadioGroup } from \"radix-ui\"\nimport React, { createContext, use, useId, useMemo } from \"react\"\nimport { CheckMd } from \"../Icon\"\nimport s from \"@plexui/styles/components/RadioGroup/RadioGroup.module.css\"\n\ntype Direction = \"col\" | \"row\"\n\ntype RadioGroupContextValue = {\n disabled: boolean\n direction: Direction\n}\n\nconst RadioGroupContext = createContext<RadioGroupContextValue | null>(null)\n\nconst useRadioGroupContext = () => {\n const context = use(RadioGroupContext)\n\n if (!context) {\n throw new Error(\"RadioGroup components must be wrapped in <RadioGroup />\")\n }\n\n return context\n}\n\nexport type RadioGroupProps<T extends string> = {\n \"defaultValue\"?: T\n \"value\"?: T\n \"name\"?: string\n \"onChange\"?: (value: T) => void\n /** Accessible label for the radio options */\n \"aria-label\"?: string\n /** Determines the layout direction of the radio items\n * @default row\n */\n \"direction\"?: Direction\n /** Controls whether the entire radio group is disabled */\n \"disabled\"?: boolean\n /** Class applied to the radio group container */\n \"className\"?: string\n \"children\": React.ReactNode\n \"required\"?: boolean\n}\n\nexport const RadioGroup = <T extends string>({\n onChange,\n children,\n className,\n direction = \"row\",\n disabled = false,\n ...restProps\n}: RadioGroupProps<T>) => {\n const store = useMemo<RadioGroupContextValue>(\n () => ({\n disabled,\n direction,\n }),\n [disabled, direction],\n )\n\n return (\n <RadioGroupContext value={store}>\n <RadixRadioGroup.Root\n className={clsx(s.RadioGroup, className)}\n data-direction={direction}\n onValueChange={onChange}\n disabled={disabled}\n {...restProps}\n >\n {children}\n </RadixRadioGroup.Root>\n </RadioGroupContext>\n )\n}\n\nexport type RadioGroupItemProps<T extends string> = {\n value: T\n /** Determines if a given radio item is disabled */\n disabled?: boolean\n required?: boolean\n block?: boolean\n className?: string\n /**\n * The orientation of the radio indicator relative to the label.\n *\n * @default \"left\"\n */\n orientation?: \"left\" | \"right\"\n /** Id of the radio, so a label outside the item can target it with `htmlFor` */\n id?: string\n \"aria-label\"?: string\n \"aria-labelledby\"?: string\n \"aria-describedby\"?: string\n /** The option's label. Leave it out when a `Field` around the item names it. */\n children?: React.ReactNode\n /** Optional second line below the option's label. Linked via `aria-describedby`. */\n description?: React.ReactNode\n}\n\nconst Item = <T extends string>({\n value,\n disabled: itemDisabled = false,\n required,\n children,\n description,\n className,\n block = false,\n orientation = \"left\",\n id: idProp,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...restProps\n}: RadioGroupItemProps<T>) => {\n const { disabled: groupDisabled } = useRadioGroupContext()\n const disabled = groupDisabled || itemDisabled\n\n const id = useId()\n // These name the radio itself: a `Field` around the item labels it through them\n const itemId = idProp ?? `${value}-${id}`\n const descriptionId = description ? `${itemId}-description` : undefined\n\n const label = (\n <label\n htmlFor={itemId}\n className={clsx(s.RadioLabel, className)}\n data-disabled={disabled ? \"\" : undefined}\n data-block={block ? \"\" : undefined}\n data-orientation={orientation}\n onMouseDown={(event) => {\n if (!event.defaultPrevented && event.detail > 1) event.preventDefault()\n }}\n >\n <div className={s.RadioIndicatorWrapper}>\n <RadixRadioGroup.Item\n id={itemId}\n value={value}\n disabled={disabled}\n required={required}\n className={s.RadioItem}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={[descriptionId, ariaDescribedBy].filter(Boolean).join(\" \") || undefined}\n >\n <RadixRadioGroup.Indicator className={s.RadioIndicator}>\n <CheckMd className={s.Checkmark} />\n </RadixRadioGroup.Indicator>\n </RadixRadioGroup.Item>\n </div>\n {children}\n </label>\n )\n\n return (\n // Providing an extra wrapper enables `label` to be inline-flex, avoiding clickable whitespace\n // when radio options are of varied lengths.\n // NOTE: Important that this is `flex` to prevent the `inline-flex` label from extra, unintentional whitespace.\n <div className={clsx(\"flex\", block && \"w-full\")} {...restProps}>\n {description ? (\n // The description stays outside the label, so it describes the radio instead of naming it\n <div className={s.RadioItemGroup} data-block={block ? \"\" : undefined} data-orientation={orientation}>\n {label}\n <span id={descriptionId} className={s.RadioDescription} data-disabled={disabled ? \"\" : undefined}>\n {description}\n </span>\n </div>\n ) : (\n label\n )}\n </div>\n )\n}\n\nRadioGroup.Item = Item\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plexui/ui",
3
- "version": "0.28.0",
3
+ "version": "0.28.1",
4
4
  "description": "Modern design system for building high-quality applications",
5
5
  "type": "module",
6
6
  "license": "MIT",