@bioturing/components 0.27.0 → 0.29.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.
Files changed (70) hide show
  1. package/dist/components/breadcrumb/style.css +1 -1
  2. package/dist/components/checkbox/component.js.map +1 -1
  3. package/dist/components/checkbox/style.css +1 -1
  4. package/dist/components/choice-list/component.js +102 -42
  5. package/dist/components/choice-list/component.js.map +1 -1
  6. package/dist/components/choice-list/style.css +1 -1
  7. package/dist/components/cmdk/index.js.map +1 -1
  8. package/dist/components/color-select/style.css +1 -1
  9. package/dist/components/combobox/component.js +232 -0
  10. package/dist/components/combobox/component.js.map +1 -0
  11. package/dist/components/combobox/style.css +1 -0
  12. package/dist/components/drag-drop/style.css +1 -1
  13. package/dist/components/dropdown-menu/component.js +181 -160
  14. package/dist/components/dropdown-menu/component.js.map +1 -1
  15. package/dist/components/dropdown-menu/divider.js +16 -0
  16. package/dist/components/dropdown-menu/divider.js.map +1 -0
  17. package/dist/components/dropdown-menu/item.css +1 -0
  18. package/dist/components/dropdown-menu/item.js +131 -0
  19. package/dist/components/dropdown-menu/item.js.map +1 -0
  20. package/dist/components/dropdown-menu/style.css +1 -1
  21. package/dist/components/ds-root/component.js +22 -17
  22. package/dist/components/ds-root/component.js.map +1 -1
  23. package/dist/components/ds-root/style.css +1 -1
  24. package/dist/components/form/style.css +1 -1
  25. package/dist/components/hooks/useDraggable.js +77 -0
  26. package/dist/components/hooks/useDraggable.js.map +1 -0
  27. package/dist/components/hooks/useHover.js +26 -0
  28. package/dist/components/hooks/useHover.js.map +1 -0
  29. package/dist/components/hooks/useTransitionStatus.js +52 -0
  30. package/dist/components/hooks/useTransitionStatus.js.map +1 -0
  31. package/dist/components/modal/style.css +1 -1
  32. package/dist/components/nav/item.js +2 -2
  33. package/dist/components/nav/style.css +1 -1
  34. package/dist/components/popup-panel/component.js +81 -92
  35. package/dist/components/popup-panel/component.js.map +1 -1
  36. package/dist/components/resizable/component.js +165 -97
  37. package/dist/components/resizable/component.js.map +1 -1
  38. package/dist/components/resizable/style.css +1 -1
  39. package/dist/components/scroll-area/component.js +70 -24
  40. package/dist/components/scroll-area/component.js.map +1 -1
  41. package/dist/components/scroll-area/style.css +1 -1
  42. package/dist/components/select/component.js +160 -91
  43. package/dist/components/select/component.js.map +1 -1
  44. package/dist/components/select/item.js +54 -0
  45. package/dist/components/select/item.js.map +1 -0
  46. package/dist/components/select/style.css +1 -1
  47. package/dist/components/select-trigger/component.js +150 -0
  48. package/dist/components/select-trigger/component.js.map +1 -0
  49. package/dist/components/select-trigger/style.css +1 -0
  50. package/dist/components/splitter/splitter-panel.js +8 -8
  51. package/dist/components/splitter/splitter.js +9 -9
  52. package/dist/components/splitter/useSizes.js +10 -10
  53. package/dist/components/splitter/useSizes.js.map +1 -1
  54. package/dist/components/stack/StackChild.js +9 -9
  55. package/dist/components/switch/style.css +1 -1
  56. package/dist/components/table/style.css +1 -1
  57. package/dist/components/theme-provider/component.js.map +1 -1
  58. package/dist/components/theme-provider/style.css +1 -1
  59. package/dist/components/tour/style.css +1 -1
  60. package/dist/components/transition/component.js +1 -1
  61. package/dist/components/transition/component.js.map +1 -1
  62. package/dist/components/utils/WithRenderProp.js.map +1 -1
  63. package/dist/index.d.ts +355 -12
  64. package/dist/index.js +198 -188
  65. package/dist/index.js.map +1 -1
  66. package/dist/metadata.js +21 -7
  67. package/dist/metadata.js.map +1 -1
  68. package/dist/tokens/and-theme/tokens.js +12 -12
  69. package/dist/tokens/and-theme/tokens.js.map +1 -1
  70. package/package.json +8 -7
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sources":["../../../src/components/popup-panel/component.tsx"],"sourcesContent":["\"use client\";\nimport { useCls, clsx, parseAntdPlacement, buildAntdPlacement, BaseUIPlacement, BaseUISide, BaseUIAlign } from \"../utils\";\nimport { Popover } from \"@base-ui-components/react/popover\";\n\nimport { type PopoverProps } from \"antd/es/popover\";\nimport { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { IconButton } from \"../icon-button\";\nimport { X } from \"@bioturing/assets\";\nimport { PopupPanelSize } from \"./constants\";\nimport { useControlledState } from \"../hooks\";\nimport { Resizable } from \"../resizable\";\nimport { Stack } from \"../stack\";\n\n// Import component-specific styles\nimport \"./style.css\";\nimport { useRef } from \"react\";\n\nexport interface PopupPanelProps\n extends Omit<\n React.ComponentPropsWithRef<\"div\">,\n \"title\" | \"content\" | \"children\"\n > {\n /** The trigger element that opens the popup panel */\n children?: React.ComponentProps<typeof Popover.Trigger>[\"render\"];\n /** Placement of the popup panel relative to its trigger */\n placement?: PopoverProps[\"placement\"];\n /** Whether to open the popup panel on hover */\n openOnHover?: boolean;\n /** Controls the open state of the popup panel */\n open?: boolean;\n /** Callback fired when the open state changes */\n onOpenChange?: Popover.Root.Props[\"onOpenChange\"];\n /** Content to display inside the popup panel */\n content?: React.ReactNode;\n /** Title text or element to display in the panel header */\n title?: React.ReactNode;\n /** The event that triggers the popup panel */\n /**\n * @default \"click\"\n */\n trigger?: \"click\" | \"hover\";\n /** Custom anchor element for positioning the panel */\n anchor?: Popover.Positioner.Props[\"anchor\"];\n /** Content to display before the close button */\n beforeCloseButton?: React.ReactNode;\n /** Content to display after the close button */\n afterCloseButton?: React.ReactNode;\n /** Content to display after the title */\n afterTitle?: React.ReactNode;\n /**\n * Predefined sizes for the popup panel\n * - xsmall: 320px\n * - small: 400px\n * - medium: 480px (default)\n * - large: 640px\n * - xlarge: 840px\n * @default \"medium\" for default type, \"xsmall\" for other types\n */\n size?: keyof typeof PopupPanelSize;\n /**\n * Footer content for the popup panel\n * Can be a React node or a function that returns a React node\n */\n footer?:\n | React.ReactNode\n | ((props: { close: () => void }) => React.ReactNode);\n /**\n * Whether the panel should be open by default when uncontrolled\n * @default false\n */\n defaultOpen?: boolean;\n /**\n * Whether the panel should be resizable\n * @default false\n */\n resizable?: boolean;\n /**\n * Custom class names for different parts of the popup panel\n * @default {}\n */\n classNames?: {\n root?: string;\n trigger?: string;\n popup?: string;\n header?: string;\n title?: string;\n content?: string;\n footer?: string;\n resizeHandle?: string;\n };\n /**\n * Whether to close the panel when clicking outside\n * @default true\n */\n closeOnClickOutside?: boolean;\n /**\n * Whether to use modal mode\n * @default false\n */\n modal?: Popover.Root.Props[\"modal\"];\n /**\n * Callback function when the placement changes\n */\n onPlacementChange?: (placement: PopoverProps[\"placement\"]) => void;\n}\n\nexport const PopupPanel = ({\n children,\n placement,\n openOnHover = false,\n open: outsideOpen,\n onOpenChange: outsideOnOpenChange,\n content,\n title,\n trigger = \"click\",\n className,\n anchor,\n beforeCloseButton,\n afterCloseButton,\n afterTitle,\n size = \"medium\",\n footer,\n defaultOpen,\n resizable = false,\n classNames,\n modal = false,\n closeOnClickOutside = true,\n onPlacementChange,\n}: PopupPanelProps) => {\n // Use controlled state with proper initialization to prevent switching between controlled/uncontrolled\n const [open, setOpen] = useControlledState(\n outsideOpen,\n outsideOnOpenChange,\n defaultOpen ?? false // Always provide a default value to prevent undefined\n );\n\n const cls = useCls();\n const baseUIPlacement = parseAntdPlacement(placement);\n\n const defaultCloseIcon = useMemo(() => <X size={16} />, []);\n\n const positionerRef = useRef<HTMLDivElement>(null);\n const currentSideRef = useRef<BaseUISide>(baseUIPlacement.side);\n const currentAlignRef = useRef<BaseUIAlign>(baseUIPlacement.align);\n const [placementChangeKey, setPlacementChangeKey] = useState(0);\n\n useEffect(() => {\n const positioner = positionerRef.current;\n if (!positioner || !open) return; // Only observe when popup is open\n\n // Create MutationObserver to watch for data-side changes\n const observer = new MutationObserver((mutations) => {\n let hasPlacementChanged = false;\n \n mutations.forEach((mutation) => {\n if (\n mutation.type === \"attributes\" &&\n mutation.attributeName === \"data-side\"\n ) {\n const newSide = positioner.getAttribute(mutation.attributeName);\n if (newSide && newSide !== currentSideRef.current) {\n currentSideRef.current = newSide as BaseUISide;\n hasPlacementChanged = true;\n }\n }\n if (\n mutation.type === \"attributes\" &&\n mutation.attributeName === \"data-align\"\n ) {\n const newAlign = positioner.getAttribute(mutation.attributeName);\n if (newAlign && newAlign !== currentAlignRef.current) {\n currentAlignRef.current = newAlign as BaseUIAlign;\n hasPlacementChanged = true;\n }\n }\n });\n\n // Only trigger callbacks if placement actually changed\n if (hasPlacementChanged) {\n const newPlacement = buildAntdPlacement({\n side: currentSideRef.current,\n align: currentAlignRef.current\n });\n \n // Trigger resizable dimensions reset when placement changes\n setPlacementChangeKey(prev => prev + 1);\n \n if (onPlacementChange) {\n onPlacementChange(newPlacement);\n }\n }\n });\n\n // Start observing\n observer.observe(positioner, {\n attributes: true,\n attributeFilter: [\"data-side\", \"data-align\"],\n attributeOldValue: true,\n });\n\n return () => {\n observer.disconnect();\n };\n }, [onPlacementChange, open]);\n\n const renderTitle = useCallback(() => {\n return (\n <div className={clsx(cls(\"popup-panel-header\"), classNames?.header)}>\n <Stack\n align=\"center\"\n gap={8}\n className={cls(\"popup-panel-title-wrapper\")}\n >\n <Popover.Title\n render={\n <div className={clsx(cls(\"grow\", \"truncate\"), classNames?.title)}>\n {title}\n </div>\n }\n ></Popover.Title>\n <div className=\"flex items-center gap-2\">\n {beforeCloseButton}\n <Popover.Close\n render={<IconButton>{defaultCloseIcon}</IconButton>}\n />\n {afterCloseButton}\n </div>\n </Stack>\n {afterTitle ? afterTitle : null}\n </div>\n );\n }, [\n afterCloseButton,\n afterTitle,\n beforeCloseButton,\n cls,\n classNames?.header,\n classNames?.title,\n defaultCloseIcon,\n title,\n ]);\n\n return (\n <Popover.Root\n openOnHover={trigger === \"hover\" ? true : openOnHover}\n open={open}\n onOpenChange={(open, event, reason) => {\n if (\n (reason === \"outside-press\" || reason === \"focus-out\") &&\n !closeOnClickOutside\n )\n return;\n setOpen(open, event, reason);\n }}\n modal={modal}\n >\n <Popover.Trigger\n render={children}\n className={clsx(cls(\"popup-panel-trigger\"), classNames?.trigger)}\n ></Popover.Trigger>\n <Popover.Portal>\n <Popover.Positioner\n ref={positionerRef}\n className={clsx(cls(\"popup-panel-root\"), classNames?.root)}\n side={baseUIPlacement.side}\n align={baseUIPlacement.align}\n sideOffset={4}\n anchor={anchor}\n style={\n {\n \"--size-width\": size ? PopupPanelSize[size] : undefined,\n } as React.CSSProperties\n }\n >\n <Resizable\n resizable={resizable}\n absolutePositioning={true}\n resetKey={placementChangeKey}\n classNames={{\n resizeHandle: classNames?.resizeHandle,\n }}\n >\n <Popover.Popup\n className={clsx(\n cls(\"popup-panel\"),\n cls(`popup-panel-size-${size}`),\n className,\n classNames?.popup\n )}\n >\n {title && renderTitle()}\n <div\n className={clsx(\n cls(\"popup-panel-content\"),\n classNames?.content\n )}\n >\n <div className={cls(\"popup-panel-content-inner\")}>\n {content}\n </div>\n </div>\n {footer && (\n <div\n className={clsx(\n cls(\"popup-panel-footer\"),\n classNames?.footer\n )}\n >\n {typeof footer === \"function\"\n ? footer({ close: () => setOpen(false) })\n : footer}\n </div>\n )}\n </Popover.Popup>\n </Resizable>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n};\n"],"names":["PopupPanel","children","placement","openOnHover","outsideOpen","outsideOnOpenChange","content","title","trigger","className","anchor","beforeCloseButton","afterCloseButton","afterTitle","size","footer","defaultOpen","resizable","classNames","modal","closeOnClickOutside","onPlacementChange","open","setOpen","useControlledState","cls","useCls","baseUIPlacement","parseAntdPlacement","defaultCloseIcon","useMemo","jsx","X","positionerRef","useRef","currentSideRef","currentAlignRef","placementChangeKey","setPlacementChangeKey","useState","useEffect","positioner","observer","mutations","hasPlacementChanged","mutation","newSide","newAlign","newPlacement","buildAntdPlacement","prev","renderTitle","useCallback","jsxs","clsx","Stack","Popover","IconButton","event","reason","PopupPanelSize","Resizable"],"mappings":";;;;;;;;;;;;;;AA0GO,MAAMA,KAAa,CAAC;AAAA,EACzB,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,MAAMC;AAAA,EACN,cAAcC;AAAA,EACd,SAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,WA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AAAA,kBAAR;AAAA,oBACC,WAAWF;AAAA,sBACT7B,EAAI,aAAa;AAAA,sBACjBA,EAAI,oBAAoBX,CAAI,EAAE;AAAA,sBAC9BL;AAAA,sBACAS,KAAA,gBAAAA,EAAY;AAAA,oBACd;AAAA,oBAEC,UAAA;AAAA,sBAAAX,KAAS4C,EAAY;AAAA,sBACtB,gBAAApB;AAAA,wBAAC;AAAA,wBAAA;AAAA,0BACC,WAAWuB;AAAA,4BACT7B,EAAI,qBAAqB;AAAA,4BACzBP,KAAA,gBAAAA,EAAY;AAAA,0BACd;AAAA,0BAEA,4BAAC,OAAI,EAAA,WAAWO,EAAI,2BAA2B,GAC5C,UACHnB,EAAA,CAAA;AAAA,wBAAA;AAAA,sBACF;AAAA,sBACCS,KACC,gBAAAgB;AAAA,wBAAC;AAAA,wBAAA;AAAA,0BACC,WAAWuB;AAAA,4BACT7B,EAAI,oBAAoB;AAAA,4BACxBP,KAAA,gBAAAA,EAAY;AAAA,0BACd;AAAA,0BAEC,UAAA,OAAOH,KAAW,aACfA,EAAO,EAAE,OAAO,MAAMQ,EAAQ,EAAK,EAAE,CAAC,IACtCR;AAAA,wBAAA;AAAA,sBAAA;AAAA,oBACN;AAAA,kBAAA;AAAA,gBAAA;AAAA,cAEJ;AAAA,YAAA;AAAA,UACF;AAAA,QAAA,EAEJ,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
1
+ {"version":3,"file":"component.js","sources":["../../../src/components/popup-panel/component.tsx"],"sourcesContent":["\"use client\";\nimport {\n useCls,\n clsx,\n parseAntdPlacement,\n buildAntdPlacement,\n BaseUIPlacement,\n BaseUISide,\n BaseUIAlign,\n} from \"../utils\";\nimport { Popover } from \"@base-ui-components/react/popover\";\n\nimport { type PopoverProps } from \"antd/es/popover\";\nimport { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { IconButton } from \"../icon-button\";\nimport { X } from \"@bioturing/assets\";\nimport { PopupPanelSize } from \"./constants\";\nimport { useControlledState, useDraggable } from \"../hooks\";\nimport { Resizable } from \"../resizable\";\nimport { Stack } from \"../stack\";\n\n// Import component-specific styles\nimport \"./style.css\";\nimport { useRef } from \"react\";\n\nexport interface PopupPanelProps\n extends Omit<\n React.ComponentPropsWithRef<\"div\">,\n \"title\" | \"content\" | \"children\"\n >,\n Omit<Popover.Root.Props, \"children\"> {\n /** The trigger element that opens the popup panel */\n children?: React.ComponentProps<typeof Popover.Trigger>[\"render\"];\n /** Placement of the popup panel relative to its trigger */\n placement?: PopoverProps[\"placement\"];\n /** Whether to open the popup panel on hover */\n openOnHover?: boolean;\n /** Controls the open state of the popup panel */\n open?: boolean;\n /** Callback fired when the open state changes */\n onOpenChange?: Popover.Root.Props[\"onOpenChange\"];\n /** Content to display inside the popup panel */\n content?: React.ReactNode;\n /** Title text or element to display in the panel header */\n title?: React.ReactNode;\n /** The event that triggers the popup panel */\n /**\n * @default \"click\"\n */\n trigger?: \"click\" | \"hover\";\n /** Custom anchor element for positioning the panel */\n anchor?: Popover.Positioner.Props[\"anchor\"];\n /** Content to display before the close button */\n beforeCloseButton?: React.ReactNode;\n /** Content to display after the close button */\n afterCloseButton?: React.ReactNode;\n /** Content to display after the title */\n afterTitle?: React.ReactNode;\n /**\n * Predefined sizes for the popup panel\n * - xsmall: 320px\n * - small: 400px\n * - medium: 480px (default)\n * - large: 640px\n * - xlarge: 840px\n * @default \"medium\" for default type, \"xsmall\" for other types\n */\n size?: keyof typeof PopupPanelSize;\n /**\n * Footer content for the popup panel\n * Can be a React node or a function that returns a React node\n */\n footer?:\n | React.ReactNode\n | ((props: { close: () => void }) => React.ReactNode);\n /**\n * Whether the panel should be open by default when uncontrolled\n * @default false\n */\n defaultOpen?: boolean;\n /**\n * Whether the panel should be resizable\n * @default false\n */\n resizable?: boolean;\n /**\n * Whether the panel should be draggable\n * @default false\n */\n draggable?: boolean;\n /**\n * Whether to maintain aspect ratio when resizing\n * Only applies when resizable is true\n * @default false\n */\n maintainAspectRatio?: boolean;\n /**\n * Custom class names for different parts of the popup panel\n * @default {}\n */\n classNames?: {\n root?: string;\n trigger?: string;\n popup?: string;\n header?: string;\n title?: string;\n content?: string;\n footer?: string;\n resizeHandle?: string;\n };\n /**\n * Whether to close the panel when clicking outside\n * @default true\n */\n closeOnClickOutside?: boolean;\n /**\n * Whether to use modal mode\n * @default false\n */\n modal?: Popover.Root.Props[\"modal\"];\n /**\n * Callback function when the placement changes\n */\n onPlacementChange?: (placement: PopoverProps[\"placement\"]) => void;\n}\n\nexport const PopupPanel = ({\n children,\n placement,\n openOnHover = false,\n open: outsideOpen,\n onOpenChange: outsideOnOpenChange,\n content,\n title,\n trigger = \"click\",\n className,\n anchor,\n beforeCloseButton,\n afterCloseButton,\n afterTitle,\n size = \"medium\",\n footer,\n defaultOpen,\n resizable = false,\n draggable = false,\n maintainAspectRatio = false,\n classNames,\n modal = false,\n closeOnClickOutside = true,\n onPlacementChange,\n ...rest\n}: PopupPanelProps) => {\n // Use controlled state with proper initialization to prevent switching between controlled/uncontrolled\n const [open, setOpen] = useControlledState(\n outsideOpen,\n outsideOnOpenChange,\n defaultOpen ?? false, // Always provide a default value to prevent undefined\n );\n\n const cls = useCls();\n const baseUIPlacement = parseAntdPlacement(placement);\n\n const defaultCloseIcon = useMemo(() => <X size={16} />, []);\n\n const positionerRef = useRef<HTMLDivElement>(null);\n const currentSideRef = useRef<BaseUISide>(baseUIPlacement.side);\n const currentAlignRef = useRef<BaseUIAlign>(baseUIPlacement.align);\n const [placementChangeKey, setPlacementChangeKey] = useState(0);\n\n useEffect(() => {\n const positioner = positionerRef.current;\n if (!positioner || !open) return; // Only observe when popup is open\n\n // Create MutationObserver to watch for data-side changes\n const observer = new MutationObserver((mutations) => {\n let hasPlacementChanged = false;\n\n mutations.forEach((mutation) => {\n if (\n mutation.type === \"attributes\" &&\n mutation.attributeName === \"data-side\"\n ) {\n const newSide = positioner.getAttribute(mutation.attributeName);\n if (newSide && newSide !== currentSideRef.current) {\n currentSideRef.current = newSide as BaseUISide;\n hasPlacementChanged = true;\n }\n }\n if (\n mutation.type === \"attributes\" &&\n mutation.attributeName === \"data-align\"\n ) {\n const newAlign = positioner.getAttribute(mutation.attributeName);\n if (newAlign && newAlign !== currentAlignRef.current) {\n currentAlignRef.current = newAlign as BaseUIAlign;\n hasPlacementChanged = true;\n }\n }\n });\n\n // Only trigger callbacks if placement actually changed\n if (hasPlacementChanged) {\n const newPlacement = buildAntdPlacement({\n side: currentSideRef.current,\n align: currentAlignRef.current,\n });\n\n // Trigger resizable dimensions reset when placement changes\n setPlacementChangeKey((prev) => prev + 1);\n\n if (onPlacementChange) {\n onPlacementChange(newPlacement);\n }\n }\n });\n\n // Start observing\n observer.observe(positioner, {\n attributes: true,\n attributeFilter: [\"data-side\", \"data-align\"],\n attributeOldValue: true,\n });\n\n return () => {\n observer.disconnect();\n };\n }, [onPlacementChange, open]);\n\n const renderTitle = useCallback(() => {\n return (\n <div className={clsx(cls(\"popup-panel-header\"), classNames?.header)}>\n <Stack\n align=\"center\"\n gap={8}\n className={cls(\"popup-panel-title-wrapper\")}\n >\n <Popover.Title\n render={\n <div className={clsx(cls(\"grow\", \"truncate\"), classNames?.title)}>\n {title}\n </div>\n }\n ></Popover.Title>\n <div className=\"flex items-center gap-2\">\n {beforeCloseButton}\n <Popover.Close\n render={<IconButton>{defaultCloseIcon}</IconButton>}\n />\n {afterCloseButton}\n </div>\n </Stack>\n {afterTitle ? afterTitle : null}\n </div>\n );\n }, [\n afterCloseButton,\n afterTitle,\n beforeCloseButton,\n cls,\n classNames?.header,\n classNames?.title,\n defaultCloseIcon,\n title,\n ]);\n\n const { ref: draggableRef } = useDraggable(draggable);\n\n const popup = (\n <Popover.Popup\n className={clsx(\n cls(\"popup-panel\"),\n cls(`popup-panel-size-${size}`),\n className,\n classNames?.popup,\n )}\n ref={draggableRef}\n >\n {title && renderTitle()}\n <div className={clsx(cls(\"popup-panel-content\"), classNames?.content)}>\n <div className={cls(\"popup-panel-content-inner\")}>{content}</div>\n </div>\n {footer && (\n <div className={clsx(cls(\"popup-panel-footer\"), classNames?.footer)}>\n {typeof footer === \"function\"\n ? footer({ close: () => setOpen(false) })\n : footer}\n </div>\n )}\n </Popover.Popup>\n );\n\n return (\n <Popover.Root\n openOnHover={trigger === \"hover\" ? true : openOnHover}\n open={open}\n onOpenChange={(open, event, reason) => {\n if (\n (reason === \"outside-press\" || reason === \"focus-out\") &&\n !closeOnClickOutside\n )\n return;\n setOpen(open, event, reason);\n }}\n modal={modal}\n {...rest}\n >\n <Popover.Trigger\n render={children}\n className={clsx(cls(\"popup-panel-trigger\"), classNames?.trigger)}\n ></Popover.Trigger>\n <Popover.Portal>\n <Popover.Positioner\n ref={positionerRef}\n className={clsx(cls(\"popup-panel-root\"), classNames?.root)}\n side={baseUIPlacement.side}\n align={baseUIPlacement.align}\n sideOffset={4}\n anchor={anchor}\n style={\n {\n \"--size-width\": size ? PopupPanelSize[size] : undefined,\n } as React.CSSProperties\n }\n >\n {resizable ? (\n <Resizable\n resizable={resizable}\n absolutePositioning={true}\n resetKey={placementChangeKey}\n maintainAspectRatio={maintainAspectRatio}\n classNames={{\n resizeHandle: classNames?.resizeHandle,\n }}\n >\n {popup}\n </Resizable>\n ) : (\n popup\n )}\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n};\n"],"names":["PopupPanel","children","placement","openOnHover","outsideOpen","outsideOnOpenChange","content","title","trigger","className","anchor","beforeCloseButton","afterCloseButton","afterTitle","size","footer","defaultOpen","resizable","draggable","maintainAspectRatio","classNames","modal","closeOnClickOutside","onPlacementChange","rest","open","setOpen","useControlledState","cls","useCls","baseUIPlacement","parseAntdPlacement","defaultCloseIcon","useMemo","jsx","X","positionerRef","useRef","currentSideRef","currentAlignRef","placementChangeKey","setPlacementChangeKey","useState","useEffect","positioner","observer","mutations","hasPlacementChanged","mutation","newSide","newAlign","newPlacement","buildAntdPlacement","prev","renderTitle","useCallback","jsxs","clsx","Stack","Popover","IconButton","draggableRef","useDragg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useEffect as C, isValidElement as T } from "react";
4
- import { useResizable as U } from "react-use-resizable";
5
- import X from "merge-refs";
6
- import { mergeProps as Y } from "@base-ui-components/react";
3
+ import T, { useState as R, useCallback as U, useEffect as W, isValidElement as X } from "react";
4
+ import { useResizable as Y } from "react-use-resizable";
5
+ import Z from "merge-refs";
6
+ import { mergeProps as K } from "@base-ui-components/react";
7
7
  import './style.css';/* empty css */
8
- import { getReactElementProp as y } from "../utils/reactElement.js";
9
- import { useCls as Z } from "../utils/antdUtils.js";
10
- import { clsx as u, cn as _ } from "../utils/cn.js";
11
- import { WithRenderProp as K } from "../utils/WithRenderProp.js";
12
- const he = ({
13
- children: f,
14
- resizable: d = !1,
15
- handles: h = { bottom: !0, right: !0, left: !0, top: !0 },
16
- absolutePositioning: H = !1,
8
+ import { getReactElementProp as x } from "../utils/reactElement.js";
9
+ import { useCls as A } from "../utils/antdUtils.js";
10
+ import { clsx as h, cn as s } from "../utils/cn.js";
11
+ import { WithRenderProp as a } from "../utils/WithRenderProp.js";
12
+ const ue = ({
13
+ children: p,
14
+ resizable: c = !1,
15
+ handles: o = { bottom: !0, right: !0, left: !0, top: !0 },
16
+ absolutePositioning: V = !1,
17
17
  classNames: t,
18
- className: E,
19
- style: V,
20
- resetKey: b,
21
- maxWidth: D,
22
- maxHeight: S,
23
- minWidth: W,
24
- minHeight: $,
25
- onResize: B,
26
- maintainAspectRatio: A = !1,
18
+ className: m,
19
+ style: I,
20
+ resetKey: B,
21
+ maxWidth: _,
22
+ maxHeight: $,
23
+ minWidth: j,
24
+ minHeight: q,
25
+ onResize: F,
26
+ maintainAspectRatio: r = !1,
27
27
  ...N
28
28
  }) => {
29
- const l = Z(), [i, I] = p(null), [g, v] = p(), [a, P] = p(), [z, w] = p(!1), j = Q(
29
+ const l = A(), [u, G] = R(null), [b, v] = R(), [H, y] = R(), [P, D] = R(!1), J = U(
30
30
  (e) => {
31
- if (I(e), e && !g && !a) {
32
- const r = e.getBoundingClientRect();
33
- r.width > 0 && r.height > 0 && (v(r.width), P(r.height));
31
+ if (G(e), e && !b && !H) {
32
+ const i = e.getBoundingClientRect();
33
+ i.width > 0 && i.height > 0 && r && (v(i.width), y(i.height));
34
34
  }
35
35
  },
36
- [g, a]
36
+ [b, H, r]
37
37
  );
38
- C(() => {
39
- if (b !== void 0 && i) {
40
- i.style.width = "", i.style.height = "";
41
- const e = i.getBoundingClientRect();
42
- e.width > 0 && e.height > 0 && (v(e.width), P(e.height), i.style.width = `${e.width}px`, i.style.height = `${e.height}px`);
38
+ W(() => {
39
+ if (B !== void 0 && u) {
40
+ u.style.width = "", u.style.height = "";
41
+ const e = u.getBoundingClientRect();
42
+ e.width > 0 && e.height > 0 && (r ? (v(e.width), y(e.height)) : (v(void 0), y(void 0)));
43
43
  }
44
- }, [b, i]);
45
- const m = U({
46
- initialWidth: g,
47
- initialHeight: a,
48
- maxWidth: D,
49
- maxHeight: S,
50
- minWidth: W,
51
- minHeight: $,
52
- onResize: B,
53
- maintainAspectRatio: A,
54
- onDragStart: () => w(!0),
55
- onDragEnd: () => w(!1)
56
- }), k = T(f);
57
- C(() => {
58
- z ? document.body.style.userSelect = "none" : document.body.style.userSelect = "";
59
- }, [z]);
60
- const { ref: q, ...F } = m.getRootProps(), s = m.getHandleProps, x = m.rootRef, G = (e, r) => {
61
- if (!e.current || !H) return;
62
- const { widthDiff: R } = r;
63
- e.current.style.left = `${parseInt(e.current.style.left || "0") - R}px`;
64
- }, J = (e, r) => {
65
- if (!e.current || !H) return;
66
- const { heightDiff: R } = r;
67
- e.current.style.top = `${parseInt(e.current.style.top || "0") - R}px`;
68
- }, L = d ? [
69
- h.top && /* @__PURE__ */ n(
44
+ }, [B, u, r]);
45
+ const w = Y({
46
+ initialWidth: r ? b : void 0,
47
+ initialHeight: r ? H : void 0,
48
+ maxWidth: _,
49
+ maxHeight: $,
50
+ minWidth: j,
51
+ minHeight: q,
52
+ onResize: F,
53
+ maintainAspectRatio: r,
54
+ onDragStart: () => {
55
+ if (D(!0), u) {
56
+ const e = u.getBoundingClientRect();
57
+ e.width > 0 && !b && v(e.width), e.height > 0 && !H && y(e.height);
58
+ }
59
+ },
60
+ onDragEnd: () => D(!1)
61
+ }), S = X(p);
62
+ W(() => {
63
+ P ? document.body.style.userSelect = "none" : document.body.style.userSelect = "";
64
+ }, [P]);
65
+ const { ref: L, ...M } = w.getRootProps(), d = w.getHandleProps, g = w.rootRef, C = (e, i) => {
66
+ if (!e.current || !V) return;
67
+ const { widthDiff: E } = i;
68
+ e.current.style.left = `${parseInt(e.current.style.left || "0") - E}px`;
69
+ }, k = (e, i) => {
70
+ if (!e.current || !V) return;
71
+ const { heightDiff: E } = i;
72
+ e.current.style.top = `${parseInt(e.current.style.top || "0") - E}px`;
73
+ }, O = c ? [
74
+ o.top && !r && /* @__PURE__ */ n(
70
75
  "div",
71
76
  {
72
- className: u(
77
+ className: h(
73
78
  l("resizable-resize-handle"),
74
79
  t == null ? void 0 : t.resizeHandle
75
80
  ),
76
81
  "data-placement": "top-center",
77
- ...s({
82
+ ...d({
78
83
  reverse: !0,
79
84
  lockHorizontal: !0,
80
- onResize: (e) => J(x, e)
85
+ onResize: (e) => k(g, e)
81
86
  })
82
87
  },
83
88
  "top"
84
89
  ),
85
- h.bottom && /* @__PURE__ */ n(
90
+ o.bottom && !r && /* @__PURE__ */ n(
86
91
  "div",
87
92
  {
88
- className: u(
93
+ className: h(
89
94
  l("resizable-resize-handle"),
90
95
  t == null ? void 0 : t.resizeHandle
91
96
  ),
92
97
  "data-placement": "bottom-left",
93
- ...s({
98
+ ...d({
94
99
  lockHorizontal: !0
95
100
  })
96
101
  },
97
102
  "bottom"
98
103
  ),
99
- h.left && /* @__PURE__ */ n(
104
+ o.left && !r && /* @__PURE__ */ n(
100
105
  "div",
101
106
  {
102
- className: u(
107
+ className: h(
103
108
  l("resizable-resize-handle"),
104
109
  t == null ? void 0 : t.resizeHandle
105
110
  ),
106
111
  "data-placement": "top-left",
107
- ...s({
112
+ ...d({
108
113
  reverse: !0,
109
114
  lockVertical: !0,
110
- onResize: (e) => G(x, e)
115
+ onResize: (e) => C(g, e)
111
116
  })
112
117
  },
113
118
  "left"
114
119
  ),
115
- h.right && /* @__PURE__ */ n(
120
+ o.right && !r && /* @__PURE__ */ n(
116
121
  "div",
117
122
  {
118
- className: u(
123
+ className: h(
119
124
  l("resizable-resize-handle"),
120
125
  t == null ? void 0 : t.resizeHandle
121
126
  ),
122
127
  "data-placement": "top-right",
123
- ...s({
128
+ ...d({
124
129
  lockVertical: !0
125
130
  })
126
131
  },
127
132
  "right"
133
+ ),
134
+ // For aspect ratio maintenance, add corner handles that can resize both dimensions
135
+ o.right && o.bottom && /* @__PURE__ */ n(
136
+ "div",
137
+ {
138
+ className: h(
139
+ l("resizable-resize-handle"),
140
+ t == null ? void 0 : t.resizeHandle
141
+ ),
142
+ "data-placement": "bottom-right-corner",
143
+ ...d({
144
+ // No locks - allow both horizontal and vertical resizing
145
+ })
146
+ },
147
+ "bottom-right-corner"
148
+ ),
149
+ r && o.left && o.bottom && /* @__PURE__ */ n(
150
+ "div",
151
+ {
152
+ className: h(
153
+ l("resizable-resize-handle"),
154
+ t == null ? void 0 : t.resizeHandle
155
+ ),
156
+ "data-placement": "bottom-left-corner",
157
+ ...d({
158
+ reverse: !0,
159
+ onResize: (e) => C(g, e)
160
+ })
161
+ },
162
+ "bottom-left-corner"
163
+ ),
164
+ r && o.right && o.top && /* @__PURE__ */ n(
165
+ "div",
166
+ {
167
+ className: h(
168
+ l("resizable-resize-handle"),
169
+ t == null ? void 0 : t.resizeHandle
170
+ ),
171
+ "data-placement": "top-right-corner",
172
+ ...d({
173
+ reverse: !0,
174
+ onResize: (e) => k(g, e)
175
+ })
176
+ },
177
+ "top-right-corner"
178
+ ),
179
+ o.left && o.top && /* @__PURE__ */ n(
180
+ "div",
181
+ {
182
+ className: h(
183
+ l("resizable-resize-handle"),
184
+ t == null ? void 0 : t.resizeHandle
185
+ ),
186
+ "data-placement": "top-left-corner",
187
+ ...d({
188
+ reverse: !0,
189
+ onResize: (e) => {
190
+ C(g, e), k(g, e);
191
+ }
192
+ })
193
+ },
194
+ "top-left-corner"
128
195
  )
129
- ] : [], o = f, c = {
130
- className: y(o, "className"),
131
- style: y(o, "style"),
132
- children: y(o, "children"),
133
- ref: o.ref
134
- }, M = {
135
- className: _(
136
- d && l("resizable"),
196
+ ] : [], f = p, z = {
197
+ className: x(f, "className"),
198
+ style: x(f, "style"),
199
+ children: x(f, "children"),
200
+ ref: f.ref
201
+ }, Q = {
202
+ className: s(
203
+ c && l("resizable"),
137
204
  t == null ? void 0 : t.root,
138
- c.className,
139
- E
205
+ z.className,
206
+ m
140
207
  ),
141
- ref: X(
142
- d ? q : void 0,
143
- j,
208
+ ref: Z(
209
+ c ? L : void 0,
210
+ J,
144
211
  // Always need this for dimension measurement
145
- o == null ? void 0 : o.ref
212
+ f == null ? void 0 : f.ref
146
213
  ),
147
- style: { ...c.style, ...V },
148
- ...z ? { "data-resizing": !0 } : {},
149
- children: k ? [
150
- ...Array.isArray(c.children) ? c.children : [c.children],
151
- ...L.filter(Boolean)
152
- ] : f
214
+ style: { ...z.style, ...I },
215
+ ...P ? { "data-resizing": !0 } : {},
216
+ ...c ? { "data-resizable": !0 } : {},
217
+ children: S ? [
218
+ ...Array.isArray(z.children) ? z.children : [z.children],
219
+ ...O.filter(Boolean)
220
+ ] : p
153
221
  };
154
222
  return /* @__PURE__ */ n(
155
- K,
223
+ a,
156
224
  {
157
225
  render: (e) => {
158
- const r = Y(
226
+ const i = K(
159
227
  e,
160
- M,
161
- d ? F : {}
228
+ Q,
229
+ c ? M : {}
162
230
  );
163
- return k ? O.cloneElement(o, r) : /* @__PURE__ */ n("div", { ...r, children: f });
231
+ return S ? T.cloneElement(f, i) : /* @__PURE__ */ n("div", { ...i, children: p });
164
232
  }
165
233
  }
166
234
  );
167
235
  };
168
236
  export {
169
- he as Resizable
237
+ ue as Resizable
170
238
  };
171
239
  //# sourceMappingURL=component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sources":["../../../src/components/resizable/component.tsx"],"sourcesContent":["\"use client\";\nimport React, { useCallback, useEffect, useState, isValidElement } from \"react\";\nimport { useResizable, type MoveValues } from \"react-use-resizable\";\nimport mergeRefs from \"merge-refs\";\nimport {\n useCls,\n clsx,\n WithRenderProp,\n WithRenderPropProps,\n cn,\n getReactElementProp,\n} from \"../utils\";\nimport { mergeProps } from \"@base-ui-components/react\";\n\nimport \"./style.css\";\n\nexport interface ResizableProps extends WithRenderPropProps {\n /**\n * Single React element child that will be enhanced with resize handles\n */\n children: React.ReactNode;\n /**\n * Whether the component should be resizable\n * @default false\n */\n resizable?: boolean;\n /**\n * Configure which resize handles to show\n * @default { bottom: true, right: true, left: true, top: true }\n */\n handles?: {\n bottom?: boolean;\n right?: boolean;\n left?: boolean;\n top?: boolean;\n };\n /**\n * Whether to use absolute positioning for left handle resizing\n * Set to true when used in absolutely positioned containers like PopupPanel\n * @default false\n */\n absolutePositioning?: boolean;\n /**\n * Custom class names for different parts of the resizable component\n */\n classNames?: {\n root?: string;\n resizeHandle?: string;\n };\n /**\n * Key to reset dimensions to current element size\n * When this value changes, the component will recalculate its dimensions\n * Similar to React's key prop pattern for forcing component resets\n */\n resetKey?: React.Key;\n /**\n * Maximum width the component can be resized to\n */\n maxWidth?: number;\n /**\n * Maximum height the component can be resized to\n */\n maxHeight?: number;\n /**\n * Minimum width the component can be resized to\n */\n minWidth?: number;\n /**\n * Minimum height the component can be resized to\n */\n minHeight?: number;\n /**\n * Callback fired during resize operations\n */\n onResize?: (values: MoveValues) => void;\n /**\n * Whether to maintain aspect ratio during resize\n * @default false\n */\n maintainAspectRatio?: boolean;\n}\n\nexport const Resizable = ({\n children,\n resizable = false,\n handles = { bottom: true, right: true, left: true, top: true },\n absolutePositioning = false,\n classNames,\n className: containerClassName,\n style: containerStyle,\n resetKey,\n maxWidth,\n maxHeight,\n minWidth,\n minHeight,\n onResize,\n maintainAspectRatio = false,\n ...rest\n}: ResizableProps) => {\n // Validate that children is a single React element\n // if (!isValidElement(children)) {\n // throw new Error(\n // \"Resizable component expects a single React element as children\"\n // );\n // }\n\n const cls = useCls();\n const [panelRef, setPanelRef] = useState<HTMLDivElement | null>(null);\n const [width, setWidth] = useState<number>();\n const [height, setHeight] = useState<number>();\n const [resizing, setResizing] = useState(false);\n\n const callbackRef = useCallback(\n (node: HTMLDivElement) => {\n setPanelRef(node);\n\n // Get initial dimensions only once when ref is set\n if (node && !width && !height) {\n const rect = node.getBoundingClientRect();\n if (rect.width > 0 && rect.height > 0) {\n setWidth(rect.width);\n setHeight(rect.height);\n }\n }\n },\n [width, height]\n );\n\n // Reset dimensions when resetKey changes\n useEffect(() => {\n if (resetKey !== undefined && panelRef) {\n // Clear the hook's inline styles to reset to natural size\n panelRef.style.width = \"\";\n panelRef.style.height = \"\";\n\n // Force a reflow to get natural dimensions\n const rect = panelRef.getBoundingClientRect();\n\n if (rect.width > 0 && rect.height > 0) {\n // Update the component state to match the reset dimensions\n setWidth(rect.width);\n setHeight(rect.height);\n\n // Apply the reset dimensions directly to ensure they stick\n panelRef.style.width = `${rect.width}px`;\n panelRef.style.height = `${rect.height}px`;\n }\n }\n }, [resetKey, panelRef]);\n\n // Initialize useResizable with current dimensions (or undefined if not ready)\n const resizableHook = useResizable({\n initialWidth: width,\n initialHeight: height,\n maxWidth,\n maxHeight,\n minWidth,\n minHeight,\n onResize,\n maintainAspectRatio,\n onDragStart: () => setResizing(true),\n onDragEnd: () => setResizing(false),\n });\n\n const isChildrenValidElement = isValidElement(children);\n\n useEffect(() => {\n if (resizing) {\n document.body.style.userSelect = \"none\";\n } else {\n document.body.style.userSelect = \"\";\n }\n }, [resizing]);\n\n // Get resizable props - useResizable hook handles cases where dimensions aren't ready\n const { ref: rootRefProp, ...rootPropsWithoutRef } =\n resizableHook.getRootProps();\n const getHandleProps = resizableHook.getHandleProps;\n const rootRef = resizableHook.rootRef;\n\n // Handle reverse handle change for horizontal resizing (only for absolute positioning)\n const onReverseHandleChangeHorizontal = (\n parent: React.RefObject<HTMLDivElement>,\n values: MoveValues\n ) => {\n if (!parent.current || !absolutePositioning) return;\n const { widthDiff } = values;\n parent.current.style.left = `${\n parseInt(parent.current.style.left || \"0\") - widthDiff\n }px`;\n };\n\n // Handle reverse handle change for vertical resizing (only for absolute positioning)\n const onReverseHandleChangeVertical = (\n parent: React.RefObject<HTMLDivElement>,\n values: MoveValues\n ) => {\n if (!parent.current || !absolutePositioning) return;\n const { heightDiff } = values;\n parent.current.style.top = `${\n parseInt(parent.current.style.top || \"0\") - heightDiff\n }px`;\n };\n\n const resizeHandles = resizable\n ? [\n handles.top && (\n <div\n key=\"top\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-center\"\n {...getHandleProps({\n reverse: true,\n lockHorizontal: true,\n onResize: (values) =>\n onReverseHandleChangeVertical(rootRef, values),\n })}\n />\n ),\n handles.bottom && (\n <div\n key=\"bottom\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"bottom-left\"\n {...getHandleProps({\n lockHorizontal: true,\n })}\n />\n ),\n handles.left && (\n <div\n key=\"left\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-left\"\n {...getHandleProps({\n reverse: true,\n lockVertical: true,\n onResize: (values) =>\n onReverseHandleChangeHorizontal(rootRef, values),\n })}\n />\n ),\n handles.right && (\n <div\n key=\"right\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-right\"\n {...getHandleProps({\n lockVertical: true,\n })}\n />\n ),\n ]\n : [];\n\n const childElement = children as React.ReactElement & {\n ref?: React.Ref<HTMLDivElement>;\n };\n\n const childElementProps = {\n className: getReactElementProp<string>(childElement, \"className\"),\n style: getReactElementProp<React.CSSProperties>(childElement, \"style\"),\n children: getReactElementProp<React.ReactNode>(childElement, \"children\"),\n ref: childElement.ref,\n };\n\n const childProps = {\n className: cn(\n resizable && cls(\"resizable\"),\n classNames?.root,\n childElementProps.className,\n containerClassName\n ),\n ref: mergeRefs(\n resizable ? rootRefProp : undefined,\n callbackRef, // Always need this for dimension measurement\n childElement?.ref\n ),\n style: { ...childElementProps.style, ...containerStyle },\n ...(resizing ? { \"data-resizing\": true } : {}),\n children: isChildrenValidElement\n ? [\n ...(Array.isArray(childElementProps.children)\n ? childElementProps.children\n : [childElementProps.children]),\n ...resizeHandles.filter(Boolean),\n ]\n : children,\n };\n\n return (\n <WithRenderProp\n render={(props) => {\n // Merge the props from WithRenderProp with our childProps\n const mergedProps = mergeProps(\n props,\n childProps,\n resizable ? rootPropsWithoutRef : {}\n );\n if (isChildrenValidElement) {\n return React.cloneElement(childElement, mergedProps);\n } else {\n return <div {...mergedProps}>{children}</div>;\n }\n }}\n />\n );\n};\n"],"names":["Resizable","children","resizable","handles","absolutePositioning","classNames","containerClassName","containerStyle","resetKey","maxWidth","maxHeight","minWidth","minHeight","onResize","maintainAspectRatio","rest","cls","useCls","panelRef","setPanelRef","useState","width","setWidth","height","setHeight","resizing","setResizing","callbackRef","useCallback","node","rect","useEffect","resizableHook","useResizable","isChildrenValidElement","isValidElement","rootRefProp","rootPropsWithoutRef","getHandleProps","rootRef","onReverseHandleChangeHorizontal","parent","values","widthDiff","onReverseHandleChangeVertical","heightDiff","resizeHandles","jsx","clsx","childElement","childElementProps","getReactElementProp","childProps","cn","mergeRefs","WithRenderProp","props","mergedProps","mergeProps","React"],"mappings":";;;;;;;;;;;AAkFO,MAAMA,KAAY,CAAC;AAAA,EACxB,UAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,SAAAC,IAAU,EAAE,QAAQ,IAAM,OAAO,IAAM,MAAM,IAAM,KAAK,GAAK;AAAA,EAC7D,qBAAAC,IAAsB;AAAA,EACtB,YAAAC;AAAA,EACA,WAAWC;AAAA,EACX,OAAOC;AAAA,EACP,UAAAC;AAAA,EACA,U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AAAA,EAAc;AAAA,IAChB;AAAA,IACA,OAAO,EAAE,GAAGC,EAAkB,OAAO,GAAG3C,EAAe;AAAA,IACvD,GAAIkB,IAAW,EAAE,iBAAiB,OAAS,CAAC;AAAA,IAC5C,UAAUS,IACN;AAAA,MACE,GAAI,MAAM,QAAQgB,EAAkB,QAAQ,IACxCA,EAAkB,WAClB,CAACA,EAAkB,QAAQ;AAAA,MAC/B,GAAGJ,EAAc,OAAO,OAAO;AAAA,IAAA,IAEjC7C;AAAA,EACN;AAGE,SAAA,gBAAA8C;AAAA,IAACQ;AAAA,IAAA;AAAA,MACC,QAAQ,CAACC,MAAU;AAEjB,cAAMC,IAAcC;AAAA,UAClBF;AAAA,UACAJ;AAAA,UACAlD,IAAYmC,IAAsB,CAAA;AAAA,QACpC;AACA,eAAIH,IACKyB,EAAM,aAAaV,GAAcQ,CAAW,IAE3C,gBAAAV,EAAA,OAAA,EAAK,GAAGU,GAAc,UAAAxD,EAAS,CAAA;AAAA,MACzC;AAAA,IACF;AAAA,EACF;AAEJ;"}
1
+ {"version":3,"file":"component.js","sources":["../../../src/components/resizable/component.tsx"],"sourcesContent":["\"use client\";\nimport React, { useCallback, useEffect, useState, isValidElement } from \"react\";\nimport { useResizable, type MoveValues } from \"react-use-resizable\";\nimport mergeRefs from \"merge-refs\";\nimport {\n useCls,\n clsx,\n WithRenderProp,\n WithRenderPropProps,\n cn,\n getReactElementProp,\n} from \"../utils\";\nimport { mergeProps } from \"@base-ui-components/react\";\n\nimport \"./style.css\";\n\nexport interface ResizableProps extends WithRenderPropProps {\n /**\n * Single React element child that will be enhanced with resize handles\n */\n children: React.ReactNode;\n /**\n * Whether the component should be resizable\n * @default false\n */\n resizable?: boolean;\n /**\n * Configure which resize handles to show\n * @default { bottom: true, right: true, left: true, top: true }\n */\n handles?: {\n bottom?: boolean;\n right?: boolean;\n left?: boolean;\n top?: boolean;\n };\n /**\n * Whether to use absolute positioning for left handle resizing\n * Set to true when used in absolutely positioned containers like PopupPanel\n * @default false\n */\n absolutePositioning?: boolean;\n /**\n * Custom class names for different parts of the resizable component\n */\n classNames?: {\n root?: string;\n resizeHandle?: string;\n };\n /**\n * Key to reset dimensions to current element size\n * When this value changes, the component will recalculate its dimensions\n * Similar to React's key prop pattern for forcing component resets\n */\n resetKey?: React.Key;\n /**\n * Maximum width the component can be resized to\n */\n maxWidth?: number;\n /**\n * Maximum height the component can be resized to\n */\n maxHeight?: number;\n /**\n * Minimum width the component can be resized to\n */\n minWidth?: number;\n /**\n * Minimum height the component can be resized to\n */\n minHeight?: number;\n /**\n * Callback fired during resize operations\n */\n onResize?: (values: MoveValues) => void;\n /**\n * Whether to maintain aspect ratio during resize\n * @default false\n */\n maintainAspectRatio?: boolean;\n}\n\nexport const Resizable = ({\n children,\n resizable = false,\n handles = { bottom: true, right: true, left: true, top: true },\n absolutePositioning = false,\n classNames,\n className: containerClassName,\n style: containerStyle,\n resetKey,\n maxWidth,\n maxHeight,\n minWidth,\n minHeight,\n onResize,\n maintainAspectRatio = false,\n ...rest\n}: ResizableProps) => {\n // Validate that children is a single React element\n // if (!isValidElement(children)) {\n // throw new Error(\n // \"Resizable component expects a single React element as children\"\n // );\n // }\n\n const cls = useCls();\n const [panelRef, setPanelRef] = useState<HTMLDivElement | null>(null);\n const [width, setWidth] = useState<number>();\n const [height, setHeight] = useState<number>();\n const [resizing, setResizing] = useState(false);\n\n const callbackRef = useCallback(\n (node: HTMLDivElement) => {\n setPanelRef(node);\n\n // Get initial dimensions only once when ref is set\n // For aspect ratio maintenance, we need initial dimensions immediately\n // Otherwise, preserve natural width/height behavior\n if (node && !width && !height) {\n const rect = node.getBoundingClientRect();\n if (rect.width > 0 && rect.height > 0) {\n if (maintainAspectRatio) {\n // Need dimensions for aspect ratio calculation\n setWidth(rect.width);\n setHeight(rect.height);\n }\n // For non-aspect-ratio cases, don't set dimensions to preserve natural behavior\n }\n }\n },\n [width, height, maintainAspectRatio]\n );\n\n // Reset dimensions when resetKey changes\n useEffect(() => {\n if (resetKey !== undefined && panelRef) {\n // Clear the hook's inline styles to reset to natural size\n panelRef.style.width = \"\";\n panelRef.style.height = \"\";\n\n // Force a reflow to get natural dimensions\n const rect = panelRef.getBoundingClientRect();\n\n if (rect.width > 0 && rect.height > 0) {\n if (maintainAspectRatio) {\n // For aspect ratio maintenance, re-measure and set dimensions\n setWidth(rect.width);\n setHeight(rect.height);\n } else {\n // Reset state to allow natural dimensions again\n setWidth(undefined);\n setHeight(undefined);\n }\n\n // Don't apply any explicit dimensions - let them remain natural\n // panelRef.style.width = `${rect.width}px`;\n // panelRef.style.height = `${rect.height}px`;\n }\n }\n }, [resetKey, panelRef, maintainAspectRatio]);\n\n // Initialize useResizable with current dimensions (or undefined if not ready)\n // For aspect ratio maintenance, we need initial dimensions\n // Otherwise, preserve natural width/height behavior until user starts resizing\n const resizableHook = useResizable({\n initialWidth: maintainAspectRatio ? width : undefined,\n initialHeight: maintainAspectRatio ? height : undefined,\n maxWidth,\n maxHeight,\n minWidth,\n minHeight,\n onResize,\n maintainAspectRatio,\n onDragStart: () => {\n setResizing(true);\n // Capture natural dimensions when user starts resizing\n if (panelRef) {\n const rect = panelRef.getBoundingClientRect();\n if (rect.width > 0 && !width) {\n setWidth(rect.width);\n }\n if (rect.height > 0 && !height) {\n setHeight(rect.height);\n }\n }\n },\n onDragEnd: () => setResizing(false),\n });\n\n const isChildrenValidElement = isValidElement(children);\n\n useEffect(() => {\n if (resizing) {\n document.body.style.userSelect = \"none\";\n } else {\n document.body.style.userSelect = \"\";\n }\n }, [resizing]);\n\n // Get resizable props - useResizable hook handles cases where dimensions aren't ready\n const { ref: rootRefProp, ...rootPropsWithoutRef } =\n resizableHook.getRootProps();\n const getHandleProps = resizableHook.getHandleProps;\n const rootRef = resizableHook.rootRef;\n\n // Handle reverse handle change for horizontal resizing (only for absolute positioning)\n const onReverseHandleChangeHorizontal = (\n parent: React.RefObject<HTMLDivElement>,\n values: MoveValues\n ) => {\n if (!parent.current || !absolutePositioning) return;\n const { widthDiff } = values;\n parent.current.style.left = `${\n parseInt(parent.current.style.left || \"0\") - widthDiff\n }px`;\n };\n\n // Handle reverse handle change for vertical resizing (only for absolute positioning)\n const onReverseHandleChangeVertical = (\n parent: React.RefObject<HTMLDivElement>,\n values: MoveValues\n ) => {\n if (!parent.current || !absolutePositioning) return;\n const { heightDiff } = values;\n parent.current.style.top = `${\n parseInt(parent.current.style.top || \"0\") - heightDiff\n }px`;\n };\n\n const resizeHandles = resizable\n ? [\n handles.top && !maintainAspectRatio && (\n <div\n key=\"top\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-center\"\n {...getHandleProps({\n reverse: true,\n lockHorizontal: true,\n onResize: (values) =>\n onReverseHandleChangeVertical(rootRef, values),\n })}\n />\n ),\n handles.bottom && !maintainAspectRatio && (\n <div\n key=\"bottom\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"bottom-left\"\n {...getHandleProps({\n lockHorizontal: true,\n })}\n />\n ),\n handles.left && !maintainAspectRatio && (\n <div\n key=\"left\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-left\"\n {...getHandleProps({\n reverse: true,\n lockVertical: true,\n onResize: (values) =>\n onReverseHandleChangeHorizontal(rootRef, values),\n })}\n />\n ),\n handles.right && !maintainAspectRatio && (\n <div\n key=\"right\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-right\"\n {...getHandleProps({\n lockVertical: true,\n })}\n />\n ),\n // For aspect ratio maintenance, add corner handles that can resize both dimensions\n handles.right && handles.bottom && (\n <div\n key=\"bottom-right-corner\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"bottom-right-corner\"\n {...getHandleProps({\n // No locks - allow both horizontal and vertical resizing\n })}\n />\n ),\n maintainAspectRatio && handles.left && handles.bottom && (\n <div\n key=\"bottom-left-corner\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"bottom-left-corner\"\n {...getHandleProps({\n reverse: true,\n onResize: (values) =>\n onReverseHandleChangeHorizontal(rootRef, values),\n })}\n />\n ),\n maintainAspectRatio && handles.right && handles.top && (\n <div\n key=\"top-right-corner\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-right-corner\"\n {...getHandleProps({\n reverse: true,\n onResize: (values) =>\n onReverseHandleChangeVertical(rootRef, values),\n })}\n />\n ),\n handles.left && handles.top && (\n <div\n key=\"top-left-corner\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-left-corner\"\n {...getHandleProps({\n reverse: true,\n onResize: (values) => {\n onReverseHandleChangeHorizontal(rootRef, values);\n onReverseHandleChangeVertical(rootRef, values);\n },\n })}\n />\n ),\n ]\n : [];\n\n const childElement = children as React.ReactElement & {\n ref?: React.Ref<HTMLDivElement>;\n };\n\n const childElementProps = {\n className: getReactElementProp<string>(childElement, \"className\"),\n style: getReactElementProp<React.CSSProperties>(childElement, \"style\"),\n children: getReactElementProp<React.ReactNode>(childElement, \"children\"),\n ref: childElement.ref,\n };\n\n const childProps = {\n className: cn(\n resizable && cls(\"resizable\"),\n classNames?.root,\n childElementProps.className,\n containerClassName\n ),\n ref: mergeRefs(\n resizable ? rootRefProp : undefined,\n callbackRef, // Always need this for dimension measurement\n childElement?.ref\n ),\n style: { ...childElementProps.style, ...containerStyle },\n ...(resizing ? { \"data-resizing\": true } : {}),\n ...(resizable ? { \"data-resizable\": true } : {}),\n children: isChildrenValidElement\n ? [\n ...(Array.isArray(childElementProps.children)\n ? childElementProps.children\n : [childElementProps.children]),\n ...resizeHandles.filter(Boolean),\n ]\n : children,\n };\n\n return (\n <WithRenderProp\n render={(props) => {\n // Merge the props from WithRenderProp with our childProps\n const mergedProps = mergeProps(\n props,\n childProps,\n resizable ? rootPropsWithoutRef : {}\n );\n if (isChildrenValidElement) {\n return React.cloneElement(childElement, mergedProps);\n } else {\n return <div {...mergedProps}>{children}</div>;\n }\n }}\n />\n );\n};\n"],"names":["Resizable","children","resizable","handles","absolutePositioning","classNames","containerClassName","containerStyle","resetKey","maxWidth","maxHeight","minWidth","minHeight","onResize","maintainAspectRatio","rest","cls","useCls","panelRef","setPanelRef","useState","width","setWidth","height","setHeight","resizing","setResizing","callbackRef","useCallback","node","rect","useEffect","resizableHook","useResizable","isChildrenValidElement","isValidElement","rootRefProp","rootPropsWithoutRef","getHandleProps","rootRef","onReverseHandleChangeHorizontal","parent","values","widthDiff","onReverseHandleChangeVertical","heightDiff","resizeHandles","jsx","clsx","childElement","childElementProps","getReactElementProp","childProps","cn","mergeRefs","WithRenderProp","props","mergedProps","mergeProps","React"],"mappings":";;;;;;;;;;;AAkFO,MAAMA,KAAY,CAAC;AAAA,EACxB,UAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,SAAAC,IAAU,EAAE,QAAQ,IAAM,OAAO,IAAM,MAAM,IAAM,KAAK,GAAK;AAAA,EAC7D,qBAAAC,IAAsB;AAAA,EACtB,YAAAC;AAAA,EACA,WAAWC;AAAA,EACX,OAAOC;AAAA,EACP,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,qBAAAC,IAAsB;AAAA,EACtB,GAAGC;AACL,MAAsB;AAQpB,QAAMC,IAAMC,EAAO,GACb,CAACC,GAAUC,CAAW,IAAIC,EAAgC,IAAI,GAC9D,CAACC,GAAOC,CAAQ,IAAIF,EAAiB,GACrC,CAACG,GAAQC,CAAS,IAAIJ,EAAiB,GACvC,CAACK,GAAUC,CAAW,IAAIN,EAAS,EAAK,GAExCO,IAAcC;AAAA,IAClB,CAACC,MAAyB;AAMxB,UALAV,EAAYU,CAAI,GAKZ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c;AAAA,IAChB;AAAA,IACA,OAAO,EAAE,GAAGC,EAAkB,OAAO,GAAG3C,EAAe;AAAA,IACvD,GAAIkB,IAAW,EAAE,iBAAiB,OAAS,CAAC;AAAA,IAC5C,GAAIvB,IAAY,EAAE,kBAAkB,OAAS,CAAC;AAAA,IAC9C,UAAUgC,IACN;AAAA,MACE,GAAI,MAAM,QAAQgB,EAAkB,QAAQ,IACxCA,EAAkB,WAClB,CAACA,EAAkB,QAAQ;AAAA,MAC/B,GAAGJ,EAAc,OAAO,OAAO;AAAA,IAAA,IAEjC7C;AAAA,EACN;AAGE,SAAA,gBAAA8C;AAAA,IAACQ;AAAA,IAAA;AAAA,MACC,QAAQ,CAACC,MAAU;AAEjB,cAAMC,IAAcC;AAAA,UAClBF;AAAA,UACAJ;AAAA,UACAlD,IAAYmC,IAAsB,CAAA;AAAA,QACpC;AACA,eAAIH,IACKyB,EAAM,aAAaV,GAAcQ,CAAW,IAE3C,gBAAAV,EAAA,OAAA,EAAK,GAAGU,GAAc,UAAAxD,EAAS,CAAA;AAAA,MACzC;AAAA,IACF;AAAA,EACF;AAEJ;"}
@@ -1 +1 @@
1
- @layer components{.ds-resizable{position:relative}.ds-resizable-resize-handle{position:absolute;padding:.5rem;color:#fff;display:block}.ds-resizable-resize-handle[data-placement=top-left]{left:0;top:0;width:4px;height:100%;border-top-left-radius:.5rem;border-bottom-left-radius:.5rem;align-items:center}.ds-resizable-resize-handle[data-placement=top-right]{right:0;top:0;width:4px;height:100%;border-top-right-radius:.5rem;border-bottom-right-radius:.5rem;align-items:center}.ds-resizable-resize-handle[data-placement=bottom-left]{bottom:0;width:100%;height:4px;border-bottom-left-radius:.5rem;border-bottom-right-radius:.5rem;justify-content:center}.ds-resizable-resize-handle[data-placement=top-center]{top:0;width:100%;height:4px;border-top-left-radius:.5rem;border-top-right-radius:.5rem;justify-content:center}}
1
+ @layer components{.ds-resizable{position:relative}.ds-resizable-resize-handle{position:absolute;padding:.5rem;color:#fff;display:block}.ds-resizable-resize-handle[data-placement=top-left]{left:0;top:0;width:4px;height:100%;border-top-left-radius:.5rem;border-bottom-left-radius:.5rem;align-items:center}.ds-resizable-resize-handle[data-placement=top-right]{right:0;top:0;width:4px;height:100%;border-top-right-radius:.5rem;border-bottom-right-radius:.5rem;align-items:center}.ds-resizable-resize-handle[data-placement=bottom-left]{bottom:0;width:100%;height:4px;border-bottom-left-radius:.5rem;border-bottom-right-radius:.5rem;justify-content:center}.ds-resizable-resize-handle[data-placement=top-center]{top:0;width:100%;height:4px;border-top-left-radius:.5rem;border-top-right-radius:.5rem;justify-content:center}.ds-resizable-resize-handle[data-placement=bottom-right-corner]{bottom:0;right:0;width:12px;height:12px;border-bottom-right-radius:.5rem;cursor:nw-resize}.ds-resizable-resize-handle[data-placement=bottom-left-corner]{bottom:0;left:0;width:12px;height:12px;border-bottom-left-radius:.5rem;cursor:ne-resize}.ds-resizable-resize-handle[data-placement=top-right-corner]{top:0;right:0;width:12px;height:12px;border-top-right-radius:.5rem;cursor:ne-resize}.ds-resizable-resize-handle[data-placement=top-left-corner]{top:0;left:0;width:12px;height:12px;border-top-left-radius:.5rem;cursor:nw-resize}}
@@ -1,34 +1,80 @@
1
1
  "use client";
2
- import { jsxs as p, jsx as e } from "react/jsx-runtime";
3
- import { ScrollArea as t } from "@base-ui-components/react";
2
+ import { jsxs as x, jsx as f } from "react/jsx-runtime";
3
+ import { useRef as y, useState as R, useEffect as T } from "react";
4
+ import { ScrollArea as S } from "@base-ui-components/react";
4
5
  import './style.css';/* empty css */
5
- import { useCls as b } from "../utils/antdUtils.js";
6
- import { clsx as l } from "../utils/cn.js";
7
- const S = ({
8
- children: c,
9
- className: n,
10
- classNames: r = {},
11
- orientation: i = "vertical"
6
+ import { useCls as E } from "../utils/antdUtils.js";
7
+ import { clsx as b } from "../utils/cn.js";
8
+ const I = ({
9
+ children: m,
10
+ className: w,
11
+ classNames: o = {},
12
+ orientation: t = "vertical",
13
+ fadeEdges: e = !1,
14
+ onScroll: h
12
15
  }) => {
13
- const o = b();
14
- return /* @__PURE__ */ p(t.Root, { className: l(o("scroll-area"), n), children: [
15
- /* @__PURE__ */ e(
16
- t.Viewport,
16
+ const l = E(), u = y(null), [r, v] = R({
17
+ isAtStart: !0,
18
+ isAtEnd: !1,
19
+ isScrollable: !1
20
+ });
21
+ return T(() => {
22
+ if (!u.current) return;
23
+ const c = u.current, i = (d) => {
24
+ if (d && h && h(d), e)
25
+ if (t === "vertical") {
26
+ const { scrollTop: s, scrollHeight: a, clientHeight: n } = c, A = a > n;
27
+ v({
28
+ isAtStart: s <= 1,
29
+ isAtEnd: s >= a - n - 1,
30
+ isScrollable: A
31
+ });
32
+ } else {
33
+ const { scrollLeft: s, scrollWidth: a, clientWidth: n } = c, A = a > n + 2;
34
+ v({
35
+ isAtStart: s <= 1,
36
+ isAtEnd: s >= a - n - 1,
37
+ isScrollable: A
38
+ });
39
+ }
40
+ };
41
+ i();
42
+ const z = setTimeout(i, 0);
43
+ c.addEventListener("scroll", i);
44
+ const p = new ResizeObserver(() => {
45
+ i();
46
+ });
47
+ return p.observe(c), () => {
48
+ clearTimeout(z), c.removeEventListener("scroll", i), p.disconnect();
49
+ };
50
+ }, [e, t, h]), /* @__PURE__ */ x(S.Root, { className: b(l("scroll-area"), w), children: [
51
+ /* @__PURE__ */ f(
52
+ S.Viewport,
17
53
  {
18
- className: l(o("scroll-area-viewport"), r == null ? void 0 : r.viewport),
19
- children: /* @__PURE__ */ e(t.Content, { className: l(o("scroll-area-content")), children: c })
54
+ ref: u,
55
+ className: b(
56
+ l("scroll-area-viewport"),
57
+ e && r.isScrollable && t === "vertical" && r.isAtStart && l("scroll-area-fade-bottom-only"),
58
+ e && r.isScrollable && t === "vertical" && r.isAtEnd && l("scroll-area-fade-top-only"),
59
+ e && r.isScrollable && t === "vertical" && !r.isAtStart && !r.isAtEnd && l("scroll-area-fade-both-vertical"),
60
+ e && r.isScrollable && t === "horizontal" && r.isAtStart && l("scroll-area-fade-right-only"),
61
+ e && r.isScrollable && t === "horizontal" && r.isAtEnd && l("scroll-area-fade-left-only"),
62
+ e && r.isScrollable && t === "horizontal" && !r.isAtStart && !r.isAtEnd && l("scroll-area-fade-both-horizontal"),
63
+ o == null ? void 0 : o.viewport
64
+ ),
65
+ children: /* @__PURE__ */ f(S.Content, { className: b(l("scroll-area-content")), children: m })
20
66
  }
21
67
  ),
22
- /* @__PURE__ */ e(
23
- t.Scrollbar,
68
+ /* @__PURE__ */ f(
69
+ S.Scrollbar,
24
70
  {
25
- className: l(o("scroll-area-scrollbar"), r == null ? void 0 : r.scrollbar),
26
- orientation: i,
27
- "data-orientation": i,
28
- children: /* @__PURE__ */ e(
29
- t.Thumb,
71
+ className: b(l("scroll-area-scrollbar"), o == null ? void 0 : o.scrollbar),
72
+ orientation: t,
73
+ "data-orientation": t,
74
+ children: /* @__PURE__ */ f(
75
+ S.Thumb,
30
76
  {
31
- className: l(o("scroll-area-thumb"), r == null ? void 0 : r.thumb)
77
+ className: b(l("scroll-area-thumb"), o == null ? void 0 : o.thumb)
32
78
  }
33
79
  )
34
80
  }
@@ -36,6 +82,6 @@ const S = ({
36
82
  ] });
37
83
  };
38
84
  export {
39
- S as ScrollArea
85
+ I as ScrollArea
40
86
  };
41
87
  //# sourceMappingURL=component.js.map