{"version":3,"file":"Separator.cjs","names":[],"sources":["../../../src/components/Separator/Separator.tsx"],"sourcesContent":["/*\nCopyright 2023, 2024 New Vector Ltd.\n\nSPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial\nPlease see LICENSE files in the repository root for full details.\n*/\n\nimport classnames from \"classnames\";\nimport * as RadixSeparator from \"@radix-ui/react-separator\";\nimport React, {\n  type ComponentProps,\n  type PropsWithoutRef,\n  type Ref,\n  forwardRef,\n  useEffect,\n  useRef,\n} from \"react\";\nimport styles from \"./Separator.module.css\";\nimport { useMergeRefs } from \"@floating-ui/react\";\n\ntype SeparatorProps = {\n  /**\n   * The CSS class name.\n   */\n  className?: string;\n  /**\n   * The spacing on either side of the separator.\n   * @default var(--cpd-space-2x)\n   */\n  spacing?: string;\n  /**\n   * The style of separator.\n   * @default primary\n   */\n  kind?: \"primary\" | \"secondary\" | \"section\";\n} & ComponentProps<typeof RadixSeparator.Root>;\n\nconst SPACING_CUSTOM_PROP = \"--cpd-separator-spacing\";\n\n/**\n * A separator component.\n */\nexport const Separator = forwardRef(\n  (\n    {\n      className,\n      spacing, // Default provided via global.css\n      kind = \"primary\",\n      ...props\n    }: PropsWithoutRef<SeparatorProps>,\n    theirRef?: Ref<HTMLDivElement>,\n  ) => {\n    const classes = classnames(styles.separator, className);\n    const ourRef = useRef<HTMLDivElement | null>(null);\n    const ref = useMergeRefs([ourRef, theirRef]);\n\n    useEffect(() => {\n      const style = ourRef.current?.style;\n      if (spacing) {\n        style?.setProperty(SPACING_CUSTOM_PROP, spacing);\n      } else {\n        style?.removeProperty(SPACING_CUSTOM_PROP);\n      }\n    }, [spacing]);\n\n    return (\n      <RadixSeparator.Root\n        {...props}\n        className={classes}\n        ref={ref}\n        data-kind={kind}\n      />\n    );\n  },\n);\n\nSeparator.displayName = \"Separator\";\n"],"mappings":";;;;;;;;;;;AAqCA,IAAM,sBAAsB;;;;AAK5B,IAAa,aAAA,GAAA,MAAA,aAET,EACE,WACA,SACA,OAAO,WACP,GAAG,SAEL,aACG;CACH,MAAM,WAAA,GAAA,WAAA,SAAqB,yBAAA,QAAO,WAAW,UAAU;CACvD,MAAM,UAAA,GAAA,MAAA,QAAuC,KAAK;CAClD,MAAM,OAAA,GAAA,mBAAA,cAAmB,CAAC,QAAQ,SAAS,CAAC;AAE5C,EAAA,GAAA,MAAA,iBAAgB;EACd,MAAM,QAAQ,OAAO,SAAS;AAC9B,MAAI,QACF,QAAO,YAAY,qBAAqB,QAAQ;MAEhD,QAAO,eAAe,oBAAoB;IAE3C,CAAC,QAAQ,CAAC;AAEb,QACE,iBAAA,GAAA,kBAAA,KAAC,0BAAe,MAAhB;EACE,GAAI;EACJ,WAAW;EACN;EACL,aAAW;EACX,CAAA;EAGP;AAED,UAAU,cAAc"}