import { Box, Button, Icon, IconButton, Switch, Text, TextInput, Tooltip, } from "@prismicio/editor-ui"; import { useRef, useState } from "react"; import { Checkbox, Flex, Label } from "theme-ui"; import { Col } from "@/legacy/components/Flex"; interface CommonCheckboxProps { checked?: boolean; height?: 130 | 127; // eslint-disable-next-line @typescript-eslint/no-explicit-any setFieldValue: (name: string, checked?: boolean) => void | Promise; } export function DisplayTextCheckbox(props: CommonCheckboxProps) { const { checked, height = 130, setFieldValue } = props; // Container to position the tooltip inside it. const [container, setContainer] = useState(null); return ( ); } export function RepeatableCheckbox(props: CommonCheckboxProps) { const { checked, setFieldValue } = props; return ( Repeatable link fields are returned as an array of links by the API.{" "} See documentation. ); } export function Variants({ variants, onVariantsChange, error, }: { variants?: string[]; onVariantsChange: (variants?: string[]) => void; error?: string; }) { const enabled = Boolean(variants); const onCheckedChange = (checked: boolean) => { onVariantsChange(checked ? ["Primary", "Secondary"] : undefined); }; const switchLabel = enabled ? "Enabled" : "Disabled"; const optionsTitle = `Options (${variants?.length ?? 0})`; const deleteButtonShown = (variants?.length ?? 0) > 2; const focusableInputIndex = useRef(); return ( Variants Add variants like "Primary" and "Secondary" to allow editors to choose the link's style by selecting one of them. {switchLabel} {enabled && ( {optionsTitle} {Boolean(error) && ( {` ${error}`} )} {variants?.map((variant, position) => ( { if (focusableInputIndex.current !== position) return; focusableInputIndex.current = undefined; ref?.focus(); }} placeholder="Variant option (e.g. Primary)" value={variant} onValueChange={(newVariant) => onVariantsChange( variants?.map((variant, index) => index === position ? newVariant : variant, ), ) } /> {deleteButtonShown && ( onVariantsChange( variants?.filter((_, index) => index !== position), ) } /> )} ))} )} Need additional properties similar to "Variants"?{" "} Please provide your feedback here. ); }