proje-react-panel 1.1.5 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,17 +19,15 @@ export function Select<TValue>({ input, fieldName }: SelectProps) {
19
19
  const inputSelect = input as SelectInputConfiguration<TValue>;
20
20
  const { control } = useFormContext();
21
21
  const [options, setOptions] = useState<OptionType<TValue>[]>(inputSelect.defaultOptions || []);
22
- const [key, setKey] = useState(0);
23
22
  //NOTE: is added to component to fix type error. Need to find a better solution.
24
23
  const styles = useMemo(() => darkSelectStyles<TValue>(), []);
25
24
  useEffect(() => {
26
25
  if (inputSelect.onSelectPreloader) {
27
26
  inputSelect.onSelectPreloader().then(option => {
28
27
  setOptions(option);
29
- setKey(key + 1);
30
28
  });
31
29
  }
32
- }, [inputSelect, inputSelect.onSelectPreloader, key]);
30
+ }, [inputSelect, inputSelect.onSelectPreloader]);
33
31
 
34
32
  return (
35
33
  <Controller
@@ -38,7 +36,6 @@ export function Select<TValue>({ input, fieldName }: SelectProps) {
38
36
  render={({ field }) => {
39
37
  return (
40
38
  <ReactSelect
41
- key={key}
42
39
  options={options}
43
40
  styles={styles}
44
41
  value={options.find(option => option.value === field.value) || null}
@@ -17,6 +17,7 @@ export interface InputOptions {
17
17
  label?: string;
18
18
  placeholder?: string;
19
19
  nestedFields?: InputConfiguration[];
20
+ defaultValue?: string;
20
21
  includeInCSV?: boolean;
21
22
  includeInJSON?: boolean;
22
23
  }
@@ -32,6 +33,7 @@ export interface InputConfiguration {
32
33
  label?: string;
33
34
  placeholder?: string;
34
35
  nestedFields?: InputConfiguration[];
36
+ defaultValue?: string;
35
37
  includeInCSV: boolean;
36
38
  includeInJSON: boolean;
37
39
  }
@@ -52,9 +54,8 @@ export function ExtendedInput(options?: ExtendedInputOptions): PropertyDecorator
52
54
  return (target, propertyKey) => {
53
55
  const existingInputs: string[] = Reflect.getMetadata(INPUT_KEY, target) || [];
54
56
  Reflect.defineMetadata(INPUT_KEY, [...existingInputs, propertyKey.toString()], target);
55
-
56
57
  if (options) {
57
- const keyString = `${INPUT_KEY.toString()}:${propertyKey.toString()}:options`;
58
+ const keyString = `${INPUT_KEY.toString()}:${propertyKey.toString()}:options`;
58
59
  Reflect.defineMetadata(keyString, options, target);
59
60
  }
60
61
  };
@@ -70,6 +71,7 @@ export function getInputFields<T extends AnyClass>(
70
71
  Reflect.getMetadata(`${INPUT_KEY.toString()}:${field}:options`, prototype) || {};
71
72
  const inputType = fields?.inputType ?? (isFieldSensitive(field) ? 'password' : 'text');
72
73
  const inputConfiguration: InputConfiguration = {
74
+ ...fields,
73
75
  name: fields?.name ?? field,
74
76
  label: fields?.label ?? field,
75
77
  placeholder: fields?.placeholder ?? field,
@@ -4,12 +4,15 @@ export interface SelectInputOptions<T> extends InputOptions {
4
4
  onSelectPreloader?: () => Promise<{ label: string; value: T }[]>;
5
5
  defaultOptions?: { value: T; label: string }[];
6
6
  csvExport?: never;
7
+ defaultValue?: never;
7
8
  }
8
9
 
9
10
  export interface SelectInputConfiguration<T> extends InputConfiguration {
10
11
  type: 'select';
11
12
  onSelectPreloader?: () => Promise<{ label: string; value: T }[]>;
12
13
  defaultOptions?: { value: T; label: string }[];
14
+ csvExport?: never;
15
+ defaultValue?: never;
13
16
  }
14
17
 
15
18
  export function SelectInput<K>(options?: SelectInputOptions<K>): PropertyDecorator {