{"version":3,"sources":["../src/button-group.tsx"],"sourcesContent":["import type {\n  CSSUIObject,\n  CSSUIProps,\n  HTMLUIProps,\n  ThemeProps,\n} from \"@yamada-ui/core\"\nimport { forwardRef, ui } from \"@yamada-ui/core\"\nimport { createContext, cx, dataAttr } from \"@yamada-ui/utils\"\nimport { useMemo } from \"react\"\n\ninterface ButtonGroupOptions {\n  /**\n   * If `true`, the borderRadius of button that are direct children will be altered to look flushed together.\n   *\n   * @default false\n   */\n  attached?: boolean\n  /**\n   * The CSS `flex-direction` property.\n   *\n   * @deprecated Use `flexDirection` instead.\n   */\n  direction?: CSSUIProps[\"flexDirection\"]\n  /**\n   * If `true`, all wrapped button will be disabled.\n   *\n   * @default false\n   */\n  disabled?: boolean\n  /**\n   * If `true`, the borderRadius of button that are direct children will be altered to look flushed together.\n   *\n   * @default false\n   *\n   * @deprecated Use `attached` instead.\n   */\n  isAttached?: boolean\n  /**\n   * If `true`, all wrapped button will be disabled.\n   *\n   * @default false\n   *\n   * @deprecated Use `disabled` instead.\n   */\n  isDisabled?: boolean\n}\n\nexport interface ButtonGroupProps\n  extends Omit<HTMLUIProps, \"direction\">,\n    ThemeProps<\"Button\">,\n    ButtonGroupOptions {}\n\ninterface ButtonGroupContext extends ThemeProps<\"Button\"> {\n  disabled?: boolean\n}\n\nconst [ButtonGroupProvider, useButtonGroup] = createContext<ButtonGroupContext>(\n  {\n    name: \"ButtonGroupContext\",\n    strict: false,\n  },\n)\n\nexport { useButtonGroup }\n\nexport const ButtonGroup = forwardRef<ButtonGroupProps, \"div\">(\n  (\n    {\n      className,\n      size,\n      variant,\n      isAttached,\n      attached = isAttached,\n      columnGap,\n      direction,\n      isDisabled,\n      disabled = isDisabled,\n      flexDirection = direction,\n      gap,\n      rowGap,\n      ...rest\n    },\n    ref,\n  ) => {\n    const column =\n      flexDirection === \"column\" || flexDirection === \"column-reverse\"\n\n    const css: CSSUIObject = {\n      display: \"inline-flex\",\n      flexDirection,\n    }\n\n    const context: ButtonGroupContext = useMemo(\n      () => ({ size, variant, disabled }),\n      [size, variant, disabled],\n    )\n\n    if (attached) {\n      Object.assign(css, {\n        \"> *:first-of-type:not(:last-of-type)\": column\n          ? { borderBottomRadius: 0 }\n          : { borderRightRadius: 0, borderRightWidth: \"0px\" },\n        \"> *:not(:first-of-type):last-of-type\": column\n          ? { borderTopRadius: 0, borderTopWidth: \"0px\" }\n          : { borderLeftRadius: 0 },\n        \"> *:not(:first-of-type):not(:last-of-type)\": column\n          ? { borderRadius: 0, borderTopWidth: \"0px\" }\n          : { borderRadius: 0, borderRightWidth: \"0px\" },\n      })\n    } else {\n      Object.assign(css, {\n        columnGap,\n        gap,\n        rowGap,\n      })\n    }\n\n    return (\n      <ButtonGroupProvider value={context}>\n        <ui.div\n          ref={ref}\n          className={cx(\"ui-button-group\", className)}\n          data-attached={dataAttr(attached)}\n          role=\"group\"\n          __css={css}\n          {...rest}\n        />\n      </ButtonGroupProvider>\n    )\n  },\n)\n\nButtonGroup.displayName = \"ButtonGroup\"\nButtonGroup.__ui__ = \"ButtonGroup\"\n"],"mappings":";;;AAMA,SAAS,YAAY,UAAU;AAC/B,SAAS,eAAe,IAAI,gBAAgB;AAC5C,SAAS,eAAe;AA+GhB;AA/DR,IAAM,CAAC,qBAAqB,cAAc,IAAI;AAAA,EAC5C;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,EACV;AACF;AAIO,IAAM,cAAc;AAAA,EACzB,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GACA,QACG;AACH,UAAM,SACJ,kBAAkB,YAAY,kBAAkB;AAElD,UAAM,MAAmB;AAAA,MACvB,SAAS;AAAA,MACT;AAAA,IACF;AAEA,UAAM,UAA8B;AAAA,MAClC,OAAO,EAAE,MAA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