@yenio-pld/blocks 1.2.0-rc.19 → 1.2.0-rc.20
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/ui/button.d.ts +2 -2
- package/dist/ui/dialog.js +12 -2
- package/dist/ui/dialog.js.map +1 -1
- package/dist/ui/select.js +1 -0
- package/dist/ui/select.js.map +1 -1
- package/package.json +1 -1
package/dist/ui/button.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { Button as Button$1 } from '@base-ui/react/button';
|
|
|
4
4
|
import { VariantProps } from 'class-variance-authority';
|
|
5
5
|
|
|
6
6
|
declare const buttonVariants: (props?: ({
|
|
7
|
-
variant?: "default" | "outline" | "secondary" | "ghost" | "destructive" |
|
|
8
|
-
size?: "default" | "
|
|
7
|
+
variant?: "link" | "default" | "outline" | "secondary" | "ghost" | "destructive" | null | undefined;
|
|
8
|
+
size?: "default" | "sm" | "xs" | "lg" | "touch" | "xl" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | "icon-touch" | "icon-xl" | null | undefined;
|
|
9
9
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
10
10
|
declare function Button({ className, variant, size, ...props }: Button$1.Props & VariantProps<typeof buttonVariants>): React.JSX.Element;
|
|
11
11
|
|
package/dist/ui/dialog.js
CHANGED
|
@@ -88,7 +88,10 @@ function DialogContent({
|
|
|
88
88
|
// PlaceAutocompleteElement prediction lists and other fixed UI.
|
|
89
89
|
// flex-col + h-fit: Safari stretches out-of-flow `display:grid`
|
|
90
90
|
// panels to the viewport (WebKit 260461); flex sizes to content.
|
|
91
|
-
|
|
91
|
+
// overflow-visible: Select/Combobox portal into this node; an
|
|
92
|
+
// overflow scrollport here folds abspos popup height into the
|
|
93
|
+
// dialog and stretches the panel when a list opens.
|
|
94
|
+
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 m-auto flex h-fit max-h-[calc(100%-2rem)] w-full max-w-[calc(100%-2rem)] flex-col overflow-visible rounded-lg border shadow-lg duration-200 sm:max-w-lg",
|
|
92
95
|
className
|
|
93
96
|
),
|
|
94
97
|
...props,
|
|
@@ -106,7 +109,14 @@ function DialogContent({
|
|
|
106
109
|
onFocusOutside?.(event);
|
|
107
110
|
},
|
|
108
111
|
children: [
|
|
109
|
-
|
|
112
|
+
/* @__PURE__ */ jsx(
|
|
113
|
+
"div",
|
|
114
|
+
{
|
|
115
|
+
"data-slot": "dialog-body",
|
|
116
|
+
className: "flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-6",
|
|
117
|
+
children
|
|
118
|
+
}
|
|
119
|
+
),
|
|
110
120
|
showCloseButton ? /* @__PURE__ */ jsxs(DialogPrimitive.Close, { className: "ring-offset-background focus:ring-ring absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none", children: [
|
|
111
121
|
/* @__PURE__ */ jsx(XIcon, { className: "size-4" }),
|
|
112
122
|
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
|
package/dist/ui/dialog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/utils.ts","../../src/ui/dialog.tsx"],"names":[],"mappings":";;;;;;;AAGO,SAAS,MAAM,MAAA,EAAsB;AAC3C,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC5B;ACOA,IAAM,4BAAA,GAA+B,cAAkC,IAAI,CAAA;AAG3E,SAAS,wBAAA,GAA+C;AACvD,EAAA,OAAO,WAAW,4BAA4B,CAAA;AAC/C;AAEA,SAAS,MAAA,CAAO,EAAE,GAAG,KAAA,EAAM,EAAgD;AAC1E,EAAA,2BAAwB,eAAA,CAAA,IAAA,EAAhB,EAAqB,WAAA,EAAU,QAAA,EAAU,GAAG,KAAA,EAAO,CAAA;AAC5D;AAE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oBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,+BAAA,EAAiC,SAAS,CAAA;AAAA,MACvD,GAAG;AAAA;AAAA,GACL;AAEF","file":"dialog.js","sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n\treturn twMerge(clsx(inputs));\n}\n","\"use client\";\n\nimport * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport { XIcon } from \"lucide-react\";\nimport {\n\tcreateContext,\n\tuseContext,\n\tuseState,\n\ttype ComponentProps,\n} from \"react\";\nimport { cn } from \"../lib/utils\";\n\nconst DialogPortalContainerContext = createContext<HTMLElement | null>(null);\n\n/** Portal target for Base UI popups nested in this dialog (Select, Combobox, …). */\nfunction useDialogPortalContainer(): HTMLElement | null {\n\treturn useContext(DialogPortalContainerContext);\n}\n\nfunction Dialog({ ...props }: ComponentProps<typeof DialogPrimitive.Root>) {\n\treturn <DialogPrimitive.Root data-slot=\"dialog\" {...props} />;\n}\n\nfunction DialogTrigger({\n\t...props\n}: ComponentProps<typeof DialogPrimitive.Trigger>) {\n\treturn <DialogPrimitive.Trigger data-slot=\"dialog-trigger\" {...props} />;\n}\n\nfunction DialogPortal({\n\t...props\n}: ComponentProps<typeof DialogPrimitive.Portal>) {\n\treturn <DialogPrimitive.Portal data-slot=\"dialog-portal\" {...props} />;\n}\n\nfunction DialogClose({\n\t...props\n}: ComponentProps<typeof DialogPrimitive.Close>) {\n\treturn <DialogPrimitive.Close data-slot=\"dialog-close\" {...props} />;\n}\n\nfunction DialogOverlay({\n\tclassName,\n\t...props\n}: ComponentProps<typeof DialogPrimitive.Overlay>) {\n\treturn (\n\t\t<DialogPrimitive.Overlay\n\t\t\tdata-slot=\"dialog-overlay\"\n\t\t\tclassName={cn(\n\t\t\t\t\"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\n/**\n * Portaled Base UI Select / Combobox popups (and their focus guards / inert\n * backdrops) sit outside Dialog Content in the DOM when not using the dialog\n * portal container. Treat those nodes as inside the dialog for dismiss/focus.\n */\nfunction isPortaledOverlayTarget(target: EventTarget | null): boolean {\n\tif (!(target instanceof Element)) return false;\n\treturn Boolean(\n\t\ttarget.closest(\n\t\t\t[\n\t\t\t\t'[data-slot=\"select-positioner\"]',\n\t\t\t\t'[data-slot=\"select-popup\"]',\n\t\t\t\t'[data-slot=\"combobox-positioner\"]',\n\t\t\t\t'[role=\"listbox\"]',\n\t\t\t\t'[role=\"option\"]',\n\t\t\t\t\"[data-base-ui-portal]\",\n\t\t\t\t\"[data-base-ui-focus-guard]\",\n\t\t\t\t\"[data-base-ui-inert]\",\n\t\t\t].join(\", \"),\n\t\t),\n\t);\n}\n\nfunction DialogContent({\n\tclassName,\n\tchildren,\n\tshowCloseButton = true,\n\tonPointerDownOutside,\n\tonInteractOutside,\n\tonFocusOutside,\n\t...props\n}: ComponentProps<typeof DialogPrimitive.Content> & {\n\tshowCloseButton?: boolean;\n}) {\n\tconst [portalContainer, setPortalContainer] = useState<HTMLElement | null>(\n\t\tnull,\n\t);\n\n\treturn (\n\t\t<DialogPortal>\n\t\t\t<DialogOverlay />\n\t\t\t<DialogPortalContainerContext.Provider value={portalContainer}>\n\t\t\t\t<DialogPrimitive.Content\n\t\t\t\t\tdata-slot=\"dialog-content\"\n\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t// Center with inset + margin, not translate. Translate (and zoom\n\t\t\t\t\t\t// scale) create a containing block that misaligns Google Places\n\t\t\t\t\t\t// PlaceAutocompleteElement prediction lists and other fixed UI.\n\t\t\t\t\t\t// flex-col + h-fit: Safari stretches out-of-flow `display:grid`\n\t\t\t\t\t\t// panels to the viewport (WebKit 260461); flex sizes to content.\n\t\t\t\t\t\t\"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 m-auto flex h-fit max-h-[calc(100%-2rem)] w-full max-w-[calc(100%-2rem)] flex-col gap-4 overflow-y-auto rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg\",\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t)}\n\t\t\t\t\t{...props}\n\t\t\t\t\tref={setPortalContainer}\n\t\t\t\t\tonPointerDownOutside={(event) => {\n\t\t\t\t\t\tif (isPortaledOverlayTarget(event.target)) event.preventDefault();\n\t\t\t\t\t\tonPointerDownOutside?.(event);\n\t\t\t\t\t}}\n\t\t\t\t\tonInteractOutside={(event) => {\n\t\t\t\t\t\tif (isPortaledOverlayTarget(event.target)) event.preventDefault();\n\t\t\t\t\t\tonInteractOutside?.(event);\n\t\t\t\t\t}}\n\t\t\t\t\tonFocusOutside={(event) => {\n\t\t\t\t\t\tif (isPortaledOverlayTarget(event.target)) event.preventDefault();\n\t\t\t\t\t\tonFocusOutside?.(event);\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t\t{showCloseButton ? (\n\t\t\t\t\t\t<DialogPrimitive.Close className=\"ring-offset-background focus:ring-ring absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none\">\n\t\t\t\t\t\t\t<XIcon className=\"size-4\" />\n\t\t\t\t\t\t\t<span className=\"sr-only\">Close</span>\n\t\t\t\t\t\t</DialogPrimitive.Close>\n\t\t\t\t\t) : null}\n\t\t\t\t</DialogPrimitive.Content>\n\t\t\t</DialogPortalContainerContext.Provider>\n\t\t</DialogPortal>\n\t);\n}\n\nfunction DialogHeader({ className, ...props }: ComponentProps<\"div\">) {\n\treturn (\n\t\t<div\n\t\t\tdata-slot=\"dialog-header\"\n\t\t\tclassName={cn(\"flex flex-col gap-2 text-center sm:text-left\", className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction DialogFooter({ className, ...props }: ComponentProps<\"div\">) {\n\treturn (\n\t\t<div\n\t\t\tdata-slot=\"dialog-footer\"\n\t\t\tclassName={cn(\n\t\t\t\t\"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction DialogTitle({\n\tclassName,\n\t...props\n}: ComponentProps<typeof DialogPrimitive.Title>) {\n\treturn (\n\t\t<DialogPrimitive.Title\n\t\t\tdata-slot=\"dialog-title\"\n\t\t\tclassName={cn(\"text-lg leading-none font-semibold\", className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction DialogDescription({\n\tclassName,\n\t...props\n}: ComponentProps<typeof DialogPrimitive.Description>) {\n\treturn (\n\t\t<DialogPrimitive.Description\n\t\t\tdata-slot=\"dialog-description\"\n\t\t\tclassName={cn(\"text-muted-foreground text-sm\", className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nexport {\n\tDialog,\n\tDialogClose,\n\tDialogContent,\n\tDialogDescription,\n\tDialogFooter,\n\tDialogHeader,\n\tDialogTitle,\n\tDialogTrigger,\n\tuseDialogPortalContainer,\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/lib/utils.ts","../../src/ui/dialog.tsx"],"names":[],"mappings":";;;;;;;AAGO,SAAS,MAAM,MAAA,EAAsB;AAC3C,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC5B;ACOA,IAAM,4BAAA,GAA+B,cAAkC,IAAI,CAAA;AAG3E,SAAS,wBAAA,GAA+C;AACvD,EAAA,OAAO,WAAW,4BAA4B,CAAA;AAC/C;AAEA,SAAS,MAAA,CAAO,EAAE,GAAG,KAAA,EAAM,EAAgD;AAC1E,EAAA,2BAAwB,eAAA,CAAA,IAAA,EAAhB,EAAqB,WAAA,EAAU,QAAA,EAAU,GAAG,KAAA,EAAO,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AkB;AAAA,EAC1B,SAAA;AAAA,EACA,GAAG;AACJ,CAAA,EAAuD;AACtD,EAAA,uBACC,GAAA;AAAA,IAAiB,eAAA,CAAA,WAAA;AAAA,IAAhB;AAAA,MACA,WAAA,EAAU,oBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,+BAAA,EAAiC,SAAS,CAAA;AAAA,MACvD,GAAG;AAAA;AAAA,GACL;AAEF","file":"dialog.js","sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n\treturn twMerge(clsx(inputs));\n}\n","\"use client\";\n\nimport * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport { XIcon } from \"lucide-react\";\nimport {\n\tcreateContext,\n\tuseContext,\n\tuseState,\n\ttype ComponentProps,\n} from \"react\";\nimport { cn } from \"../lib/utils\";\n\nconst DialogPortalContainerContext = createContext<HTMLElement | null>(null);\n\n/** Portal target for Base UI popups nested in this dialog (Select, Combobox, …). */\nfunction useDialogPortalContainer(): HTMLElement | null {\n\treturn useContext(DialogPortalContainerContext);\n}\n\nfunction Dialog({ ...props }: ComponentProps<typeof DialogPrimitive.Root>) {\n\treturn <DialogPrimitive.Root data-slot=\"dialog\" {...props} />;\n}\n\nfunction DialogTrigger({\n\t...props\n}: ComponentProps<typeof DialogPrimitive.Trigger>) {\n\treturn <DialogPrimitive.Trigger data-slot=\"dialog-trigger\" {...props} />;\n}\n\nfunction DialogPortal({\n\t...props\n}: ComponentProps<typeof DialogPrimitive.Portal>) {\n\treturn <DialogPrimitive.Portal data-slot=\"dialog-portal\" {...props} />;\n}\n\nfunction DialogClose({\n\t...props\n}: ComponentProps<typeof DialogPrimitive.Close>) {\n\treturn <DialogPrimitive.Close data-slot=\"dialog-close\" {...props} />;\n}\n\nfunction DialogOverlay({\n\tclassName,\n\t...props\n}: ComponentProps<typeof DialogPrimitive.Overlay>) {\n\treturn (\n\t\t<DialogPrimitive.Overlay\n\t\t\tdata-slot=\"dialog-overlay\"\n\t\t\tclassName={cn(\n\t\t\t\t\"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\n/**\n * Portaled Base UI Select / Combobox popups (and their focus guards / inert\n * backdrops) sit outside Dialog Content in the DOM when not using the dialog\n * portal container. Treat those nodes as inside the dialog for dismiss/focus.\n */\nfunction isPortaledOverlayTarget(target: EventTarget | null): boolean {\n\tif (!(target instanceof Element)) return false;\n\treturn Boolean(\n\t\ttarget.closest(\n\t\t\t[\n\t\t\t\t'[data-slot=\"select-positioner\"]',\n\t\t\t\t'[data-slot=\"select-popup\"]',\n\t\t\t\t'[data-slot=\"combobox-positioner\"]',\n\t\t\t\t'[role=\"listbox\"]',\n\t\t\t\t'[role=\"option\"]',\n\t\t\t\t\"[data-base-ui-portal]\",\n\t\t\t\t\"[data-base-ui-focus-guard]\",\n\t\t\t\t\"[data-base-ui-inert]\",\n\t\t\t].join(\", \"),\n\t\t),\n\t);\n}\n\nfunction DialogContent({\n\tclassName,\n\tchildren,\n\tshowCloseButton = true,\n\tonPointerDownOutside,\n\tonInteractOutside,\n\tonFocusOutside,\n\t...props\n}: ComponentProps<typeof DialogPrimitive.Content> & {\n\tshowCloseButton?: boolean;\n}) {\n\tconst [portalContainer, setPortalContainer] = useState<HTMLElement | null>(\n\t\tnull,\n\t);\n\n\treturn (\n\t\t<DialogPortal>\n\t\t\t<DialogOverlay />\n\t\t\t<DialogPortalContainerContext.Provider value={portalContainer}>\n\t\t\t\t<DialogPrimitive.Content\n\t\t\t\t\tdata-slot=\"dialog-content\"\n\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t// Center with inset + margin, not translate. Translate (and zoom\n\t\t\t\t\t\t// scale) create a containing block that misaligns Google Places\n\t\t\t\t\t\t// PlaceAutocompleteElement prediction lists and other fixed UI.\n\t\t\t\t\t\t// flex-col + h-fit: Safari stretches out-of-flow `display:grid`\n\t\t\t\t\t\t// panels to the viewport (WebKit 260461); flex sizes to content.\n\t\t\t\t\t\t// overflow-visible: Select/Combobox portal into this node; an\n\t\t\t\t\t\t// overflow scrollport here folds abspos popup height into the\n\t\t\t\t\t\t// dialog and stretches the panel when a list opens.\n\t\t\t\t\t\t\"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 m-auto flex h-fit max-h-[calc(100%-2rem)] w-full max-w-[calc(100%-2rem)] flex-col overflow-visible rounded-lg border shadow-lg duration-200 sm:max-w-lg\",\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t)}\n\t\t\t\t\t{...props}\n\t\t\t\t\tref={setPortalContainer}\n\t\t\t\t\tonPointerDownOutside={(event) => {\n\t\t\t\t\t\tif (isPortaledOverlayTarget(event.target)) event.preventDefault();\n\t\t\t\t\t\tonPointerDownOutside?.(event);\n\t\t\t\t\t}}\n\t\t\t\t\tonInteractOutside={(event) => {\n\t\t\t\t\t\tif (isPortaledOverlayTarget(event.target)) event.preventDefault();\n\t\t\t\t\t\tonInteractOutside?.(event);\n\t\t\t\t\t}}\n\t\t\t\t\tonFocusOutside={(event) => {\n\t\t\t\t\t\tif (isPortaledOverlayTarget(event.target)) event.preventDefault();\n\t\t\t\t\t\tonFocusOutside?.(event);\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tdata-slot=\"dialog-body\"\n\t\t\t\t\t\tclassName=\"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-6\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</div>\n\t\t\t\t\t{showCloseButton ? (\n\t\t\t\t\t\t<DialogPrimitive.Close className=\"ring-offset-background focus:ring-ring absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none\">\n\t\t\t\t\t\t\t<XIcon className=\"size-4\" />\n\t\t\t\t\t\t\t<span className=\"sr-only\">Close</span>\n\t\t\t\t\t\t</DialogPrimitive.Close>\n\t\t\t\t\t) : null}\n\t\t\t\t</DialogPrimitive.Content>\n\t\t\t</DialogPortalContainerContext.Provider>\n\t\t</DialogPortal>\n\t);\n}\n\nfunction DialogHeader({ className, ...props }: ComponentProps<\"div\">) {\n\treturn (\n\t\t<div\n\t\t\tdata-slot=\"dialog-header\"\n\t\t\tclassName={cn(\"flex flex-col gap-2 text-center sm:text-left\", className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction DialogFooter({ className, ...props }: ComponentProps<\"div\">) {\n\treturn (\n\t\t<div\n\t\t\tdata-slot=\"dialog-footer\"\n\t\t\tclassName={cn(\n\t\t\t\t\"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction DialogTitle({\n\tclassName,\n\t...props\n}: ComponentProps<typeof DialogPrimitive.Title>) {\n\treturn (\n\t\t<DialogPrimitive.Title\n\t\t\tdata-slot=\"dialog-title\"\n\t\t\tclassName={cn(\"text-lg leading-none font-semibold\", className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction DialogDescription({\n\tclassName,\n\t...props\n}: ComponentProps<typeof DialogPrimitive.Description>) {\n\treturn (\n\t\t<DialogPrimitive.Description\n\t\t\tdata-slot=\"dialog-description\"\n\t\t\tclassName={cn(\"text-muted-foreground text-sm\", className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nexport {\n\tDialog,\n\tDialogClose,\n\tDialogContent,\n\tDialogDescription,\n\tDialogFooter,\n\tDialogHeader,\n\tDialogTitle,\n\tDialogTrigger,\n\tuseDialogPortalContainer,\n};\n"]}
|
package/dist/ui/select.js
CHANGED
|
@@ -115,6 +115,7 @@ function Select({
|
|
|
115
115
|
/* @__PURE__ */ jsx(Select$1.Portal, { container: dialogPortalContainer ?? void 0, children: /* @__PURE__ */ jsx(
|
|
116
116
|
Select$1.Positioner,
|
|
117
117
|
{
|
|
118
|
+
alignItemWithTrigger: false,
|
|
118
119
|
"data-slot": "select-positioner",
|
|
119
120
|
className: "pointer-events-auto isolate z-[100] outline-none",
|
|
120
121
|
sideOffset: 4,
|
package/dist/ui/select.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/utils.ts","../../src/ui/select.tsx"],"names":["SelectPrimitive"],"mappings":";;;;;;;;AAGO,SAAS,MAAM,MAAA,EAAsB;AAC3C,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC5B;ACUA,SAAS,oBAAoB,QAAA,EAA2C;AACvE,EAAA,MAAM,UAA0B,EAAC;AACjC,EAAM,KAAA,CAAA,QAAA,CAAS,OAAA,CAAQ,QAAA,EAAU,CAAC,KAAA,KAAU;AAC3C,IAAA,IAAI,CAAO,KAAA,CAAA,cAAA,CAAe,KAAK,CAAA,IAAK,KAAA,CAAM,SAAS,QAAA,EAAU;AAC7D,IAAA,MAAM,QAAQ,KAAA,CAAM,KAAA;AACpB,IAAA,IAAI,KAAA,CAAM,KAAA,KAAU,MAAA,IAAa,KAAA,CAAM,UAAU,IAAA,EAAM;AACvD,IAAA,OAAA,CAAQ,IAAA,CAAK;AAAA,MACZ,KAAA,EAAO,MAAA,CAAO,KAAA,CAAM,KAAK,CAAA;AAAA,MACzB,KAAA,EAAO,KAAA,CAAM,QAAA,IAAY,MAAA,CAAO,MAAM,KAAK,CAAA;AAAA,MAC3C,UAAU,KAAA,CAAM;AAAA,KAChB,CAAA;AAAA,EACF,CAAC,CAAA;AACD,EAAA,OAAO,OAAA;AACR;AAEA,IAAM,gBAAA,GACL,oiBAAA;AAED,IAAM,cAAA,GACL,qpBAAA;AAED,IAAM,aAAA,GACL,s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CAAO,KAAA;AAAA,oBAEX,UAAU,MAAA,CAAO,QAAA;AAAA,oBACjB,SAAA,EAAW,aAAA;AAAA,oBAEX,QAAA,EAAA;AAAA,sCAAA,GAAA,CAACA,QAAA,CAAgB,QAAA,EAAhB,EACC,QAAA,EAAA,MAAA,CAAO,KAAA,EACT,CAAA;AAAA,sCACA,GAAA,CAACA,QAAA,CAAgB,aAAA,EAAhB,EAA8B,SAAA,EAAU,kFACxC,QAAA,kBAAA,GAAA,CAAC,SAAA,EAAA,EAAU,SAAA,EAAU,QAAA,EAAS,CAAA,EAC/B;AAAA;AAAA,mBAAA;AAAA,kBAfK,MAAA,CAAO;AAAA,iBAiBb,CAAA,EACF;AAAA;AAAA;AACD;AAAA,SACD,EACD;AAAA;AAAA;AAAA,GACD;AAEF","file":"select.js","sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n\treturn twMerge(clsx(inputs));\n}\n","\"use client\";\n\nimport * as React from \"react\";\nimport { Select as SelectPrimitive } from \"@base-ui/react/select\";\nimport { CheckIcon, ChevronDownIcon } from \"lucide-react\";\n\nimport { cn } from \"../lib/utils\";\nimport { useDialogPortalContainer } from \"./dialog\";\n\ntype ParsedOption = {\n\tvalue: string;\n\tlabel: React.ReactNode;\n\tdisabled?: boolean;\n};\n\nfunction parseOptionChildren(children: React.ReactNode): ParsedOption[] {\n\tconst options: ParsedOption[] = [];\n\tReact.Children.forEach(children, (child) => {\n\t\tif (!React.isValidElement(child) || child.type !== \"option\") return;\n\t\tconst props = child.props as React.OptionHTMLAttributes<HTMLOptionElement>;\n\t\tif (props.value === undefined || props.value === null) return;\n\t\toptions.push({\n\t\t\tvalue: String(props.value),\n\t\t\tlabel: props.children ?? String(props.value),\n\t\t\tdisabled: props.disabled,\n\t\t});\n\t});\n\treturn options;\n}\n\nconst triggerClassName =\n\t\"flex h-8 w-full min-w-0 items-center justify-between gap-2 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40\";\n\nconst popupClassName =\n\t\"pointer-events-auto z-[100] max-h-(--available-height) min-w-(--anchor-width) origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95\";\n\nconst itemClassName =\n\t\"relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none pointer-events-auto data-disabled:pointer-events-none data-disabled:opacity-50 data-highlighted:bg-accent data-highlighted:text-accent-foreground data-selected:bg-accent/50\";\n\ntype SelectProps = Omit<\n\tReact.ComponentProps<\"select\">,\n\t\"onChange\" | \"children\" | \"size\" | \"multiple\"\n> & {\n\tonChange?: React.ChangeEventHandler<HTMLSelectElement>;\n\tchildren?: React.ReactNode;\n};\n\nfunction optionsSignature(options: ParsedOption[]): string {\n\treturn options\n\t\t.map(\n\t\t\t(option) =>\n\t\t\t\t`${option.value}\\0${option.disabled ? \"1\" : \"0\"}\\0${\n\t\t\t\t\ttypeof option.label === \"string\" ? option.label : \"\"\n\t\t\t\t}`,\n\t\t)\n\t\t.join(\"\\n\");\n}\n\nfunction Select({\n\tclassName,\n\tchildren,\n\tvalue,\n\tdefaultValue,\n\tonChange,\n\tdisabled,\n\trequired,\n\tname,\n\tid,\n\tautoFocus,\n\ttabIndex,\n\t\"aria-label\": ariaLabel,\n\t\"aria-labelledby\": ariaLabelledby,\n\t\"aria-describedby\": ariaDescribedby,\n\t\"aria-invalid\": ariaInvalid,\n}: SelectProps) {\n\tconst dialogPortalContainer = useDialogPortalContainer();\n\t// `children` is a new element tree every parent render; keep the same options\n\t// array when value/label/disabled are unchanged so an open list does not remount.\n\tconst optionsRef = React.useRef<ParsedOption[]>([]);\n\tconst nextOptions = parseOptionChildren(children);\n\tif (optionsSignature(optionsRef.current) !== optionsSignature(nextOptions)) {\n\t\toptionsRef.current = nextOptions;\n\t}\n\tconst options = optionsRef.current;\n\tconst items = React.useMemo(\n\t\t() =>\n\t\t\toptions.map((option) => ({ value: option.value, label: option.label })),\n\t\t[options],\n\t);\n\n\tconst handleValueChange = React.useCallback(\n\t\t(next: string | null) => {\n\t\t\tif (!onChange) return;\n\t\t\tconst nextValue = next ?? \"\";\n\t\t\tonChange({\n\t\t\t\ttarget: { value: nextValue },\n\t\t\t\tcurrentTarget: { value: nextValue },\n\t\t\t} as React.ChangeEvent<HTMLSelectElement>);\n\t\t},\n\t\t[onChange],\n\t);\n\n\t// Base UI rejects \"\" as a controlled value (throws → workspace error boundary).\n\tconst controlledValue =\n\t\tvalue === undefined || value === null || value === \"\"\n\t\t\t? null\n\t\t\t: String(value);\n\tconst uncontrolledDefault =\n\t\tdefaultValue === undefined || defaultValue === null || defaultValue === \"\"\n\t\t\t? undefined\n\t\t\t: String(defaultValue);\n\n\tif (options.length === 0) {\n\t\treturn (\n\t\t\t<select\n\t\t\t\tdata-slot=\"select\"\n\t\t\t\tclassName={cn(triggerClassName, className)}\n\t\t\t\tdisabled\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<SelectPrimitive.Root\n\t\t\tname={name}\n\t\t\trequired={required}\n\t\t\tdisabled={disabled}\n\t\t\t// Keep the Base UI default (modal). `modal={false}` leaves the popup under\n\t\t\t// Radix Dialog's body `pointer-events: none`, so options cannot be clicked\n\t\t\t// and the list appears to blur/collapse immediately.\n\t\t\titems={items}\n\t\t\tvalue={controlledValue}\n\t\t\tdefaultValue={uncontrolledDefault}\n\t\t\tonValueChange={handleValueChange}\n\t\t>\n\t\t\t<SelectPrimitive.Trigger\n\t\t\t\tdata-slot=\"select\"\n\t\t\t\tid={id}\n\t\t\t\tautoFocus={autoFocus}\n\t\t\t\ttabIndex={tabIndex}\n\t\t\t\taria-label={ariaLabel}\n\t\t\t\taria-labelledby={ariaLabelledby}\n\t\t\t\taria-describedby={ariaDescribedby}\n\t\t\t\taria-invalid={ariaInvalid}\n\t\t\t\tclassName={cn(triggerClassName, className)}\n\t\t\t>\n\t\t\t\t<SelectPrimitive.Value className=\"truncate text-left\" />\n\t\t\t\t<SelectPrimitive.Icon className=\"pointer-events-none shrink-0 text-muted-foreground\">\n\t\t\t\t\t<ChevronDownIcon className=\"size-4\" />\n\t\t\t\t</SelectPrimitive.Icon>\n\t\t\t</SelectPrimitive.Trigger>\n\t\t\t{/* Prefer Dialog content as portal root so Radix focus trap keeps the list\n\t\t\t open; fall back to body with pointer-events/z overrides. */}\n\t\t\t<SelectPrimitive.Portal container={dialogPortalContainer ?? undefined}>\n\t\t\t\t<SelectPrimitive.Positioner\n\t\t\t\t\tdata-slot=\"select-positioner\"\n\t\t\t\t\tclassName=\"pointer-events-auto isolate z-[100] outline-none\"\n\t\t\t\t\tsideOffset={4}\n\t\t\t\t>\n\t\t\t\t\t<SelectPrimitive.Popup\n\t\t\t\t\t\tdata-slot=\"select-popup\"\n\t\t\t\t\t\tclassName={popupClassName}\n\t\t\t\t\t>\n\t\t\t\t\t\t<SelectPrimitive.List onWheel={(event) => event.stopPropagation()}>\n\t\t\t\t\t\t\t{options.map((option) => (\n\t\t\t\t\t\t\t\t<SelectPrimitive.Item\n\t\t\t\t\t\t\t\t\tkey={option.value}\n\t\t\t\t\t\t\t\t\tvalue={option.value}\n\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\ttypeof option.label === \"string\"\n\t\t\t\t\t\t\t\t\t\t\t? option.label\n\t\t\t\t\t\t\t\t\t\t\t: option.value\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tdisabled={option.disabled}\n\t\t\t\t\t\t\t\t\tclassName={itemClassName}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<SelectPrimitive.ItemText>\n\t\t\t\t\t\t\t\t\t\t{option.label}\n\t\t\t\t\t\t\t\t\t</SelectPrimitive.ItemText>\n\t\t\t\t\t\t\t\t\t<SelectPrimitive.ItemIndicator className=\"pointer-events-none absolute right-1.5 flex size-4 items-center justify-center\">\n\t\t\t\t\t\t\t\t\t\t<CheckIcon className=\"size-4\" />\n\t\t\t\t\t\t\t\t\t</SelectPrimitive.ItemIndicator>\n\t\t\t\t\t\t\t\t</SelectPrimitive.Item>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</SelectPrimitive.List>\n\t\t\t\t\t</SelectPrimitive.Popup>\n\t\t\t\t</SelectPrimitive.Positioner>\n\t\t\t</SelectPrimitive.Portal>\n\t\t</SelectPrimitive.Root>\n\t);\n}\n\nexport { Select };\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/lib/utils.ts","../../src/ui/select.tsx"],"names":["SelectPrimitive"],"mappings":";;;;;;;;AAGO,SAAS,MAAM,MAAA,EAAsB;AAC3C,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC5B;ACUA,SAAS,oBAAoB,QAAA,EAA2C;AACvE,EAAA,MAAM,UAA0B,EAAC;AACjC,EAAM,KAAA,CAAA,QAAA,CAAS,OAAA,CAAQ,QAAA,EAAU,CAAC,KAAA,KAAU;AAC3C,IAAA,IAAI,CAAO,KAAA,CAAA,cAAA,CAAe,KAAK,CAAA,IAAK,KAAA,CAAM,SAAS,QAAA,EAAU;AA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AA,YACV,UAAA,EAAY,CAAA;AAAA,YAEZ,QAAA,kBAAA,GAAA;AAAA,cAACA,QAAA,CAAgB,KAAA;AAAA,cAAhB;AAAA,gBACA,WAAA,EAAU,cAAA;AAAA,gBACV,SAAA,EAAW,cAAA;AAAA,gBAEX,QAAA,kBAAA,GAAA,CAACA,QAAA,CAAgB,IAAA,EAAhB,EAAqB,OAAA,EAAS,CAAC,KAAA,KAAU,KAAA,CAAM,eAAA,EAAgB,EAC9D,QAAA,EAAA,OAAA,CAAQ,GAAA,CAAI,CAAC,MAAA,qBACb,IAAA;AAAA,kBAACA,QAAA,CAAgB,IAAA;AAAA,kBAAhB;AAAA,oBAEA,OAAO,MAAA,CAAO,KAAA;AAAA,oBACd,OACC,OAAO,MAAA,CAAO,UAAU,QAAA,GACrB,MAAA,CAAO,QACP,MAAA,CAAO,KAAA;AAAA,oBAEX,UAAU,MAAA,CAAO,QAAA;AAAA,oBACjB,SAAA,EAAW,aAAA;AAAA,oBAEX,QAAA,EAAA;AAAA,sCAAA,GAAA,CAACA,QAAA,CAAgB,QAAA,EAAhB,EACC,QAAA,EAAA,MAAA,CAAO,KAAA,EACT,CAAA;AAAA,sCACA,GAAA,CAACA,QAAA,CAAgB,aAAA,EAAhB,EAA8B,SAAA,EAAU,kFACxC,QAAA,kBAAA,GAAA,CAAC,SAAA,EAAA,EAAU,SAAA,EAAU,QAAA,EAAS,CAAA,EAC/B;AAAA;AAAA,mBAAA;AAAA,kBAfK,MAAA,CAAO;AAAA,iBAiBb,CAAA,EACF;AAAA;AAAA;AACD;AAAA,SACD,EACD;AAAA;AAAA;AAAA,GACD;AAEF","file":"select.js","sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n\treturn twMerge(clsx(inputs));\n}\n","\"use client\";\n\nimport * as React from \"react\";\nimport { Select as SelectPrimitive } from \"@base-ui/react/select\";\nimport { CheckIcon, ChevronDownIcon } from \"lucide-react\";\n\nimport { cn } from \"../lib/utils\";\nimport { useDialogPortalContainer } from \"./dialog\";\n\ntype ParsedOption = {\n\tvalue: string;\n\tlabel: React.ReactNode;\n\tdisabled?: boolean;\n};\n\nfunction parseOptionChildren(children: React.ReactNode): ParsedOption[] {\n\tconst options: ParsedOption[] = [];\n\tReact.Children.forEach(children, (child) => {\n\t\tif (!React.isValidElement(child) || child.type !== \"option\") return;\n\t\tconst props = child.props as React.OptionHTMLAttributes<HTMLOptionElement>;\n\t\tif (props.value === undefined || props.value === null) return;\n\t\toptions.push({\n\t\t\tvalue: String(props.value),\n\t\t\tlabel: props.children ?? String(props.value),\n\t\t\tdisabled: props.disabled,\n\t\t});\n\t});\n\treturn options;\n}\n\nconst triggerClassName =\n\t\"flex h-8 w-full min-w-0 items-center justify-between gap-2 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40\";\n\nconst popupClassName =\n\t\"pointer-events-auto z-[100] max-h-(--available-height) min-w-(--anchor-width) origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95\";\n\nconst itemClassName =\n\t\"relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none pointer-events-auto data-disabled:pointer-events-none data-disabled:opacity-50 data-highlighted:bg-accent data-highlighted:text-accent-foreground data-selected:bg-accent/50\";\n\ntype SelectProps = Omit<\n\tReact.ComponentProps<\"select\">,\n\t\"onChange\" | \"children\" | \"size\" | \"multiple\"\n> & {\n\tonChange?: React.ChangeEventHandler<HTMLSelectElement>;\n\tchildren?: React.ReactNode;\n};\n\nfunction optionsSignature(options: ParsedOption[]): string {\n\treturn options\n\t\t.map(\n\t\t\t(option) =>\n\t\t\t\t`${option.value}\\0${option.disabled ? \"1\" : \"0\"}\\0${\n\t\t\t\t\ttypeof option.label === \"string\" ? option.label : \"\"\n\t\t\t\t}`,\n\t\t)\n\t\t.join(\"\\n\");\n}\n\nfunction Select({\n\tclassName,\n\tchildren,\n\tvalue,\n\tdefaultValue,\n\tonChange,\n\tdisabled,\n\trequired,\n\tname,\n\tid,\n\tautoFocus,\n\ttabIndex,\n\t\"aria-label\": ariaLabel,\n\t\"aria-labelledby\": ariaLabelledby,\n\t\"aria-describedby\": ariaDescribedby,\n\t\"aria-invalid\": ariaInvalid,\n}: SelectProps) {\n\tconst dialogPortalContainer = useDialogPortalContainer();\n\t// `children` is a new element tree every parent render; keep the same options\n\t// array when value/label/disabled are unchanged so an open list does not remount.\n\tconst optionsRef = React.useRef<ParsedOption[]>([]);\n\tconst nextOptions = parseOptionChildren(children);\n\tif (optionsSignature(optionsRef.current) !== optionsSignature(nextOptions)) {\n\t\toptionsRef.current = nextOptions;\n\t}\n\tconst options = optionsRef.current;\n\tconst items = React.useMemo(\n\t\t() =>\n\t\t\toptions.map((option) => ({ value: option.value, label: option.label })),\n\t\t[options],\n\t);\n\n\tconst handleValueChange = React.useCallback(\n\t\t(next: string | null) => {\n\t\t\tif (!onChange) return;\n\t\t\tconst nextValue = next ?? \"\";\n\t\t\tonChange({\n\t\t\t\ttarget: { value: nextValue },\n\t\t\t\tcurrentTarget: { value: nextValue },\n\t\t\t} as React.ChangeEvent<HTMLSelectElement>);\n\t\t},\n\t\t[onChange],\n\t);\n\n\t// Base UI rejects \"\" as a controlled value (throws → workspace error boundary).\n\tconst controlledValue =\n\t\tvalue === undefined || value === null || value === \"\"\n\t\t\t? null\n\t\t\t: String(value);\n\tconst uncontrolledDefault =\n\t\tdefaultValue === undefined || defaultValue === null || defaultValue === \"\"\n\t\t\t? undefined\n\t\t\t: String(defaultValue);\n\n\tif (options.length === 0) {\n\t\treturn (\n\t\t\t<select\n\t\t\t\tdata-slot=\"select\"\n\t\t\t\tclassName={cn(triggerClassName, className)}\n\t\t\t\tdisabled\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<SelectPrimitive.Root\n\t\t\tname={name}\n\t\t\trequired={required}\n\t\t\tdisabled={disabled}\n\t\t\t// Keep the Base UI default (modal). `modal={false}` leaves the popup under\n\t\t\t// Radix Dialog's body `pointer-events: none`, so options cannot be clicked\n\t\t\t// and the list appears to blur/collapse immediately.\n\t\t\titems={items}\n\t\t\tvalue={controlledValue}\n\t\t\tdefaultValue={uncontrolledDefault}\n\t\t\tonValueChange={handleValueChange}\n\t\t>\n\t\t\t<SelectPrimitive.Trigger\n\t\t\t\tdata-slot=\"select\"\n\t\t\t\tid={id}\n\t\t\t\tautoFocus={autoFocus}\n\t\t\t\ttabIndex={tabIndex}\n\t\t\t\taria-label={ariaLabel}\n\t\t\t\taria-labelledby={ariaLabelledby}\n\t\t\t\taria-describedby={ariaDescribedby}\n\t\t\t\taria-invalid={ariaInvalid}\n\t\t\t\tclassName={cn(triggerClassName, className)}\n\t\t\t>\n\t\t\t\t<SelectPrimitive.Value className=\"truncate text-left\" />\n\t\t\t\t<SelectPrimitive.Icon className=\"pointer-events-none shrink-0 text-muted-foreground\">\n\t\t\t\t\t<ChevronDownIcon className=\"size-4\" />\n\t\t\t\t</SelectPrimitive.Icon>\n\t\t\t</SelectPrimitive.Trigger>\n\t\t\t{/* Prefer Dialog content as portal root so Radix focus trap keeps the list\n\t\t\t open; fall back to body with pointer-events/z overrides. */}\n\t\t\t<SelectPrimitive.Portal container={dialogPortalContainer ?? undefined}>\n\t\t\t\t<SelectPrimitive.Positioner\n\t\t\t\t\talignItemWithTrigger={false}\n\t\t\t\t\tdata-slot=\"select-positioner\"\n\t\t\t\t\tclassName=\"pointer-events-auto isolate z-[100] outline-none\"\n\t\t\t\t\tsideOffset={4}\n\t\t\t\t>\n\t\t\t\t\t<SelectPrimitive.Popup\n\t\t\t\t\t\tdata-slot=\"select-popup\"\n\t\t\t\t\t\tclassName={popupClassName}\n\t\t\t\t\t>\n\t\t\t\t\t\t<SelectPrimitive.List onWheel={(event) => event.stopPropagation()}>\n\t\t\t\t\t\t\t{options.map((option) => (\n\t\t\t\t\t\t\t\t<SelectPrimitive.Item\n\t\t\t\t\t\t\t\t\tkey={option.value}\n\t\t\t\t\t\t\t\t\tvalue={option.value}\n\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\ttypeof option.label === \"string\"\n\t\t\t\t\t\t\t\t\t\t\t? option.label\n\t\t\t\t\t\t\t\t\t\t\t: option.value\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tdisabled={option.disabled}\n\t\t\t\t\t\t\t\t\tclassName={itemClassName}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<SelectPrimitive.ItemText>\n\t\t\t\t\t\t\t\t\t\t{option.label}\n\t\t\t\t\t\t\t\t\t</SelectPrimitive.ItemText>\n\t\t\t\t\t\t\t\t\t<SelectPrimitive.ItemIndicator className=\"pointer-events-none absolute right-1.5 flex size-4 items-center justify-center\">\n\t\t\t\t\t\t\t\t\t\t<CheckIcon className=\"size-4\" />\n\t\t\t\t\t\t\t\t\t</SelectPrimitive.ItemIndicator>\n\t\t\t\t\t\t\t\t</SelectPrimitive.Item>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</SelectPrimitive.List>\n\t\t\t\t\t</SelectPrimitive.Popup>\n\t\t\t\t</SelectPrimitive.Positioner>\n\t\t\t</SelectPrimitive.Portal>\n\t\t</SelectPrimitive.Root>\n\t);\n}\n\nexport { Select };\n"]}
|