mirror of
https://github.com/Xevion/rdap.git
synced 2025-12-05 23:15:58 -06:00
reformatting, improve name/docs
This commit is contained in:
@@ -36,7 +36,10 @@ type LookupInputProps = {
|
|||||||
* @param target - The target object containing the search target and target type.
|
* @param target - The target object containing the search target and target type.
|
||||||
* @returns Nothing.
|
* @returns Nothing.
|
||||||
*/
|
*/
|
||||||
onChange?: (target: { target: string; targetType: ObjectType | null }) => void;
|
onChange?: (target: {
|
||||||
|
target: string;
|
||||||
|
targetType: ObjectType | null;
|
||||||
|
}) => void;
|
||||||
detectedType: Maybe<ObjectType>;
|
detectedType: Maybe<ObjectType>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -54,7 +57,10 @@ const LookupInput: FunctionComponent<LookupInputProps> = ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const options: Record<ObjectType | "auto", string> = {
|
/**
|
||||||
|
* Mapping of object types to their corresponding display names.
|
||||||
|
*/
|
||||||
|
const objectNames: Record<ObjectType | "auto", string> = {
|
||||||
auto: "Autodetect",
|
auto: "Autodetect",
|
||||||
domain: "Domain",
|
domain: "Domain",
|
||||||
ip: "IP/CIDR",
|
ip: "IP/CIDR",
|
||||||
@@ -66,7 +72,6 @@ const LookupInput: FunctionComponent<LookupInputProps> = ({
|
|||||||
json: "JSON",
|
json: "JSON",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the selected value in the LookupInput component.
|
* Represents the selected value in the LookupInput component.
|
||||||
*/
|
*/
|
||||||
@@ -82,7 +87,7 @@ const LookupInput: FunctionComponent<LookupInputProps> = ({
|
|||||||
if (value == null) value = selected;
|
if (value == null) value = selected;
|
||||||
|
|
||||||
// 'auto' means 'do whatever' so we return null.
|
// 'auto' means 'do whatever' so we return null.
|
||||||
if (value == "auto" ) return null;
|
if (value == "auto") return null;
|
||||||
|
|
||||||
return value as ObjectType;
|
return value as ObjectType;
|
||||||
}
|
}
|
||||||
@@ -154,7 +159,9 @@ const LookupInput: FunctionComponent<LookupInputProps> = ({
|
|||||||
>
|
>
|
||||||
{/* Fetch special text for 'auto' mode, otherwise just use the options. */}
|
{/* Fetch special text for 'auto' mode, otherwise just use the options. */}
|
||||||
<span className="block">
|
<span className="block">
|
||||||
{selected == "auto" ? detectedType.unwrapOr("???") : options[selected]}
|
{selected == "auto"
|
||||||
|
? detectedType.unwrapOr("???")
|
||||||
|
: objectNames[selected]}
|
||||||
</span>
|
</span>
|
||||||
<span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
|
<span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
|
||||||
<ChevronUpDownIcon
|
<ChevronUpDownIcon
|
||||||
@@ -175,7 +182,7 @@ const LookupInput: FunctionComponent<LookupInputProps> = ({
|
|||||||
"text-zinc-200 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm"
|
"text-zinc-200 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{Object.entries(options).map(([key, value]) => (
|
{Object.entries(objectNames).map(([key, value]) => (
|
||||||
<Listbox.Option
|
<Listbox.Option
|
||||||
key={key}
|
key={key}
|
||||||
className={({ active }) =>
|
className={({ active }) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user