# All files / src/form SliderContainer.tsx

0% Statements 0/91
0% Branches 0/1
0% Functions 0/1
0% Lines 0/91

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92

     import { cnb } from "cnbuilder";
    import { forwardRef, type HTMLAttributes, type ReactNode } from "react";
    import { bem } from "../utils/bem.js";

    const styles = bem("rmd-slider-container");

    /**
     * @remarks
     * \@since 2.5.0
     * \@since 6.0.0 Renamed from `SliderAddons` to `SliderContainerAddonProps`
     */
    export interface SliderAddonProps {
      /**
       * An optional addon to render before the slider's track. This can be anything
       * and will be wrapped in the `TextIconSpacing` component.
       *
       * When the `vertical` prop is enabled, the addon will appear underneath the
       * track.
       */
      beforeAddon?: ReactNode;

      /**
       * An optional addon to render after the slider's track. This can be anything
       * and will be wrapped in the `TextIconSpacing` component.
       *
       * When the `vertical` prop is enabled, the addon will appear above the track.
       */
      afterAddon?: ReactNode;
    }

    /**
     * @internal
     * @remarks
     * \@since 2.5.0
     * \@since 6.0.0 Removed the `label` support since you'll generally want to use
     * a `Fieldset` instead.
     */
    export interface SliderContainerProps
      extends HTMLAttributes<HTMLDivElement>,
        SliderAddonProps {
      vertical: boolean;
    }

    /**
     * **Server Component**
     *
     * The `SliderContainer` component is mostly an internal component that is
     * built-in to the `Slider` and `RangeSlider` components to add addons to the
     * left or right of the `SliderTrack`. When vertical, it will add addons to the
     * bottom or top instead.
     *
     * @internal
     * @remarks
     * \@since 2.5.0
     * \@since 6.0.0 Removed the `label` support since you'll generally want to use
     * a `Fieldset` instead.
     */
    export const SliderContainer = forwardRef<HTMLDivElement, SliderContainerProps>(
      function SliderContainer(props, ref) {
        const {
          className,
          children,
          beforeAddon,
          afterAddon,
          vertical,
          ...remaining
        } = props;

        return (
          <div
            {...remaining}
            ref={ref}
            className={cnb(
              styles({
                h: !vertical,
                "pad-left": !vertical && !beforeAddon,
                "pad-right": !vertical && !afterAddon,
                v: vertical,
                "pad-bottom": vertical && !beforeAddon,
                "pad-top": vertical && !afterAddon,
              }),
              className
            )}
          >
            {beforeAddon}
            {children}
            {afterAddon}
          </div>
        );
      }
    );