@entur/form 5.4.11 → 5.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +828 -0
- package/dist/form.cjs.development.js +274 -196
- package/dist/form.cjs.development.js.map +1 -1
- package/dist/form.cjs.production.min.js.map +1 -1
- package/dist/form.esm.js +274 -196
- package/dist/form.esm.js.map +1 -1
- package/dist/styles.css +251 -231
- package/package.json +11 -18
package/dist/form.esm.js
CHANGED
|
@@ -11,59 +11,73 @@ function _extends() {
|
|
|
11
11
|
_extends = Object.assign || function (target) {
|
|
12
12
|
for (var i = 1; i < arguments.length; i++) {
|
|
13
13
|
var source = arguments[i];
|
|
14
|
+
|
|
14
15
|
for (var key in source) {
|
|
15
16
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
16
17
|
target[key] = source[key];
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
}
|
|
21
|
+
|
|
20
22
|
return target;
|
|
21
23
|
};
|
|
24
|
+
|
|
22
25
|
return _extends.apply(this, arguments);
|
|
23
26
|
}
|
|
27
|
+
|
|
24
28
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
25
29
|
if (source == null) return {};
|
|
26
30
|
var target = {};
|
|
27
31
|
var sourceKeys = Object.keys(source);
|
|
28
32
|
var key, i;
|
|
33
|
+
|
|
29
34
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
30
35
|
key = sourceKeys[i];
|
|
31
36
|
if (excluded.indexOf(key) >= 0) continue;
|
|
32
37
|
target[key] = source[key];
|
|
33
38
|
}
|
|
39
|
+
|
|
34
40
|
return target;
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
var _excluded$f = ["children", "hideIcon", "variant", "className"];
|
|
44
|
+
|
|
38
45
|
var AlertIcon = function AlertIcon(_ref) {
|
|
39
46
|
var variant = _ref.variant;
|
|
40
47
|
var iconClass = "eds-feedback-text__icon eds-feedback-text__icon--" + variant;
|
|
48
|
+
|
|
41
49
|
switch (variant) {
|
|
42
50
|
case 'success':
|
|
43
51
|
return React__default.createElement(ValidationCheckIcon, {
|
|
44
52
|
className: iconClass
|
|
45
53
|
});
|
|
54
|
+
|
|
46
55
|
case 'error':
|
|
47
56
|
return React__default.createElement(ValidationErrorIcon, {
|
|
48
57
|
className: iconClass
|
|
49
58
|
});
|
|
59
|
+
|
|
50
60
|
case 'info':
|
|
51
61
|
return null;
|
|
62
|
+
|
|
52
63
|
case 'warning':
|
|
53
64
|
return React__default.createElement(ValidationExclamationIcon, {
|
|
54
65
|
className: iconClass
|
|
55
66
|
});
|
|
67
|
+
|
|
56
68
|
default:
|
|
57
69
|
return null;
|
|
58
70
|
}
|
|
59
71
|
};
|
|
72
|
+
|
|
60
73
|
var FeedbackText = function FeedbackText(_ref2) {
|
|
61
74
|
var children = _ref2.children,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
75
|
+
_ref2$hideIcon = _ref2.hideIcon,
|
|
76
|
+
hideIcon = _ref2$hideIcon === void 0 ? false : _ref2$hideIcon,
|
|
77
|
+
variant = _ref2.variant,
|
|
78
|
+
className = _ref2.className,
|
|
79
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded$f);
|
|
80
|
+
|
|
67
81
|
return React__default.createElement(SubLabel, _extends({
|
|
68
82
|
className: classNames('eds-feedback-text', {
|
|
69
83
|
'eds-feedback-text--info': variant === 'info'
|
|
@@ -83,9 +97,11 @@ var InputGroupContext = /*#__PURE__*/React.createContext({
|
|
|
83
97
|
});
|
|
84
98
|
var InputGroupContextProvider = function InputGroupContextProvider(_ref) {
|
|
85
99
|
var children = _ref.children;
|
|
100
|
+
|
|
86
101
|
var _React$useState = React.useState(false),
|
|
87
|
-
|
|
88
|
-
|
|
102
|
+
filled = _React$useState[0],
|
|
103
|
+
setFilled = _React$useState[1];
|
|
104
|
+
|
|
89
105
|
return React.createElement(InputGroupContext.Provider, {
|
|
90
106
|
value: {
|
|
91
107
|
isFilled: filled,
|
|
@@ -100,13 +116,15 @@ var useInputGroupContext = function useInputGroupContext() {
|
|
|
100
116
|
var _excluded$e = ["label", "required", "labelId", "staticAnimation"];
|
|
101
117
|
var InputGroupLabel = function InputGroupLabel(_ref) {
|
|
102
118
|
var label = _ref.label,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
119
|
+
required = _ref.required,
|
|
120
|
+
labelId = _ref.labelId,
|
|
121
|
+
_ref$staticAnimation = _ref.staticAnimation,
|
|
122
|
+
staticAnimation = _ref$staticAnimation === void 0 ? false : _ref$staticAnimation,
|
|
123
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$e);
|
|
124
|
+
|
|
108
125
|
var _useInputGroupContext = useInputGroupContext(),
|
|
109
|
-
|
|
126
|
+
isFilled = _useInputGroupContext.isFilled;
|
|
127
|
+
|
|
110
128
|
var filler = staticAnimation || isFilled;
|
|
111
129
|
return React__default.createElement("label", _extends({
|
|
112
130
|
className: classNames(rest.className, {
|
|
@@ -123,8 +141,8 @@ var InputGroupLabel = function InputGroupLabel(_ref) {
|
|
|
123
141
|
var VariantContext = /*#__PURE__*/React__default.createContext(null);
|
|
124
142
|
var VariantProvider = function VariantProvider(_ref) {
|
|
125
143
|
var children = _ref.children,
|
|
126
|
-
|
|
127
|
-
|
|
144
|
+
_ref$variant = _ref.variant,
|
|
145
|
+
variant = _ref$variant === void 0 ? null : _ref$variant;
|
|
128
146
|
return React__default.createElement(VariantContext.Provider, {
|
|
129
147
|
value: variant
|
|
130
148
|
}, children);
|
|
@@ -137,31 +155,32 @@ var useVariant = function useVariant() {
|
|
|
137
155
|
var _excluded$d = ["children", "className", "dark", "disabled", "readOnly", "variant", "prepend", "append", "size", "isFilled", "label", "required", "labelTooltip", "feedback", "labelId", "labelProps", "style", "disableLabelAnimation", "ariaAlertOnFeedback"];
|
|
138
156
|
var BaseFormControl = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
139
157
|
var children = _ref.children,
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
158
|
+
className = _ref.className,
|
|
159
|
+
_ref$dark = _ref.dark,
|
|
160
|
+
dark = _ref$dark === void 0 ? false : _ref$dark,
|
|
161
|
+
_ref$disabled = _ref.disabled,
|
|
162
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
163
|
+
_ref$readOnly = _ref.readOnly,
|
|
164
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
165
|
+
variant = _ref.variant,
|
|
166
|
+
prepend = _ref.prepend,
|
|
167
|
+
append = _ref.append,
|
|
168
|
+
_ref$size = _ref.size,
|
|
169
|
+
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
170
|
+
isFilled = _ref.isFilled,
|
|
171
|
+
label = _ref.label,
|
|
172
|
+
required = _ref.required,
|
|
173
|
+
labelTooltip = _ref.labelTooltip,
|
|
174
|
+
feedback = _ref.feedback,
|
|
175
|
+
labelId = _ref.labelId,
|
|
176
|
+
labelProps = _ref.labelProps,
|
|
177
|
+
style = _ref.style,
|
|
178
|
+
_ref$disableLabelAnim = _ref.disableLabelAnimation,
|
|
179
|
+
disableLabelAnimation = _ref$disableLabelAnim === void 0 ? false : _ref$disableLabelAnim,
|
|
180
|
+
_ref$ariaAlertOnFeedb = _ref.ariaAlertOnFeedback,
|
|
181
|
+
ariaAlertOnFeedback = _ref$ariaAlertOnFeedb === void 0 ? false : _ref$ariaAlertOnFeedb,
|
|
182
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$d);
|
|
183
|
+
|
|
165
184
|
var contextVariant = useVariant();
|
|
166
185
|
var currentVariant = variant || contextVariant;
|
|
167
186
|
return React__default.createElement(InputGroupContextProvider, null, React__default.createElement("div", _extends({
|
|
@@ -200,17 +219,18 @@ var BaseFormControl = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
|
200
219
|
var _excluded$c = ["checked", "className", "children", "style", "disabled", "reduceClickArea"];
|
|
201
220
|
var Checkbox = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
202
221
|
var checked = _ref.checked,
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
222
|
+
className = _ref.className,
|
|
223
|
+
children = _ref.children,
|
|
224
|
+
style = _ref.style,
|
|
225
|
+
_ref$disabled = _ref.disabled,
|
|
226
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
227
|
+
reduceClickArea = _ref.reduceClickArea,
|
|
228
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$c);
|
|
229
|
+
|
|
210
230
|
// Trick to allow using a ref locally, while still allowing for ref forwarding
|
|
211
231
|
// Read more at https://reactjs.org/docs/hooks-reference.html#useimperativehandle
|
|
212
|
-
var innerRef = React__default.useRef(null);
|
|
213
|
-
|
|
232
|
+
var innerRef = React__default.useRef(null); //eslint-disable-next-line
|
|
233
|
+
|
|
214
234
|
React__default.useImperativeHandle(ref, function () {
|
|
215
235
|
return innerRef.current;
|
|
216
236
|
});
|
|
@@ -245,9 +265,10 @@ var Checkbox = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
|
245
265
|
as: "span"
|
|
246
266
|
}, children));
|
|
247
267
|
});
|
|
268
|
+
|
|
248
269
|
var CheckboxIcon = function CheckboxIcon(_ref2) {
|
|
249
270
|
var _ref2$indeterminate = _ref2.indeterminate,
|
|
250
|
-
|
|
271
|
+
indeterminate = _ref2$indeterminate === void 0 ? false : _ref2$indeterminate;
|
|
251
272
|
return React__default.createElement("svg", {
|
|
252
273
|
className: "eds-checkbox-icon",
|
|
253
274
|
width: "11px",
|
|
@@ -269,9 +290,10 @@ var CheckboxIcon = function CheckboxIcon(_ref2) {
|
|
|
269
290
|
var _excluded$b = ["children", "className", "label"];
|
|
270
291
|
var Fieldset = function Fieldset(_ref) {
|
|
271
292
|
var children = _ref.children,
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
293
|
+
className = _ref.className,
|
|
294
|
+
label = _ref.label,
|
|
295
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$b);
|
|
296
|
+
|
|
275
297
|
return React__default.createElement("fieldset", _extends({
|
|
276
298
|
className: classNames('eds-fieldset', className)
|
|
277
299
|
}, rest), label && React__default.createElement(Label, {
|
|
@@ -284,26 +306,31 @@ var RadioGroupContext = /*#__PURE__*/React__default.createContext(null);
|
|
|
284
306
|
var RadioGroupContextProvider = RadioGroupContext.Provider;
|
|
285
307
|
var useRadioGroupContext = function useRadioGroupContext() {
|
|
286
308
|
var context = React__default.useContext(RadioGroupContext);
|
|
309
|
+
|
|
287
310
|
if (!context) {
|
|
288
311
|
throw new Error('You need to wrap your RadioButtons in a RadioGroup component');
|
|
289
312
|
}
|
|
313
|
+
|
|
290
314
|
return context;
|
|
291
315
|
};
|
|
292
316
|
|
|
293
317
|
var _excluded$a = ["className", "children", "value", "disabled"];
|
|
294
318
|
var Radio = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
295
319
|
var className = _ref.className,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
320
|
+
children = _ref.children,
|
|
321
|
+
value = _ref.value,
|
|
322
|
+
disabled = _ref.disabled,
|
|
323
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$a);
|
|
324
|
+
|
|
300
325
|
var classList = classNames(className, 'eds-form-component--radio__radio', {
|
|
301
326
|
'eds-form-component--radio__radio--disabled': disabled
|
|
302
327
|
});
|
|
328
|
+
|
|
303
329
|
var _useRadioGroupContext = useRadioGroupContext(),
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
330
|
+
name = _useRadioGroupContext.name,
|
|
331
|
+
selectedValue = _useRadioGroupContext.value,
|
|
332
|
+
onChange = _useRadioGroupContext.onChange;
|
|
333
|
+
|
|
307
334
|
return React__default.createElement("label", {
|
|
308
335
|
className: "eds-form-component--radio__container"
|
|
309
336
|
}, React__default.createElement("input", _extends({
|
|
@@ -328,11 +355,12 @@ var Radio = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
|
328
355
|
var _excluded$9 = ["name", "value", "children", "onChange", "label"];
|
|
329
356
|
var RadioGroup = function RadioGroup(_ref) {
|
|
330
357
|
var name = _ref.name,
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
358
|
+
value = _ref.value,
|
|
359
|
+
children = _ref.children,
|
|
360
|
+
onChange = _ref.onChange,
|
|
361
|
+
label = _ref.label,
|
|
362
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$9);
|
|
363
|
+
|
|
336
364
|
var contextValue = React__default.useMemo(function () {
|
|
337
365
|
return {
|
|
338
366
|
name: name,
|
|
@@ -350,26 +378,29 @@ var RadioGroup = function RadioGroup(_ref) {
|
|
|
350
378
|
var _excluded$8 = ["className", "children", "value", "title", "secondaryLabel", "size", "hideCheckbox", "style", "id", "disabled"];
|
|
351
379
|
var RadioPanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
352
380
|
var className = _ref.className,
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
381
|
+
children = _ref.children,
|
|
382
|
+
value = _ref.value,
|
|
383
|
+
title = _ref.title,
|
|
384
|
+
secondaryLabel = _ref.secondaryLabel,
|
|
385
|
+
_ref$size = _ref.size,
|
|
386
|
+
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
387
|
+
_ref$hideCheckbox = _ref.hideCheckbox,
|
|
388
|
+
hideCheckbox = _ref$hideCheckbox === void 0 ? false : _ref$hideCheckbox,
|
|
389
|
+
style = _ref.style,
|
|
390
|
+
id = _ref.id,
|
|
391
|
+
_ref$disabled = _ref.disabled,
|
|
392
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
393
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$8);
|
|
394
|
+
|
|
366
395
|
var classList = classNames(className, 'eds-radio-panel__container', "eds-radio-panel--" + size, {
|
|
367
396
|
'eds-radio-panel--disabled': disabled
|
|
368
397
|
});
|
|
398
|
+
|
|
369
399
|
var _useRadioGroupContext = useRadioGroupContext(),
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
400
|
+
name = _useRadioGroupContext.name,
|
|
401
|
+
selectedValue = _useRadioGroupContext.value,
|
|
402
|
+
onChange = _useRadioGroupContext.onChange;
|
|
403
|
+
|
|
373
404
|
var randomId = useRandomId('eds-radiopanel');
|
|
374
405
|
var radioPanelId = id || randomId;
|
|
375
406
|
return React__default.createElement("label", {
|
|
@@ -399,6 +430,7 @@ var RadioPanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
|
399
430
|
className: "eds-radio-panel__additional-content"
|
|
400
431
|
}, children)));
|
|
401
432
|
});
|
|
433
|
+
|
|
402
434
|
var RadioPanelCheck = function RadioPanelCheck() {
|
|
403
435
|
return React__default.createElement("svg", {
|
|
404
436
|
className: "eds-checkbox-icon",
|
|
@@ -415,23 +447,26 @@ var RadioPanelCheck = function RadioPanelCheck() {
|
|
|
415
447
|
var _excluded$7 = ["className", "children", "labelPlacement", "icon", "hideIcon", "color", "contrastColor", "size"];
|
|
416
448
|
var Switch = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
417
449
|
var className = _ref.className,
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
450
|
+
children = _ref.children,
|
|
451
|
+
_ref$labelPlacement = _ref.labelPlacement,
|
|
452
|
+
labelPlacement = _ref$labelPlacement === void 0 ? 'right' : _ref$labelPlacement,
|
|
453
|
+
icon = _ref.icon,
|
|
454
|
+
_ref$hideIcon = _ref.hideIcon,
|
|
455
|
+
hideIcon = _ref$hideIcon === void 0 ? false : _ref$hideIcon,
|
|
456
|
+
_ref$color = _ref.color,
|
|
457
|
+
color = _ref$color === void 0 ? colors.validation.mintContrast : _ref$color,
|
|
458
|
+
contrastColor = _ref.contrastColor,
|
|
459
|
+
_ref$size = _ref.size,
|
|
460
|
+
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
461
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
462
|
+
|
|
430
463
|
var chosenContrastColor = contrastColor && contrastColor || color;
|
|
464
|
+
|
|
431
465
|
var displayedIcon = function displayedIcon() {
|
|
432
466
|
if (icon) return icon;
|
|
433
467
|
return rest.checked ? React__default.createElement(CheckIcon, null) : React__default.createElement(CloseSmallIcon, null);
|
|
434
468
|
};
|
|
469
|
+
|
|
435
470
|
return React__default.createElement("label", {
|
|
436
471
|
className: classNames('eds-switch', "eds-switch--" + labelPlacement, className),
|
|
437
472
|
style: _extends({}, rest.style)
|
|
@@ -454,16 +489,18 @@ var Switch = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
|
454
489
|
var _excluded$6 = ["className", "children", "labelPlacement", "transport", "size"];
|
|
455
490
|
var TravelSwitch = function TravelSwitch(_ref) {
|
|
456
491
|
var className = _ref.className,
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
492
|
+
children = _ref.children,
|
|
493
|
+
_ref$labelPlacement = _ref.labelPlacement,
|
|
494
|
+
labelPlacement = _ref$labelPlacement === void 0 ? 'right' : _ref$labelPlacement,
|
|
495
|
+
transport = _ref.transport,
|
|
496
|
+
size = _ref.size,
|
|
497
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
498
|
+
|
|
463
499
|
var _modeCalc = modeCalc(transport),
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
500
|
+
color = _modeCalc.color,
|
|
501
|
+
contrast = _modeCalc.contrast,
|
|
502
|
+
Icon = _modeCalc.Icon;
|
|
503
|
+
|
|
467
504
|
return React__default.createElement(Switch, _extends({
|
|
468
505
|
className: className,
|
|
469
506
|
labelPlacement: labelPlacement,
|
|
@@ -473,6 +510,7 @@ var TravelSwitch = function TravelSwitch(_ref) {
|
|
|
473
510
|
size: size
|
|
474
511
|
}, rest), children);
|
|
475
512
|
};
|
|
513
|
+
|
|
476
514
|
function modeCalc(mode) {
|
|
477
515
|
switch (mode) {
|
|
478
516
|
case 'bus':
|
|
@@ -481,60 +519,70 @@ function modeCalc(mode) {
|
|
|
481
519
|
color: colors.transport["default"].bus,
|
|
482
520
|
contrast: colors.transport.contrast.bus
|
|
483
521
|
};
|
|
522
|
+
|
|
484
523
|
case 'metro':
|
|
485
524
|
return {
|
|
486
525
|
Icon: SubwayIcon,
|
|
487
526
|
color: colors.transport["default"].metro,
|
|
488
527
|
contrast: colors.transport.contrast.metro
|
|
489
528
|
};
|
|
529
|
+
|
|
490
530
|
case 'air':
|
|
491
531
|
return {
|
|
492
532
|
Icon: PlaneIcon,
|
|
493
533
|
color: colors.transport["default"].plane,
|
|
494
534
|
contrast: colors.transport.contrast.plane
|
|
495
535
|
};
|
|
536
|
+
|
|
496
537
|
case 'tram':
|
|
497
538
|
return {
|
|
498
539
|
Icon: TramIcon,
|
|
499
540
|
color: colors.transport["default"].tram,
|
|
500
541
|
contrast: colors.transport.contrast.tram
|
|
501
542
|
};
|
|
543
|
+
|
|
502
544
|
case 'rail':
|
|
503
545
|
return {
|
|
504
546
|
Icon: TrainIcon,
|
|
505
547
|
color: colors.transport["default"].train,
|
|
506
548
|
contrast: colors.transport.contrast.train
|
|
507
549
|
};
|
|
550
|
+
|
|
508
551
|
case 'water':
|
|
509
552
|
return {
|
|
510
553
|
Icon: FerryIcon,
|
|
511
554
|
color: colors.transport["default"].ferry,
|
|
512
555
|
contrast: colors.transport.contrast.ferry
|
|
513
556
|
};
|
|
557
|
+
|
|
514
558
|
case 'bike':
|
|
515
559
|
return {
|
|
516
560
|
Icon: BicycleIcon,
|
|
517
561
|
color: colors.transport["default"].mobility,
|
|
518
562
|
contrast: colors.transport.contrast.mobility
|
|
519
563
|
};
|
|
564
|
+
|
|
520
565
|
case 'scooter':
|
|
521
566
|
return {
|
|
522
567
|
Icon: ScooterIcon,
|
|
523
568
|
color: colors.transport["default"].mobility,
|
|
524
569
|
contrast: colors.transport.contrast.mobility
|
|
525
570
|
};
|
|
571
|
+
|
|
526
572
|
case 'airportLinkBus':
|
|
527
573
|
return {
|
|
528
574
|
Icon: BusIcon,
|
|
529
575
|
color: colors.transport["default"].plane,
|
|
530
576
|
contrast: colors.transport.contrast.plane
|
|
531
577
|
};
|
|
578
|
+
|
|
532
579
|
case 'airportLinkRail':
|
|
533
580
|
return {
|
|
534
581
|
Icon: TrainIcon,
|
|
535
582
|
color: colors.transport["default"].plane,
|
|
536
583
|
contrast: colors.transport.contrast.plane
|
|
537
584
|
};
|
|
585
|
+
|
|
538
586
|
default:
|
|
539
587
|
throw Error('Please select a transport for the TravelSwitch.');
|
|
540
588
|
}
|
|
@@ -543,8 +591,7 @@ function modeCalc(mode) {
|
|
|
543
591
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -- disabled during Yarn upgrade
|
|
544
592
|
function hasValue(value) {
|
|
545
593
|
return value != null && !(Array.isArray(value) && value.length === 0);
|
|
546
|
-
}
|
|
547
|
-
// Determine if field is empty or filled.
|
|
594
|
+
} // Determine if field is empty or filled.
|
|
548
595
|
// Response determines if label is presented above field or as placeholder.
|
|
549
596
|
//
|
|
550
597
|
// @param obj
|
|
@@ -552,29 +599,32 @@ function hasValue(value) {
|
|
|
552
599
|
// @returns {boolean} False when not present or empty string.
|
|
553
600
|
// True when any number or string with length.
|
|
554
601
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -- disabled during Yarn upgrade
|
|
602
|
+
|
|
555
603
|
function isFilled(obj, SSR) {
|
|
556
604
|
if (SSR === void 0) {
|
|
557
605
|
SSR = false;
|
|
558
606
|
}
|
|
607
|
+
|
|
559
608
|
return obj && (hasValue(obj.value) && obj.value !== '' || SSR && hasValue(obj.defaultValue) && obj.defaultValue !== '');
|
|
560
609
|
}
|
|
561
610
|
|
|
562
611
|
var _excluded$5 = ["variant", "disabled", "readOnly", "className", "style", "label", "feedback", "labelTooltip", "onChange", "disableLabelAnimation"],
|
|
563
|
-
|
|
612
|
+
_excluded2$1 = ["readOnly", "disabled", "onChange", "value", "variant"];
|
|
564
613
|
var TextArea = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
565
614
|
var variant = _ref.variant,
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
615
|
+
_ref$disabled = _ref.disabled,
|
|
616
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
617
|
+
_ref$readOnly = _ref.readOnly,
|
|
618
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
619
|
+
className = _ref.className,
|
|
620
|
+
style = _ref.style,
|
|
621
|
+
label = _ref.label,
|
|
622
|
+
feedback = _ref.feedback,
|
|
623
|
+
labelTooltip = _ref.labelTooltip,
|
|
624
|
+
onChange = _ref.onChange,
|
|
625
|
+
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
626
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
627
|
+
|
|
578
628
|
var textAreaId = useRandomId('eds-textarea');
|
|
579
629
|
return React__default.createElement(BaseFormControl, {
|
|
580
630
|
className: className,
|
|
@@ -601,16 +651,19 @@ var TextArea = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
|
601
651
|
});
|
|
602
652
|
var TextAreaBase = /*#__PURE__*/React__default.forwardRef(function (_ref2, ref) {
|
|
603
653
|
var readOnly = _ref2.readOnly,
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
654
|
+
disabled = _ref2.disabled,
|
|
655
|
+
onChange = _ref2.onChange,
|
|
656
|
+
value = _ref2.value,
|
|
657
|
+
variant = _ref2.variant,
|
|
658
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded2$1);
|
|
659
|
+
|
|
609
660
|
var contextVariant = useVariant();
|
|
610
661
|
var currentVariant = variant || contextVariant;
|
|
662
|
+
|
|
611
663
|
var _useInputGroupContext = useInputGroupContext(),
|
|
612
|
-
|
|
613
|
-
|
|
664
|
+
isInputFilled = _useInputGroupContext.isFilled,
|
|
665
|
+
setFiller = _useInputGroupContext.setFilled;
|
|
666
|
+
|
|
614
667
|
useOnMount(function () {
|
|
615
668
|
if (value || rest.defaultValue) {
|
|
616
669
|
setFiller && !isInputFilled && setFiller(true);
|
|
@@ -621,16 +674,19 @@ var TextAreaBase = /*#__PURE__*/React__default.forwardRef(function (_ref2, ref)
|
|
|
621
674
|
setFiller(true);
|
|
622
675
|
}
|
|
623
676
|
}, [value, setFiller, isInputFilled]);
|
|
677
|
+
|
|
624
678
|
var handleChange = function handleChange(event) {
|
|
625
679
|
if (isFilled(event.target)) {
|
|
626
680
|
setFiller && !isInputFilled && setFiller(true);
|
|
627
681
|
} else {
|
|
628
682
|
setFiller && isInputFilled && setFiller(false);
|
|
629
683
|
}
|
|
684
|
+
|
|
630
685
|
if (onChange) {
|
|
631
686
|
onChange(event);
|
|
632
687
|
}
|
|
633
688
|
};
|
|
689
|
+
|
|
634
690
|
return React__default.createElement("textarea", _extends({
|
|
635
691
|
className: "eds-form-control eds-textarea",
|
|
636
692
|
ref: ref,
|
|
@@ -643,34 +699,35 @@ var TextAreaBase = /*#__PURE__*/React__default.forwardRef(function (_ref2, ref)
|
|
|
643
699
|
});
|
|
644
700
|
|
|
645
701
|
var _excluded$4 = ["prepend", "append", "variant", "disabled", "readOnly", "className", "style", "size", "label", "required", "labelTooltip", "feedback", "onChange", "disableLabelAnimation", "labelProps", "clearable", "onClear", "value", "ariaAlertOnFeedback"],
|
|
646
|
-
|
|
647
|
-
|
|
702
|
+
_excluded2 = ["disabled", "readOnly", "placeholder", "onChange", "value", "variant"],
|
|
703
|
+
_excluded3 = ["onClear"];
|
|
648
704
|
var TextField = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
649
705
|
var prepend = _ref.prepend,
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
706
|
+
append = _ref.append,
|
|
707
|
+
variant = _ref.variant,
|
|
708
|
+
_ref$disabled = _ref.disabled,
|
|
709
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
710
|
+
_ref$readOnly = _ref.readOnly,
|
|
711
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
712
|
+
className = _ref.className,
|
|
713
|
+
style = _ref.style,
|
|
714
|
+
_ref$size = _ref.size,
|
|
715
|
+
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
716
|
+
label = _ref.label,
|
|
717
|
+
required = _ref.required,
|
|
718
|
+
labelTooltip = _ref.labelTooltip,
|
|
719
|
+
feedback = _ref.feedback,
|
|
720
|
+
onChange = _ref.onChange,
|
|
721
|
+
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
722
|
+
labelProps = _ref.labelProps,
|
|
723
|
+
_ref$clearable = _ref.clearable,
|
|
724
|
+
clearable = _ref$clearable === void 0 ? false : _ref$clearable,
|
|
725
|
+
onClear = _ref.onClear,
|
|
726
|
+
value = _ref.value,
|
|
727
|
+
_ref$ariaAlertOnFeedb = _ref.ariaAlertOnFeedback,
|
|
728
|
+
ariaAlertOnFeedback = _ref$ariaAlertOnFeedb === void 0 ? false : _ref$ariaAlertOnFeedb,
|
|
729
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
730
|
+
|
|
674
731
|
var randomId = useRandomId('eds-textfield');
|
|
675
732
|
var textFieldId = labelProps && labelProps.id ? labelProps.id : randomId;
|
|
676
733
|
return React__default.createElement(BaseFormControl, {
|
|
@@ -704,17 +761,20 @@ var TextField = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
|
704
761
|
});
|
|
705
762
|
var TextFieldBase = /*#__PURE__*/React__default.forwardRef(function (_ref2, forwardRef) {
|
|
706
763
|
var disabled = _ref2.disabled,
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
764
|
+
readOnly = _ref2.readOnly,
|
|
765
|
+
placeholder = _ref2.placeholder,
|
|
766
|
+
onChange = _ref2.onChange,
|
|
767
|
+
value = _ref2.value,
|
|
768
|
+
variant = _ref2.variant,
|
|
769
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
770
|
+
|
|
713
771
|
var contextVariant = useVariant();
|
|
714
772
|
var currentVariant = variant || contextVariant;
|
|
773
|
+
|
|
715
774
|
var _useInputGroupContext = useInputGroupContext(),
|
|
716
|
-
|
|
717
|
-
|
|
775
|
+
isInputFilled = _useInputGroupContext.isFilled,
|
|
776
|
+
setFiller = _useInputGroupContext.setFilled;
|
|
777
|
+
|
|
718
778
|
useOnMount(function () {
|
|
719
779
|
if (value || rest.defaultValue) {
|
|
720
780
|
setFiller && !isInputFilled && setFiller(true);
|
|
@@ -725,16 +785,19 @@ var TextFieldBase = /*#__PURE__*/React__default.forwardRef(function (_ref2, forw
|
|
|
725
785
|
setFiller(true);
|
|
726
786
|
}
|
|
727
787
|
}, [value, setFiller, isInputFilled]);
|
|
788
|
+
|
|
728
789
|
var handleChange = function handleChange(event) {
|
|
729
790
|
if (isFilled(event.target)) {
|
|
730
791
|
setFiller && !isInputFilled && setFiller(true);
|
|
731
792
|
} else {
|
|
732
793
|
setFiller && isInputFilled && setFiller(false);
|
|
733
794
|
}
|
|
795
|
+
|
|
734
796
|
if (onChange) {
|
|
735
797
|
onChange(event);
|
|
736
798
|
}
|
|
737
799
|
};
|
|
800
|
+
|
|
738
801
|
return React__default.createElement("input", _extends({
|
|
739
802
|
"aria-invalid": currentVariant === 'error',
|
|
740
803
|
className: "eds-form-control",
|
|
@@ -746,12 +809,15 @@ var TextFieldBase = /*#__PURE__*/React__default.forwardRef(function (_ref2, forw
|
|
|
746
809
|
value: value
|
|
747
810
|
}, rest));
|
|
748
811
|
});
|
|
812
|
+
|
|
749
813
|
var ClearButton = function ClearButton(_ref3) {
|
|
750
814
|
var onClear = _ref3.onClear,
|
|
751
|
-
|
|
815
|
+
props = _objectWithoutPropertiesLoose(_ref3, _excluded3);
|
|
816
|
+
|
|
752
817
|
var _useInputGroupContext2 = useInputGroupContext(),
|
|
753
|
-
|
|
754
|
-
|
|
818
|
+
hasValue = _useInputGroupContext2.isFilled,
|
|
819
|
+
setFilled = _useInputGroupContext2.setFilled;
|
|
820
|
+
|
|
755
821
|
return React__default.createElement("div", {
|
|
756
822
|
className: "eds-textfield__clear-button-wrapper"
|
|
757
823
|
}, hasValue && React__default.createElement("div", {
|
|
@@ -771,14 +837,15 @@ var _excluded$3 = ["name", "onChange", "selectedValue", "multiple", "size"];
|
|
|
771
837
|
var SegmentedContext = /*#__PURE__*/React__default.createContext(null);
|
|
772
838
|
var SegmentedProvider = function SegmentedProvider(_ref) {
|
|
773
839
|
var name = _ref.name,
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
840
|
+
_ref$onChange = _ref.onChange,
|
|
841
|
+
onChange = _ref$onChange === void 0 ? function () {
|
|
842
|
+
return undefined;
|
|
843
|
+
} : _ref$onChange,
|
|
844
|
+
selectedValue = _ref.selectedValue,
|
|
845
|
+
multiple = _ref.multiple,
|
|
846
|
+
size = _ref.size,
|
|
847
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
848
|
+
|
|
782
849
|
var generatedName = useRandomId('eds-segmented-control');
|
|
783
850
|
var contextValue = React__default.useMemo(function () {
|
|
784
851
|
return {
|
|
@@ -795,40 +862,48 @@ var SegmentedProvider = function SegmentedProvider(_ref) {
|
|
|
795
862
|
};
|
|
796
863
|
var useSegmentedContext = function useSegmentedContext() {
|
|
797
864
|
var context = React__default.useContext(SegmentedContext);
|
|
865
|
+
|
|
798
866
|
if (!context) {
|
|
799
867
|
throw new Error('You need to wrap your SegmentedChoice in either SegmentedControl or MultipleSegmentedControl');
|
|
800
868
|
}
|
|
869
|
+
|
|
801
870
|
return context;
|
|
802
871
|
};
|
|
803
872
|
|
|
804
873
|
var _excluded$2 = ["children", "className", "style", "value", "name", "onChange"];
|
|
805
874
|
var SegmentedChoice = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
806
875
|
var children = _ref.children,
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
876
|
+
className = _ref.className,
|
|
877
|
+
style = _ref.style,
|
|
878
|
+
value = _ref.value,
|
|
879
|
+
name = _ref.name,
|
|
880
|
+
_ref$onChange = _ref.onChange,
|
|
881
|
+
onChange = _ref$onChange === void 0 ? function () {
|
|
882
|
+
return undefined;
|
|
883
|
+
} : _ref$onChange,
|
|
884
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
885
|
+
|
|
816
886
|
var _useSegmentedContext = useSegmentedContext(),
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
887
|
+
commonName = _useSegmentedContext.name,
|
|
888
|
+
selectedValue = _useSegmentedContext.selectedValue,
|
|
889
|
+
commonOnChange = _useSegmentedContext.onChange,
|
|
890
|
+
multiple = _useSegmentedContext.multiple,
|
|
891
|
+
size = _useSegmentedContext.size;
|
|
892
|
+
|
|
822
893
|
var isChecked = multiple ? selectedValue[value] : selectedValue === value;
|
|
894
|
+
|
|
823
895
|
var handleChange = function handleChange(e) {
|
|
824
896
|
onChange(e);
|
|
897
|
+
|
|
825
898
|
if (multiple) {
|
|
826
899
|
var _extends2;
|
|
900
|
+
|
|
827
901
|
commonOnChange(_extends({}, selectedValue, (_extends2 = {}, _extends2[value] = e.target.checked, _extends2)));
|
|
828
902
|
} else if (e.target.checked) {
|
|
829
903
|
commonOnChange(value);
|
|
830
904
|
}
|
|
831
905
|
};
|
|
906
|
+
|
|
832
907
|
return React__default.createElement("label", {
|
|
833
908
|
className: classNames('eds-segmented-choice', className, {
|
|
834
909
|
'eds-segmented-choide--large': size === 'large'
|
|
@@ -851,14 +926,15 @@ var SegmentedChoice = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
|
851
926
|
var _excluded$1 = ["children", "label", "name", "onChange", "selectedValue", "size", "className"];
|
|
852
927
|
var SegmentedControl = function SegmentedControl(_ref) {
|
|
853
928
|
var children = _ref.children,
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
929
|
+
label = _ref.label,
|
|
930
|
+
name = _ref.name,
|
|
931
|
+
onChange = _ref.onChange,
|
|
932
|
+
selectedValue = _ref.selectedValue,
|
|
933
|
+
_ref$size = _ref.size,
|
|
934
|
+
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
935
|
+
className = _ref.className,
|
|
936
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
937
|
+
|
|
862
938
|
return React__default.createElement(SegmentedProvider, {
|
|
863
939
|
name: name,
|
|
864
940
|
selectedValue: selectedValue,
|
|
@@ -876,13 +952,15 @@ var _excluded = ["children", "label", "name", "onChange", "selectedValue"];
|
|
|
876
952
|
/**This component is not used by anyone, and is therefore deprecated
|
|
877
953
|
* @deprecated
|
|
878
954
|
*/
|
|
955
|
+
|
|
879
956
|
var MultipleSegmentedControl = function MultipleSegmentedControl(_ref) {
|
|
880
957
|
var children = _ref.children,
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
958
|
+
label = _ref.label,
|
|
959
|
+
name = _ref.name,
|
|
960
|
+
onChange = _ref.onChange,
|
|
961
|
+
selectedValue = _ref.selectedValue,
|
|
962
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
963
|
+
|
|
886
964
|
return React__default.createElement(SegmentedProvider, {
|
|
887
965
|
name: name,
|
|
888
966
|
selectedValue: selectedValue,
|