@mtes-mct/monitor-ui 2.6.0 → 2.7.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/CHANGELOG.md +14 -0
- package/index.js +561 -59
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/src/fields/AutoComplete.d.ts +4 -2
- package/src/fields/DatePicker/index.d.ts +3 -1
- package/src/fields/DateRangePicker/TimeInput.d.ts +2 -0
- package/src/fields/DateRangePicker/index.d.ts +3 -1
- package/src/fields/MultiSelect.d.ts +3 -1
- package/src/fields/Select.d.ts +3 -1
- package/src/hooks/useClickOutside.d.ts +3 -0
- package/src/index.d.ts +2 -0
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styled, { createGlobalStyle, ThemeProvider as ThemeProvider$1, css } from 'styled-components';
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
-
import { useMemo,
|
|
3
|
+
import { useMemo, useCallback, useEffect, useReducer, useRef, useState, forwardRef, useImperativeHandle } from 'react';
|
|
4
4
|
import { Dropdown as Dropdown$1, AutoComplete as AutoComplete$1, Checkbox as Checkbox$1, DatePicker as DatePicker$1, DateRangePicker as DateRangePicker$1, TagPicker, Radio, Input, SelectPicker } from 'rsuite';
|
|
5
5
|
import { useField, useFormikContext } from 'formik';
|
|
6
6
|
|
|
@@ -333,6 +333,100 @@ function _arity(n, fn) {
|
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
+
/**
|
|
337
|
+
* Internal curryN function.
|
|
338
|
+
*
|
|
339
|
+
* @private
|
|
340
|
+
* @category Function
|
|
341
|
+
* @param {Number} length The arity of the curried function.
|
|
342
|
+
* @param {Array} received An array of arguments received thus far.
|
|
343
|
+
* @param {Function} fn The function to curry.
|
|
344
|
+
* @return {Function} The curried function.
|
|
345
|
+
*/
|
|
346
|
+
|
|
347
|
+
function _curryN(length, received, fn) {
|
|
348
|
+
return function () {
|
|
349
|
+
var combined = [];
|
|
350
|
+
var argsIdx = 0;
|
|
351
|
+
var left = length;
|
|
352
|
+
var combinedIdx = 0;
|
|
353
|
+
|
|
354
|
+
while (combinedIdx < received.length || argsIdx < arguments.length) {
|
|
355
|
+
var result;
|
|
356
|
+
|
|
357
|
+
if (combinedIdx < received.length && (!_isPlaceholder(received[combinedIdx]) || argsIdx >= arguments.length)) {
|
|
358
|
+
result = received[combinedIdx];
|
|
359
|
+
} else {
|
|
360
|
+
result = arguments[argsIdx];
|
|
361
|
+
argsIdx += 1;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
combined[combinedIdx] = result;
|
|
365
|
+
|
|
366
|
+
if (!_isPlaceholder(result)) {
|
|
367
|
+
left -= 1;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
combinedIdx += 1;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
return left <= 0 ? fn.apply(this, combined) : _arity(left, _curryN(length, combined, fn));
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Returns a curried equivalent of the provided function, with the specified
|
|
379
|
+
* arity. The curried function has two unusual capabilities. First, its
|
|
380
|
+
* arguments needn't be provided one at a time. If `g` is `R.curryN(3, f)`, the
|
|
381
|
+
* following are equivalent:
|
|
382
|
+
*
|
|
383
|
+
* - `g(1)(2)(3)`
|
|
384
|
+
* - `g(1)(2, 3)`
|
|
385
|
+
* - `g(1, 2)(3)`
|
|
386
|
+
* - `g(1, 2, 3)`
|
|
387
|
+
*
|
|
388
|
+
* Secondly, the special placeholder value [`R.__`](#__) may be used to specify
|
|
389
|
+
* "gaps", allowing partial application of any combination of arguments,
|
|
390
|
+
* regardless of their positions. If `g` is as above and `_` is [`R.__`](#__),
|
|
391
|
+
* the following are equivalent:
|
|
392
|
+
*
|
|
393
|
+
* - `g(1, 2, 3)`
|
|
394
|
+
* - `g(_, 2, 3)(1)`
|
|
395
|
+
* - `g(_, _, 3)(1)(2)`
|
|
396
|
+
* - `g(_, _, 3)(1, 2)`
|
|
397
|
+
* - `g(_, 2)(1)(3)`
|
|
398
|
+
* - `g(_, 2)(1, 3)`
|
|
399
|
+
* - `g(_, 2)(_, 3)(1)`
|
|
400
|
+
*
|
|
401
|
+
* @func
|
|
402
|
+
* @memberOf R
|
|
403
|
+
* @since v0.5.0
|
|
404
|
+
* @category Function
|
|
405
|
+
* @sig Number -> (* -> a) -> (* -> a)
|
|
406
|
+
* @param {Number} length The arity for the returned function.
|
|
407
|
+
* @param {Function} fn The function to curry.
|
|
408
|
+
* @return {Function} A new, curried function.
|
|
409
|
+
* @see R.curry
|
|
410
|
+
* @example
|
|
411
|
+
*
|
|
412
|
+
* const sumArgs = (...args) => R.sum(args);
|
|
413
|
+
*
|
|
414
|
+
* const curriedAddFourNumbers = R.curryN(4, sumArgs);
|
|
415
|
+
* const f = curriedAddFourNumbers(1, 2);
|
|
416
|
+
* const g = f(3);
|
|
417
|
+
* g(4); //=> 10
|
|
418
|
+
*/
|
|
419
|
+
|
|
420
|
+
var curryN =
|
|
421
|
+
/*#__PURE__*/
|
|
422
|
+
_curry2(function curryN(length, fn) {
|
|
423
|
+
if (length === 1) {
|
|
424
|
+
return _curry1(fn);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
return _arity(length, _curryN(length, [], fn));
|
|
428
|
+
});
|
|
429
|
+
|
|
336
430
|
/**
|
|
337
431
|
* Optimized internal three-arity curry function.
|
|
338
432
|
*
|
|
@@ -445,6 +539,13 @@ function _dispatchable(methodNames, transducerCreator, fn) {
|
|
|
445
539
|
};
|
|
446
540
|
}
|
|
447
541
|
|
|
542
|
+
function _reduced(x) {
|
|
543
|
+
return x && x['@@transducer/reduced'] ? x : {
|
|
544
|
+
'@@transducer/value': x,
|
|
545
|
+
'@@transducer/reduced': true
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
|
|
448
549
|
var _xfBase = {
|
|
449
550
|
init: function () {
|
|
450
551
|
return this.xf['@@transducer/init']();
|
|
@@ -454,6 +555,19 @@ var _xfBase = {
|
|
|
454
555
|
}
|
|
455
556
|
};
|
|
456
557
|
|
|
558
|
+
function _map(fn, functor) {
|
|
559
|
+
var idx = 0;
|
|
560
|
+
var len = functor.length;
|
|
561
|
+
var result = Array(len);
|
|
562
|
+
|
|
563
|
+
while (idx < len) {
|
|
564
|
+
result[idx] = fn(functor[idx]);
|
|
565
|
+
idx += 1;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
return result;
|
|
569
|
+
}
|
|
570
|
+
|
|
457
571
|
function _isString(x) {
|
|
458
572
|
return Object.prototype.toString.call(x) === '[object String]';
|
|
459
573
|
}
|
|
@@ -632,6 +746,30 @@ function _reduce(fn, acc, list) {
|
|
|
632
746
|
throw new TypeError('reduce: list must be array or iterable');
|
|
633
747
|
}
|
|
634
748
|
|
|
749
|
+
var XMap =
|
|
750
|
+
/*#__PURE__*/
|
|
751
|
+
function () {
|
|
752
|
+
function XMap(f, xf) {
|
|
753
|
+
this.xf = xf;
|
|
754
|
+
this.f = f;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
XMap.prototype['@@transducer/init'] = _xfBase.init;
|
|
758
|
+
XMap.prototype['@@transducer/result'] = _xfBase.result;
|
|
759
|
+
|
|
760
|
+
XMap.prototype['@@transducer/step'] = function (result, input) {
|
|
761
|
+
return this.xf['@@transducer/step'](result, this.f(input));
|
|
762
|
+
};
|
|
763
|
+
|
|
764
|
+
return XMap;
|
|
765
|
+
}();
|
|
766
|
+
|
|
767
|
+
var _xmap =
|
|
768
|
+
/*#__PURE__*/
|
|
769
|
+
_curry2(function _xmap(f, xf) {
|
|
770
|
+
return new XMap(f, xf);
|
|
771
|
+
});
|
|
772
|
+
|
|
635
773
|
function _has(prop, obj) {
|
|
636
774
|
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
637
775
|
}
|
|
@@ -734,6 +872,64 @@ _curry1(function keys(obj) {
|
|
|
734
872
|
return ks;
|
|
735
873
|
});
|
|
736
874
|
|
|
875
|
+
/**
|
|
876
|
+
* Takes a function and
|
|
877
|
+
* a [functor](https://github.com/fantasyland/fantasy-land#functor),
|
|
878
|
+
* applies the function to each of the functor's values, and returns
|
|
879
|
+
* a functor of the same shape.
|
|
880
|
+
*
|
|
881
|
+
* Ramda provides suitable `map` implementations for `Array` and `Object`,
|
|
882
|
+
* so this function may be applied to `[1, 2, 3]` or `{x: 1, y: 2, z: 3}`.
|
|
883
|
+
*
|
|
884
|
+
* Dispatches to the `map` method of the second argument, if present.
|
|
885
|
+
*
|
|
886
|
+
* Acts as a transducer if a transformer is given in list position.
|
|
887
|
+
*
|
|
888
|
+
* Also treats functions as functors and will compose them together.
|
|
889
|
+
*
|
|
890
|
+
* @func
|
|
891
|
+
* @memberOf R
|
|
892
|
+
* @since v0.1.0
|
|
893
|
+
* @category List
|
|
894
|
+
* @sig Functor f => (a -> b) -> f a -> f b
|
|
895
|
+
* @param {Function} fn The function to be called on every element of the input `list`.
|
|
896
|
+
* @param {Array} list The list to be iterated over.
|
|
897
|
+
* @return {Array} The new list.
|
|
898
|
+
* @see R.transduce, R.addIndex, R.pluck, R.project
|
|
899
|
+
* @example
|
|
900
|
+
*
|
|
901
|
+
* const double = x => x * 2;
|
|
902
|
+
*
|
|
903
|
+
* R.map(double, [1, 2, 3]); //=> [2, 4, 6]
|
|
904
|
+
*
|
|
905
|
+
* R.map(double, {x: 1, y: 2, z: 3}); //=> {x: 2, y: 4, z: 6}
|
|
906
|
+
* @symb R.map(f, [a, b]) = [f(a), f(b)]
|
|
907
|
+
* @symb R.map(f, { x: a, y: b }) = { x: f(a), y: f(b) }
|
|
908
|
+
* @symb R.map(f, functor_o) = functor_o.map(f)
|
|
909
|
+
*/
|
|
910
|
+
|
|
911
|
+
var map =
|
|
912
|
+
/*#__PURE__*/
|
|
913
|
+
_curry2(
|
|
914
|
+
/*#__PURE__*/
|
|
915
|
+
_dispatchable(['fantasy-land/map', 'map'], _xmap, function map(fn, functor) {
|
|
916
|
+
switch (Object.prototype.toString.call(functor)) {
|
|
917
|
+
case '[object Function]':
|
|
918
|
+
return curryN(functor.length, function () {
|
|
919
|
+
return fn.call(this, functor.apply(this, arguments));
|
|
920
|
+
});
|
|
921
|
+
|
|
922
|
+
case '[object Object]':
|
|
923
|
+
return _reduce(function (acc, key) {
|
|
924
|
+
acc[key] = fn(functor[key]);
|
|
925
|
+
return acc;
|
|
926
|
+
}, {}, keys(functor));
|
|
927
|
+
|
|
928
|
+
default:
|
|
929
|
+
return _map(fn, functor);
|
|
930
|
+
}
|
|
931
|
+
}));
|
|
932
|
+
|
|
737
933
|
/**
|
|
738
934
|
* Determine if the passed argument is an integer.
|
|
739
935
|
*
|
|
@@ -812,6 +1008,138 @@ _curry2(function prop(p, obj) {
|
|
|
812
1008
|
return _isInteger(p) ? nth(p, obj) : obj[p];
|
|
813
1009
|
});
|
|
814
1010
|
|
|
1011
|
+
/**
|
|
1012
|
+
* Returns a single item by iterating through the list, successively calling
|
|
1013
|
+
* the iterator function and passing it an accumulator value and the current
|
|
1014
|
+
* value from the array, and then passing the result to the next call.
|
|
1015
|
+
*
|
|
1016
|
+
* The iterator function receives two values: *(acc, value)*. It may use
|
|
1017
|
+
* [`R.reduced`](#reduced) to shortcut the iteration.
|
|
1018
|
+
*
|
|
1019
|
+
* The arguments' order of [`reduceRight`](#reduceRight)'s iterator function
|
|
1020
|
+
* is *(value, acc)*.
|
|
1021
|
+
*
|
|
1022
|
+
* Note: `R.reduce` does not skip deleted or unassigned indices (sparse
|
|
1023
|
+
* arrays), unlike the native `Array.prototype.reduce` method. For more details
|
|
1024
|
+
* on this behavior, see:
|
|
1025
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#Description
|
|
1026
|
+
*
|
|
1027
|
+
* Dispatches to the `reduce` method of the third argument, if present. When
|
|
1028
|
+
* doing so, it is up to the user to handle the [`R.reduced`](#reduced)
|
|
1029
|
+
* shortcuting, as this is not implemented by `reduce`.
|
|
1030
|
+
*
|
|
1031
|
+
* @func
|
|
1032
|
+
* @memberOf R
|
|
1033
|
+
* @since v0.1.0
|
|
1034
|
+
* @category List
|
|
1035
|
+
* @sig ((a, b) -> a) -> a -> [b] -> a
|
|
1036
|
+
* @param {Function} fn The iterator function. Receives two values, the accumulator and the
|
|
1037
|
+
* current element from the array.
|
|
1038
|
+
* @param {*} acc The accumulator value.
|
|
1039
|
+
* @param {Array} list The list to iterate over.
|
|
1040
|
+
* @return {*} The final, accumulated value.
|
|
1041
|
+
* @see R.reduced, R.addIndex, R.reduceRight
|
|
1042
|
+
* @example
|
|
1043
|
+
*
|
|
1044
|
+
* R.reduce(R.subtract, 0, [1, 2, 3, 4]) // => ((((0 - 1) - 2) - 3) - 4) = -10
|
|
1045
|
+
* // - -10
|
|
1046
|
+
* // / \ / \
|
|
1047
|
+
* // - 4 -6 4
|
|
1048
|
+
* // / \ / \
|
|
1049
|
+
* // - 3 ==> -3 3
|
|
1050
|
+
* // / \ / \
|
|
1051
|
+
* // - 2 -1 2
|
|
1052
|
+
* // / \ / \
|
|
1053
|
+
* // 0 1 0 1
|
|
1054
|
+
*
|
|
1055
|
+
* @symb R.reduce(f, a, [b, c, d]) = f(f(f(a, b), c), d)
|
|
1056
|
+
*/
|
|
1057
|
+
|
|
1058
|
+
var reduce =
|
|
1059
|
+
/*#__PURE__*/
|
|
1060
|
+
_curry3(_reduce);
|
|
1061
|
+
|
|
1062
|
+
var XAny =
|
|
1063
|
+
/*#__PURE__*/
|
|
1064
|
+
function () {
|
|
1065
|
+
function XAny(f, xf) {
|
|
1066
|
+
this.xf = xf;
|
|
1067
|
+
this.f = f;
|
|
1068
|
+
this.any = false;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
XAny.prototype['@@transducer/init'] = _xfBase.init;
|
|
1072
|
+
|
|
1073
|
+
XAny.prototype['@@transducer/result'] = function (result) {
|
|
1074
|
+
if (!this.any) {
|
|
1075
|
+
result = this.xf['@@transducer/step'](result, false);
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
return this.xf['@@transducer/result'](result);
|
|
1079
|
+
};
|
|
1080
|
+
|
|
1081
|
+
XAny.prototype['@@transducer/step'] = function (result, input) {
|
|
1082
|
+
if (this.f(input)) {
|
|
1083
|
+
this.any = true;
|
|
1084
|
+
result = _reduced(this.xf['@@transducer/step'](result, true));
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
return result;
|
|
1088
|
+
};
|
|
1089
|
+
|
|
1090
|
+
return XAny;
|
|
1091
|
+
}();
|
|
1092
|
+
|
|
1093
|
+
var _xany =
|
|
1094
|
+
/*#__PURE__*/
|
|
1095
|
+
_curry2(function _xany(f, xf) {
|
|
1096
|
+
return new XAny(f, xf);
|
|
1097
|
+
});
|
|
1098
|
+
|
|
1099
|
+
/**
|
|
1100
|
+
* Returns `true` if at least one of the elements of the list match the predicate,
|
|
1101
|
+
* `false` otherwise.
|
|
1102
|
+
*
|
|
1103
|
+
* Dispatches to the `any` method of the second argument, if present.
|
|
1104
|
+
*
|
|
1105
|
+
* Acts as a transducer if a transformer is given in list position.
|
|
1106
|
+
*
|
|
1107
|
+
* @func
|
|
1108
|
+
* @memberOf R
|
|
1109
|
+
* @since v0.1.0
|
|
1110
|
+
* @category List
|
|
1111
|
+
* @sig (a -> Boolean) -> [a] -> Boolean
|
|
1112
|
+
* @param {Function} fn The predicate function.
|
|
1113
|
+
* @param {Array} list The array to consider.
|
|
1114
|
+
* @return {Boolean} `true` if the predicate is satisfied by at least one element, `false`
|
|
1115
|
+
* otherwise.
|
|
1116
|
+
* @see R.all, R.none, R.transduce
|
|
1117
|
+
* @example
|
|
1118
|
+
*
|
|
1119
|
+
* const lessThan0 = R.flip(R.lt)(0);
|
|
1120
|
+
* const lessThan2 = R.flip(R.lt)(2);
|
|
1121
|
+
* R.any(lessThan0)([1, 2]); //=> false
|
|
1122
|
+
* R.any(lessThan2)([1, 2]); //=> true
|
|
1123
|
+
*/
|
|
1124
|
+
|
|
1125
|
+
var any =
|
|
1126
|
+
/*#__PURE__*/
|
|
1127
|
+
_curry2(
|
|
1128
|
+
/*#__PURE__*/
|
|
1129
|
+
_dispatchable(['any'], _xany, function any(fn, list) {
|
|
1130
|
+
var idx = 0;
|
|
1131
|
+
|
|
1132
|
+
while (idx < list.length) {
|
|
1133
|
+
if (fn(list[idx])) {
|
|
1134
|
+
return true;
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
idx += 1;
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
return false;
|
|
1141
|
+
}));
|
|
1142
|
+
|
|
815
1143
|
/**
|
|
816
1144
|
* Gives a single-word string description of the (native) type of a value,
|
|
817
1145
|
* returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not
|
|
@@ -844,6 +1172,166 @@ _curry1(function type(val) {
|
|
|
844
1172
|
return val === null ? 'Null' : val === undefined ? 'Undefined' : Object.prototype.toString.call(val).slice(8, -1);
|
|
845
1173
|
});
|
|
846
1174
|
|
|
1175
|
+
function _pipe(f, g) {
|
|
1176
|
+
return function () {
|
|
1177
|
+
return g.call(this, f.apply(this, arguments));
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
/**
|
|
1182
|
+
* This checks whether a function has a [methodname] function. If it isn't an
|
|
1183
|
+
* array it will execute that function otherwise it will default to the ramda
|
|
1184
|
+
* implementation.
|
|
1185
|
+
*
|
|
1186
|
+
* @private
|
|
1187
|
+
* @param {Function} fn ramda implementation
|
|
1188
|
+
* @param {String} methodname property to check for a custom implementation
|
|
1189
|
+
* @return {Object} Whatever the return value of the method is.
|
|
1190
|
+
*/
|
|
1191
|
+
|
|
1192
|
+
function _checkForMethod(methodname, fn) {
|
|
1193
|
+
return function () {
|
|
1194
|
+
var length = arguments.length;
|
|
1195
|
+
|
|
1196
|
+
if (length === 0) {
|
|
1197
|
+
return fn();
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
var obj = arguments[length - 1];
|
|
1201
|
+
return _isArray(obj) || typeof obj[methodname] !== 'function' ? fn.apply(this, arguments) : obj[methodname].apply(obj, Array.prototype.slice.call(arguments, 0, length - 1));
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
/**
|
|
1206
|
+
* Returns the elements of the given list or string (or object with a `slice`
|
|
1207
|
+
* method) from `fromIndex` (inclusive) to `toIndex` (exclusive).
|
|
1208
|
+
*
|
|
1209
|
+
* Dispatches to the `slice` method of the third argument, if present.
|
|
1210
|
+
*
|
|
1211
|
+
* @func
|
|
1212
|
+
* @memberOf R
|
|
1213
|
+
* @since v0.1.4
|
|
1214
|
+
* @category List
|
|
1215
|
+
* @sig Number -> Number -> [a] -> [a]
|
|
1216
|
+
* @sig Number -> Number -> String -> String
|
|
1217
|
+
* @param {Number} fromIndex The start index (inclusive).
|
|
1218
|
+
* @param {Number} toIndex The end index (exclusive).
|
|
1219
|
+
* @param {*} list
|
|
1220
|
+
* @return {*}
|
|
1221
|
+
* @example
|
|
1222
|
+
*
|
|
1223
|
+
* R.slice(1, 3, ['a', 'b', 'c', 'd']); //=> ['b', 'c']
|
|
1224
|
+
* R.slice(1, Infinity, ['a', 'b', 'c', 'd']); //=> ['b', 'c', 'd']
|
|
1225
|
+
* R.slice(0, -1, ['a', 'b', 'c', 'd']); //=> ['a', 'b', 'c']
|
|
1226
|
+
* R.slice(-3, -1, ['a', 'b', 'c', 'd']); //=> ['b', 'c']
|
|
1227
|
+
* R.slice(0, 3, 'ramda'); //=> 'ram'
|
|
1228
|
+
*/
|
|
1229
|
+
|
|
1230
|
+
var slice =
|
|
1231
|
+
/*#__PURE__*/
|
|
1232
|
+
_curry3(
|
|
1233
|
+
/*#__PURE__*/
|
|
1234
|
+
_checkForMethod('slice', function slice(fromIndex, toIndex, list) {
|
|
1235
|
+
return Array.prototype.slice.call(list, fromIndex, toIndex);
|
|
1236
|
+
}));
|
|
1237
|
+
|
|
1238
|
+
/**
|
|
1239
|
+
* Returns all but the first element of the given list or string (or object
|
|
1240
|
+
* with a `tail` method).
|
|
1241
|
+
*
|
|
1242
|
+
* Dispatches to the `slice` method of the first argument, if present.
|
|
1243
|
+
*
|
|
1244
|
+
* @func
|
|
1245
|
+
* @memberOf R
|
|
1246
|
+
* @since v0.1.0
|
|
1247
|
+
* @category List
|
|
1248
|
+
* @sig [a] -> [a]
|
|
1249
|
+
* @sig String -> String
|
|
1250
|
+
* @param {*} list
|
|
1251
|
+
* @return {*}
|
|
1252
|
+
* @see R.head, R.init, R.last
|
|
1253
|
+
* @example
|
|
1254
|
+
*
|
|
1255
|
+
* R.tail([1, 2, 3]); //=> [2, 3]
|
|
1256
|
+
* R.tail([1, 2]); //=> [2]
|
|
1257
|
+
* R.tail([1]); //=> []
|
|
1258
|
+
* R.tail([]); //=> []
|
|
1259
|
+
*
|
|
1260
|
+
* R.tail('abc'); //=> 'bc'
|
|
1261
|
+
* R.tail('ab'); //=> 'b'
|
|
1262
|
+
* R.tail('a'); //=> ''
|
|
1263
|
+
* R.tail(''); //=> ''
|
|
1264
|
+
*/
|
|
1265
|
+
|
|
1266
|
+
var tail =
|
|
1267
|
+
/*#__PURE__*/
|
|
1268
|
+
_curry1(
|
|
1269
|
+
/*#__PURE__*/
|
|
1270
|
+
_checkForMethod('tail',
|
|
1271
|
+
/*#__PURE__*/
|
|
1272
|
+
slice(1, Infinity)));
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* Performs left-to-right function composition. The first argument may have
|
|
1276
|
+
* any arity; the remaining arguments must be unary.
|
|
1277
|
+
*
|
|
1278
|
+
* In some libraries this function is named `sequence`.
|
|
1279
|
+
*
|
|
1280
|
+
* **Note:** The result of pipe is not automatically curried.
|
|
1281
|
+
*
|
|
1282
|
+
* @func
|
|
1283
|
+
* @memberOf R
|
|
1284
|
+
* @since v0.1.0
|
|
1285
|
+
* @category Function
|
|
1286
|
+
* @sig (((a, b, ..., n) -> o), (o -> p), ..., (x -> y), (y -> z)) -> ((a, b, ..., n) -> z)
|
|
1287
|
+
* @param {...Function} functions
|
|
1288
|
+
* @return {Function}
|
|
1289
|
+
* @see R.compose
|
|
1290
|
+
* @example
|
|
1291
|
+
*
|
|
1292
|
+
* const f = R.pipe(Math.pow, R.negate, R.inc);
|
|
1293
|
+
*
|
|
1294
|
+
* f(3, 4); // -(3^4) + 1
|
|
1295
|
+
* @symb R.pipe(f, g, h)(a, b) = h(g(f(a, b)))
|
|
1296
|
+
* @symb R.pipe(f, g, h)(a)(b) = h(g(f(a)))(b)
|
|
1297
|
+
*/
|
|
1298
|
+
|
|
1299
|
+
function pipe() {
|
|
1300
|
+
if (arguments.length === 0) {
|
|
1301
|
+
throw new Error('pipe requires at least one argument');
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
return _arity(arguments[0].length, reduce(_pipe, arguments[0], tail(arguments)));
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
function _identity(x) {
|
|
1308
|
+
return x;
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
/**
|
|
1312
|
+
* A function that does nothing but return the parameter supplied to it. Good
|
|
1313
|
+
* as a default or placeholder function.
|
|
1314
|
+
*
|
|
1315
|
+
* @func
|
|
1316
|
+
* @memberOf R
|
|
1317
|
+
* @since v0.1.0
|
|
1318
|
+
* @category Function
|
|
1319
|
+
* @sig a -> a
|
|
1320
|
+
* @param {*} x The value to return.
|
|
1321
|
+
* @return {*} The input value, `x`.
|
|
1322
|
+
* @example
|
|
1323
|
+
*
|
|
1324
|
+
* R.identity(1); //=> 1
|
|
1325
|
+
*
|
|
1326
|
+
* const obj = {};
|
|
1327
|
+
* R.identity(obj) === obj; //=> true
|
|
1328
|
+
* @symb R.identity(a) = a
|
|
1329
|
+
*/
|
|
1330
|
+
|
|
1331
|
+
var identity =
|
|
1332
|
+
/*#__PURE__*/
|
|
1333
|
+
_curry1(_identity);
|
|
1334
|
+
|
|
847
1335
|
function _arrayFromIterator(iter) {
|
|
848
1336
|
var list = [];
|
|
849
1337
|
var next;
|
|
@@ -1594,6 +2082,7 @@ const TertiaryButton$1 = styled.button `
|
|
|
1594
2082
|
`;
|
|
1595
2083
|
|
|
1596
2084
|
const Field$2 = styled.div `
|
|
2085
|
+
align-items: flex-start;
|
|
1597
2086
|
display: flex;
|
|
1598
2087
|
flex-direction: column;
|
|
1599
2088
|
`;
|
|
@@ -2299,6 +2788,25 @@ const FieldError = styled.p `
|
|
|
2299
2788
|
margin-top: 4px;
|
|
2300
2789
|
`;
|
|
2301
2790
|
|
|
2791
|
+
const useClickOutside = (zoneRefOrzoneRefs, action, baseContainer) => {
|
|
2792
|
+
const handleClickOutside = useCallback((event) => {
|
|
2793
|
+
const eventTarget = event.target;
|
|
2794
|
+
const zoneRefs = Array.isArray(zoneRefOrzoneRefs) ? zoneRefOrzoneRefs : [zoneRefOrzoneRefs];
|
|
2795
|
+
const isEventTargetInZones = pipe(map((zoneRef) => zoneRef.current.contains(eventTarget)), any(identity))(zoneRefs);
|
|
2796
|
+
if (isEventTargetInZones) {
|
|
2797
|
+
return;
|
|
2798
|
+
}
|
|
2799
|
+
action();
|
|
2800
|
+
}, [action, zoneRefOrzoneRefs]);
|
|
2801
|
+
useEffect(() => {
|
|
2802
|
+
const globalContainer = baseContainer ?? window.document;
|
|
2803
|
+
globalContainer.addEventListener('click', handleClickOutside);
|
|
2804
|
+
return () => {
|
|
2805
|
+
globalContainer.removeEventListener('click', handleClickOutside);
|
|
2806
|
+
};
|
|
2807
|
+
}, [baseContainer, handleClickOutside]);
|
|
2808
|
+
};
|
|
2809
|
+
|
|
2302
2810
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
2303
2811
|
|
|
2304
2812
|
/**
|
|
@@ -2771,12 +3279,14 @@ function normalizeString(text) {
|
|
|
2771
3279
|
return cleanText.length > 0 ? cleanText : undefined;
|
|
2772
3280
|
}
|
|
2773
3281
|
|
|
2774
|
-
function AutoComplete({ defaultValue, error, isLabelHidden, isLight = false, label, onChange, onQuery, options, queryMap, queryUrl, ...originalProps }) {
|
|
3282
|
+
function AutoComplete({ baseContainer, defaultValue, error, isLabelHidden, isLight = false, label, onChange, onQuery, options, queryMap, queryUrl, ...originalProps }) {
|
|
2775
3283
|
// eslint-disable-next-line no-null/no-null
|
|
2776
3284
|
const boxRef = useRef(null);
|
|
3285
|
+
const queryRef = useRef(undefined);
|
|
2777
3286
|
const prevDefaultValuePropRef = useRef(defaultValue);
|
|
2778
|
-
const [controlledDefaultValue, setDefaultControlledValue] = useState(defaultValue);
|
|
2779
3287
|
const [autoGeneratedOptions, setAutoGeneratedOptions] = useState([]);
|
|
3288
|
+
const [controlledDefaultValue, setDefaultControlledValue] = useState(defaultValue);
|
|
3289
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
2780
3290
|
const { forceUpdate } = useForceUpdate();
|
|
2781
3291
|
const controlledError = useMemo(() => normalizeString(error), [error]);
|
|
2782
3292
|
const controlledOptions = useMemo(() => options ?? autoGeneratedOptions, [autoGeneratedOptions, options]);
|
|
@@ -2786,19 +3296,23 @@ function AutoComplete({ defaultValue, error, isLabelHidden, isLight = false, lab
|
|
|
2786
3296
|
}, [controlledDefaultValue, controlledOptions]);
|
|
2787
3297
|
const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
|
|
2788
3298
|
const key = useMemo(() => `${originalProps.name}-${JSON.stringify(controlledDefaultValue)}`, [controlledDefaultValue, originalProps.name]);
|
|
3299
|
+
const close = useCallback(() => {
|
|
3300
|
+
setIsOpen(false);
|
|
3301
|
+
}, []);
|
|
2789
3302
|
const handleChange = useCallback(async (nextQuery) => {
|
|
2790
|
-
|
|
2791
|
-
|
|
3303
|
+
queryRef.current = normalizeString(nextQuery);
|
|
3304
|
+
if (queryUrl && queryMap && queryRef.current) {
|
|
3305
|
+
const url = queryUrl.replace('%s', queryRef.current);
|
|
2792
3306
|
const rawData = await ky$1.get(url).json();
|
|
2793
3307
|
const nextData = rawData.map(queryMap);
|
|
2794
3308
|
setAutoGeneratedOptions(nextData);
|
|
2795
3309
|
}
|
|
2796
|
-
|
|
2797
|
-
if (onChange && !
|
|
3310
|
+
setIsOpen(Boolean(queryRef.current));
|
|
3311
|
+
if (onChange && !queryRef.current) {
|
|
2798
3312
|
onChange(undefined);
|
|
2799
3313
|
}
|
|
2800
3314
|
if (onQuery) {
|
|
2801
|
-
onQuery(
|
|
3315
|
+
onQuery(queryRef.current);
|
|
2802
3316
|
}
|
|
2803
3317
|
}, [onChange, onQuery, queryMap, queryUrl]);
|
|
2804
3318
|
const handleSelect = useCallback((nextValue) => {
|
|
@@ -2807,16 +3321,23 @@ function AutoComplete({ defaultValue, error, isLabelHidden, isLight = false, lab
|
|
|
2807
3321
|
}
|
|
2808
3322
|
setDefaultControlledValue(nextValue);
|
|
2809
3323
|
}, [onChange]);
|
|
3324
|
+
const open = useCallback(() => {
|
|
3325
|
+
if (!queryRef.current) {
|
|
3326
|
+
return;
|
|
3327
|
+
}
|
|
3328
|
+
setIsOpen(true);
|
|
3329
|
+
}, []);
|
|
2810
3330
|
useEffect(() => {
|
|
2811
3331
|
if (defaultValue === prevDefaultValuePropRef.current) {
|
|
2812
3332
|
return;
|
|
2813
3333
|
}
|
|
2814
3334
|
setDefaultControlledValue(defaultValue);
|
|
2815
3335
|
}, [defaultValue]);
|
|
3336
|
+
useClickOutside(boxRef, close, baseContainer);
|
|
2816
3337
|
useEffect(() => {
|
|
2817
3338
|
forceUpdate();
|
|
2818
3339
|
}, [forceUpdate]);
|
|
2819
|
-
return (jsxs(Field$2, { children: [jsx(Label, { hasError: hasError, htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(Box$9, { ref: boxRef, children: boxRef.current && (jsx(StyledAutoComplete, { "$isLight": isLight, container: boxRef.current, data: controlledOptions, defaultValue: controlledValueAsLabel, id: originalProps.name, onChange: handleChange, onSelect: handleSelect, ...originalProps }, key)) }), hasError && jsx(FieldError, { children: controlledError })] }));
|
|
3340
|
+
return (jsxs(Field$2, { children: [jsx(Label, { hasError: hasError, htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(Box$9, { ref: boxRef, onClick: open, children: boxRef.current && (jsx(StyledAutoComplete, { "$isLight": isLight, container: boxRef.current, data: controlledOptions, defaultValue: controlledValueAsLabel, id: originalProps.name, onChange: handleChange, onSelect: handleSelect, open: isOpen, ...originalProps }, key)) }), hasError && jsx(FieldError, { children: controlledError })] }));
|
|
2820
3341
|
}
|
|
2821
3342
|
const StyledAutoComplete = styled(AutoComplete$1) `
|
|
2822
3343
|
font-size: 13px;
|
|
@@ -3445,6 +3966,7 @@ disabled = false, isCompact, isEndDate = false, isForcedFocused, isLight, isStar
|
|
|
3445
3966
|
const [isFocused, setIsFocused] = useState(false);
|
|
3446
3967
|
useImperativeHandle(ref, () => ({
|
|
3447
3968
|
box: boxRef.current,
|
|
3969
|
+
contains: boxRef.current.contains.bind(boxRef.current),
|
|
3448
3970
|
focus: (isInLastInputOfTheGroup = false) => {
|
|
3449
3971
|
if (isInLastInputOfTheGroup) {
|
|
3450
3972
|
yearInputRef.current.focus();
|
|
@@ -3621,7 +4143,7 @@ const Option = styled.div `
|
|
|
3621
4143
|
}
|
|
3622
4144
|
`;
|
|
3623
4145
|
|
|
3624
|
-
function TimeInputWithRef({ defaultValue,
|
|
4146
|
+
function TimeInputWithRef({ baseContainer, defaultValue,
|
|
3625
4147
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
3626
4148
|
disabled = false, isCompact, isEndDate = false, isLight, isStartDate = false, minutesRange = 15, onBack, onChange, onFocus, onNext, onPrevious }, ref) {
|
|
3627
4149
|
const boxRef = useRef();
|
|
@@ -3659,13 +4181,6 @@ disabled = false, isCompact, isEndDate = false, isLight, isStartDate = false, mi
|
|
|
3659
4181
|
const handleBlur = useCallback(() => {
|
|
3660
4182
|
setIsFocused(false);
|
|
3661
4183
|
}, []);
|
|
3662
|
-
const handleClickOutside = useCallback((event) => {
|
|
3663
|
-
const target = event.target;
|
|
3664
|
-
if (hourInputRef.current.contains(target) || minuteInputRef.current.contains(target)) {
|
|
3665
|
-
return;
|
|
3666
|
-
}
|
|
3667
|
-
closeRangedTimePicker();
|
|
3668
|
-
}, [closeRangedTimePicker]);
|
|
3669
4184
|
const handleFocus = useCallback(() => {
|
|
3670
4185
|
setIsFocused(true);
|
|
3671
4186
|
if (onFocus) {
|
|
@@ -3689,12 +4204,6 @@ disabled = false, isCompact, isEndDate = false, isLight, isStartDate = false, mi
|
|
|
3689
4204
|
isRangedTimePickerOpenRef.current = true;
|
|
3690
4205
|
forceUpdate();
|
|
3691
4206
|
}, [forceUpdate]);
|
|
3692
|
-
useEffect(() => {
|
|
3693
|
-
window.document.addEventListener('click', handleClickOutside);
|
|
3694
|
-
return () => {
|
|
3695
|
-
window.document.removeEventListener('click', handleClickOutside);
|
|
3696
|
-
};
|
|
3697
|
-
}, [handleClickOutside]);
|
|
3698
4207
|
const submit = useCallback(() => {
|
|
3699
4208
|
setHasValidationError(false);
|
|
3700
4209
|
if (window.document.activeElement === hourInputRef.current) {
|
|
@@ -3710,6 +4219,7 @@ disabled = false, isCompact, isEndDate = false, isLight, isStartDate = false, mi
|
|
|
3710
4219
|
const nextTimeTuple = [hourInputRef.current.value, minuteInputRef.current.value];
|
|
3711
4220
|
onChange(nextTimeTuple);
|
|
3712
4221
|
}, [closeRangedTimePicker, onChange]);
|
|
4222
|
+
useClickOutside(boxRef, closeRangedTimePicker, baseContainer);
|
|
3713
4223
|
return (jsxs(Box$6, { ref: boxRef, "$hasError": hasFormatError || hasValidationError, "$isCompact": isCompact, "$isDisabled": disabled, "$isFocused": isFocused, "$isLight": isLight, children: [jsxs(InputGroup, { children: [jsxs("div", { children: [jsx(NumberInput$1, { ref: hourInputRef, "aria-label": `Heure${isStartDate ? ' de début' : ''}${isEndDate ? ' de fin' : ''}`, defaultValue: controlledDefaultValue && controlledDefaultValue[0], disabled: disabled, isLight: isLight, max: 23, min: 0, onBack: handleBack, onBlur: handleBlur, onClick: openRangedTimePicker, onFilled: submit, onFocus: handleFocus, onFormatError: handleFormatError, onInput: handleHourInput, onNext: () => minuteInputRef.current.focus(), onPrevious: onPrevious, size: 2 }), ":", jsx(NumberInput$1, { ref: minuteInputRef, "aria-label": `Minute${isStartDate ? ' de début' : ''}${isEndDate ? ' de fin' : ''}`, defaultValue: controlledDefaultValue && controlledDefaultValue[1], disabled: disabled, isLight: isLight, max: 59, min: 0, onBack: () => hourInputRef.current.focus(), onBlur: handleBlur, onClick: openRangedTimePicker, onFilled: submit, onFocus: handleFocus, onFormatError: handleFormatError, onNext: onNext, onPrevious: () => hourInputRef.current.focus(), size: 2 })] }), !isCompact && jsx(Clock, {})] }), isRangedTimePickerOpenRef.current && (jsx(RangedTimePicker, { filter: rangedTimePickerFilter, minutesRange: minutesRange, onChange: handleRangedTimePickedChange }))] }));
|
|
3714
4224
|
}
|
|
3715
4225
|
const TimeInput = forwardRef(TimeInputWithRef);
|
|
@@ -3951,7 +4461,7 @@ const Box$5 = styled.div `
|
|
|
3951
4461
|
}
|
|
3952
4462
|
`;
|
|
3953
4463
|
|
|
3954
|
-
function DatePicker({ defaultValue,
|
|
4464
|
+
function DatePicker({ baseContainer, defaultValue,
|
|
3955
4465
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
3956
4466
|
disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false, isLight = false, label, minutesRange = 15, onChange, withTime = false, ...nativeProps }) {
|
|
3957
4467
|
const boxRef = useRef();
|
|
@@ -3978,13 +4488,6 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
3978
4488
|
isCalendarPickerOpenRef.current = false;
|
|
3979
4489
|
forceUpdate();
|
|
3980
4490
|
}, [forceUpdate]);
|
|
3981
|
-
const handleClickOutside = useCallback((event) => {
|
|
3982
|
-
const target = event.target;
|
|
3983
|
-
if (dateInputRef.current.box.contains(target)) {
|
|
3984
|
-
return;
|
|
3985
|
-
}
|
|
3986
|
-
closeCalendarPicker();
|
|
3987
|
-
}, [closeCalendarPicker]);
|
|
3988
4491
|
const handleDateInputNext = useCallback(() => {
|
|
3989
4492
|
if (!withTime) {
|
|
3990
4493
|
return;
|
|
@@ -4042,13 +4545,8 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
4042
4545
|
isCalendarPickerOpenRef.current = true;
|
|
4043
4546
|
forceUpdate();
|
|
4044
4547
|
}, [forceUpdate]);
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
return () => {
|
|
4048
|
-
window.document.removeEventListener('click', handleClickOutside);
|
|
4049
|
-
};
|
|
4050
|
-
}, [handleClickOutside]);
|
|
4051
|
-
return (jsxs(Fieldset, { disabled: disabled, ...nativeProps, children: [jsx(Legend, { isDisabled: disabled, isHidden: isLabelHidden, children: label }), jsxs(Box$4, { ref: boxRef, children: [jsx(Field$1, { children: jsx(DateInput, { ref: dateInputRef, defaultValue: selectedDateTupleRef.current, disabled: disabled, isCompact: isCompact, isForcedFocused: isCalendarPickerOpenRef.current, isLight: isLight, onChange: handleDateInputChange, onClick: openCalendarPicker, onNext: handleDateInputNext }) }), withTime && (jsx(Field$1, { "$isTimeField": true, children: jsx(TimeInput, { ref: timeInputRef, defaultValue: selectedTimeTupleRef.current, disabled: disabled, isCompact: isCompact, isLight: isLight, minutesRange: minutesRange, onBack: () => dateInputRef.current.focus(true), onChange: handleTimeInputFilled, onFocus: closeCalendarPicker, onPrevious: () => dateInputRef.current.focus(true) }) }))] }), jsx(CalendarPicker, { defaultValue: rangeCalendarPickerDefaultValue, isHistorical: isHistorical, isOpen: isCalendarPickerOpenRef.current, onChange: handleCalendarPickerChange })] }));
|
|
4548
|
+
useClickOutside(boxRef, closeCalendarPicker, baseContainer);
|
|
4549
|
+
return (jsxs(Fieldset, { disabled: disabled, ...nativeProps, children: [jsx(Legend, { isDisabled: disabled, isHidden: isLabelHidden, children: label }), jsxs(Box$4, { ref: boxRef, children: [jsx(Field$1, { children: jsx(DateInput, { ref: dateInputRef, defaultValue: selectedDateTupleRef.current, disabled: disabled, isCompact: isCompact, isForcedFocused: isCalendarPickerOpenRef.current, isLight: isLight, onChange: handleDateInputChange, onClick: openCalendarPicker, onNext: handleDateInputNext }) }), withTime && (jsx(Field$1, { "$isTimeField": true, children: jsx(TimeInput, { ref: timeInputRef, baseContainer: baseContainer, defaultValue: selectedTimeTupleRef.current, disabled: disabled, isCompact: isCompact, isLight: isLight, minutesRange: minutesRange, onBack: () => dateInputRef.current.focus(true), onChange: handleTimeInputFilled, onFocus: closeCalendarPicker, onPrevious: () => dateInputRef.current.focus(true) }) }))] }), jsx(CalendarPicker, { defaultValue: rangeCalendarPickerDefaultValue, isHistorical: isHistorical, isOpen: isCalendarPickerOpenRef.current, onChange: handleCalendarPickerChange })] }));
|
|
4052
4550
|
}
|
|
4053
4551
|
const Box$4 = styled.div `
|
|
4054
4552
|
* {
|
|
@@ -4269,7 +4767,7 @@ var DateRangePosition;
|
|
|
4269
4767
|
DateRangePosition["START"] = "START";
|
|
4270
4768
|
})(DateRangePosition || (DateRangePosition = {}));
|
|
4271
4769
|
|
|
4272
|
-
function DateRangePicker({ defaultValue,
|
|
4770
|
+
function DateRangePicker({ baseContainer, defaultValue,
|
|
4273
4771
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
4274
4772
|
disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false, isLight = false, label, minutesRange = 15, onChange, withTime = false, ...nativeProps }) {
|
|
4275
4773
|
const startDateInputRef = useRef();
|
|
@@ -4305,13 +4803,6 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
4305
4803
|
isRangeCalendarPickerOpenRef.current = false;
|
|
4306
4804
|
forceUpdate();
|
|
4307
4805
|
}, [forceUpdate]);
|
|
4308
|
-
const handleClickOutside = useCallback((event) => {
|
|
4309
|
-
const target = event.target;
|
|
4310
|
-
if (startDateInputRef.current.box.contains(target) || endDateInputRef.current.box.contains(target)) {
|
|
4311
|
-
return;
|
|
4312
|
-
}
|
|
4313
|
-
closeRangeCalendarPicker();
|
|
4314
|
-
}, [closeRangeCalendarPicker]);
|
|
4315
4806
|
const handleEndDateInputNext = useCallback(() => {
|
|
4316
4807
|
if (!withTime) {
|
|
4317
4808
|
return;
|
|
@@ -4418,13 +4909,8 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
4418
4909
|
isRangeCalendarPickerOpenRef.current = true;
|
|
4419
4910
|
forceUpdate();
|
|
4420
4911
|
}, [forceUpdate]);
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
return () => {
|
|
4424
|
-
window.document.removeEventListener('click', handleClickOutside);
|
|
4425
|
-
};
|
|
4426
|
-
}, [handleClickOutside]);
|
|
4427
|
-
return (jsxs(Fieldset, { ...nativeProps, children: [jsx(Legend, { isDisabled: disabled, isHidden: isLabelHidden, children: label }), jsxs(Box$2, { isDisabled: disabled, children: [jsx(Field, { children: jsx(DateInput, { ref: startDateInputRef, defaultValue: selectedStartDateTupleRef.current, disabled: disabled, isCompact: isCompact, isForcedFocused: isRangeCalendarPickerOpenRef.current, isLight: isLight, isStartDate: true, onChange: (nextDateTuple, isFilled) => handleDateInputChange(DateRangePosition.START, nextDateTuple, isFilled), onClick: openRangeCalendarPicker, onNext: handleStartDateInputNext }) }), withTime && (jsx(Field, { isTimeField: true, children: jsx(TimeInput, { ref: startTimeInputRef, defaultValue: selectedStartTimeTupleRef.current, disabled: disabled, isCompact: isCompact, isLight: isLight, isStartDate: true, minutesRange: minutesRange, onBack: () => startDateInputRef.current.focus(true), onChange: nextTimeTuple => handleTimeInputFilled(DateRangePosition.START, nextTimeTuple), onFocus: closeRangeCalendarPicker, onNext: () => endDateInputRef.current.focus(), onPrevious: () => startDateInputRef.current.focus(true) }) })), jsx(Field, { isEndDateField: true, children: jsx(DateInput, { ref: endDateInputRef, defaultValue: selectedEndDateTupleRef.current, disabled: disabled, isCompact: isCompact, isEndDate: true, isForcedFocused: isRangeCalendarPickerOpenRef.current, isLight: isLight, onBack: handleEndDateInputPrevious, onChange: (nextDateTuple, isFilled) => handleDateInputChange(DateRangePosition.END, nextDateTuple, isFilled), onClick: openRangeCalendarPicker, onNext: handleEndDateInputNext, onPrevious: handleEndDateInputPrevious }) }), withTime && (jsx(Field, { isTimeField: true, children: jsx(TimeInput, { ref: endTimeInputRef, defaultValue: selectedEndTimeTupleRef.current, disabled: disabled, isCompact: isCompact, isEndDate: true, isLight: isLight, minutesRange: minutesRange, onBack: () => endDateInputRef.current.focus(true), onChange: nextTimeTuple => handleTimeInputFilled(DateRangePosition.END, nextTimeTuple), onFocus: closeRangeCalendarPicker, onPrevious: () => endDateInputRef.current.focus(true) }) }))] }), jsx(RangeCalendarPicker, { defaultValue: rangeCalendarPickerDefaultValue, isHistorical: isHistorical, isOpen: isRangeCalendarPickerOpenRef.current, onChange: handleRangeCalendarPickerChange })] }));
|
|
4912
|
+
useClickOutside([endDateInputRef, startDateInputRef], closeRangeCalendarPicker, baseContainer);
|
|
4913
|
+
return (jsxs(Fieldset, { ...nativeProps, children: [jsx(Legend, { isDisabled: disabled, isHidden: isLabelHidden, children: label }), jsxs(Box$2, { isDisabled: disabled, children: [jsx(Field, { children: jsx(DateInput, { ref: startDateInputRef, defaultValue: selectedStartDateTupleRef.current, disabled: disabled, isCompact: isCompact, isForcedFocused: isRangeCalendarPickerOpenRef.current, isLight: isLight, isStartDate: true, onChange: (nextDateTuple, isFilled) => handleDateInputChange(DateRangePosition.START, nextDateTuple, isFilled), onClick: openRangeCalendarPicker, onNext: handleStartDateInputNext }) }), withTime && (jsx(Field, { isTimeField: true, children: jsx(TimeInput, { ref: startTimeInputRef, baseContainer: baseContainer, defaultValue: selectedStartTimeTupleRef.current, disabled: disabled, isCompact: isCompact, isLight: isLight, isStartDate: true, minutesRange: minutesRange, onBack: () => startDateInputRef.current.focus(true), onChange: nextTimeTuple => handleTimeInputFilled(DateRangePosition.START, nextTimeTuple), onFocus: closeRangeCalendarPicker, onNext: () => endDateInputRef.current.focus(), onPrevious: () => startDateInputRef.current.focus(true) }) })), jsx(Field, { isEndDateField: true, children: jsx(DateInput, { ref: endDateInputRef, defaultValue: selectedEndDateTupleRef.current, disabled: disabled, isCompact: isCompact, isEndDate: true, isForcedFocused: isRangeCalendarPickerOpenRef.current, isLight: isLight, onBack: handleEndDateInputPrevious, onChange: (nextDateTuple, isFilled) => handleDateInputChange(DateRangePosition.END, nextDateTuple, isFilled), onClick: openRangeCalendarPicker, onNext: handleEndDateInputNext, onPrevious: handleEndDateInputPrevious }) }), withTime && (jsx(Field, { isTimeField: true, children: jsx(TimeInput, { ref: endTimeInputRef, baseContainer: baseContainer, defaultValue: selectedEndTimeTupleRef.current, disabled: disabled, isCompact: isCompact, isEndDate: true, isLight: isLight, minutesRange: minutesRange, onBack: () => endDateInputRef.current.focus(true), onChange: nextTimeTuple => handleTimeInputFilled(DateRangePosition.END, nextTimeTuple), onFocus: closeRangeCalendarPicker, onPrevious: () => endDateInputRef.current.focus(true) }) }))] }), jsx(RangeCalendarPicker, { defaultValue: rangeCalendarPickerDefaultValue, isHistorical: isHistorical, isOpen: isRangeCalendarPickerOpenRef.current, onChange: handleRangeCalendarPickerChange })] }));
|
|
4428
4914
|
}
|
|
4429
4915
|
const Box$2 = styled.div `
|
|
4430
4916
|
* {
|
|
@@ -4492,15 +4978,19 @@ const ChecboxesBox$1 = styled.div `
|
|
|
4492
4978
|
`}
|
|
4493
4979
|
`;
|
|
4494
4980
|
|
|
4495
|
-
function MultiSelect({ error, fixedWidth = 5, isLabelHidden = false, isLight = false, label, onChange, options,
|
|
4981
|
+
function MultiSelect({ baseContainer, error, fixedWidth = 5, isLabelHidden = false, isLight = false, label, onChange, options,
|
|
4496
4982
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
4497
4983
|
searchable = false, ...originalProps }) {
|
|
4498
4984
|
// eslint-disable-next-line no-null/no-null
|
|
4499
4985
|
const boxRef = useRef(null);
|
|
4986
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
4500
4987
|
const { forceUpdate } = useForceUpdate();
|
|
4501
4988
|
const controlledError = useMemo(() => normalizeString(error), [error]);
|
|
4502
4989
|
const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
|
|
4503
4990
|
const key = useMemo(() => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`, [originalProps.defaultValue, originalProps.name]);
|
|
4991
|
+
const close = useCallback(() => {
|
|
4992
|
+
setIsOpen(false);
|
|
4993
|
+
}, []);
|
|
4504
4994
|
const handleChange = useCallback((nextValue) => {
|
|
4505
4995
|
if (!onChange) {
|
|
4506
4996
|
return;
|
|
@@ -4508,10 +4998,14 @@ searchable = false, ...originalProps }) {
|
|
|
4508
4998
|
const normalizedNextValue = !nextValue || !nextValue.length ? undefined : nextValue;
|
|
4509
4999
|
onChange(normalizedNextValue);
|
|
4510
5000
|
}, [onChange]);
|
|
5001
|
+
const open = useCallback(() => {
|
|
5002
|
+
setIsOpen(true);
|
|
5003
|
+
}, []);
|
|
5004
|
+
useClickOutside(boxRef, close, baseContainer);
|
|
4511
5005
|
useEffect(() => {
|
|
4512
5006
|
forceUpdate();
|
|
4513
5007
|
}, [forceUpdate]);
|
|
4514
|
-
return (jsxs(Field$2, { children: [jsx(Label, { hasError: hasError, htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(Box$1, { ref: boxRef, children: boxRef.current && (jsx(StyledTagPicker, { "$fixedWidth": fixedWidth, "$isLight": isLight, container: boxRef.current, data: options, id: originalProps.name, onChange: handleChange, searchable: searchable, ...originalProps }, key)) }), hasError && jsx(FieldError, { children: controlledError })] }));
|
|
5008
|
+
return (jsxs(Field$2, { children: [jsx(Label, { hasError: hasError, htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(Box$1, { ref: boxRef, onClick: open, children: boxRef.current && (jsx(StyledTagPicker, { "$fixedWidth": fixedWidth, "$isLight": isLight, container: boxRef.current, data: options, id: originalProps.name, onChange: handleChange, open: isOpen, searchable: searchable, ...originalProps }, key)) }), hasError && jsx(FieldError, { children: controlledError })] }));
|
|
4515
5009
|
}
|
|
4516
5010
|
// TODO A width seems to be mandatory in rsuite which is a very dirty behavior.
|
|
4517
5011
|
// We should hack that.
|
|
@@ -4706,15 +5200,19 @@ const StyledInput$2 = styled(Input) `
|
|
|
4706
5200
|
width: 100%;
|
|
4707
5201
|
`;
|
|
4708
5202
|
|
|
4709
|
-
function Select({ error, isLabelHidden = false, isLight = false, label, onChange, options,
|
|
5203
|
+
function Select({ baseContainer, error, isLabelHidden = false, isLight = false, label, onChange, options,
|
|
4710
5204
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
4711
5205
|
searchable = false, ...originalProps }) {
|
|
4712
5206
|
// eslint-disable-next-line no-null/no-null
|
|
4713
5207
|
const boxRef = useRef(null);
|
|
5208
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
4714
5209
|
const { forceUpdate } = useForceUpdate();
|
|
4715
5210
|
const controlledError = useMemo(() => normalizeString(error), [error]);
|
|
4716
5211
|
const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
|
|
4717
5212
|
const key = useMemo(() => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`, [originalProps.defaultValue, originalProps.name]);
|
|
5213
|
+
const close = useCallback(() => {
|
|
5214
|
+
setIsOpen(false);
|
|
5215
|
+
}, []);
|
|
4718
5216
|
const handleChange = useCallback((nextValue) => {
|
|
4719
5217
|
if (!onChange) {
|
|
4720
5218
|
return;
|
|
@@ -4722,13 +5220,17 @@ searchable = false, ...originalProps }) {
|
|
|
4722
5220
|
const normalizedNextValue = nextValue ?? undefined;
|
|
4723
5221
|
onChange(normalizedNextValue);
|
|
4724
5222
|
}, [onChange]);
|
|
5223
|
+
const open = useCallback(() => {
|
|
5224
|
+
setIsOpen(true);
|
|
5225
|
+
}, []);
|
|
5226
|
+
useClickOutside(boxRef, close, baseContainer);
|
|
4725
5227
|
useEffect(() => {
|
|
4726
5228
|
forceUpdate();
|
|
4727
5229
|
}, [forceUpdate]);
|
|
4728
|
-
return (jsxs(Field$2, { children: [jsx(Label, { hasError: hasError, htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(Box, { ref: boxRef, children: boxRef.current && (jsx(StyledSelectPicker, { "$isLight": isLight, container: boxRef.current, data: options, id: originalProps.name,
|
|
5230
|
+
return (jsxs(Field$2, { children: [jsx(Label, { hasError: hasError, htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(Box, { ref: boxRef, onClick: open, children: boxRef.current && (jsx(StyledSelectPicker, { "$isLight": isLight, container: boxRef.current, data: options, id: originalProps.name,
|
|
4729
5231
|
// The `unknown` type from Rsuite library is wrong. It should be inferred from `data` prop type.
|
|
4730
5232
|
// `onChange: ((value: unknown, event: React.SyntheticEvent<Element, Event>) => void) | undefined`
|
|
4731
|
-
onChange: handleChange, searchable: searchable, ...originalProps }, key)) }), hasError && jsx(FieldError, { children: controlledError })] }));
|
|
5233
|
+
onChange: handleChange, open: isOpen, searchable: searchable, ...originalProps }, key)) }), hasError && jsx(FieldError, { children: controlledError })] }));
|
|
4732
5234
|
}
|
|
4733
5235
|
const StyledSelectPicker = styled(SelectPicker) `
|
|
4734
5236
|
> .rs-picker-toggle {
|
|
@@ -4905,5 +5407,5 @@ function FormikTextInput({ name, ...originalProps }) {
|
|
|
4905
5407
|
return jsx(TextInput, { defaultValue: defaultValue, name: name, onChange: helpers.setValue, ...originalProps });
|
|
4906
5408
|
}
|
|
4907
5409
|
|
|
4908
|
-
export { Accent, AutoComplete, Button, Checkbox, DatePicker, DateRangePicker, Dropdown, Field$2 as Field, Fieldset, FormikAutoComplete, FormikCheckbox, FormikDatePicker, FormikDateRangePicker, FormikEffect, FormikMultiCheckbox, FormikMultiRadio, FormikMultiSelect, FormikNumberInput, FormikSelect, FormikTextInput, FormikTextarea, GlobalStyle, index as Icon, IconButton, Label, Legend, MultiCheckbox, MultiRadio, MultiSelect, MultiZoneEditor, NumberInput, OnlyFontGlobalStyle, Select, Size, THEME, Tag$1 as Tag, TagGroup, TextInput, Textarea, ThemeProvider };
|
|
5410
|
+
export { Accent, AutoComplete, Button, Checkbox, DatePicker, DateRangePicker, Dropdown, Field$2 as Field, Fieldset, FormikAutoComplete, FormikCheckbox, FormikDatePicker, FormikDateRangePicker, FormikEffect, FormikMultiCheckbox, FormikMultiRadio, FormikMultiSelect, FormikNumberInput, FormikSelect, FormikTextInput, FormikTextarea, GlobalStyle, index as Icon, IconButton, Label, Legend, MultiCheckbox, MultiRadio, MultiSelect, MultiZoneEditor, NumberInput, OnlyFontGlobalStyle, Select, Size, THEME, Tag$1 as Tag, TagGroup, TextInput, Textarea, ThemeProvider, useClickOutside, useForceUpdate };
|
|
4909
5411
|
//# sourceMappingURL=index.js.map
|