@mtes-mct/monitor-ui 2.5.1 → 2.7.0
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 +802 -134
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/NewWindow/index.d.ts +14 -0
- package/src/elements/FieldError.d.ts +7 -0
- package/src/elements/Label.d.ts +2 -0
- package/src/fields/AutoComplete.d.ts +5 -2
- package/src/fields/DatePicker/index.d.ts +3 -1
- package/src/fields/DateRangePicker/index.d.ts +3 -1
- package/src/fields/MultiSelect.d.ts +5 -2
- package/src/fields/Select.d.ts +5 -2
- package/src/hooks/useClickOutside.d.ts +3 -0
- package/src/index.d.ts +2 -0
- package/src/utils/cleanString.d.ts +4 -0
- package/src/utils/normalizeString.d.ts +4 -0
- package/src/utils/cleanInputString.d.ts +0 -4
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
|
|
|
@@ -89,7 +89,7 @@ const GlobalStyle = createGlobalStyle `
|
|
|
89
89
|
body {
|
|
90
90
|
font-family: Marianne, sans-serif;
|
|
91
91
|
font-size: 16px;
|
|
92
|
-
line-height: 1.
|
|
92
|
+
line-height: 1.3846;
|
|
93
93
|
}
|
|
94
94
|
`;
|
|
95
95
|
|
|
@@ -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,15 +2082,18 @@ 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
|
`;
|
|
1600
2089
|
|
|
1601
2090
|
const Label = styled.label `
|
|
1602
|
-
color: ${p =>
|
|
1603
|
-
|
|
2091
|
+
color: ${p =>
|
|
2092
|
+
// eslint-disable-next-line no-nested-ternary
|
|
2093
|
+
p.isDisabled ? p.theme.color.lightGray : p.hasError ? p.theme.color.maximumRed : p.theme.color.slateGray};
|
|
2094
|
+
display: ${p => (p.isHidden ? 'none' : 'block')};
|
|
1604
2095
|
font-size: 13px;
|
|
1605
|
-
line-height: 1.
|
|
2096
|
+
line-height: 1.3846;
|
|
1606
2097
|
margin-bottom: 4px;
|
|
1607
2098
|
`;
|
|
1608
2099
|
|
|
@@ -1615,14 +2106,14 @@ const StyledLabel = styled(Label) `
|
|
|
1615
2106
|
|
|
1616
2107
|
function Fieldset({ children, hasBorder = false, isHidden = false, isLight = false, legend, ...nativeProps }) {
|
|
1617
2108
|
const hasLegend = useMemo(() => Boolean(legend), [legend]);
|
|
1618
|
-
return (jsxs(StyledField, { as: "fieldset", ...nativeProps, children: [legend && jsx(Legend, { isHidden: isHidden, children: legend }), jsx(Box$
|
|
2109
|
+
return (jsxs(StyledField, { as: "fieldset", ...nativeProps, children: [legend && jsx(Legend, { isHidden: isHidden, children: legend }), jsx(Box$b, { "$hasBorder": hasBorder, "$hasLegend": hasLegend, "$isLight": isLight, children: children })] }));
|
|
1619
2110
|
}
|
|
1620
2111
|
const StyledField = styled(Field$2) `
|
|
1621
2112
|
border: 0;
|
|
1622
2113
|
margin: 0;
|
|
1623
2114
|
padding: 0;
|
|
1624
2115
|
`;
|
|
1625
|
-
const Box$
|
|
2116
|
+
const Box$b = styled.div `
|
|
1626
2117
|
background-color: ${p => (p.$isLight ? p.theme.color.white : 'transparent')};
|
|
1627
2118
|
padding: ${p => (p.$hasBorder || p.$isLight ? '16px' : 0)};
|
|
1628
2119
|
|
|
@@ -1727,17 +2218,17 @@ function Tag$1({ accent, bullet, children, color, Icon, isLight = false, ...nati
|
|
|
1727
2218
|
case Accent.TERTIARY:
|
|
1728
2219
|
return jsx(TertiaryTag, { ...commonProps });
|
|
1729
2220
|
default:
|
|
1730
|
-
return jsx(Box$
|
|
2221
|
+
return jsx(Box$a, { "$color": color, ...commonProps });
|
|
1731
2222
|
}
|
|
1732
2223
|
}
|
|
1733
|
-
const Box$
|
|
2224
|
+
const Box$a = styled.span `
|
|
1734
2225
|
align-items: center;
|
|
1735
2226
|
background-color: ${p => (p.$isLight ? p.theme.color.white : 'transparent')};
|
|
1736
2227
|
border-radius: 11px;
|
|
1737
2228
|
color: ${p => (p.$color ? p.$color : p.theme.color.gunMetal)};
|
|
1738
2229
|
display: inline-flex;
|
|
1739
2230
|
font-size: 13px;
|
|
1740
|
-
line-height: 1.
|
|
2231
|
+
line-height: 1.3846;
|
|
1741
2232
|
padding: 1px 8px 3px 8px;
|
|
1742
2233
|
|
|
1743
2234
|
/* Bullet components are a span */
|
|
@@ -1752,16 +2243,16 @@ const Box$7 = styled.span `
|
|
|
1752
2243
|
margin-right: 4px;
|
|
1753
2244
|
}
|
|
1754
2245
|
`;
|
|
1755
|
-
const PrimaryTag = styled(Box$
|
|
2246
|
+
const PrimaryTag = styled(Box$a) `
|
|
1756
2247
|
background-color: ${p => (p.$isLight ? p.theme.color.white : p.theme.color.gainsboro)};
|
|
1757
2248
|
color: ${p => p.theme.color.gunMetal};
|
|
1758
2249
|
`;
|
|
1759
2250
|
// TODO Fix this color.
|
|
1760
|
-
const SecondaryTag = styled(Box$
|
|
2251
|
+
const SecondaryTag = styled(Box$a) `
|
|
1761
2252
|
background-color: ${p => (p.$isLight ? '#f6d012' : '#f6d012')};
|
|
1762
2253
|
color: ${p => p.theme.color.gunMetal};
|
|
1763
2254
|
`;
|
|
1764
|
-
const TertiaryTag = styled(Box$
|
|
2255
|
+
const TertiaryTag = styled(Box$a) `
|
|
1765
2256
|
background-color: ${p => (p.$isLight ? p.theme.color.charcoal : p.theme.color.charcoal)};
|
|
1766
2257
|
color: ${p => p.theme.color.white};
|
|
1767
2258
|
`;
|
|
@@ -2288,78 +2779,33 @@ const createInstance = (defaults) => {
|
|
|
2288
2779
|
const ky = createInstance();
|
|
2289
2780
|
var ky$1 = ky;
|
|
2290
2781
|
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
const [autoGeneratedOptions, setAutoGeneratedOptions] = useState([]);
|
|
2295
|
-
const controlledOptions = useMemo(() => options ?? autoGeneratedOptions, [autoGeneratedOptions, options]);
|
|
2296
|
-
const controlledValueAsLabel = useMemo(() => {
|
|
2297
|
-
const foundOption = controlledOptions.find(propEq('value', controlledDefaultValue));
|
|
2298
|
-
return foundOption ? foundOption.label : undefined;
|
|
2299
|
-
}, [controlledDefaultValue, controlledOptions]);
|
|
2300
|
-
const key = useMemo(() => `${originalProps.name}-${JSON.stringify(controlledDefaultValue)}`, [controlledDefaultValue, originalProps.name]);
|
|
2301
|
-
const handleChange = useCallback(async (nextQuery) => {
|
|
2302
|
-
if (queryUrl && queryMap) {
|
|
2303
|
-
const url = queryUrl.replace('%s', nextQuery);
|
|
2304
|
-
const rawData = await ky$1.get(url).json();
|
|
2305
|
-
const nextData = rawData.map(queryMap);
|
|
2306
|
-
setAutoGeneratedOptions(nextData);
|
|
2307
|
-
}
|
|
2308
|
-
const normalizedNextQuery = nextQuery && nextQuery.trim().length ? nextQuery : undefined;
|
|
2309
|
-
if (onChange && !normalizedNextQuery) {
|
|
2310
|
-
onChange(undefined);
|
|
2311
|
-
}
|
|
2312
|
-
if (onQuery) {
|
|
2313
|
-
onQuery(normalizedNextQuery);
|
|
2314
|
-
}
|
|
2315
|
-
}, [onChange, onQuery, queryMap, queryUrl]);
|
|
2316
|
-
const handleSelect = useCallback((nextValue) => {
|
|
2317
|
-
if (onChange) {
|
|
2318
|
-
onChange(nextValue);
|
|
2319
|
-
}
|
|
2320
|
-
setDefaultControlledValue(nextValue);
|
|
2321
|
-
}, [onChange]);
|
|
2322
|
-
useEffect(() => {
|
|
2323
|
-
if (defaultValue === prevDefaultValuePropRef.current) {
|
|
2324
|
-
return;
|
|
2325
|
-
}
|
|
2326
|
-
setDefaultControlledValue(defaultValue);
|
|
2327
|
-
}, [defaultValue]);
|
|
2328
|
-
return (jsxs(Field$2, { children: [jsx(Label, { htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(StyledAutoComplete, { "$isLight": isLight, data: controlledOptions, defaultValue: controlledValueAsLabel, id: originalProps.name, onChange: handleChange, onSelect: handleSelect, ...originalProps }, key)] }));
|
|
2329
|
-
}
|
|
2330
|
-
const StyledAutoComplete = styled(AutoComplete$1) `
|
|
2782
|
+
const FieldError = styled.p `
|
|
2783
|
+
color: ${p => p.theme.color.maximumRed};
|
|
2784
|
+
display: ${p => (p.isDisabled ? 'none' : 'block')};
|
|
2331
2785
|
font-size: 13px;
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
border: 0;
|
|
2336
|
-
font-size: 13px;
|
|
2337
|
-
width: 100%;
|
|
2338
|
-
}
|
|
2786
|
+
font-weight: 700;
|
|
2787
|
+
line-height: 1.3846;
|
|
2788
|
+
margin-top: 4px;
|
|
2339
2789
|
`;
|
|
2340
2790
|
|
|
2341
|
-
|
|
2342
|
-
const
|
|
2343
|
-
|
|
2344
|
-
|
|
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) {
|
|
2345
2797
|
return;
|
|
2346
2798
|
}
|
|
2347
|
-
|
|
2348
|
-
}, [
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
.rs-checkbox-wrapper {
|
|
2358
|
-
left: 2px;
|
|
2359
|
-
top: 2px !important;
|
|
2360
|
-
}
|
|
2361
|
-
}
|
|
2362
|
-
`;
|
|
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
|
+
};
|
|
2363
2809
|
|
|
2364
2810
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
2365
2811
|
|
|
@@ -2815,6 +3261,135 @@ function useForceUpdate() {
|
|
|
2815
3261
|
return { forceDebouncedUpdate, forceUpdate };
|
|
2816
3262
|
}
|
|
2817
3263
|
|
|
3264
|
+
/**
|
|
3265
|
+
* Trim and single-space a string
|
|
3266
|
+
*/
|
|
3267
|
+
function cleanString(text) {
|
|
3268
|
+
return text.replace(/\s+/g, ' ').trim();
|
|
3269
|
+
}
|
|
3270
|
+
|
|
3271
|
+
/**
|
|
3272
|
+
* Normalize a string, making them undefined if empty-ish
|
|
3273
|
+
*/
|
|
3274
|
+
function normalizeString(text) {
|
|
3275
|
+
if (!text) {
|
|
3276
|
+
return undefined;
|
|
3277
|
+
}
|
|
3278
|
+
const cleanText = cleanString(text);
|
|
3279
|
+
return cleanText.length > 0 ? cleanText : undefined;
|
|
3280
|
+
}
|
|
3281
|
+
|
|
3282
|
+
function AutoComplete({ baseContainer, defaultValue, error, isLabelHidden, isLight = false, label, onChange, onQuery, options, queryMap, queryUrl, ...originalProps }) {
|
|
3283
|
+
// eslint-disable-next-line no-null/no-null
|
|
3284
|
+
const boxRef = useRef(null);
|
|
3285
|
+
const queryRef = useRef(undefined);
|
|
3286
|
+
const prevDefaultValuePropRef = useRef(defaultValue);
|
|
3287
|
+
const [autoGeneratedOptions, setAutoGeneratedOptions] = useState([]);
|
|
3288
|
+
const [controlledDefaultValue, setDefaultControlledValue] = useState(defaultValue);
|
|
3289
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
3290
|
+
const { forceUpdate } = useForceUpdate();
|
|
3291
|
+
const controlledError = useMemo(() => normalizeString(error), [error]);
|
|
3292
|
+
const controlledOptions = useMemo(() => options ?? autoGeneratedOptions, [autoGeneratedOptions, options]);
|
|
3293
|
+
const controlledValueAsLabel = useMemo(() => {
|
|
3294
|
+
const foundOption = controlledOptions.find(propEq('value', controlledDefaultValue));
|
|
3295
|
+
return foundOption ? foundOption.label : undefined;
|
|
3296
|
+
}, [controlledDefaultValue, controlledOptions]);
|
|
3297
|
+
const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
|
|
3298
|
+
const key = useMemo(() => `${originalProps.name}-${JSON.stringify(controlledDefaultValue)}`, [controlledDefaultValue, originalProps.name]);
|
|
3299
|
+
const close = useCallback(() => {
|
|
3300
|
+
setIsOpen(false);
|
|
3301
|
+
}, []);
|
|
3302
|
+
const handleChange = useCallback(async (nextQuery) => {
|
|
3303
|
+
queryRef.current = normalizeString(nextQuery);
|
|
3304
|
+
if (queryUrl && queryMap && queryRef.current) {
|
|
3305
|
+
const url = queryUrl.replace('%s', queryRef.current);
|
|
3306
|
+
const rawData = await ky$1.get(url).json();
|
|
3307
|
+
const nextData = rawData.map(queryMap);
|
|
3308
|
+
setAutoGeneratedOptions(nextData);
|
|
3309
|
+
}
|
|
3310
|
+
setIsOpen(Boolean(queryRef.current));
|
|
3311
|
+
if (onChange && !queryRef.current) {
|
|
3312
|
+
onChange(undefined);
|
|
3313
|
+
}
|
|
3314
|
+
if (onQuery) {
|
|
3315
|
+
onQuery(queryRef.current);
|
|
3316
|
+
}
|
|
3317
|
+
}, [onChange, onQuery, queryMap, queryUrl]);
|
|
3318
|
+
const handleSelect = useCallback((nextValue) => {
|
|
3319
|
+
if (onChange) {
|
|
3320
|
+
onChange(nextValue);
|
|
3321
|
+
}
|
|
3322
|
+
setDefaultControlledValue(nextValue);
|
|
3323
|
+
}, [onChange]);
|
|
3324
|
+
const open = useCallback(() => {
|
|
3325
|
+
if (!queryRef.current) {
|
|
3326
|
+
return;
|
|
3327
|
+
}
|
|
3328
|
+
setIsOpen(true);
|
|
3329
|
+
}, []);
|
|
3330
|
+
useEffect(() => {
|
|
3331
|
+
if (defaultValue === prevDefaultValuePropRef.current) {
|
|
3332
|
+
return;
|
|
3333
|
+
}
|
|
3334
|
+
setDefaultControlledValue(defaultValue);
|
|
3335
|
+
}, [defaultValue]);
|
|
3336
|
+
useClickOutside(boxRef, close, baseContainer);
|
|
3337
|
+
useEffect(() => {
|
|
3338
|
+
forceUpdate();
|
|
3339
|
+
}, [forceUpdate]);
|
|
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 })] }));
|
|
3341
|
+
}
|
|
3342
|
+
const StyledAutoComplete = styled(AutoComplete$1) `
|
|
3343
|
+
font-size: 13px;
|
|
3344
|
+
|
|
3345
|
+
> input {
|
|
3346
|
+
background-color: ${p => (p.$isLight ? p.theme.color.white : p.theme.color.gainsboro)};
|
|
3347
|
+
border: 0;
|
|
3348
|
+
font-size: 13px;
|
|
3349
|
+
width: 100%;
|
|
3350
|
+
}
|
|
3351
|
+
`;
|
|
3352
|
+
const Box$9 = styled.div `
|
|
3353
|
+
position: relative;
|
|
3354
|
+
|
|
3355
|
+
> .rs-picker-select {
|
|
3356
|
+
> .rs-picker-toggle {
|
|
3357
|
+
font-size: 13px;
|
|
3358
|
+
|
|
3359
|
+
> .rs-stack {
|
|
3360
|
+
> .rs-stack-item {
|
|
3361
|
+
> .rs-picker-toggle-placeholder {
|
|
3362
|
+
font-size: 13px;
|
|
3363
|
+
}
|
|
3364
|
+
}
|
|
3365
|
+
}
|
|
3366
|
+
}
|
|
3367
|
+
}
|
|
3368
|
+
`;
|
|
3369
|
+
|
|
3370
|
+
function Checkbox({ label, onChange, ...originalProps }) {
|
|
3371
|
+
const key = useMemo(() => `${originalProps.name}-${String(originalProps.defaultChecked)}`, [originalProps.defaultChecked, originalProps.name]);
|
|
3372
|
+
const handleChange = useCallback((_, isChecked) => {
|
|
3373
|
+
if (!onChange) {
|
|
3374
|
+
return;
|
|
3375
|
+
}
|
|
3376
|
+
onChange(isChecked);
|
|
3377
|
+
}, [onChange]);
|
|
3378
|
+
return (jsx(StyledCheckbox, { id: originalProps.name, onChange: handleChange, ...originalProps, children: label }, key));
|
|
3379
|
+
}
|
|
3380
|
+
const StyledCheckbox = styled(Checkbox$1) `
|
|
3381
|
+
> .rs-checkbox-checker {
|
|
3382
|
+
min-height: 0;
|
|
3383
|
+
padding-left: 28px;
|
|
3384
|
+
padding-top: 0;
|
|
3385
|
+
|
|
3386
|
+
.rs-checkbox-wrapper {
|
|
3387
|
+
left: 2px;
|
|
3388
|
+
top: 2px !important;
|
|
3389
|
+
}
|
|
3390
|
+
}
|
|
3391
|
+
`;
|
|
3392
|
+
|
|
2818
3393
|
var dayjs_min = {exports: {}};
|
|
2819
3394
|
|
|
2820
3395
|
var hasRequiredDayjs_min;
|
|
@@ -3391,6 +3966,7 @@ disabled = false, isCompact, isEndDate = false, isForcedFocused, isLight, isStar
|
|
|
3391
3966
|
const [isFocused, setIsFocused] = useState(false);
|
|
3392
3967
|
useImperativeHandle(ref, () => ({
|
|
3393
3968
|
box: boxRef.current,
|
|
3969
|
+
contains: boxRef.current.contains.bind(boxRef.current),
|
|
3394
3970
|
focus: (isInLastInputOfTheGroup = false) => {
|
|
3395
3971
|
if (isInLastInputOfTheGroup) {
|
|
3396
3972
|
yearInputRef.current.focus();
|
|
@@ -3437,10 +4013,10 @@ disabled = false, isCompact, isEndDate = false, isForcedFocused, isLight, isStar
|
|
|
3437
4013
|
];
|
|
3438
4014
|
onChange(nextDateTuple, isFilled);
|
|
3439
4015
|
}, [onChange]);
|
|
3440
|
-
return (jsxs(Box$
|
|
4016
|
+
return (jsxs(Box$8, { ref: boxRef, "$hasError": hasFormatError || hasValidationError, "$isCompact": isCompact, "$isDisabled": disabled, "$isFocused": isForcedFocused || isFocused, "$isLight": isLight, children: [jsxs("div", { children: [isStartDate && jsx("span", { children: "Du " }), isEndDate && jsx("span", { children: "Au " }), jsx(NumberInput$1, { ref: dayInputRef, "aria-label": `Jour${isStartDate ? ' de début' : ''}${isEndDate ? ' de fin' : ''}`, defaultValue: defaultValue && formatNumberAsDoubleDigit(defaultValue[2]), disabled: disabled, isLight: isLight, max: 31, min: 1, onBack: onBack, onBlur: handleBlur, onClick: onClick, onFilled: submit, onFocus: handleFocus, onFormatError: handleFormatError, onNext: () => monthInputRef.current.focus(), onPrevious: onPrevious, size: 2 }), "/", jsx(NumberInput$1, { ref: monthInputRef, "aria-label": `Mois${isStartDate ? ' de début' : ''}${isEndDate ? ' de fin' : ''}`, defaultValue: defaultValue && formatNumberAsDoubleDigit(defaultValue[1]), disabled: disabled, isLight: isLight, max: 12, min: 1, onBack: () => dayInputRef.current.focus(), onBlur: handleBlur, onClick: onClick, onFilled: submit, onFocus: handleFocus, onFormatError: handleFormatError, onNext: () => yearInputRef.current.focus(), onPrevious: () => dayInputRef.current.focus(), size: 2 }), "/", jsx(NumberInput$1, { ref: yearInputRef, "aria-label": `Année${isStartDate ? ' de début' : ''}${isEndDate ? ' de fin' : ''}`, defaultValue: defaultValue && defaultValue[0], disabled: disabled, isLight: isLight, max: 2030, min: 2020, onBack: () => monthInputRef.current.focus(), onBlur: handleBlur, onClick: onClick, onFilled: submit, onFocus: handleFocus, onFormatError: handleFormatError, onNext: onNext, onPrevious: () => monthInputRef.current.focus(), size: 4 })] }), !isCompact && jsx(Calendar, {})] }));
|
|
3441
4017
|
}
|
|
3442
4018
|
const DateInput = forwardRef(DateInputWithRef);
|
|
3443
|
-
const Box$
|
|
4019
|
+
const Box$8 = styled.div `
|
|
3444
4020
|
align-items: center;
|
|
3445
4021
|
background-color: ${p => (p.$isLight ? p.theme.color.white : p.theme.color.gainsboro)};
|
|
3446
4022
|
box-shadow: ${p => p.$hasError || p.$isFocused
|
|
@@ -3517,9 +4093,9 @@ function RangedTimePicker({ filter, minutesRange, onChange }) {
|
|
|
3517
4093
|
if (!filteredRangedTimeOptions.length) {
|
|
3518
4094
|
return jsx(Fragment, {});
|
|
3519
4095
|
}
|
|
3520
|
-
return (jsx(Box$
|
|
4096
|
+
return (jsx(Box$7, { onClick: stopMouseEventPropagation, role: "listbox", children: filteredRangedTimeOptions.map(({ label, value }, index) => (jsx(Option, { "aria-selected": false, className: "js-ranged-time-picker-option", isSelected: index === selectedOptionIndex, onClick: () => onChange(value), role: "option", tabIndex: -1, children: spannedLabels[index] }, label))) }));
|
|
3521
4097
|
}
|
|
3522
|
-
const Box$
|
|
4098
|
+
const Box$7 = styled.div `
|
|
3523
4099
|
background-color: ${p => p.theme.color.white};
|
|
3524
4100
|
box-shadow: inset 0px 0px 0px 1px ${p => p.theme.color.lightGray};
|
|
3525
4101
|
display: flex;
|
|
@@ -3656,10 +4232,10 @@ disabled = false, isCompact, isEndDate = false, isLight, isStartDate = false, mi
|
|
|
3656
4232
|
const nextTimeTuple = [hourInputRef.current.value, minuteInputRef.current.value];
|
|
3657
4233
|
onChange(nextTimeTuple);
|
|
3658
4234
|
}, [closeRangedTimePicker, onChange]);
|
|
3659
|
-
return (jsxs(Box$
|
|
4235
|
+
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 }))] }));
|
|
3660
4236
|
}
|
|
3661
4237
|
const TimeInput = forwardRef(TimeInputWithRef);
|
|
3662
|
-
const Box$
|
|
4238
|
+
const Box$6 = styled.div `
|
|
3663
4239
|
background-color: ${p => (p.$isLight ? p.theme.color.white : p.theme.color.gainsboro)};
|
|
3664
4240
|
box-shadow: ${p => p.$hasError || p.$isFocused
|
|
3665
4241
|
? `inset 0px 0px 0px 1px ${p.$hasError ? p.theme.color.maximumRed : p.theme.color.blueGray[100]}`
|
|
@@ -3738,11 +4314,11 @@ function CalendarPicker({ defaultValue, isHistorical, isOpen, onChange }) {
|
|
|
3738
4314
|
// and can be used as a container for <RsuiteDatePicker />
|
|
3739
4315
|
forceUpdate();
|
|
3740
4316
|
}, [forceUpdate]);
|
|
3741
|
-
return (jsx(Box$
|
|
4317
|
+
return (jsx(Box$5, { ref: boxRef, onClick: stopMouseEventPropagation, children: boxRef.current && (jsx(DatePicker$1, { container: boxRef.current, disabledDate: disabledDate, format: "yyyy-MM-dd", locale: RSUITE_CALENDAR_LOCALE, oneTap: true, onSelect: handleSelect, open: isOpen,
|
|
3742
4318
|
// `defaultValue` seems to be immediatly cancelled so we come down to using a controlled `value`
|
|
3743
4319
|
ranges: [], value: defaultValue })) }));
|
|
3744
4320
|
}
|
|
3745
|
-
const Box$
|
|
4321
|
+
const Box$5 = styled.div `
|
|
3746
4322
|
height: 0;
|
|
3747
4323
|
position: relative;
|
|
3748
4324
|
user-select: none;
|
|
@@ -3780,7 +4356,7 @@ const Box$3 = styled.div `
|
|
|
3780
4356
|
border: 0;
|
|
3781
4357
|
font-size: 13px;
|
|
3782
4358
|
height: auto !important;
|
|
3783
|
-
line-height: 1.
|
|
4359
|
+
line-height: 1.3846;
|
|
3784
4360
|
padding: 0;
|
|
3785
4361
|
|
|
3786
4362
|
> .rs-calendar-header {
|
|
@@ -3897,7 +4473,7 @@ const Box$3 = styled.div `
|
|
|
3897
4473
|
}
|
|
3898
4474
|
`;
|
|
3899
4475
|
|
|
3900
|
-
function DatePicker({ defaultValue,
|
|
4476
|
+
function DatePicker({ baseContainer, defaultValue,
|
|
3901
4477
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
3902
4478
|
disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false, isLight = false, label, minutesRange = 15, onChange, withTime = false, ...nativeProps }) {
|
|
3903
4479
|
const boxRef = useRef();
|
|
@@ -3924,13 +4500,6 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
3924
4500
|
isCalendarPickerOpenRef.current = false;
|
|
3925
4501
|
forceUpdate();
|
|
3926
4502
|
}, [forceUpdate]);
|
|
3927
|
-
const handleClickOutside = useCallback((event) => {
|
|
3928
|
-
const target = event.target;
|
|
3929
|
-
if (dateInputRef.current.box.contains(target)) {
|
|
3930
|
-
return;
|
|
3931
|
-
}
|
|
3932
|
-
closeCalendarPicker();
|
|
3933
|
-
}, [closeCalendarPicker]);
|
|
3934
4503
|
const handleDateInputNext = useCallback(() => {
|
|
3935
4504
|
if (!withTime) {
|
|
3936
4505
|
return;
|
|
@@ -3988,15 +4557,10 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
3988
4557
|
isCalendarPickerOpenRef.current = true;
|
|
3989
4558
|
forceUpdate();
|
|
3990
4559
|
}, [forceUpdate]);
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
return () => {
|
|
3994
|
-
window.document.removeEventListener('click', handleClickOutside);
|
|
3995
|
-
};
|
|
3996
|
-
}, [handleClickOutside]);
|
|
3997
|
-
return (jsxs(Fieldset, { disabled: disabled, ...nativeProps, children: [jsx(Legend, { isDisabled: disabled, isHidden: isLabelHidden, children: label }), jsxs(Box$2, { 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 })] }));
|
|
4560
|
+
useClickOutside(boxRef, closeCalendarPicker, baseContainer);
|
|
4561
|
+
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 })] }));
|
|
3998
4562
|
}
|
|
3999
|
-
const Box$
|
|
4563
|
+
const Box$4 = styled.div `
|
|
4000
4564
|
* {
|
|
4001
4565
|
font-weight: 500;
|
|
4002
4566
|
line-height: 1;
|
|
@@ -4042,11 +4606,11 @@ function RangeCalendarPicker({ defaultValue, isHistorical, isOpen, onChange }) {
|
|
|
4042
4606
|
// and can be used as a container for <RsuiteDateRangePicker />
|
|
4043
4607
|
forceUpdate();
|
|
4044
4608
|
}, [forceUpdate]);
|
|
4045
|
-
return (jsx(Box$
|
|
4609
|
+
return (jsx(Box$3, { ref: boxRef, onClick: stopMouseEventPropagation, children: boxRef.current && (jsx(DateRangePicker$1, { container: boxRef.current, disabledDate: disabledDate, format: "yyyy-MM-dd", locale: RSUITE_CALENDAR_LOCALE, onSelect: handleSelect, open: isOpen, ranges: [],
|
|
4046
4610
|
// `defaultValue` seems to be immediatly cancelled so we come down to using a controlled `value`
|
|
4047
4611
|
value: controlledValue })) }));
|
|
4048
4612
|
}
|
|
4049
|
-
const Box$
|
|
4613
|
+
const Box$3 = styled.div `
|
|
4050
4614
|
height: 0;
|
|
4051
4615
|
position: relative;
|
|
4052
4616
|
user-select: none;
|
|
@@ -4087,7 +4651,7 @@ const Box$1 = styled.div `
|
|
|
4087
4651
|
> .rs-calendar {
|
|
4088
4652
|
font-size: 13px;
|
|
4089
4653
|
height: auto !important;
|
|
4090
|
-
line-height: 1.
|
|
4654
|
+
line-height: 1.3846;
|
|
4091
4655
|
padding: 0;
|
|
4092
4656
|
|
|
4093
4657
|
&:first-child {
|
|
@@ -4215,7 +4779,7 @@ var DateRangePosition;
|
|
|
4215
4779
|
DateRangePosition["START"] = "START";
|
|
4216
4780
|
})(DateRangePosition || (DateRangePosition = {}));
|
|
4217
4781
|
|
|
4218
|
-
function DateRangePicker({ defaultValue,
|
|
4782
|
+
function DateRangePicker({ baseContainer, defaultValue,
|
|
4219
4783
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
4220
4784
|
disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false, isLight = false, label, minutesRange = 15, onChange, withTime = false, ...nativeProps }) {
|
|
4221
4785
|
const startDateInputRef = useRef();
|
|
@@ -4251,13 +4815,6 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
4251
4815
|
isRangeCalendarPickerOpenRef.current = false;
|
|
4252
4816
|
forceUpdate();
|
|
4253
4817
|
}, [forceUpdate]);
|
|
4254
|
-
const handleClickOutside = useCallback((event) => {
|
|
4255
|
-
const target = event.target;
|
|
4256
|
-
if (startDateInputRef.current.box.contains(target) || endDateInputRef.current.box.contains(target)) {
|
|
4257
|
-
return;
|
|
4258
|
-
}
|
|
4259
|
-
closeRangeCalendarPicker();
|
|
4260
|
-
}, [closeRangeCalendarPicker]);
|
|
4261
4818
|
const handleEndDateInputNext = useCallback(() => {
|
|
4262
4819
|
if (!withTime) {
|
|
4263
4820
|
return;
|
|
@@ -4364,15 +4921,10 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
4364
4921
|
isRangeCalendarPickerOpenRef.current = true;
|
|
4365
4922
|
forceUpdate();
|
|
4366
4923
|
}, [forceUpdate]);
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
return () => {
|
|
4370
|
-
window.document.removeEventListener('click', handleClickOutside);
|
|
4371
|
-
};
|
|
4372
|
-
}, [handleClickOutside]);
|
|
4373
|
-
return (jsxs(Fieldset, { ...nativeProps, children: [jsx(Legend, { isDisabled: disabled, isHidden: isLabelHidden, children: label }), jsxs(Box, { 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 })] }));
|
|
4924
|
+
useClickOutside([endDateInputRef, startDateInputRef], closeRangeCalendarPicker, baseContainer);
|
|
4925
|
+
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 })] }));
|
|
4374
4926
|
}
|
|
4375
|
-
const Box = styled.div `
|
|
4927
|
+
const Box$2 = styled.div `
|
|
4376
4928
|
* {
|
|
4377
4929
|
font-weight: 500;
|
|
4378
4930
|
line-height: 1;
|
|
@@ -4438,10 +4990,19 @@ const ChecboxesBox$1 = styled.div `
|
|
|
4438
4990
|
`}
|
|
4439
4991
|
`;
|
|
4440
4992
|
|
|
4441
|
-
function MultiSelect({ fixedWidth = 5, isLabelHidden = false, isLight = false, label, onChange, options,
|
|
4993
|
+
function MultiSelect({ baseContainer, error, fixedWidth = 5, isLabelHidden = false, isLight = false, label, onChange, options,
|
|
4442
4994
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
4443
4995
|
searchable = false, ...originalProps }) {
|
|
4996
|
+
// eslint-disable-next-line no-null/no-null
|
|
4997
|
+
const boxRef = useRef(null);
|
|
4998
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
4999
|
+
const { forceUpdate } = useForceUpdate();
|
|
5000
|
+
const controlledError = useMemo(() => normalizeString(error), [error]);
|
|
5001
|
+
const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
|
|
4444
5002
|
const key = useMemo(() => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`, [originalProps.defaultValue, originalProps.name]);
|
|
5003
|
+
const close = useCallback(() => {
|
|
5004
|
+
setIsOpen(false);
|
|
5005
|
+
}, []);
|
|
4445
5006
|
const handleChange = useCallback((nextValue) => {
|
|
4446
5007
|
if (!onChange) {
|
|
4447
5008
|
return;
|
|
@@ -4449,7 +5010,14 @@ searchable = false, ...originalProps }) {
|
|
|
4449
5010
|
const normalizedNextValue = !nextValue || !nextValue.length ? undefined : nextValue;
|
|
4450
5011
|
onChange(normalizedNextValue);
|
|
4451
5012
|
}, [onChange]);
|
|
4452
|
-
|
|
5013
|
+
const open = useCallback(() => {
|
|
5014
|
+
setIsOpen(true);
|
|
5015
|
+
}, []);
|
|
5016
|
+
useClickOutside(boxRef, close, baseContainer);
|
|
5017
|
+
useEffect(() => {
|
|
5018
|
+
forceUpdate();
|
|
5019
|
+
}, [forceUpdate]);
|
|
5020
|
+
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 })] }));
|
|
4453
5021
|
}
|
|
4454
5022
|
// TODO A width seems to be mandatory in rsuite which is a very dirty behavior.
|
|
4455
5023
|
// We should hack that.
|
|
@@ -4463,6 +5031,54 @@ const StyledTagPicker = styled(TagPicker) `
|
|
|
4463
5031
|
cursor: inherit;
|
|
4464
5032
|
}
|
|
4465
5033
|
`;
|
|
5034
|
+
const Box$1 = styled.div `
|
|
5035
|
+
position: relative;
|
|
5036
|
+
|
|
5037
|
+
> .rs-picker-input {
|
|
5038
|
+
> .rs-picker-toggle {
|
|
5039
|
+
border: solid 1px ${p => p.theme.color.gainsboro} !important;
|
|
5040
|
+
font-size: 13px;
|
|
5041
|
+
line-height: 1.3846;
|
|
5042
|
+
padding: 5px 40px 5px 8px !important;
|
|
5043
|
+
|
|
5044
|
+
:hover {
|
|
5045
|
+
border: solid 1px ${p => p.theme.color.blueYonder[100]} !important;
|
|
5046
|
+
}
|
|
5047
|
+
|
|
5048
|
+
:active,
|
|
5049
|
+
:focus {
|
|
5050
|
+
border: solid 1px ${p => p.theme.color.blueGray[100]} !important;
|
|
5051
|
+
}
|
|
5052
|
+
|
|
5053
|
+
> .rs-stack {
|
|
5054
|
+
> .rs-stack-item {
|
|
5055
|
+
> .rs-picker-toggle-placeholder {
|
|
5056
|
+
font-size: 13px;
|
|
5057
|
+
line-height: 1.3846;
|
|
5058
|
+
}
|
|
5059
|
+
|
|
5060
|
+
> svg {
|
|
5061
|
+
height: 18px;
|
|
5062
|
+
/* margin-top: -2px; */
|
|
5063
|
+
}
|
|
5064
|
+
}
|
|
5065
|
+
}
|
|
5066
|
+
}
|
|
5067
|
+
|
|
5068
|
+
> .rs-picker-tag-wrapper {
|
|
5069
|
+
.rs-picker-search {
|
|
5070
|
+
.rs-picker-search-input {
|
|
5071
|
+
padding: 0 8px !important;
|
|
5072
|
+
|
|
5073
|
+
input {
|
|
5074
|
+
font-size: 13px;
|
|
5075
|
+
line-height: 1.3846;
|
|
5076
|
+
}
|
|
5077
|
+
}
|
|
5078
|
+
}
|
|
5079
|
+
}
|
|
5080
|
+
}
|
|
5081
|
+
`;
|
|
4466
5082
|
|
|
4467
5083
|
function MultiRadio({ defaultValue, isInline = false, isLabelHidden = false, isLight = false, label, name, onChange, options }) {
|
|
4468
5084
|
const [checkedOptionValue, setCheckedOptionValue] = useState(undefined);
|
|
@@ -4596,10 +5212,19 @@ const StyledInput$2 = styled(Input) `
|
|
|
4596
5212
|
width: 100%;
|
|
4597
5213
|
`;
|
|
4598
5214
|
|
|
4599
|
-
function Select({ isLabelHidden = false, isLight = false, label, onChange, options,
|
|
5215
|
+
function Select({ baseContainer, error, isLabelHidden = false, isLight = false, label, onChange, options,
|
|
4600
5216
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
4601
5217
|
searchable = false, ...originalProps }) {
|
|
5218
|
+
// eslint-disable-next-line no-null/no-null
|
|
5219
|
+
const boxRef = useRef(null);
|
|
5220
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
5221
|
+
const { forceUpdate } = useForceUpdate();
|
|
5222
|
+
const controlledError = useMemo(() => normalizeString(error), [error]);
|
|
5223
|
+
const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
|
|
4602
5224
|
const key = useMemo(() => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`, [originalProps.defaultValue, originalProps.name]);
|
|
5225
|
+
const close = useCallback(() => {
|
|
5226
|
+
setIsOpen(false);
|
|
5227
|
+
}, []);
|
|
4603
5228
|
const handleChange = useCallback((nextValue) => {
|
|
4604
5229
|
if (!onChange) {
|
|
4605
5230
|
return;
|
|
@@ -4607,10 +5232,17 @@ searchable = false, ...originalProps }) {
|
|
|
4607
5232
|
const normalizedNextValue = nextValue ?? undefined;
|
|
4608
5233
|
onChange(normalizedNextValue);
|
|
4609
5234
|
}, [onChange]);
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
5235
|
+
const open = useCallback(() => {
|
|
5236
|
+
setIsOpen(true);
|
|
5237
|
+
}, []);
|
|
5238
|
+
useClickOutside(boxRef, close, baseContainer);
|
|
5239
|
+
useEffect(() => {
|
|
5240
|
+
forceUpdate();
|
|
5241
|
+
}, [forceUpdate]);
|
|
5242
|
+
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,
|
|
5243
|
+
// The `unknown` type from Rsuite library is wrong. It should be inferred from `data` prop type.
|
|
5244
|
+
// `onChange: ((value: unknown, event: React.SyntheticEvent<Element, Event>) => void) | undefined`
|
|
5245
|
+
onChange: handleChange, open: isOpen, searchable: searchable, ...originalProps }, key)) }), hasError && jsx(FieldError, { children: controlledError })] }));
|
|
4614
5246
|
}
|
|
4615
5247
|
const StyledSelectPicker = styled(SelectPicker) `
|
|
4616
5248
|
> .rs-picker-toggle {
|
|
@@ -4618,6 +5250,41 @@ const StyledSelectPicker = styled(SelectPicker) `
|
|
|
4618
5250
|
border: 0;
|
|
4619
5251
|
}
|
|
4620
5252
|
`;
|
|
5253
|
+
const Box = styled.div `
|
|
5254
|
+
position: relative;
|
|
5255
|
+
|
|
5256
|
+
> .rs-picker-select {
|
|
5257
|
+
> .rs-picker-toggle {
|
|
5258
|
+
border: solid 1px ${p => p.theme.color.gainsboro} !important;
|
|
5259
|
+
font-size: 13px;
|
|
5260
|
+
line-height: 1.3846;
|
|
5261
|
+
padding: 4px 40px 6px 8px;
|
|
5262
|
+
|
|
5263
|
+
:hover {
|
|
5264
|
+
border: solid 1px ${p => p.theme.color.blueYonder[100]} !important;
|
|
5265
|
+
}
|
|
5266
|
+
|
|
5267
|
+
:active,
|
|
5268
|
+
:focus {
|
|
5269
|
+
border: solid 1px ${p => p.theme.color.blueGray[100]} !important;
|
|
5270
|
+
}
|
|
5271
|
+
|
|
5272
|
+
> .rs-stack {
|
|
5273
|
+
> .rs-stack-item {
|
|
5274
|
+
> .rs-picker-toggle-placeholder {
|
|
5275
|
+
font-size: 13px;
|
|
5276
|
+
line-height: 1.3846;
|
|
5277
|
+
}
|
|
5278
|
+
|
|
5279
|
+
> svg {
|
|
5280
|
+
height: 18px;
|
|
5281
|
+
margin-top: -2px;
|
|
5282
|
+
}
|
|
5283
|
+
}
|
|
5284
|
+
}
|
|
5285
|
+
}
|
|
5286
|
+
}
|
|
5287
|
+
`;
|
|
4621
5288
|
|
|
4622
5289
|
function Textarea({ isLabelHidden = false, isLight = false, label, onChange, rows = 3, ...originalProps }) {
|
|
4623
5290
|
const inputRef = useRef();
|
|
@@ -4731,10 +5398,11 @@ function FormikNumberInput({ name, ...originalProps }) {
|
|
|
4731
5398
|
}
|
|
4732
5399
|
|
|
4733
5400
|
function FormikSelect({ name, ...originalProps }) {
|
|
4734
|
-
const [field, , helpers] = useField(name);
|
|
5401
|
+
const [field, meta, helpers] = useField(name);
|
|
4735
5402
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4736
5403
|
const defaultValue = useMemo(() => field.value, []);
|
|
4737
|
-
|
|
5404
|
+
const error = useMemo(() => (meta.initialTouched ? meta.error : undefined), [meta.error, meta.initialTouched]);
|
|
5405
|
+
return jsx(Select, { defaultValue: defaultValue, error: error, name: name, onChange: helpers.setValue, ...originalProps });
|
|
4738
5406
|
}
|
|
4739
5407
|
|
|
4740
5408
|
function FormikTextarea({ name, ...originalProps }) {
|
|
@@ -4751,5 +5419,5 @@ function FormikTextInput({ name, ...originalProps }) {
|
|
|
4751
5419
|
return jsx(TextInput, { defaultValue: defaultValue, name: name, onChange: helpers.setValue, ...originalProps });
|
|
4752
5420
|
}
|
|
4753
5421
|
|
|
4754
|
-
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 };
|
|
5422
|
+
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 };
|
|
4755
5423
|
//# sourceMappingURL=index.js.map
|