Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const SelectUsers = ({
isMulti = true,
className = "",
...props
}: {
isMulti?: boolean;
name: string;
className?: string;
[key: string]: any;
}) => {
const [, meta, helpers] = useField(props);
const { value } = meta;
const { setValue } = helpers;
const { data } = useBetterQuery>(
["listUsers", {}, 1],
api.users.list,
{
refetchOnWindowFocus: false,
}
);
// react-select requires an `options` field of a special type. These hooks handle this.
const [usersOptions, setUsersOptions] = useState<
OptionsType<{ value: string; label: string }>
>([]);
export const RatingField = ({ question, label, ...props }) => {
// @ts-ignore
const [field, meta, helpers] = useField(props);
const setValue = (value) => {
field.value[question.id] = value;
helpers.setValue(field.value);
};
if (meta.touched && meta.error) return <p>{meta.error}</p>
return (
{Array.from(Array(5).keys()).map((index) =>
<button style="{{"> setValue(index + 1)}
>
{(index < field.value[question.id])</button>
const ChoicesField = (props) => {
const [field, meta, helpers] = useField(props);
const handleClick = (choice: Choice) => {
const index = field.value.findIndex((e)=>e===choice.id);
const newSelected: number[] = field.value.slice();
if (index >= 0) {
newSelected.splice(index, 1)
} else {
newSelected.push(choice.id)
}
if (newSelected.length > props.maxChoicesPerBallot) {
newSelected.shift()
}
helpers.setValue(newSelected)
};
const DatesField = (props) => {
const [field, meta] = useField(props)
return (
<h4>Dates</h4>
data: {
fg: color("#fff"),
bg: color("#555a62"),
},
},
];
let defaultValue = options[0];
const [currentOption, setCurrentOption] = useState(defaultValue);
const fgID = "global.mainColors.fg";
const bgID = "global.mainColors.bg";
const [fgValue, fgValueMeta, fgValueHelpers] = useField(fgID);
const [bgValue, bgValueMeta, bgValueHelpers] = useField(bgID);
const onChange = (option: IComboBoxOption | undefined) => {
if (option) {
fgValueHelpers.setTouched(true);
bgValueHelpers.setTouched(true);
fgValueHelpers.setValue(option.data.fg.toHexString());
bgValueHelpers.setValue(option.data.bg.toHexString());
setCurrentOption(option as any);
}
};
const inputID = useUniqueID("themePreset");
const labelID = useUniqueID("themePresetLabel");
return (
const DroppableFileInputField: React.FC = ({ name, label, helpText }) => {
const [field] = useField(name);
const { setFieldValue } = useFormikContext();
const fieldId = getFieldId(name, 'droppable-input');
return (
setFieldValue(name, fileData)}
inputFileData={field.value}
inputFieldHelpText={helpText}
aria-describedby={`${fieldId}-helper`}
/>
);
};
const SourceSecretSelector: React.FC = () => {
const [secret] = useField('git.secret');
const { values, setFieldValue } = useFormikContext();
const handleSave = (name: string) => {
setFieldValue('git.secret', name);
};
const handleDropdownChange = (key: string) => {
if (key === CREATE_SOURCE_SECRET) {
setFieldValue('git.secret', secret.value);
secretModalLauncher({
namespace: values.project.name,
save: handleSave,
secretType: SecretTypeAbstraction.source,
});
} else {
setFieldValue('git.secret', key);
const ToggleableFieldBase: React.FC = ({
label,
formLabel,
helpText,
required,
children,
...props
}) => {
const [field, { touched, error }] = useField(props.name);
const fieldId = getFieldId(props.name, 'checkbox');
const isValid = !(touched && error);
const errorMessage = !isValid ? error : '';
return (
{children({
...field,
...props,
id: fieldId,
function CalendarMui({
name,
label,
disabled = false,
minDate,
maxDate,
}: CalendarProps) {
const { i18n } = useTranslation();
const [locale, setLocale] = useState('enUS');
const [dateFormat, setDateFormat] = useState('dd/MM/yyyy');
const { allLanguages } = useLanguage();
const [field, { error, touched, value }] = useField(name);
useEffect(() => {
const lang = find(allLanguages, { i18nValue: i18n.language });
setDateFormat(lang.dateFormat);
setLocale(lang.i18nValue as LocaleType);
}, [i18n.language, allLanguages]);
return (
function FRadioGroup(props) {
const [{ onChange, onBlur, ...field }] = useField(props.name);
return (
);
}