@sebgroup/green-react 1.0.0-beta.9 → 1.0.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.d.ts +7 -1
- package/index.esm.js +934 -151
- package/index.umd.js +3356 -2034
- package/lib/accordion/accordion-item.d.ts +17 -0
- package/lib/accordion/accordion.d.ts +6 -0
- package/lib/alert-ribbon/alert-ribbon.d.ts +16 -0
- package/lib/badge/badge.d.ts +7 -4
- package/lib/datepicker/hook.d.ts +1 -1
- package/lib/dropdown/dropdown.d.ts +4 -7
- package/lib/dropdown/hooks.d.ts +18 -8
- package/lib/form/button/button.d.ts +4 -2
- package/lib/form/formItems.d.ts +1 -1
- package/lib/form/input/input.d.ts +2 -1
- package/lib/form/radioButton/radioGroup.d.ts +4 -2
- package/lib/form/types.d.ts +1 -6
- package/lib/icons/check.d.ts +1 -0
- package/lib/icons/chevronDown.d.ts +1 -0
- package/lib/icons/index.d.ts +4 -0
- package/lib/icons/square-exclamation.d.ts +1 -0
- package/lib/icons/square-info.d.ts +1 -0
- package/lib/list/index.d.ts +2 -0
- package/lib/list/valueList.d.ts +17 -0
- package/lib/select/index.d.ts +1 -0
- package/lib/select/select.d.ts +38 -0
- package/lib/stepper/hook.d.ts +3 -0
- package/lib/stepper/stepper.d.ts +9 -0
- package/package.json +5 -5
- package/types/index.d.ts +1 -0
- package/types/props/index.d.ts +9 -0
- package/lib/alert/alert.d.ts +0 -12
package/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import React, { useState, useLayoutEffect, useEffect, useMemo, useRef } from 'react';
|
|
3
|
-
import { randomId, validateClassName } from '@sebgroup/extract';
|
|
3
|
+
import { randomId, validateClassName, createStepper, createDropdown, dropdownValues, createDatepicker, months, years } from '@sebgroup/extract';
|
|
4
4
|
|
|
5
5
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ var check = function (it) {
|
|
|
10
10
|
|
|
11
11
|
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
|
|
12
12
|
var global$r =
|
|
13
|
-
// eslint-disable-next-line es/no-global-this -- safe
|
|
13
|
+
// eslint-disable-next-line es-x/no-global-this -- safe
|
|
14
14
|
check(typeof globalThis == 'object' && globalThis) ||
|
|
15
15
|
check(typeof window == 'object' && window) ||
|
|
16
16
|
// eslint-disable-next-line no-restricted-globals -- safe
|
|
@@ -33,13 +33,14 @@ var fails$9 = fails$a;
|
|
|
33
33
|
|
|
34
34
|
// Detect IE8's incomplete defineProperty implementation
|
|
35
35
|
var descriptors = !fails$9(function () {
|
|
36
|
-
// eslint-disable-next-line es/no-object-defineproperty -- required for testing
|
|
36
|
+
// eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
|
|
37
37
|
return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
var fails$8 = fails$a;
|
|
41
41
|
|
|
42
42
|
var functionBindNative = !fails$8(function () {
|
|
43
|
+
// eslint-disable-next-line es-x/no-function-prototype-bind -- safe
|
|
43
44
|
var test = (function () { /* empty */ }).bind();
|
|
44
45
|
// eslint-disable-next-line no-prototype-builtins -- safe
|
|
45
46
|
return typeof test != 'function' || test.hasOwnProperty('prototype');
|
|
@@ -56,7 +57,7 @@ var functionCall = NATIVE_BIND$1 ? call$6.bind(call$6) : function () {
|
|
|
56
57
|
var objectPropertyIsEnumerable = {};
|
|
57
58
|
|
|
58
59
|
var $propertyIsEnumerable = {}.propertyIsEnumerable;
|
|
59
|
-
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
60
|
+
// eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
|
|
60
61
|
var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
|
|
61
62
|
|
|
62
63
|
// Nashorn ~ JDK8 bug
|
|
@@ -197,12 +198,12 @@ if (!version && userAgent) {
|
|
|
197
198
|
|
|
198
199
|
var engineV8Version = version;
|
|
199
200
|
|
|
200
|
-
/* eslint-disable es/no-symbol -- required for testing */
|
|
201
|
+
/* eslint-disable es-x/no-symbol -- required for testing */
|
|
201
202
|
|
|
202
203
|
var V8_VERSION = engineV8Version;
|
|
203
204
|
var fails$6 = fails$a;
|
|
204
205
|
|
|
205
|
-
// eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
|
|
206
|
+
// eslint-disable-next-line es-x/no-object-getownpropertysymbols -- required for testing
|
|
206
207
|
var nativeSymbol = !!Object.getOwnPropertySymbols && !fails$6(function () {
|
|
207
208
|
var symbol = Symbol();
|
|
208
209
|
// Chrome 38 Symbol has incorrect toString conversion
|
|
@@ -212,7 +213,7 @@ var nativeSymbol = !!Object.getOwnPropertySymbols && !fails$6(function () {
|
|
|
212
213
|
!Symbol.sham && V8_VERSION && V8_VERSION < 41;
|
|
213
214
|
});
|
|
214
215
|
|
|
215
|
-
/* eslint-disable es/no-symbol -- required for testing */
|
|
216
|
+
/* eslint-disable es-x/no-symbol -- required for testing */
|
|
216
217
|
|
|
217
218
|
var NATIVE_SYMBOL$2 = nativeSymbol;
|
|
218
219
|
|
|
@@ -289,7 +290,7 @@ var shared$3 = {exports: {}};
|
|
|
289
290
|
|
|
290
291
|
var global$i = global$r;
|
|
291
292
|
|
|
292
|
-
// eslint-disable-next-line es/no-object-defineproperty -- safe
|
|
293
|
+
// eslint-disable-next-line es-x/no-object-defineproperty -- safe
|
|
293
294
|
var defineProperty$4 = Object.defineProperty;
|
|
294
295
|
|
|
295
296
|
var setGlobal$3 = function (key, value) {
|
|
@@ -313,10 +314,10 @@ var store$2 = sharedStore;
|
|
|
313
314
|
(shared$3.exports = function (key, value) {
|
|
314
315
|
return store$2[key] || (store$2[key] = value !== undefined ? value : {});
|
|
315
316
|
})('versions', []).push({
|
|
316
|
-
version: '3.
|
|
317
|
+
version: '3.22.2',
|
|
317
318
|
mode: 'global',
|
|
318
319
|
copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)',
|
|
319
|
-
license: 'https://github.com/zloirock/core-js/blob/v3.
|
|
320
|
+
license: 'https://github.com/zloirock/core-js/blob/v3.22.2/LICENSE',
|
|
320
321
|
source: 'https://github.com/zloirock/core-js'
|
|
321
322
|
});
|
|
322
323
|
|
|
@@ -338,6 +339,7 @@ var hasOwnProperty = uncurryThis$8({}.hasOwnProperty);
|
|
|
338
339
|
|
|
339
340
|
// `HasOwnProperty` abstract operation
|
|
340
341
|
// https://tc39.es/ecma262/#sec-hasownproperty
|
|
342
|
+
// eslint-disable-next-line es-x/no-object-hasown -- safe
|
|
341
343
|
var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
|
|
342
344
|
return hasOwnProperty(toObject$2(it), key);
|
|
343
345
|
};
|
|
@@ -431,7 +433,7 @@ var createElement = documentCreateElement$2;
|
|
|
431
433
|
|
|
432
434
|
// Thanks to IE8 for its funny defineProperty
|
|
433
435
|
var ie8DomDefine = !DESCRIPTORS$9 && !fails$5(function () {
|
|
434
|
-
// eslint-disable-next-line es/no-object-defineproperty -- required for testing
|
|
436
|
+
// eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
|
|
435
437
|
return Object.defineProperty(createElement('div'), 'a', {
|
|
436
438
|
get: function () { return 7; }
|
|
437
439
|
}).a != 7;
|
|
@@ -446,7 +448,7 @@ var toPropertyKey$1 = toPropertyKey$2;
|
|
|
446
448
|
var hasOwn$8 = hasOwnProperty_1;
|
|
447
449
|
var IE8_DOM_DEFINE$1 = ie8DomDefine;
|
|
448
450
|
|
|
449
|
-
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
451
|
+
// eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
|
|
450
452
|
var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
|
|
451
453
|
|
|
452
454
|
// `Object.getOwnPropertyDescriptor` method
|
|
@@ -468,7 +470,7 @@ var fails$4 = fails$a;
|
|
|
468
470
|
// V8 ~ Chrome 36-
|
|
469
471
|
// https://bugs.chromium.org/p/v8/issues/detail?id=3334
|
|
470
472
|
var v8PrototypeDefineBug = DESCRIPTORS$7 && fails$4(function () {
|
|
471
|
-
// eslint-disable-next-line es/no-object-defineproperty -- required for testing
|
|
473
|
+
// eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
|
|
472
474
|
return Object.defineProperty(function () { /* empty */ }, 'prototype', {
|
|
473
475
|
value: 42,
|
|
474
476
|
writable: false
|
|
@@ -495,9 +497,9 @@ var anObject$4 = anObject$5;
|
|
|
495
497
|
var toPropertyKey = toPropertyKey$2;
|
|
496
498
|
|
|
497
499
|
var TypeError$3 = global$b.TypeError;
|
|
498
|
-
// eslint-disable-next-line es/no-object-defineproperty -- safe
|
|
500
|
+
// eslint-disable-next-line es-x/no-object-defineproperty -- safe
|
|
499
501
|
var $defineProperty = Object.defineProperty;
|
|
500
|
-
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
502
|
+
// eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
|
|
501
503
|
var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
502
504
|
var ENUMERABLE = 'enumerable';
|
|
503
505
|
var CONFIGURABLE$1 = 'configurable';
|
|
@@ -653,7 +655,7 @@ var DESCRIPTORS$4 = descriptors;
|
|
|
653
655
|
var hasOwn$6 = hasOwnProperty_1;
|
|
654
656
|
|
|
655
657
|
var FunctionPrototype = Function.prototype;
|
|
656
|
-
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
658
|
+
// eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
|
|
657
659
|
var getDescriptor = DESCRIPTORS$4 && Object.getOwnPropertyDescriptor;
|
|
658
660
|
|
|
659
661
|
var EXISTS = hasOwn$6(FunctionPrototype, 'name');
|
|
@@ -830,14 +832,14 @@ var hiddenKeys$1 = enumBugKeys$2.concat('length', 'prototype');
|
|
|
830
832
|
|
|
831
833
|
// `Object.getOwnPropertyNames` method
|
|
832
834
|
// https://tc39.es/ecma262/#sec-object.getownpropertynames
|
|
833
|
-
// eslint-disable-next-line es/no-object-getownpropertynames -- safe
|
|
835
|
+
// eslint-disable-next-line es-x/no-object-getownpropertynames -- safe
|
|
834
836
|
objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
|
|
835
837
|
return internalObjectKeys$1(O, hiddenKeys$1);
|
|
836
838
|
};
|
|
837
839
|
|
|
838
840
|
var objectGetOwnPropertySymbols = {};
|
|
839
841
|
|
|
840
|
-
// eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
|
|
842
|
+
// eslint-disable-next-line es-x/no-object-getownpropertysymbols -- safe
|
|
841
843
|
objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
|
|
842
844
|
|
|
843
845
|
var getBuiltIn$1 = getBuiltIn$4;
|
|
@@ -956,7 +958,7 @@ var enumBugKeys$1 = enumBugKeys$3;
|
|
|
956
958
|
|
|
957
959
|
// `Object.keys` method
|
|
958
960
|
// https://tc39.es/ecma262/#sec-object.keys
|
|
959
|
-
// eslint-disable-next-line es/no-object-keys -- safe
|
|
961
|
+
// eslint-disable-next-line es-x/no-object-keys -- safe
|
|
960
962
|
var objectKeys$2 = Object.keys || function keys(O) {
|
|
961
963
|
return internalObjectKeys(O, enumBugKeys$1);
|
|
962
964
|
};
|
|
@@ -971,9 +973,9 @@ var propertyIsEnumerableModule = objectPropertyIsEnumerable;
|
|
|
971
973
|
var toObject$1 = toObject$3;
|
|
972
974
|
var IndexedObject = indexedObject;
|
|
973
975
|
|
|
974
|
-
// eslint-disable-next-line es/no-object-assign -- safe
|
|
976
|
+
// eslint-disable-next-line es-x/no-object-assign -- safe
|
|
975
977
|
var $assign = Object.assign;
|
|
976
|
-
// eslint-disable-next-line es/no-object-defineproperty -- required for testing
|
|
978
|
+
// eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
|
|
977
979
|
var defineProperty$3 = Object.defineProperty;
|
|
978
980
|
var concat = uncurryThis$2([].concat);
|
|
979
981
|
|
|
@@ -993,7 +995,7 @@ var objectAssign = !$assign || fails$2(function () {
|
|
|
993
995
|
// should work with symbols and should have deterministic property order (V8 bug)
|
|
994
996
|
var A = {};
|
|
995
997
|
var B = {};
|
|
996
|
-
// eslint-disable-next-line es/no-symbol -- safe
|
|
998
|
+
// eslint-disable-next-line es-x/no-symbol -- safe
|
|
997
999
|
var symbol = Symbol();
|
|
998
1000
|
var alphabet = 'abcdefghijklmnopqrst';
|
|
999
1001
|
A[symbol] = 7;
|
|
@@ -1023,12 +1025,12 @@ var assign = objectAssign;
|
|
|
1023
1025
|
|
|
1024
1026
|
// `Object.assign` method
|
|
1025
1027
|
// https://tc39.es/ecma262/#sec-object.assign
|
|
1026
|
-
// eslint-disable-next-line es/no-object-assign -- required for testing
|
|
1028
|
+
// eslint-disable-next-line es-x/no-object-assign -- required for testing
|
|
1027
1029
|
$$2({ target: 'Object', stat: true, forced: Object.assign !== assign }, {
|
|
1028
1030
|
assign: assign
|
|
1029
1031
|
});
|
|
1030
1032
|
|
|
1031
|
-
|
|
1033
|
+
/******************************************************************************
|
|
1032
1034
|
Copyright (c) Microsoft Corporation.
|
|
1033
1035
|
|
|
1034
1036
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -1059,20 +1061,24 @@ function Button({
|
|
|
1059
1061
|
children,
|
|
1060
1062
|
variant,
|
|
1061
1063
|
onClick,
|
|
1064
|
+
disabled,
|
|
1062
1065
|
active = false,
|
|
1063
|
-
type = 'button'
|
|
1066
|
+
type = 'button',
|
|
1067
|
+
size
|
|
1064
1068
|
}) {
|
|
1065
1069
|
const props = {
|
|
1066
|
-
type
|
|
1070
|
+
type,
|
|
1071
|
+
disabled
|
|
1067
1072
|
};
|
|
1068
1073
|
const classNames = [];
|
|
1069
1074
|
if (variant) classNames.push(variant);
|
|
1070
1075
|
if (active) classNames.push('active');
|
|
1076
|
+
if (size) classNames.push(size);
|
|
1071
1077
|
if (classNames.length) props.className = classNames.join(' ');
|
|
1072
1078
|
if (onClick) props.onClick = onClick;
|
|
1073
1079
|
return jsx("button", Object.assign({}, props, {
|
|
1074
1080
|
children: children
|
|
1075
|
-
})
|
|
1081
|
+
}));
|
|
1076
1082
|
}
|
|
1077
1083
|
|
|
1078
1084
|
const ModalHeader = ({
|
|
@@ -1088,17 +1094,17 @@ const ModalHeader = ({
|
|
|
1088
1094
|
}, {
|
|
1089
1095
|
children: [jsx("h3", {
|
|
1090
1096
|
children: _header
|
|
1091
|
-
}
|
|
1097
|
+
}), jsxs("button", Object.assign({
|
|
1092
1098
|
className: "close",
|
|
1093
1099
|
onClick: handleClose
|
|
1094
1100
|
}, {
|
|
1095
|
-
children: jsx("span", Object.assign({
|
|
1101
|
+
children: [jsx("span", Object.assign({
|
|
1096
1102
|
className: "sr-only"
|
|
1097
1103
|
}, {
|
|
1098
1104
|
children: "Close"
|
|
1099
|
-
}),
|
|
1100
|
-
})
|
|
1101
|
-
})
|
|
1105
|
+
})), jsx("i", {})]
|
|
1106
|
+
}))]
|
|
1107
|
+
}));
|
|
1102
1108
|
};
|
|
1103
1109
|
|
|
1104
1110
|
const ModalBody = ({
|
|
@@ -1108,7 +1114,7 @@ const ModalBody = ({
|
|
|
1108
1114
|
className: "body"
|
|
1109
1115
|
}, {
|
|
1110
1116
|
children: children
|
|
1111
|
-
})
|
|
1117
|
+
}));
|
|
1112
1118
|
};
|
|
1113
1119
|
|
|
1114
1120
|
const ModalFooter = ({
|
|
@@ -1136,13 +1142,13 @@ const ModalFooter = ({
|
|
|
1136
1142
|
onClick: handleDismiss
|
|
1137
1143
|
}, {
|
|
1138
1144
|
children: dismiss
|
|
1139
|
-
})
|
|
1145
|
+
})), confirm && jsx(Button, Object.assign({
|
|
1140
1146
|
variant: "primary",
|
|
1141
1147
|
onClick: handleConfirm
|
|
1142
1148
|
}, {
|
|
1143
1149
|
children: confirm
|
|
1144
|
-
})
|
|
1145
|
-
})
|
|
1150
|
+
}))]
|
|
1151
|
+
}));
|
|
1146
1152
|
};
|
|
1147
1153
|
|
|
1148
1154
|
const Modal = _a => {
|
|
@@ -1159,8 +1165,8 @@ const Modal = _a => {
|
|
|
1159
1165
|
return jsxs("aside", Object.assign({
|
|
1160
1166
|
role: "dialog"
|
|
1161
1167
|
}, {
|
|
1162
|
-
children: [jsx(ModalHeader, Object.assign({}, props)
|
|
1163
|
-
})
|
|
1168
|
+
children: [jsx(ModalHeader, Object.assign({}, props)), jsx(ModalBody, Object.assign({}, props)), jsx(ModalFooter, Object.assign({}, props))]
|
|
1169
|
+
}));
|
|
1164
1170
|
}
|
|
1165
1171
|
|
|
1166
1172
|
case 'takeover':
|
|
@@ -1168,8 +1174,8 @@ const Modal = _a => {
|
|
|
1168
1174
|
return jsxs("main", Object.assign({
|
|
1169
1175
|
role: "dialog"
|
|
1170
1176
|
}, {
|
|
1171
|
-
children: [jsx(ModalHeader, Object.assign({}, props)
|
|
1172
|
-
})
|
|
1177
|
+
children: [jsx(ModalHeader, Object.assign({}, props)), jsx(ModalBody, Object.assign({}, props)), jsx(ModalFooter, Object.assign({}, props))]
|
|
1178
|
+
}));
|
|
1173
1179
|
}
|
|
1174
1180
|
|
|
1175
1181
|
default:
|
|
@@ -1177,8 +1183,8 @@ const Modal = _a => {
|
|
|
1177
1183
|
return jsxs("section", Object.assign({
|
|
1178
1184
|
role: "dialog"
|
|
1179
1185
|
}, {
|
|
1180
|
-
children: [jsx(ModalHeader, Object.assign({}, props)
|
|
1181
|
-
})
|
|
1186
|
+
children: [jsx(ModalHeader, Object.assign({}, props)), jsx(ModalBody, Object.assign({}, props)), jsx(ModalFooter, Object.assign({}, props))]
|
|
1187
|
+
}));
|
|
1182
1188
|
}
|
|
1183
1189
|
}
|
|
1184
1190
|
};
|
|
@@ -1197,7 +1203,7 @@ var objectKeys = objectKeys$2;
|
|
|
1197
1203
|
|
|
1198
1204
|
// `Object.defineProperties` method
|
|
1199
1205
|
// https://tc39.es/ecma262/#sec-object.defineproperties
|
|
1200
|
-
// eslint-disable-next-line es/no-object-defineproperties -- safe
|
|
1206
|
+
// eslint-disable-next-line es-x/no-object-defineproperties -- safe
|
|
1201
1207
|
objectDefineProperties.f = DESCRIPTORS$2 && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) {
|
|
1202
1208
|
anObject$2(O);
|
|
1203
1209
|
var props = toIndexedObject$1(Properties);
|
|
@@ -1285,6 +1291,7 @@ hiddenKeys[IE_PROTO$1] = true;
|
|
|
1285
1291
|
|
|
1286
1292
|
// `Object.create` method
|
|
1287
1293
|
// https://tc39.es/ecma262/#sec-object.create
|
|
1294
|
+
// eslint-disable-next-line es-x/no-object-create -- safe
|
|
1288
1295
|
var objectCreate = Object.create || function create(O, Properties) {
|
|
1289
1296
|
var result;
|
|
1290
1297
|
if (O !== null) {
|
|
@@ -1325,7 +1332,7 @@ var fails$1 = fails$a;
|
|
|
1325
1332
|
var correctPrototypeGetter = !fails$1(function () {
|
|
1326
1333
|
function F() { /* empty */ }
|
|
1327
1334
|
F.prototype.constructor = null;
|
|
1328
|
-
// eslint-disable-next-line es/no-object-getprototypeof -- required for testing
|
|
1335
|
+
// eslint-disable-next-line es-x/no-object-getprototypeof -- required for testing
|
|
1329
1336
|
return Object.getPrototypeOf(new F()) !== F.prototype;
|
|
1330
1337
|
});
|
|
1331
1338
|
|
|
@@ -1364,7 +1371,7 @@ var BUGGY_SAFARI_ITERATORS$1 = false;
|
|
|
1364
1371
|
// https://tc39.es/ecma262/#sec-%iteratorprototype%-object
|
|
1365
1372
|
var IteratorPrototype$2, PrototypeOfArrayIteratorPrototype, arrayIterator;
|
|
1366
1373
|
|
|
1367
|
-
/* eslint-disable es/no-array-prototype-keys -- safe */
|
|
1374
|
+
/* eslint-disable es-x/no-array-prototype-keys -- safe */
|
|
1368
1375
|
if ([].keys) {
|
|
1369
1376
|
arrayIterator = [].keys();
|
|
1370
1377
|
// Safari 8 has buggy iterators w/o `next`
|
|
@@ -1445,13 +1452,13 @@ var aPossiblePrototype = aPossiblePrototype$1;
|
|
|
1445
1452
|
// `Object.setPrototypeOf` method
|
|
1446
1453
|
// https://tc39.es/ecma262/#sec-object.setprototypeof
|
|
1447
1454
|
// Works with __proto__ only. Old v8 can't work with null proto objects.
|
|
1448
|
-
// eslint-disable-next-line es/no-object-setprototypeof -- safe
|
|
1455
|
+
// eslint-disable-next-line es-x/no-object-setprototypeof -- safe
|
|
1449
1456
|
var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () {
|
|
1450
1457
|
var CORRECT_SETTER = false;
|
|
1451
1458
|
var test = {};
|
|
1452
1459
|
var setter;
|
|
1453
1460
|
try {
|
|
1454
|
-
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
1461
|
+
// eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
|
|
1455
1462
|
setter = uncurryThis$1(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set);
|
|
1456
1463
|
setter(test, []);
|
|
1457
1464
|
CORRECT_SETTER = test instanceof Array;
|
|
@@ -1741,7 +1748,7 @@ const Flexbox = _a => {
|
|
|
1741
1748
|
className: flexClassName
|
|
1742
1749
|
}, props, {
|
|
1743
1750
|
children: children
|
|
1744
|
-
})
|
|
1751
|
+
}));
|
|
1745
1752
|
};
|
|
1746
1753
|
|
|
1747
1754
|
function Card({
|
|
@@ -1754,54 +1761,147 @@ function Card({
|
|
|
1754
1761
|
}, {
|
|
1755
1762
|
children: [jsx("header", {
|
|
1756
1763
|
children: header
|
|
1757
|
-
},
|
|
1758
|
-
children: children
|
|
1759
|
-
}, void 0), jsx("footer", {
|
|
1764
|
+
}), children, jsx("footer", {
|
|
1760
1765
|
children: footer
|
|
1761
|
-
}
|
|
1762
|
-
})
|
|
1766
|
+
})]
|
|
1767
|
+
}));
|
|
1763
1768
|
}
|
|
1764
1769
|
|
|
1765
|
-
|
|
1770
|
+
const SquareExclamation = jsx("svg", Object.assign({
|
|
1771
|
+
viewBox: "0 0 24 24",
|
|
1772
|
+
fill: "none",
|
|
1773
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1774
|
+
"aria-hidden": "true",
|
|
1775
|
+
focusable: "false"
|
|
1776
|
+
}, {
|
|
1777
|
+
children: jsx("path", {
|
|
1778
|
+
fillRule: "evenodd",
|
|
1779
|
+
clipRule: "evenodd",
|
|
1780
|
+
d: "M18.2857 4H5.71429C4.7675 4 4 4.7675 4 5.71429V18.2857C4 19.2325 4.7675 20 5.71429 20H18.2857C19.2325 20 20 19.2325 20 18.2857V5.71429C20 4.7675 19.2325 4 18.2857 4ZM10.8682 7.42857H13.1318C13.3777 7.42857 13.5731 7.635 13.5597 7.8805L13.2948 12.7376C13.2824 12.9649 13.0945 13.1429 12.8669 13.1429H11.1331C10.9055 13.1429 10.7176 12.9649 10.7052 12.7376L10.4402 7.8805C10.4269 7.635 10.6223 7.42857 10.8682 7.42857ZM12 17.0714C11.0927 17.0714 10.3571 16.3359 10.3571 15.4286C10.3571 14.5213 11.0927 13.7857 12 13.7857C12.9073 13.7857 13.6429 14.5213 13.6429 15.4286C13.6429 16.3359 12.9073 17.0714 12 17.0714Z",
|
|
1781
|
+
fill: "#333333"
|
|
1782
|
+
})
|
|
1783
|
+
}));
|
|
1784
|
+
|
|
1785
|
+
const SquareInfo = jsx("svg", Object.assign({
|
|
1786
|
+
viewBox: "0 0 24 24",
|
|
1787
|
+
fill: "none",
|
|
1788
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
1789
|
+
}, {
|
|
1790
|
+
children: jsx("path", {
|
|
1791
|
+
d: "M18.2857 4H5.71429C4.7675 4 4 4.7675 4 5.71429V18.2857C4 19.2325 4.7675 20 5.71429 20H18.2857C19.2325 20 20 19.2325 20 18.2857V5.71429C20 4.7675 19.2325 4 18.2857 4ZM12 7.07143C12.8284 7.07143 13.5 7.743 13.5 8.57143C13.5 9.39986 12.8284 10.0714 12 10.0714C11.1716 10.0714 10.5 9.39986 10.5 8.57143C10.5 7.743 11.1716 7.07143 12 7.07143ZM14 16.1429C14 16.3795 13.8081 16.5714 13.5714 16.5714H10.4286C10.1919 16.5714 10 16.3795 10 16.1429V15.2857C10 15.049 10.1919 14.8571 10.4286 14.8571H10.8571V12.5714H10.4286C10.1919 12.5714 10 12.3795 10 12.1429V11.2857C10 11.049 10.1919 10.8571 10.4286 10.8571H12.7143C12.951 10.8571 13.1429 11.049 13.1429 11.2857V14.8571H13.5714C13.8081 14.8571 14 15.049 14 15.2857V16.1429Z",
|
|
1792
|
+
fill: "#333333"
|
|
1793
|
+
})
|
|
1794
|
+
}));
|
|
1795
|
+
|
|
1796
|
+
const Check = jsx("svg", Object.assign({
|
|
1797
|
+
width: "24",
|
|
1798
|
+
height: "24",
|
|
1799
|
+
viewBox: "0 0 24 24",
|
|
1800
|
+
fill: "none",
|
|
1801
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
1802
|
+
}, {
|
|
1803
|
+
children: jsx("path", {
|
|
1804
|
+
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",
|
|
1805
|
+
fill: "white"
|
|
1806
|
+
})
|
|
1807
|
+
}));
|
|
1808
|
+
|
|
1809
|
+
const ChevronDown = jsx("svg", Object.assign({
|
|
1810
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1811
|
+
width: "24",
|
|
1812
|
+
height: "24",
|
|
1813
|
+
viewBox: "0 0 448 512"
|
|
1814
|
+
}, {
|
|
1815
|
+
children: jsx("path", {
|
|
1816
|
+
d: "M441.9 167.3l-19.8-19.8c-4.7-4.7-12.3-4.7-17 0L224 328.2 42.9 147.5c-4.7-4.7-12.3-4.7-17 0L6.1 167.3c-4.7 4.7-4.7 12.3 0 17l209.4 209.4c4.7 4.7 12.3 4.7 17 0l209.4-209.4c4.7-4.7 4.7-12.3 0-17z"
|
|
1817
|
+
})
|
|
1818
|
+
}));
|
|
1819
|
+
|
|
1820
|
+
function AlertRibbon({
|
|
1766
1821
|
type,
|
|
1767
1822
|
header,
|
|
1768
1823
|
footer,
|
|
1769
1824
|
children,
|
|
1770
1825
|
closeText,
|
|
1771
|
-
isCloseable = true
|
|
1826
|
+
isCloseable = true,
|
|
1827
|
+
onClose,
|
|
1828
|
+
role,
|
|
1829
|
+
"aria-live": ariaLive,
|
|
1830
|
+
closeAriaLabel
|
|
1772
1831
|
}) {
|
|
1773
1832
|
const [closeButton, setCloseButton] = useState();
|
|
1774
1833
|
useEffect(() => {
|
|
1775
1834
|
if (!isCloseable) {
|
|
1776
1835
|
setCloseButton(null);
|
|
1777
1836
|
} else {
|
|
1778
|
-
if (closeText) setCloseButton(
|
|
1779
|
-
|
|
1837
|
+
if (closeText) setCloseButton(jsxs("button", Object.assign({
|
|
1838
|
+
className: "close"
|
|
1780
1839
|
}, {
|
|
1781
|
-
children: jsx("span", Object.assign({
|
|
1840
|
+
children: [jsx("span", Object.assign({
|
|
1782
1841
|
className: "sr-only"
|
|
1783
1842
|
}, {
|
|
1784
1843
|
children: closeText
|
|
1785
|
-
}),
|
|
1786
|
-
})
|
|
1844
|
+
})), jsx("i", {})]
|
|
1845
|
+
})));else setCloseButton(jsxs("button", Object.assign({
|
|
1787
1846
|
className: "close"
|
|
1788
|
-
},
|
|
1847
|
+
}, {
|
|
1848
|
+
children: [jsx("span", Object.assign({
|
|
1849
|
+
className: "sr-only"
|
|
1850
|
+
}, {
|
|
1851
|
+
children: "Close"
|
|
1852
|
+
})), jsx("i", {})]
|
|
1853
|
+
})));
|
|
1789
1854
|
}
|
|
1790
1855
|
}, [isCloseable, closeText]);
|
|
1856
|
+
|
|
1857
|
+
const renderIcon = () => {
|
|
1858
|
+
switch (type) {
|
|
1859
|
+
case "danger":
|
|
1860
|
+
case "warning":
|
|
1861
|
+
return SquareExclamation;
|
|
1862
|
+
|
|
1863
|
+
case "success":
|
|
1864
|
+
return Check;
|
|
1865
|
+
|
|
1866
|
+
default:
|
|
1867
|
+
return SquareInfo;
|
|
1868
|
+
}
|
|
1869
|
+
};
|
|
1870
|
+
|
|
1791
1871
|
return jsxs("div", Object.assign({
|
|
1792
|
-
|
|
1793
|
-
|
|
1872
|
+
className: `alert-ribbon ${type}`,
|
|
1873
|
+
role: role,
|
|
1874
|
+
"aria-live": ariaLive
|
|
1794
1875
|
}, {
|
|
1795
|
-
children: [
|
|
1796
|
-
|
|
1876
|
+
children: [jsx("i", Object.assign({
|
|
1877
|
+
"aria-hidden": "true"
|
|
1878
|
+
}, {
|
|
1879
|
+
children: renderIcon()
|
|
1880
|
+
})), jsxs("div", Object.assign({
|
|
1881
|
+
className: "alert-ribbon__content"
|
|
1882
|
+
}, {
|
|
1883
|
+
children: [header && /*#__PURE__*/React.isValidElement(header) ? header : jsx("span", Object.assign({
|
|
1884
|
+
className: "header"
|
|
1885
|
+
}, {
|
|
1797
1886
|
children: header
|
|
1798
|
-
},
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
}
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1887
|
+
})), jsx("p", {
|
|
1888
|
+
children: children
|
|
1889
|
+
})]
|
|
1890
|
+
})), closeButton && jsx("button", Object.assign({
|
|
1891
|
+
className: "close",
|
|
1892
|
+
type: "button",
|
|
1893
|
+
"aria-label": closeAriaLabel !== null && closeAriaLabel !== void 0 ? closeAriaLabel : "Close alert",
|
|
1894
|
+
onClick: event => {
|
|
1895
|
+
onClose && onClose(event);
|
|
1896
|
+
}
|
|
1897
|
+
}, {
|
|
1898
|
+
children: jsx("i", {})
|
|
1899
|
+
})), footer && jsxs("div", Object.assign({
|
|
1900
|
+
className: "alert-ribbon__footer"
|
|
1901
|
+
}, {
|
|
1902
|
+
children: [" ", footer, " "]
|
|
1903
|
+
}))]
|
|
1904
|
+
}));
|
|
1805
1905
|
}
|
|
1806
1906
|
|
|
1807
1907
|
const ButtonGroup = ({
|
|
@@ -1829,9 +1929,10 @@ const ButtonGroup = ({
|
|
|
1829
1929
|
}, [children, selected, variant]);
|
|
1830
1930
|
return jsx(Group, {
|
|
1831
1931
|
children: buttons.map(props => jsx(Button, Object.assign({}, props), props.key))
|
|
1832
|
-
}
|
|
1932
|
+
});
|
|
1833
1933
|
};
|
|
1834
1934
|
|
|
1935
|
+
/* eslint-disable-next-line */
|
|
1835
1936
|
const validateInputValue = (target, rules, setError) => {
|
|
1836
1937
|
const errorMessage = validateInputValueErrors(rules, target);
|
|
1837
1938
|
errorMessage ? setErrorInsert(setError, target.name) : setErrorRemove(setError, target.name);
|
|
@@ -1849,17 +1950,24 @@ const validateInputValueErrors = (rules, target) => {
|
|
|
1849
1950
|
|
|
1850
1951
|
return validateTextInputValues(value, rules);
|
|
1851
1952
|
};
|
|
1953
|
+
/* eslint-disable-next-line */
|
|
1954
|
+
|
|
1852
1955
|
|
|
1853
1956
|
const setErrorInsert = (setError, name) => {
|
|
1957
|
+
/* eslint-disable-next-line */
|
|
1854
1958
|
setError(errors => {
|
|
1855
1959
|
return Object.assign(Object.assign({}, errors), {
|
|
1856
1960
|
[name]: true
|
|
1857
1961
|
});
|
|
1858
1962
|
});
|
|
1859
1963
|
};
|
|
1964
|
+
/* eslint-disable-next-line */
|
|
1965
|
+
|
|
1860
1966
|
|
|
1861
1967
|
const setErrorRemove = (setError, name) => {
|
|
1968
|
+
/* eslint-disable-next-line */
|
|
1862
1969
|
setError(errors => {
|
|
1970
|
+
/* eslint-disable-next-line */
|
|
1863
1971
|
const newError = Object.assign({}, errors);
|
|
1864
1972
|
delete newError[name];
|
|
1865
1973
|
return newError;
|
|
@@ -1893,9 +2001,15 @@ const FormProvider = _a => {
|
|
|
1893
2001
|
onFormSubmit
|
|
1894
2002
|
} = _a,
|
|
1895
2003
|
props = __rest(_a, ["children", "direction", "formSize", "onSubmit", "onFormSubmit"]);
|
|
2004
|
+
/* eslint-disable-next-line */
|
|
2005
|
+
|
|
1896
2006
|
|
|
1897
2007
|
const [values, setValues] = React.useState();
|
|
2008
|
+
/* eslint-disable-next-line */
|
|
2009
|
+
|
|
1898
2010
|
const [errors, setErrors] = React.useState();
|
|
2011
|
+
/* eslint-disable-next-line */
|
|
2012
|
+
|
|
1899
2013
|
const [fields, setFields] = React.useState({});
|
|
1900
2014
|
|
|
1901
2015
|
const formSubmit = event => {
|
|
@@ -1935,12 +2049,12 @@ const FormProvider = _a => {
|
|
|
1935
2049
|
onReset: resetForm
|
|
1936
2050
|
}, {
|
|
1937
2051
|
children: children
|
|
1938
|
-
})
|
|
1939
|
-
})
|
|
2052
|
+
}))
|
|
2053
|
+
}));
|
|
1940
2054
|
};
|
|
1941
2055
|
|
|
1942
2056
|
const Form = props => {
|
|
1943
|
-
return jsx(FormProvider, Object.assign({}, props)
|
|
2057
|
+
return jsx(FormProvider, Object.assign({}, props));
|
|
1944
2058
|
};
|
|
1945
2059
|
|
|
1946
2060
|
const FormItems = ({
|
|
@@ -1955,24 +2069,33 @@ const FormItems = ({
|
|
|
1955
2069
|
errors
|
|
1956
2070
|
} = useFormContext();
|
|
1957
2071
|
React.useEffect(() => {
|
|
2072
|
+
/* eslint-disable-next-line */
|
|
1958
2073
|
setFields(fields => Object.assign(Object.assign({}, fields), {
|
|
1959
2074
|
[name]: validate === null || validate === void 0 ? void 0 : validate.rules
|
|
1960
2075
|
}));
|
|
2076
|
+
/* eslint-disable-next-line */
|
|
1961
2077
|
|
|
1962
2078
|
const removeValues = values => {
|
|
2079
|
+
/* eslint-disable-next-line */
|
|
1963
2080
|
const newValues = Object.assign({}, values);
|
|
1964
2081
|
delete newValues[name];
|
|
1965
2082
|
return newValues;
|
|
1966
2083
|
};
|
|
1967
2084
|
|
|
1968
2085
|
return () => {
|
|
2086
|
+
/* eslint-disable-next-line */
|
|
1969
2087
|
setFields(fields => removeValues(fields));
|
|
2088
|
+
/* eslint-disable-next-line */
|
|
2089
|
+
|
|
1970
2090
|
setValues(values => removeValues(values));
|
|
2091
|
+
/* eslint-disable-next-line */
|
|
2092
|
+
|
|
1971
2093
|
setErrors(errors => removeValues(errors));
|
|
1972
|
-
};
|
|
2094
|
+
}; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1973
2095
|
}, []);
|
|
1974
2096
|
|
|
1975
2097
|
const onChange = event => {
|
|
2098
|
+
if (!event.target) return;
|
|
1976
2099
|
const {
|
|
1977
2100
|
value,
|
|
1978
2101
|
name,
|
|
@@ -1983,6 +2106,8 @@ const FormItems = ({
|
|
|
1983
2106
|
|
|
1984
2107
|
if (type === 'checkbox') {
|
|
1985
2108
|
inputValue = checked ? value : null;
|
|
2109
|
+
/* eslint-disable-next-line */
|
|
2110
|
+
|
|
1986
2111
|
checked ? setValues(values => Object.assign(Object.assign({}, values), {
|
|
1987
2112
|
[name]: value
|
|
1988
2113
|
})) : setValues(values => Object.assign(Object.assign({}, values), {
|
|
@@ -1990,6 +2115,8 @@ const FormItems = ({
|
|
|
1990
2115
|
}));
|
|
1991
2116
|
} else {
|
|
1992
2117
|
inputValue = value;
|
|
2118
|
+
/* eslint-disable-next-line */
|
|
2119
|
+
|
|
1993
2120
|
setValues(values => Object.assign(Object.assign({}, values), {
|
|
1994
2121
|
[name]: value
|
|
1995
2122
|
}));
|
|
@@ -2002,6 +2129,8 @@ const FormItems = ({
|
|
|
2002
2129
|
checked
|
|
2003
2130
|
}, validate === null || validate === void 0 ? void 0 : validate.rules, setErrors);
|
|
2004
2131
|
};
|
|
2132
|
+
/* eslint-disable-next-line */
|
|
2133
|
+
|
|
2005
2134
|
|
|
2006
2135
|
return /*#__PURE__*/React.cloneElement(children, {
|
|
2007
2136
|
validator: (errors === null || errors === void 0 ? void 0 : errors[name]) && validate,
|
|
@@ -2024,12 +2153,12 @@ function Group({
|
|
|
2024
2153
|
className: groupClassName
|
|
2025
2154
|
}, {
|
|
2026
2155
|
children: children
|
|
2027
|
-
})
|
|
2156
|
+
})), error && jsx("span", Object.assign({
|
|
2028
2157
|
className: "form-info"
|
|
2029
2158
|
}, {
|
|
2030
2159
|
children: errorMessage
|
|
2031
|
-
})
|
|
2032
|
-
})
|
|
2160
|
+
}))]
|
|
2161
|
+
}));
|
|
2033
2162
|
}
|
|
2034
2163
|
|
|
2035
2164
|
const useInput = (props, onChanges, onChangeInput) => {
|
|
@@ -2083,7 +2212,7 @@ const RenderInput = (type, props, onChange, onChangeInput, label, info, validato
|
|
|
2083
2212
|
if (!label && !info) return jsx("input", Object.assign({
|
|
2084
2213
|
type: type,
|
|
2085
2214
|
value: value
|
|
2086
|
-
}, propsWithDescription)
|
|
2215
|
+
}, propsWithDescription));
|
|
2087
2216
|
return jsxs("div", Object.assign({
|
|
2088
2217
|
className: "form-group"
|
|
2089
2218
|
}, {
|
|
@@ -2091,22 +2220,22 @@ const RenderInput = (type, props, onChange, onChangeInput, label, info, validato
|
|
|
2091
2220
|
htmlFor: inputProps.id
|
|
2092
2221
|
}, {
|
|
2093
2222
|
children: label
|
|
2094
|
-
})
|
|
2223
|
+
})), info && jsx("span", Object.assign({
|
|
2095
2224
|
className: "form-info",
|
|
2096
2225
|
id: `${inputProps.id}_info`
|
|
2097
2226
|
}, {
|
|
2098
2227
|
children: info
|
|
2099
|
-
})
|
|
2228
|
+
})), jsx("input", Object.assign({
|
|
2100
2229
|
type: type,
|
|
2101
2230
|
value: value
|
|
2102
2231
|
}, propsWithDescription, {
|
|
2103
2232
|
className: validator && validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)
|
|
2104
|
-
})
|
|
2233
|
+
})), validator && jsx("span", Object.assign({
|
|
2105
2234
|
className: "form-info"
|
|
2106
2235
|
}, {
|
|
2107
2236
|
children: validator.message
|
|
2108
|
-
})
|
|
2109
|
-
})
|
|
2237
|
+
}))]
|
|
2238
|
+
}));
|
|
2110
2239
|
};
|
|
2111
2240
|
const TextInput = _a => {
|
|
2112
2241
|
var {
|
|
@@ -2154,20 +2283,24 @@ const Checkbox = _a => {
|
|
|
2154
2283
|
|
|
2155
2284
|
const inputProps = useInput(props, onChange);
|
|
2156
2285
|
const validatorClassName = validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
|
|
2157
|
-
return jsxs(
|
|
2286
|
+
return jsxs("div", Object.assign({
|
|
2287
|
+
className: "form-group"
|
|
2288
|
+
}, {
|
|
2158
2289
|
children: [jsxs("label", Object.assign({
|
|
2159
2290
|
htmlFor: inputProps.id,
|
|
2160
2291
|
className: `form-control ${validatorClassName}`
|
|
2161
2292
|
}, {
|
|
2162
2293
|
children: [label, jsx("input", Object.assign({
|
|
2163
2294
|
type: "checkbox"
|
|
2164
|
-
}, inputProps
|
|
2165
|
-
|
|
2295
|
+
}, inputProps, {
|
|
2296
|
+
className: validatorClassName
|
|
2297
|
+
})), jsx("i", {})]
|
|
2298
|
+
})), validator && jsx("span", Object.assign({
|
|
2166
2299
|
className: "form-info"
|
|
2167
2300
|
}, {
|
|
2168
2301
|
children: validator.message
|
|
2169
|
-
})
|
|
2170
|
-
}
|
|
2302
|
+
}))]
|
|
2303
|
+
}));
|
|
2171
2304
|
};
|
|
2172
2305
|
const RadioButton = /*#__PURE__*/React.forwardRef((_a, ref) => {
|
|
2173
2306
|
var {
|
|
@@ -2189,10 +2322,10 @@ const RadioButton = /*#__PURE__*/React.forwardRef((_a, ref) => {
|
|
|
2189
2322
|
}, props, {
|
|
2190
2323
|
className: validator,
|
|
2191
2324
|
ref: ref
|
|
2192
|
-
})
|
|
2325
|
+
})), jsx("span", {
|
|
2193
2326
|
children: label
|
|
2194
|
-
}
|
|
2195
|
-
})
|
|
2327
|
+
}), jsx("i", {})]
|
|
2328
|
+
}));
|
|
2196
2329
|
});
|
|
2197
2330
|
|
|
2198
2331
|
const Text = ({
|
|
@@ -2201,7 +2334,7 @@ const Text = ({
|
|
|
2201
2334
|
className: "form-text"
|
|
2202
2335
|
}, {
|
|
2203
2336
|
children: children
|
|
2204
|
-
})
|
|
2337
|
+
}));
|
|
2205
2338
|
|
|
2206
2339
|
var wellKnownSymbol$1 = wellKnownSymbol$8;
|
|
2207
2340
|
|
|
@@ -2311,6 +2444,8 @@ if (DESCRIPTORS && isCallable(NativeSymbol) && (!('description' in SymbolPrototy
|
|
|
2311
2444
|
}
|
|
2312
2445
|
|
|
2313
2446
|
const RadioGroup = ({
|
|
2447
|
+
defaultSelected,
|
|
2448
|
+
valueSelected,
|
|
2314
2449
|
description,
|
|
2315
2450
|
title,
|
|
2316
2451
|
validator,
|
|
@@ -2319,13 +2454,15 @@ const RadioGroup = ({
|
|
|
2319
2454
|
name,
|
|
2320
2455
|
children
|
|
2321
2456
|
}) => {
|
|
2322
|
-
const [
|
|
2457
|
+
const [selected, setSelected] = React.useState(valueSelected !== null && valueSelected !== void 0 ? valueSelected : defaultSelected);
|
|
2323
2458
|
const validatorClassName = validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
|
|
2324
2459
|
|
|
2325
|
-
const
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2460
|
+
const handleOnChange = event => {
|
|
2461
|
+
if (event.target.value !== selected) {
|
|
2462
|
+
setSelected(event.target.value);
|
|
2463
|
+
onChangeRadio && onChangeRadio(event.target.value);
|
|
2464
|
+
onChange && onChange(event);
|
|
2465
|
+
}
|
|
2329
2466
|
};
|
|
2330
2467
|
|
|
2331
2468
|
const radioBtnRef = React.useRef(null);
|
|
@@ -2336,7 +2473,7 @@ const RadioGroup = ({
|
|
|
2336
2473
|
const form = (_a = radioBtnRef === null || radioBtnRef === void 0 ? void 0 : radioBtnRef.current) === null || _a === void 0 ? void 0 : _a.form;
|
|
2337
2474
|
|
|
2338
2475
|
const resetListner = () => {
|
|
2339
|
-
|
|
2476
|
+
setSelected(undefined);
|
|
2340
2477
|
};
|
|
2341
2478
|
|
|
2342
2479
|
form === null || form === void 0 ? void 0 : form.addEventListener('reset', resetListner);
|
|
@@ -2344,7 +2481,8 @@ const RadioGroup = ({
|
|
|
2344
2481
|
} else {
|
|
2345
2482
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
2346
2483
|
return () => {};
|
|
2347
|
-
}
|
|
2484
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2485
|
+
|
|
2348
2486
|
}, []);
|
|
2349
2487
|
return jsxs("div", Object.assign({
|
|
2350
2488
|
className: "form-group"
|
|
@@ -2352,27 +2490,29 @@ const RadioGroup = ({
|
|
|
2352
2490
|
children: [jsxs("fieldset", Object.assign({
|
|
2353
2491
|
className: validatorClassName
|
|
2354
2492
|
}, {
|
|
2355
|
-
children: [jsx("legend", {
|
|
2493
|
+
children: [title && jsx("legend", {
|
|
2356
2494
|
children: title
|
|
2357
|
-
},
|
|
2495
|
+
}), description && jsx("span", Object.assign({
|
|
2358
2496
|
className: "form-info"
|
|
2359
2497
|
}, {
|
|
2360
2498
|
children: description
|
|
2361
|
-
})
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2499
|
+
})), jsx("div", {
|
|
2500
|
+
children: React.Children.map(children, radioButton => {
|
|
2501
|
+
return /*#__PURE__*/React.isValidElement(radioButton) ? /*#__PURE__*/React.cloneElement(radioButton, {
|
|
2502
|
+
validator: validatorClassName,
|
|
2503
|
+
onChange: handleOnChange,
|
|
2504
|
+
checked: selected === radioButton.props.value,
|
|
2505
|
+
name,
|
|
2506
|
+
ref: radioBtnRef
|
|
2507
|
+
}) : radioButton;
|
|
2508
|
+
})
|
|
2369
2509
|
})]
|
|
2370
|
-
})
|
|
2510
|
+
})), (validator === null || validator === void 0 ? void 0 : validator.message) && jsx("span", Object.assign({
|
|
2371
2511
|
className: "form-info"
|
|
2372
2512
|
}, {
|
|
2373
2513
|
children: validator === null || validator === void 0 ? void 0 : validator.message
|
|
2374
|
-
})
|
|
2375
|
-
})
|
|
2514
|
+
}))]
|
|
2515
|
+
}));
|
|
2376
2516
|
};
|
|
2377
2517
|
|
|
2378
2518
|
const ListItem = _a => {
|
|
@@ -2388,15 +2528,15 @@ const ListItem = _a => {
|
|
|
2388
2528
|
children: jsxs("div", {
|
|
2389
2529
|
children: [jsx("dt", {
|
|
2390
2530
|
children: tableRowData === null || tableRowData === void 0 ? void 0 : tableRowData.title
|
|
2391
|
-
}
|
|
2531
|
+
}), tableRowData === null || tableRowData === void 0 ? void 0 : tableRowData.definition.map((item, index) => jsx("dd", {
|
|
2392
2532
|
children: item
|
|
2393
2533
|
}, index))]
|
|
2394
|
-
}
|
|
2395
|
-
}
|
|
2534
|
+
})
|
|
2535
|
+
});
|
|
2396
2536
|
} else {
|
|
2397
2537
|
return jsx("li", Object.assign({}, props, {
|
|
2398
2538
|
children: children
|
|
2399
|
-
})
|
|
2539
|
+
}));
|
|
2400
2540
|
}
|
|
2401
2541
|
};
|
|
2402
2542
|
|
|
@@ -2414,7 +2554,7 @@ const List = _a => {
|
|
|
2414
2554
|
children: children === null || children === void 0 ? void 0 : children.map((child, index) => jsx(ListItem, {
|
|
2415
2555
|
children: child
|
|
2416
2556
|
}, index))
|
|
2417
|
-
})
|
|
2557
|
+
}));
|
|
2418
2558
|
} else if (listType !== 'table') {
|
|
2419
2559
|
return jsx("ul", Object.assign({}, props, {
|
|
2420
2560
|
className: listType
|
|
@@ -2422,20 +2562,20 @@ const List = _a => {
|
|
|
2422
2562
|
children: children === null || children === void 0 ? void 0 : children.map((child, index) => jsx(ListItem, {
|
|
2423
2563
|
children: child
|
|
2424
2564
|
}, index))
|
|
2425
|
-
})
|
|
2565
|
+
}));
|
|
2426
2566
|
} else {
|
|
2427
2567
|
return jsxs("figure", {
|
|
2428
2568
|
children: [jsx("figcaption", Object.assign({
|
|
2429
2569
|
className: "table-list-caption"
|
|
2430
2570
|
}, {
|
|
2431
2571
|
children: tableCaption
|
|
2432
|
-
})
|
|
2572
|
+
})), jsx("dl", {
|
|
2433
2573
|
children: tableData === null || tableData === void 0 ? void 0 : tableData.map((data, index) => jsx(ListItem, {
|
|
2434
2574
|
listType: listType,
|
|
2435
2575
|
tableRowData: data
|
|
2436
2576
|
}, index))
|
|
2437
|
-
}
|
|
2438
|
-
}
|
|
2577
|
+
})]
|
|
2578
|
+
});
|
|
2439
2579
|
}
|
|
2440
2580
|
};
|
|
2441
2581
|
|
|
@@ -2453,11 +2593,11 @@ const Link = _a => {
|
|
|
2453
2593
|
role: button ? 'button' : undefined,
|
|
2454
2594
|
className: className
|
|
2455
2595
|
}, props);
|
|
2456
|
-
setAnchorProps(newProps);
|
|
2596
|
+
setAnchorProps(newProps); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2457
2597
|
}, [button]);
|
|
2458
2598
|
return jsx("a", Object.assign({}, anchorProps, {
|
|
2459
2599
|
children: children
|
|
2460
|
-
})
|
|
2600
|
+
}));
|
|
2461
2601
|
};
|
|
2462
2602
|
|
|
2463
2603
|
const Navbar = ({
|
|
@@ -2484,7 +2624,7 @@ const Navbar = ({
|
|
|
2484
2624
|
href: _brandLink,
|
|
2485
2625
|
target: "_blank",
|
|
2486
2626
|
className: "brand"
|
|
2487
|
-
}
|
|
2627
|
+
}), jsx("div", Object.assign({
|
|
2488
2628
|
className: "container-fluid"
|
|
2489
2629
|
}, {
|
|
2490
2630
|
children: jsxs("div", Object.assign({
|
|
@@ -2499,48 +2639,691 @@ const Navbar = ({
|
|
|
2499
2639
|
}, {
|
|
2500
2640
|
children: jsx("h1", {
|
|
2501
2641
|
children: title
|
|
2502
|
-
}
|
|
2503
|
-
})
|
|
2642
|
+
})
|
|
2643
|
+
})) : jsx("h1", {
|
|
2504
2644
|
children: title
|
|
2505
|
-
}
|
|
2506
|
-
})
|
|
2645
|
+
})
|
|
2646
|
+
})), jsx("div", Object.assign({
|
|
2507
2647
|
className: "col-auto"
|
|
2508
2648
|
}, {
|
|
2509
2649
|
children: jsx("div", Object.assign({
|
|
2510
2650
|
className: "group size-sm"
|
|
2511
2651
|
}, {
|
|
2512
2652
|
children: children
|
|
2513
|
-
})
|
|
2514
|
-
})
|
|
2515
|
-
})
|
|
2516
|
-
})
|
|
2517
|
-
})
|
|
2653
|
+
}))
|
|
2654
|
+
}))]
|
|
2655
|
+
}))
|
|
2656
|
+
}))]
|
|
2657
|
+
}));
|
|
2518
2658
|
};
|
|
2519
2659
|
|
|
2520
2660
|
function Badge(_a) {
|
|
2521
2661
|
var {
|
|
2522
|
-
|
|
2662
|
+
children,
|
|
2523
2663
|
badgeType,
|
|
2524
2664
|
isCloseable,
|
|
2525
|
-
closeText
|
|
2665
|
+
closeText,
|
|
2666
|
+
customColor,
|
|
2667
|
+
customBackgroundColor
|
|
2526
2668
|
} = _a,
|
|
2527
|
-
props = __rest(_a, ["
|
|
2669
|
+
props = __rest(_a, ["children", "badgeType", "isCloseable", "closeText", "customColor", "customBackgroundColor"]);
|
|
2528
2670
|
|
|
2529
|
-
|
|
2530
|
-
|
|
2671
|
+
const [isClosed, setIsClosed] = React.useState(false);
|
|
2672
|
+
const [type, setType] = React.useState('');
|
|
2673
|
+
React.useEffect(() => {
|
|
2674
|
+
if (badgeType) {
|
|
2675
|
+
setType(badgeType);
|
|
2676
|
+
}
|
|
2677
|
+
|
|
2678
|
+
if (!!customColor || !!customBackgroundColor) {
|
|
2679
|
+
setType('');
|
|
2680
|
+
}
|
|
2681
|
+
}, [badgeType, customColor, customBackgroundColor]);
|
|
2682
|
+
return !isClosed ? jsxs("span", Object.assign({}, props, {
|
|
2683
|
+
className: `badge ${type}`,
|
|
2684
|
+
style: {
|
|
2685
|
+
color: customColor,
|
|
2686
|
+
backgroundColor: customBackgroundColor
|
|
2687
|
+
}
|
|
2531
2688
|
}, {
|
|
2532
2689
|
children: [jsx("strong", {
|
|
2533
|
-
children:
|
|
2534
|
-
}
|
|
2535
|
-
|
|
2690
|
+
children: children
|
|
2691
|
+
}), isCloseable && jsxs("button", Object.assign({
|
|
2692
|
+
type: "button",
|
|
2693
|
+
className: "close",
|
|
2694
|
+
onClick: () => setIsClosed(true)
|
|
2536
2695
|
}, {
|
|
2537
|
-
children: jsx("
|
|
2538
|
-
|
|
2696
|
+
children: [closeText, jsx("i", {})]
|
|
2697
|
+
}))]
|
|
2698
|
+
})) : null;
|
|
2699
|
+
}
|
|
2700
|
+
|
|
2701
|
+
const noop = () => {};
|
|
2702
|
+
|
|
2703
|
+
const useStepper = ({
|
|
2704
|
+
min,
|
|
2705
|
+
max,
|
|
2706
|
+
value: _value = 0,
|
|
2707
|
+
step: _step = 1,
|
|
2708
|
+
id: _id = randomId(),
|
|
2709
|
+
onChange
|
|
2710
|
+
}) => {
|
|
2711
|
+
const pStepper = {
|
|
2712
|
+
down: noop,
|
|
2713
|
+
setMax: noop,
|
|
2714
|
+
setMin: noop,
|
|
2715
|
+
setStep: noop,
|
|
2716
|
+
setValue: noop,
|
|
2717
|
+
up: noop
|
|
2718
|
+
};
|
|
2719
|
+
const [stepper, setStepper] = useState(pStepper);
|
|
2720
|
+
const [data, setData] = useState({
|
|
2721
|
+
id: _id,
|
|
2722
|
+
value: _value,
|
|
2723
|
+
min,
|
|
2724
|
+
max,
|
|
2725
|
+
step: _step
|
|
2726
|
+
}); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2727
|
+
|
|
2728
|
+
useEffect(() => {
|
|
2729
|
+
if (max !== data.max) stepper.setMax(max);
|
|
2730
|
+
}, [stepper, max]); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2731
|
+
|
|
2732
|
+
useEffect(() => {
|
|
2733
|
+
if (min !== data.min) stepper.setMin(min);
|
|
2734
|
+
}, [stepper, min]); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2735
|
+
|
|
2736
|
+
useEffect(() => {
|
|
2737
|
+
if (_step !== data.step) stepper.setStep(_step || 1);
|
|
2738
|
+
}, [stepper, _step]); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2739
|
+
|
|
2740
|
+
useEffect(() => {
|
|
2741
|
+
if (_value !== data.value) stepper.setValue(_value || 0, false);
|
|
2742
|
+
}, [stepper, _value]);
|
|
2743
|
+
useEffect(() => {
|
|
2744
|
+
setStepper(createStepper({
|
|
2745
|
+
id: _id,
|
|
2746
|
+
value: _value,
|
|
2747
|
+
min,
|
|
2748
|
+
max,
|
|
2749
|
+
step: _step,
|
|
2750
|
+
onChange
|
|
2751
|
+
}, setData)); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2752
|
+
}, []);
|
|
2753
|
+
return [stepper, data];
|
|
2754
|
+
};
|
|
2755
|
+
|
|
2756
|
+
function Stepper(_a) {
|
|
2757
|
+
var {
|
|
2758
|
+
label,
|
|
2759
|
+
description,
|
|
2760
|
+
statusMessage,
|
|
2761
|
+
validator
|
|
2762
|
+
} = _a,
|
|
2763
|
+
stepperArgs = __rest(_a, ["label", "description", "statusMessage", "validator"]);
|
|
2764
|
+
|
|
2765
|
+
const [stepper, data] = useStepper(stepperArgs);
|
|
2766
|
+
|
|
2767
|
+
const onChangeEvent = e => {
|
|
2768
|
+
stepper.setValue(e.target.valueAsNumber);
|
|
2769
|
+
};
|
|
2770
|
+
|
|
2771
|
+
const PrimitiveStepper = jsxs("div", Object.assign({
|
|
2772
|
+
className: `group group-border group-stepper ${validator && validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)}`
|
|
2773
|
+
}, {
|
|
2774
|
+
children: [jsx("button", Object.assign({
|
|
2775
|
+
onClick: () => stepper.down()
|
|
2776
|
+
}, {
|
|
2777
|
+
children: "-"
|
|
2778
|
+
})), jsx("input", {
|
|
2779
|
+
id: data.id,
|
|
2780
|
+
type: "number",
|
|
2781
|
+
onChange: onChangeEvent,
|
|
2782
|
+
onFocus: ({
|
|
2783
|
+
target
|
|
2784
|
+
}) => target.select(),
|
|
2785
|
+
placeholder: "0",
|
|
2786
|
+
value: data.value
|
|
2787
|
+
}), jsx("button", Object.assign({
|
|
2788
|
+
onClick: () => stepper.up()
|
|
2789
|
+
}, {
|
|
2790
|
+
children: "+"
|
|
2791
|
+
}))]
|
|
2792
|
+
}));
|
|
2793
|
+
|
|
2794
|
+
if (!label && !description && !statusMessage && !validator) return PrimitiveStepper;
|
|
2795
|
+
return jsxs("div", Object.assign({
|
|
2796
|
+
className: "form-group"
|
|
2797
|
+
}, {
|
|
2798
|
+
children: [label && jsx("label", Object.assign({
|
|
2799
|
+
htmlFor: data.id
|
|
2800
|
+
}, {
|
|
2801
|
+
children: label
|
|
2802
|
+
})), description && jsx("span", Object.assign({
|
|
2803
|
+
className: "form-info"
|
|
2804
|
+
}, {
|
|
2805
|
+
children: description
|
|
2806
|
+
})), jsxs("div", Object.assign({
|
|
2807
|
+
className: "stepper-wrapper"
|
|
2808
|
+
}, {
|
|
2809
|
+
children: [PrimitiveStepper, validator && jsx("span", Object.assign({
|
|
2810
|
+
className: "form-info"
|
|
2539
2811
|
}, {
|
|
2540
|
-
children:
|
|
2541
|
-
})
|
|
2542
|
-
})
|
|
2543
|
-
})
|
|
2812
|
+
children: validator.message
|
|
2813
|
+
}))]
|
|
2814
|
+
}))]
|
|
2815
|
+
}));
|
|
2544
2816
|
}
|
|
2545
2817
|
|
|
2546
|
-
|
|
2818
|
+
const Select = /*#__PURE__*/React.forwardRef(({
|
|
2819
|
+
id,
|
|
2820
|
+
className,
|
|
2821
|
+
children,
|
|
2822
|
+
validator,
|
|
2823
|
+
label,
|
|
2824
|
+
labelInformation,
|
|
2825
|
+
defaultValue,
|
|
2826
|
+
value,
|
|
2827
|
+
testId,
|
|
2828
|
+
onChange,
|
|
2829
|
+
onSelect
|
|
2830
|
+
}, ref) => {
|
|
2831
|
+
const selectId = id !== null && id !== void 0 ? id : randomId();
|
|
2832
|
+
const validatorClassName = validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
|
|
2833
|
+
return jsx(Fragment, {
|
|
2834
|
+
children: jsx("div", Object.assign({
|
|
2835
|
+
className: `form-group ${validator && 'validated'}`
|
|
2836
|
+
}, {
|
|
2837
|
+
children: jsxs("div", Object.assign({
|
|
2838
|
+
className: "gds--select"
|
|
2839
|
+
}, {
|
|
2840
|
+
children: [label && jsx("label", Object.assign({
|
|
2841
|
+
htmlFor: selectId
|
|
2842
|
+
}, {
|
|
2843
|
+
children: label
|
|
2844
|
+
})), labelInformation && jsx("div", Object.assign({
|
|
2845
|
+
className: "form-info"
|
|
2846
|
+
}, {
|
|
2847
|
+
children: labelInformation
|
|
2848
|
+
})), jsxs("div", Object.assign({
|
|
2849
|
+
className: `gsd--select-wrapper ${validatorClassName}`
|
|
2850
|
+
}, {
|
|
2851
|
+
children: [jsx("select", Object.assign({
|
|
2852
|
+
id: selectId,
|
|
2853
|
+
"data-testid": testId,
|
|
2854
|
+
className: className,
|
|
2855
|
+
defaultValue: defaultValue,
|
|
2856
|
+
value: value,
|
|
2857
|
+
ref: ref,
|
|
2858
|
+
onChange: event => {
|
|
2859
|
+
onChange && onChange(event);
|
|
2860
|
+
}
|
|
2861
|
+
}, {
|
|
2862
|
+
children: children
|
|
2863
|
+
})), ChevronDown]
|
|
2864
|
+
})), (validator === null || validator === void 0 ? void 0 : validator.message) && jsx("div", Object.assign({
|
|
2865
|
+
className: "form-info"
|
|
2866
|
+
}, {
|
|
2867
|
+
children: validator.message
|
|
2868
|
+
}))]
|
|
2869
|
+
}))
|
|
2870
|
+
}))
|
|
2871
|
+
});
|
|
2872
|
+
});
|
|
2873
|
+
const Option = _a => {
|
|
2874
|
+
var {
|
|
2875
|
+
value,
|
|
2876
|
+
children
|
|
2877
|
+
} = _a,
|
|
2878
|
+
rest = __rest(_a, ["value", "children"]);
|
|
2879
|
+
|
|
2880
|
+
return jsx("option", Object.assign({
|
|
2881
|
+
value: value
|
|
2882
|
+
}, rest, {
|
|
2883
|
+
children: children
|
|
2884
|
+
}));
|
|
2885
|
+
};
|
|
2886
|
+
const OptionGroup = ({
|
|
2887
|
+
label,
|
|
2888
|
+
disabled,
|
|
2889
|
+
children
|
|
2890
|
+
}) => {
|
|
2891
|
+
return jsx("optgroup", Object.assign({
|
|
2892
|
+
label: label,
|
|
2893
|
+
disabled: disabled
|
|
2894
|
+
}, {
|
|
2895
|
+
children: children
|
|
2896
|
+
}));
|
|
2897
|
+
};
|
|
2898
|
+
|
|
2899
|
+
const useDropdown = ({
|
|
2900
|
+
id,
|
|
2901
|
+
value,
|
|
2902
|
+
texts,
|
|
2903
|
+
options,
|
|
2904
|
+
loop,
|
|
2905
|
+
multiSelect,
|
|
2906
|
+
searchable,
|
|
2907
|
+
searchFilter,
|
|
2908
|
+
compareWith,
|
|
2909
|
+
useValue,
|
|
2910
|
+
display,
|
|
2911
|
+
togglerRef,
|
|
2912
|
+
listboxRef,
|
|
2913
|
+
onChange,
|
|
2914
|
+
validator
|
|
2915
|
+
}) => {
|
|
2916
|
+
const [handler, setHandler] = useState();
|
|
2917
|
+
const [dropdown, setDropdown] = useState();
|
|
2918
|
+
const [togglerProps, setTogglerProps] = useState({});
|
|
2919
|
+
const [listboxProps, setListboxProps] = useState({});
|
|
2920
|
+
const [listItems, setListItems] = useState([]);
|
|
2921
|
+
const [multiSelectProps, setMultiSelectProps] = useState({}); // When dropdown data changes
|
|
2922
|
+
|
|
2923
|
+
useEffect(() => {
|
|
2924
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
2925
|
+
|
|
2926
|
+
if (!dropdown) return;
|
|
2927
|
+
const {
|
|
2928
|
+
elements: {
|
|
2929
|
+
toggler,
|
|
2930
|
+
listbox
|
|
2931
|
+
}
|
|
2932
|
+
} = dropdown;
|
|
2933
|
+
const newToggleProps = Object.assign(Object.assign({}, toggler === null || toggler === void 0 ? void 0 : toggler.attributes), {
|
|
2934
|
+
className: (_a = toggler === null || toggler === void 0 ? void 0 : toggler.classes) === null || _a === void 0 ? void 0 : _a.join(' '),
|
|
2935
|
+
children: (_b = dropdown === null || dropdown === void 0 ? void 0 : dropdown.texts) === null || _b === void 0 ? void 0 : _b.select,
|
|
2936
|
+
onClick: () => handler === null || handler === void 0 ? void 0 : handler.toggle()
|
|
2937
|
+
});
|
|
2938
|
+
setTogglerProps(newToggleProps);
|
|
2939
|
+
const newListboxProps = Object.assign(Object.assign({}, listbox === null || listbox === void 0 ? void 0 : listbox.attributes), {
|
|
2940
|
+
className: (_c = listbox === null || listbox === void 0 ? void 0 : listbox.classes) === null || _c === void 0 ? void 0 : _c.join(' ')
|
|
2941
|
+
});
|
|
2942
|
+
setListboxProps(newListboxProps);
|
|
2943
|
+
|
|
2944
|
+
if (!dropdown.isMultiSelect) {
|
|
2945
|
+
const newListItems = dropdown.options.map(o => {
|
|
2946
|
+
var _a;
|
|
2947
|
+
|
|
2948
|
+
return Object.assign(Object.assign({}, o.attributes), {
|
|
2949
|
+
className: (_a = o.classes) === null || _a === void 0 ? void 0 : _a.join(' '),
|
|
2950
|
+
children: o[dropdown.display],
|
|
2951
|
+
selected: o.selected,
|
|
2952
|
+
onClick: () => handler === null || handler === void 0 ? void 0 : handler.select(o)
|
|
2953
|
+
});
|
|
2954
|
+
});
|
|
2955
|
+
setListItems(newListItems);
|
|
2956
|
+
} else {
|
|
2957
|
+
const checkboxes = dropdown.options.map(o => ({
|
|
2958
|
+
labelProps: Object.assign(Object.assign({}, o.attributes), {
|
|
2959
|
+
className: ['form-control', ...o.classes].join(' ')
|
|
2960
|
+
}),
|
|
2961
|
+
inputProps: {
|
|
2962
|
+
defaultChecked: o.selected,
|
|
2963
|
+
type: 'checkbox',
|
|
2964
|
+
onClick: () => handler === null || handler === void 0 ? void 0 : handler.select(o, false)
|
|
2965
|
+
},
|
|
2966
|
+
spanProps: {
|
|
2967
|
+
children: o[dropdown.display]
|
|
2968
|
+
}
|
|
2969
|
+
}));
|
|
2970
|
+
const newMultiselect = {
|
|
2971
|
+
fieldsetProps: {
|
|
2972
|
+
'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,
|
|
2973
|
+
'aria-multiselectable': true,
|
|
2974
|
+
role: 'listbox',
|
|
2975
|
+
tabIndex: -1
|
|
2976
|
+
},
|
|
2977
|
+
legendProps: {
|
|
2978
|
+
className: 'sr-only',
|
|
2979
|
+
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,
|
|
2980
|
+
children: dropdown.texts.optionsDescription
|
|
2981
|
+
},
|
|
2982
|
+
checkboxes
|
|
2983
|
+
};
|
|
2984
|
+
setMultiSelectProps(newMultiselect);
|
|
2985
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2986
|
+
|
|
2987
|
+
}, [dropdown]); // When dropdown properties change
|
|
2988
|
+
|
|
2989
|
+
useEffect(() => {
|
|
2990
|
+
if (!dropdown) return;
|
|
2991
|
+
handler === null || handler === void 0 ? void 0 : handler.update({
|
|
2992
|
+
id,
|
|
2993
|
+
value,
|
|
2994
|
+
texts,
|
|
2995
|
+
options,
|
|
2996
|
+
loop,
|
|
2997
|
+
multiSelect,
|
|
2998
|
+
searchable,
|
|
2999
|
+
searchFilter,
|
|
3000
|
+
compareWith,
|
|
3001
|
+
useValue,
|
|
3002
|
+
display,
|
|
3003
|
+
validator
|
|
3004
|
+
}); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3005
|
+
}, [id, texts, options, loop, multiSelect, searchable, searchFilter, compareWith, useValue, display]);
|
|
3006
|
+
useEffect(() => {
|
|
3007
|
+
if (!dropdown) return;
|
|
3008
|
+
handler === null || handler === void 0 ? void 0 : handler.selectByValue(value);
|
|
3009
|
+
console.log('new value'); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3010
|
+
}, [value]); // When validator changes
|
|
3011
|
+
|
|
3012
|
+
useEffect(() => {
|
|
3013
|
+
if (!dropdown) return;
|
|
3014
|
+
if (validator) handler === null || handler === void 0 ? void 0 : handler.validate(validator); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3015
|
+
}, [validator]); // Create dropdown handler
|
|
3016
|
+
|
|
3017
|
+
useEffect(() => {
|
|
3018
|
+
if (!handler && togglerRef.current && listboxRef.current) {
|
|
3019
|
+
setHandler(createDropdown({
|
|
3020
|
+
id,
|
|
3021
|
+
value,
|
|
3022
|
+
texts,
|
|
3023
|
+
options,
|
|
3024
|
+
loop,
|
|
3025
|
+
multiSelect,
|
|
3026
|
+
searchable,
|
|
3027
|
+
searchFilter,
|
|
3028
|
+
compareWith,
|
|
3029
|
+
useValue,
|
|
3030
|
+
display,
|
|
3031
|
+
validator
|
|
3032
|
+
}, togglerRef.current, listboxRef.current, listboxRef.current, dd => setDropdown(dd), value => onChange === null || onChange === void 0 ? void 0 : onChange(value)));
|
|
3033
|
+
}
|
|
3034
|
+
|
|
3035
|
+
return () => handler === null || handler === void 0 ? void 0 : handler.destroy(); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3036
|
+
}, [togglerRef, listboxRef]);
|
|
3037
|
+
return {
|
|
3038
|
+
dropdown: handler,
|
|
3039
|
+
togglerProps,
|
|
3040
|
+
listboxProps,
|
|
3041
|
+
listItems,
|
|
3042
|
+
multiSelectProps
|
|
3043
|
+
};
|
|
3044
|
+
};
|
|
3045
|
+
|
|
3046
|
+
const Dropdown = ({
|
|
3047
|
+
compareWith,
|
|
3048
|
+
display,
|
|
3049
|
+
id,
|
|
3050
|
+
informationLabel,
|
|
3051
|
+
label,
|
|
3052
|
+
loop,
|
|
3053
|
+
multiSelect,
|
|
3054
|
+
onChange,
|
|
3055
|
+
options,
|
|
3056
|
+
searchFilter,
|
|
3057
|
+
searchable,
|
|
3058
|
+
texts,
|
|
3059
|
+
useValue,
|
|
3060
|
+
validator,
|
|
3061
|
+
value
|
|
3062
|
+
}) => {
|
|
3063
|
+
var _a;
|
|
3064
|
+
|
|
3065
|
+
const togglerRef = useRef(null);
|
|
3066
|
+
const listboxRef = useRef(null);
|
|
3067
|
+
const {
|
|
3068
|
+
dropdown,
|
|
3069
|
+
listboxProps,
|
|
3070
|
+
togglerProps,
|
|
3071
|
+
listItems,
|
|
3072
|
+
multiSelectProps
|
|
3073
|
+
} = useDropdown({
|
|
3074
|
+
id,
|
|
3075
|
+
value,
|
|
3076
|
+
options,
|
|
3077
|
+
loop,
|
|
3078
|
+
multiSelect,
|
|
3079
|
+
searchable,
|
|
3080
|
+
searchFilter,
|
|
3081
|
+
compareWith,
|
|
3082
|
+
useValue,
|
|
3083
|
+
display,
|
|
3084
|
+
togglerRef,
|
|
3085
|
+
listboxRef,
|
|
3086
|
+
texts,
|
|
3087
|
+
onChange,
|
|
3088
|
+
validator
|
|
3089
|
+
});
|
|
3090
|
+
|
|
3091
|
+
const getListBoxProps = props => {
|
|
3092
|
+
var _a, _b, _c;
|
|
3093
|
+
|
|
3094
|
+
if (Object.keys(props).length === 0) return {
|
|
3095
|
+
role: 'listbox',
|
|
3096
|
+
tabIndex: -1,
|
|
3097
|
+
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(' ')
|
|
3098
|
+
};
|
|
3099
|
+
return props;
|
|
3100
|
+
};
|
|
3101
|
+
|
|
3102
|
+
return jsxs("div", Object.assign({
|
|
3103
|
+
className: "form-group"
|
|
3104
|
+
}, {
|
|
3105
|
+
children: [label && jsx("label", Object.assign({
|
|
3106
|
+
htmlFor: togglerProps.id
|
|
3107
|
+
}, {
|
|
3108
|
+
children: label
|
|
3109
|
+
})), informationLabel && jsx("div", Object.assign({
|
|
3110
|
+
className: "form-info"
|
|
3111
|
+
}, {
|
|
3112
|
+
children: informationLabel
|
|
3113
|
+
})), jsx("button", Object.assign({
|
|
3114
|
+
type: "button"
|
|
3115
|
+
}, togglerProps, {
|
|
3116
|
+
ref: togglerRef
|
|
3117
|
+
}, {
|
|
3118
|
+
children: jsx("span", {
|
|
3119
|
+
children: togglerProps.children
|
|
3120
|
+
})
|
|
3121
|
+
})), jsxs("div", Object.assign({}, getListBoxProps(listboxProps), {
|
|
3122
|
+
ref: listboxRef
|
|
3123
|
+
}, {
|
|
3124
|
+
children: [jsxs("button", Object.assign({
|
|
3125
|
+
type: "button",
|
|
3126
|
+
className: "close m-4 m-sm-2 d-block d-sm-none",
|
|
3127
|
+
onClick: dropdown === null || dropdown === void 0 ? void 0 : dropdown.close
|
|
3128
|
+
}, {
|
|
3129
|
+
children: [jsx("span", Object.assign({
|
|
3130
|
+
className: "sr-only"
|
|
3131
|
+
}, {
|
|
3132
|
+
children: dropdown === null || dropdown === void 0 ? void 0 : dropdown.dropdown.texts.close
|
|
3133
|
+
})), jsx("i", {})]
|
|
3134
|
+
})), (dropdown === null || dropdown === void 0 ? void 0 : dropdown.dropdown.isMultiSelect) ? jsx("div", Object.assign({
|
|
3135
|
+
className: "sg-fieldset-container"
|
|
3136
|
+
}, {
|
|
3137
|
+
children: jsxs("fieldset", Object.assign({}, multiSelectProps.fieldsetProps, {
|
|
3138
|
+
children: [jsx("legend", Object.assign({}, multiSelectProps.legendProps)), jsx("div", {
|
|
3139
|
+
children: (_a = multiSelectProps.checkboxes) === null || _a === void 0 ? void 0 : _a.map(checkboxItem => jsxs("label", Object.assign({}, checkboxItem.labelProps, {
|
|
3140
|
+
children: [jsx("input", Object.assign({}, checkboxItem.inputProps)), jsx("span", Object.assign({}, checkboxItem.spanProps)), jsx("i", {})]
|
|
3141
|
+
}), checkboxItem.labelProps.id))
|
|
3142
|
+
})]
|
|
3143
|
+
}))
|
|
3144
|
+
})) : jsx("ul", Object.assign({
|
|
3145
|
+
role: "listbox"
|
|
3146
|
+
}, {
|
|
3147
|
+
children: listItems.map(liProps => jsx("li", Object.assign({}, liProps), liProps.id))
|
|
3148
|
+
}))]
|
|
3149
|
+
})), validator && jsx("span", Object.assign({
|
|
3150
|
+
className: "form-info"
|
|
3151
|
+
}, {
|
|
3152
|
+
children: validator === null || validator === void 0 ? void 0 : validator.message
|
|
3153
|
+
}))]
|
|
3154
|
+
}));
|
|
3155
|
+
};
|
|
3156
|
+
|
|
3157
|
+
const useDatepicker = (datepickerRef, datepickerDialogRef, dateInputRef, datepickerTriggerRef, options = {}) => {
|
|
3158
|
+
const dataStub = {
|
|
3159
|
+
formattedSelectedDate: '',
|
|
3160
|
+
calendar: {
|
|
3161
|
+
headers: [],
|
|
3162
|
+
calendarGrid: []
|
|
3163
|
+
}
|
|
3164
|
+
};
|
|
3165
|
+
const [data, setData] = useState(dataStub);
|
|
3166
|
+
const [state, setState] = useState({
|
|
3167
|
+
isActive: false
|
|
3168
|
+
});
|
|
3169
|
+
const datepickerStub = {};
|
|
3170
|
+
const [datepicker, setDatepicker] = useState(datepickerStub);
|
|
3171
|
+
useEffect(() => {
|
|
3172
|
+
if (!datepicker.open && datepickerRef.current && datepickerDialogRef.current && dateInputRef.current && datepickerTriggerRef.current) {
|
|
3173
|
+
setDatepicker(createDatepicker((data, state) => {
|
|
3174
|
+
if (data) setData(data);
|
|
3175
|
+
if (state) setState(state);
|
|
3176
|
+
}, options, datepickerRef.current, datepickerDialogRef.current, dateInputRef.current, datepickerTriggerRef.current));
|
|
3177
|
+
}
|
|
3178
|
+
}, [datepicker, datepickerRef, datepickerDialogRef, dateInputRef, datepickerTriggerRef, options]);
|
|
3179
|
+
return {
|
|
3180
|
+
datepicker,
|
|
3181
|
+
data,
|
|
3182
|
+
state
|
|
3183
|
+
};
|
|
3184
|
+
};
|
|
3185
|
+
|
|
3186
|
+
const Datepicker = (options = {}) => {
|
|
3187
|
+
const [uuid] = useState(randomId());
|
|
3188
|
+
const id = `sgr-datepicker-${uuid}`;
|
|
3189
|
+
const datepickerRef = useRef(null);
|
|
3190
|
+
const datepickerTriggerRef = useRef(null);
|
|
3191
|
+
const datepickerDialogRef = useRef(null);
|
|
3192
|
+
const dateInputRef = useRef(null);
|
|
3193
|
+
const {
|
|
3194
|
+
datepicker,
|
|
3195
|
+
data,
|
|
3196
|
+
state
|
|
3197
|
+
} = useDatepicker(datepickerRef, datepickerDialogRef, dateInputRef, datepickerTriggerRef, options);
|
|
3198
|
+
useEffect(() => {
|
|
3199
|
+
var _a;
|
|
3200
|
+
|
|
3201
|
+
const selDateSub = (_a = datepicker.selectedDate$) === null || _a === void 0 ? void 0 : _a.subscribe(newDate => options.onChange && options.onChange(newDate));
|
|
3202
|
+
return () => selDateSub === null || selDateSub === void 0 ? void 0 : selDateSub.unsubscribe();
|
|
3203
|
+
}, [datepicker, options]);
|
|
3204
|
+
|
|
3205
|
+
const classNames = day => Object.entries({
|
|
3206
|
+
disabled: !day.currentMonth,
|
|
3207
|
+
'sg-date-today': day.today // 'sg-date-holiday': day.holiday,
|
|
3208
|
+
|
|
3209
|
+
}).map(([className, add]) => add ? className : '').join(' ');
|
|
3210
|
+
|
|
3211
|
+
return jsxs(Fragment, {
|
|
3212
|
+
children: [jsxs("div", Object.assign({
|
|
3213
|
+
className: "form-group"
|
|
3214
|
+
}, {
|
|
3215
|
+
children: [jsx("label", Object.assign({
|
|
3216
|
+
htmlFor: id
|
|
3217
|
+
}, {
|
|
3218
|
+
children: "Date"
|
|
3219
|
+
})), jsxs("div", Object.assign({
|
|
3220
|
+
className: "group",
|
|
3221
|
+
ref: datepickerRef
|
|
3222
|
+
}, {
|
|
3223
|
+
children: [jsx("input", {
|
|
3224
|
+
ref: dateInputRef,
|
|
3225
|
+
id: id,
|
|
3226
|
+
type: "text",
|
|
3227
|
+
placeholder: "yyyy-mm-dd",
|
|
3228
|
+
value: data.formattedSelectedDate,
|
|
3229
|
+
onChange: e => datepicker.select(e.target.value)
|
|
3230
|
+
}), jsx("button", Object.assign({
|
|
3231
|
+
ref: datepickerTriggerRef,
|
|
3232
|
+
type: "button",
|
|
3233
|
+
className: "primary",
|
|
3234
|
+
onClick: () => datepicker.toggle()
|
|
3235
|
+
}, {
|
|
3236
|
+
children: jsx("i", Object.assign({
|
|
3237
|
+
className: "sg-icon sg-icon-calendar"
|
|
3238
|
+
}, {
|
|
3239
|
+
children: "Select date"
|
|
3240
|
+
}))
|
|
3241
|
+
}))]
|
|
3242
|
+
})), jsx("span", Object.assign({
|
|
3243
|
+
className: "form-info"
|
|
3244
|
+
}, {
|
|
3245
|
+
children: "Select a date"
|
|
3246
|
+
}))]
|
|
3247
|
+
})), jsx("div", Object.assign({
|
|
3248
|
+
ref: datepickerDialogRef,
|
|
3249
|
+
className: `popover popover-datepicker ${state.isActive ? 'active' : ''}`,
|
|
3250
|
+
role: "dialog",
|
|
3251
|
+
"aria-modal": "true",
|
|
3252
|
+
"aria-label": "Choose Date"
|
|
3253
|
+
}, {
|
|
3254
|
+
children: state.isActive && jsxs("div", Object.assign({
|
|
3255
|
+
className: "sg-date"
|
|
3256
|
+
}, {
|
|
3257
|
+
children: [jsxs("header", {
|
|
3258
|
+
children: [jsx("button", Object.assign({
|
|
3259
|
+
className: "link",
|
|
3260
|
+
onClick: () => datepicker.sub(1, 'months')
|
|
3261
|
+
}, {
|
|
3262
|
+
children: jsx("i", Object.assign({
|
|
3263
|
+
className: "sg-icon sg-icon-previous"
|
|
3264
|
+
}, {
|
|
3265
|
+
children: "Previous month"
|
|
3266
|
+
}))
|
|
3267
|
+
})), jsx(Dropdown, {
|
|
3268
|
+
options: months({}),
|
|
3269
|
+
texts: {
|
|
3270
|
+
placeholder: data.monthName
|
|
3271
|
+
}
|
|
3272
|
+
}), jsx(Dropdown, {
|
|
3273
|
+
options: years({}),
|
|
3274
|
+
texts: {
|
|
3275
|
+
placeholder: data.year + ''
|
|
3276
|
+
}
|
|
3277
|
+
}), jsx("button", Object.assign({
|
|
3278
|
+
className: "link",
|
|
3279
|
+
onClick: () => datepicker.add(1, 'months')
|
|
3280
|
+
}, {
|
|
3281
|
+
children: jsx("i", Object.assign({
|
|
3282
|
+
className: "sg-icon sg-icon-next"
|
|
3283
|
+
}, {
|
|
3284
|
+
children: "Next month"
|
|
3285
|
+
}))
|
|
3286
|
+
}))]
|
|
3287
|
+
}), jsx("main", {
|
|
3288
|
+
children: jsxs("table", Object.assign({
|
|
3289
|
+
role: "grid"
|
|
3290
|
+
}, {
|
|
3291
|
+
children: [jsx("thead", {
|
|
3292
|
+
children: jsx("tr", {
|
|
3293
|
+
children: data.calendar.headers.map((header, ix) => jsx("th", Object.assign({
|
|
3294
|
+
scope: "col",
|
|
3295
|
+
abbr: header.abbr,
|
|
3296
|
+
className: header.type === 'week' ? 'sg-week-header' : 'sg-day-header'
|
|
3297
|
+
}, {
|
|
3298
|
+
children: header.displayText
|
|
3299
|
+
}), `week_${ix}`))
|
|
3300
|
+
})
|
|
3301
|
+
}), jsx("tbody", {
|
|
3302
|
+
children: data.calendar.calendarGrid.map((week, ix) => jsxs("tr", {
|
|
3303
|
+
children: [data.calendar.weekNumbers ? jsx("th", Object.assign({
|
|
3304
|
+
className: "sg-week-number"
|
|
3305
|
+
}, {
|
|
3306
|
+
children: data.calendar.weekNumbers[ix]
|
|
3307
|
+
})) : '', week.map(day => jsx("td", Object.assign({
|
|
3308
|
+
"data-date": day.formattedDate,
|
|
3309
|
+
className: classNames(day),
|
|
3310
|
+
title: day.today ? 'Today' : '',
|
|
3311
|
+
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,
|
|
3312
|
+
role: day.selected ? 'gridcell' : undefined,
|
|
3313
|
+
"aria-selected": day.selected && !(data === null || data === void 0 ? void 0 : data.highlightedDate) ? true : undefined,
|
|
3314
|
+
onClick: () => {
|
|
3315
|
+
day.currentMonth && datepicker.select(day.date);
|
|
3316
|
+
}
|
|
3317
|
+
}, {
|
|
3318
|
+
children: day.day
|
|
3319
|
+
}), day.day))]
|
|
3320
|
+
}, `week_${ix}`))
|
|
3321
|
+
})]
|
|
3322
|
+
}))
|
|
3323
|
+
})]
|
|
3324
|
+
}))
|
|
3325
|
+
}))]
|
|
3326
|
+
});
|
|
3327
|
+
};
|
|
3328
|
+
|
|
3329
|
+
export { AlertRibbon as Alert, AlertRibbon, Badge, Button, ButtonGroup, Card, Checkbox, Datepicker, Dropdown, EmailInput, Flexbox, Form, FormItems, Group, Link, List, Modal, Navbar, NumberInput, Option, OptionGroup, RadioButton, RadioGroup, RenderInput, Select, Stepper, Text, TextInput };
|