Skip to content
Source
Sign inSign up
Open History to see the last commit

ScopedSwitch.tsx

14 lines498 Bytes

1import type { ServerSettings } from "@t3tools/contracts";
2import type { ComponentProps } from "react";
3​
4import { Switch } from "../ui/switch";
5import { useScopedSettingsMixed } from "./useScopedSettings";
6​
7export function ScopedSwitch({
8 settingKeys,
9 checked,
10 ...props
11}: ComponentProps<typeof Switch> & { settingKeys: readonly (keyof ServerSettings)[] }) {
12 const mixed = useScopedSettingsMixed(settingKeys);
13 return <Switch {...props} mixed={mixed} checked={mixed ? false : checked} />;