@opengeoweb/form-fields 9.32.1 → 9.33.1-spike-ol.3
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.
package/index.esm.js
CHANGED
|
@@ -3,8 +3,8 @@ import { FormControl, FormHelperText, InputLabel, Select, RadioGroup, TextField,
|
|
|
3
3
|
import { useFormContext, useController, useForm, FormProvider } from 'react-hook-form';
|
|
4
4
|
import { isEqual } from 'lodash';
|
|
5
5
|
import { dateUtils } from '@opengeoweb/shared';
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
6
|
+
import 'i18next';
|
|
7
|
+
import { useTranslation } from 'react-i18next';
|
|
8
8
|
import * as React from 'react';
|
|
9
9
|
import { DateTimePicker } from '@mui/x-date-pickers';
|
|
10
10
|
import { CalendarToday } from '@opengeoweb/theme';
|
|
@@ -2335,27 +2335,6 @@ const isNonOrBothCoordinates = (coordinate, otherCoordinate) => {
|
|
|
2335
2335
|
};
|
|
2336
2336
|
|
|
2337
2337
|
const FORM_FIELDS_NAMESPACE = 'form-fields';
|
|
2338
|
-
void i18n.use(initReactI18next).init({
|
|
2339
|
-
lng: 'en',
|
|
2340
|
-
ns: FORM_FIELDS_NAMESPACE,
|
|
2341
|
-
interpolation: {
|
|
2342
|
-
escapeValue: false
|
|
2343
|
-
},
|
|
2344
|
-
resources: {
|
|
2345
|
-
en: {
|
|
2346
|
-
[FORM_FIELDS_NAMESPACE]: formFieldsTranslations.en
|
|
2347
|
-
},
|
|
2348
|
-
fi: {
|
|
2349
|
-
[FORM_FIELDS_NAMESPACE]: formFieldsTranslations.fi
|
|
2350
|
-
},
|
|
2351
|
-
no: {
|
|
2352
|
-
[FORM_FIELDS_NAMESPACE]: formFieldsTranslations.no
|
|
2353
|
-
},
|
|
2354
|
-
nl: {
|
|
2355
|
-
[FORM_FIELDS_NAMESPACE]: formFieldsTranslations.nl
|
|
2356
|
-
}
|
|
2357
|
-
}
|
|
2358
|
-
});
|
|
2359
2338
|
const ns = [FORM_FIELDS_NAMESPACE];
|
|
2360
2339
|
const useFormFieldsTranslation = () => useTranslation(ns);
|
|
2361
2340
|
|
|
@@ -2538,11 +2517,16 @@ $$3({ target: 'Array', proto: true, forced: FORCED$1 }, {
|
|
|
2538
2517
|
});
|
|
2539
2518
|
|
|
2540
2519
|
function getDeepProperty(p, o) {
|
|
2541
|
-
return p.reduce((xs, x) =>
|
|
2520
|
+
return p.reduce((xs, x) => {
|
|
2521
|
+
if (xs && typeof xs === 'object' && x in xs) {
|
|
2522
|
+
return xs[x];
|
|
2523
|
+
}
|
|
2524
|
+
return null;
|
|
2525
|
+
}, o);
|
|
2542
2526
|
}
|
|
2543
2527
|
const getErrors = (name, errors) => {
|
|
2544
2528
|
const nameAsArray = name.split('.');
|
|
2545
|
-
return getDeepProperty(nameAsArray, errors);
|
|
2529
|
+
return getDeepProperty(nameAsArray, errors) || undefined;
|
|
2546
2530
|
};
|
|
2547
2531
|
|
|
2548
2532
|
const _excluded$5 = ["name", "label", "defaultValue", "children", "rules", "onChange", "disabled", "className", "sx", "isReadOnly", "size"];
|
|
@@ -2597,10 +2581,10 @@ const ReactHookFormSelect = _ref => {
|
|
|
2597
2581
|
label: label,
|
|
2598
2582
|
inputRef: ref,
|
|
2599
2583
|
name: name,
|
|
2600
|
-
onChange: changeEvent => {
|
|
2584
|
+
onChange: (changeEvent, child) => {
|
|
2601
2585
|
onChangeField(changeEvent.target.value);
|
|
2602
2586
|
// default props
|
|
2603
|
-
onChange(changeEvent);
|
|
2587
|
+
onChange(changeEvent, child);
|
|
2604
2588
|
},
|
|
2605
2589
|
value: value || '',
|
|
2606
2590
|
variant: "filled"
|
package/package.json
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { SelectProps } from '@mui/material';
|
|
3
3
|
import { ReactHookFormInput } from './types';
|
|
4
|
-
type ReactHookFormSelectProps = Partial<SelectProps> & ReactHookFormInput<
|
|
5
|
-
onChange?: (value: React.ChangeEvent<HTMLInputElement>) => void;
|
|
6
|
-
}>;
|
|
4
|
+
type ReactHookFormSelectProps = Partial<SelectProps> & ReactHookFormInput<object>;
|
|
7
5
|
declare const ReactHookFormSelect: React.FC<ReactHookFormSelectProps>;
|
|
8
6
|
export default ReactHookFormSelect;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { FieldErrors } from 'react-hook-form';
|
|
2
|
-
export declare function getDeepProperty<I>(p: string[], o: I): I;
|
|
3
|
-
export declare const getErrors: (name: string, errors: FieldErrors) => FieldErrors;
|
|
2
|
+
export declare function getDeepProperty<I>(p: string[], o: I): I | null;
|
|
3
|
+
export declare const getErrors: (name: string, errors: FieldErrors) => FieldErrors | undefined;
|
package/src/lib/utils/i18n.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import i18n from 'i18next';
|
|
2
2
|
import { UseTranslationResponse } from 'react-i18next';
|
|
3
3
|
export declare const FORM_FIELDS_NAMESPACE = "form-fields";
|
|
4
|
+
export declare const initFormFieldsI18n: () => void;
|
|
4
5
|
export declare const translateKeyOutsideComponents: (key: string, params?: Record<string, string | number> | undefined) => string;
|
|
5
6
|
export declare const useFormFieldsTranslation: () => UseTranslationResponse<typeof FORM_FIELDS_NAMESPACE, typeof i18n>;
|
|
6
7
|
export { i18n };
|