mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
refactor(web/input): select backwards compat with no label
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { Group, Modal, Button, Stack } from '@mantine/core';
|
||||
import { Group, Modal, Button, Stack, SelectItem } from '@mantine/core';
|
||||
import React, { FormEvent, useRef } from 'react';
|
||||
import { useNuiEvent } from '../../hooks/useNuiEvent';
|
||||
import { useLocales } from '../../providers/LocaleProvider';
|
||||
import { fetchNui } from '../../utils/fetchNui';
|
||||
import { IInput, ICheckbox, ISelect, INumber, ISlider, IColorInput } from '../../interfaces/dialog';
|
||||
import { IInput, ICheckbox, ISelect, INumber, ISlider, IColorInput, OptionValue } from '../../interfaces/dialog';
|
||||
import InputField from './components/fields/input';
|
||||
import CheckboxField from './components/fields/checkbox';
|
||||
import SelectField from './components/fields/select';
|
||||
@@ -42,6 +42,12 @@ const InputDialog: React.FC = () => {
|
||||
setVisible(true);
|
||||
data.rows.forEach((row, index) => {
|
||||
fieldForm.insert(index, { value: row.type !== 'checkbox' ? row.default : row.checked } || { value: null });
|
||||
// Backwards compat with new Select data type
|
||||
if (row.type === 'select') {
|
||||
row.options = row.options.map((option) =>
|
||||
!option.label ? { ...option, label: option.value } : option
|
||||
) as Array<OptionValue>;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ interface Props {
|
||||
control: Control<FormValues>;
|
||||
}
|
||||
|
||||
// TODO: set label to value of value when there is no label provided
|
||||
const SelectField: React.FC<Props> = (props) => {
|
||||
const controller = useController({
|
||||
name: `test.${props.index}.value`,
|
||||
|
||||
Reference in New Issue
Block a user