@opengeoweb/form-fields 9.31.0 → 9.32.1

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
@@ -4,7 +4,7 @@ import { useFormContext, useController, useForm, FormProvider } from 'react-hook
4
4
  import { isEqual } from 'lodash';
5
5
  import { dateUtils } from '@opengeoweb/shared';
6
6
  import i18n from 'i18next';
7
- import { initReactI18next } from 'react-i18next';
7
+ import { initReactI18next, 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';
@@ -82,6 +82,16 @@ var formFieldsTranslations = {
82
82
  nl: nl
83
83
  };
84
84
 
85
+ function _objectWithoutPropertiesLoose(r, e) {
86
+ if (null == r) return {};
87
+ var t = {};
88
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
89
+ if (e.indexOf(n) >= 0) continue;
90
+ t[n] = r[n];
91
+ }
92
+ return t;
93
+ }
94
+
85
95
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
86
96
 
87
97
  var check = function (it) {
@@ -89,7 +99,7 @@ var check = function (it) {
89
99
  };
90
100
 
91
101
  // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
92
- var global$h =
102
+ var globalThis_1 =
93
103
  // eslint-disable-next-line es/no-global-this -- safe
94
104
  check(typeof globalThis == 'object' && globalThis) ||
95
105
  check(typeof window == 'object' && window) ||
@@ -240,7 +250,7 @@ var isObject$9 = function (it) {
240
250
  return typeof it == 'object' ? it !== null : isCallable$f(it);
241
251
  };
242
252
 
243
- var global$g = global$h;
253
+ var globalThis$i = globalThis_1;
244
254
  var isCallable$e = isCallable$g;
245
255
 
246
256
  var aFunction = function (argument) {
@@ -248,21 +258,26 @@ var aFunction = function (argument) {
248
258
  };
249
259
 
250
260
  var getBuiltIn$3 = function (namespace, method) {
251
- return arguments.length < 2 ? aFunction(global$g[namespace]) : global$g[namespace] && global$g[namespace][method];
261
+ return arguments.length < 2 ? aFunction(globalThis$i[namespace]) : globalThis$i[namespace] && globalThis$i[namespace][method];
252
262
  };
253
263
 
254
264
  var uncurryThis$e = functionUncurryThis;
255
265
 
256
266
  var objectIsPrototypeOf = uncurryThis$e({}.isPrototypeOf);
257
267
 
258
- var engineUserAgent = typeof navigator != 'undefined' && String(navigator.userAgent) || '';
268
+ var globalThis$h = globalThis_1;
269
+
270
+ var navigator = globalThis$h.navigator;
271
+ var userAgent$2 = navigator && navigator.userAgent;
259
272
 
260
- var global$f = global$h;
261
- var userAgent = engineUserAgent;
273
+ var environmentUserAgent = userAgent$2 ? String(userAgent$2) : '';
262
274
 
263
- var process = global$f.process;
264
- var Deno = global$f.Deno;
265
- var versions = process && process.versions || Deno && Deno.version;
275
+ var globalThis$g = globalThis_1;
276
+ var userAgent$1 = environmentUserAgent;
277
+
278
+ var process = globalThis$g.process;
279
+ var Deno$1 = globalThis$g.Deno;
280
+ var versions = process && process.versions || Deno$1 && Deno$1.version;
266
281
  var v8 = versions && versions.v8;
267
282
  var match, version;
268
283
 
@@ -275,22 +290,22 @@ if (v8) {
275
290
 
276
291
  // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
277
292
  // so check `userAgent` even if `.v8` exists, but 0
278
- if (!version && userAgent) {
279
- match = userAgent.match(/Edge\/(\d+)/);
293
+ if (!version && userAgent$1) {
294
+ match = userAgent$1.match(/Edge\/(\d+)/);
280
295
  if (!match || match[1] >= 74) {
281
- match = userAgent.match(/Chrome\/(\d+)/);
296
+ match = userAgent$1.match(/Chrome\/(\d+)/);
282
297
  if (match) version = +match[1];
283
298
  }
284
299
  }
285
300
 
286
- var engineV8Version = version;
301
+ var environmentV8Version = version;
287
302
 
288
303
  /* eslint-disable es/no-symbol -- required for testing */
289
- var V8_VERSION = engineV8Version;
304
+ var V8_VERSION = environmentV8Version;
290
305
  var fails$h = fails$l;
291
- var global$e = global$h;
306
+ var globalThis$f = globalThis_1;
292
307
 
293
- var $String$5 = global$e.String;
308
+ var $String$5 = globalThis$f.String;
294
309
 
295
310
  // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
296
311
  var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails$h(function () {
@@ -307,9 +322,9 @@ var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails$h(func
307
322
  /* eslint-disable es/no-symbol -- required for testing */
308
323
  var NATIVE_SYMBOL$1 = symbolConstructorDetection;
309
324
 
310
- var useSymbolAsUid = NATIVE_SYMBOL$1
311
- && !Symbol.sham
312
- && typeof Symbol.iterator == 'symbol';
325
+ var useSymbolAsUid = NATIVE_SYMBOL$1 &&
326
+ !Symbol.sham &&
327
+ typeof Symbol.iterator == 'symbol';
313
328
 
314
329
  var getBuiltIn$2 = getBuiltIn$3;
315
330
  var isCallable$d = isCallable$g;
@@ -374,30 +389,30 @@ var ordinaryToPrimitive$1 = function (input, pref) {
374
389
 
375
390
  var sharedStore = {exports: {}};
376
391
 
377
- var global$d = global$h;
392
+ var globalThis$e = globalThis_1;
378
393
 
379
394
  // eslint-disable-next-line es/no-object-defineproperty -- safe
380
395
  var defineProperty$5 = Object.defineProperty;
381
396
 
382
397
  var defineGlobalProperty$3 = function (key, value) {
383
398
  try {
384
- defineProperty$5(global$d, key, { value: value, configurable: true, writable: true });
399
+ defineProperty$5(globalThis$e, key, { value: value, configurable: true, writable: true });
385
400
  } catch (error) {
386
- global$d[key] = value;
401
+ globalThis$e[key] = value;
387
402
  } return value;
388
403
  };
389
404
 
390
- var globalThis$1 = global$h;
405
+ var globalThis$d = globalThis_1;
391
406
  var defineGlobalProperty$2 = defineGlobalProperty$3;
392
407
 
393
408
  var SHARED = '__core-js_shared__';
394
- var store$3 = sharedStore.exports = globalThis$1[SHARED] || defineGlobalProperty$2(SHARED, {});
409
+ var store$3 = sharedStore.exports = globalThis$d[SHARED] || defineGlobalProperty$2(SHARED, {});
395
410
 
396
411
  (store$3.versions || (store$3.versions = [])).push({
397
- version: '3.37.1',
412
+ version: '3.39.0',
398
413
  mode: 'global',
399
414
  copyright: '© 2014-2024 Denis Pushkarev (zloirock.ru)',
400
- license: 'https://github.com/zloirock/core-js/blob/v3.37.1/LICENSE',
415
+ license: 'https://github.com/zloirock/core-js/blob/v3.39.0/LICENSE',
401
416
  source: 'https://github.com/zloirock/core-js'
402
417
  });
403
418
 
@@ -441,14 +456,14 @@ var uid$2 = function (key) {
441
456
  return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$9(++id + postfix, 36);
442
457
  };
443
458
 
444
- var global$c = global$h;
459
+ var globalThis$c = globalThis_1;
445
460
  var shared$3 = shared$4;
446
461
  var hasOwn$9 = hasOwnProperty_1;
447
462
  var uid$1 = uid$2;
448
463
  var NATIVE_SYMBOL = symbolConstructorDetection;
449
464
  var USE_SYMBOL_AS_UID = useSymbolAsUid;
450
465
 
451
- var Symbol$3 = global$c.Symbol;
466
+ var Symbol$3 = globalThis$c.Symbol;
452
467
  var WellKnownSymbolsStore = shared$3('wks');
453
468
  var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$3['for'] || Symbol$3 : Symbol$3 && Symbol$3.withoutSetter || uid$1;
454
469
 
@@ -496,10 +511,10 @@ var toPropertyKey$2 = function (argument) {
496
511
  return isSymbol(key) ? key : key + '';
497
512
  };
498
513
 
499
- var global$b = global$h;
514
+ var globalThis$b = globalThis_1;
500
515
  var isObject$6 = isObject$9;
501
516
 
502
- var document$1 = global$b.document;
517
+ var document$1 = globalThis$b.document;
503
518
  // typeof document.createElement is 'object' in old IE
504
519
  var EXISTS$1 = isObject$6(document$1) && isObject$6(document$1.createElement);
505
520
 
@@ -658,10 +673,10 @@ if (!isCallable$a(store$1.inspectSource)) {
658
673
 
659
674
  var inspectSource$1 = store$1.inspectSource;
660
675
 
661
- var global$a = global$h;
676
+ var globalThis$a = globalThis_1;
662
677
  var isCallable$9 = isCallable$g;
663
678
 
664
- var WeakMap$1 = global$a.WeakMap;
679
+ var WeakMap$1 = globalThis$a.WeakMap;
665
680
 
666
681
  var weakMapBasicDetection = isCallable$9(WeakMap$1) && /native code/.test(String(WeakMap$1));
667
682
 
@@ -677,7 +692,7 @@ var sharedKey$3 = function (key) {
677
692
  var hiddenKeys$4 = {};
678
693
 
679
694
  var NATIVE_WEAK_MAP = weakMapBasicDetection;
680
- var global$9 = global$h;
695
+ var globalThis$9 = globalThis_1;
681
696
  var isObject$4 = isObject$9;
682
697
  var createNonEnumerableProperty$4 = createNonEnumerableProperty$5;
683
698
  var hasOwn$6 = hasOwnProperty_1;
@@ -686,8 +701,8 @@ var sharedKey$2 = sharedKey$3;
686
701
  var hiddenKeys$3 = hiddenKeys$4;
687
702
 
688
703
  var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
689
- var TypeError$1 = global$9.TypeError;
690
- var WeakMap = global$9.WeakMap;
704
+ var TypeError$1 = globalThis$9.TypeError;
705
+ var WeakMap = globalThis$9.WeakMap;
691
706
  var set, get, has;
692
707
 
693
708
  var enforce = function (it) {
@@ -1025,7 +1040,7 @@ var POLYFILL = isForced$1.POLYFILL = 'P';
1025
1040
 
1026
1041
  var isForced_1 = isForced$1;
1027
1042
 
1028
- var global$8 = global$h;
1043
+ var globalThis$8 = globalThis_1;
1029
1044
  var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
1030
1045
  var createNonEnumerableProperty$3 = createNonEnumerableProperty$5;
1031
1046
  var defineBuiltIn$4 = defineBuiltIn$5;
@@ -1054,11 +1069,11 @@ var _export = function (options, source) {
1054
1069
  var STATIC = options.stat;
1055
1070
  var FORCED, target, key, targetProperty, sourceProperty, descriptor;
1056
1071
  if (GLOBAL) {
1057
- target = global$8;
1072
+ target = globalThis$8;
1058
1073
  } else if (STATIC) {
1059
- target = global$8[TARGET] || defineGlobalProperty(TARGET, {});
1074
+ target = globalThis$8[TARGET] || defineGlobalProperty(TARGET, {});
1060
1075
  } else {
1061
- target = global$8[TARGET] && global$8[TARGET].prototype;
1076
+ target = globalThis$8[TARGET] && globalThis$8[TARGET].prototype;
1062
1077
  }
1063
1078
  if (target) for (key in source) {
1064
1079
  sourceProperty = source[key];
@@ -1157,40 +1172,6 @@ $$9({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }
1157
1172
  assign: assign
1158
1173
  });
1159
1174
 
1160
- /******************************************************************************
1161
- Copyright (c) Microsoft Corporation.
1162
-
1163
- Permission to use, copy, modify, and/or distribute this software for any
1164
- purpose with or without fee is hereby granted.
1165
-
1166
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1167
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1168
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1169
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1170
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1171
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1172
- PERFORMANCE OF THIS SOFTWARE.
1173
- ***************************************************************************** */
1174
- /* global Reflect, Promise, SuppressedError, Symbol */
1175
-
1176
-
1177
- function __rest(s, e) {
1178
- var t = {};
1179
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1180
- t[p] = s[p];
1181
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
1182
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1183
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1184
- t[p[i]] = s[p[i]];
1185
- }
1186
- return t;
1187
- }
1188
-
1189
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1190
- var e = new Error(message);
1191
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1192
- };
1193
-
1194
1175
  var objectDefineProperties = {};
1195
1176
 
1196
1177
  var DESCRIPTORS$1 = descriptors;
@@ -1244,7 +1225,8 @@ var NullProtoObjectViaActiveX = function (activeXDocument) {
1244
1225
  activeXDocument.write(scriptTag(''));
1245
1226
  activeXDocument.close();
1246
1227
  var temp = activeXDocument.parentWindow.Object;
1247
- activeXDocument = null; // avoid memory leak
1228
+ // eslint-disable-next-line no-useless-assignment -- avoid memory leak
1229
+ activeXDocument = null;
1248
1230
  return temp;
1249
1231
  };
1250
1232
 
@@ -1629,7 +1611,7 @@ var es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind)
1629
1611
  var target = state.target;
1630
1612
  var index = state.index++;
1631
1613
  if (!target || index >= target.length) {
1632
- state.target = undefined;
1614
+ state.target = null;
1633
1615
  return createIterResultObject(undefined, true);
1634
1616
  }
1635
1617
  switch (state.kind) {
@@ -1736,7 +1718,7 @@ var stringTrim = {
1736
1718
  trim: createMethod$2(3)
1737
1719
  };
1738
1720
 
1739
- var global$7 = global$h;
1721
+ var globalThis$7 = globalThis_1;
1740
1722
  var fails$9 = fails$l;
1741
1723
  var uncurryThis$4 = functionUncurryThis;
1742
1724
  var toString$6 = toString$8;
@@ -1744,8 +1726,8 @@ var trim$1 = stringTrim.trim;
1744
1726
  var whitespaces$2 = whitespaces$4;
1745
1727
 
1746
1728
  var charAt$3 = uncurryThis$4(''.charAt);
1747
- var $parseFloat$1 = global$7.parseFloat;
1748
- var Symbol$2 = global$7.Symbol;
1729
+ var $parseFloat$1 = globalThis$7.parseFloat;
1730
+ var Symbol$2 = globalThis$7.Symbol;
1749
1731
  var ITERATOR$2 = Symbol$2 && Symbol$2.iterator;
1750
1732
  var FORCED$2 = 1 / $parseFloat$1(whitespaces$2 + '-0') !== -Infinity
1751
1733
  // MS Edge 18- broken with boxed symbols
@@ -1787,10 +1769,10 @@ var regexpFlags$1 = function () {
1787
1769
  };
1788
1770
 
1789
1771
  var fails$8 = fails$l;
1790
- var global$6 = global$h;
1772
+ var globalThis$6 = globalThis_1;
1791
1773
 
1792
1774
  // babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError
1793
- var $RegExp$2 = global$6.RegExp;
1775
+ var $RegExp$2 = globalThis$6.RegExp;
1794
1776
 
1795
1777
  var UNSUPPORTED_Y$1 = fails$8(function () {
1796
1778
  var re = $RegExp$2('a', 'y');
@@ -1818,10 +1800,10 @@ var regexpStickyHelpers = {
1818
1800
  };
1819
1801
 
1820
1802
  var fails$7 = fails$l;
1821
- var global$5 = global$h;
1803
+ var globalThis$5 = globalThis_1;
1822
1804
 
1823
1805
  // babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError
1824
- var $RegExp$1 = global$5.RegExp;
1806
+ var $RegExp$1 = globalThis$5.RegExp;
1825
1807
 
1826
1808
  var regexpUnsupportedDotAll = fails$7(function () {
1827
1809
  var re = $RegExp$1('.', 's');
@@ -1829,10 +1811,10 @@ var regexpUnsupportedDotAll = fails$7(function () {
1829
1811
  });
1830
1812
 
1831
1813
  var fails$6 = fails$l;
1832
- var global$4 = global$h;
1814
+ var globalThis$4 = globalThis_1;
1833
1815
 
1834
1816
  // babel-minify and Closure Compiler transpiles RegExp('(?<a>b)', 'g') -> /(?<a>b)/g and it causes SyntaxError
1835
- var $RegExp = global$4.RegExp;
1817
+ var $RegExp = globalThis$4.RegExp;
1836
1818
 
1837
1819
  var regexpUnsupportedNcg = fails$6(function () {
1838
1820
  var re = $RegExp('(?<a>b)', 'g');
@@ -2112,7 +2094,7 @@ var DOMTokenListPrototype$1 = classList && classList.constructor && classList.co
2112
2094
 
2113
2095
  var domTokenListPrototype = DOMTokenListPrototype$1 === Object.prototype ? undefined : DOMTokenListPrototype$1;
2114
2096
 
2115
- var global$3 = global$h;
2097
+ var globalThis$3 = globalThis_1;
2116
2098
  var DOMIterables = domIterables;
2117
2099
  var DOMTokenListPrototype = domTokenListPrototype;
2118
2100
  var ArrayIteratorMethods = es_array_iterator;
@@ -2144,7 +2126,7 @@ var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) {
2144
2126
  };
2145
2127
 
2146
2128
  for (var COLLECTION_NAME in DOMIterables) {
2147
- handlePrototype(global$3[COLLECTION_NAME] && global$3[COLLECTION_NAME].prototype, COLLECTION_NAME);
2129
+ handlePrototype(globalThis$3[COLLECTION_NAME] && globalThis$3[COLLECTION_NAME].prototype, COLLECTION_NAME);
2148
2130
  }
2149
2131
 
2150
2132
  handlePrototype(DOMTokenListPrototype, 'DOMTokenList');
@@ -2301,8 +2283,8 @@ const hasMulitpleIntersections = geojson => {
2301
2283
  return false;
2302
2284
  };
2303
2285
  const countIntersectionPoints = (geojson, intersection) => {
2304
- var _a, _b;
2305
- if (!(geojson === null || geojson === void 0 ? void 0 : geojson.features) || !((_a = geojson.features[0]) === null || _a === void 0 ? void 0 : _a.geometry) || !(intersection === null || intersection === void 0 ? void 0 : intersection.features) || !((_b = intersection.features[0]) === null || _b === void 0 ? void 0 : _b.geometry)) {
2286
+ var _geojson$features$, _intersection$feature;
2287
+ if (!(geojson != null && geojson.features) || !((_geojson$features$ = geojson.features[0]) != null && _geojson$features$.geometry) || !(intersection != null && intersection.features) || !((_intersection$feature = intersection.features[0]) != null && _intersection$feature.geometry)) {
2306
2288
  return 0;
2307
2289
  }
2308
2290
  const geojsonGeometry = geojson.features[0].geometry;
@@ -2353,7 +2335,7 @@ const isNonOrBothCoordinates = (coordinate, otherCoordinate) => {
2353
2335
  };
2354
2336
 
2355
2337
  const FORM_FIELDS_NAMESPACE = 'form-fields';
2356
- i18n.use(initReactI18next).init({
2338
+ void i18n.use(initReactI18next).init({
2357
2339
  lng: 'en',
2358
2340
  ns: FORM_FIELDS_NAMESPACE,
2359
2341
  interpolation: {
@@ -2375,10 +2357,9 @@ i18n.use(initReactI18next).init({
2375
2357
  }
2376
2358
  });
2377
2359
  const ns = [FORM_FIELDS_NAMESPACE];
2378
- const translateKeyOutsideComponents = (key, params = undefined) => i18n.t(key, Object.assign({
2379
- ns
2380
- }, params));
2360
+ const useFormFieldsTranslation = () => useTranslation(ns);
2381
2361
 
2362
+ const _excluded$6 = ["children", "errors", "isReadOnly", "sx", "className", "size"];
2382
2363
  const radioCheckboxStyle = {
2383
2364
  // hides unchecked values
2384
2365
  display: 'none',
@@ -2399,31 +2380,34 @@ const radioCheckboxStyle = {
2399
2380
  color: 'geowebColors.typographyAndIcons.iconLinkActive'
2400
2381
  }
2401
2382
  };
2402
- const getErrorMessage = errors => {
2383
+ const getErrorMessage = (t, errors) => {
2403
2384
  if (errors && errors.message && typeof errors.message === 'string') {
2404
- return translateKeyOutsideComponents(errors.message);
2385
+ return t(errors.message);
2405
2386
  }
2406
2387
  if (errors && errors.type && typeof errors.type === 'string') {
2407
- return translateKeyOutsideComponents(errorMessages[errors.type]);
2388
+ return t(errorMessages[errors.type]);
2408
2389
  }
2409
2390
  return '';
2410
2391
  };
2411
- const ReactHookFormFormControl = _a => {
2412
- var {
2392
+ const ReactHookFormFormControl = _ref => {
2393
+ let {
2413
2394
  children,
2414
2395
  errors,
2415
2396
  isReadOnly,
2416
2397
  sx = {},
2417
2398
  className = '',
2418
2399
  size = 'medium'
2419
- } = _a,
2420
- props = __rest(_a, ["children", "errors", "isReadOnly", "sx", "className", "size"]);
2400
+ } = _ref,
2401
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
2402
+ const {
2403
+ t
2404
+ } = useFormFieldsTranslation();
2421
2405
  return jsxs(FormControl, Object.assign({
2422
2406
  fullWidth: true,
2423
2407
  error: !!errors,
2424
2408
  className: `${isReadOnly ? 'is-read-only' : ''} ${className}`,
2425
2409
  size: size,
2426
- sx: Object.assign(Object.assign({}, isReadOnly && {
2410
+ sx: Object.assign({}, isReadOnly && {
2427
2411
  // Radio input
2428
2412
  '.MuiRadio-root': radioCheckboxStyle,
2429
2413
  // Checkbox input
@@ -2442,14 +2426,13 @@ const ReactHookFormFormControl = _a => {
2442
2426
  '.Mui-disabled:before': {
2443
2427
  border: 'transparent'
2444
2428
  }
2445
- }), sx)
2429
+ }, sx)
2446
2430
  }, props, {
2447
- children: [children, errors && jsx(FormHelperText, Object.assign({
2431
+ children: [children, errors && jsx(FormHelperText, {
2448
2432
  variant: "filled",
2449
- role: "alert"
2450
- }, {
2451
- children: getErrorMessage(errors)
2452
- }))]
2433
+ role: "alert",
2434
+ children: getErrorMessage(t, errors)
2435
+ })]
2453
2436
  }));
2454
2437
  };
2455
2438
 
@@ -2509,16 +2492,36 @@ var arrayMethodIsStrict$1 = function (METHOD_NAME, argument) {
2509
2492
  });
2510
2493
  };
2511
2494
 
2512
- var global$2 = global$h;
2495
+ /* global Bun, Deno -- detection */
2496
+ var globalThis$2 = globalThis_1;
2497
+ var userAgent = environmentUserAgent;
2513
2498
  var classof$2 = classofRaw$1;
2514
2499
 
2515
- var engineIsNode = classof$2(global$2.process) === 'process';
2500
+ var userAgentStartsWith = function (string) {
2501
+ return userAgent.slice(0, string.length) === string;
2502
+ };
2503
+
2504
+ var environment = (function () {
2505
+ if (userAgentStartsWith('Bun/')) return 'BUN';
2506
+ if (userAgentStartsWith('Cloudflare-Workers')) return 'CLOUDFLARE';
2507
+ if (userAgentStartsWith('Deno/')) return 'DENO';
2508
+ if (userAgentStartsWith('Node.js/')) return 'NODE';
2509
+ if (globalThis$2.Bun && typeof Bun.version == 'string') return 'BUN';
2510
+ if (globalThis$2.Deno && typeof Deno.version == 'object') return 'DENO';
2511
+ if (classof$2(globalThis$2.process) === 'process') return 'NODE';
2512
+ if (globalThis$2.window && globalThis$2.document) return 'BROWSER';
2513
+ return 'REST';
2514
+ })();
2515
+
2516
+ var ENVIRONMENT = environment;
2517
+
2518
+ var environmentIsNode = ENVIRONMENT === 'NODE';
2516
2519
 
2517
2520
  var $$3 = _export;
2518
2521
  var $reduce = arrayReduce.left;
2519
2522
  var arrayMethodIsStrict = arrayMethodIsStrict$1;
2520
- var CHROME_VERSION = engineV8Version;
2521
- var IS_NODE = engineIsNode;
2523
+ var CHROME_VERSION = environmentV8Version;
2524
+ var IS_NODE = environmentIsNode;
2522
2525
 
2523
2526
  // Chrome 80-82 has a critical bug
2524
2527
  // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
@@ -2542,8 +2545,9 @@ const getErrors = (name, errors) => {
2542
2545
  return getDeepProperty(nameAsArray, errors);
2543
2546
  };
2544
2547
 
2545
- const ReactHookFormSelect = _a => {
2546
- var {
2548
+ const _excluded$5 = ["name", "label", "defaultValue", "children", "rules", "onChange", "disabled", "className", "sx", "isReadOnly", "size"];
2549
+ const ReactHookFormSelect = _ref => {
2550
+ let {
2547
2551
  name,
2548
2552
  label,
2549
2553
  defaultValue = '',
@@ -2555,8 +2559,8 @@ const ReactHookFormSelect = _a => {
2555
2559
  sx,
2556
2560
  isReadOnly,
2557
2561
  size = 'medium'
2558
- } = _a,
2559
- otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "onChange", "disabled", "className", "sx", "isReadOnly", "size"]);
2562
+ } = _ref,
2563
+ otherProps = _objectWithoutPropertiesLoose(_ref, _excluded$5);
2560
2564
  const labelId = `${name}-label`;
2561
2565
  const {
2562
2566
  control
@@ -2577,20 +2581,18 @@ const ReactHookFormSelect = _a => {
2577
2581
  defaultValue
2578
2582
  }, defaultProps));
2579
2583
  const errors = getErrors(name, formErrors);
2580
- return jsxs(ReactHookFormFormControl, Object.assign({
2584
+ return jsxs(ReactHookFormFormControl, {
2581
2585
  className: className,
2582
2586
  sx: sx,
2583
2587
  disabled: disabled,
2584
2588
  errors: errors,
2585
2589
  isReadOnly: isReadOnly,
2586
- size: size
2587
- }, {
2588
- children: [jsx(InputLabel, Object.assign({
2590
+ size: size,
2591
+ children: [jsx(InputLabel, {
2589
2592
  variant: "filled",
2590
- id: labelId
2591
- }, {
2593
+ id: labelId,
2592
2594
  children: label
2593
- })), jsx(Select, Object.assign({
2595
+ }), jsx(Select, Object.assign({
2594
2596
  labelId: labelId,
2595
2597
  label: label,
2596
2598
  inputRef: ref,
@@ -2605,11 +2607,12 @@ const ReactHookFormSelect = _a => {
2605
2607
  }, otherProps, {
2606
2608
  children: children
2607
2609
  }))]
2608
- }));
2610
+ });
2609
2611
  };
2610
2612
 
2611
- const ReactHookFormRadioGroup = _a => {
2612
- var {
2613
+ const _excluded$4 = ["name", "label", "defaultValue", "children", "rules", "disabled", "onChange", "isReadOnly"];
2614
+ const ReactHookFormRadioGroup = _ref => {
2615
+ let {
2613
2616
  name,
2614
2617
  label,
2615
2618
  defaultValue = '',
@@ -2618,8 +2621,8 @@ const ReactHookFormRadioGroup = _a => {
2618
2621
  disabled = false,
2619
2622
  onChange = () => {},
2620
2623
  isReadOnly
2621
- } = _a,
2622
- otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "disabled", "onChange", "isReadOnly"]);
2624
+ } = _ref,
2625
+ otherProps = _objectWithoutPropertiesLoose(_ref, _excluded$4);
2623
2626
  const labelId = `${name}-label`;
2624
2627
  const {
2625
2628
  control
@@ -2652,16 +2655,14 @@ const ReactHookFormRadioGroup = _a => {
2652
2655
  }
2653
2656
  }
2654
2657
  }, [errors, formErrors, name]);
2655
- return jsxs(ReactHookFormFormControl, Object.assign({
2658
+ return jsxs(ReactHookFormFormControl, {
2656
2659
  disabled: disabled,
2657
2660
  errors: errors,
2658
- isReadOnly: isReadOnly
2659
- }, {
2660
- children: [jsx(InputLabel, Object.assign({
2661
- id: labelId
2662
- }, {
2661
+ isReadOnly: isReadOnly,
2662
+ children: [jsx(InputLabel, {
2663
+ id: labelId,
2663
2664
  children: label
2664
- })), jsx(RadioGroup, Object.assign({
2665
+ }), jsx(RadioGroup, Object.assign({
2665
2666
  value: value,
2666
2667
  onChange: changeEvent => {
2667
2668
  onChangeField(changeEvent.target.value);
@@ -2672,14 +2673,15 @@ const ReactHookFormRadioGroup = _a => {
2672
2673
  }, otherProps, {
2673
2674
  children: children
2674
2675
  }))]
2675
- }));
2676
+ });
2676
2677
  };
2677
2678
 
2679
+ const _excluded$3 = ["name", "label", "defaultValue", "rules", "disabled", "upperCase", "helperText", "className", "sx", "onChange", "isReadOnly", "inputSlotProps"];
2678
2680
  const convertTextInputValue = (value, inCapitals) => {
2679
2681
  return inCapitals ? value.toUpperCase() : value;
2680
2682
  };
2681
- const ReactHookFormTextField = _a => {
2682
- var {
2683
+ const ReactHookFormTextField = _ref => {
2684
+ let {
2683
2685
  name,
2684
2686
  label,
2685
2687
  defaultValue = '',
@@ -2692,8 +2694,8 @@ const ReactHookFormTextField = _a => {
2692
2694
  onChange = () => {},
2693
2695
  isReadOnly,
2694
2696
  inputSlotProps
2695
- } = _a,
2696
- otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "upperCase", "helperText", "className", "sx", "onChange", "isReadOnly", "inputSlotProps"]);
2697
+ } = _ref,
2698
+ otherProps = _objectWithoutPropertiesLoose(_ref, _excluded$3);
2697
2699
  const {
2698
2700
  control
2699
2701
  } = useFormContext();
@@ -2713,13 +2715,12 @@ const ReactHookFormTextField = _a => {
2713
2715
  defaultValue
2714
2716
  }, defaultProps));
2715
2717
  const errors = getErrors(name, formErrors);
2716
- return jsx(ReactHookFormFormControl, Object.assign({
2718
+ return jsx(ReactHookFormFormControl, {
2717
2719
  className: className,
2718
2720
  sx: sx,
2719
2721
  disabled: disabled,
2720
2722
  errors: errors,
2721
- isReadOnly: isReadOnly
2722
- }, {
2723
+ isReadOnly: isReadOnly,
2723
2724
  children: jsx(TextField, Object.assign({
2724
2725
  label: label,
2725
2726
  error: !!errors,
@@ -2739,13 +2740,13 @@ const ReactHookFormTextField = _a => {
2739
2740
  disabled: disabled,
2740
2741
  inputRef: ref
2741
2742
  }, otherProps, {
2742
- slotProps: Object.assign(Object.assign({}, otherProps.slotProps), {
2743
- input: Object.assign(Object.assign({}, inputSlotProps), isReadOnly && {
2743
+ slotProps: Object.assign({}, otherProps.slotProps, {
2744
+ input: Object.assign({}, inputSlotProps, isReadOnly && {
2744
2745
  readOnly: true
2745
2746
  })
2746
2747
  })
2747
2748
  }))
2748
- }));
2749
+ });
2749
2750
  };
2750
2751
 
2751
2752
  var $$2 = _export;
@@ -2770,15 +2771,15 @@ $$2({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
2770
2771
  // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
2771
2772
  addToUnscopables('includes');
2772
2773
 
2773
- var global$1 = global$h;
2774
+ var globalThis$1 = globalThis_1;
2774
2775
  var fails$1 = fails$l;
2775
2776
  var uncurryThis$2 = functionUncurryThis;
2776
2777
  var toString$3 = toString$8;
2777
2778
  var trim = stringTrim.trim;
2778
2779
  var whitespaces = whitespaces$4;
2779
2780
 
2780
- var $parseInt$1 = global$1.parseInt;
2781
- var Symbol$1 = global$1.Symbol;
2781
+ var $parseInt$1 = globalThis$1.parseInt;
2782
+ var Symbol$1 = globalThis$1.Symbol;
2782
2783
  var ITERATOR = Symbol$1 && Symbol$1.iterator;
2783
2784
  var hex = /^[+-]?0x/i;
2784
2785
  var exec = uncurryThis$2(hex.exec);
@@ -3052,6 +3053,7 @@ fixRegExpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNa
3052
3053
  ];
3053
3054
  });
3054
3055
 
3056
+ const _excluded$2 = ["name", "label", "defaultValue", "rules", "disabled", "inputMode", "helperText", "className", "size", "sx", "onChange", "isReadOnly"];
3055
3057
  const convertNumericInputValue = (value, inputMode) => {
3056
3058
  if (value !== '' && !isNaN(parseFloat(value))) {
3057
3059
  return inputMode === 'numeric' ? parseInt(value, 10) : parseFloat(value);
@@ -3062,9 +3064,9 @@ const getAllowedKeys = (inputMode = 'numeric') => {
3062
3064
  const allowedKeys = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', 'Backspace', 'ArrowRight', 'ArrowLeft', 'Tab', 'Home', 'End', 'PageDown', 'PageUp', 'Delete', ...(inputMode === 'decimal' ? ['.'] : [])];
3063
3065
  return allowedKeys;
3064
3066
  };
3065
- const ReactHookFormNumberField = _a => {
3066
- var _b;
3067
- var {
3067
+ const ReactHookFormNumberField = _ref => {
3068
+ var _otherProps$slotProps;
3069
+ let {
3068
3070
  name,
3069
3071
  label,
3070
3072
  defaultValue = null,
@@ -3077,8 +3079,8 @@ const ReactHookFormNumberField = _a => {
3077
3079
  sx,
3078
3080
  onChange = () => {},
3079
3081
  isReadOnly
3080
- } = _a,
3081
- otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "inputMode", "helperText", "className", "size", "sx", "onChange", "isReadOnly"]);
3082
+ } = _ref,
3083
+ otherProps = _objectWithoutPropertiesLoose(_ref, _excluded$2);
3082
3084
  const {
3083
3085
  control
3084
3086
  } = useFormContext();
@@ -3130,13 +3132,12 @@ const ReactHookFormNumberField = _a => {
3130
3132
  }
3131
3133
  };
3132
3134
  const [displayValue, setDisplayValue] = React.useState(value === null || isNaN(value) ? '' : value);
3133
- return jsx(ReactHookFormFormControl, Object.assign({
3135
+ return jsx(ReactHookFormFormControl, {
3134
3136
  className: className,
3135
3137
  sx: sx,
3136
3138
  disabled: disabled,
3137
3139
  errors: errors,
3138
- isReadOnly: isReadOnly
3139
- }, {
3140
+ isReadOnly: isReadOnly,
3140
3141
  children: jsx(TextField, Object.assign({
3141
3142
  label: label,
3142
3143
  error: !!errors,
@@ -3159,20 +3160,21 @@ const ReactHookFormNumberField = _a => {
3159
3160
  disabled: disabled,
3160
3161
  inputRef: ref
3161
3162
  }, otherProps, {
3162
- slotProps: Object.assign(Object.assign({}, otherProps.slotProps), {
3163
- input: Object.assign(Object.assign({}, isReadOnly && {
3163
+ slotProps: Object.assign({}, otherProps.slotProps, {
3164
+ input: Object.assign({}, isReadOnly && {
3164
3165
  readOnly: true
3165
- }), {
3166
+ }, {
3166
3167
  onPaste
3167
3168
  }),
3168
- htmlInput: Object.assign(Object.assign({}, (_b = otherProps.slotProps) === null || _b === void 0 ? void 0 : _b.htmlInput), {
3169
+ htmlInput: Object.assign({}, (_otherProps$slotProps = otherProps.slotProps) == null ? void 0 : _otherProps$slotProps.htmlInput, {
3169
3170
  inputMode
3170
3171
  })
3171
3172
  })
3172
3173
  }))
3173
- }));
3174
+ });
3174
3175
  };
3175
3176
 
3177
+ const _excluded$1 = ["name", "rules", "disabled", "label", "format", "openTo", "defaultNullValue", "helperText", "onChange", "className", "sx", "isReadOnly", "inputAdornment", "shouldHideUTC", "disablePast", "disableFuture"];
3176
3178
  const OpenPicker = () => jsx(CalendarToday, {});
3177
3179
  const getTimezoneOffset = value => value.getTimezoneOffset() * 60000;
3178
3180
  const makeLocalAppearUTC = value => new Date(value.getTime() + getTimezoneOffset(value));
@@ -3184,13 +3186,13 @@ const localToUTC = dateTime => new Date(dateTime.getTime() - getTimezoneOffset(d
3184
3186
  * @returns iso string in YYYY-MM-DDThh:mm:ssZ format.
3185
3187
  */
3186
3188
  const getFormattedValueForDatePicker = value => {
3187
- var _a;
3188
- return (_a = dateUtils.dateToString(value, "yyyy-MM-dd'T'HH:mm:ss'Z'", true)) !== null && _a !== void 0 ? _a : null;
3189
+ var _dateUtils$dateToStri;
3190
+ return (_dateUtils$dateToStri = dateUtils.dateToString(value, "yyyy-MM-dd'T'HH:mm:ss'Z'", true)) != null ? _dateUtils$dateToStri : null;
3189
3191
  };
3190
3192
  const getDateValue = value => {
3191
- var _a, _b;
3192
3193
  if (value) {
3193
- const dateValue = (_b = (_a = dateUtils.stringToDate(value, 'yyyy/MM/dd HH:mm', false)) !== null && _a !== void 0 ? _a : dateUtils.isoStringToDate(value, false)) !== null && _b !== void 0 ? _b : null;
3194
+ var _ref, _dateUtils$stringToDa;
3195
+ const dateValue = (_ref = (_dateUtils$stringToDa = dateUtils.stringToDate(value, 'yyyy/MM/dd HH:mm', false)) != null ? _dateUtils$stringToDa : dateUtils.isoStringToDate(value, false)) != null ? _ref : null;
3194
3196
  if (dateValue) {
3195
3197
  return makeLocalAppearUTC(dateValue);
3196
3198
  }
@@ -3198,8 +3200,8 @@ const getDateValue = value => {
3198
3200
  }
3199
3201
  return null;
3200
3202
  };
3201
- const ReactHookKeyboardDateTimePicker = _a => {
3202
- var {
3203
+ const ReactHookKeyboardDateTimePicker = _ref2 => {
3204
+ let {
3203
3205
  name,
3204
3206
  rules,
3205
3207
  disabled,
@@ -3216,8 +3218,8 @@ const ReactHookKeyboardDateTimePicker = _a => {
3216
3218
  shouldHideUTC,
3217
3219
  disablePast,
3218
3220
  disableFuture
3219
- } = _a,
3220
- otherProps = __rest(_a, ["name", "rules", "disabled", "label", "format", "openTo", "defaultNullValue", "helperText", "onChange", "className", "sx", "isReadOnly", "inputAdornment", "shouldHideUTC", "disablePast", "disableFuture"]);
3221
+ } = _ref2,
3222
+ otherProps = _objectWithoutPropertiesLoose(_ref2, _excluded$1);
3221
3223
  const {
3222
3224
  control
3223
3225
  } = useFormContext();
@@ -3242,13 +3244,12 @@ const ReactHookKeyboardDateTimePicker = _a => {
3242
3244
  const now = makeLocalAppearUTC(dateUtils.utc());
3243
3245
  const minDateTime = disablePast ? now : null;
3244
3246
  const maxDateTime = disableFuture ? now : null;
3245
- return jsx(ReactHookFormFormControl, Object.assign({
3247
+ return jsx(ReactHookFormFormControl, {
3246
3248
  disabled: disabled,
3247
3249
  errors: errors,
3248
3250
  className: className,
3249
3251
  sx: sx,
3250
- isReadOnly: isReadOnly
3251
- }, {
3252
+ isReadOnly: isReadOnly,
3252
3253
  children: jsx(DateTimePicker, Object.assign({
3253
3254
  desktopModeMediaQuery: "@media (min-width: 720px)",
3254
3255
  ampm: false,
@@ -3276,14 +3277,13 @@ const ReactHookKeyboardDateTimePicker = _a => {
3276
3277
  name,
3277
3278
  placeholder: disabled ? '' : format.toLowerCase(),
3278
3279
  InputProps: Object.assign({}, !shouldHideUTC && {
3279
- endAdornment: jsx(InputAdornment, Object.assign({
3280
+ endAdornment: jsx(InputAdornment, {
3280
3281
  style: {
3281
3282
  paddingTop: '16px'
3282
3283
  },
3283
- position: "end"
3284
- }, {
3284
+ position: "end",
3285
3285
  children: "UTC"
3286
- }))
3286
+ })
3287
3287
  }),
3288
3288
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3289
3289
  // @ts-ignore
@@ -3310,7 +3310,7 @@ const ReactHookKeyboardDateTimePicker = _a => {
3310
3310
  minDateTime: minDateTime,
3311
3311
  maxDateTime: maxDateTime
3312
3312
  }, otherProps))
3313
- }));
3313
+ });
3314
3314
  };
3315
3315
 
3316
3316
  const defaultFormOptions = {
@@ -3332,23 +3332,22 @@ const ReactHookFormProvider = ({
3332
3332
  const ReactHookFormProviderWrapper = ({
3333
3333
  children,
3334
3334
  options: _options2 = defaultFormOptions
3335
- }) => jsx(LocalizationProvider, Object.assign({
3336
- dateAdapter: AdapterDateFns
3337
- }, {
3338
- children: jsx(ReactHookFormProvider, Object.assign({
3339
- options: _options2
3340
- }, {
3335
+ }) => jsx(LocalizationProvider, {
3336
+ dateAdapter: AdapterDateFns,
3337
+ children: jsx(ReactHookFormProvider, {
3338
+ options: _options2,
3341
3339
  children: children
3342
- }))
3343
- }));
3340
+ })
3341
+ });
3344
3342
 
3345
- const ReactHookFormHiddenInput = _a => {
3346
- var {
3343
+ const _excluded = ["name", "defaultValue", "rules"];
3344
+ const ReactHookFormHiddenInput = _ref => {
3345
+ let {
3347
3346
  name,
3348
3347
  defaultValue = null,
3349
3348
  rules
3350
- } = _a,
3351
- props = __rest(_a, ["name", "defaultValue", "rules"]);
3349
+ } = _ref,
3350
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
3352
3351
  const {
3353
3352
  control
3354
3353
  } = useFormContext();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/form-fields",
3
- "version": "9.31.0",
3
+ "version": "9.32.1",
4
4
  "description": "GeoWeb form-fields library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -12,8 +12,8 @@
12
12
  "react-hook-form": "^7.50.1",
13
13
  "@mui/x-date-pickers": "^7.17.0",
14
14
  "lodash": "^4.17.21",
15
- "@opengeoweb/shared": "9.31.0",
16
- "react-i18next": "^14.1.2",
15
+ "@opengeoweb/shared": "*",
16
+ "react-i18next": "^15.1.1",
17
17
  "@mui/material": "^6.1.1",
18
18
  "i18next": "^23.11.5"
19
19
  },
@@ -24,5 +24,6 @@
24
24
  },
25
25
  "module": "./index.esm.js",
26
26
  "type": "module",
27
- "main": "./index.esm.js"
27
+ "main": "./index.esm.js",
28
+ "types": "./index.esm.d.ts"
28
29
  }
@@ -1,11 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import { FormControlProps } from '@mui/material';
3
3
  import { FieldErrors } from 'react-hook-form';
4
+ import { TFunction } from 'i18next';
4
5
  interface ReactHookFormFormControlProps extends FormControlProps {
5
6
  children?: React.ReactNode;
6
7
  errors?: FieldErrors;
7
8
  isReadOnly?: boolean;
8
9
  }
9
- export declare const getErrorMessage: (errors: FieldErrors) => string;
10
+ export declare const getErrorMessage: (t: TFunction, errors: FieldErrors) => string;
10
11
  declare const ReactHookFormFormControl: React.FC<ReactHookFormFormControlProps>;
11
12
  export default ReactHookFormFormControl;
@@ -1,4 +1,6 @@
1
1
  import i18n from 'i18next';
2
+ import { UseTranslationResponse } from 'react-i18next';
2
3
  export declare const FORM_FIELDS_NAMESPACE = "form-fields";
3
4
  export declare const translateKeyOutsideComponents: (key: string, params?: Record<string, string | number> | undefined) => string;
5
+ export declare const useFormFieldsTranslation: () => UseTranslationResponse<typeof FORM_FIELDS_NAMESPACE, typeof i18n>;
4
6
  export { i18n };