@sebgroup/green-react 1.7.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import React, { useState, useLayoutEffect, useEffect, useRef, useMemo } from 'react';
3
- import { randomId, debounce, validateClassName, delay, sliderColors, getSliderTrackBackground, createStepper, createDropdown, dropdownValues, createDatepicker, months, years } from '@sebgroup/extract';
1
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
+ import React, { useState, useEffect, useRef, useLayoutEffect, useMemo } from 'react';
3
+ import { randomId, createDatepicker, createDropdown, dropdownValues, months, years, debounce, validateClassName, delay, sliderColors, getSliderTrackBackground, createStepper } from '@sebgroup/extract';
4
4
  import classNames from 'classnames';
5
5
 
6
6
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -10,7 +10,7 @@ var check = function (it) {
10
10
  };
11
11
 
12
12
  // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
13
- var global$c =
13
+ var global$d =
14
14
  // eslint-disable-next-line es/no-global-this -- safe
15
15
  check(typeof globalThis == 'object' && globalThis) ||
16
16
  check(typeof window == 'object' && window) ||
@@ -22,7 +22,7 @@ var global$c =
22
22
 
23
23
  var objectGetOwnPropertyDescriptor = {};
24
24
 
25
- var fails$b = function (exec) {
25
+ var fails$c = function (exec) {
26
26
  try {
27
27
  return !!exec();
28
28
  } catch (error) {
@@ -30,17 +30,17 @@ var fails$b = function (exec) {
30
30
  }
31
31
  };
32
32
 
33
- var fails$a = fails$b;
33
+ var fails$b = fails$c;
34
34
 
35
35
  // Detect IE8's incomplete defineProperty implementation
36
- var descriptors = !fails$a(function () {
36
+ var descriptors = !fails$b(function () {
37
37
  // eslint-disable-next-line es/no-object-defineproperty -- required for testing
38
38
  return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
39
39
  });
40
40
 
41
- var fails$9 = fails$b;
41
+ var fails$a = fails$c;
42
42
 
43
- var functionBindNative = !fails$9(function () {
43
+ var functionBindNative = !fails$a(function () {
44
44
  // eslint-disable-next-line es/no-function-prototype-bind -- safe
45
45
  var test = (function () { /* empty */ }).bind();
46
46
  // eslint-disable-next-line no-prototype-builtins -- safe
@@ -92,24 +92,24 @@ var functionUncurryThis = NATIVE_BIND ? uncurryThisWithBind : function (fn) {
92
92
  };
93
93
  };
94
94
 
95
- var uncurryThis$b = functionUncurryThis;
95
+ var uncurryThis$d = functionUncurryThis;
96
96
 
97
- var toString$3 = uncurryThis$b({}.toString);
98
- var stringSlice$2 = uncurryThis$b(''.slice);
97
+ var toString$5 = uncurryThis$d({}.toString);
98
+ var stringSlice$2 = uncurryThis$d(''.slice);
99
99
 
100
100
  var classofRaw$1 = function (it) {
101
- return stringSlice$2(toString$3(it), 8, -1);
101
+ return stringSlice$2(toString$5(it), 8, -1);
102
102
  };
103
103
 
104
- var uncurryThis$a = functionUncurryThis;
105
- var fails$8 = fails$b;
104
+ var uncurryThis$c = functionUncurryThis;
105
+ var fails$9 = fails$c;
106
106
  var classof$2 = classofRaw$1;
107
107
 
108
108
  var $Object$4 = Object;
109
- var split = uncurryThis$a(''.split);
109
+ var split = uncurryThis$c(''.split);
110
110
 
111
111
  // fallback for non-array-like ES3 and non-enumerable old V8 strings
112
- var indexedObject = fails$8(function () {
112
+ var indexedObject = fails$9(function () {
113
113
  // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
114
114
  // eslint-disable-next-line no-prototype-builtins -- safe
115
115
  return !$Object$4('z').propertyIsEnumerable(0);
@@ -129,17 +129,17 @@ var $TypeError$6 = TypeError;
129
129
 
130
130
  // `RequireObjectCoercible` abstract operation
131
131
  // https://tc39.es/ecma262/#sec-requireobjectcoercible
132
- var requireObjectCoercible$2 = function (it) {
132
+ var requireObjectCoercible$3 = function (it) {
133
133
  if (isNullOrUndefined$1(it)) throw $TypeError$6("Can't call method on " + it);
134
134
  return it;
135
135
  };
136
136
 
137
137
  // toObject with fallback for non-array-like ES3 strings
138
138
  var IndexedObject$1 = indexedObject;
139
- var requireObjectCoercible$1 = requireObjectCoercible$2;
139
+ var requireObjectCoercible$2 = requireObjectCoercible$3;
140
140
 
141
141
  var toIndexedObject$5 = function (it) {
142
- return IndexedObject$1(requireObjectCoercible$1(it));
142
+ return IndexedObject$1(requireObjectCoercible$2(it));
143
143
  };
144
144
 
145
145
  var documentAll$2 = typeof document == 'object' && document.all;
@@ -176,7 +176,7 @@ var isObject$6 = $documentAll.IS_HTMLDDA ? function (it) {
176
176
  return typeof it == 'object' ? it !== null : isCallable$f(it);
177
177
  };
178
178
 
179
- var global$b = global$c;
179
+ var global$c = global$d;
180
180
  var isCallable$e = isCallable$g;
181
181
 
182
182
  var aFunction = function (argument) {
@@ -184,20 +184,20 @@ var aFunction = function (argument) {
184
184
  };
185
185
 
186
186
  var getBuiltIn$3 = function (namespace, method) {
187
- return arguments.length < 2 ? aFunction(global$b[namespace]) : global$b[namespace] && global$b[namespace][method];
187
+ return arguments.length < 2 ? aFunction(global$c[namespace]) : global$c[namespace] && global$c[namespace][method];
188
188
  };
189
189
 
190
- var uncurryThis$9 = functionUncurryThis;
190
+ var uncurryThis$b = functionUncurryThis;
191
191
 
192
- var objectIsPrototypeOf = uncurryThis$9({}.isPrototypeOf);
192
+ var objectIsPrototypeOf = uncurryThis$b({}.isPrototypeOf);
193
193
 
194
194
  var engineUserAgent = typeof navigator != 'undefined' && String(navigator.userAgent) || '';
195
195
 
196
- var global$a = global$c;
196
+ var global$b = global$d;
197
197
  var userAgent = engineUserAgent;
198
198
 
199
- var process = global$a.process;
200
- var Deno = global$a.Deno;
199
+ var process = global$b.process;
200
+ var Deno = global$b.Deno;
201
201
  var versions = process && process.versions || Deno && Deno.version;
202
202
  var v8 = versions && versions.v8;
203
203
  var match, version;
@@ -224,10 +224,10 @@ var engineV8Version = version;
224
224
  /* eslint-disable es/no-symbol -- required for testing */
225
225
 
226
226
  var V8_VERSION = engineV8Version;
227
- var fails$7 = fails$b;
227
+ var fails$8 = fails$c;
228
228
 
229
229
  // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
230
- var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails$7(function () {
230
+ var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails$8(function () {
231
231
  var symbol = Symbol();
232
232
  // Chrome 38 Symbol has incorrect toString conversion
233
233
  // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
@@ -307,24 +307,24 @@ var ordinaryToPrimitive$1 = function (input, pref) {
307
307
 
308
308
  var shared$3 = {exports: {}};
309
309
 
310
- var global$9 = global$c;
310
+ var global$a = global$d;
311
311
 
312
312
  // eslint-disable-next-line es/no-object-defineproperty -- safe
313
313
  var defineProperty$6 = Object.defineProperty;
314
314
 
315
315
  var defineGlobalProperty$3 = function (key, value) {
316
316
  try {
317
- defineProperty$6(global$9, key, { value: value, configurable: true, writable: true });
317
+ defineProperty$6(global$a, key, { value: value, configurable: true, writable: true });
318
318
  } catch (error) {
319
- global$9[key] = value;
319
+ global$a[key] = value;
320
320
  } return value;
321
321
  };
322
322
 
323
- var global$8 = global$c;
323
+ var global$9 = global$d;
324
324
  var defineGlobalProperty$2 = defineGlobalProperty$3;
325
325
 
326
326
  var SHARED = '__core-js_shared__';
327
- var store$3 = global$8[SHARED] || defineGlobalProperty$2(SHARED, {});
327
+ var store$3 = global$9[SHARED] || defineGlobalProperty$2(SHARED, {});
328
328
 
329
329
  var sharedStore = store$3;
330
330
 
@@ -340,20 +340,20 @@ var store$2 = sharedStore;
340
340
  source: 'https://github.com/zloirock/core-js'
341
341
  });
342
342
 
343
- var requireObjectCoercible = requireObjectCoercible$2;
343
+ var requireObjectCoercible$1 = requireObjectCoercible$3;
344
344
 
345
345
  var $Object$2 = Object;
346
346
 
347
347
  // `ToObject` abstract operation
348
348
  // https://tc39.es/ecma262/#sec-toobject
349
349
  var toObject$3 = function (argument) {
350
- return $Object$2(requireObjectCoercible(argument));
350
+ return $Object$2(requireObjectCoercible$1(argument));
351
351
  };
352
352
 
353
- var uncurryThis$8 = functionUncurryThis;
353
+ var uncurryThis$a = functionUncurryThis;
354
354
  var toObject$2 = toObject$3;
355
355
 
356
- var hasOwnProperty = uncurryThis$8({}.hasOwnProperty);
356
+ var hasOwnProperty = uncurryThis$a({}.hasOwnProperty);
357
357
 
358
358
  // `HasOwnProperty` abstract operation
359
359
  // https://tc39.es/ecma262/#sec-hasownproperty
@@ -362,31 +362,31 @@ var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
362
362
  return hasOwnProperty(toObject$2(it), key);
363
363
  };
364
364
 
365
- var uncurryThis$7 = functionUncurryThis;
365
+ var uncurryThis$9 = functionUncurryThis;
366
366
 
367
367
  var id = 0;
368
368
  var postfix = Math.random();
369
- var toString$2 = uncurryThis$7(1.0.toString);
369
+ var toString$4 = uncurryThis$9(1.0.toString);
370
370
 
371
371
  var uid$2 = function (key) {
372
- return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$2(++id + postfix, 36);
372
+ return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$4(++id + postfix, 36);
373
373
  };
374
374
 
375
- var global$7 = global$c;
375
+ var global$8 = global$d;
376
376
  var shared$2 = shared$3.exports;
377
377
  var hasOwn$9 = hasOwnProperty_1;
378
378
  var uid$1 = uid$2;
379
379
  var NATIVE_SYMBOL$1 = symbolConstructorDetection;
380
380
  var USE_SYMBOL_AS_UID = useSymbolAsUid;
381
381
 
382
- var Symbol$1 = global$7.Symbol;
382
+ var Symbol$2 = global$8.Symbol;
383
383
  var WellKnownSymbolsStore = shared$2('wks');
384
- var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$1['for'] || Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$1;
384
+ var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$2['for'] || Symbol$2 : Symbol$2 && Symbol$2.withoutSetter || uid$1;
385
385
 
386
386
  var wellKnownSymbol$8 = function (name) {
387
387
  if (!hasOwn$9(WellKnownSymbolsStore, name)) {
388
- WellKnownSymbolsStore[name] = NATIVE_SYMBOL$1 && hasOwn$9(Symbol$1, name)
389
- ? Symbol$1[name]
388
+ WellKnownSymbolsStore[name] = NATIVE_SYMBOL$1 && hasOwn$9(Symbol$2, name)
389
+ ? Symbol$2[name]
390
390
  : createWellKnownSymbol('Symbol.' + name);
391
391
  } return WellKnownSymbolsStore[name];
392
392
  };
@@ -427,10 +427,10 @@ var toPropertyKey$2 = function (argument) {
427
427
  return isSymbol(key) ? key : key + '';
428
428
  };
429
429
 
430
- var global$6 = global$c;
430
+ var global$7 = global$d;
431
431
  var isObject$3 = isObject$6;
432
432
 
433
- var document$1 = global$6.document;
433
+ var document$1 = global$7.document;
434
434
  // typeof document.createElement is 'object' in old IE
435
435
  var EXISTS$1 = isObject$3(document$1) && isObject$3(document$1.createElement);
436
436
 
@@ -439,11 +439,11 @@ var documentCreateElement$2 = function (it) {
439
439
  };
440
440
 
441
441
  var DESCRIPTORS$a = descriptors;
442
- var fails$6 = fails$b;
442
+ var fails$7 = fails$c;
443
443
  var createElement = documentCreateElement$2;
444
444
 
445
445
  // Thanks to IE8 for its funny defineProperty
446
- var ie8DomDefine = !DESCRIPTORS$a && !fails$6(function () {
446
+ var ie8DomDefine = !DESCRIPTORS$a && !fails$7(function () {
447
447
  // eslint-disable-next-line es/no-object-defineproperty -- required for testing
448
448
  return Object.defineProperty(createElement('div'), 'a', {
449
449
  get: function () { return 7; }
@@ -476,11 +476,11 @@ objectGetOwnPropertyDescriptor.f = DESCRIPTORS$9 ? $getOwnPropertyDescriptor$1 :
476
476
  var objectDefineProperty = {};
477
477
 
478
478
  var DESCRIPTORS$8 = descriptors;
479
- var fails$5 = fails$b;
479
+ var fails$6 = fails$c;
480
480
 
481
481
  // V8 ~ Chrome 36-
482
482
  // https://bugs.chromium.org/p/v8/issues/detail?id=3334
483
- var v8PrototypeDefineBug = DESCRIPTORS$8 && fails$5(function () {
483
+ var v8PrototypeDefineBug = DESCRIPTORS$8 && fails$6(function () {
484
484
  // eslint-disable-next-line es/no-object-defineproperty -- required for testing
485
485
  return Object.defineProperty(function () { /* empty */ }, 'prototype', {
486
486
  value: 42,
@@ -574,11 +574,11 @@ var functionName = {
574
574
  CONFIGURABLE: CONFIGURABLE
575
575
  };
576
576
 
577
- var uncurryThis$6 = functionUncurryThis;
577
+ var uncurryThis$8 = functionUncurryThis;
578
578
  var isCallable$a = isCallable$g;
579
579
  var store$1 = sharedStore;
580
580
 
581
- var functionToString = uncurryThis$6(Function.toString);
581
+ var functionToString = uncurryThis$8(Function.toString);
582
582
 
583
583
  // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
584
584
  if (!isCallable$a(store$1.inspectSource)) {
@@ -589,10 +589,10 @@ if (!isCallable$a(store$1.inspectSource)) {
589
589
 
590
590
  var inspectSource$1 = store$1.inspectSource;
591
591
 
592
- var global$5 = global$c;
592
+ var global$6 = global$d;
593
593
  var isCallable$9 = isCallable$g;
594
594
 
595
- var WeakMap$1 = global$5.WeakMap;
595
+ var WeakMap$1 = global$6.WeakMap;
596
596
 
597
597
  var weakMapBasicDetection = isCallable$9(WeakMap$1) && /native code/.test(String(WeakMap$1));
598
598
 
@@ -608,7 +608,7 @@ var sharedKey$3 = function (key) {
608
608
  var hiddenKeys$4 = {};
609
609
 
610
610
  var NATIVE_WEAK_MAP = weakMapBasicDetection;
611
- var global$4 = global$c;
611
+ var global$5 = global$d;
612
612
  var isObject$1 = isObject$6;
613
613
  var createNonEnumerableProperty$3 = createNonEnumerableProperty$4;
614
614
  var hasOwn$6 = hasOwnProperty_1;
@@ -617,8 +617,8 @@ var sharedKey$2 = sharedKey$3;
617
617
  var hiddenKeys$3 = hiddenKeys$4;
618
618
 
619
619
  var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
620
- var TypeError$1 = global$4.TypeError;
621
- var WeakMap = global$4.WeakMap;
620
+ var TypeError$1 = global$5.TypeError;
621
+ var WeakMap = global$5.WeakMap;
622
622
  var set, get, has;
623
623
 
624
624
  var enforce = function (it) {
@@ -678,8 +678,8 @@ var internalState = {
678
678
  getterFor: getterFor
679
679
  };
680
680
 
681
- var uncurryThis$5 = functionUncurryThis;
682
- var fails$4 = fails$b;
681
+ var uncurryThis$7 = functionUncurryThis;
682
+ var fails$5 = fails$c;
683
683
  var isCallable$8 = isCallable$g;
684
684
  var hasOwn$5 = hasOwnProperty_1;
685
685
  var DESCRIPTORS$4 = descriptors;
@@ -692,11 +692,11 @@ var getInternalState$1 = InternalStateModule$1.get;
692
692
  var $String$2 = String;
693
693
  // eslint-disable-next-line es/no-object-defineproperty -- safe
694
694
  var defineProperty$5 = Object.defineProperty;
695
- var stringSlice$1 = uncurryThis$5(''.slice);
696
- var replace$1 = uncurryThis$5(''.replace);
697
- var join = uncurryThis$5([].join);
695
+ var stringSlice$1 = uncurryThis$7(''.slice);
696
+ var replace$2 = uncurryThis$7(''.replace);
697
+ var join = uncurryThis$7([].join);
698
698
 
699
- var CONFIGURABLE_LENGTH = DESCRIPTORS$4 && !fails$4(function () {
699
+ var CONFIGURABLE_LENGTH = DESCRIPTORS$4 && !fails$5(function () {
700
700
  return defineProperty$5(function () { /* empty */ }, 'length', { value: 8 }).length !== 8;
701
701
  });
702
702
 
@@ -704,7 +704,7 @@ var TEMPLATE = String(String).split('String');
704
704
 
705
705
  var makeBuiltIn$2 = makeBuiltIn$3.exports = function (value, name, options) {
706
706
  if (stringSlice$1($String$2(name), 0, 7) === 'Symbol(') {
707
- name = '[' + replace$1($String$2(name), /^Symbol\(([^)]*)\)/, '$1') + ']';
707
+ name = '[' + replace$2($String$2(name), /^Symbol\(([^)]*)\)/, '$1') + ']';
708
708
  }
709
709
  if (options && options.getter) name = 'get ' + name;
710
710
  if (options && options.setter) name = 'set ' + name;
@@ -820,7 +820,7 @@ var toAbsoluteIndex = toAbsoluteIndex$1;
820
820
  var lengthOfArrayLike = lengthOfArrayLike$1;
821
821
 
822
822
  // `Array.prototype.{ indexOf, includes }` methods implementation
823
- var createMethod = function (IS_INCLUDES) {
823
+ var createMethod$1 = function (IS_INCLUDES) {
824
824
  return function ($this, el, fromIndex) {
825
825
  var O = toIndexedObject$3($this);
826
826
  var length = lengthOfArrayLike(O);
@@ -842,19 +842,19 @@ var createMethod = function (IS_INCLUDES) {
842
842
  var arrayIncludes = {
843
843
  // `Array.prototype.includes` method
844
844
  // https://tc39.es/ecma262/#sec-array.prototype.includes
845
- includes: createMethod(true),
845
+ includes: createMethod$1(true),
846
846
  // `Array.prototype.indexOf` method
847
847
  // https://tc39.es/ecma262/#sec-array.prototype.indexof
848
- indexOf: createMethod(false)
848
+ indexOf: createMethod$1(false)
849
849
  };
850
850
 
851
- var uncurryThis$4 = functionUncurryThis;
851
+ var uncurryThis$6 = functionUncurryThis;
852
852
  var hasOwn$4 = hasOwnProperty_1;
853
853
  var toIndexedObject$2 = toIndexedObject$5;
854
854
  var indexOf = arrayIncludes.indexOf;
855
855
  var hiddenKeys$2 = hiddenKeys$4;
856
856
 
857
- var push = uncurryThis$4([].push);
857
+ var push = uncurryThis$6([].push);
858
858
 
859
859
  var objectKeysInternal = function (object, names) {
860
860
  var O = toIndexedObject$2(object);
@@ -898,12 +898,12 @@ var objectGetOwnPropertySymbols = {};
898
898
  objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
899
899
 
900
900
  var getBuiltIn$1 = getBuiltIn$3;
901
- var uncurryThis$3 = functionUncurryThis;
901
+ var uncurryThis$5 = functionUncurryThis;
902
902
  var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
903
903
  var getOwnPropertySymbolsModule$1 = objectGetOwnPropertySymbols;
904
904
  var anObject$3 = anObject$5;
905
905
 
906
- var concat$1 = uncurryThis$3([].concat);
906
+ var concat$1 = uncurryThis$5([].concat);
907
907
 
908
908
  // all object keys, includes non-enumerable and symbols
909
909
  var ownKeys$1 = getBuiltIn$1('Reflect', 'ownKeys') || function ownKeys(it) {
@@ -929,7 +929,7 @@ var copyConstructorProperties$2 = function (target, source, exceptions) {
929
929
  }
930
930
  };
931
931
 
932
- var fails$3 = fails$b;
932
+ var fails$4 = fails$c;
933
933
  var isCallable$6 = isCallable$g;
934
934
 
935
935
  var replacement = /#|\.prototype\./;
@@ -938,7 +938,7 @@ var isForced$1 = function (feature, detection) {
938
938
  var value = data[normalize(feature)];
939
939
  return value == POLYFILL ? true
940
940
  : value == NATIVE ? false
941
- : isCallable$6(detection) ? fails$3(detection)
941
+ : isCallable$6(detection) ? fails$4(detection)
942
942
  : !!detection;
943
943
  };
944
944
 
@@ -952,7 +952,7 @@ var POLYFILL = isForced$1.POLYFILL = 'P';
952
952
 
953
953
  var isForced_1 = isForced$1;
954
954
 
955
- var global$3 = global$c;
955
+ var global$4 = global$d;
956
956
  var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
957
957
  var createNonEnumerableProperty$2 = createNonEnumerableProperty$4;
958
958
  var defineBuiltIn$2 = defineBuiltIn$3;
@@ -981,11 +981,11 @@ var _export = function (options, source) {
981
981
  var STATIC = options.stat;
982
982
  var FORCED, target, key, targetProperty, sourceProperty, descriptor;
983
983
  if (GLOBAL) {
984
- target = global$3;
984
+ target = global$4;
985
985
  } else if (STATIC) {
986
- target = global$3[TARGET] || defineGlobalProperty(TARGET, {});
986
+ target = global$4[TARGET] || defineGlobalProperty(TARGET, {});
987
987
  } else {
988
- target = (global$3[TARGET] || {}).prototype;
988
+ target = (global$4[TARGET] || {}).prototype;
989
989
  }
990
990
  if (target) for (key in source) {
991
991
  sourceProperty = source[key];
@@ -1018,9 +1018,9 @@ var objectKeys$2 = Object.keys || function keys(O) {
1018
1018
  };
1019
1019
 
1020
1020
  var DESCRIPTORS$3 = descriptors;
1021
- var uncurryThis$2 = functionUncurryThis;
1021
+ var uncurryThis$4 = functionUncurryThis;
1022
1022
  var call$1 = functionCall;
1023
- var fails$2 = fails$b;
1023
+ var fails$3 = fails$c;
1024
1024
  var objectKeys$1 = objectKeys$2;
1025
1025
  var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
1026
1026
  var propertyIsEnumerableModule = objectPropertyIsEnumerable;
@@ -1031,11 +1031,11 @@ var IndexedObject = indexedObject;
1031
1031
  var $assign = Object.assign;
1032
1032
  // eslint-disable-next-line es/no-object-defineproperty -- required for testing
1033
1033
  var defineProperty$4 = Object.defineProperty;
1034
- var concat = uncurryThis$2([].concat);
1034
+ var concat = uncurryThis$4([].concat);
1035
1035
 
1036
1036
  // `Object.assign` method
1037
1037
  // https://tc39.es/ecma262/#sec-object.assign
1038
- var objectAssign = !$assign || fails$2(function () {
1038
+ var objectAssign = !$assign || fails$3(function () {
1039
1039
  // should have correct order of operations (Edge bug)
1040
1040
  if (DESCRIPTORS$3 && $assign({ b: 1 }, $assign(defineProperty$4({}, 'a', {
1041
1041
  enumerable: true,
@@ -1074,178 +1074,16 @@ var objectAssign = !$assign || fails$2(function () {
1074
1074
  } return T;
1075
1075
  } : $assign;
1076
1076
 
1077
- var $$2 = _export;
1077
+ var $$3 = _export;
1078
1078
  var assign = objectAssign;
1079
1079
 
1080
1080
  // `Object.assign` method
1081
1081
  // https://tc39.es/ecma262/#sec-object.assign
1082
1082
  // eslint-disable-next-line es/no-object-assign -- required for testing
1083
- $$2({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, {
1083
+ $$3({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, {
1084
1084
  assign: assign
1085
1085
  });
1086
1086
 
1087
- /******************************************************************************
1088
- Copyright (c) Microsoft Corporation.
1089
-
1090
- Permission to use, copy, modify, and/or distribute this software for any
1091
- purpose with or without fee is hereby granted.
1092
-
1093
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1094
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1095
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1096
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1097
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1098
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1099
- PERFORMANCE OF THIS SOFTWARE.
1100
- ***************************************************************************** */
1101
-
1102
- function __rest(s, e) {
1103
- var t = {};
1104
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1105
- t[p] = s[p];
1106
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
1107
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1108
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1109
- t[p[i]] = s[p[i]];
1110
- }
1111
- return t;
1112
- }
1113
-
1114
- function __awaiter(thisArg, _arguments, P, generator) {
1115
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1116
- return new (P || (P = Promise))(function (resolve, reject) {
1117
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1118
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1119
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1120
- step((generator = generator.apply(thisArg, _arguments || [])).next());
1121
- });
1122
- }
1123
-
1124
- function Button({
1125
- children,
1126
- variant,
1127
- onClick,
1128
- disabled,
1129
- active = false,
1130
- type = 'button',
1131
- size
1132
- }) {
1133
- const props = {
1134
- type,
1135
- disabled
1136
- };
1137
- const classNames = [];
1138
- if (variant) classNames.push(variant);
1139
- if (active) classNames.push('active');
1140
- if (size) classNames.push(size);
1141
- if (classNames.length) props.className = classNames.join(' ');
1142
- if (onClick) props.onClick = onClick;
1143
- return jsx("button", Object.assign({}, props, {
1144
- children: children
1145
- }));
1146
- }
1147
-
1148
- const ModalHeader = ({
1149
- header: _header = '',
1150
- onClose
1151
- }) => {
1152
- const handleClose = event => {
1153
- if (onClose) onClose(event);
1154
- };
1155
- return jsxs("div", Object.assign({
1156
- className: "header"
1157
- }, {
1158
- children: [jsx("h3", {
1159
- children: _header
1160
- }), jsxs("button", Object.assign({
1161
- className: "close",
1162
- onClick: handleClose
1163
- }, {
1164
- children: [jsx("span", Object.assign({
1165
- className: "sr-only"
1166
- }, {
1167
- children: "Close"
1168
- })), jsx("i", {})]
1169
- }))]
1170
- }));
1171
- };
1172
- const ModalBody = ({
1173
- children
1174
- }) => {
1175
- return jsx("div", Object.assign({
1176
- className: "body"
1177
- }, {
1178
- children: children
1179
- }));
1180
- };
1181
- const ModalFooter = ({
1182
- confirm,
1183
- dismiss,
1184
- onClose,
1185
- onConfirm,
1186
- onDismiss
1187
- }) => {
1188
- const handleConfirm = event => {
1189
- if (onConfirm) onConfirm(event);
1190
- if (onClose) onClose(event);
1191
- };
1192
- const handleDismiss = event => {
1193
- if (onDismiss) onDismiss(event);
1194
- if (onClose) onClose(event);
1195
- };
1196
- return jsxs("div", Object.assign({
1197
- className: "footer"
1198
- }, {
1199
- children: [dismiss && jsx(Button, Object.assign({
1200
- variant: "secondary",
1201
- onClick: handleDismiss
1202
- }, {
1203
- children: dismiss
1204
- })), confirm && jsx(Button, Object.assign({
1205
- variant: "primary",
1206
- onClick: handleConfirm
1207
- }, {
1208
- children: confirm
1209
- }))]
1210
- }));
1211
- };
1212
- const Modal = _a => {
1213
- var {
1214
- type = 'default',
1215
- isOpen
1216
- } = _a,
1217
- props = __rest(_a, ["type", "isOpen"]);
1218
- const modalContent = () => {
1219
- switch (type) {
1220
- case 'slideout':
1221
- {
1222
- return jsxs("aside", Object.assign({
1223
- role: "dialog"
1224
- }, {
1225
- children: [jsx(ModalHeader, Object.assign({}, props)), jsx(ModalBody, Object.assign({}, props)), jsx(ModalFooter, Object.assign({}, props))]
1226
- }));
1227
- }
1228
- case 'takeover':
1229
- {
1230
- return jsxs("main", Object.assign({
1231
- role: "dialog"
1232
- }, {
1233
- children: [jsx(ModalHeader, Object.assign({}, props)), jsx(ModalBody, Object.assign({}, props)), jsx(ModalFooter, Object.assign({}, props))]
1234
- }));
1235
- }
1236
- default:
1237
- {
1238
- return jsxs("section", Object.assign({
1239
- role: "dialog"
1240
- }, {
1241
- children: [jsx(ModalHeader, Object.assign({}, props)), jsx(ModalBody, Object.assign({}, props)), jsx(ModalFooter, Object.assign({}, props))]
1242
- }));
1243
- }
1244
- }
1245
- };
1246
- return isOpen ? modalContent() : null;
1247
- };
1248
-
1249
1087
  var objectDefineProperties = {};
1250
1088
 
1251
1089
  var DESCRIPTORS$2 = descriptors;
@@ -1381,9 +1219,9 @@ var addToUnscopables$1 = function (key) {
1381
1219
 
1382
1220
  var iterators = {};
1383
1221
 
1384
- var fails$1 = fails$b;
1222
+ var fails$2 = fails$c;
1385
1223
 
1386
- var correctPrototypeGetter = !fails$1(function () {
1224
+ var correctPrototypeGetter = !fails$2(function () {
1387
1225
  function F() { /* empty */ }
1388
1226
  F.prototype.constructor = null;
1389
1227
  // eslint-disable-next-line es/no-object-getprototypeof -- required for testing
@@ -1412,14 +1250,14 @@ var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? $Object$1.getPrototypeOf :
1412
1250
  } return object instanceof $Object$1 ? ObjectPrototype : null;
1413
1251
  };
1414
1252
 
1415
- var fails = fails$b;
1253
+ var fails$1 = fails$c;
1416
1254
  var isCallable$4 = isCallable$g;
1417
1255
  var isObject = isObject$6;
1418
1256
  var getPrototypeOf$1 = objectGetPrototypeOf;
1419
1257
  var defineBuiltIn$1 = defineBuiltIn$3;
1420
1258
  var wellKnownSymbol$5 = wellKnownSymbol$8;
1421
1259
 
1422
- var ITERATOR$2 = wellKnownSymbol$5('iterator');
1260
+ var ITERATOR$3 = wellKnownSymbol$5('iterator');
1423
1261
  var BUGGY_SAFARI_ITERATORS$1 = false;
1424
1262
 
1425
1263
  // `%IteratorPrototype%` object
@@ -1437,18 +1275,18 @@ if ([].keys) {
1437
1275
  }
1438
1276
  }
1439
1277
 
1440
- var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype$2) || fails(function () {
1278
+ var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype$2) || fails$1(function () {
1441
1279
  var test = {};
1442
1280
  // FF44- legacy iterators case
1443
- return IteratorPrototype$2[ITERATOR$2].call(test) !== test;
1281
+ return IteratorPrototype$2[ITERATOR$3].call(test) !== test;
1444
1282
  });
1445
1283
 
1446
1284
  if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype$2 = {};
1447
1285
 
1448
1286
  // `%IteratorPrototype%[@@iterator]()` method
1449
1287
  // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
1450
- if (!isCallable$4(IteratorPrototype$2[ITERATOR$2])) {
1451
- defineBuiltIn$1(IteratorPrototype$2, ITERATOR$2, function () {
1288
+ if (!isCallable$4(IteratorPrototype$2[ITERATOR$3])) {
1289
+ defineBuiltIn$1(IteratorPrototype$2, ITERATOR$3, function () {
1452
1290
  return this;
1453
1291
  });
1454
1292
  }
@@ -1487,13 +1325,13 @@ var iteratorCreateConstructor = function (IteratorConstructor, NAME, next, ENUME
1487
1325
  return IteratorConstructor;
1488
1326
  };
1489
1327
 
1490
- var uncurryThis$1 = functionUncurryThis;
1328
+ var uncurryThis$3 = functionUncurryThis;
1491
1329
  var aCallable = aCallable$2;
1492
1330
 
1493
1331
  var functionUncurryThisAccessor = function (object, key, method) {
1494
1332
  try {
1495
1333
  // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1496
- return uncurryThis$1(aCallable(Object.getOwnPropertyDescriptor(object, key)[method]));
1334
+ return uncurryThis$3(aCallable(Object.getOwnPropertyDescriptor(object, key)[method]));
1497
1335
  } catch (error) { /* empty */ }
1498
1336
  };
1499
1337
 
@@ -1535,7 +1373,7 @@ var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? functio
1535
1373
  };
1536
1374
  }() : undefined);
1537
1375
 
1538
- var $$1 = _export;
1376
+ var $$2 = _export;
1539
1377
  var call = functionCall;
1540
1378
  var FunctionName = functionName;
1541
1379
  var isCallable$2 = isCallable$g;
@@ -1553,7 +1391,7 @@ var PROPER_FUNCTION_NAME = FunctionName.PROPER;
1553
1391
  var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE;
1554
1392
  var IteratorPrototype = IteratorsCore.IteratorPrototype;
1555
1393
  var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
1556
- var ITERATOR$1 = wellKnownSymbol$3('iterator');
1394
+ var ITERATOR$2 = wellKnownSymbol$3('iterator');
1557
1395
  var KEYS = 'keys';
1558
1396
  var VALUES = 'values';
1559
1397
  var ENTRIES = 'entries';
@@ -1576,7 +1414,7 @@ var iteratorDefine = function (Iterable, NAME, IteratorConstructor, next, DEFAUL
1576
1414
  var TO_STRING_TAG = NAME + ' Iterator';
1577
1415
  var INCORRECT_VALUES_NAME = false;
1578
1416
  var IterablePrototype = Iterable.prototype;
1579
- var nativeIterator = IterablePrototype[ITERATOR$1]
1417
+ var nativeIterator = IterablePrototype[ITERATOR$2]
1580
1418
  || IterablePrototype['@@iterator']
1581
1419
  || DEFAULT && IterablePrototype[DEFAULT];
1582
1420
  var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
@@ -1590,8 +1428,8 @@ var iteratorDefine = function (Iterable, NAME, IteratorConstructor, next, DEFAUL
1590
1428
  if (getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
1591
1429
  if (setPrototypeOf) {
1592
1430
  setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
1593
- } else if (!isCallable$2(CurrentIteratorPrototype[ITERATOR$1])) {
1594
- defineBuiltIn(CurrentIteratorPrototype, ITERATOR$1, returnThis);
1431
+ } else if (!isCallable$2(CurrentIteratorPrototype[ITERATOR$2])) {
1432
+ defineBuiltIn(CurrentIteratorPrototype, ITERATOR$2, returnThis);
1595
1433
  }
1596
1434
  }
1597
1435
  // Set @@toStringTag to native iterators
@@ -1620,12 +1458,12 @@ var iteratorDefine = function (Iterable, NAME, IteratorConstructor, next, DEFAUL
1620
1458
  if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
1621
1459
  defineBuiltIn(IterablePrototype, KEY, methods[KEY]);
1622
1460
  }
1623
- } else $$1({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
1461
+ } else $$2({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
1624
1462
  }
1625
1463
 
1626
1464
  // define iterator
1627
- if (IterablePrototype[ITERATOR$1] !== defaultIterator) {
1628
- defineBuiltIn(IterablePrototype, ITERATOR$1, defaultIterator, { name: DEFAULT });
1465
+ if (IterablePrototype[ITERATOR$2] !== defaultIterator) {
1466
+ defineBuiltIn(IterablePrototype, ITERATOR$2, defaultIterator, { name: DEFAULT });
1629
1467
  }
1630
1468
  Iterators$1[NAME] = defaultIterator;
1631
1469
 
@@ -1743,24 +1581,24 @@ var DOMTokenListPrototype$1 = classList && classList.constructor && classList.co
1743
1581
 
1744
1582
  var domTokenListPrototype = DOMTokenListPrototype$1 === Object.prototype ? undefined : DOMTokenListPrototype$1;
1745
1583
 
1746
- var global$2 = global$c;
1584
+ var global$3 = global$d;
1747
1585
  var DOMIterables = domIterables;
1748
1586
  var DOMTokenListPrototype = domTokenListPrototype;
1749
1587
  var ArrayIteratorMethods = es_array_iterator;
1750
1588
  var createNonEnumerableProperty = createNonEnumerableProperty$4;
1751
1589
  var wellKnownSymbol$2 = wellKnownSymbol$8;
1752
1590
 
1753
- var ITERATOR = wellKnownSymbol$2('iterator');
1591
+ var ITERATOR$1 = wellKnownSymbol$2('iterator');
1754
1592
  var TO_STRING_TAG$2 = wellKnownSymbol$2('toStringTag');
1755
1593
  var ArrayValues = ArrayIteratorMethods.values;
1756
1594
 
1757
1595
  var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) {
1758
1596
  if (CollectionPrototype) {
1759
1597
  // some Chrome versions have non-configurable methods on DOMTokenList
1760
- if (CollectionPrototype[ITERATOR] !== ArrayValues) try {
1761
- createNonEnumerableProperty(CollectionPrototype, ITERATOR, ArrayValues);
1598
+ if (CollectionPrototype[ITERATOR$1] !== ArrayValues) try {
1599
+ createNonEnumerableProperty(CollectionPrototype, ITERATOR$1, ArrayValues);
1762
1600
  } catch (error) {
1763
- CollectionPrototype[ITERATOR] = ArrayValues;
1601
+ CollectionPrototype[ITERATOR$1] = ArrayValues;
1764
1602
  }
1765
1603
  if (!CollectionPrototype[TO_STRING_TAG$2]) {
1766
1604
  createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG$2, COLLECTION_NAME);
@@ -1777,82 +1615,65 @@ var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) {
1777
1615
  };
1778
1616
 
1779
1617
  for (var COLLECTION_NAME in DOMIterables) {
1780
- handlePrototype(global$2[COLLECTION_NAME] && global$2[COLLECTION_NAME].prototype, COLLECTION_NAME);
1618
+ handlePrototype(global$3[COLLECTION_NAME] && global$3[COLLECTION_NAME].prototype, COLLECTION_NAME);
1781
1619
  }
1782
1620
 
1783
1621
  handlePrototype(DOMTokenListPrototype, 'DOMTokenList');
1784
1622
 
1785
- const Flexbox = _a => {
1786
- var {
1787
- alignContent,
1788
- alignItems,
1789
- alignSelf,
1790
- children,
1791
- justifyContent,
1792
- flexDirection,
1793
- flexWrap,
1794
- className
1795
- } = _a,
1796
- props = __rest(_a, ["alignContent", "alignItems", "alignSelf", "children", "justifyContent", "flexDirection", "flexWrap", "className"]);
1797
- const [classes, setClasses] = useState(['d-flex']);
1798
- const [flexClassName, setFlexClassName] = useState('d-flex');
1799
- // // update className when classes change
1800
- useLayoutEffect(() => {
1801
- const newClassName = classes.join(' ');
1802
- if (newClassName !== flexClassName) setFlexClassName(newClassName);
1803
- }, [classes, flexClassName]);
1804
- // // update classes when props change
1805
- useLayoutEffect(() => {
1806
- const newClasses = ['d-flex'];
1807
- alignItems && newClasses.push(`align-items-${alignItems}`);
1808
- alignContent && newClasses.push(`align-content-${alignContent}`);
1809
- alignSelf && newClasses.push(`align-self-${alignSelf}`);
1810
- justifyContent && newClasses.push(`justify-content-${justifyContent}`);
1811
- flexDirection && newClasses.push(`flex-${flexDirection}`);
1812
- flexWrap && newClasses.push(`flex-${flexWrap}`);
1813
- className && newClasses.push(className);
1814
- setClasses(newClasses);
1815
- }, [alignContent, alignItems, alignSelf, justifyContent, flexDirection, flexWrap, className]);
1816
- return jsx("div", Object.assign({
1817
- className: flexClassName
1818
- }, props, {
1819
- children: children
1820
- }));
1821
- };
1822
-
1823
- function Card({
1824
- children,
1825
- header,
1826
- footer
1827
- }) {
1828
- return jsxs("section", Object.assign({
1829
- className: "card"
1830
- }, {
1831
- children: [jsx("header", {
1832
- children: header
1833
- }), children, jsx("footer", {
1834
- children: footer
1835
- })]
1836
- }));
1837
- }
1838
-
1839
- const Check = ({
1840
- focusable: _focusable = false,
1841
- title
1842
- }) => {
1843
- let id;
1844
- if (title) id = randomId();
1845
- return jsxs("svg", Object.assign({
1846
- width: "24",
1847
- height: "24",
1848
- viewBox: "0 0 24 24",
1849
- xmlns: "http://www.w3.org/2000/svg",
1850
- focusable: _focusable,
1851
- "aria-labelledby": id
1852
- }, {
1853
- children: ["title && ", jsx("title", Object.assign({
1854
- id: id
1855
- }, {
1623
+ /******************************************************************************
1624
+ Copyright (c) Microsoft Corporation.
1625
+
1626
+ Permission to use, copy, modify, and/or distribute this software for any
1627
+ purpose with or without fee is hereby granted.
1628
+
1629
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1630
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1631
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1632
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1633
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1634
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1635
+ PERFORMANCE OF THIS SOFTWARE.
1636
+ ***************************************************************************** */
1637
+
1638
+ function __rest(s, e) {
1639
+ var t = {};
1640
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1641
+ t[p] = s[p];
1642
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
1643
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1644
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1645
+ t[p[i]] = s[p[i]];
1646
+ }
1647
+ return t;
1648
+ }
1649
+
1650
+ function __awaiter(thisArg, _arguments, P, generator) {
1651
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1652
+ return new (P || (P = Promise))(function (resolve, reject) {
1653
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1654
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1655
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1656
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
1657
+ });
1658
+ }
1659
+
1660
+ const Check = ({
1661
+ focusable: _focusable = false,
1662
+ title
1663
+ }) => {
1664
+ let id;
1665
+ if (title) id = randomId();
1666
+ return jsxs("svg", Object.assign({
1667
+ width: "24",
1668
+ height: "24",
1669
+ viewBox: "0 0 24 24",
1670
+ xmlns: "http://www.w3.org/2000/svg",
1671
+ focusable: _focusable,
1672
+ "aria-labelledby": id
1673
+ }, {
1674
+ children: ["title && ", jsx("title", Object.assign({
1675
+ id: id
1676
+ }, {
1856
1677
  children: title
1857
1678
  })), jsx("path", {
1858
1679
  d: "M17.6203 6.60836L9.40014 14.8285L6.37976 11.8081C6.23332 11.6617 5.99588 11.6617 5.84942 11.8081L4.96554 12.692C4.8191 12.8384 4.8191 13.0759 4.96554 13.2223L9.13495 17.3917C9.28138 17.5382 9.51882 17.5382 9.66529 17.3917L19.0344 8.02258C19.1809 7.87614 19.1809 7.63871 19.0344 7.49224L18.1506 6.60836C18.0041 6.46193 17.7667 6.46193 17.6203 6.60836Z",
@@ -2073,441 +1894,948 @@ function AlertRibbon({
2073
1894
  }));
2074
1895
  }
2075
1896
 
2076
- const IconButton = _a => {
1897
+ function Badge(_a) {
2077
1898
  var {
2078
1899
  children,
2079
- onClick
1900
+ badgeType,
1901
+ isCloseable,
1902
+ closeText,
1903
+ customColor,
1904
+ customBackgroundColor
2080
1905
  } = _a,
2081
- props = __rest(_a, ["children", "onClick"]);
2082
- return jsx("button", Object.assign({
2083
- className: "icon",
2084
- onClick: onClick,
2085
- "aria-controls": props['aria-controls'],
2086
- "aria-expanded": props['aria-expanded']
1906
+ props = __rest(_a, ["children", "badgeType", "isCloseable", "closeText", "customColor", "customBackgroundColor"]);
1907
+ const [isClosed, setIsClosed] = React.useState(false);
1908
+ const [type, setType] = React.useState('');
1909
+ React.useEffect(() => {
1910
+ if (badgeType) {
1911
+ setType(badgeType);
1912
+ }
1913
+ if (!!customColor || !!customBackgroundColor) {
1914
+ setType('');
1915
+ }
1916
+ }, [badgeType, customColor, customBackgroundColor]);
1917
+ return !isClosed ? jsxs("span", Object.assign({}, props, {
1918
+ className: `badge ${type}`,
1919
+ style: {
1920
+ color: customColor,
1921
+ backgroundColor: customBackgroundColor
1922
+ }
2087
1923
  }, {
2088
- children: children
2089
- }));
2090
- };
1924
+ children: [jsx("strong", {
1925
+ children: children
1926
+ }), isCloseable && jsxs("button", Object.assign({
1927
+ type: "button",
1928
+ className: "close",
1929
+ onClick: () => setIsClosed(true)
1930
+ }, {
1931
+ children: [closeText, jsx("i", {})]
1932
+ }))]
1933
+ })) : null;
1934
+ }
2091
1935
 
2092
- const ButtonGroup = ({
1936
+ function Card({
2093
1937
  children,
2094
- selectedIndex,
2095
- variant,
2096
- id
2097
- }) => {
2098
- const [selected, setSelected] = useState(selectedIndex);
2099
- const [buttons, setButtons] = useState([]);
2100
- useEffect(() => {
2101
- const buttonProps = (children instanceof Array ? children : [children]).filter(b => b && b.props).map((b, ix) => {
2102
- const bp = b.props;
2103
- const props = Object.assign(Object.assign({}, bp), {
2104
- variant,
2105
- key: bp.key || `btn_${ix}`,
2106
- active: ix === selected,
2107
- onClick: e => {
2108
- setSelected(ix);
2109
- if (bp.onClick) bp.onClick(e);
2110
- }
2111
- });
2112
- return props;
2113
- });
2114
- setButtons(buttonProps);
2115
- }, [children, selected, variant]);
2116
- return jsx(Group, Object.assign({
2117
- "data-label": "button-group",
2118
- id: id
1938
+ header,
1939
+ footer
1940
+ }) {
1941
+ return jsxs("section", Object.assign({
1942
+ className: "card"
2119
1943
  }, {
2120
- children: buttons.map(props => jsx(Button, Object.assign({}, props), props.key))
1944
+ children: [jsx("header", {
1945
+ children: header
1946
+ }), children, jsx("footer", {
1947
+ children: footer
1948
+ })]
2121
1949
  }));
2122
- };
2123
-
2124
- /* eslint-disable-next-line */
2125
- const validateInputValue = (target, rules, setError) => {
2126
- const errorMessage = validateInputValueErrors(rules, target);
2127
- errorMessage ? setErrorInsert(setError, target.name) : setErrorRemove(setError, target.name);
2128
- return errorMessage;
2129
- };
2130
- const validateInputValueErrors = (rules, target) => {
2131
- const {
2132
- value
2133
- } = target;
2134
- if ((rules === null || rules === void 0 ? void 0 : rules.custom) instanceof Function) {
2135
- return rules === null || rules === void 0 ? void 0 : rules.custom();
2136
- }
2137
- return validateTextInputValues(value, rules);
2138
- };
2139
- /* eslint-disable-next-line */
2140
- const setErrorInsert = (setError, name) => {
2141
- /* eslint-disable-next-line */
2142
- setError(errors => {
2143
- return Object.assign(Object.assign({}, errors), {
2144
- [name]: true
2145
- });
2146
- });
2147
- };
2148
- /* eslint-disable-next-line */
2149
- const setErrorRemove = (setError, name) => {
2150
- /* eslint-disable-next-line */
2151
- setError(errors => {
2152
- /* eslint-disable-next-line */
2153
- const newError = Object.assign({}, errors);
2154
- delete newError[name];
2155
- return newError;
2156
- });
2157
- };
2158
- const validateTextInputValues = (value, rules) => {
2159
- switch (rules === null || rules === void 0 ? void 0 : rules.type) {
2160
- case 'Required':
2161
- {
2162
- return value === '' || value === undefined || value === null ? 'error' : null;
2163
- }
2164
- default:
2165
- {
2166
- return;
2167
- }
2168
- }
2169
- };
1950
+ }
2170
1951
 
2171
- const FormContext = /*#__PURE__*/React.createContext({});
2172
- const useFormContext = () => {
2173
- return React.useContext(FormContext);
2174
- };
2175
- const FormProvider = _a => {
2176
- var {
2177
- children,
2178
- direction = 'vertical',
2179
- formSize = 'md',
2180
- onSubmit,
2181
- onFormSubmit
2182
- } = _a,
2183
- props = __rest(_a, ["children", "direction", "formSize", "onSubmit", "onFormSubmit"]);
2184
- /* eslint-disable-next-line */
2185
- const [values, setValues] = React.useState();
2186
- /* eslint-disable-next-line */
2187
- const [errors, setErrors] = React.useState();
2188
- /* eslint-disable-next-line */
2189
- const [fields, setFields] = React.useState({});
2190
- const formSubmit = event => {
2191
- let hasError = false;
2192
- event.preventDefault();
2193
- Object.keys(fields).forEach(key => {
2194
- const errorMessage = validateInputValue({
2195
- name: key,
2196
- value: values === null || values === void 0 ? void 0 : values[key]
2197
- }, fields[key], setErrors);
2198
- hasError = hasError || !!errorMessage;
2199
- });
2200
- if (!hasError) {
2201
- onFormSubmit && onFormSubmit(values);
1952
+ const useDatepicker = (datepickerRef, datepickerDialogRef, dateInputRef, datepickerTriggerRef, options = {}) => {
1953
+ const dataStub = {
1954
+ formattedSelectedDate: '',
1955
+ calendar: {
1956
+ headers: [],
1957
+ calendarGrid: []
2202
1958
  }
2203
1959
  };
2204
- const resetForm = () => {
2205
- setValues({});
2206
- setErrors({});
2207
- };
2208
- return jsx(FormContext.Provider, Object.assign({
2209
- value: {
2210
- setValues,
2211
- setErrors,
2212
- setFields,
2213
- errors,
2214
- values
1960
+ const [data, setData] = useState(dataStub);
1961
+ const [state, setState] = useState({
1962
+ isActive: false
1963
+ });
1964
+ const datepickerStub = {};
1965
+ const [datepicker, setDatepicker] = useState(datepickerStub);
1966
+ useEffect(() => {
1967
+ if (!datepicker.open && datepickerRef.current && datepickerDialogRef.current && dateInputRef.current && datepickerTriggerRef.current) {
1968
+ setDatepicker(createDatepicker((data, state) => {
1969
+ if (data) setData(data);
1970
+ if (state) setState(state);
1971
+ }, options, datepickerRef.current, datepickerDialogRef.current, dateInputRef.current, datepickerTriggerRef.current));
2215
1972
  }
2216
- }, {
2217
- children: jsx("form", Object.assign({
2218
- className: [direction, `size-${formSize}`].join(' '),
2219
- onSubmit: formSubmit
2220
- }, props, {
2221
- onReset: resetForm
2222
- }, {
2223
- children: children
2224
- }))
2225
- }));
2226
- };
2227
-
2228
- const Form = props => {
2229
- return jsx(FormProvider, Object.assign({}, props));
1973
+ }, [datepicker, datepickerRef, datepickerDialogRef, dateInputRef, datepickerTriggerRef, options]);
1974
+ return {
1975
+ datepicker,
1976
+ data,
1977
+ state
1978
+ };
2230
1979
  };
2231
1980
 
2232
- const FormItems = ({
2233
- children,
2234
- validate,
2235
- name
1981
+ const useDropdown = ({
1982
+ id,
1983
+ value,
1984
+ texts,
1985
+ options,
1986
+ loop,
1987
+ multiSelect,
1988
+ searchable,
1989
+ searchFilter,
1990
+ compareWith,
1991
+ useValue,
1992
+ display,
1993
+ togglerRef,
1994
+ listboxRef,
1995
+ onChange,
1996
+ validator
2236
1997
  }) => {
2237
- const {
2238
- setValues,
2239
- setErrors,
2240
- setFields,
2241
- errors
2242
- } = useFormContext();
2243
- React.useEffect(() => {
2244
- /* eslint-disable-next-line */
2245
- setFields(fields => Object.assign(Object.assign({}, fields), {
2246
- [name]: validate === null || validate === void 0 ? void 0 : validate.rules
2247
- }));
2248
- /* eslint-disable-next-line */
2249
- const removeValues = values => {
2250
- /* eslint-disable-next-line */
2251
- const newValues = Object.assign({}, values);
2252
- delete newValues[name];
2253
- return newValues;
2254
- };
2255
- return () => {
2256
- /* eslint-disable-next-line */
2257
- setFields(fields => removeValues(fields));
2258
- /* eslint-disable-next-line */
2259
- setValues(values => removeValues(values));
2260
- /* eslint-disable-next-line */
2261
- setErrors(errors => removeValues(errors));
2262
- };
2263
- // eslint-disable-next-line react-hooks/exhaustive-deps
2264
- }, []);
2265
- const onChange = event => {
2266
- if (!event.target) return;
1998
+ const [handler, setHandler] = useState();
1999
+ const [dropdown, setDropdown] = useState();
2000
+ const [togglerProps, setTogglerProps] = useState({});
2001
+ const [listboxProps, setListboxProps] = useState({});
2002
+ const [listItems, setListItems] = useState([]);
2003
+ const [multiSelectProps, setMultiSelectProps] = useState({});
2004
+ // When dropdown data changes
2005
+ useEffect(() => {
2006
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2007
+ if (!dropdown) return;
2267
2008
  const {
2268
- value,
2269
- name,
2270
- type,
2271
- checked
2272
- } = event.target;
2273
- let inputValue;
2274
- if (type === 'checkbox') {
2275
- inputValue = checked ? value : null;
2276
- /* eslint-disable-next-line */
2277
- checked ? setValues(values => Object.assign(Object.assign({}, values), {
2278
- [name]: value
2279
- })) : setValues(values => Object.assign(Object.assign({}, values), {
2280
- [name]: null
2281
- }));
2009
+ elements: {
2010
+ toggler,
2011
+ listbox
2012
+ }
2013
+ } = dropdown;
2014
+ const newToggleProps = Object.assign(Object.assign({}, toggler === null || toggler === void 0 ? void 0 : toggler.attributes), {
2015
+ className: (_a = toggler === null || toggler === void 0 ? void 0 : toggler.classes) === null || _a === void 0 ? void 0 : _a.join(' '),
2016
+ children: (_b = dropdown === null || dropdown === void 0 ? void 0 : dropdown.texts) === null || _b === void 0 ? void 0 : _b.select,
2017
+ onClick: () => handler === null || handler === void 0 ? void 0 : handler.toggle()
2018
+ });
2019
+ setTogglerProps(newToggleProps);
2020
+ const newListboxProps = Object.assign(Object.assign({}, listbox === null || listbox === void 0 ? void 0 : listbox.attributes), {
2021
+ className: (_c = listbox === null || listbox === void 0 ? void 0 : listbox.classes) === null || _c === void 0 ? void 0 : _c.join(' ')
2022
+ });
2023
+ setListboxProps(newListboxProps);
2024
+ if (!dropdown.isMultiSelect) {
2025
+ const newListItems = dropdown.options.map(o => {
2026
+ var _a;
2027
+ return Object.assign(Object.assign({}, o.attributes), {
2028
+ className: (_a = o.classes) === null || _a === void 0 ? void 0 : _a.join(' '),
2029
+ children: o[dropdown.display],
2030
+ selected: o.selected,
2031
+ onClick: () => handler === null || handler === void 0 ? void 0 : handler.select(o)
2032
+ });
2033
+ });
2034
+ setListItems(newListItems);
2282
2035
  } else {
2283
- inputValue = value;
2284
- /* eslint-disable-next-line */
2285
- setValues(values => Object.assign(Object.assign({}, values), {
2286
- [name]: value
2036
+ const checkboxes = dropdown.options.map(o => ({
2037
+ labelProps: Object.assign(Object.assign({}, o.attributes), {
2038
+ className: ['form-control', ...o.classes].join(' ')
2039
+ }),
2040
+ inputProps: {
2041
+ defaultChecked: o.selected,
2042
+ type: 'checkbox',
2043
+ onClick: () => handler === null || handler === void 0 ? void 0 : handler.select(o, false)
2044
+ },
2045
+ spanProps: {
2046
+ children: o[dropdown.display]
2047
+ }
2287
2048
  }));
2049
+ const newMultiselect = {
2050
+ fieldsetProps: {
2051
+ 'aria-describedby': (_f = (_e = (_d = dropdown === null || dropdown === void 0 ? void 0 : dropdown.elements) === null || _d === void 0 ? void 0 : _d.fieldset) === null || _e === void 0 ? void 0 : _e.attributes) === null || _f === void 0 ? void 0 : _f.id,
2052
+ 'aria-multiselectable': true,
2053
+ role: 'listbox',
2054
+ tabIndex: -1
2055
+ },
2056
+ legendProps: {
2057
+ className: 'sr-only',
2058
+ id: (_j = (_h = (_g = dropdown === null || dropdown === void 0 ? void 0 : dropdown.elements) === null || _g === void 0 ? void 0 : _g.fieldset) === null || _h === void 0 ? void 0 : _h.attributes) === null || _j === void 0 ? void 0 : _j.id,
2059
+ children: dropdown.texts.optionsDescription
2060
+ },
2061
+ checkboxes
2062
+ };
2063
+ setMultiSelectProps(newMultiselect);
2288
2064
  }
2289
- validateInputValue({
2290
- value: inputValue,
2291
- name,
2292
- type,
2293
- checked
2294
- }, validate === null || validate === void 0 ? void 0 : validate.rules, setErrors);
2065
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2066
+ }, [dropdown]);
2067
+ // When dropdown properties change
2068
+ useEffect(() => {
2069
+ if (!dropdown) return;
2070
+ handler === null || handler === void 0 ? void 0 : handler.update({
2071
+ id,
2072
+ value,
2073
+ texts,
2074
+ options,
2075
+ loop,
2076
+ multiSelect,
2077
+ searchable,
2078
+ searchFilter,
2079
+ compareWith,
2080
+ useValue,
2081
+ display,
2082
+ validator
2083
+ });
2084
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2085
+ }, [id, texts, options, loop, multiSelect, searchable, searchFilter, compareWith, useValue, display]);
2086
+ useEffect(() => {
2087
+ if (!dropdown) return;
2088
+ handler === null || handler === void 0 ? void 0 : handler.selectByValue(value);
2089
+ console.log('new value');
2090
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2091
+ }, [value]);
2092
+ // When validator changes
2093
+ useEffect(() => {
2094
+ if (!dropdown) return;
2095
+ if (validator) handler === null || handler === void 0 ? void 0 : handler.validate(validator);
2096
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2097
+ }, [validator]);
2098
+ // Create dropdown handler
2099
+ useEffect(() => {
2100
+ if (!handler && togglerRef.current && listboxRef.current) {
2101
+ setHandler(createDropdown({
2102
+ id,
2103
+ value,
2104
+ texts,
2105
+ options,
2106
+ loop,
2107
+ multiSelect,
2108
+ searchable,
2109
+ searchFilter,
2110
+ compareWith,
2111
+ useValue,
2112
+ display,
2113
+ validator
2114
+ }, togglerRef.current, listboxRef.current, listboxRef.current, dd => setDropdown(dd), value => onChange === null || onChange === void 0 ? void 0 : onChange(value)));
2115
+ }
2116
+ return () => handler === null || handler === void 0 ? void 0 : handler.destroy();
2117
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2118
+ }, [togglerRef, listboxRef]);
2119
+ return {
2120
+ dropdown: handler,
2121
+ togglerProps,
2122
+ listboxProps,
2123
+ listItems,
2124
+ multiSelectProps
2295
2125
  };
2296
- /* eslint-disable-next-line */
2297
- return /*#__PURE__*/React.cloneElement(children, {
2298
- validator: (errors === null || errors === void 0 ? void 0 : errors[name]) && validate,
2299
- name,
2300
- onChange
2301
- });
2302
2126
  };
2303
2127
 
2304
- function Group({
2128
+ const Dropdown = ({
2129
+ compareWith,
2130
+ display,
2305
2131
  id,
2306
- children,
2307
- error,
2308
- groupBorder = false
2309
- }) {
2310
- const groupClassName = `group ${groupBorder ? 'group-border' : ''} ${error ? 'is-invalid' : ''}`;
2311
- const errorMessage = error ? error.message || error : '';
2312
- return jsxs("div", Object.assign({
2313
- className: "form-group",
2314
- id: id
2315
- }, {
2316
- children: [jsx("div", Object.assign({
2317
- className: groupClassName
2318
- }, {
2319
- children: children
2320
- })), error && jsx("span", Object.assign({
2321
- className: "form-info"
2322
- }, {
2323
- children: errorMessage
2324
- }))]
2325
- }));
2326
- }
2327
-
2328
- const FormItem = ({
2329
- expandableInfo,
2132
+ informationLabel,
2330
2133
  label,
2331
- labelInformation,
2134
+ loop,
2135
+ multiSelect,
2136
+ onChange,
2137
+ options,
2138
+ searchFilter,
2139
+ searchable,
2140
+ texts,
2141
+ useValue,
2332
2142
  validator,
2333
- inputId,
2334
- children,
2335
- expandableInfoButtonLabel,
2336
- role
2143
+ value
2337
2144
  }) => {
2338
- const expandableInnerRef = useRef(null);
2339
- const expandableRef = useRef(null);
2340
- const [expandableHeight, setExpandableHeight] = useState(0);
2341
- const [isExpanded, setIsExpanded] = useState(false);
2342
- const [isHidden, setIsHidden] = useState(false);
2343
- useLayoutEffect(() => {
2344
- expandableInnerRef.current && setExpandableHeight(expandableInnerRef.current['clientHeight']);
2345
- setIsHidden(true);
2346
- }, []);
2347
- useEffect(() => {
2348
- const handleResize = debounce(function setExpandableHeightAfterResize() {
2349
- isExpanded && expandableInnerRef.current && setExpandableHeight(expandableInnerRef.current['clientHeight']);
2350
- }, 300);
2351
- if (expandableRef.current) {
2352
- window.addEventListener('resize', handleResize);
2353
- }
2354
- return () => {
2355
- window.removeEventListener('resize', handleResize);
2145
+ var _a;
2146
+ const togglerRef = useRef(null);
2147
+ const listboxRef = useRef(null);
2148
+ const {
2149
+ dropdown,
2150
+ listboxProps,
2151
+ togglerProps,
2152
+ listItems,
2153
+ multiSelectProps
2154
+ } = useDropdown({
2155
+ id,
2156
+ value,
2157
+ options,
2158
+ loop,
2159
+ multiSelect,
2160
+ searchable,
2161
+ searchFilter,
2162
+ compareWith,
2163
+ useValue,
2164
+ display,
2165
+ togglerRef,
2166
+ listboxRef,
2167
+ texts,
2168
+ onChange,
2169
+ validator
2170
+ });
2171
+ const getListBoxProps = props => {
2172
+ var _a, _b, _c;
2173
+ if (Object.keys(props).length === 0) return {
2174
+ role: 'listbox',
2175
+ tabIndex: -1,
2176
+ className: (_c = (_b = (_a = dropdownValues().elements) === null || _a === void 0 ? void 0 : _a.listbox) === null || _b === void 0 ? void 0 : _b.classes) === null || _c === void 0 ? void 0 : _c.join(' ')
2356
2177
  };
2357
- }, [isExpanded, expandableInnerRef]);
2358
- if (!inputId) inputId = randomId();
2359
- const formItemClassNames = classNames('gds-form-item', validator && validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator));
2178
+ return props;
2179
+ };
2360
2180
  return jsxs("div", Object.assign({
2361
- className: formItemClassNames,
2362
- role: role ? role : undefined,
2363
- "aria-labelledby": role ? `${inputId}-label` : undefined
2181
+ className: "form-group"
2364
2182
  }, {
2365
- children: [expandableInfo && jsx("div", {
2366
- className: "gds-form-item__backdrop"
2367
- }), jsxs("div", Object.assign({
2368
- className: "gds-form-item__header"
2183
+ children: [label && jsx("label", Object.assign({
2184
+ htmlFor: togglerProps.id
2185
+ }, {
2186
+ children: label
2187
+ })), informationLabel && jsx("div", Object.assign({
2188
+ className: "form-info"
2189
+ }, {
2190
+ children: informationLabel
2191
+ })), jsx("button", Object.assign({
2192
+ type: "button"
2193
+ }, togglerProps, {
2194
+ ref: togglerRef
2195
+ }, {
2196
+ children: jsx("span", {
2197
+ children: togglerProps.children
2198
+ })
2199
+ })), jsxs("div", Object.assign({}, getListBoxProps(listboxProps), {
2200
+ ref: listboxRef
2369
2201
  }, {
2370
2202
  children: [jsxs("div", Object.assign({
2371
- className: "gds-form-item__labels"
2203
+ className: "d-flex d-sm-none align-items-center"
2372
2204
  }, {
2373
- children: [label && jsx("label", Object.assign({
2374
- id: role ? `${inputId}-label` : undefined,
2375
- htmlFor: role ? undefined : inputId
2205
+ children: [jsx("span", Object.assign({
2206
+ className: "flex-grow-1 ps-4 fs-2 fw-bolder"
2376
2207
  }, {
2377
2208
  children: label
2378
- })), labelInformation && jsx("div", Object.assign({
2379
- className: "form-info",
2380
- id: `${inputId}_info`
2209
+ })), jsx("button", Object.assign({
2210
+ type: "button",
2211
+ className: "close m-4 m-sm-2 d-block d-sm-none",
2212
+ onClick: dropdown === null || dropdown === void 0 ? void 0 : dropdown.close,
2213
+ "aria-label": dropdown === null || dropdown === void 0 ? void 0 : dropdown.dropdown.texts.close
2381
2214
  }, {
2382
- children: labelInformation
2215
+ children: jsx("i", {})
2383
2216
  }))]
2384
- })), expandableInfo && jsx(IconButton, Object.assign({
2385
- "aria-expanded": isExpanded,
2386
- "aria-controls": `${inputId}-expandable-info`,
2387
- onClick: event => __awaiter(void 0, void 0, void 0, function* () {
2388
- if (!isExpanded) {
2389
- setIsHidden(false);
2390
- yield delay(10);
2391
- expandableInnerRef.current && setExpandableHeight(expandableInnerRef.current['clientHeight']);
2392
- setIsExpanded(true);
2393
- } else {
2394
- setIsExpanded(false);
2395
- yield delay(300);
2396
- setIsHidden(true);
2397
- }
2398
- })
2217
+ })), (dropdown === null || dropdown === void 0 ? void 0 : dropdown.dropdown.isMultiSelect) ? jsx("div", Object.assign({
2218
+ className: "sg-fieldset-container"
2399
2219
  }, {
2400
- children: isExpanded ? jsx(Times, {
2401
- title: expandableInfoButtonLabel
2402
- }) : jsx(InfoCircle, {
2403
- title: expandableInfoButtonLabel
2404
- })
2405
- }))]
2406
- })), expandableInfo && jsx("div", Object.assign({
2407
- ref: expandableRef,
2408
- id: `gds-expandable-info-${inputId}`,
2409
- className: "gds-form-item__expandable-info",
2410
- hidden: isHidden,
2411
- style: {
2412
- height: isExpanded ? expandableHeight : 0
2413
- }
2414
- }, {
2415
- children: jsxs("div", Object.assign({
2416
- ref: expandableInnerRef
2220
+ children: jsxs("fieldset", Object.assign({}, multiSelectProps.fieldsetProps, {
2221
+ children: [jsx("legend", Object.assign({}, multiSelectProps.legendProps)), (_a = multiSelectProps.checkboxes) === null || _a === void 0 ? void 0 : _a.map(checkboxItem => jsxs("label", Object.assign({}, checkboxItem.labelProps, {
2222
+ children: [jsx("input", Object.assign({}, checkboxItem.inputProps)), jsx("span", Object.assign({}, checkboxItem.spanProps)), jsx("i", {})]
2223
+ }), checkboxItem.labelProps.id))]
2224
+ }))
2225
+ })) : jsx("ul", Object.assign({
2226
+ role: "listbox"
2417
2227
  }, {
2418
- children: [" ", expandableInfo, " "]
2419
- }))
2420
- })), children, jsx("div", Object.assign({
2421
- className: "gds-form-item__footer"
2228
+ children: listItems.map(liProps => jsx("li", Object.assign({}, liProps), liProps.id))
2229
+ }))]
2230
+ })), validator && jsx("span", Object.assign({
2231
+ className: "form-info"
2422
2232
  }, {
2423
- children: validator && jsx("span", Object.assign({
2424
- className: "form-info"
2425
- }, {
2426
- children: validator.message
2427
- }))
2233
+ children: validator === null || validator === void 0 ? void 0 : validator.message
2428
2234
  }))]
2429
2235
  }));
2430
2236
  };
2431
2237
 
2432
- const useInput = (props, onChanges, onChangeInput) => {
2433
- const id = useMemo(() => props.id || randomId(), [props.id]);
2434
- const ref = useRef(null);
2435
- const onChange = event => {
2436
- onChanges && onChanges(event);
2437
- onChangeInput && onChangeInput(event.target.value);
2438
- };
2439
- return Object.assign(Object.assign({}, props), {
2440
- id,
2441
- ref,
2442
- onChange
2443
- });
2444
- };
2445
-
2446
- const RenderInput = (type, props, onChange, onChangeInput, label, info, validator, expandableInfo, expandableInfoButtonLabel, testId) => {
2447
- const _a = useInput(props, onChange, onChangeInput),
2448
- {
2449
- value
2450
- } = _a,
2451
- inputProps = __rest(_a, ["value"]);
2452
- const propsWithDescription = info ? Object.assign(Object.assign({}, inputProps), {
2453
- 'aria-describedby': `${inputProps.id}_info`
2454
- }) : inputProps;
2455
- // Render naked
2456
- if (!label && !info && !expandableInfo) return jsx("input", Object.assign({
2457
- type: type,
2458
- value: value,
2459
- "data-testid": testId
2460
- }, propsWithDescription));
2461
- return jsx(FormItem, Object.assign({
2462
- validator: validator,
2463
- labelInformation: info,
2464
- label: label,
2465
- expandableInfo: expandableInfo,
2466
- expandableInfoButtonLabel: expandableInfoButtonLabel,
2467
- inputId: inputProps.id
2468
- }, {
2469
- children: jsx("div", Object.assign({
2470
- className: "gds-input-wrapper"
2238
+ const Datepicker = (options = {}) => {
2239
+ const [uuid] = useState(randomId());
2240
+ const id = `sgr-datepicker-${uuid}`;
2241
+ const datepickerRef = useRef(null);
2242
+ const datepickerTriggerRef = useRef(null);
2243
+ const datepickerDialogRef = useRef(null);
2244
+ const dateInputRef = useRef(null);
2245
+ const {
2246
+ datepicker,
2247
+ data,
2248
+ state
2249
+ } = useDatepicker(datepickerRef, datepickerDialogRef, dateInputRef, datepickerTriggerRef, options);
2250
+ useEffect(() => {
2251
+ var _a;
2252
+ const selDateSub = (_a = datepicker.selectedDate$) === null || _a === void 0 ? void 0 : _a.subscribe(newDate => options.onChange && options.onChange(newDate));
2253
+ return () => selDateSub === null || selDateSub === void 0 ? void 0 : selDateSub.unsubscribe();
2254
+ }, [datepicker, options]);
2255
+ const classNames = day => Object.entries({
2256
+ disabled: !day.currentMonth,
2257
+ 'sg-date-today': day.today
2258
+ // 'sg-date-holiday': day.holiday,
2259
+ }).map(([className, add]) => add ? className : '').join(' ');
2260
+ return jsxs(Fragment, {
2261
+ children: [jsxs("div", Object.assign({
2262
+ className: "form-group"
2471
2263
  }, {
2472
- children: jsx("input", Object.assign({
2473
- type: type,
2474
- value: value
2475
- }, propsWithDescription, {
2476
- className: validator && validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator),
2477
- "data-testid": testId
2478
- }))
2479
- }))
2480
- }));
2481
- };
2482
- const TextInput = _a => {
2483
- var {
2484
- label,
2485
- info,
2486
- testId,
2487
- onChange,
2488
- onChangeInput,
2489
- validator,
2490
- expandableInfo,
2491
- expandableInfoButtonLabel
2492
- } = _a,
2493
- props = __rest(_a, ["label", "info", "testId", "onChange", "onChangeInput", "validator", "expandableInfo", "expandableInfoButtonLabel"]);
2494
- return RenderInput('text', props, onChange, onChangeInput, label, info, validator, expandableInfo, expandableInfoButtonLabel, testId);
2495
- };
2496
- const EmailInput = _a => {
2497
- var {
2498
- label,
2499
- info,
2500
- onChange,
2501
- onChangeInput,
2502
- validator,
2503
- testId
2504
- } = _a,
2505
- props = __rest(_a, ["label", "info", "onChange", "onChangeInput", "validator", "testId"]);
2506
- return RenderInput('email', props, onChange, onChangeInput, label, info, validator, testId);
2507
- };
2508
- const NumberInput = _a => {
2509
- var {
2510
- label,
2264
+ children: [jsx("label", Object.assign({
2265
+ htmlFor: id
2266
+ }, {
2267
+ children: "Date"
2268
+ })), jsxs("div", Object.assign({
2269
+ className: "group",
2270
+ ref: datepickerRef
2271
+ }, {
2272
+ children: [jsx("input", {
2273
+ ref: dateInputRef,
2274
+ id: id,
2275
+ type: "text",
2276
+ placeholder: "yyyy-mm-dd",
2277
+ value: data.formattedSelectedDate,
2278
+ onChange: e => datepicker.select(e.target.value)
2279
+ }), jsx("button", Object.assign({
2280
+ ref: datepickerTriggerRef,
2281
+ type: "button",
2282
+ className: "primary",
2283
+ onClick: () => datepicker.toggle()
2284
+ }, {
2285
+ children: jsx("i", Object.assign({
2286
+ className: "sg-icon sg-icon-calendar"
2287
+ }, {
2288
+ children: "Select date"
2289
+ }))
2290
+ }))]
2291
+ })), jsx("span", Object.assign({
2292
+ className: "form-info"
2293
+ }, {
2294
+ children: "Select a date"
2295
+ }))]
2296
+ })), jsx("div", Object.assign({
2297
+ ref: datepickerDialogRef,
2298
+ className: `popover popover-datepicker ${state.isActive ? 'active' : ''}`,
2299
+ role: "dialog",
2300
+ "aria-modal": "true",
2301
+ "aria-label": "Choose Date"
2302
+ }, {
2303
+ children: state.isActive && jsxs("div", Object.assign({
2304
+ className: "sg-date"
2305
+ }, {
2306
+ children: [jsxs("header", {
2307
+ children: [jsx("button", Object.assign({
2308
+ className: "link",
2309
+ onClick: () => datepicker.sub(1, 'months')
2310
+ }, {
2311
+ children: jsx("i", Object.assign({
2312
+ className: "sg-icon sg-icon-previous"
2313
+ }, {
2314
+ children: "Previous month"
2315
+ }))
2316
+ })), jsx(Dropdown, {
2317
+ options: months({}),
2318
+ display: "key",
2319
+ texts: {
2320
+ placeholder: data.monthName
2321
+ }
2322
+ }), jsx(Dropdown, {
2323
+ options: years({}),
2324
+ display: "key",
2325
+ texts: {
2326
+ placeholder: data.year + ''
2327
+ }
2328
+ }), jsx("button", Object.assign({
2329
+ className: "link",
2330
+ onClick: () => datepicker.add(1, 'months')
2331
+ }, {
2332
+ children: jsx("i", Object.assign({
2333
+ className: "sg-icon sg-icon-next"
2334
+ }, {
2335
+ children: "Next month"
2336
+ }))
2337
+ }))]
2338
+ }), jsx("main", {
2339
+ children: jsxs("table", Object.assign({
2340
+ role: "grid"
2341
+ }, {
2342
+ children: [jsx("thead", {
2343
+ children: jsx("tr", {
2344
+ children: data.calendar.headers.map((header, ix) => jsx("th", Object.assign({
2345
+ scope: "col",
2346
+ abbr: header.abbr,
2347
+ className: header.type === 'week' ? 'sg-week-header' : 'sg-day-header'
2348
+ }, {
2349
+ children: header.displayText
2350
+ }), `week_${ix}`))
2351
+ })
2352
+ }), jsx("tbody", {
2353
+ children: data.calendar.calendarGrid.map((week, ix) => jsxs("tr", {
2354
+ children: [data.calendar.weekNumbers ? jsx("th", Object.assign({
2355
+ className: "sg-week-number"
2356
+ }, {
2357
+ children: data.calendar.weekNumbers[ix]
2358
+ })) : '', week.map(day => jsx("td", Object.assign({
2359
+ "data-date": day.formattedDate,
2360
+ className: classNames(day),
2361
+ title: day.today ? 'Today' : '',
2362
+ tabIndex: day.highlighted || day.selected && !(data === null || data === void 0 ? void 0 : data.highlightedDate) || day.today && !(data === null || data === void 0 ? void 0 : data.highlightedDate) && !(data === null || data === void 0 ? void 0 : data.selectedDate) ? 0 : -1,
2363
+ role: day.selected ? 'gridcell' : undefined,
2364
+ "aria-selected": day.selected && !(data === null || data === void 0 ? void 0 : data.highlightedDate) ? true : undefined,
2365
+ onClick: () => {
2366
+ day.currentMonth && datepicker.select(day.date);
2367
+ }
2368
+ }, {
2369
+ children: day.day
2370
+ }), day.day))]
2371
+ }, `week_${ix}`))
2372
+ })]
2373
+ }))
2374
+ })]
2375
+ }))
2376
+ }))]
2377
+ });
2378
+ };
2379
+
2380
+ function Button({
2381
+ children,
2382
+ variant,
2383
+ onClick,
2384
+ disabled,
2385
+ active = false,
2386
+ type = 'button',
2387
+ size
2388
+ }) {
2389
+ const props = {
2390
+ type,
2391
+ disabled
2392
+ };
2393
+ const classNames = [];
2394
+ if (variant) classNames.push(variant);
2395
+ if (active) classNames.push('active');
2396
+ if (size) classNames.push(size);
2397
+ if (classNames.length) props.className = classNames.join(' ');
2398
+ if (onClick) props.onClick = onClick;
2399
+ return jsx("button", Object.assign({}, props, {
2400
+ children: children
2401
+ }));
2402
+ }
2403
+
2404
+ const IconButton = _a => {
2405
+ var {
2406
+ children,
2407
+ onClick
2408
+ } = _a,
2409
+ props = __rest(_a, ["children", "onClick"]);
2410
+ return jsx("button", Object.assign({
2411
+ className: "icon",
2412
+ onClick: onClick,
2413
+ "aria-controls": props['aria-controls'],
2414
+ "aria-expanded": props['aria-expanded']
2415
+ }, {
2416
+ children: children
2417
+ }));
2418
+ };
2419
+
2420
+ const ButtonGroup = ({
2421
+ children,
2422
+ selectedIndex,
2423
+ variant,
2424
+ id
2425
+ }) => {
2426
+ const [selected, setSelected] = useState(selectedIndex);
2427
+ const [buttons, setButtons] = useState([]);
2428
+ useEffect(() => {
2429
+ const buttonProps = (children instanceof Array ? children : [children]).filter(b => b && b.props).map((b, ix) => {
2430
+ const bp = b.props;
2431
+ const props = Object.assign(Object.assign({}, bp), {
2432
+ variant,
2433
+ key: bp.key || `btn_${ix}`,
2434
+ active: ix === selected,
2435
+ onClick: e => {
2436
+ setSelected(ix);
2437
+ if (bp.onClick) bp.onClick(e);
2438
+ }
2439
+ });
2440
+ return props;
2441
+ });
2442
+ setButtons(buttonProps);
2443
+ }, [children, selected, variant]);
2444
+ return jsx(Group, Object.assign({
2445
+ "data-label": "button-group",
2446
+ id: id
2447
+ }, {
2448
+ children: buttons.map(props => jsx(Button, Object.assign({}, props), props.key))
2449
+ }));
2450
+ };
2451
+
2452
+ /* eslint-disable-next-line */
2453
+ const validateInputValue = (target, rules, setError) => {
2454
+ const errorMessage = validateInputValueErrors(rules, target);
2455
+ errorMessage ? setErrorInsert(setError, target.name) : setErrorRemove(setError, target.name);
2456
+ return errorMessage;
2457
+ };
2458
+ const validateInputValueErrors = (rules, target) => {
2459
+ const {
2460
+ value
2461
+ } = target;
2462
+ if ((rules === null || rules === void 0 ? void 0 : rules.custom) instanceof Function) {
2463
+ return rules === null || rules === void 0 ? void 0 : rules.custom();
2464
+ }
2465
+ return validateTextInputValues(value, rules);
2466
+ };
2467
+ /* eslint-disable-next-line */
2468
+ const setErrorInsert = (setError, name) => {
2469
+ /* eslint-disable-next-line */
2470
+ setError(errors => {
2471
+ return Object.assign(Object.assign({}, errors), {
2472
+ [name]: true
2473
+ });
2474
+ });
2475
+ };
2476
+ /* eslint-disable-next-line */
2477
+ const setErrorRemove = (setError, name) => {
2478
+ /* eslint-disable-next-line */
2479
+ setError(errors => {
2480
+ /* eslint-disable-next-line */
2481
+ const newError = Object.assign({}, errors);
2482
+ delete newError[name];
2483
+ return newError;
2484
+ });
2485
+ };
2486
+ const validateTextInputValues = (value, rules) => {
2487
+ switch (rules === null || rules === void 0 ? void 0 : rules.type) {
2488
+ case 'Required':
2489
+ {
2490
+ return value === '' || value === undefined || value === null ? 'error' : null;
2491
+ }
2492
+ default:
2493
+ {
2494
+ return;
2495
+ }
2496
+ }
2497
+ };
2498
+
2499
+ const FormContext = /*#__PURE__*/React.createContext({});
2500
+ const useFormContext = () => {
2501
+ return React.useContext(FormContext);
2502
+ };
2503
+ const FormProvider = _a => {
2504
+ var {
2505
+ children,
2506
+ direction = 'vertical',
2507
+ formSize = 'md',
2508
+ onSubmit,
2509
+ onFormSubmit
2510
+ } = _a,
2511
+ props = __rest(_a, ["children", "direction", "formSize", "onSubmit", "onFormSubmit"]);
2512
+ /* eslint-disable-next-line */
2513
+ const [values, setValues] = React.useState();
2514
+ /* eslint-disable-next-line */
2515
+ const [errors, setErrors] = React.useState();
2516
+ /* eslint-disable-next-line */
2517
+ const [fields, setFields] = React.useState({});
2518
+ const formSubmit = event => {
2519
+ let hasError = false;
2520
+ event.preventDefault();
2521
+ Object.keys(fields).forEach(key => {
2522
+ const errorMessage = validateInputValue({
2523
+ name: key,
2524
+ value: values === null || values === void 0 ? void 0 : values[key]
2525
+ }, fields[key], setErrors);
2526
+ hasError = hasError || !!errorMessage;
2527
+ });
2528
+ if (!hasError) {
2529
+ onFormSubmit && onFormSubmit(values);
2530
+ }
2531
+ };
2532
+ const resetForm = () => {
2533
+ setValues({});
2534
+ setErrors({});
2535
+ };
2536
+ return jsx(FormContext.Provider, Object.assign({
2537
+ value: {
2538
+ setValues,
2539
+ setErrors,
2540
+ setFields,
2541
+ errors,
2542
+ values
2543
+ }
2544
+ }, {
2545
+ children: jsx("form", Object.assign({
2546
+ className: [direction, `size-${formSize}`].join(' '),
2547
+ onSubmit: formSubmit
2548
+ }, props, {
2549
+ onReset: resetForm
2550
+ }, {
2551
+ children: children
2552
+ }))
2553
+ }));
2554
+ };
2555
+
2556
+ const Form = props => {
2557
+ return jsx(FormProvider, Object.assign({}, props));
2558
+ };
2559
+
2560
+ const FormItems = ({
2561
+ children,
2562
+ validate,
2563
+ name
2564
+ }) => {
2565
+ const {
2566
+ setValues,
2567
+ setErrors,
2568
+ setFields,
2569
+ errors
2570
+ } = useFormContext();
2571
+ React.useEffect(() => {
2572
+ /* eslint-disable-next-line */
2573
+ setFields(fields => Object.assign(Object.assign({}, fields), {
2574
+ [name]: validate === null || validate === void 0 ? void 0 : validate.rules
2575
+ }));
2576
+ /* eslint-disable-next-line */
2577
+ const removeValues = values => {
2578
+ /* eslint-disable-next-line */
2579
+ const newValues = Object.assign({}, values);
2580
+ delete newValues[name];
2581
+ return newValues;
2582
+ };
2583
+ return () => {
2584
+ /* eslint-disable-next-line */
2585
+ setFields(fields => removeValues(fields));
2586
+ /* eslint-disable-next-line */
2587
+ setValues(values => removeValues(values));
2588
+ /* eslint-disable-next-line */
2589
+ setErrors(errors => removeValues(errors));
2590
+ };
2591
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2592
+ }, []);
2593
+ const onChange = event => {
2594
+ if (!event.target) return;
2595
+ const {
2596
+ value,
2597
+ name,
2598
+ type,
2599
+ checked
2600
+ } = event.target;
2601
+ let inputValue;
2602
+ if (type === 'checkbox') {
2603
+ inputValue = checked ? value : null;
2604
+ /* eslint-disable-next-line */
2605
+ checked ? setValues(values => Object.assign(Object.assign({}, values), {
2606
+ [name]: value
2607
+ })) : setValues(values => Object.assign(Object.assign({}, values), {
2608
+ [name]: null
2609
+ }));
2610
+ } else {
2611
+ inputValue = value;
2612
+ /* eslint-disable-next-line */
2613
+ setValues(values => Object.assign(Object.assign({}, values), {
2614
+ [name]: value
2615
+ }));
2616
+ }
2617
+ validateInputValue({
2618
+ value: inputValue,
2619
+ name,
2620
+ type,
2621
+ checked
2622
+ }, validate === null || validate === void 0 ? void 0 : validate.rules, setErrors);
2623
+ };
2624
+ /* eslint-disable-next-line */
2625
+ return /*#__PURE__*/React.cloneElement(children, {
2626
+ validator: (errors === null || errors === void 0 ? void 0 : errors[name]) && validate,
2627
+ name,
2628
+ onChange
2629
+ });
2630
+ };
2631
+
2632
+ function Group({
2633
+ id,
2634
+ children,
2635
+ error,
2636
+ groupBorder = false
2637
+ }) {
2638
+ const groupClassName = `group ${groupBorder ? 'group-border' : ''} ${error ? 'is-invalid' : ''}`;
2639
+ const errorMessage = error ? error.message || error : '';
2640
+ return jsxs("div", Object.assign({
2641
+ className: "form-group",
2642
+ id: id
2643
+ }, {
2644
+ children: [jsx("div", Object.assign({
2645
+ className: groupClassName
2646
+ }, {
2647
+ children: children
2648
+ })), error && jsx("span", Object.assign({
2649
+ className: "form-info"
2650
+ }, {
2651
+ children: errorMessage
2652
+ }))]
2653
+ }));
2654
+ }
2655
+
2656
+ const FormItem = ({
2657
+ expandableInfo,
2658
+ label,
2659
+ labelInformation,
2660
+ validator,
2661
+ inputId,
2662
+ children,
2663
+ expandableInfoButtonLabel,
2664
+ role
2665
+ }) => {
2666
+ const expandableInnerRef = useRef(null);
2667
+ const expandableRef = useRef(null);
2668
+ const [expandableHeight, setExpandableHeight] = useState(0);
2669
+ const [isExpanded, setIsExpanded] = useState(false);
2670
+ const [isHidden, setIsHidden] = useState(false);
2671
+ useLayoutEffect(() => {
2672
+ expandableInnerRef.current && setExpandableHeight(expandableInnerRef.current['clientHeight']);
2673
+ setIsHidden(true);
2674
+ }, []);
2675
+ useEffect(() => {
2676
+ const handleResize = debounce(function setExpandableHeightAfterResize() {
2677
+ isExpanded && expandableInnerRef.current && setExpandableHeight(expandableInnerRef.current['clientHeight']);
2678
+ }, 300);
2679
+ if (expandableRef.current) {
2680
+ window.addEventListener('resize', handleResize);
2681
+ }
2682
+ return () => {
2683
+ window.removeEventListener('resize', handleResize);
2684
+ };
2685
+ }, [isExpanded, expandableInnerRef]);
2686
+ if (!inputId) inputId = randomId();
2687
+ const formItemClassNames = classNames('gds-form-item', validator && validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator));
2688
+ return jsxs("div", Object.assign({
2689
+ className: formItemClassNames,
2690
+ role: role ? role : undefined,
2691
+ "aria-labelledby": role ? `${inputId}-label` : undefined
2692
+ }, {
2693
+ children: [expandableInfo && jsx("div", {
2694
+ className: "gds-form-item__backdrop"
2695
+ }), jsxs("div", Object.assign({
2696
+ className: "gds-form-item__header"
2697
+ }, {
2698
+ children: [jsxs("div", Object.assign({
2699
+ className: "gds-form-item__labels"
2700
+ }, {
2701
+ children: [label && jsx("label", Object.assign({
2702
+ id: role ? `${inputId}-label` : undefined,
2703
+ htmlFor: role ? undefined : inputId
2704
+ }, {
2705
+ children: label
2706
+ })), labelInformation && jsx("div", Object.assign({
2707
+ className: "form-info",
2708
+ id: `${inputId}_info`
2709
+ }, {
2710
+ children: labelInformation
2711
+ }))]
2712
+ })), expandableInfo && jsx(IconButton, Object.assign({
2713
+ "aria-expanded": isExpanded,
2714
+ "aria-controls": `${inputId}-expandable-info`,
2715
+ onClick: event => __awaiter(void 0, void 0, void 0, function* () {
2716
+ if (!isExpanded) {
2717
+ setIsHidden(false);
2718
+ yield delay(10);
2719
+ expandableInnerRef.current && setExpandableHeight(expandableInnerRef.current['clientHeight']);
2720
+ setIsExpanded(true);
2721
+ } else {
2722
+ setIsExpanded(false);
2723
+ yield delay(300);
2724
+ setIsHidden(true);
2725
+ }
2726
+ })
2727
+ }, {
2728
+ children: isExpanded ? jsx(Times, {
2729
+ title: expandableInfoButtonLabel
2730
+ }) : jsx(InfoCircle, {
2731
+ title: expandableInfoButtonLabel
2732
+ })
2733
+ }))]
2734
+ })), expandableInfo && jsx("div", Object.assign({
2735
+ ref: expandableRef,
2736
+ id: `gds-expandable-info-${inputId}`,
2737
+ className: "gds-form-item__expandable-info",
2738
+ hidden: isHidden,
2739
+ style: {
2740
+ height: isExpanded ? expandableHeight : 0
2741
+ }
2742
+ }, {
2743
+ children: jsxs("div", Object.assign({
2744
+ ref: expandableInnerRef
2745
+ }, {
2746
+ children: [" ", expandableInfo, " "]
2747
+ }))
2748
+ })), children, jsx("div", Object.assign({
2749
+ className: "gds-form-item__footer"
2750
+ }, {
2751
+ children: validator && jsx("span", Object.assign({
2752
+ className: "form-info"
2753
+ }, {
2754
+ children: validator.message
2755
+ }))
2756
+ }))]
2757
+ }));
2758
+ };
2759
+
2760
+ const useInput = (props, onChanges, onChangeInput) => {
2761
+ const id = useMemo(() => props.id || randomId(), [props.id]);
2762
+ const ref = useRef(null);
2763
+ const onChange = event => {
2764
+ onChanges && onChanges(event);
2765
+ onChangeInput && onChangeInput(event.target.value);
2766
+ };
2767
+ return Object.assign(Object.assign({}, props), {
2768
+ id,
2769
+ ref,
2770
+ onChange
2771
+ });
2772
+ };
2773
+
2774
+ const RenderInput = (type, props, onChange, onChangeInput, label, info, validator, expandableInfo, expandableInfoButtonLabel, testId) => {
2775
+ const _a = useInput(props, onChange, onChangeInput),
2776
+ {
2777
+ value
2778
+ } = _a,
2779
+ inputProps = __rest(_a, ["value"]);
2780
+ const propsWithDescription = info ? Object.assign(Object.assign({}, inputProps), {
2781
+ 'aria-describedby': `${inputProps.id}_info`
2782
+ }) : inputProps;
2783
+ // Render naked
2784
+ if (!label && !info && !expandableInfo) return jsx("input", Object.assign({
2785
+ type: type,
2786
+ value: value,
2787
+ "data-testid": testId
2788
+ }, propsWithDescription));
2789
+ return jsx(FormItem, Object.assign({
2790
+ validator: validator,
2791
+ labelInformation: info,
2792
+ label: label,
2793
+ expandableInfo: expandableInfo,
2794
+ expandableInfoButtonLabel: expandableInfoButtonLabel,
2795
+ inputId: inputProps.id
2796
+ }, {
2797
+ children: jsx("div", Object.assign({
2798
+ className: "gds-input-wrapper"
2799
+ }, {
2800
+ children: jsx("input", Object.assign({
2801
+ type: type,
2802
+ value: value
2803
+ }, propsWithDescription, {
2804
+ className: validator && validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator),
2805
+ "data-testid": testId
2806
+ }))
2807
+ }))
2808
+ }));
2809
+ };
2810
+ const TextInput = _a => {
2811
+ var {
2812
+ label,
2813
+ info,
2814
+ testId,
2815
+ onChange,
2816
+ onChangeInput,
2817
+ validator,
2818
+ expandableInfo,
2819
+ expandableInfoButtonLabel
2820
+ } = _a,
2821
+ props = __rest(_a, ["label", "info", "testId", "onChange", "onChangeInput", "validator", "expandableInfo", "expandableInfoButtonLabel"]);
2822
+ return RenderInput('text', props, onChange, onChangeInput, label, info, validator, expandableInfo, expandableInfoButtonLabel, testId);
2823
+ };
2824
+ const EmailInput = _a => {
2825
+ var {
2826
+ label,
2827
+ info,
2828
+ onChange,
2829
+ onChangeInput,
2830
+ validator,
2831
+ testId
2832
+ } = _a,
2833
+ props = __rest(_a, ["label", "info", "onChange", "onChangeInput", "validator", "testId"]);
2834
+ return RenderInput('email', props, onChange, onChangeInput, label, info, validator, testId);
2835
+ };
2836
+ const NumberInput = _a => {
2837
+ var {
2838
+ label,
2511
2839
  info,
2512
2840
  onChange,
2513
2841
  onChangeInput,
@@ -2629,7 +2957,7 @@ var classof = classof$1;
2629
2957
 
2630
2958
  var $String = String;
2631
2959
 
2632
- var toString$1 = function (argument) {
2960
+ var toString$3 = function (argument) {
2633
2961
  if (classof(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
2634
2962
  return $String(argument);
2635
2963
  };
@@ -2643,18 +2971,18 @@ var defineBuiltInAccessor$1 = function (target, name, descriptor) {
2643
2971
  return defineProperty.f(target, name, descriptor);
2644
2972
  };
2645
2973
 
2646
- var $ = _export;
2974
+ var $$1 = _export;
2647
2975
  var DESCRIPTORS = descriptors;
2648
- var global$1 = global$c;
2649
- var uncurryThis = functionUncurryThis;
2976
+ var global$2 = global$d;
2977
+ var uncurryThis$2 = functionUncurryThis;
2650
2978
  var hasOwn = hasOwnProperty_1;
2651
2979
  var isCallable = isCallable$g;
2652
2980
  var isPrototypeOf = objectIsPrototypeOf;
2653
- var toString = toString$1;
2981
+ var toString$2 = toString$3;
2654
2982
  var defineBuiltInAccessor = defineBuiltInAccessor$1;
2655
2983
  var copyConstructorProperties = copyConstructorProperties$2;
2656
2984
 
2657
- var NativeSymbol = global$1.Symbol;
2985
+ var NativeSymbol = global$2.Symbol;
2658
2986
  var SymbolPrototype = NativeSymbol && NativeSymbol.prototype;
2659
2987
 
2660
2988
  if (DESCRIPTORS && isCallable(NativeSymbol) && (!('description' in SymbolPrototype) ||
@@ -2664,7 +2992,7 @@ if (DESCRIPTORS && isCallable(NativeSymbol) && (!('description' in SymbolPrototy
2664
2992
  var EmptyStringDescriptionStore = {};
2665
2993
  // wrap Symbol constructor for correct work with undefined description
2666
2994
  var SymbolWrapper = function Symbol() {
2667
- var description = arguments.length < 1 || arguments[0] === undefined ? undefined : toString(arguments[0]);
2995
+ var description = arguments.length < 1 || arguments[0] === undefined ? undefined : toString$2(arguments[0]);
2668
2996
  var result = isPrototypeOf(SymbolPrototype, this)
2669
2997
  ? new NativeSymbol(description)
2670
2998
  // in Edge 13, String(Symbol(undefined)) === 'Symbol(undefined)'
@@ -2678,11 +3006,11 @@ if (DESCRIPTORS && isCallable(NativeSymbol) && (!('description' in SymbolPrototy
2678
3006
  SymbolPrototype.constructor = SymbolWrapper;
2679
3007
 
2680
3008
  var NATIVE_SYMBOL = String(NativeSymbol('test')) == 'Symbol(test)';
2681
- var thisSymbolValue = uncurryThis(SymbolPrototype.valueOf);
2682
- var symbolDescriptiveString = uncurryThis(SymbolPrototype.toString);
3009
+ var thisSymbolValue = uncurryThis$2(SymbolPrototype.valueOf);
3010
+ var symbolDescriptiveString = uncurryThis$2(SymbolPrototype.toString);
2683
3011
  var regexp = /^Symbol\((.*)\)[^)]+$/;
2684
- var replace = uncurryThis(''.replace);
2685
- var stringSlice = uncurryThis(''.slice);
3012
+ var replace$1 = uncurryThis$2(''.replace);
3013
+ var stringSlice = uncurryThis$2(''.slice);
2686
3014
 
2687
3015
  defineBuiltInAccessor(SymbolPrototype, 'description', {
2688
3016
  configurable: true,
@@ -2690,12 +3018,12 @@ if (DESCRIPTORS && isCallable(NativeSymbol) && (!('description' in SymbolPrototy
2690
3018
  var symbol = thisSymbolValue(this);
2691
3019
  if (hasOwn(EmptyStringDescriptionStore, symbol)) return '';
2692
3020
  var string = symbolDescriptiveString(symbol);
2693
- var desc = NATIVE_SYMBOL ? stringSlice(string, 7, -1) : replace(string, regexp, '$1');
3021
+ var desc = NATIVE_SYMBOL ? stringSlice(string, 7, -1) : replace$1(string, regexp, '$1');
2694
3022
  return desc === '' ? undefined : desc;
2695
3023
  }
2696
3024
  });
2697
3025
 
2698
- $({ global: true, constructor: true, forced: true }, {
3026
+ $$1({ global: true, constructor: true, forced: true }, {
2699
3027
  Symbol: SymbolWrapper
2700
3028
  });
2701
3029
  }
@@ -2779,6 +3107,65 @@ const RadioGroup = ({
2779
3107
  }));
2780
3108
  };
2781
3109
 
3110
+ const Flexbox = _a => {
3111
+ var {
3112
+ alignContent,
3113
+ alignItems,
3114
+ alignSelf,
3115
+ children,
3116
+ justifyContent,
3117
+ flexDirection,
3118
+ flexWrap,
3119
+ className
3120
+ } = _a,
3121
+ props = __rest(_a, ["alignContent", "alignItems", "alignSelf", "children", "justifyContent", "flexDirection", "flexWrap", "className"]);
3122
+ const [classes, setClasses] = useState(['d-flex']);
3123
+ const [flexClassName, setFlexClassName] = useState('d-flex');
3124
+ // // update className when classes change
3125
+ useLayoutEffect(() => {
3126
+ const newClassName = classes.join(' ');
3127
+ if (newClassName !== flexClassName) setFlexClassName(newClassName);
3128
+ }, [classes, flexClassName]);
3129
+ // // update classes when props change
3130
+ useLayoutEffect(() => {
3131
+ const newClasses = ['d-flex'];
3132
+ alignItems && newClasses.push(`align-items-${alignItems}`);
3133
+ alignContent && newClasses.push(`align-content-${alignContent}`);
3134
+ alignSelf && newClasses.push(`align-self-${alignSelf}`);
3135
+ justifyContent && newClasses.push(`justify-content-${justifyContent}`);
3136
+ flexDirection && newClasses.push(`flex-${flexDirection}`);
3137
+ flexWrap && newClasses.push(`flex-${flexWrap}`);
3138
+ className && newClasses.push(className);
3139
+ setClasses(newClasses);
3140
+ }, [alignContent, alignItems, alignSelf, justifyContent, flexDirection, flexWrap, className]);
3141
+ return jsx("div", Object.assign({
3142
+ className: flexClassName
3143
+ }, props, {
3144
+ children: children
3145
+ }));
3146
+ };
3147
+
3148
+ const Link = _a => {
3149
+ var {
3150
+ button,
3151
+ children
3152
+ } = _a,
3153
+ props = __rest(_a, ["button", "children"]);
3154
+ const [anchorProps, setAnchorProps] = useState({});
3155
+ useEffect(() => {
3156
+ const className = button ? typeof button === 'string' ? `button ${button}` : 'button' : undefined;
3157
+ const newProps = Object.assign({
3158
+ role: button ? 'button' : undefined,
3159
+ className: className
3160
+ }, props);
3161
+ setAnchorProps(newProps);
3162
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3163
+ }, [button]);
3164
+ return jsx("a", Object.assign({}, anchorProps, {
3165
+ children: children
3166
+ }));
3167
+ };
3168
+
2782
3169
  const ListItem = _a => {
2783
3170
  var {
2784
3171
  listType,
@@ -2868,40 +3255,19 @@ const List = ({
2868
3255
  }));
2869
3256
  };
2870
3257
  var valueList = {
2871
- List,
2872
- Label,
2873
- Value
2874
- };
2875
-
2876
- var valueList$1 = /*#__PURE__*/Object.freeze({
2877
- __proto__: null,
2878
- Label: Label,
2879
- Value: Value,
2880
- List: List,
2881
- 'default': valueList
2882
- });
2883
-
2884
- const Link = _a => {
2885
- var {
2886
- button,
2887
- children
2888
- } = _a,
2889
- props = __rest(_a, ["button", "children"]);
2890
- const [anchorProps, setAnchorProps] = useState({});
2891
- useEffect(() => {
2892
- const className = button ? typeof button === 'string' ? `button ${button}` : 'button' : undefined;
2893
- const newProps = Object.assign({
2894
- role: button ? 'button' : undefined,
2895
- className: className
2896
- }, props);
2897
- setAnchorProps(newProps);
2898
- // eslint-disable-next-line react-hooks/exhaustive-deps
2899
- }, [button]);
2900
- return jsx("a", Object.assign({}, anchorProps, {
2901
- children: children
2902
- }));
3258
+ List,
3259
+ Label,
3260
+ Value
2903
3261
  };
2904
3262
 
3263
+ var valueList$1 = /*#__PURE__*/Object.freeze({
3264
+ __proto__: null,
3265
+ Label: Label,
3266
+ Value: Value,
3267
+ List: List,
3268
+ 'default': valueList
3269
+ });
3270
+
2905
3271
  //TODO: Add variants
2906
3272
  const Navbar = ({
2907
3273
  children,
@@ -2961,45 +3327,6 @@ const Navbar = ({
2961
3327
  }));
2962
3328
  };
2963
3329
 
2964
- function Badge(_a) {
2965
- var {
2966
- children,
2967
- badgeType,
2968
- isCloseable,
2969
- closeText,
2970
- customColor,
2971
- customBackgroundColor
2972
- } = _a,
2973
- props = __rest(_a, ["children", "badgeType", "isCloseable", "closeText", "customColor", "customBackgroundColor"]);
2974
- const [isClosed, setIsClosed] = React.useState(false);
2975
- const [type, setType] = React.useState('');
2976
- React.useEffect(() => {
2977
- if (badgeType) {
2978
- setType(badgeType);
2979
- }
2980
- if (!!customColor || !!customBackgroundColor) {
2981
- setType('');
2982
- }
2983
- }, [badgeType, customColor, customBackgroundColor]);
2984
- return !isClosed ? jsxs("span", Object.assign({}, props, {
2985
- className: `badge ${type}`,
2986
- style: {
2987
- color: customColor,
2988
- backgroundColor: customBackgroundColor
2989
- }
2990
- }, {
2991
- children: [jsx("strong", {
2992
- children: children
2993
- }), isCloseable && jsxs("button", Object.assign({
2994
- type: "button",
2995
- className: "close",
2996
- onClick: () => setIsClosed(true)
2997
- }, {
2998
- children: [closeText, jsx("i", {})]
2999
- }))]
3000
- })) : null;
3001
- }
3002
-
3003
3330
  const Select = /*#__PURE__*/React.forwardRef(({
3004
3331
  id,
3005
3332
  className,
@@ -3096,64 +3423,93 @@ function Slider({
3096
3423
  hasTextbox = false,
3097
3424
  unitLabel,
3098
3425
  disabled = false,
3099
- onChange
3426
+ onChange,
3427
+ enableClamping = true,
3428
+ onClamp
3100
3429
  }) {
3101
- var _a;
3102
3430
  const [background, setBackground] = React.useState();
3103
- const [sliderValue, setSliderValue] = React.useState((_a = value !== null && value !== void 0 ? value : defaultValue) !== null && _a !== void 0 ? _a : 0);
3431
+ const [sliderValue, setSliderValue] = React.useState(value !== null && value !== void 0 ? value : defaultValue);
3432
+ const [inputFieldValue, setInputFieldValue] = React.useState(sliderValue + '');
3104
3433
  React.useLayoutEffect(() => {
3105
3434
  if (disabled) {
3106
3435
  setBackground(sliderColors.disabled);
3107
3436
  return;
3108
3437
  }
3109
- const percent = (sliderValue - min) / (max - min) * 100;
3438
+ let percent = 0;
3439
+ if (sliderValue !== undefined) percent = (sliderValue - min) / (max - min) * 100;
3110
3440
  setBackground(getSliderTrackBackground(percent));
3111
3441
  }, [disabled, sliderValue]);
3442
+ const clamp = unclamped => {
3443
+ if (!enableClamping) return Number(unclamped);
3444
+ if (typeof unclamped === 'string') unclamped = Number(unclamped);
3445
+ if (!unclamped || Number.isNaN(unclamped)) return min;
3446
+ const clamped = Math.min(Math.max(min, unclamped), max);
3447
+ if (clamped !== unclamped && onClamp) onClamp(unclamped);
3448
+ return clamped;
3449
+ };
3450
+ const setNumValue = value => {
3451
+ if (value === '') value = min;
3452
+ const unclamped = Number(value);
3453
+ const clamped = clamp(unclamped);
3454
+ setSliderValue(clamped);
3455
+ return [unclamped, clamped];
3456
+ };
3112
3457
  React.useEffect(() => {
3113
- setSliderValue(Number(value));
3458
+ setNumValue(value);
3114
3459
  }, [value]);
3115
- const handleChange = e => {
3116
- const {
3117
- value
3118
- } = e.target;
3119
- setSliderValue(Number(value));
3120
- if (onChange) onChange(Number(value));
3460
+ const handleChange = value => {
3461
+ const [unclamped, clamped] = setNumValue(value);
3462
+ setInputFieldValue(unclamped + '');
3463
+ if (onChange) onChange(clamped);
3464
+ };
3465
+ const handleInputFieldChange = (value, shouldClamp = false) => {
3466
+ handleChange(value);
3467
+ if (value === '') setInputFieldValue('');else if (shouldClamp) setInputFieldValue(clamp(value) + '');
3121
3468
  };
3122
3469
  return jsxs(Fragment, {
3123
- children: [label && jsxs("div", Object.assign({
3470
+ children: [jsxs("div", Object.assign({
3124
3471
  className: "gds-slider-label-container"
3125
3472
  }, {
3126
- children: [jsxs("div", {
3127
- children: [jsx("label", Object.assign({
3128
- htmlFor: name
3129
- }, {
3130
- children: label
3131
- })), instruction && jsx("p", {
3132
- children: instruction
3133
- })]
3473
+ children: [jsx("div", {
3474
+ children: label && jsxs(Fragment, {
3475
+ children: [jsx("label", Object.assign({
3476
+ htmlFor: name
3477
+ }, {
3478
+ children: label
3479
+ })), instruction && jsx("p", {
3480
+ children: instruction
3481
+ })]
3482
+ })
3134
3483
  }), hasTextbox && jsx(InputWrapper, Object.assign({
3135
3484
  unitLabel: unitLabel
3136
3485
  }, {
3137
3486
  children: jsx("input", {
3138
3487
  type: "number",
3139
- value: sliderValue,
3488
+ value: inputFieldValue,
3140
3489
  id: `${name}-textbox`,
3141
3490
  name: name,
3142
3491
  className: errorMessage ? 'is-invalid' : '',
3143
3492
  disabled: disabled,
3144
- onChange: handleChange
3493
+ onChange: e => handleInputFieldChange(e.currentTarget.value),
3494
+ onKeyDown: e => e.key === 'Enter' && handleInputFieldChange(e.currentTarget.value, true),
3495
+ onBlur: e => handleInputFieldChange(e.currentTarget.value, true),
3496
+ min: min,
3497
+ max: max,
3498
+ onInvalid: e => {
3499
+ e.preventDefault();
3500
+ }
3145
3501
  })
3146
3502
  }))]
3147
3503
  })), jsx("input", {
3148
3504
  type: "range",
3149
- value: sliderValue,
3505
+ value: sliderValue || 0,
3150
3506
  id: name,
3151
3507
  name: name,
3152
3508
  min: min,
3153
3509
  max: max,
3154
3510
  step: step,
3155
3511
  disabled: disabled,
3156
- onChange: handleChange,
3512
+ onChange: e => handleChange(e.currentTarget.value),
3157
3513
  style: {
3158
3514
  background
3159
3515
  }
@@ -3176,536 +3532,315 @@ const useStepper = ({
3176
3532
  onChange
3177
3533
  }) => {
3178
3534
  const pStepper = {
3179
- down: noop,
3180
- setMax: noop,
3181
- setMin: noop,
3182
- setStep: noop,
3183
- setValue: noop,
3184
- up: noop
3185
- };
3186
- const [stepper, setStepper] = useState(pStepper);
3187
- const [data, setData] = useState({
3188
- id: _id,
3189
- value: _value,
3190
- min,
3191
- max,
3192
- step: _step
3193
- });
3194
- // eslint-disable-next-line react-hooks/exhaustive-deps
3195
- useEffect(() => {
3196
- if (max !== data.max) stepper.setMax(max);
3197
- }, [stepper, max]);
3198
- // eslint-disable-next-line react-hooks/exhaustive-deps
3199
- useEffect(() => {
3200
- if (min !== data.min) stepper.setMin(min);
3201
- }, [stepper, min]);
3202
- // eslint-disable-next-line react-hooks/exhaustive-deps
3203
- useEffect(() => {
3204
- if (_step !== data.step) stepper.setStep(_step || 1);
3205
- }, [stepper, _step]);
3206
- // eslint-disable-next-line react-hooks/exhaustive-deps
3207
- useEffect(() => {
3208
- if (_value !== data.value) stepper.setValue(_value || 0, false);
3209
- }, [stepper, _value]);
3210
- useEffect(() => {
3211
- setStepper(createStepper({
3212
- id: _id,
3213
- value: _value,
3214
- min,
3215
- max,
3216
- step: _step,
3217
- onChange
3218
- }, setData));
3219
- // eslint-disable-next-line react-hooks/exhaustive-deps
3220
- }, []);
3221
- return [stepper, data];
3222
- };
3223
-
3224
- // TODO: Should be named "Numeric input" instead of stepper?
3225
- function Stepper(_a) {
3226
- var {
3227
- label,
3228
- description,
3229
- statusMessage,
3230
- validator
3231
- } = _a,
3232
- stepperArgs = __rest(_a, ["label", "description", "statusMessage", "validator"]);
3233
- const [stepper, data] = useStepper(stepperArgs);
3234
- const onChangeEvent = e => {
3235
- stepper.setValue(e.target.valueAsNumber);
3236
- };
3237
- const PrimitiveStepper = jsxs("div", Object.assign({
3238
- className: `group group-border group-stepper ${validator && validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)}`
3239
- }, {
3240
- children: [jsx("button", Object.assign({
3241
- onClick: () => stepper.down()
3242
- }, {
3243
- children: "-"
3244
- })), jsx("input", {
3245
- id: data.id,
3246
- type: "number",
3247
- onChange: onChangeEvent,
3248
- onFocus: ({
3249
- target
3250
- }) => target.select(),
3251
- placeholder: "0",
3252
- value: data.value
3253
- }), jsx("button", Object.assign({
3254
- onClick: () => stepper.up()
3255
- }, {
3256
- children: "+"
3257
- }))]
3258
- }));
3259
- if (!label && !description && !statusMessage && !validator) return PrimitiveStepper;
3260
- return jsxs("div", Object.assign({
3261
- className: "form-group"
3262
- }, {
3263
- children: [label && jsx("label", Object.assign({
3264
- htmlFor: data.id
3265
- }, {
3266
- children: label
3267
- })), description && jsx("span", Object.assign({
3268
- className: "form-info"
3269
- }, {
3270
- children: description
3271
- })), jsxs("div", Object.assign({
3272
- className: "stepper-wrapper"
3273
- }, {
3274
- children: [PrimitiveStepper, validator && jsx("span", Object.assign({
3275
- className: "form-info"
3276
- }, {
3277
- children: validator.message
3278
- }))]
3279
- }))]
3280
- }));
3281
- }
3282
-
3283
- const useDropdown = ({
3284
- id,
3285
- value,
3286
- texts,
3287
- options,
3288
- loop,
3289
- multiSelect,
3290
- searchable,
3291
- searchFilter,
3292
- compareWith,
3293
- useValue,
3294
- display,
3295
- togglerRef,
3296
- listboxRef,
3297
- onChange,
3298
- validator
3299
- }) => {
3300
- const [handler, setHandler] = useState();
3301
- const [dropdown, setDropdown] = useState();
3302
- const [togglerProps, setTogglerProps] = useState({});
3303
- const [listboxProps, setListboxProps] = useState({});
3304
- const [listItems, setListItems] = useState([]);
3305
- const [multiSelectProps, setMultiSelectProps] = useState({});
3306
- // When dropdown data changes
3307
- useEffect(() => {
3308
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
3309
- if (!dropdown) return;
3310
- const {
3311
- elements: {
3312
- toggler,
3313
- listbox
3314
- }
3315
- } = dropdown;
3316
- const newToggleProps = Object.assign(Object.assign({}, toggler === null || toggler === void 0 ? void 0 : toggler.attributes), {
3317
- className: (_a = toggler === null || toggler === void 0 ? void 0 : toggler.classes) === null || _a === void 0 ? void 0 : _a.join(' '),
3318
- children: (_b = dropdown === null || dropdown === void 0 ? void 0 : dropdown.texts) === null || _b === void 0 ? void 0 : _b.select,
3319
- onClick: () => handler === null || handler === void 0 ? void 0 : handler.toggle()
3320
- });
3321
- setTogglerProps(newToggleProps);
3322
- const newListboxProps = Object.assign(Object.assign({}, listbox === null || listbox === void 0 ? void 0 : listbox.attributes), {
3323
- className: (_c = listbox === null || listbox === void 0 ? void 0 : listbox.classes) === null || _c === void 0 ? void 0 : _c.join(' ')
3324
- });
3325
- setListboxProps(newListboxProps);
3326
- if (!dropdown.isMultiSelect) {
3327
- const newListItems = dropdown.options.map(o => {
3328
- var _a;
3329
- return Object.assign(Object.assign({}, o.attributes), {
3330
- className: (_a = o.classes) === null || _a === void 0 ? void 0 : _a.join(' '),
3331
- children: o[dropdown.display],
3332
- selected: o.selected,
3333
- onClick: () => handler === null || handler === void 0 ? void 0 : handler.select(o)
3334
- });
3335
- });
3336
- setListItems(newListItems);
3337
- } else {
3338
- const checkboxes = dropdown.options.map(o => ({
3339
- labelProps: Object.assign(Object.assign({}, o.attributes), {
3340
- className: ['form-control', ...o.classes].join(' ')
3341
- }),
3342
- inputProps: {
3343
- defaultChecked: o.selected,
3344
- type: 'checkbox',
3345
- onClick: () => handler === null || handler === void 0 ? void 0 : handler.select(o, false)
3346
- },
3347
- spanProps: {
3348
- children: o[dropdown.display]
3349
- }
3350
- }));
3351
- const newMultiselect = {
3352
- fieldsetProps: {
3353
- 'aria-describedby': (_f = (_e = (_d = dropdown === null || dropdown === void 0 ? void 0 : dropdown.elements) === null || _d === void 0 ? void 0 : _d.fieldset) === null || _e === void 0 ? void 0 : _e.attributes) === null || _f === void 0 ? void 0 : _f.id,
3354
- 'aria-multiselectable': true,
3355
- role: 'listbox',
3356
- tabIndex: -1
3357
- },
3358
- legendProps: {
3359
- className: 'sr-only',
3360
- id: (_j = (_h = (_g = dropdown === null || dropdown === void 0 ? void 0 : dropdown.elements) === null || _g === void 0 ? void 0 : _g.fieldset) === null || _h === void 0 ? void 0 : _h.attributes) === null || _j === void 0 ? void 0 : _j.id,
3361
- children: dropdown.texts.optionsDescription
3362
- },
3363
- checkboxes
3364
- };
3365
- setMultiSelectProps(newMultiselect);
3366
- }
3367
- // eslint-disable-next-line react-hooks/exhaustive-deps
3368
- }, [dropdown]);
3369
- // When dropdown properties change
3535
+ down: noop,
3536
+ setMax: noop,
3537
+ setMin: noop,
3538
+ setStep: noop,
3539
+ setValue: noop,
3540
+ up: noop
3541
+ };
3542
+ const [stepper, setStepper] = useState(pStepper);
3543
+ const [data, setData] = useState({
3544
+ id: _id,
3545
+ value: _value,
3546
+ min,
3547
+ max,
3548
+ step: _step
3549
+ });
3550
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3370
3551
  useEffect(() => {
3371
- if (!dropdown) return;
3372
- handler === null || handler === void 0 ? void 0 : handler.update({
3373
- id,
3374
- value,
3375
- texts,
3376
- options,
3377
- loop,
3378
- multiSelect,
3379
- searchable,
3380
- searchFilter,
3381
- compareWith,
3382
- useValue,
3383
- display,
3384
- validator
3385
- });
3386
- // eslint-disable-next-line react-hooks/exhaustive-deps
3387
- }, [id, texts, options, loop, multiSelect, searchable, searchFilter, compareWith, useValue, display]);
3552
+ if (max !== data.max) stepper.setMax(max);
3553
+ }, [stepper, max]);
3554
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3388
3555
  useEffect(() => {
3389
- if (!dropdown) return;
3390
- handler === null || handler === void 0 ? void 0 : handler.selectByValue(value);
3391
- console.log('new value');
3392
- // eslint-disable-next-line react-hooks/exhaustive-deps
3393
- }, [value]);
3394
- // When validator changes
3556
+ if (min !== data.min) stepper.setMin(min);
3557
+ }, [stepper, min]);
3558
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3395
3559
  useEffect(() => {
3396
- if (!dropdown) return;
3397
- if (validator) handler === null || handler === void 0 ? void 0 : handler.validate(validator);
3398
- // eslint-disable-next-line react-hooks/exhaustive-deps
3399
- }, [validator]);
3400
- // Create dropdown handler
3560
+ if (_step !== data.step) stepper.setStep(_step || 1);
3561
+ }, [stepper, _step]);
3562
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3401
3563
  useEffect(() => {
3402
- if (!handler && togglerRef.current && listboxRef.current) {
3403
- setHandler(createDropdown({
3404
- id,
3405
- value,
3406
- texts,
3407
- options,
3408
- loop,
3409
- multiSelect,
3410
- searchable,
3411
- searchFilter,
3412
- compareWith,
3413
- useValue,
3414
- display,
3415
- validator
3416
- }, togglerRef.current, listboxRef.current, listboxRef.current, dd => setDropdown(dd), value => onChange === null || onChange === void 0 ? void 0 : onChange(value)));
3417
- }
3418
- return () => handler === null || handler === void 0 ? void 0 : handler.destroy();
3564
+ if (_value !== data.value) stepper.setValue(_value || 0, false);
3565
+ }, [stepper, _value]);
3566
+ useEffect(() => {
3567
+ setStepper(createStepper({
3568
+ id: _id,
3569
+ value: _value,
3570
+ min,
3571
+ max,
3572
+ step: _step,
3573
+ onChange
3574
+ }, setData));
3419
3575
  // eslint-disable-next-line react-hooks/exhaustive-deps
3420
- }, [togglerRef, listboxRef]);
3421
- return {
3422
- dropdown: handler,
3423
- togglerProps,
3424
- listboxProps,
3425
- listItems,
3426
- multiSelectProps
3427
- };
3576
+ }, []);
3577
+ return [stepper, data];
3428
3578
  };
3429
3579
 
3430
- const Dropdown = ({
3431
- compareWith,
3432
- display,
3433
- id,
3434
- informationLabel,
3435
- label,
3436
- loop,
3437
- multiSelect,
3438
- onChange,
3439
- options,
3440
- searchFilter,
3441
- searchable,
3442
- texts,
3443
- useValue,
3444
- validator,
3445
- value
3446
- }) => {
3447
- var _a;
3448
- const togglerRef = useRef(null);
3449
- const listboxRef = useRef(null);
3450
- const {
3451
- dropdown,
3452
- listboxProps,
3453
- togglerProps,
3454
- listItems,
3455
- multiSelectProps
3456
- } = useDropdown({
3457
- id,
3458
- value,
3459
- options,
3460
- loop,
3461
- multiSelect,
3462
- searchable,
3463
- searchFilter,
3464
- compareWith,
3465
- useValue,
3466
- display,
3467
- togglerRef,
3468
- listboxRef,
3469
- texts,
3470
- onChange,
3471
- validator
3472
- });
3473
- const getListBoxProps = props => {
3474
- var _a, _b, _c;
3475
- if (Object.keys(props).length === 0) return {
3476
- role: 'listbox',
3477
- tabIndex: -1,
3478
- className: (_c = (_b = (_a = dropdownValues().elements) === null || _a === void 0 ? void 0 : _a.listbox) === null || _b === void 0 ? void 0 : _b.classes) === null || _c === void 0 ? void 0 : _c.join(' ')
3479
- };
3480
- return props;
3580
+ // TODO: Should be named "Numeric input" instead of stepper?
3581
+ function Stepper(_a) {
3582
+ var {
3583
+ label,
3584
+ description,
3585
+ statusMessage,
3586
+ validator
3587
+ } = _a,
3588
+ stepperArgs = __rest(_a, ["label", "description", "statusMessage", "validator"]);
3589
+ const [stepper, data] = useStepper(stepperArgs);
3590
+ const onChangeEvent = e => {
3591
+ stepper.setValue(e.target.valueAsNumber);
3481
3592
  };
3593
+ const PrimitiveStepper = jsxs("div", Object.assign({
3594
+ className: `group group-border group-stepper ${validator && validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)}`
3595
+ }, {
3596
+ children: [jsx("button", Object.assign({
3597
+ onClick: () => stepper.down()
3598
+ }, {
3599
+ children: "-"
3600
+ })), jsx("input", {
3601
+ id: data.id,
3602
+ type: "number",
3603
+ onChange: onChangeEvent,
3604
+ onFocus: ({
3605
+ target
3606
+ }) => target.select(),
3607
+ placeholder: "0",
3608
+ value: data.value
3609
+ }), jsx("button", Object.assign({
3610
+ onClick: () => stepper.up()
3611
+ }, {
3612
+ children: "+"
3613
+ }))]
3614
+ }));
3615
+ if (!label && !description && !statusMessage && !validator) return PrimitiveStepper;
3482
3616
  return jsxs("div", Object.assign({
3483
3617
  className: "form-group"
3484
3618
  }, {
3485
3619
  children: [label && jsx("label", Object.assign({
3486
- htmlFor: togglerProps.id
3620
+ htmlFor: data.id
3487
3621
  }, {
3488
3622
  children: label
3489
- })), informationLabel && jsx("div", Object.assign({
3490
- className: "form-info"
3491
- }, {
3492
- children: informationLabel
3493
- })), jsx("button", Object.assign({
3494
- type: "button"
3495
- }, togglerProps, {
3496
- ref: togglerRef
3497
- }, {
3498
- children: jsx("span", {
3499
- children: togglerProps.children
3500
- })
3501
- })), jsxs("div", Object.assign({}, getListBoxProps(listboxProps), {
3502
- ref: listboxRef
3503
- }, {
3504
- children: [jsxs("div", Object.assign({
3505
- className: "d-flex d-sm-none align-items-center"
3506
- }, {
3507
- children: [jsx("span", Object.assign({
3508
- className: "flex-grow-1 ps-4 fs-2 fw-bolder"
3509
- }, {
3510
- children: label
3511
- })), jsx("button", Object.assign({
3512
- type: "button",
3513
- className: "close m-4 m-sm-2 d-block d-sm-none",
3514
- onClick: dropdown === null || dropdown === void 0 ? void 0 : dropdown.close,
3515
- "aria-label": dropdown === null || dropdown === void 0 ? void 0 : dropdown.dropdown.texts.close
3516
- }, {
3517
- children: jsx("i", {})
3518
- }))]
3519
- })), (dropdown === null || dropdown === void 0 ? void 0 : dropdown.dropdown.isMultiSelect) ? jsx("div", Object.assign({
3520
- className: "sg-fieldset-container"
3521
- }, {
3522
- children: jsxs("fieldset", Object.assign({}, multiSelectProps.fieldsetProps, {
3523
- children: [jsx("legend", Object.assign({}, multiSelectProps.legendProps)), (_a = multiSelectProps.checkboxes) === null || _a === void 0 ? void 0 : _a.map(checkboxItem => jsxs("label", Object.assign({}, checkboxItem.labelProps, {
3524
- children: [jsx("input", Object.assign({}, checkboxItem.inputProps)), jsx("span", Object.assign({}, checkboxItem.spanProps)), jsx("i", {})]
3525
- }), checkboxItem.labelProps.id))]
3526
- }))
3527
- })) : jsx("ul", Object.assign({
3528
- role: "listbox"
3529
- }, {
3530
- children: listItems.map(liProps => jsx("li", Object.assign({}, liProps), liProps.id))
3531
- }))]
3532
- })), validator && jsx("span", Object.assign({
3623
+ })), description && jsx("span", Object.assign({
3533
3624
  className: "form-info"
3534
3625
  }, {
3535
- children: validator === null || validator === void 0 ? void 0 : validator.message
3536
- }))]
3537
- }));
3538
- };
3539
-
3540
- const useDatepicker = (datepickerRef, datepickerDialogRef, dateInputRef, datepickerTriggerRef, options = {}) => {
3541
- const dataStub = {
3542
- formattedSelectedDate: '',
3543
- calendar: {
3544
- headers: [],
3545
- calendarGrid: []
3546
- }
3547
- };
3548
- const [data, setData] = useState(dataStub);
3549
- const [state, setState] = useState({
3550
- isActive: false
3551
- });
3552
- const datepickerStub = {};
3553
- const [datepicker, setDatepicker] = useState(datepickerStub);
3554
- useEffect(() => {
3555
- if (!datepicker.open && datepickerRef.current && datepickerDialogRef.current && dateInputRef.current && datepickerTriggerRef.current) {
3556
- setDatepicker(createDatepicker((data, state) => {
3557
- if (data) setData(data);
3558
- if (state) setState(state);
3559
- }, options, datepickerRef.current, datepickerDialogRef.current, dateInputRef.current, datepickerTriggerRef.current));
3560
- }
3561
- }, [datepicker, datepickerRef, datepickerDialogRef, dateInputRef, datepickerTriggerRef, options]);
3562
- return {
3563
- datepicker,
3564
- data,
3565
- state
3626
+ children: description
3627
+ })), jsxs("div", Object.assign({
3628
+ className: "stepper-wrapper"
3629
+ }, {
3630
+ children: [PrimitiveStepper, validator && jsx("span", Object.assign({
3631
+ className: "form-info"
3632
+ }, {
3633
+ children: validator.message
3634
+ }))]
3635
+ }))]
3636
+ }));
3637
+ }
3638
+
3639
+ // a string of all valid unicode whitespaces
3640
+ var whitespaces$2 = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' +
3641
+ '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
3642
+
3643
+ var uncurryThis$1 = functionUncurryThis;
3644
+ var requireObjectCoercible = requireObjectCoercible$3;
3645
+ var toString$1 = toString$3;
3646
+ var whitespaces$1 = whitespaces$2;
3647
+
3648
+ var replace = uncurryThis$1(''.replace);
3649
+ var ltrim = RegExp('^[' + whitespaces$1 + ']+');
3650
+ var rtrim = RegExp('(^|[^' + whitespaces$1 + '])[' + whitespaces$1 + ']+$');
3651
+
3652
+ // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
3653
+ var createMethod = function (TYPE) {
3654
+ return function ($this) {
3655
+ var string = toString$1(requireObjectCoercible($this));
3656
+ if (TYPE & 1) string = replace(string, ltrim, '');
3657
+ if (TYPE & 2) string = replace(string, rtrim, '$1');
3658
+ return string;
3566
3659
  };
3567
3660
  };
3568
3661
 
3569
- const Datepicker = (options = {}) => {
3570
- const [uuid] = useState(randomId());
3571
- const id = `sgr-datepicker-${uuid}`;
3572
- const datepickerRef = useRef(null);
3573
- const datepickerTriggerRef = useRef(null);
3574
- const datepickerDialogRef = useRef(null);
3575
- const dateInputRef = useRef(null);
3576
- const {
3577
- datepicker,
3578
- data,
3579
- state
3580
- } = useDatepicker(datepickerRef, datepickerDialogRef, dateInputRef, datepickerTriggerRef, options);
3581
- useEffect(() => {
3582
- var _a;
3583
- const selDateSub = (_a = datepicker.selectedDate$) === null || _a === void 0 ? void 0 : _a.subscribe(newDate => options.onChange && options.onChange(newDate));
3584
- return () => selDateSub === null || selDateSub === void 0 ? void 0 : selDateSub.unsubscribe();
3585
- }, [datepicker, options]);
3586
- const classNames = day => Object.entries({
3587
- disabled: !day.currentMonth,
3588
- 'sg-date-today': day.today
3589
- // 'sg-date-holiday': day.holiday,
3590
- }).map(([className, add]) => add ? className : '').join(' ');
3662
+ var stringTrim = {
3663
+ // `String.prototype.{ trimLeft, trimStart }` methods
3664
+ // https://tc39.es/ecma262/#sec-string.prototype.trimstart
3665
+ start: createMethod(1),
3666
+ // `String.prototype.{ trimRight, trimEnd }` methods
3667
+ // https://tc39.es/ecma262/#sec-string.prototype.trimend
3668
+ end: createMethod(2),
3669
+ // `String.prototype.trim` method
3670
+ // https://tc39.es/ecma262/#sec-string.prototype.trim
3671
+ trim: createMethod(3)
3672
+ };
3673
+
3674
+ var global$1 = global$d;
3675
+ var fails = fails$c;
3676
+ var uncurryThis = functionUncurryThis;
3677
+ var toString = toString$3;
3678
+ var trim = stringTrim.trim;
3679
+ var whitespaces = whitespaces$2;
3680
+
3681
+ var $parseInt$1 = global$1.parseInt;
3682
+ var Symbol$1 = global$1.Symbol;
3683
+ var ITERATOR = Symbol$1 && Symbol$1.iterator;
3684
+ var hex = /^[+-]?0x/i;
3685
+ var exec = uncurryThis(hex.exec);
3686
+ var FORCED = $parseInt$1(whitespaces + '08') !== 8 || $parseInt$1(whitespaces + '0x16') !== 22
3687
+ // MS Edge 18- broken with boxed symbols
3688
+ || (ITERATOR && !fails(function () { $parseInt$1(Object(ITERATOR)); }));
3689
+
3690
+ // `parseInt` method
3691
+ // https://tc39.es/ecma262/#sec-parseint-string-radix
3692
+ var numberParseInt = FORCED ? function parseInt(string, radix) {
3693
+ var S = trim(toString(string));
3694
+ return $parseInt$1(S, (radix >>> 0) || (exec(hex, S) ? 16 : 10));
3695
+ } : $parseInt$1;
3696
+
3697
+ var $ = _export;
3698
+ var $parseInt = numberParseInt;
3699
+
3700
+ // `parseInt` method
3701
+ // https://tc39.es/ecma262/#sec-parseint-string-radix
3702
+ $({ global: true, forced: parseInt != $parseInt }, {
3703
+ parseInt: $parseInt
3704
+ });
3705
+
3706
+ const Tabs = ({
3707
+ list,
3708
+ onTabChange,
3709
+ children
3710
+ }) => {
3711
+ const [selectedTab, setSelectedTab] = useState(0);
3712
+ const onClick = event => {
3713
+ event.preventDefault();
3714
+ if (event.currentTarget.ariaDisabled !== 'true') {
3715
+ const focusedIndex = parseInt(event.currentTarget.dataset.indexNumber);
3716
+ setSelectedTab(focusedIndex);
3717
+ onTabChange && onTabChange(focusedIndex);
3718
+ }
3719
+ };
3591
3720
  return jsxs(Fragment, {
3592
- children: [jsxs("div", Object.assign({
3593
- className: "form-group"
3721
+ children: [jsx("nav", Object.assign({
3722
+ role: "tablist"
3594
3723
  }, {
3595
- children: [jsx("label", Object.assign({
3596
- htmlFor: id
3597
- }, {
3598
- children: "Date"
3599
- })), jsxs("div", Object.assign({
3600
- className: "group",
3601
- ref: datepickerRef
3724
+ children: list === null || list === void 0 ? void 0 : list.map((value, index) => jsx("a", Object.assign({
3725
+ href: value.disabled ? undefined : value.href || '#',
3726
+ onClick: onClick,
3727
+ role: "tab",
3728
+ "data-index-number": index,
3729
+ "aria-disabled": value.disabled,
3730
+ "aria-selected": selectedTab === index
3602
3731
  }, {
3603
- children: [jsx("input", {
3604
- ref: dateInputRef,
3605
- id: id,
3606
- type: "text",
3607
- placeholder: "yyyy-mm-dd",
3608
- value: data.formattedSelectedDate,
3609
- onChange: e => datepicker.select(e.target.value)
3610
- }), jsx("button", Object.assign({
3611
- ref: datepickerTriggerRef,
3612
- type: "button",
3613
- className: "primary",
3614
- onClick: () => datepicker.toggle()
3615
- }, {
3616
- children: jsx("i", Object.assign({
3617
- className: "sg-icon sg-icon-calendar"
3618
- }, {
3619
- children: "Select date"
3620
- }))
3621
- }))]
3622
- })), jsx("span", Object.assign({
3623
- className: "form-info"
3732
+ children: value.text
3733
+ }), index))
3734
+ })), jsx("section", {
3735
+ children: list === null || list === void 0 ? void 0 : list.map((value, index) => jsx("article", Object.assign({
3736
+ role: "tabpanel",
3737
+ "aria-hidden": selectedTab !== index
3624
3738
  }, {
3625
- children: "Select a date"
3626
- }))]
3627
- })), jsx("div", Object.assign({
3628
- ref: datepickerDialogRef,
3629
- className: `popover popover-datepicker ${state.isActive ? 'active' : ''}`,
3630
- role: "dialog",
3631
- "aria-modal": "true",
3632
- "aria-label": "Choose Date"
3739
+ children: value.text
3740
+ }), index))
3741
+ })]
3742
+ });
3743
+ };
3744
+
3745
+ const ModalHeader = ({
3746
+ header: _header = '',
3747
+ onClose
3748
+ }) => {
3749
+ const handleClose = event => {
3750
+ if (onClose) onClose(event);
3751
+ };
3752
+ return jsxs("div", Object.assign({
3753
+ className: "header"
3754
+ }, {
3755
+ children: [jsx("h3", {
3756
+ children: _header
3757
+ }), jsxs("button", Object.assign({
3758
+ className: "close",
3759
+ onClick: handleClose
3633
3760
  }, {
3634
- children: state.isActive && jsxs("div", Object.assign({
3635
- className: "sg-date"
3761
+ children: [jsx("span", Object.assign({
3762
+ className: "sr-only"
3636
3763
  }, {
3637
- children: [jsxs("header", {
3638
- children: [jsx("button", Object.assign({
3639
- className: "link",
3640
- onClick: () => datepicker.sub(1, 'months')
3764
+ children: "Close"
3765
+ })), jsx("i", {})]
3766
+ }))]
3767
+ }));
3768
+ };
3769
+ const ModalBody = ({
3770
+ children
3771
+ }) => {
3772
+ return jsx("div", Object.assign({
3773
+ className: "body"
3774
+ }, {
3775
+ children: children
3776
+ }));
3777
+ };
3778
+ const ModalFooter = ({
3779
+ confirm,
3780
+ dismiss,
3781
+ onClose,
3782
+ onConfirm,
3783
+ onDismiss
3784
+ }) => {
3785
+ const handleConfirm = event => {
3786
+ if (onConfirm) onConfirm(event);
3787
+ if (onClose) onClose(event);
3788
+ };
3789
+ const handleDismiss = event => {
3790
+ if (onDismiss) onDismiss(event);
3791
+ if (onClose) onClose(event);
3792
+ };
3793
+ return jsxs("div", Object.assign({
3794
+ className: "footer"
3795
+ }, {
3796
+ children: [dismiss && jsx(Button, Object.assign({
3797
+ variant: "secondary",
3798
+ onClick: handleDismiss
3799
+ }, {
3800
+ children: dismiss
3801
+ })), confirm && jsx(Button, Object.assign({
3802
+ variant: "primary",
3803
+ onClick: handleConfirm
3804
+ }, {
3805
+ children: confirm
3806
+ }))]
3807
+ }));
3808
+ };
3809
+ const Modal = _a => {
3810
+ var {
3811
+ type = 'default',
3812
+ isOpen
3813
+ } = _a,
3814
+ props = __rest(_a, ["type", "isOpen"]);
3815
+ const modalContent = () => {
3816
+ switch (type) {
3817
+ case 'slideout':
3818
+ {
3819
+ return jsxs("aside", Object.assign({
3820
+ role: "dialog"
3641
3821
  }, {
3642
- children: jsx("i", Object.assign({
3643
- className: "sg-icon sg-icon-previous"
3644
- }, {
3645
- children: "Previous month"
3646
- }))
3647
- })), jsx(Dropdown, {
3648
- options: months({}),
3649
- display: "key",
3650
- texts: {
3651
- placeholder: data.monthName
3652
- }
3653
- }), jsx(Dropdown, {
3654
- options: years({}),
3655
- display: "key",
3656
- texts: {
3657
- placeholder: data.year + ''
3658
- }
3659
- }), jsx("button", Object.assign({
3660
- className: "link",
3661
- onClick: () => datepicker.add(1, 'months')
3822
+ children: [jsx(ModalHeader, Object.assign({}, props)), jsx(ModalBody, Object.assign({}, props)), jsx(ModalFooter, Object.assign({}, props))]
3823
+ }));
3824
+ }
3825
+ case 'takeover':
3826
+ {
3827
+ return jsxs("main", Object.assign({
3828
+ role: "dialog"
3662
3829
  }, {
3663
- children: jsx("i", Object.assign({
3664
- className: "sg-icon sg-icon-next"
3665
- }, {
3666
- children: "Next month"
3667
- }))
3668
- }))]
3669
- }), jsx("main", {
3670
- children: jsxs("table", Object.assign({
3671
- role: "grid"
3830
+ children: [jsx(ModalHeader, Object.assign({}, props)), jsx(ModalBody, Object.assign({}, props)), jsx(ModalFooter, Object.assign({}, props))]
3831
+ }));
3832
+ }
3833
+ default:
3834
+ {
3835
+ return jsxs("section", Object.assign({
3836
+ role: "dialog"
3672
3837
  }, {
3673
- children: [jsx("thead", {
3674
- children: jsx("tr", {
3675
- children: data.calendar.headers.map((header, ix) => jsx("th", Object.assign({
3676
- scope: "col",
3677
- abbr: header.abbr,
3678
- className: header.type === 'week' ? 'sg-week-header' : 'sg-day-header'
3679
- }, {
3680
- children: header.displayText
3681
- }), `week_${ix}`))
3682
- })
3683
- }), jsx("tbody", {
3684
- children: data.calendar.calendarGrid.map((week, ix) => jsxs("tr", {
3685
- children: [data.calendar.weekNumbers ? jsx("th", Object.assign({
3686
- className: "sg-week-number"
3687
- }, {
3688
- children: data.calendar.weekNumbers[ix]
3689
- })) : '', week.map(day => jsx("td", Object.assign({
3690
- "data-date": day.formattedDate,
3691
- className: classNames(day),
3692
- title: day.today ? 'Today' : '',
3693
- tabIndex: day.highlighted || day.selected && !(data === null || data === void 0 ? void 0 : data.highlightedDate) || day.today && !(data === null || data === void 0 ? void 0 : data.highlightedDate) && !(data === null || data === void 0 ? void 0 : data.selectedDate) ? 0 : -1,
3694
- role: day.selected ? 'gridcell' : undefined,
3695
- "aria-selected": day.selected && !(data === null || data === void 0 ? void 0 : data.highlightedDate) ? true : undefined,
3696
- onClick: () => {
3697
- day.currentMonth && datepicker.select(day.date);
3698
- }
3699
- }, {
3700
- children: day.day
3701
- }), day.day))]
3702
- }, `week_${ix}`))
3703
- })]
3704
- }))
3705
- })]
3706
- }))
3707
- }))]
3708
- });
3838
+ children: [jsx(ModalHeader, Object.assign({}, props)), jsx(ModalBody, Object.assign({}, props)), jsx(ModalFooter, Object.assign({}, props))]
3839
+ }));
3840
+ }
3841
+ }
3842
+ };
3843
+ return isOpen ? modalContent() : null;
3709
3844
  };
3710
3845
 
3711
- export { AlertRibbon as Alert, AlertRibbon, Badge, Button, ButtonGroup, Card, Checkbox, Datepicker, Dropdown, EmailInput, Flexbox, Form, FormItem, FormItems, Group, Link, List$1 as List, Modal, Navbar, NumberInput, Option, OptionGroup, RadioButton, RadioGroup, RenderInput, Select, Slider, Stepper, Text, TextInput, valueList$1 as ValueList };
3846
+ export { AlertRibbon as Alert, AlertRibbon, Badge, Button, ButtonGroup, Card, Checkbox, Datepicker, Dropdown, EmailInput, Flexbox, Form, FormItem, FormItems, Group, Link, List$1 as List, Modal, Navbar, NumberInput, Option, OptionGroup, RadioButton, RadioGroup, RenderInput, Select, Slider, Stepper, Tabs, Text, TextInput, valueList$1 as ValueList };