Files
CT/src/View/Components/option.tsx
T

33 lines
847 B
TypeScript
Raw Normal View History

import * as React from "bloatless-react";
export function Option(text: string, value: string, selectedOnCreate: boolean) {
2026-04-01 08:29:39 +00:00
return (
<option value={value} toggle:selected={selectedOnCreate}>
{text}
</option>
);
}
export const StringToOption: React.StateItemConverter<string> = (
2026-04-01 08:29:39 +00:00
string: string,
) => {
2026-04-01 08:29:39 +00:00
return Option(string, string, false);
};
2024-07-24 15:57:02 +02:00
export const EntryToOption: React.StateItemConverter<Entry> = (
2026-04-01 08:29:39 +00:00
entry: Entry,
) => {
2026-04-01 08:29:39 +00:00
return Option(entry[1], entry[0], false);
};
2024-07-24 15:57:02 +02:00
export const VersionIdToOption: React.StateItemConverter<string> = (
2026-04-01 08:29:39 +00:00
versionId: string,
2024-07-24 15:57:02 +02:00
) => {
2026-04-01 08:29:39 +00:00
const [date, rest] = versionId.split("T");
const [time] = rest.split(".");
const readableName = `${date} ${time}`;
return Option(readableName, versionId, false);
2024-07-24 15:57:02 +02:00
};
export type Entry = [string, string];