@qualtrics/ui-react 0.27.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/README.md +19 -0
- package/dist/index.es.js +2635 -0
- package/dist/index.js +2679 -0
- package/package.json +97 -0
- package/postinstall.js +36 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2679 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
+
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var React__default = _interopDefault(React);
|
|
9
|
+
var PropTypes = _interopDefault(require('prop-types'));
|
|
10
|
+
var classNames = _interopDefault(require('classnames'));
|
|
11
|
+
var componentStyles = require('@qualtrics/component-styles');
|
|
12
|
+
var reactPopper = require('react-popper');
|
|
13
|
+
var ReactDOM = _interopDefault(require('react-dom'));
|
|
14
|
+
|
|
15
|
+
var version = "0.27.1";
|
|
16
|
+
|
|
17
|
+
function _defineProperty(obj, key, value) {
|
|
18
|
+
if (key in obj) {
|
|
19
|
+
Object.defineProperty(obj, key, {
|
|
20
|
+
value: value,
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true
|
|
24
|
+
});
|
|
25
|
+
} else {
|
|
26
|
+
obj[key] = value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return obj;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function _extends() {
|
|
33
|
+
_extends = Object.assign || function (target) {
|
|
34
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
35
|
+
var source = arguments[i];
|
|
36
|
+
|
|
37
|
+
for (var key in source) {
|
|
38
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
39
|
+
target[key] = source[key];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return target;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return _extends.apply(this, arguments);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function ownKeys(object, enumerableOnly) {
|
|
51
|
+
var keys = Object.keys(object);
|
|
52
|
+
|
|
53
|
+
if (Object.getOwnPropertySymbols) {
|
|
54
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
55
|
+
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
56
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
57
|
+
});
|
|
58
|
+
keys.push.apply(keys, symbols);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return keys;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function _objectSpread2(target) {
|
|
65
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
66
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
67
|
+
|
|
68
|
+
if (i % 2) {
|
|
69
|
+
ownKeys(source, true).forEach(function (key) {
|
|
70
|
+
_defineProperty(target, key, source[key]);
|
|
71
|
+
});
|
|
72
|
+
} else if (Object.getOwnPropertyDescriptors) {
|
|
73
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
74
|
+
} else {
|
|
75
|
+
ownKeys(source).forEach(function (key) {
|
|
76
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return target;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
85
|
+
if (source == null) return {};
|
|
86
|
+
var target = {};
|
|
87
|
+
var sourceKeys = Object.keys(source);
|
|
88
|
+
var key, i;
|
|
89
|
+
|
|
90
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
91
|
+
key = sourceKeys[i];
|
|
92
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
93
|
+
target[key] = source[key];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return target;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function _objectWithoutProperties(source, excluded) {
|
|
100
|
+
if (source == null) return {};
|
|
101
|
+
|
|
102
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
103
|
+
|
|
104
|
+
var key, i;
|
|
105
|
+
|
|
106
|
+
if (Object.getOwnPropertySymbols) {
|
|
107
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
108
|
+
|
|
109
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
110
|
+
key = sourceSymbolKeys[i];
|
|
111
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
112
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
113
|
+
target[key] = source[key];
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return target;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function _slicedToArray(arr, i) {
|
|
121
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function _toConsumableArray(arr) {
|
|
125
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function _arrayWithoutHoles(arr) {
|
|
129
|
+
if (Array.isArray(arr)) {
|
|
130
|
+
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
|
|
131
|
+
|
|
132
|
+
return arr2;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function _arrayWithHoles(arr) {
|
|
137
|
+
if (Array.isArray(arr)) return arr;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function _iterableToArray(iter) {
|
|
141
|
+
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function _iterableToArrayLimit(arr, i) {
|
|
145
|
+
var _arr = [];
|
|
146
|
+
var _n = true;
|
|
147
|
+
var _d = false;
|
|
148
|
+
var _e = undefined;
|
|
149
|
+
|
|
150
|
+
try {
|
|
151
|
+
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
152
|
+
_arr.push(_s.value);
|
|
153
|
+
|
|
154
|
+
if (i && _arr.length === i) break;
|
|
155
|
+
}
|
|
156
|
+
} catch (err) {
|
|
157
|
+
_d = true;
|
|
158
|
+
_e = err;
|
|
159
|
+
} finally {
|
|
160
|
+
try {
|
|
161
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
162
|
+
} finally {
|
|
163
|
+
if (_d) throw _e;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return _arr;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function _nonIterableSpread() {
|
|
171
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance");
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function _nonIterableRest() {
|
|
175
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
var UIContext = React__default.createContext(componentStyles.styles); // default to built-in styles
|
|
179
|
+
|
|
180
|
+
function useStyles(key) {
|
|
181
|
+
var styles = React.useContext(UIContext);
|
|
182
|
+
|
|
183
|
+
if (key) {
|
|
184
|
+
return styles[key];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return styles;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
var ButtonGroupContext = React__default.createContext({});
|
|
191
|
+
|
|
192
|
+
function useButtonGroupContext() {
|
|
193
|
+
return React.useContext(ButtonGroupContext);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
var ButtonGroupContextProvider = function ButtonGroupContextProvider(_ref) {
|
|
197
|
+
var value = _ref.value,
|
|
198
|
+
children = _ref.children;
|
|
199
|
+
return React__default.createElement(ButtonGroupContext.Provider, {
|
|
200
|
+
value: value
|
|
201
|
+
}, children);
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
ButtonGroupContextProvider.propTypes = {
|
|
205
|
+
value: PropTypes.object.isRequired,
|
|
206
|
+
children: PropTypes.any.isRequired
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
var buttonKinds = ['default', 'primary', 'secondary', 'tertiary', 'danger'];
|
|
210
|
+
var Button = React__default.forwardRef(function Button(props, ref) {
|
|
211
|
+
var _classNames;
|
|
212
|
+
|
|
213
|
+
var styles = useStyles('ButtonStyles');
|
|
214
|
+
|
|
215
|
+
var children = props.children,
|
|
216
|
+
kind = props.kind,
|
|
217
|
+
disabled = props.disabled,
|
|
218
|
+
small = props.small,
|
|
219
|
+
full = props.full,
|
|
220
|
+
className = props.className,
|
|
221
|
+
type = props.type,
|
|
222
|
+
onClick = props.onClick,
|
|
223
|
+
onKeyDown = props.onKeyDown,
|
|
224
|
+
other = _objectWithoutProperties(props, ["children", "kind", "disabled", "small", "full", "className", "type", "onClick", "onKeyDown"]);
|
|
225
|
+
|
|
226
|
+
var _useButtonGroupContex = useButtonGroupContext(),
|
|
227
|
+
isInsideButtonGroup = _useButtonGroupContex.isInsideButtonGroup,
|
|
228
|
+
groupFull = _useButtonGroupContex.full,
|
|
229
|
+
groupSmall = _useButtonGroupContex.small;
|
|
230
|
+
|
|
231
|
+
var classes = classNames(className, styles.btn, (_classNames = {}, _defineProperty(_classNames, styles[kind], kind), _defineProperty(_classNames, styles.disabled, disabled), _defineProperty(_classNames, styles.small, small || groupSmall), _defineProperty(_classNames, styles.full, full || groupFull), _defineProperty(_classNames, styles.group, isInsideButtonGroup), _classNames));
|
|
232
|
+
var clickHandler = disabled ? null : onClick;
|
|
233
|
+
var keyDownHandler = disabled ? null : onKeyDown;
|
|
234
|
+
return React__default.createElement("button", _extends({}, other, {
|
|
235
|
+
type: type,
|
|
236
|
+
className: classes,
|
|
237
|
+
ref: ref,
|
|
238
|
+
onClick: clickHandler,
|
|
239
|
+
onKeyDown: keyDownHandler
|
|
240
|
+
}), children);
|
|
241
|
+
});
|
|
242
|
+
Button.propTypes = {
|
|
243
|
+
children: PropTypes.node,
|
|
244
|
+
kind: PropTypes.oneOf(buttonKinds),
|
|
245
|
+
disabled: PropTypes.bool,
|
|
246
|
+
small: PropTypes.bool,
|
|
247
|
+
full: PropTypes.bool,
|
|
248
|
+
className: PropTypes.string,
|
|
249
|
+
type: PropTypes.oneOf(['button', 'submit', 'reset']),
|
|
250
|
+
onClick: PropTypes.func,
|
|
251
|
+
onKeyDown: PropTypes.func
|
|
252
|
+
};
|
|
253
|
+
Button.defaultProps = {
|
|
254
|
+
children: null,
|
|
255
|
+
kind: 'default',
|
|
256
|
+
disabled: false,
|
|
257
|
+
small: false,
|
|
258
|
+
full: false,
|
|
259
|
+
className: '',
|
|
260
|
+
type: 'button',
|
|
261
|
+
onClick: null,
|
|
262
|
+
onKeyDown: null
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
var IconTypes = componentStyles.styles.IconTypes;
|
|
266
|
+
var IconSizes = {
|
|
267
|
+
small: 16,
|
|
268
|
+
medium: 24,
|
|
269
|
+
large: 32
|
|
270
|
+
};
|
|
271
|
+
var Icon = React__default.forwardRef(function Icon(props, ref) {
|
|
272
|
+
var IconData = useStyles('IconData');
|
|
273
|
+
var className = props.className,
|
|
274
|
+
style = props.style,
|
|
275
|
+
type = props.type,
|
|
276
|
+
size = props.size,
|
|
277
|
+
onClick = props.onClick;
|
|
278
|
+
var svgContent = IconData[type];
|
|
279
|
+
var pixels = IconSizes[size];
|
|
280
|
+
return React__default.createElement("svg", {
|
|
281
|
+
ref: ref,
|
|
282
|
+
onClick: onClick,
|
|
283
|
+
className: className,
|
|
284
|
+
style: style,
|
|
285
|
+
width: pixels,
|
|
286
|
+
height: pixels,
|
|
287
|
+
focusable: "false",
|
|
288
|
+
viewBox: "0 0 24 24",
|
|
289
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
290
|
+
dangerouslySetInnerHTML: {
|
|
291
|
+
__html: svgContent
|
|
292
|
+
} // eslint-disable-line react/no-danger
|
|
293
|
+
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
Icon.propTypes = {
|
|
297
|
+
type: PropTypes.oneOf(Object.keys(IconTypes)).isRequired,
|
|
298
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
299
|
+
className: PropTypes.string,
|
|
300
|
+
style: PropTypes.object,
|
|
301
|
+
onClick: PropTypes.func
|
|
302
|
+
};
|
|
303
|
+
Icon.defaultProps = {
|
|
304
|
+
size: 'medium',
|
|
305
|
+
className: '',
|
|
306
|
+
style: {},
|
|
307
|
+
onClick: undefined
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
/* eslint-disable jsx-a11y/label-has-for */
|
|
311
|
+
var Label = React__default.forwardRef(function (props, ref) {
|
|
312
|
+
var styles = useStyles('LabelStyles');
|
|
313
|
+
var children = props.children,
|
|
314
|
+
className = props.className,
|
|
315
|
+
htmlFor = props.htmlFor,
|
|
316
|
+
style = props.style;
|
|
317
|
+
var classes = classNames(styles.label, className);
|
|
318
|
+
return React__default.createElement("label", {
|
|
319
|
+
htmlFor: htmlFor,
|
|
320
|
+
ref: ref,
|
|
321
|
+
className: classes,
|
|
322
|
+
style: style
|
|
323
|
+
}, React__default.Children.map(children, function (child) {
|
|
324
|
+
if (!React__default.isValidElement(child)) {
|
|
325
|
+
return child;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return React__default.cloneElement(child, {
|
|
329
|
+
className: classNames(child.props.className, styles.input)
|
|
330
|
+
});
|
|
331
|
+
}));
|
|
332
|
+
});
|
|
333
|
+
Label.propTypes = {
|
|
334
|
+
children: PropTypes.any,
|
|
335
|
+
className: PropTypes.string,
|
|
336
|
+
htmlFor: PropTypes.string,
|
|
337
|
+
style: PropTypes.object
|
|
338
|
+
};
|
|
339
|
+
Label.defaultProps = {
|
|
340
|
+
children: null,
|
|
341
|
+
className: null,
|
|
342
|
+
htmlFor: null,
|
|
343
|
+
style: {}
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
var Checkbox = React__default.forwardRef(function Checkbox(props, ref) {
|
|
347
|
+
var styles = useStyles('CheckboxStyles');
|
|
348
|
+
var id = props.id,
|
|
349
|
+
className = props.className,
|
|
350
|
+
checked = props.checked,
|
|
351
|
+
defaultChecked = props.defaultChecked,
|
|
352
|
+
onChange = props.onChange,
|
|
353
|
+
children = props.children,
|
|
354
|
+
testId = props.testId;
|
|
355
|
+
return React__default.createElement(Label, {
|
|
356
|
+
className: classNames(className, styles.label),
|
|
357
|
+
htmlFor: id
|
|
358
|
+
}, React__default.createElement("span", {
|
|
359
|
+
className: styles.checkbox
|
|
360
|
+
}, React__default.createElement("input", {
|
|
361
|
+
id: id,
|
|
362
|
+
ref: ref,
|
|
363
|
+
className: styles.input,
|
|
364
|
+
type: "checkbox",
|
|
365
|
+
checked: checked,
|
|
366
|
+
defaultChecked: defaultChecked,
|
|
367
|
+
onChange: onChange,
|
|
368
|
+
"data-testid": testId
|
|
369
|
+
}), React__default.createElement(Icon, {
|
|
370
|
+
className: styles.check,
|
|
371
|
+
type: IconTypes.Check,
|
|
372
|
+
size: "small"
|
|
373
|
+
})), children);
|
|
374
|
+
});
|
|
375
|
+
Checkbox.propTypes = {
|
|
376
|
+
id: PropTypes.string,
|
|
377
|
+
className: PropTypes.string,
|
|
378
|
+
checked: PropTypes.bool,
|
|
379
|
+
defaultChecked: PropTypes.bool,
|
|
380
|
+
onChange: PropTypes.func,
|
|
381
|
+
children: PropTypes.string.isRequired,
|
|
382
|
+
testId: PropTypes.string
|
|
383
|
+
};
|
|
384
|
+
Checkbox.defaultProps = {
|
|
385
|
+
id: undefined,
|
|
386
|
+
className: undefined,
|
|
387
|
+
checked: undefined,
|
|
388
|
+
defaultChecked: undefined,
|
|
389
|
+
onChange: undefined,
|
|
390
|
+
testId: undefined
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
var Switch = React__default.forwardRef(function Switch(props, ref) {
|
|
394
|
+
var styles = useStyles('SwitchStyles');
|
|
395
|
+
var id = props.id,
|
|
396
|
+
className = props.className,
|
|
397
|
+
checked = props.checked,
|
|
398
|
+
onChange = props.onChange,
|
|
399
|
+
children = props.children,
|
|
400
|
+
disabled = props.disabled,
|
|
401
|
+
value = props.value;
|
|
402
|
+
|
|
403
|
+
function handleChange(event) {
|
|
404
|
+
if (!disabled && onChange) {
|
|
405
|
+
onChange(event);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
var disabledClass = _defineProperty({}, styles.disabled, disabled);
|
|
410
|
+
|
|
411
|
+
return React__default.createElement("label", {
|
|
412
|
+
htmlFor: id,
|
|
413
|
+
className: classNames(className, styles["switch"], disabledClass)
|
|
414
|
+
}, React__default.createElement("input", {
|
|
415
|
+
id: id,
|
|
416
|
+
ref: ref,
|
|
417
|
+
className: styles.input,
|
|
418
|
+
type: "checkbox",
|
|
419
|
+
checked: checked,
|
|
420
|
+
onChange: handleChange,
|
|
421
|
+
disabled: disabled,
|
|
422
|
+
value: value
|
|
423
|
+
}), React__default.createElement("span", {
|
|
424
|
+
className: styles.slider
|
|
425
|
+
}), children ? React__default.createElement("span", {
|
|
426
|
+
className: styles.children
|
|
427
|
+
}, children) : null);
|
|
428
|
+
});
|
|
429
|
+
Switch.propTypes = {
|
|
430
|
+
id: PropTypes.string,
|
|
431
|
+
className: PropTypes.string,
|
|
432
|
+
checked: PropTypes.bool,
|
|
433
|
+
onChange: PropTypes.func,
|
|
434
|
+
children: PropTypes.string,
|
|
435
|
+
disabled: PropTypes.bool,
|
|
436
|
+
value: PropTypes.any
|
|
437
|
+
};
|
|
438
|
+
Switch.defaultProps = {
|
|
439
|
+
id: null,
|
|
440
|
+
className: '',
|
|
441
|
+
checked: false,
|
|
442
|
+
onChange: null,
|
|
443
|
+
children: '',
|
|
444
|
+
disabled: false,
|
|
445
|
+
value: ''
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
var CaptionTypes = ['error', 'helper'];
|
|
449
|
+
|
|
450
|
+
var Caption = function Caption(props) {
|
|
451
|
+
var styles = useStyles('CaptionStyles');
|
|
452
|
+
var children = props.children,
|
|
453
|
+
type = props.type,
|
|
454
|
+
className = props.className;
|
|
455
|
+
var classes = classNames(className, styles.caption, styles[type]);
|
|
456
|
+
return React__default.createElement("div", {
|
|
457
|
+
className: classes
|
|
458
|
+
}, children);
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
Caption.propTypes = {
|
|
462
|
+
children: PropTypes.any,
|
|
463
|
+
className: PropTypes.string,
|
|
464
|
+
type: PropTypes.oneOf(CaptionTypes)
|
|
465
|
+
};
|
|
466
|
+
Caption.defaultProps = {
|
|
467
|
+
children: null,
|
|
468
|
+
className: null,
|
|
469
|
+
type: 'helper'
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
var RadioGroupContext = React__default.createContext({});
|
|
473
|
+
|
|
474
|
+
function useRadioGroupContext() {
|
|
475
|
+
return React.useContext(RadioGroupContext);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
var RadioGroupContextProvider = function RadioGroupContextProvider(_ref) {
|
|
479
|
+
var value = _ref.value,
|
|
480
|
+
children = _ref.children;
|
|
481
|
+
return React__default.createElement(RadioGroupContext.Provider, {
|
|
482
|
+
value: value
|
|
483
|
+
}, children);
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
RadioGroupContextProvider.propTypes = {
|
|
487
|
+
value: PropTypes.object.isRequired,
|
|
488
|
+
children: PropTypes.any.isRequired
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
var Radio = React__default.forwardRef(function Radio(props, ref) {
|
|
492
|
+
var styles = useStyles('RadioStyles');
|
|
493
|
+
var id = props.id,
|
|
494
|
+
className = props.className,
|
|
495
|
+
children = props.children,
|
|
496
|
+
testId = props.testId,
|
|
497
|
+
value = props.value;
|
|
498
|
+
|
|
499
|
+
var _useRadioGroupContext = useRadioGroupContext(),
|
|
500
|
+
name = _useRadioGroupContext.name,
|
|
501
|
+
onChange = _useRadioGroupContext.onChange,
|
|
502
|
+
groupDefaultValue = _useRadioGroupContext.groupDefaultValue,
|
|
503
|
+
groupValue = _useRadioGroupContext.groupValue,
|
|
504
|
+
groupClasses = _useRadioGroupContext.groupClasses;
|
|
505
|
+
|
|
506
|
+
return React__default.createElement(Label, {
|
|
507
|
+
className: classNames(className, groupClasses, styles.label),
|
|
508
|
+
htmlFor: id
|
|
509
|
+
}, React__default.createElement("span", {
|
|
510
|
+
className: styles.radio
|
|
511
|
+
}, React__default.createElement("input", {
|
|
512
|
+
id: id,
|
|
513
|
+
ref: ref,
|
|
514
|
+
className: styles.input,
|
|
515
|
+
type: "radio",
|
|
516
|
+
checked: groupValue !== undefined ? value === groupValue : undefined,
|
|
517
|
+
defaultChecked: groupDefaultValue !== undefined ? value === groupDefaultValue : undefined,
|
|
518
|
+
name: name,
|
|
519
|
+
value: value,
|
|
520
|
+
onChange: onChange,
|
|
521
|
+
"data-testid": testId
|
|
522
|
+
}), React__default.createElement("span", {
|
|
523
|
+
className: styles.check
|
|
524
|
+
})), children);
|
|
525
|
+
});
|
|
526
|
+
Radio.propTypes = {
|
|
527
|
+
children: PropTypes.node.isRequired,
|
|
528
|
+
className: PropTypes.string,
|
|
529
|
+
id: PropTypes.string,
|
|
530
|
+
testId: PropTypes.string,
|
|
531
|
+
value: PropTypes.string.isRequired
|
|
532
|
+
};
|
|
533
|
+
Radio.defaultProps = {
|
|
534
|
+
className: undefined,
|
|
535
|
+
id: undefined,
|
|
536
|
+
testId: undefined
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Returns a type check error if all children of the prop are not of the given type.
|
|
541
|
+
* @param {type} type - A component type
|
|
542
|
+
* @param {string} typeName - The name of the component type
|
|
543
|
+
* @return {function} A type checker
|
|
544
|
+
*/
|
|
545
|
+
|
|
546
|
+
function allChildrenOfTypeChecker(type, typeName) {
|
|
547
|
+
return function (props, propName, componentName) {
|
|
548
|
+
var prop = props[propName];
|
|
549
|
+
var error = null;
|
|
550
|
+
React__default.Children.forEach(prop, function (child) {
|
|
551
|
+
if (child.type !== type) {
|
|
552
|
+
var childName = typeof child.type === 'function' ? child.type.name : child.type;
|
|
553
|
+
error = new Error("`".concat(componentName, "` only accepts children of type `").concat(typeName, "`, ") + "but found `".concat(childName, "`."));
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
return error;
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Chains type checkers by adding the isRequired property.
|
|
561
|
+
* @param {function} validate - A validation function to chain
|
|
562
|
+
* @return A chained type checker
|
|
563
|
+
*/
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
function createChainableTypeChecker(validate) {
|
|
567
|
+
function checkType(isRequired, props, propName, componentName, location, propFullName) {
|
|
568
|
+
var resolvedComponentName = componentName || '<<anonymous>>';
|
|
569
|
+
var resolvedPropFullName = propFullName || propName;
|
|
570
|
+
|
|
571
|
+
if (props[propName] == null) {
|
|
572
|
+
if (isRequired) {
|
|
573
|
+
return new Error("The ".concat(location, " `").concat(resolvedPropFullName, "` ") + "is marked as required in `".concat(resolvedComponentName, "`, ") + "but its value is `".concat(props[propName], "`."));
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
return null;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
return validate(props, propName, componentName, location, propFullName);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
var chainedCheckType = checkType.bind(null, false);
|
|
583
|
+
chainedCheckType.isRequired = checkType.bind(null, true);
|
|
584
|
+
return chainedCheckType;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
var RadioGroup = React__default.forwardRef(function RadioGroup(props, ref) {
|
|
588
|
+
var styles = useStyles('RadioGroupStyles');
|
|
589
|
+
var id = props.id,
|
|
590
|
+
className = props.className,
|
|
591
|
+
label = props.label,
|
|
592
|
+
name = props.name,
|
|
593
|
+
defaultValue = props.defaultValue,
|
|
594
|
+
value = props.value,
|
|
595
|
+
onChange = props.onChange,
|
|
596
|
+
children = props.children,
|
|
597
|
+
testId = props.testId;
|
|
598
|
+
var classes = classNames(className, styles.radioGroup);
|
|
599
|
+
return React__default.createElement(RadioGroupContextProvider, {
|
|
600
|
+
value: {
|
|
601
|
+
name: name,
|
|
602
|
+
onChange: onChange,
|
|
603
|
+
groupDefaultValue: defaultValue,
|
|
604
|
+
groupValue: value,
|
|
605
|
+
groupClasses: styles.option
|
|
606
|
+
}
|
|
607
|
+
}, React__default.createElement("fieldset", {
|
|
608
|
+
id: id,
|
|
609
|
+
ref: ref,
|
|
610
|
+
className: classes,
|
|
611
|
+
"data-testid": testId
|
|
612
|
+
}, React__default.createElement("legend", {
|
|
613
|
+
className: styles.legend
|
|
614
|
+
}, label), children));
|
|
615
|
+
});
|
|
616
|
+
var allOfTypeRadio = createChainableTypeChecker(allChildrenOfTypeChecker(Radio, 'Radio'));
|
|
617
|
+
RadioGroup.propTypes = {
|
|
618
|
+
id: PropTypes.string,
|
|
619
|
+
className: PropTypes.string,
|
|
620
|
+
defaultValue: PropTypes.string,
|
|
621
|
+
label: PropTypes.string,
|
|
622
|
+
name: PropTypes.string,
|
|
623
|
+
value: PropTypes.string,
|
|
624
|
+
onChange: PropTypes.func,
|
|
625
|
+
children: allOfTypeRadio.isRequired,
|
|
626
|
+
testId: PropTypes.string
|
|
627
|
+
};
|
|
628
|
+
RadioGroup.defaultProps = {
|
|
629
|
+
id: undefined,
|
|
630
|
+
className: undefined,
|
|
631
|
+
defaultValue: undefined,
|
|
632
|
+
label: undefined,
|
|
633
|
+
name: undefined,
|
|
634
|
+
value: undefined,
|
|
635
|
+
onChange: undefined,
|
|
636
|
+
testId: undefined
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
/* eslint-disable no-param-reassign */
|
|
640
|
+
var assignRef = function assignRef(ref, value) {
|
|
641
|
+
if (ref == null) return;
|
|
642
|
+
|
|
643
|
+
if (typeof ref === 'function') {
|
|
644
|
+
ref(value);
|
|
645
|
+
} else {
|
|
646
|
+
try {
|
|
647
|
+
ref.current = value;
|
|
648
|
+
} catch (error) {
|
|
649
|
+
throw new Error("Cannot assign value \"".concat(value, "\" to ref \"").concat(ref, "\""));
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
};
|
|
653
|
+
|
|
654
|
+
var FileDetails = function FileDetails(props) {
|
|
655
|
+
var styles = useStyles('FilePickerStyles');
|
|
656
|
+
var files = props.files;
|
|
657
|
+
|
|
658
|
+
if (files) {
|
|
659
|
+
return React__default.createElement("span", {
|
|
660
|
+
className: styles['file-details']
|
|
661
|
+
}, Array.prototype.map.call(files, function (file) {
|
|
662
|
+
return React__default.createElement("span", {
|
|
663
|
+
className: styles['file-name'],
|
|
664
|
+
key: file.name
|
|
665
|
+
}, file.name);
|
|
666
|
+
}));
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
return null;
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
FileDetails.defaultProps = {
|
|
673
|
+
files: null
|
|
674
|
+
};
|
|
675
|
+
FileDetails.propTypes = {
|
|
676
|
+
files: PropTypes.oneOfType([PropTypes.instanceOf(FileList), PropTypes.arrayOf(PropTypes.object)])
|
|
677
|
+
};
|
|
678
|
+
var FilePicker = React__default.forwardRef(function (props, _ref) {
|
|
679
|
+
var styles = useStyles('FilePickerStyles');
|
|
680
|
+
var accept = props.accept,
|
|
681
|
+
ariaLabel = props.ariaLabel,
|
|
682
|
+
buttonText = props.buttonText,
|
|
683
|
+
className = props.className,
|
|
684
|
+
disabled = props.disabled,
|
|
685
|
+
id = props.id,
|
|
686
|
+
multiple = props.multiple,
|
|
687
|
+
onChange = props.onChange;
|
|
688
|
+
var fileInputRef = React__default.useRef();
|
|
689
|
+
|
|
690
|
+
var _React$useState = React__default.useState(),
|
|
691
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
692
|
+
files = _React$useState2[0],
|
|
693
|
+
setFiles = _React$useState2[1]; // TODO: replace with localized string
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
var chooseFileMessage = buttonText || (multiple ? 'Choose files' : 'Choose file');
|
|
697
|
+
|
|
698
|
+
var changeHandler = function changeHandler(e) {
|
|
699
|
+
setFiles(e.target.files);
|
|
700
|
+
|
|
701
|
+
if (typeof onChange === 'function') {
|
|
702
|
+
onChange(e);
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
|
|
706
|
+
return React__default.createElement("span", {
|
|
707
|
+
className: className
|
|
708
|
+
}, React__default.createElement(Button, {
|
|
709
|
+
disabled: disabled,
|
|
710
|
+
kind: "secondary",
|
|
711
|
+
onClick: function onClick() {
|
|
712
|
+
fileInputRef.current.click();
|
|
713
|
+
}
|
|
714
|
+
}, chooseFileMessage), React__default.createElement("input", {
|
|
715
|
+
accept: accept,
|
|
716
|
+
"aria-label": ariaLabel,
|
|
717
|
+
className: styles['file-input'],
|
|
718
|
+
disabled: disabled,
|
|
719
|
+
id: id,
|
|
720
|
+
multiple: multiple,
|
|
721
|
+
onChange: disabled ? null : changeHandler,
|
|
722
|
+
ref: function ref(node) {
|
|
723
|
+
fileInputRef.current = node;
|
|
724
|
+
assignRef(_ref, node);
|
|
725
|
+
},
|
|
726
|
+
type: "file"
|
|
727
|
+
}), React__default.createElement(FileDetails, {
|
|
728
|
+
files: files
|
|
729
|
+
}));
|
|
730
|
+
});
|
|
731
|
+
FilePicker.defaultProps = {
|
|
732
|
+
accept: null,
|
|
733
|
+
ariaLabel: null,
|
|
734
|
+
buttonText: null,
|
|
735
|
+
className: null,
|
|
736
|
+
disabled: false,
|
|
737
|
+
id: null,
|
|
738
|
+
multiple: false,
|
|
739
|
+
onChange: null
|
|
740
|
+
};
|
|
741
|
+
FilePicker.propTypes = {
|
|
742
|
+
accept: PropTypes.string,
|
|
743
|
+
ariaLabel: PropTypes.string,
|
|
744
|
+
buttonText: PropTypes.string,
|
|
745
|
+
className: PropTypes.string,
|
|
746
|
+
disabled: PropTypes.bool,
|
|
747
|
+
id: PropTypes.string,
|
|
748
|
+
multiple: PropTypes.bool,
|
|
749
|
+
onChange: PropTypes.func
|
|
750
|
+
};
|
|
751
|
+
|
|
752
|
+
var targets = ['_self', '_blank'];
|
|
753
|
+
var Link = React__default.forwardRef(function Link(props, ref) {
|
|
754
|
+
var styles = useStyles('LinkStyles');
|
|
755
|
+
var children = props.children,
|
|
756
|
+
href = props.href,
|
|
757
|
+
target = props.target,
|
|
758
|
+
className = props.className;
|
|
759
|
+
var classes = classNames(className, styles.link);
|
|
760
|
+
var rel = target !== '_self' ? 'noopener noreferrer' : null;
|
|
761
|
+
|
|
762
|
+
if (typeof children !== 'string') {
|
|
763
|
+
return null;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
return React__default.createElement("a", {
|
|
767
|
+
href: href,
|
|
768
|
+
target: target,
|
|
769
|
+
rel: rel,
|
|
770
|
+
className: classes,
|
|
771
|
+
ref: ref
|
|
772
|
+
}, children);
|
|
773
|
+
});
|
|
774
|
+
Link.propTypes = {
|
|
775
|
+
children: PropTypes.string.isRequired,
|
|
776
|
+
className: PropTypes.string,
|
|
777
|
+
href: PropTypes.string,
|
|
778
|
+
target: PropTypes.oneOf(targets)
|
|
779
|
+
};
|
|
780
|
+
Link.defaultProps = {
|
|
781
|
+
className: '',
|
|
782
|
+
href: '#',
|
|
783
|
+
target: '_self'
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
var InputTypes = ['text', 'password', 'number', 'email', 'tel', 'url'];
|
|
787
|
+
var Input = React__default.forwardRef(function Input(props, ref) {
|
|
788
|
+
var _classNames, _classNames2;
|
|
789
|
+
|
|
790
|
+
var styles = useStyles('InputStyles');
|
|
791
|
+
|
|
792
|
+
var append = props.append,
|
|
793
|
+
ariaLabel = props.ariaLabel,
|
|
794
|
+
autoComplete = props.autoComplete,
|
|
795
|
+
className = props.className,
|
|
796
|
+
disabled = props.disabled,
|
|
797
|
+
defaultValue = props.defaultValue,
|
|
798
|
+
full = props.full,
|
|
799
|
+
id = props.id,
|
|
800
|
+
invalid = props.invalid,
|
|
801
|
+
multiline = props.multiline,
|
|
802
|
+
onBlur = props.onBlur,
|
|
803
|
+
onChange = props.onChange,
|
|
804
|
+
placeholder = props.placeholder,
|
|
805
|
+
prepend = props.prepend,
|
|
806
|
+
rows = props.rows,
|
|
807
|
+
small = props.small,
|
|
808
|
+
style = props.style,
|
|
809
|
+
testId = props.testId,
|
|
810
|
+
type = props.type,
|
|
811
|
+
value = props.value,
|
|
812
|
+
other = _objectWithoutProperties(props, ["append", "ariaLabel", "autoComplete", "className", "disabled", "defaultValue", "full", "id", "invalid", "multiline", "onBlur", "onChange", "placeholder", "prepend", "rows", "small", "style", "testId", "type", "value"]);
|
|
813
|
+
|
|
814
|
+
var inputClasses = classNames(styles.input, (_classNames = {}, _defineProperty(_classNames, styles.full, full), _defineProperty(_classNames, styles.invalid, invalid), _defineProperty(_classNames, styles.small, small), _defineProperty(_classNames, styles.multiline, multiline), _classNames));
|
|
815
|
+
|
|
816
|
+
var _React$useState = React__default.useState(false),
|
|
817
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
818
|
+
focused = _React$useState2[0],
|
|
819
|
+
setFocused = _React$useState2[1];
|
|
820
|
+
|
|
821
|
+
var blurHandler = function blurHandler(e) {
|
|
822
|
+
setFocused(false);
|
|
823
|
+
|
|
824
|
+
if (typeof onBlur === 'function') {
|
|
825
|
+
onBlur(e);
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
|
|
829
|
+
var focusHandler = function focusHandler() {
|
|
830
|
+
setFocused(true);
|
|
831
|
+
};
|
|
832
|
+
|
|
833
|
+
var InputComponent = multiline ? React__default.createElement("textarea", _extends({
|
|
834
|
+
"aria-label": ariaLabel,
|
|
835
|
+
autoComplete: autoComplete,
|
|
836
|
+
className: inputClasses,
|
|
837
|
+
"data-testid": testId,
|
|
838
|
+
disabled: disabled,
|
|
839
|
+
defaultValue: defaultValue,
|
|
840
|
+
id: id,
|
|
841
|
+
onBlur: blurHandler,
|
|
842
|
+
onChange: disabled ? null : onChange,
|
|
843
|
+
onFocus: focusHandler,
|
|
844
|
+
placeholder: placeholder,
|
|
845
|
+
rows: rows,
|
|
846
|
+
style: style,
|
|
847
|
+
value: value
|
|
848
|
+
}, other)) : React__default.createElement("input", _extends({
|
|
849
|
+
"aria-label": ariaLabel,
|
|
850
|
+
autoComplete: autoComplete,
|
|
851
|
+
className: inputClasses,
|
|
852
|
+
"data-testid": testId,
|
|
853
|
+
defaultValue: defaultValue,
|
|
854
|
+
disabled: disabled,
|
|
855
|
+
id: id,
|
|
856
|
+
onBlur: blurHandler,
|
|
857
|
+
onChange: disabled ? null : onChange,
|
|
858
|
+
onFocus: focusHandler,
|
|
859
|
+
placeholder: placeholder,
|
|
860
|
+
style: style,
|
|
861
|
+
type: type,
|
|
862
|
+
value: value
|
|
863
|
+
}, other));
|
|
864
|
+
return React__default.createElement("div", {
|
|
865
|
+
className: classNames(className, styles.inputContainer, (_classNames2 = {}, _defineProperty(_classNames2, styles.appended, append), _defineProperty(_classNames2, styles.disabled, disabled), _defineProperty(_classNames2, styles.focused, focused), _defineProperty(_classNames2, styles.full, full), _defineProperty(_classNames2, styles.invalid, invalid), _defineProperty(_classNames2, styles.multiline, multiline), _defineProperty(_classNames2, styles.prepended, prepend), _defineProperty(_classNames2, styles.small, small), _classNames2)),
|
|
866
|
+
ref: ref
|
|
867
|
+
}, prepend, InputComponent, append);
|
|
868
|
+
});
|
|
869
|
+
|
|
870
|
+
var validateAppendPrepend = function validateAppendPrepend(props, propName, componentName) {
|
|
871
|
+
var value = props[propName];
|
|
872
|
+
|
|
873
|
+
if (value != null && typeof value !== 'string' && value.type !== Icon) {
|
|
874
|
+
return new Error("Invalid value for '".concat(propName, "' prop supplied to '").concat(componentName, "': ").concat(value, ". The '").concat(propName, "' prop must be string or Icon."));
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
return null;
|
|
878
|
+
};
|
|
879
|
+
|
|
880
|
+
Input.propTypes = {
|
|
881
|
+
append: validateAppendPrepend,
|
|
882
|
+
autoComplete: PropTypes.string,
|
|
883
|
+
ariaLabel: PropTypes.string,
|
|
884
|
+
className: PropTypes.string,
|
|
885
|
+
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
886
|
+
disabled: PropTypes.bool,
|
|
887
|
+
full: PropTypes.bool,
|
|
888
|
+
id: PropTypes.string,
|
|
889
|
+
invalid: PropTypes.bool,
|
|
890
|
+
multiline: PropTypes.bool,
|
|
891
|
+
onBlur: PropTypes.func,
|
|
892
|
+
onChange: PropTypes.func,
|
|
893
|
+
placeholder: PropTypes.string,
|
|
894
|
+
prepend: validateAppendPrepend,
|
|
895
|
+
rows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
896
|
+
small: PropTypes.bool,
|
|
897
|
+
style: PropTypes.object,
|
|
898
|
+
testId: PropTypes.string,
|
|
899
|
+
type: PropTypes.oneOf(InputTypes),
|
|
900
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
901
|
+
};
|
|
902
|
+
Input.defaultProps = {
|
|
903
|
+
append: undefined,
|
|
904
|
+
autoComplete: undefined,
|
|
905
|
+
ariaLabel: undefined,
|
|
906
|
+
className: undefined,
|
|
907
|
+
defaultValue: undefined,
|
|
908
|
+
disabled: false,
|
|
909
|
+
full: false,
|
|
910
|
+
id: undefined,
|
|
911
|
+
invalid: false,
|
|
912
|
+
multiline: undefined,
|
|
913
|
+
onBlur: undefined,
|
|
914
|
+
onChange: undefined,
|
|
915
|
+
placeholder: undefined,
|
|
916
|
+
prepend: undefined,
|
|
917
|
+
rows: 2,
|
|
918
|
+
small: false,
|
|
919
|
+
style: {},
|
|
920
|
+
testId: undefined,
|
|
921
|
+
type: 'text',
|
|
922
|
+
value: undefined
|
|
923
|
+
};
|
|
924
|
+
|
|
925
|
+
var Table = React__default.forwardRef(function Table(props, ref) {
|
|
926
|
+
var styles = useStyles('TableStyles');
|
|
927
|
+
var children = props.children,
|
|
928
|
+
className = props.className,
|
|
929
|
+
id = props.id;
|
|
930
|
+
return React__default.createElement("table", {
|
|
931
|
+
ref: ref,
|
|
932
|
+
id: id,
|
|
933
|
+
className: classNames(className, styles.table)
|
|
934
|
+
}, children);
|
|
935
|
+
});
|
|
936
|
+
Table.propTypes = {
|
|
937
|
+
children: PropTypes.node,
|
|
938
|
+
className: PropTypes.string,
|
|
939
|
+
id: PropTypes.string
|
|
940
|
+
};
|
|
941
|
+
Table.defaultProps = {
|
|
942
|
+
children: null,
|
|
943
|
+
className: null,
|
|
944
|
+
id: null
|
|
945
|
+
};
|
|
946
|
+
|
|
947
|
+
var TableBody = React__default.forwardRef(function TableBody(props, ref) {
|
|
948
|
+
var styles = useStyles('TableStyles');
|
|
949
|
+
var children = props.children,
|
|
950
|
+
className = props.className,
|
|
951
|
+
id = props.id;
|
|
952
|
+
return React__default.createElement("tbody", {
|
|
953
|
+
ref: ref,
|
|
954
|
+
id: id,
|
|
955
|
+
className: classNames(className, styles.tableBody)
|
|
956
|
+
}, children);
|
|
957
|
+
});
|
|
958
|
+
TableBody.propTypes = {
|
|
959
|
+
children: PropTypes.node,
|
|
960
|
+
className: PropTypes.string,
|
|
961
|
+
id: PropTypes.string
|
|
962
|
+
};
|
|
963
|
+
TableBody.defaultProps = {
|
|
964
|
+
children: null,
|
|
965
|
+
className: null,
|
|
966
|
+
id: null
|
|
967
|
+
};
|
|
968
|
+
|
|
969
|
+
var TableCell = React__default.forwardRef(function TableCell(props, ref) {
|
|
970
|
+
var styles = useStyles('TableStyles');
|
|
971
|
+
var children = props.children,
|
|
972
|
+
className = props.className,
|
|
973
|
+
id = props.id;
|
|
974
|
+
return React__default.createElement("td", {
|
|
975
|
+
ref: ref,
|
|
976
|
+
id: id,
|
|
977
|
+
className: classNames(className, styles.tableCell)
|
|
978
|
+
}, children);
|
|
979
|
+
});
|
|
980
|
+
TableCell.propTypes = {
|
|
981
|
+
children: PropTypes.node,
|
|
982
|
+
className: PropTypes.string,
|
|
983
|
+
id: PropTypes.string
|
|
984
|
+
};
|
|
985
|
+
TableCell.defaultProps = {
|
|
986
|
+
children: null,
|
|
987
|
+
className: null,
|
|
988
|
+
id: null
|
|
989
|
+
};
|
|
990
|
+
|
|
991
|
+
var TableHead = React__default.forwardRef(function TableHead(props, ref) {
|
|
992
|
+
var styles = useStyles('TableStyles');
|
|
993
|
+
var children = props.children,
|
|
994
|
+
className = props.className,
|
|
995
|
+
id = props.id;
|
|
996
|
+
return React__default.createElement("thead", {
|
|
997
|
+
ref: ref,
|
|
998
|
+
id: id,
|
|
999
|
+
className: classNames(className, styles.tableHead)
|
|
1000
|
+
}, children);
|
|
1001
|
+
});
|
|
1002
|
+
TableHead.propTypes = {
|
|
1003
|
+
children: PropTypes.node,
|
|
1004
|
+
className: PropTypes.string,
|
|
1005
|
+
id: PropTypes.string
|
|
1006
|
+
};
|
|
1007
|
+
TableHead.defaultProps = {
|
|
1008
|
+
children: null,
|
|
1009
|
+
className: null,
|
|
1010
|
+
id: null
|
|
1011
|
+
};
|
|
1012
|
+
|
|
1013
|
+
var TableHeaderCell = React__default.forwardRef(function TableHeaderCell(props, ref) {
|
|
1014
|
+
var styles = useStyles('TableStyles');
|
|
1015
|
+
var children = props.children,
|
|
1016
|
+
className = props.className,
|
|
1017
|
+
id = props.id;
|
|
1018
|
+
return React__default.createElement("th", {
|
|
1019
|
+
ref: ref,
|
|
1020
|
+
id: id,
|
|
1021
|
+
className: classNames(className, styles.tableHeaderCell)
|
|
1022
|
+
}, children);
|
|
1023
|
+
});
|
|
1024
|
+
TableHeaderCell.propTypes = {
|
|
1025
|
+
children: PropTypes.node,
|
|
1026
|
+
className: PropTypes.string,
|
|
1027
|
+
id: PropTypes.string
|
|
1028
|
+
};
|
|
1029
|
+
TableHeaderCell.defaultProps = {
|
|
1030
|
+
children: null,
|
|
1031
|
+
className: null,
|
|
1032
|
+
id: null
|
|
1033
|
+
};
|
|
1034
|
+
|
|
1035
|
+
var TableRow = React__default.forwardRef(function TableRow(props, ref) {
|
|
1036
|
+
var styles = useStyles('TableStyles');
|
|
1037
|
+
var children = props.children,
|
|
1038
|
+
className = props.className,
|
|
1039
|
+
id = props.id;
|
|
1040
|
+
return React__default.createElement("tr", {
|
|
1041
|
+
ref: ref,
|
|
1042
|
+
id: id,
|
|
1043
|
+
className: classNames(className, styles.tableRow)
|
|
1044
|
+
}, children);
|
|
1045
|
+
});
|
|
1046
|
+
TableRow.propTypes = {
|
|
1047
|
+
children: PropTypes.node,
|
|
1048
|
+
className: PropTypes.string,
|
|
1049
|
+
id: PropTypes.string
|
|
1050
|
+
};
|
|
1051
|
+
TableRow.defaultProps = {
|
|
1052
|
+
children: null,
|
|
1053
|
+
className: null,
|
|
1054
|
+
id: null
|
|
1055
|
+
};
|
|
1056
|
+
|
|
1057
|
+
var Tab = React__default.forwardRef(function Tab(props, ref) {
|
|
1058
|
+
var styles = useStyles('TabsStyles');
|
|
1059
|
+
var id = props.id,
|
|
1060
|
+
label = props.label,
|
|
1061
|
+
active = props.active,
|
|
1062
|
+
onSelect = props.onSelect;
|
|
1063
|
+
var classes = classNames(styles.tab, _defineProperty({}, styles.active, active));
|
|
1064
|
+
|
|
1065
|
+
var handleKeyDown = function handleKeyDown(event) {
|
|
1066
|
+
if (event.key === 'Enter' || event.which === 32) {
|
|
1067
|
+
onSelect();
|
|
1068
|
+
}
|
|
1069
|
+
};
|
|
1070
|
+
|
|
1071
|
+
return React__default.createElement("div", {
|
|
1072
|
+
id: id,
|
|
1073
|
+
role: "tab",
|
|
1074
|
+
"aria-selected": active,
|
|
1075
|
+
tabIndex: 0,
|
|
1076
|
+
onClick: onSelect,
|
|
1077
|
+
onKeyDown: handleKeyDown,
|
|
1078
|
+
className: classes,
|
|
1079
|
+
ref: ref
|
|
1080
|
+
}, label);
|
|
1081
|
+
});
|
|
1082
|
+
Tab.propTypes = {
|
|
1083
|
+
children: PropTypes.node,
|
|
1084
|
+
// eslint-disable-line react/no-unused-prop-types
|
|
1085
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
1086
|
+
label: PropTypes.string,
|
|
1087
|
+
active: PropTypes.bool,
|
|
1088
|
+
onSelect: PropTypes.func
|
|
1089
|
+
};
|
|
1090
|
+
Tab.defaultProps = {
|
|
1091
|
+
children: null,
|
|
1092
|
+
id: null,
|
|
1093
|
+
label: '',
|
|
1094
|
+
active: false,
|
|
1095
|
+
onSelect: null
|
|
1096
|
+
};
|
|
1097
|
+
|
|
1098
|
+
var Tabs = React__default.forwardRef(function Tabs(props, ref) {
|
|
1099
|
+
var styles = useStyles('TabsStyles');
|
|
1100
|
+
var children = props.children,
|
|
1101
|
+
className = props.className,
|
|
1102
|
+
style = props.style;
|
|
1103
|
+
var classes = classNames(className, styles.tabs);
|
|
1104
|
+
|
|
1105
|
+
var _useState = React.useState(0),
|
|
1106
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1107
|
+
activeTab = _useState2[0],
|
|
1108
|
+
setActiveTab = _useState2[1];
|
|
1109
|
+
|
|
1110
|
+
function handleTabSelect(key) {
|
|
1111
|
+
setActiveTab(key);
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
return React__default.createElement("div", {
|
|
1115
|
+
className: classes,
|
|
1116
|
+
style: style,
|
|
1117
|
+
ref: ref
|
|
1118
|
+
}, React__default.createElement("div", {
|
|
1119
|
+
role: "tablist",
|
|
1120
|
+
className: styles.bar
|
|
1121
|
+
}, React__default.Children.map(children, function (child, index) {
|
|
1122
|
+
return React__default.cloneElement(child, {
|
|
1123
|
+
index: index,
|
|
1124
|
+
id: index,
|
|
1125
|
+
active: activeTab === index,
|
|
1126
|
+
children: child.props.children,
|
|
1127
|
+
onSelect: function onSelect() {
|
|
1128
|
+
return handleTabSelect(index);
|
|
1129
|
+
}
|
|
1130
|
+
});
|
|
1131
|
+
})), React__default.Children.map(children, function (child, index) {
|
|
1132
|
+
var isActive = index === activeTab;
|
|
1133
|
+
var panelClasses = classNames(styles.panel, _defineProperty({}, styles.inactive, !isActive));
|
|
1134
|
+
return React__default.createElement("div", {
|
|
1135
|
+
role: "tabpanel",
|
|
1136
|
+
"aria-labelledby": index,
|
|
1137
|
+
className: panelClasses
|
|
1138
|
+
}, isActive ? child.props.children : null);
|
|
1139
|
+
}));
|
|
1140
|
+
});
|
|
1141
|
+
var allOfTypeTab = createChainableTypeChecker(allChildrenOfTypeChecker(Tab, 'Tab'));
|
|
1142
|
+
Tabs.propTypes = {
|
|
1143
|
+
children: allOfTypeTab.isRequired,
|
|
1144
|
+
className: PropTypes.string,
|
|
1145
|
+
style: PropTypes.object
|
|
1146
|
+
};
|
|
1147
|
+
Tabs.defaultProps = {
|
|
1148
|
+
className: '',
|
|
1149
|
+
style: {}
|
|
1150
|
+
};
|
|
1151
|
+
|
|
1152
|
+
/* eslint-disable consistent-return */
|
|
1153
|
+
|
|
1154
|
+
function useDocumentEvent(event, handler) {
|
|
1155
|
+
var enabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
1156
|
+
React.useEffect(function () {
|
|
1157
|
+
if (enabled) {
|
|
1158
|
+
document.addEventListener(event, handler);
|
|
1159
|
+
return function () {
|
|
1160
|
+
return document.removeEventListener(event, handler);
|
|
1161
|
+
};
|
|
1162
|
+
}
|
|
1163
|
+
}, [event, handler, enabled]);
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
var MenuAnchor = React__default.forwardRef(function MenuAnchor(_ref, ref) {
|
|
1167
|
+
var label = _ref.label,
|
|
1168
|
+
onClick = _ref.onClick,
|
|
1169
|
+
onKeyDown = _ref.onKeyDown,
|
|
1170
|
+
ariaExpanded = _ref.ariaExpanded,
|
|
1171
|
+
disabled = _ref.disabled,
|
|
1172
|
+
className = _ref.className,
|
|
1173
|
+
testId = _ref.testId,
|
|
1174
|
+
kind = _ref.kind;
|
|
1175
|
+
var styles = useStyles('MenuStyles');
|
|
1176
|
+
return React__default.createElement(Button, {
|
|
1177
|
+
ref: ref,
|
|
1178
|
+
type: "button",
|
|
1179
|
+
className: classNames(styles.menuBtn, className, _defineProperty({}, styles.unlabelledButton, !label)),
|
|
1180
|
+
"aria-haspopup": "menu",
|
|
1181
|
+
"aria-expanded": ariaExpanded || undefined // aria-expanded should either be true or 'undefined'
|
|
1182
|
+
,
|
|
1183
|
+
onClick: onClick,
|
|
1184
|
+
onKeyDown: onKeyDown,
|
|
1185
|
+
disabled: disabled,
|
|
1186
|
+
"data-testid": testId,
|
|
1187
|
+
kind: kind
|
|
1188
|
+
}, label, React__default.createElement(Icon, {
|
|
1189
|
+
className: styles.rightIcon,
|
|
1190
|
+
type: IconTypes.AngleDown
|
|
1191
|
+
}));
|
|
1192
|
+
});
|
|
1193
|
+
MenuAnchor.propTypes = {
|
|
1194
|
+
label: PropTypes.string,
|
|
1195
|
+
onClick: PropTypes.func,
|
|
1196
|
+
onKeyDown: PropTypes.func,
|
|
1197
|
+
ariaExpanded: PropTypes.bool,
|
|
1198
|
+
disabled: PropTypes.bool,
|
|
1199
|
+
className: PropTypes.string,
|
|
1200
|
+
testId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1201
|
+
kind: PropTypes.string
|
|
1202
|
+
};
|
|
1203
|
+
MenuAnchor.defaultProps = {
|
|
1204
|
+
label: undefined,
|
|
1205
|
+
onClick: undefined,
|
|
1206
|
+
onKeyDown: undefined,
|
|
1207
|
+
ariaExpanded: undefined,
|
|
1208
|
+
disabled: undefined,
|
|
1209
|
+
className: undefined,
|
|
1210
|
+
testId: undefined,
|
|
1211
|
+
kind: undefined
|
|
1212
|
+
};
|
|
1213
|
+
|
|
1214
|
+
var SubmenuAnchor = React__default.forwardRef(function SubmenuAnchor(_ref, ref) {
|
|
1215
|
+
var label = _ref.label,
|
|
1216
|
+
isHighlighted = _ref.isHighlighted,
|
|
1217
|
+
onMouseEnter = _ref.onMouseEnter,
|
|
1218
|
+
disabled = _ref.disabled,
|
|
1219
|
+
className = _ref.className,
|
|
1220
|
+
style = _ref.style;
|
|
1221
|
+
var styles = useStyles('MenuStyles');
|
|
1222
|
+
var classes = classNames(styles.menuItem, className, _defineProperty({}, styles.highlighted, isHighlighted));
|
|
1223
|
+
return React__default.createElement("div", {
|
|
1224
|
+
role: "menuitem",
|
|
1225
|
+
tabIndex: "-1",
|
|
1226
|
+
ref: ref,
|
|
1227
|
+
onMouseEnter: onMouseEnter,
|
|
1228
|
+
disabled: disabled,
|
|
1229
|
+
className: classes,
|
|
1230
|
+
style: style
|
|
1231
|
+
}, label, React__default.createElement(Icon, {
|
|
1232
|
+
className: styles.rightIcon,
|
|
1233
|
+
type: IconTypes.AngleRight
|
|
1234
|
+
}));
|
|
1235
|
+
});
|
|
1236
|
+
SubmenuAnchor.propTypes = {
|
|
1237
|
+
label: PropTypes.string,
|
|
1238
|
+
isHighlighted: PropTypes.bool,
|
|
1239
|
+
onMouseEnter: PropTypes.func,
|
|
1240
|
+
disabled: PropTypes.bool,
|
|
1241
|
+
className: PropTypes.string,
|
|
1242
|
+
style: PropTypes.object
|
|
1243
|
+
};
|
|
1244
|
+
SubmenuAnchor.defaultProps = {
|
|
1245
|
+
label: undefined,
|
|
1246
|
+
isHighlighted: undefined,
|
|
1247
|
+
onMouseEnter: undefined,
|
|
1248
|
+
disabled: undefined,
|
|
1249
|
+
className: undefined,
|
|
1250
|
+
style: undefined
|
|
1251
|
+
};
|
|
1252
|
+
|
|
1253
|
+
function Portal(_ref) {
|
|
1254
|
+
var children = _ref.children,
|
|
1255
|
+
portalTarget = _ref.portalTarget;
|
|
1256
|
+
|
|
1257
|
+
var _useState = React.useState(function () {
|
|
1258
|
+
return document.createElement('div');
|
|
1259
|
+
}),
|
|
1260
|
+
_useState2 = _slicedToArray(_useState, 1),
|
|
1261
|
+
container = _useState2[0];
|
|
1262
|
+
|
|
1263
|
+
React.useLayoutEffect(function () {
|
|
1264
|
+
(portalTarget || document.body).appendChild(container);
|
|
1265
|
+
return function () {
|
|
1266
|
+
return (portalTarget || document.body).removeChild(container);
|
|
1267
|
+
};
|
|
1268
|
+
}, [container, portalTarget]);
|
|
1269
|
+
return ReactDOM.createPortal(children, container);
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
var modifiers = {
|
|
1273
|
+
preventOverflow: {
|
|
1274
|
+
enabled: false
|
|
1275
|
+
},
|
|
1276
|
+
hide: {
|
|
1277
|
+
enabled: false
|
|
1278
|
+
}
|
|
1279
|
+
};
|
|
1280
|
+
|
|
1281
|
+
var Popper = function Popper(_ref) {
|
|
1282
|
+
var open = _ref.open,
|
|
1283
|
+
anchor = _ref.anchor,
|
|
1284
|
+
children = _ref.children,
|
|
1285
|
+
placementProp = _ref.placement,
|
|
1286
|
+
anchorRef = _ref.anchorRef,
|
|
1287
|
+
popperRef = _ref.popperRef,
|
|
1288
|
+
portalTarget = _ref.portalTarget;
|
|
1289
|
+
return React__default.createElement(reactPopper.Manager, null, React__default.createElement(reactPopper.Reference, {
|
|
1290
|
+
innerRef: function innerRef(node) {
|
|
1291
|
+
return assignRef(anchorRef, node);
|
|
1292
|
+
}
|
|
1293
|
+
}, function (_ref2) {
|
|
1294
|
+
var ref = _ref2.ref;
|
|
1295
|
+
return React__default.cloneElement(anchor, {
|
|
1296
|
+
ref: ref
|
|
1297
|
+
});
|
|
1298
|
+
}), open && React__default.createElement(Portal, {
|
|
1299
|
+
portalTarget: portalTarget
|
|
1300
|
+
}, React__default.createElement(reactPopper.Popper, {
|
|
1301
|
+
placement: placementProp,
|
|
1302
|
+
modifiers: modifiers,
|
|
1303
|
+
innerRef: function innerRef(node) {
|
|
1304
|
+
return assignRef(popperRef, node);
|
|
1305
|
+
}
|
|
1306
|
+
}, function (_ref3) {
|
|
1307
|
+
var _ref4 = _ref3.ref,
|
|
1308
|
+
style = _ref3.style,
|
|
1309
|
+
placement = _ref3.placement,
|
|
1310
|
+
arrowProps = _ref3.arrowProps;
|
|
1311
|
+
return typeof children === 'function' ? children({
|
|
1312
|
+
ref: function ref(node) {
|
|
1313
|
+
assignRef(children.ref, node);
|
|
1314
|
+
assignRef(_ref4, node);
|
|
1315
|
+
},
|
|
1316
|
+
style: style,
|
|
1317
|
+
placement: placement,
|
|
1318
|
+
arrowProps: arrowProps
|
|
1319
|
+
}) : React__default.cloneElement(children, {
|
|
1320
|
+
ref: function ref(node) {
|
|
1321
|
+
assignRef(children.ref, node);
|
|
1322
|
+
assignRef(_ref4, node);
|
|
1323
|
+
},
|
|
1324
|
+
style: style,
|
|
1325
|
+
'data-placement': placement
|
|
1326
|
+
});
|
|
1327
|
+
})));
|
|
1328
|
+
};
|
|
1329
|
+
|
|
1330
|
+
Popper.propTypes = {
|
|
1331
|
+
open: PropTypes.bool,
|
|
1332
|
+
anchor: PropTypes.element.isRequired,
|
|
1333
|
+
children: PropTypes.oneOfType([PropTypes.element, PropTypes.func]).isRequired,
|
|
1334
|
+
placement: PropTypes.oneOf(reactPopper.placements),
|
|
1335
|
+
anchorRef: PropTypes.oneOfType([PropTypes.shape({
|
|
1336
|
+
current: PropTypes.any
|
|
1337
|
+
}), PropTypes.func]),
|
|
1338
|
+
popperRef: PropTypes.oneOfType([PropTypes.shape({
|
|
1339
|
+
current: PropTypes.any
|
|
1340
|
+
}), PropTypes.func]),
|
|
1341
|
+
portalTarget: PropTypes.instanceOf(Element)
|
|
1342
|
+
};
|
|
1343
|
+
Popper.defaultProps = {
|
|
1344
|
+
open: false,
|
|
1345
|
+
placement: 'bottom-start',
|
|
1346
|
+
anchorRef: undefined,
|
|
1347
|
+
popperRef: undefined,
|
|
1348
|
+
portalTarget: undefined
|
|
1349
|
+
};
|
|
1350
|
+
|
|
1351
|
+
var MenuContext = React__default.createContext({});
|
|
1352
|
+
|
|
1353
|
+
function useMenuContext() {
|
|
1354
|
+
return React.useContext(MenuContext);
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
var MenuContextProvider = function MenuContextProvider(_ref) {
|
|
1358
|
+
var value = _ref.value,
|
|
1359
|
+
children = _ref.children;
|
|
1360
|
+
return React__default.createElement(MenuContext.Provider, {
|
|
1361
|
+
value: value
|
|
1362
|
+
}, children);
|
|
1363
|
+
};
|
|
1364
|
+
|
|
1365
|
+
MenuContextProvider.propTypes = {
|
|
1366
|
+
value: PropTypes.object.isRequired,
|
|
1367
|
+
children: PropTypes.any.isRequired
|
|
1368
|
+
};
|
|
1369
|
+
|
|
1370
|
+
function reducer(state, action) {
|
|
1371
|
+
switch (action.type) {
|
|
1372
|
+
case 'CLOSE_MENU':
|
|
1373
|
+
return _objectSpread2({}, state, {
|
|
1374
|
+
focusedIndex: -1,
|
|
1375
|
+
open: false,
|
|
1376
|
+
shouldFocusAnchor: action.shouldFocusAnchor || false
|
|
1377
|
+
});
|
|
1378
|
+
|
|
1379
|
+
case 'OPEN_MENU':
|
|
1380
|
+
return _objectSpread2({}, state, {
|
|
1381
|
+
open: true,
|
|
1382
|
+
focusedIndex: typeof action.focusedIndex === 'number' ? action.focusedIndex : -1,
|
|
1383
|
+
shouldFocusAnchor: false
|
|
1384
|
+
});
|
|
1385
|
+
|
|
1386
|
+
case 'SELECT_ITEM':
|
|
1387
|
+
return _objectSpread2({}, state, {
|
|
1388
|
+
selectedValue: action.value,
|
|
1389
|
+
selectedLabel: action.label,
|
|
1390
|
+
focusedIndex: -1,
|
|
1391
|
+
shouldFocusAnchor: true,
|
|
1392
|
+
open: false
|
|
1393
|
+
});
|
|
1394
|
+
|
|
1395
|
+
case 'SET_FOCUSED_INDEX':
|
|
1396
|
+
return _objectSpread2({}, state, {
|
|
1397
|
+
focusedIndex: action.index
|
|
1398
|
+
});
|
|
1399
|
+
|
|
1400
|
+
default:
|
|
1401
|
+
throw new Error("Unknown action of type: ".concat(action.type));
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
function useMenuState(defaults) {
|
|
1406
|
+
var defaultValues = typeof defaults === 'function' ? defaults() : defaults || {};
|
|
1407
|
+
|
|
1408
|
+
var initialValue = _objectSpread2({
|
|
1409
|
+
selectedValue: null,
|
|
1410
|
+
selectedLabel: null,
|
|
1411
|
+
focusedIndex: -1,
|
|
1412
|
+
shouldFocusAnchor: false,
|
|
1413
|
+
open: false
|
|
1414
|
+
}, defaultValues);
|
|
1415
|
+
|
|
1416
|
+
var _useReducer = React.useReducer(reducer, initialValue),
|
|
1417
|
+
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
1418
|
+
state = _useReducer2[0],
|
|
1419
|
+
dispatch = _useReducer2[1];
|
|
1420
|
+
|
|
1421
|
+
var closeMenu = React.useCallback(function () {
|
|
1422
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1423
|
+
shouldFocusAnchor = _ref.shouldFocusAnchor;
|
|
1424
|
+
|
|
1425
|
+
return dispatch({
|
|
1426
|
+
type: 'CLOSE_MENU',
|
|
1427
|
+
shouldFocusAnchor: shouldFocusAnchor
|
|
1428
|
+
});
|
|
1429
|
+
}, []);
|
|
1430
|
+
var openMenu = React.useCallback(function () {
|
|
1431
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1432
|
+
focusedIndex = _ref2.focusedIndex;
|
|
1433
|
+
|
|
1434
|
+
return dispatch({
|
|
1435
|
+
type: 'OPEN_MENU',
|
|
1436
|
+
focusedIndex: focusedIndex
|
|
1437
|
+
});
|
|
1438
|
+
}, []);
|
|
1439
|
+
var selectItem = React.useCallback(function (value, label) {
|
|
1440
|
+
return dispatch({
|
|
1441
|
+
type: 'SELECT_ITEM',
|
|
1442
|
+
value: value,
|
|
1443
|
+
label: label
|
|
1444
|
+
});
|
|
1445
|
+
}, []);
|
|
1446
|
+
var setFocusedIndex = React.useCallback(function (index) {
|
|
1447
|
+
return dispatch({
|
|
1448
|
+
type: 'SET_FOCUSED_INDEX',
|
|
1449
|
+
index: index
|
|
1450
|
+
});
|
|
1451
|
+
}, []);
|
|
1452
|
+
var functions = React.useRef({
|
|
1453
|
+
closeMenu: closeMenu,
|
|
1454
|
+
openMenu: openMenu,
|
|
1455
|
+
selectItem: selectItem,
|
|
1456
|
+
setFocusedIndex: setFocusedIndex
|
|
1457
|
+
});
|
|
1458
|
+
return [state, functions.current];
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
var SelectMenu = React__default.forwardRef(function SelectMenu(_ref, ref) {
|
|
1462
|
+
var defaultLabel = _ref.label,
|
|
1463
|
+
children = _ref.children,
|
|
1464
|
+
onChange = _ref.onChange,
|
|
1465
|
+
defaultValue = _ref.defaultValue,
|
|
1466
|
+
placement = _ref.placement,
|
|
1467
|
+
className = _ref.className,
|
|
1468
|
+
style = _ref.style,
|
|
1469
|
+
disabled = _ref.disabled,
|
|
1470
|
+
maxHeight = _ref.maxHeight,
|
|
1471
|
+
testId = _ref.testId,
|
|
1472
|
+
portalTarget = _ref.portalTarget,
|
|
1473
|
+
menuItemIndex = _ref.menuItemIndex,
|
|
1474
|
+
kind = _ref.kind;
|
|
1475
|
+
var styles = useStyles('MenuStyles');
|
|
1476
|
+
|
|
1477
|
+
var _useMenuContext = useMenuContext(),
|
|
1478
|
+
parentOnSelect = _useMenuContext.onSelect,
|
|
1479
|
+
parentSelectedValue = _useMenuContext.selectedValue,
|
|
1480
|
+
parentFocusedIndex = _useMenuContext.focusedIndex,
|
|
1481
|
+
parentSetFocusedIndex = _useMenuContext.setFocusedIndex;
|
|
1482
|
+
|
|
1483
|
+
var isSubmenu = Boolean(parentOnSelect);
|
|
1484
|
+
|
|
1485
|
+
var _useMenuState = useMenuState(function () {
|
|
1486
|
+
return {
|
|
1487
|
+
selectedValue: defaultValue,
|
|
1488
|
+
selectedLabel: defaultValue && getChildByValue(children, defaultValue).props.children
|
|
1489
|
+
};
|
|
1490
|
+
}),
|
|
1491
|
+
_useMenuState2 = _slicedToArray(_useMenuState, 2),
|
|
1492
|
+
_useMenuState2$ = _useMenuState2[0],
|
|
1493
|
+
open = _useMenuState2$.open,
|
|
1494
|
+
focusedIndex = _useMenuState2$.focusedIndex,
|
|
1495
|
+
ownSelectedValue = _useMenuState2$.selectedValue,
|
|
1496
|
+
selectedLabel = _useMenuState2$.selectedLabel,
|
|
1497
|
+
shouldFocusAnchor = _useMenuState2$.shouldFocusAnchor,
|
|
1498
|
+
_useMenuState2$2 = _useMenuState2[1],
|
|
1499
|
+
closeMenu = _useMenuState2$2.closeMenu,
|
|
1500
|
+
openMenu = _useMenuState2$2.openMenu,
|
|
1501
|
+
selectItem = _useMenuState2$2.selectItem,
|
|
1502
|
+
setFocusedIndex = _useMenuState2$2.setFocusedIndex;
|
|
1503
|
+
|
|
1504
|
+
var selectedValue = parentSelectedValue || ownSelectedValue;
|
|
1505
|
+
useDocumentEvent('click', closeMenu, open);
|
|
1506
|
+
|
|
1507
|
+
var onSelect = parentOnSelect || function (value, label) {
|
|
1508
|
+
selectItem(value, label);
|
|
1509
|
+
onChange && onChange(value, label);
|
|
1510
|
+
};
|
|
1511
|
+
|
|
1512
|
+
var handleAnchorClick = function handleAnchorClick() {
|
|
1513
|
+
open ? closeMenu() : openMenu();
|
|
1514
|
+
};
|
|
1515
|
+
|
|
1516
|
+
var numChildren = React__default.Children.count(children);
|
|
1517
|
+
|
|
1518
|
+
var handleAnchorKeyDown = function handleAnchorKeyDown(e) {
|
|
1519
|
+
if (!disabled) {
|
|
1520
|
+
if (e.key === 'Enter' || e.key === ' ' || e.key === 'ArrowDown') {
|
|
1521
|
+
e.preventDefault(); // prevent scroll
|
|
1522
|
+
|
|
1523
|
+
openMenu({
|
|
1524
|
+
focusedIndex: 0
|
|
1525
|
+
});
|
|
1526
|
+
} else if (e.key === 'ArrowUp') {
|
|
1527
|
+
e.preventDefault(); // prevent scroll
|
|
1528
|
+
|
|
1529
|
+
openMenu({
|
|
1530
|
+
focusedIndex: numChildren - 1
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
};
|
|
1535
|
+
|
|
1536
|
+
var handleMenuKeyDown = function handleMenuKeyDown(e) {
|
|
1537
|
+
if (e.key === 'Escape') {
|
|
1538
|
+
closeMenu({
|
|
1539
|
+
shouldFocusAnchor: true
|
|
1540
|
+
});
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
if (e.key === 'ArrowDown') {
|
|
1544
|
+
e.preventDefault(); // prevent scroll
|
|
1545
|
+
|
|
1546
|
+
var i = focusedIndex;
|
|
1547
|
+
setFocusedIndex((i + 1) % numChildren);
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
if (e.key === 'ArrowUp') {
|
|
1551
|
+
e.preventDefault(); // prevent scroll
|
|
1552
|
+
|
|
1553
|
+
var _i = focusedIndex;
|
|
1554
|
+
setFocusedIndex((_i - 1 + numChildren) % numChildren);
|
|
1555
|
+
}
|
|
1556
|
+
};
|
|
1557
|
+
|
|
1558
|
+
var menuItems = React__default.Children.map(children, function (child, index) {
|
|
1559
|
+
return React__default.cloneElement(child, {
|
|
1560
|
+
menuItemIndex: index
|
|
1561
|
+
});
|
|
1562
|
+
});
|
|
1563
|
+
var menuAnchorRef = React.useRef(null);
|
|
1564
|
+
var menuAnchor = isSubmenu ? React__default.createElement(SubmenuAnchor, {
|
|
1565
|
+
label: defaultLabel,
|
|
1566
|
+
isHighlighted: menuItemIndex === parentFocusedIndex,
|
|
1567
|
+
onMouseEnter: function onMouseEnter() {
|
|
1568
|
+
return parentSetFocusedIndex(menuItemIndex);
|
|
1569
|
+
},
|
|
1570
|
+
disabled: disabled,
|
|
1571
|
+
className: className,
|
|
1572
|
+
style: style,
|
|
1573
|
+
ref: ref
|
|
1574
|
+
}) : React__default.createElement(MenuAnchor, {
|
|
1575
|
+
label: selectedLabel || defaultLabel,
|
|
1576
|
+
onClick: handleAnchorClick,
|
|
1577
|
+
onKeyDown: handleAnchorKeyDown,
|
|
1578
|
+
ariaExpanded: open,
|
|
1579
|
+
testId: testId,
|
|
1580
|
+
disabled: disabled,
|
|
1581
|
+
className: className,
|
|
1582
|
+
style: style,
|
|
1583
|
+
ref: ref,
|
|
1584
|
+
kind: kind
|
|
1585
|
+
});
|
|
1586
|
+
React.useEffect(function () {
|
|
1587
|
+
if (shouldFocusAnchor) {
|
|
1588
|
+
menuAnchorRef.current.focus();
|
|
1589
|
+
}
|
|
1590
|
+
}, [shouldFocusAnchor]);
|
|
1591
|
+
var contextValue = {
|
|
1592
|
+
onSelect: onSelect,
|
|
1593
|
+
selectedValue: selectedValue,
|
|
1594
|
+
focusedIndex: focusedIndex,
|
|
1595
|
+
setFocusedIndex: setFocusedIndex
|
|
1596
|
+
};
|
|
1597
|
+
return React__default.createElement(Popper, {
|
|
1598
|
+
open: isSubmenu ? !disabled && menuItemIndex === parentFocusedIndex : open,
|
|
1599
|
+
anchor: menuAnchor,
|
|
1600
|
+
anchorRef: menuAnchorRef,
|
|
1601
|
+
portalTarget: portalTarget,
|
|
1602
|
+
placement: isSubmenu ? 'right-start' : placement
|
|
1603
|
+
}, React__default.createElement("div", {
|
|
1604
|
+
role: "menu",
|
|
1605
|
+
tabIndex: "-1",
|
|
1606
|
+
className: styles.menuItemsContainer,
|
|
1607
|
+
onKeyDown: handleMenuKeyDown,
|
|
1608
|
+
onClick: function onClick(e) {
|
|
1609
|
+
return e.nativeEvent.stopImmediatePropagation();
|
|
1610
|
+
}
|
|
1611
|
+
}, React__default.createElement("div", {
|
|
1612
|
+
style: {
|
|
1613
|
+
maxHeight: maxHeight
|
|
1614
|
+
},
|
|
1615
|
+
className: classNames(styles.menuItems, _defineProperty({}, styles.scrollable, !!maxHeight))
|
|
1616
|
+
}, React__default.createElement(MenuContextProvider, {
|
|
1617
|
+
value: contextValue
|
|
1618
|
+
}, menuItems))));
|
|
1619
|
+
});
|
|
1620
|
+
|
|
1621
|
+
function getChildByValue(children, value) {
|
|
1622
|
+
var result = null;
|
|
1623
|
+
var kids = React__default.Children.toArray(children);
|
|
1624
|
+
|
|
1625
|
+
for (var i = 0; i < kids.length; i += 1) {
|
|
1626
|
+
var child = kids[i];
|
|
1627
|
+
|
|
1628
|
+
if (child.props.value === value) {
|
|
1629
|
+
result = child;
|
|
1630
|
+
break;
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
return result;
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
SelectMenu.propTypes = {
|
|
1638
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
|
1639
|
+
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1640
|
+
children: PropTypes.node,
|
|
1641
|
+
onChange: PropTypes.func,
|
|
1642
|
+
placement: PropTypes.oneOf(reactPopper.placements),
|
|
1643
|
+
className: PropTypes.string,
|
|
1644
|
+
style: PropTypes.object,
|
|
1645
|
+
disabled: PropTypes.bool,
|
|
1646
|
+
maxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1647
|
+
testId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1648
|
+
menuItemIndex: PropTypes.number,
|
|
1649
|
+
portalTarget: PropTypes.instanceOf(Element),
|
|
1650
|
+
kind: PropTypes.string
|
|
1651
|
+
};
|
|
1652
|
+
SelectMenu.defaultProps = {
|
|
1653
|
+
defaultValue: undefined,
|
|
1654
|
+
children: undefined,
|
|
1655
|
+
onChange: undefined,
|
|
1656
|
+
placement: 'bottom-start',
|
|
1657
|
+
className: undefined,
|
|
1658
|
+
style: undefined,
|
|
1659
|
+
disabled: undefined,
|
|
1660
|
+
maxHeight: undefined,
|
|
1661
|
+
testId: undefined,
|
|
1662
|
+
menuItemIndex: undefined,
|
|
1663
|
+
portalTarget: undefined,
|
|
1664
|
+
kind: undefined
|
|
1665
|
+
};
|
|
1666
|
+
|
|
1667
|
+
function useFocuser(ref, isFocused) {
|
|
1668
|
+
React.useEffect(function () {
|
|
1669
|
+
if (isFocused) {
|
|
1670
|
+
var x = window.scrollX;
|
|
1671
|
+
var y = window.scrollY;
|
|
1672
|
+
ref.current.focus();
|
|
1673
|
+
window.scrollTo(x, y);
|
|
1674
|
+
} else {
|
|
1675
|
+
ref.current.blur();
|
|
1676
|
+
}
|
|
1677
|
+
}, [isFocused, ref]);
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
var MenuItem = React__default.forwardRef(function MenuItem(_ref, _ref2) {
|
|
1681
|
+
var value = _ref.value,
|
|
1682
|
+
label = _ref.children,
|
|
1683
|
+
onSelect = _ref.onSelect,
|
|
1684
|
+
className = _ref.className,
|
|
1685
|
+
style = _ref.style,
|
|
1686
|
+
disabled = _ref.disabled,
|
|
1687
|
+
testId = _ref.testId,
|
|
1688
|
+
menuItemIndex = _ref.menuItemIndex;
|
|
1689
|
+
var styles = useStyles('MenuStyles');
|
|
1690
|
+
|
|
1691
|
+
var _useMenuContext = useMenuContext(),
|
|
1692
|
+
selectedValue = _useMenuContext.selectedValue,
|
|
1693
|
+
focusedIndex = _useMenuContext.focusedIndex,
|
|
1694
|
+
setFocusedIndex = _useMenuContext.setFocusedIndex,
|
|
1695
|
+
onSelectMenu = _useMenuContext.onSelect;
|
|
1696
|
+
|
|
1697
|
+
var isSelected = selectedValue && value === selectedValue;
|
|
1698
|
+
var isFocused = menuItemIndex === focusedIndex;
|
|
1699
|
+
var menuItemRef = React.useRef(null);
|
|
1700
|
+
useFocuser(menuItemRef, isFocused);
|
|
1701
|
+
var classes = classNames(styles.menuItem, className, _defineProperty({}, styles.highlighted, isFocused));
|
|
1702
|
+
|
|
1703
|
+
var handleSelect = function handleSelect() {
|
|
1704
|
+
if (!disabled) {
|
|
1705
|
+
onSelectMenu(value, label);
|
|
1706
|
+
onSelect && onSelect();
|
|
1707
|
+
}
|
|
1708
|
+
};
|
|
1709
|
+
|
|
1710
|
+
var handleKeyDown = function handleKeyDown(event) {
|
|
1711
|
+
if (event.key === ' ' || event.key === 'Enter') {
|
|
1712
|
+
event.preventDefault(); // prevent scroll
|
|
1713
|
+
|
|
1714
|
+
handleSelect();
|
|
1715
|
+
}
|
|
1716
|
+
};
|
|
1717
|
+
|
|
1718
|
+
return React__default.createElement("div", {
|
|
1719
|
+
role: "menuitem",
|
|
1720
|
+
tabIndex: "-1" // focusable, not tabbable
|
|
1721
|
+
,
|
|
1722
|
+
ref: function ref(node) {
|
|
1723
|
+
assignRef(_ref2, node);
|
|
1724
|
+
menuItemRef.current = node;
|
|
1725
|
+
},
|
|
1726
|
+
className: classes,
|
|
1727
|
+
style: style,
|
|
1728
|
+
disabled: disabled,
|
|
1729
|
+
onClick: handleSelect,
|
|
1730
|
+
onKeyDown: handleKeyDown,
|
|
1731
|
+
onMouseEnter: function onMouseEnter() {
|
|
1732
|
+
return setFocusedIndex(menuItemIndex);
|
|
1733
|
+
},
|
|
1734
|
+
onMouseLeave: function onMouseLeave() {
|
|
1735
|
+
return setFocusedIndex(-1);
|
|
1736
|
+
},
|
|
1737
|
+
onFocus: function onFocus(e) {
|
|
1738
|
+
return e.preventDefault();
|
|
1739
|
+
},
|
|
1740
|
+
onBlur: function onBlur(e) {
|
|
1741
|
+
return e.preventDefault();
|
|
1742
|
+
},
|
|
1743
|
+
"data-testid": testId
|
|
1744
|
+
}, isSelected && React__default.createElement(Icon, {
|
|
1745
|
+
className: styles.leftIcon,
|
|
1746
|
+
type: IconTypes.Check
|
|
1747
|
+
}), label);
|
|
1748
|
+
});
|
|
1749
|
+
MenuItem.propTypes = {
|
|
1750
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1751
|
+
children: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.node]),
|
|
1752
|
+
onSelect: PropTypes.func,
|
|
1753
|
+
className: PropTypes.string,
|
|
1754
|
+
style: PropTypes.object,
|
|
1755
|
+
disabled: PropTypes.bool,
|
|
1756
|
+
testId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1757
|
+
menuItemIndex: PropTypes.number
|
|
1758
|
+
};
|
|
1759
|
+
MenuItem.defaultProps = {
|
|
1760
|
+
value: undefined,
|
|
1761
|
+
children: undefined,
|
|
1762
|
+
onSelect: undefined,
|
|
1763
|
+
className: undefined,
|
|
1764
|
+
style: undefined,
|
|
1765
|
+
disabled: undefined,
|
|
1766
|
+
testId: undefined,
|
|
1767
|
+
menuItemIndex: undefined
|
|
1768
|
+
};
|
|
1769
|
+
|
|
1770
|
+
var defaultEvents = ['mouseup', 'touchend'];
|
|
1771
|
+
|
|
1772
|
+
function useClickOutside(refs, onClickOutside) {
|
|
1773
|
+
var events = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultEvents;
|
|
1774
|
+
var allRefs = React.useMemo(function () {
|
|
1775
|
+
return Array.isArray(refs) ? refs : [refs];
|
|
1776
|
+
}, [refs]);
|
|
1777
|
+
var handleOutsideClick = React.useRef(onClickOutside);
|
|
1778
|
+
React.useEffect(function () {
|
|
1779
|
+
handleOutsideClick.current = onClickOutside;
|
|
1780
|
+
}, [onClickOutside]);
|
|
1781
|
+
React.useEffect(function () {
|
|
1782
|
+
var handler = function handler(event) {
|
|
1783
|
+
var isInside = allRefs.some(function (ref) {
|
|
1784
|
+
var el = ref.current;
|
|
1785
|
+
return el && el.contains(event.target);
|
|
1786
|
+
});
|
|
1787
|
+
|
|
1788
|
+
if (!isInside) {
|
|
1789
|
+
handleOutsideClick.current(event);
|
|
1790
|
+
}
|
|
1791
|
+
};
|
|
1792
|
+
|
|
1793
|
+
events.forEach(function (eventName) {
|
|
1794
|
+
return document.addEventListener(eventName, handler);
|
|
1795
|
+
});
|
|
1796
|
+
return function () {
|
|
1797
|
+
events.forEach(function (eventName) {
|
|
1798
|
+
return document.removeEventListener(eventName, handler);
|
|
1799
|
+
});
|
|
1800
|
+
};
|
|
1801
|
+
}, [allRefs, events]);
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
var Menu = React__default.forwardRef(function Menu(_ref, ref) {
|
|
1805
|
+
var label = _ref.label,
|
|
1806
|
+
children = _ref.children,
|
|
1807
|
+
placement = _ref.placement,
|
|
1808
|
+
disabled = _ref.disabled,
|
|
1809
|
+
menuItemIndex = _ref.menuItemIndex,
|
|
1810
|
+
portalTarget = _ref.portalTarget,
|
|
1811
|
+
maxHeight = _ref.maxHeight,
|
|
1812
|
+
rest = _objectWithoutProperties(_ref, ["label", "children", "placement", "disabled", "menuItemIndex", "portalTarget", "maxHeight"]);
|
|
1813
|
+
|
|
1814
|
+
var styles = useStyles('MenuStyles');
|
|
1815
|
+
|
|
1816
|
+
var _useMenuContext = useMenuContext(),
|
|
1817
|
+
parentSetClickOutsideEnabled = _useMenuContext.setClickOutsideEnabled,
|
|
1818
|
+
parentRefs = _useMenuContext.refs,
|
|
1819
|
+
parentOnSelect = _useMenuContext.onSelect,
|
|
1820
|
+
parentFocusedIndex = _useMenuContext.focusedIndex,
|
|
1821
|
+
parentSetFocusedIndex = _useMenuContext.setFocusedIndex;
|
|
1822
|
+
|
|
1823
|
+
var isSubmenu = typeof parentFocusedIndex !== 'undefined';
|
|
1824
|
+
var menuItems = React__default.Children.map(children, function (child, index) {
|
|
1825
|
+
return React__default.cloneElement(child, {
|
|
1826
|
+
menuItemIndex: index
|
|
1827
|
+
});
|
|
1828
|
+
});
|
|
1829
|
+
|
|
1830
|
+
var _useMenuState = useMenuState(),
|
|
1831
|
+
_useMenuState2 = _slicedToArray(_useMenuState, 2),
|
|
1832
|
+
_useMenuState2$ = _useMenuState2[0],
|
|
1833
|
+
open = _useMenuState2$.open,
|
|
1834
|
+
focusedIndex = _useMenuState2$.focusedIndex,
|
|
1835
|
+
shouldFocusAnchor = _useMenuState2$.shouldFocusAnchor,
|
|
1836
|
+
_useMenuState2$2 = _useMenuState2[1],
|
|
1837
|
+
closeMenu = _useMenuState2$2.closeMenu,
|
|
1838
|
+
openMenu = _useMenuState2$2.openMenu,
|
|
1839
|
+
setFocusedIndex = _useMenuState2$2.setFocusedIndex;
|
|
1840
|
+
|
|
1841
|
+
var numChildren = React__default.Children.count(children);
|
|
1842
|
+
|
|
1843
|
+
var handleAnchorKeyDown = function handleAnchorKeyDown(e) {
|
|
1844
|
+
if (!disabled) {
|
|
1845
|
+
if (e.key === 'Enter' || e.key === ' ' || e.key === 'ArrowDown') {
|
|
1846
|
+
e.preventDefault(); // prevent scroll
|
|
1847
|
+
|
|
1848
|
+
openMenu({
|
|
1849
|
+
focusedIndex: 0
|
|
1850
|
+
});
|
|
1851
|
+
} else if (e.key === 'ArrowUp') {
|
|
1852
|
+
e.preventDefault(); // prevent scroll
|
|
1853
|
+
|
|
1854
|
+
openMenu({
|
|
1855
|
+
focusedIndex: numChildren - 1
|
|
1856
|
+
});
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
};
|
|
1860
|
+
|
|
1861
|
+
var handleMenuKeyDown = function handleMenuKeyDown(e) {
|
|
1862
|
+
if (e.key === 'Escape') {
|
|
1863
|
+
closeMenu({
|
|
1864
|
+
shouldFocusAnchor: true
|
|
1865
|
+
});
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
if (e.key === 'ArrowDown') {
|
|
1869
|
+
e.preventDefault(); // prevent scroll
|
|
1870
|
+
|
|
1871
|
+
var i = focusedIndex;
|
|
1872
|
+
setFocusedIndex((i + 1) % numChildren);
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
if (e.key === 'ArrowUp') {
|
|
1876
|
+
e.preventDefault(); // prevent scroll
|
|
1877
|
+
|
|
1878
|
+
var _i = focusedIndex;
|
|
1879
|
+
setFocusedIndex((_i - 1 + numChildren) % numChildren);
|
|
1880
|
+
}
|
|
1881
|
+
};
|
|
1882
|
+
|
|
1883
|
+
var handleAnchorClick = function handleAnchorClick() {
|
|
1884
|
+
open ? closeMenu() : openMenu();
|
|
1885
|
+
};
|
|
1886
|
+
|
|
1887
|
+
var menuAnchorRef = React.useRef(null);
|
|
1888
|
+
var menuAnchor = isSubmenu ? React__default.createElement(SubmenuAnchor, _extends({}, rest, {
|
|
1889
|
+
ref: ref,
|
|
1890
|
+
label: label,
|
|
1891
|
+
isHighlighted: menuItemIndex === parentFocusedIndex,
|
|
1892
|
+
onMouseEnter: function onMouseEnter() {
|
|
1893
|
+
return parentSetFocusedIndex(menuItemIndex);
|
|
1894
|
+
},
|
|
1895
|
+
disabled: disabled
|
|
1896
|
+
})) : React__default.createElement(MenuAnchor, _extends({}, rest, {
|
|
1897
|
+
ref: ref,
|
|
1898
|
+
label: label,
|
|
1899
|
+
onClick: handleAnchorClick,
|
|
1900
|
+
onKeyDown: handleAnchorKeyDown,
|
|
1901
|
+
ariaExpanded: open,
|
|
1902
|
+
disabled: disabled
|
|
1903
|
+
}));
|
|
1904
|
+
React.useEffect(function () {
|
|
1905
|
+
if (shouldFocusAnchor) {
|
|
1906
|
+
menuAnchorRef.current.focus();
|
|
1907
|
+
}
|
|
1908
|
+
}, [shouldFocusAnchor]);
|
|
1909
|
+
var menuRef = React.useRef(null);
|
|
1910
|
+
var refs = React.useMemo(function () {
|
|
1911
|
+
if (parentRefs) {
|
|
1912
|
+
return [].concat(_toConsumableArray(parentRefs), [menuAnchorRef, menuRef]);
|
|
1913
|
+
}
|
|
1914
|
+
|
|
1915
|
+
return [menuAnchorRef, menuRef];
|
|
1916
|
+
}, [parentRefs]);
|
|
1917
|
+
var clickOutsideEnabled = React.useRef(true);
|
|
1918
|
+
var setClickOutsideEnabled = React.useCallback(function (isEnabled) {
|
|
1919
|
+
clickOutsideEnabled.current = isEnabled;
|
|
1920
|
+
}, []);
|
|
1921
|
+
React.useEffect(function () {
|
|
1922
|
+
parentSetClickOutsideEnabled && parentSetClickOutsideEnabled(!open);
|
|
1923
|
+
}, [open, parentSetClickOutsideEnabled]);
|
|
1924
|
+
var handler = React__default.useCallback(function () {
|
|
1925
|
+
clickOutsideEnabled.current && closeMenu();
|
|
1926
|
+
}, [closeMenu]);
|
|
1927
|
+
useClickOutside(refs, handler);
|
|
1928
|
+
|
|
1929
|
+
var onSelect = parentOnSelect || function () {
|
|
1930
|
+
return closeMenu({
|
|
1931
|
+
shouldFocusAnchor: true
|
|
1932
|
+
});
|
|
1933
|
+
};
|
|
1934
|
+
|
|
1935
|
+
var contextValue = {
|
|
1936
|
+
setClickOutsideEnabled: setClickOutsideEnabled,
|
|
1937
|
+
refs: refs,
|
|
1938
|
+
onSelect: onSelect,
|
|
1939
|
+
focusedIndex: focusedIndex,
|
|
1940
|
+
setFocusedIndex: setFocusedIndex
|
|
1941
|
+
};
|
|
1942
|
+
return React__default.createElement(Popper, {
|
|
1943
|
+
open: isSubmenu ? !disabled && menuItemIndex === parentFocusedIndex : open,
|
|
1944
|
+
anchor: menuAnchor,
|
|
1945
|
+
anchorRef: menuAnchorRef,
|
|
1946
|
+
portalTarget: portalTarget,
|
|
1947
|
+
placement: isSubmenu ? 'right-start' : placement
|
|
1948
|
+
}, React__default.createElement("div", {
|
|
1949
|
+
ref: menuRef,
|
|
1950
|
+
role: "menu",
|
|
1951
|
+
tabIndex: "-1",
|
|
1952
|
+
className: styles.menuItemsContainer,
|
|
1953
|
+
onKeyDown: handleMenuKeyDown,
|
|
1954
|
+
onClick: function onClick(e) {
|
|
1955
|
+
return e.nativeEvent.stopImmediatePropagation();
|
|
1956
|
+
}
|
|
1957
|
+
}, React__default.createElement("div", {
|
|
1958
|
+
style: {
|
|
1959
|
+
maxHeight: maxHeight
|
|
1960
|
+
},
|
|
1961
|
+
className: classNames(styles.menuItems, _defineProperty({}, styles.scrollable, !!maxHeight))
|
|
1962
|
+
}, React__default.createElement(MenuContextProvider, {
|
|
1963
|
+
value: contextValue
|
|
1964
|
+
}, menuItems))));
|
|
1965
|
+
});
|
|
1966
|
+
Menu.propTypes = {
|
|
1967
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1968
|
+
children: PropTypes.node,
|
|
1969
|
+
placement: PropTypes.oneOf(reactPopper.placements),
|
|
1970
|
+
disabled: PropTypes.bool,
|
|
1971
|
+
kind: PropTypes.string,
|
|
1972
|
+
menuItemIndex: PropTypes.number,
|
|
1973
|
+
portalTarget: PropTypes.instanceOf(Element),
|
|
1974
|
+
maxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
1975
|
+
};
|
|
1976
|
+
Menu.defaultProps = {
|
|
1977
|
+
label: undefined,
|
|
1978
|
+
children: undefined,
|
|
1979
|
+
placement: 'bottom-start',
|
|
1980
|
+
disabled: undefined,
|
|
1981
|
+
kind: undefined,
|
|
1982
|
+
menuItemIndex: undefined,
|
|
1983
|
+
portalTarget: undefined,
|
|
1984
|
+
maxHeight: undefined
|
|
1985
|
+
};
|
|
1986
|
+
|
|
1987
|
+
var FormField = React__default.forwardRef(function (props, ref) {
|
|
1988
|
+
var styles = useStyles('FormFieldStyles');
|
|
1989
|
+
var className = props.className,
|
|
1990
|
+
children = props.children,
|
|
1991
|
+
errorText = props.errorText,
|
|
1992
|
+
helperText = props.helperText;
|
|
1993
|
+
return React__default.createElement("div", {
|
|
1994
|
+
className: className,
|
|
1995
|
+
ref: ref
|
|
1996
|
+
}, children, helperText ? React__default.createElement(Caption, {
|
|
1997
|
+
className: styles.caption,
|
|
1998
|
+
type: "helper"
|
|
1999
|
+
}, helperText) : null, errorText ? React__default.createElement(Caption, {
|
|
2000
|
+
className: styles.caption,
|
|
2001
|
+
type: "error"
|
|
2002
|
+
}, errorText) : null);
|
|
2003
|
+
});
|
|
2004
|
+
FormField.propTypes = {
|
|
2005
|
+
className: PropTypes.string,
|
|
2006
|
+
children: PropTypes.any,
|
|
2007
|
+
errorText: PropTypes.string,
|
|
2008
|
+
helperText: PropTypes.string
|
|
2009
|
+
};
|
|
2010
|
+
FormField.defaultProps = {
|
|
2011
|
+
className: null,
|
|
2012
|
+
children: null,
|
|
2013
|
+
errorText: null,
|
|
2014
|
+
helperText: null
|
|
2015
|
+
};
|
|
2016
|
+
|
|
2017
|
+
var TextField = React__default.forwardRef(function (props, ref) {
|
|
2018
|
+
var styles = useStyles('TextFieldStyles');
|
|
2019
|
+
var ariaLabel = props.ariaLabel,
|
|
2020
|
+
autoComplete = props.autoComplete,
|
|
2021
|
+
className = props.className,
|
|
2022
|
+
disabled = props.disabled,
|
|
2023
|
+
errorText = props.errorText,
|
|
2024
|
+
full = props.full,
|
|
2025
|
+
helperText = props.helperText,
|
|
2026
|
+
id = props.id,
|
|
2027
|
+
invalid = props.invalid,
|
|
2028
|
+
label = props.label,
|
|
2029
|
+
multiline = props.multiline,
|
|
2030
|
+
onBlur = props.onBlur,
|
|
2031
|
+
onChange = props.onChange,
|
|
2032
|
+
placeholder = props.placeholder,
|
|
2033
|
+
rows = props.rows,
|
|
2034
|
+
small = props.small,
|
|
2035
|
+
style = props.style,
|
|
2036
|
+
type = props.type,
|
|
2037
|
+
value = props.value;
|
|
2038
|
+
var classes = classNames(className, styles['text-field'], _defineProperty({}, styles.full, full));
|
|
2039
|
+
var labelClasses = classNames(styles.label, _defineProperty({}, styles.full, full));
|
|
2040
|
+
var InputComponent = React__default.createElement(Input, {
|
|
2041
|
+
ariaLabel: ariaLabel,
|
|
2042
|
+
autoComplete: autoComplete,
|
|
2043
|
+
disabled: disabled,
|
|
2044
|
+
full: full,
|
|
2045
|
+
id: id,
|
|
2046
|
+
invalid: invalid,
|
|
2047
|
+
multiline: multiline,
|
|
2048
|
+
onBlur: onBlur,
|
|
2049
|
+
onChange: onChange,
|
|
2050
|
+
placeholder: placeholder,
|
|
2051
|
+
ref: ref,
|
|
2052
|
+
rows: rows,
|
|
2053
|
+
small: small,
|
|
2054
|
+
type: type,
|
|
2055
|
+
value: value
|
|
2056
|
+
});
|
|
2057
|
+
return React__default.createElement(FormField, {
|
|
2058
|
+
className: classes,
|
|
2059
|
+
style: style,
|
|
2060
|
+
helperText: helperText,
|
|
2061
|
+
errorText: errorText
|
|
2062
|
+
}, label ? React__default.createElement(Label, {
|
|
2063
|
+
htmlFor: id,
|
|
2064
|
+
className: labelClasses
|
|
2065
|
+
}, label, InputComponent) : InputComponent);
|
|
2066
|
+
});
|
|
2067
|
+
TextField.propTypes = {
|
|
2068
|
+
ariaLabel: PropTypes.string,
|
|
2069
|
+
autoComplete: PropTypes.string,
|
|
2070
|
+
className: PropTypes.string,
|
|
2071
|
+
disabled: PropTypes.bool,
|
|
2072
|
+
errorText: PropTypes.string,
|
|
2073
|
+
full: PropTypes.bool,
|
|
2074
|
+
helperText: PropTypes.string,
|
|
2075
|
+
id: PropTypes.string,
|
|
2076
|
+
invalid: PropTypes.bool,
|
|
2077
|
+
label: PropTypes.string,
|
|
2078
|
+
multiline: PropTypes.bool,
|
|
2079
|
+
onBlur: PropTypes.func,
|
|
2080
|
+
onChange: PropTypes.func,
|
|
2081
|
+
placeholder: PropTypes.string,
|
|
2082
|
+
rows: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
2083
|
+
small: PropTypes.bool,
|
|
2084
|
+
style: PropTypes.object,
|
|
2085
|
+
type: PropTypes.oneOf(InputTypes),
|
|
2086
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
2087
|
+
};
|
|
2088
|
+
TextField.defaultProps = {
|
|
2089
|
+
ariaLabel: null,
|
|
2090
|
+
autoComplete: null,
|
|
2091
|
+
className: null,
|
|
2092
|
+
disabled: false,
|
|
2093
|
+
errorText: null,
|
|
2094
|
+
full: false,
|
|
2095
|
+
helperText: null,
|
|
2096
|
+
id: null,
|
|
2097
|
+
invalid: false,
|
|
2098
|
+
label: null,
|
|
2099
|
+
multiline: false,
|
|
2100
|
+
onBlur: null,
|
|
2101
|
+
onChange: null,
|
|
2102
|
+
placeholder: null,
|
|
2103
|
+
rows: null,
|
|
2104
|
+
small: false,
|
|
2105
|
+
style: {},
|
|
2106
|
+
type: null,
|
|
2107
|
+
value: undefined
|
|
2108
|
+
};
|
|
2109
|
+
|
|
2110
|
+
var InputGroup = React__default.forwardRef(function (props, ref) {
|
|
2111
|
+
var styles = useStyles('InputGroupStyles');
|
|
2112
|
+
var children = props.children,
|
|
2113
|
+
className = props.className,
|
|
2114
|
+
full = props.full,
|
|
2115
|
+
small = props.small;
|
|
2116
|
+
return React__default.createElement("span", {
|
|
2117
|
+
ref: ref,
|
|
2118
|
+
className: classNames(className, styles.inputGroup, _defineProperty({}, styles.full, full))
|
|
2119
|
+
}, React__default.Children.map(children, function (child) {
|
|
2120
|
+
var _classNames2;
|
|
2121
|
+
|
|
2122
|
+
if (!React__default.isValidElement(child)) {
|
|
2123
|
+
return null;
|
|
2124
|
+
}
|
|
2125
|
+
|
|
2126
|
+
return React__default.cloneElement(child, {
|
|
2127
|
+
className: classNames(child.props.className, styles.inputGroupElement, (_classNames2 = {}, _defineProperty(_classNames2, styles.full, full && child.type === Input), _defineProperty(_classNames2, styles.small, small), _classNames2)),
|
|
2128
|
+
full: false,
|
|
2129
|
+
small: small
|
|
2130
|
+
});
|
|
2131
|
+
}));
|
|
2132
|
+
});
|
|
2133
|
+
InputGroup.defaultProps = {
|
|
2134
|
+
children: null,
|
|
2135
|
+
className: null,
|
|
2136
|
+
full: null,
|
|
2137
|
+
small: null
|
|
2138
|
+
};
|
|
2139
|
+
InputGroup.propTypes = {
|
|
2140
|
+
children: PropTypes.any,
|
|
2141
|
+
className: PropTypes.string,
|
|
2142
|
+
full: PropTypes.bool,
|
|
2143
|
+
small: PropTypes.bool
|
|
2144
|
+
};
|
|
2145
|
+
|
|
2146
|
+
var InputGroupAddon = function InputGroupAddon(props) {
|
|
2147
|
+
var styles = useStyles('InputGroupStyles');
|
|
2148
|
+
var children = props.children,
|
|
2149
|
+
className = props.className,
|
|
2150
|
+
small = props.small;
|
|
2151
|
+
return React__default.createElement("span", {
|
|
2152
|
+
className: classNames(className, styles.addon, _defineProperty({}, styles.small, small))
|
|
2153
|
+
}, children);
|
|
2154
|
+
};
|
|
2155
|
+
|
|
2156
|
+
InputGroupAddon.defaultProps = {
|
|
2157
|
+
children: null,
|
|
2158
|
+
className: null,
|
|
2159
|
+
small: false
|
|
2160
|
+
};
|
|
2161
|
+
InputGroupAddon.propTypes = {
|
|
2162
|
+
children: PropTypes.any,
|
|
2163
|
+
className: PropTypes.string,
|
|
2164
|
+
small: PropTypes.bool
|
|
2165
|
+
};
|
|
2166
|
+
|
|
2167
|
+
var InlineInput = React__default.forwardRef(function (props, _ref) {
|
|
2168
|
+
var styles = useStyles('InlineInputStyles');
|
|
2169
|
+
var ariaLabel = props.ariaLabel,
|
|
2170
|
+
className = props.className,
|
|
2171
|
+
defaultValue = props.defaultValue,
|
|
2172
|
+
id = props.id,
|
|
2173
|
+
onChange = props.onChange,
|
|
2174
|
+
onBlur = props.onBlur;
|
|
2175
|
+
var internalRef = React__default.useRef(null);
|
|
2176
|
+
|
|
2177
|
+
var _React$useState = React__default.useState(defaultValue),
|
|
2178
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
2179
|
+
lastVal = _React$useState2[0],
|
|
2180
|
+
setLastVal = _React$useState2[1];
|
|
2181
|
+
|
|
2182
|
+
var changeHandler = function changeHandler(e) {
|
|
2183
|
+
if (typeof onChange === 'function') {
|
|
2184
|
+
var newVal = e.target.innerText;
|
|
2185
|
+
|
|
2186
|
+
if (newVal !== lastVal) {
|
|
2187
|
+
e.target.value = newVal;
|
|
2188
|
+
onChange(e);
|
|
2189
|
+
setLastVal(newVal);
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
};
|
|
2193
|
+
|
|
2194
|
+
var blurHandler = function blurHandler(e) {
|
|
2195
|
+
if (typeof onBlur === 'function') {
|
|
2196
|
+
e.target.value = e.target.innerText;
|
|
2197
|
+
onBlur(e);
|
|
2198
|
+
}
|
|
2199
|
+
};
|
|
2200
|
+
|
|
2201
|
+
return React__default.createElement("span", {
|
|
2202
|
+
"aria-label": ariaLabel,
|
|
2203
|
+
className: classNames(className, styles.inlineInput),
|
|
2204
|
+
contentEditable: true,
|
|
2205
|
+
suppressContentEditableWarning: true,
|
|
2206
|
+
id: id,
|
|
2207
|
+
onBlur: blurHandler,
|
|
2208
|
+
onKeyDown: function onKeyDown(e) {
|
|
2209
|
+
if (e.key === 'Enter' || e.key === 'Escape') {
|
|
2210
|
+
e.preventDefault();
|
|
2211
|
+
internalRef.current.blur();
|
|
2212
|
+
}
|
|
2213
|
+
},
|
|
2214
|
+
onInput: changeHandler,
|
|
2215
|
+
onFocus: function onFocus() {
|
|
2216
|
+
setTimeout(function () {
|
|
2217
|
+
var range = document.createRange();
|
|
2218
|
+
range.selectNodeContents(internalRef.current);
|
|
2219
|
+
var sel = window.getSelection();
|
|
2220
|
+
sel.removeAllRanges();
|
|
2221
|
+
sel.addRange(range);
|
|
2222
|
+
});
|
|
2223
|
+
},
|
|
2224
|
+
ref: function ref(node) {
|
|
2225
|
+
internalRef.current = node;
|
|
2226
|
+
assignRef(_ref, node);
|
|
2227
|
+
},
|
|
2228
|
+
role: "textbox",
|
|
2229
|
+
tabIndex: 0
|
|
2230
|
+
}, defaultValue);
|
|
2231
|
+
});
|
|
2232
|
+
InlineInput.defaultProps = {
|
|
2233
|
+
ariaLabel: null,
|
|
2234
|
+
defaultValue: null,
|
|
2235
|
+
className: null,
|
|
2236
|
+
id: null,
|
|
2237
|
+
onBlur: null,
|
|
2238
|
+
onChange: null
|
|
2239
|
+
};
|
|
2240
|
+
InlineInput.propTypes = {
|
|
2241
|
+
ariaLabel: PropTypes.string,
|
|
2242
|
+
className: PropTypes.string,
|
|
2243
|
+
defaultValue: PropTypes.string,
|
|
2244
|
+
id: PropTypes.string,
|
|
2245
|
+
onBlur: PropTypes.func,
|
|
2246
|
+
onChange: PropTypes.func
|
|
2247
|
+
};
|
|
2248
|
+
|
|
2249
|
+
var Tooltip = React__default.forwardRef(function Tooltip(_ref, ref) {
|
|
2250
|
+
var content = _ref.content,
|
|
2251
|
+
placement = _ref.placement,
|
|
2252
|
+
children = _ref.children,
|
|
2253
|
+
disabled = _ref.disabled,
|
|
2254
|
+
delayMs = _ref.delayMs,
|
|
2255
|
+
zIndex = _ref.zIndex,
|
|
2256
|
+
className = _ref.className,
|
|
2257
|
+
portalTarget = _ref.portalTarget;
|
|
2258
|
+
var styles = useStyles('TooltipStyles');
|
|
2259
|
+
|
|
2260
|
+
var _useState = React.useState(false),
|
|
2261
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2262
|
+
show = _useState2[0],
|
|
2263
|
+
setShow = _useState2[1];
|
|
2264
|
+
|
|
2265
|
+
var timer;
|
|
2266
|
+
|
|
2267
|
+
function onMouseEnter() {
|
|
2268
|
+
if (!disabled) {
|
|
2269
|
+
timer = setTimeout(function () {
|
|
2270
|
+
return setShow(true);
|
|
2271
|
+
}, delayMs);
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
function onMouseLeave() {
|
|
2276
|
+
clearTimeout(timer);
|
|
2277
|
+
setShow(false);
|
|
2278
|
+
}
|
|
2279
|
+
|
|
2280
|
+
var anchor = React__default.cloneElement(children, {
|
|
2281
|
+
onMouseEnter: onMouseEnter,
|
|
2282
|
+
onMouseLeave: onMouseLeave
|
|
2283
|
+
});
|
|
2284
|
+
var tooltipClasses = classNames(styles.tooltip, className);
|
|
2285
|
+
return React__default.createElement(Popper, {
|
|
2286
|
+
open: show,
|
|
2287
|
+
anchor: anchor,
|
|
2288
|
+
portalTarget: portalTarget,
|
|
2289
|
+
placement: placement,
|
|
2290
|
+
popperRef: ref
|
|
2291
|
+
}, function (_ref2) {
|
|
2292
|
+
var ref = _ref2.ref,
|
|
2293
|
+
style = _ref2.style,
|
|
2294
|
+
placement = _ref2.placement,
|
|
2295
|
+
arrowProps = _ref2.arrowProps;
|
|
2296
|
+
return React__default.createElement("div", {
|
|
2297
|
+
className: tooltipClasses,
|
|
2298
|
+
ref: ref,
|
|
2299
|
+
style: _objectSpread2({}, style, {
|
|
2300
|
+
zIndex: zIndex
|
|
2301
|
+
}),
|
|
2302
|
+
"data-placement": placement
|
|
2303
|
+
}, content, React__default.createElement("div", {
|
|
2304
|
+
className: "".concat(styles.arrow),
|
|
2305
|
+
ref: arrowProps.ref,
|
|
2306
|
+
style: _objectSpread2({}, arrowProps.style)
|
|
2307
|
+
}));
|
|
2308
|
+
});
|
|
2309
|
+
});
|
|
2310
|
+
Tooltip.propTypes = {
|
|
2311
|
+
children: PropTypes.element.isRequired,
|
|
2312
|
+
content: PropTypes.element,
|
|
2313
|
+
placement: PropTypes.oneOf(reactPopper.placements),
|
|
2314
|
+
delayMs: PropTypes.number,
|
|
2315
|
+
zIndex: PropTypes.number,
|
|
2316
|
+
disabled: PropTypes.bool,
|
|
2317
|
+
portalTarget: PropTypes.instanceOf(Element),
|
|
2318
|
+
className: PropTypes.string
|
|
2319
|
+
};
|
|
2320
|
+
Tooltip.defaultProps = {
|
|
2321
|
+
content: undefined,
|
|
2322
|
+
placement: 'top',
|
|
2323
|
+
delayMs: 0,
|
|
2324
|
+
zIndex: 2000,
|
|
2325
|
+
disabled: false,
|
|
2326
|
+
portalTarget: undefined,
|
|
2327
|
+
className: undefined
|
|
2328
|
+
};
|
|
2329
|
+
|
|
2330
|
+
var Popover = React__default.forwardRef(function Popover(_ref, ref) {
|
|
2331
|
+
var show = _ref.show,
|
|
2332
|
+
content = _ref.content,
|
|
2333
|
+
placement = _ref.placement,
|
|
2334
|
+
anchor = _ref.children,
|
|
2335
|
+
zIndex = _ref.zIndex,
|
|
2336
|
+
className = _ref.className,
|
|
2337
|
+
portalTarget = _ref.portalTarget;
|
|
2338
|
+
var styles = useStyles('PopoverStyles');
|
|
2339
|
+
var classes = classNames(styles.popover, className);
|
|
2340
|
+
return React__default.createElement(Popper, {
|
|
2341
|
+
open: show,
|
|
2342
|
+
anchor: anchor,
|
|
2343
|
+
portalTarget: portalTarget,
|
|
2344
|
+
placement: placement,
|
|
2345
|
+
popperRef: ref
|
|
2346
|
+
}, function (_ref2) {
|
|
2347
|
+
var ref = _ref2.ref,
|
|
2348
|
+
style = _ref2.style,
|
|
2349
|
+
placement = _ref2.placement,
|
|
2350
|
+
arrowProps = _ref2.arrowProps;
|
|
2351
|
+
return React__default.createElement("div", {
|
|
2352
|
+
className: classes,
|
|
2353
|
+
ref: ref,
|
|
2354
|
+
style: _objectSpread2({}, style, {
|
|
2355
|
+
zIndex: zIndex
|
|
2356
|
+
}),
|
|
2357
|
+
"data-placement": placement
|
|
2358
|
+
}, content, React__default.createElement("div", {
|
|
2359
|
+
className: "".concat(styles.arrow),
|
|
2360
|
+
ref: arrowProps.ref,
|
|
2361
|
+
style: _objectSpread2({}, arrowProps.style)
|
|
2362
|
+
}));
|
|
2363
|
+
});
|
|
2364
|
+
});
|
|
2365
|
+
Popover.propTypes = {
|
|
2366
|
+
children: PropTypes.element.isRequired,
|
|
2367
|
+
content: PropTypes.element,
|
|
2368
|
+
show: PropTypes.bool,
|
|
2369
|
+
placement: PropTypes.oneOf(reactPopper.placements),
|
|
2370
|
+
zIndex: PropTypes.number,
|
|
2371
|
+
portalTarget: PropTypes.instanceOf(Element),
|
|
2372
|
+
className: PropTypes.string
|
|
2373
|
+
};
|
|
2374
|
+
Popover.defaultProps = {
|
|
2375
|
+
content: undefined,
|
|
2376
|
+
show: false,
|
|
2377
|
+
placement: 'top',
|
|
2378
|
+
zIndex: 1000,
|
|
2379
|
+
portalTarget: undefined,
|
|
2380
|
+
className: undefined
|
|
2381
|
+
};
|
|
2382
|
+
|
|
2383
|
+
var ButtonGroup = React__default.forwardRef(function ButtonGroup(props, ref) {
|
|
2384
|
+
var styles = useStyles('ButtonGroupStyles');
|
|
2385
|
+
var children = props.children,
|
|
2386
|
+
className = props.className,
|
|
2387
|
+
full = props.full,
|
|
2388
|
+
small = props.small;
|
|
2389
|
+
var contextValue = React__default.useMemo(function () {
|
|
2390
|
+
return {
|
|
2391
|
+
isInsideButtonGroup: true,
|
|
2392
|
+
full: full,
|
|
2393
|
+
small: small
|
|
2394
|
+
};
|
|
2395
|
+
}, [full, small]);
|
|
2396
|
+
return React__default.createElement("span", {
|
|
2397
|
+
ref: ref,
|
|
2398
|
+
className: classNames(className, styles.buttonGroup, _defineProperty({}, styles.full, full))
|
|
2399
|
+
}, React__default.createElement(ButtonGroupContextProvider, {
|
|
2400
|
+
value: contextValue
|
|
2401
|
+
}, children));
|
|
2402
|
+
});
|
|
2403
|
+
ButtonGroup.defaultProps = {
|
|
2404
|
+
children: null,
|
|
2405
|
+
className: null,
|
|
2406
|
+
full: null,
|
|
2407
|
+
small: null
|
|
2408
|
+
};
|
|
2409
|
+
ButtonGroup.propTypes = {
|
|
2410
|
+
children: PropTypes.any,
|
|
2411
|
+
className: PropTypes.string,
|
|
2412
|
+
full: PropTypes.bool,
|
|
2413
|
+
small: PropTypes.bool
|
|
2414
|
+
};
|
|
2415
|
+
|
|
2416
|
+
var backgrounds = ['hide', 'fade', 'show'];
|
|
2417
|
+
var sizes = ['small', 'medium', 'large'];
|
|
2418
|
+
var Spinner = React__default.forwardRef(function Spinner(props, ref) {
|
|
2419
|
+
var styles = useStyles('SpinnerStyles');
|
|
2420
|
+
|
|
2421
|
+
var background = props.background,
|
|
2422
|
+
children = props.children,
|
|
2423
|
+
className = props.className,
|
|
2424
|
+
id = props.id,
|
|
2425
|
+
inverted = props.inverted,
|
|
2426
|
+
show = props.show,
|
|
2427
|
+
size = props.size,
|
|
2428
|
+
style = props.style,
|
|
2429
|
+
testId = props.testId,
|
|
2430
|
+
other = _objectWithoutProperties(props, ["background", "children", "className", "id", "inverted", "show", "size", "style", "testId"]);
|
|
2431
|
+
|
|
2432
|
+
return React__default.createElement("div", _extends({
|
|
2433
|
+
ref: ref,
|
|
2434
|
+
id: id,
|
|
2435
|
+
style: style,
|
|
2436
|
+
className: classNames(styles.spinnerContainer, _defineProperty({}, styles[size], !children)),
|
|
2437
|
+
"data-testid": testId
|
|
2438
|
+
}, other), show && React__default.createElement("div", {
|
|
2439
|
+
className: classNames(styles.spinnerComponent, styles[size], _defineProperty({}, styles.inverted, inverted))
|
|
2440
|
+
}, React__default.createElement("div", null, React__default.createElement("div", null), React__default.createElement("div", null), React__default.createElement("div", null), React__default.createElement("div", null), React__default.createElement("div", null), React__default.createElement("div", null), React__default.createElement("div", null), React__default.createElement("div", null), React__default.createElement("div", null))), React__default.createElement("div", {
|
|
2441
|
+
className: classNames(styles.spinnerContent, _defineProperty({}, styles[background], show))
|
|
2442
|
+
}, children));
|
|
2443
|
+
});
|
|
2444
|
+
Spinner.propTypes = {
|
|
2445
|
+
background: PropTypes.oneOf(backgrounds),
|
|
2446
|
+
children: PropTypes.oneOfType([PropTypes.element, PropTypes.string]),
|
|
2447
|
+
className: PropTypes.string,
|
|
2448
|
+
id: PropTypes.string,
|
|
2449
|
+
inverted: PropTypes.bool,
|
|
2450
|
+
show: PropTypes.bool,
|
|
2451
|
+
size: PropTypes.oneOf(sizes),
|
|
2452
|
+
style: PropTypes.object,
|
|
2453
|
+
testId: PropTypes.string
|
|
2454
|
+
};
|
|
2455
|
+
Spinner.defaultProps = {
|
|
2456
|
+
background: 'fade',
|
|
2457
|
+
children: undefined,
|
|
2458
|
+
className: undefined,
|
|
2459
|
+
id: undefined,
|
|
2460
|
+
inverted: false,
|
|
2461
|
+
show: false,
|
|
2462
|
+
size: 'medium',
|
|
2463
|
+
style: undefined,
|
|
2464
|
+
testId: undefined
|
|
2465
|
+
};
|
|
2466
|
+
|
|
2467
|
+
function createStyledComponent(displayName, stylesNamespace, className) {
|
|
2468
|
+
var NewComponent = React__default.forwardRef(function (_ref, ref) {
|
|
2469
|
+
var children = _ref.children,
|
|
2470
|
+
userClassname = _ref.className,
|
|
2471
|
+
testId = _ref.testId,
|
|
2472
|
+
restProps = _objectWithoutProperties(_ref, ["children", "className", "testId"]);
|
|
2473
|
+
|
|
2474
|
+
var styles = useStyles(stylesNamespace);
|
|
2475
|
+
var classes = classNames(styles[className], userClassname);
|
|
2476
|
+
return React__default.createElement("div", _extends({
|
|
2477
|
+
ref: ref,
|
|
2478
|
+
"data-testid": testId,
|
|
2479
|
+
className: classes
|
|
2480
|
+
}, restProps), children);
|
|
2481
|
+
});
|
|
2482
|
+
NewComponent.displayName = displayName;
|
|
2483
|
+
NewComponent.propTypes = {
|
|
2484
|
+
className: PropTypes.string,
|
|
2485
|
+
children: PropTypes.any,
|
|
2486
|
+
testId: PropTypes.string
|
|
2487
|
+
};
|
|
2488
|
+
NewComponent.defaultProps = {
|
|
2489
|
+
className: undefined,
|
|
2490
|
+
children: undefined,
|
|
2491
|
+
testId: undefined
|
|
2492
|
+
};
|
|
2493
|
+
return NewComponent;
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2496
|
+
var Modal = function Modal(_ref) {
|
|
2497
|
+
var open = _ref.open,
|
|
2498
|
+
children = _ref.children,
|
|
2499
|
+
zIndex = _ref.zIndex,
|
|
2500
|
+
portalTarget = _ref.portalTarget,
|
|
2501
|
+
testId = _ref.testId,
|
|
2502
|
+
restProps = _objectWithoutProperties(_ref, ["open", "children", "zIndex", "portalTarget", "testId"]);
|
|
2503
|
+
|
|
2504
|
+
var _React$useState = React__default.useState(open),
|
|
2505
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
2506
|
+
isInDOM = _React$useState2[0],
|
|
2507
|
+
setIsInDOM = _React$useState2[1];
|
|
2508
|
+
|
|
2509
|
+
React.useEffect(function () {
|
|
2510
|
+
open && setIsInDOM(true);
|
|
2511
|
+
}, [open]);
|
|
2512
|
+
return isInDOM && React__default.createElement(Portal, {
|
|
2513
|
+
portalTarget: portalTarget
|
|
2514
|
+
}, React__default.createElement(Overlay, {
|
|
2515
|
+
open: open,
|
|
2516
|
+
zIndex: zIndex,
|
|
2517
|
+
onAnimationEnd: function onAnimationEnd() {
|
|
2518
|
+
return !open && setIsInDOM(false);
|
|
2519
|
+
}
|
|
2520
|
+
}, React__default.createElement(Dialog, _extends({
|
|
2521
|
+
open: open,
|
|
2522
|
+
testId: testId
|
|
2523
|
+
}, restProps), children)));
|
|
2524
|
+
};
|
|
2525
|
+
|
|
2526
|
+
Modal.propTypes = {
|
|
2527
|
+
open: PropTypes.bool,
|
|
2528
|
+
className: PropTypes.string,
|
|
2529
|
+
children: PropTypes.any,
|
|
2530
|
+
zIndex: PropTypes.number,
|
|
2531
|
+
portalTarget: PropTypes.instanceOf(Element),
|
|
2532
|
+
testId: PropTypes.string
|
|
2533
|
+
};
|
|
2534
|
+
Modal.defaultProps = {
|
|
2535
|
+
open: false,
|
|
2536
|
+
className: undefined,
|
|
2537
|
+
children: undefined,
|
|
2538
|
+
zIndex: 1050,
|
|
2539
|
+
portalTarget: undefined,
|
|
2540
|
+
testId: undefined
|
|
2541
|
+
};
|
|
2542
|
+
|
|
2543
|
+
var Overlay = function Overlay(_ref2) {
|
|
2544
|
+
var _classNames;
|
|
2545
|
+
|
|
2546
|
+
var open = _ref2.open,
|
|
2547
|
+
zIndex = _ref2.zIndex,
|
|
2548
|
+
children = _ref2.children,
|
|
2549
|
+
onAnimationEnd = _ref2.onAnimationEnd;
|
|
2550
|
+
var styles = useStyles('ModalStyles');
|
|
2551
|
+
var overlayClasses = classNames(styles.backdrop, (_classNames = {}, _defineProperty(_classNames, styles.fadeEnter, open), _defineProperty(_classNames, styles.fadeLeave, !open), _classNames));
|
|
2552
|
+
return React__default.createElement("div", {
|
|
2553
|
+
className: overlayClasses,
|
|
2554
|
+
onAnimationEnd: onAnimationEnd,
|
|
2555
|
+
style: {
|
|
2556
|
+
zIndex: zIndex
|
|
2557
|
+
}
|
|
2558
|
+
}, children, React__default.createElement("style", null, "body { overflow: hidden; }"));
|
|
2559
|
+
};
|
|
2560
|
+
|
|
2561
|
+
Overlay.propTypes = {
|
|
2562
|
+
open: PropTypes.bool,
|
|
2563
|
+
zIndex: PropTypes.number,
|
|
2564
|
+
children: PropTypes.any,
|
|
2565
|
+
onAnimationEnd: PropTypes.func
|
|
2566
|
+
};
|
|
2567
|
+
Overlay.defaultProps = {
|
|
2568
|
+
open: false,
|
|
2569
|
+
zIndex: undefined,
|
|
2570
|
+
children: undefined,
|
|
2571
|
+
onAnimationEnd: undefined
|
|
2572
|
+
};
|
|
2573
|
+
|
|
2574
|
+
var Dialog = function Dialog(_ref3) {
|
|
2575
|
+
var _classNames2;
|
|
2576
|
+
|
|
2577
|
+
var open = _ref3.open,
|
|
2578
|
+
children = _ref3.children,
|
|
2579
|
+
className = _ref3.className,
|
|
2580
|
+
testId = _ref3.testId,
|
|
2581
|
+
restProps = _objectWithoutProperties(_ref3, ["open", "children", "className", "testId"]);
|
|
2582
|
+
|
|
2583
|
+
var styles = useStyles('ModalStyles');
|
|
2584
|
+
var modalClasses = classNames(styles.modal, className, (_classNames2 = {}, _defineProperty(_classNames2, styles.zoomEnter, open), _defineProperty(_classNames2, styles.zoomLeave, !open), _classNames2));
|
|
2585
|
+
return React__default.createElement("div", _extends({
|
|
2586
|
+
className: modalClasses,
|
|
2587
|
+
"data-testid": testId
|
|
2588
|
+
}, restProps), children);
|
|
2589
|
+
};
|
|
2590
|
+
|
|
2591
|
+
Dialog.propTypes = {
|
|
2592
|
+
open: PropTypes.bool,
|
|
2593
|
+
className: PropTypes.string,
|
|
2594
|
+
children: PropTypes.any,
|
|
2595
|
+
testId: PropTypes.string
|
|
2596
|
+
};
|
|
2597
|
+
Dialog.defaultProps = {
|
|
2598
|
+
open: false,
|
|
2599
|
+
className: undefined,
|
|
2600
|
+
children: undefined,
|
|
2601
|
+
testId: undefined
|
|
2602
|
+
};
|
|
2603
|
+
var ModalHeader = createStyledComponent('ModalHeader', 'ModalStyles', 'modalHeader');
|
|
2604
|
+
var ModalBody = createStyledComponent('ModalBody', 'ModalStyles', 'modalBody');
|
|
2605
|
+
var ModalFooter = createStyledComponent('ModalFooter', 'ModalStyles', 'modalFooter');
|
|
2606
|
+
|
|
2607
|
+
function UIProvider(_ref) {
|
|
2608
|
+
var children = _ref.children;
|
|
2609
|
+
var styleOverrides = React.useMemo(function () {
|
|
2610
|
+
return componentStyles.getStyleOverridesStore();
|
|
2611
|
+
}, []);
|
|
2612
|
+
|
|
2613
|
+
var _useState = React.useState(function () {
|
|
2614
|
+
// use styles overrides if available, otherwise use built-in styles
|
|
2615
|
+
return styleOverrides.get() || componentStyles.styles;
|
|
2616
|
+
}),
|
|
2617
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2618
|
+
styles = _useState2[0],
|
|
2619
|
+
setStyles = _useState2[1]; // subscribe to changes to styles overrides
|
|
2620
|
+
|
|
2621
|
+
|
|
2622
|
+
React.useEffect(function () {
|
|
2623
|
+
var unsubscribe = styleOverrides.subscribe(function () {
|
|
2624
|
+
setStyles(styleOverrides.get() || componentStyles.styles);
|
|
2625
|
+
});
|
|
2626
|
+
return function () {
|
|
2627
|
+
return unsubscribe();
|
|
2628
|
+
};
|
|
2629
|
+
}, [styleOverrides]);
|
|
2630
|
+
return React__default.createElement(UIContext.Provider, {
|
|
2631
|
+
value: styles
|
|
2632
|
+
}, children);
|
|
2633
|
+
}
|
|
2634
|
+
|
|
2635
|
+
UIProvider.propTypes = {
|
|
2636
|
+
children: PropTypes.any
|
|
2637
|
+
};
|
|
2638
|
+
UIProvider.defaultProps = {
|
|
2639
|
+
children: undefined
|
|
2640
|
+
};
|
|
2641
|
+
|
|
2642
|
+
exports.Button = Button;
|
|
2643
|
+
exports.ButtonGroup = ButtonGroup;
|
|
2644
|
+
exports.Caption = Caption;
|
|
2645
|
+
exports.Checkbox = Checkbox;
|
|
2646
|
+
exports.FilePicker = FilePicker;
|
|
2647
|
+
exports.FormField = FormField;
|
|
2648
|
+
exports.Icon = Icon;
|
|
2649
|
+
exports.IconTypes = IconTypes;
|
|
2650
|
+
exports.InlineInput = InlineInput;
|
|
2651
|
+
exports.Input = Input;
|
|
2652
|
+
exports.InputGroup = InputGroup;
|
|
2653
|
+
exports.InputGroupAddon = InputGroupAddon;
|
|
2654
|
+
exports.Label = Label;
|
|
2655
|
+
exports.Link = Link;
|
|
2656
|
+
exports.Menu = Menu;
|
|
2657
|
+
exports.MenuItem = MenuItem;
|
|
2658
|
+
exports.Modal = Modal;
|
|
2659
|
+
exports.ModalBody = ModalBody;
|
|
2660
|
+
exports.ModalFooter = ModalFooter;
|
|
2661
|
+
exports.ModalHeader = ModalHeader;
|
|
2662
|
+
exports.Popover = Popover;
|
|
2663
|
+
exports.Radio = Radio;
|
|
2664
|
+
exports.RadioGroup = RadioGroup;
|
|
2665
|
+
exports.SelectMenu = SelectMenu;
|
|
2666
|
+
exports.Spinner = Spinner;
|
|
2667
|
+
exports.Switch = Switch;
|
|
2668
|
+
exports.Tab = Tab;
|
|
2669
|
+
exports.Table = Table;
|
|
2670
|
+
exports.TableBody = TableBody;
|
|
2671
|
+
exports.TableCell = TableCell;
|
|
2672
|
+
exports.TableHead = TableHead;
|
|
2673
|
+
exports.TableHeaderCell = TableHeaderCell;
|
|
2674
|
+
exports.TableRow = TableRow;
|
|
2675
|
+
exports.Tabs = Tabs;
|
|
2676
|
+
exports.TextField = TextField;
|
|
2677
|
+
exports.Tooltip = Tooltip;
|
|
2678
|
+
exports.UIProvider = UIProvider;
|
|
2679
|
+
exports.version = version;
|