Files
homarr/packages/widgets/src/_inputs/widget-select-input.tsx
Tagaishi edcba9ceb6 feat: Clock widget and dayjs locale standard (#79)
* feat: Clock widget and dayjs locale standard

Co-authored-by: Meier Lukas
- Widget options modifications
<meierschlumpf@gmail.com>

* perf: add improved time state for clock widget

* fix: final fixes

* refactor: unify selectOptions

* chore: fix CI & remove serverdata from clock widget

* chore: Change custom title to be under a toggle

---------

Co-authored-by: Meier Lukas <meierschlumpf@gmail.com>
2024-03-09 19:25:48 +01:00

41 lines
929 B
TypeScript

"use client";
import { Select } from "@homarr/ui";
import type { CommonWidgetInputProps } from "./common";
import { useWidgetInputTranslation } from "./common";
import { useFormContext } from "./form";
export type SelectOption =
| {
value: string;
label: string;
}
| string;
export type inferSelectOptionValue<TOption extends SelectOption> =
TOption extends {
value: infer TValue;
}
? TValue
: TOption;
export const WidgetSelectInput = ({
property,
kind,
options,
}: CommonWidgetInputProps<"select">) => {
const t = useWidgetInputTranslation(kind, property);
const form = useFormContext();
return (
<Select
label={t("label")}
data={options.options as unknown as SelectOption[]}
description={options.withDescription ? t("description") : undefined}
searchable={options.searchable}
{...form.getInputProps(`options.${property}`)}
/>
);
};