MCPcopy Create free account
hub / github.com/Botloader/botloader / EditOptionTextField

Function EditOptionTextField

frontend/src/components/GuildScriptPage.tsx:628–661  ·  view source on GitHub ↗
({ option }: { option: SettingsOption })

Source from the content-addressed store, hash-verified

626
627
628function EditOptionTextField({ option }: { option: SettingsOption }) {
629 if (option.kind.kind !== "string") {
630 throw new Error("not a string field")
631 }
632
633 const { value: rawValue, setValue, error } = useSettingsField(option.name)
634 const value = textFieldValue(rawValue?.value, option)
635
636 return <Box mt={3}>
637 <TextField
638 id={"script-option-" + option.name}
639 label={option.label}
640 // defaultValue="Default Value"
641 type={"text"}
642 inputProps={{
643 maxLength: option.kind.max_length,
644 minLength: option.kind.min_length,
645 }}
646 helperText={<FieldHelpText description={option.description} error={error} />}
647 onChange={(evt) => {
648 setValue(evt.target.value)
649 }}
650 value={value}
651 error={Boolean(error)}
652 />
653 {(Boolean(rawValue) && (option.defaultValue || !option.required)) &&
654 <IconButton
655 color='warning'
656 onClick={() => setValue(null)}
657 >
658 <ReplayIcon />
659 </IconButton>}
660 </Box>
661}
662
663function EditOptionSelect({ option }: { option: SettingsOption }) {
664 console.assert(option.kind.kind === "channel"

Callers

nothing calls this directly

Calls 3

useSettingsFieldFunction · 0.85
textFieldValueFunction · 0.85
setValueFunction · 0.85

Tested by

no test coverage detected