Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

857 B
Raw Blame
"use client";

import { InputWrapper, Slider } from "@mantine/core";

import type { CommonWidgetInputProps } from "./common";
import { useWidgetInputTranslation } from "./common";
import { useFormContext } from "./form";

export const WidgetSliderInput = ({ property, kind, options }: CommonWidgetInputProps<"slider">) => {
  const t = useWidgetInputTranslation(kind, property);
  const form = useFormContext();

  return (
    <InputWrapper
      label={t("label")}
      description={options.withDescription ? t("description") : undefined}
      inputWrapperOrder={["label", "input", "description", "error"]}
    >
      <Slider
        min={options.validate.minValue ?? undefined}
        max={options.validate.maxValue ?? undefined}
        step={options.step}
        {...form.getInputProps(`options.${property}`)}
      />
    </InputWrapper>
  );
};