baseui 11.0.0 → 11.0.3
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/data-table/data-table.js +9 -1
- package/data-table/data-table.js.flow +3 -0
- package/data-table/index.d.ts +7 -8
- package/data-table/stateful-data-table.js +2 -1
- package/data-table/stateful-data-table.js.flow +1 -0
- package/data-table/types.js.flow +8 -0
- package/datepicker/calendar.js +16 -11
- package/datepicker/calendar.js.flow +12 -9
- package/datepicker/datepicker.js +58 -58
- package/datepicker/datepicker.js.flow +51 -34
- package/datepicker/stateful-calendar.js +6 -1
- package/datepicker/stateful-calendar.js.flow +8 -1
- package/datepicker/stateful-container.js +23 -2
- package/datepicker/stateful-container.js.flow +17 -4
- package/datepicker/stateful-datepicker.js +6 -1
- package/datepicker/stateful-datepicker.js.flow +7 -1
- package/datepicker/types.js.flow +21 -43
- package/es/data-table/data-table.js +5 -1
- package/es/data-table/stateful-data-table.js +2 -1
- package/es/datepicker/calendar.js +15 -10
- package/es/datepicker/datepicker.js +52 -52
- package/es/datepicker/stateful-calendar.js +6 -1
- package/es/datepicker/stateful-container.js +22 -2
- package/es/datepicker/stateful-datepicker.js +6 -1
- package/es/form-control/styled-components.js +0 -1
- package/es/list/list-item.js +5 -1
- package/es/list/menu-adapter.js +4 -0
- package/es/select/select-component.js +22 -12
- package/es/select/styled-components.js +17 -13
- package/es/select/utils/default-filter-options.js +1 -1
- package/es/snackbar/snackbar-context.js +1 -1
- package/esm/data-table/data-table.js +9 -1
- package/esm/data-table/stateful-data-table.js +2 -1
- package/esm/datepicker/calendar.js +16 -11
- package/esm/datepicker/datepicker.js +58 -58
- package/esm/datepicker/stateful-calendar.js +6 -1
- package/esm/datepicker/stateful-container.js +23 -2
- package/esm/datepicker/stateful-datepicker.js +6 -1
- package/esm/form-control/styled-components.js +0 -1
- package/esm/list/list-item.js +5 -1
- package/esm/list/menu-adapter.js +4 -0
- package/esm/select/select-component.js +22 -12
- package/esm/select/styled-components.js +17 -10
- package/esm/select/utils/default-filter-options.js +1 -1
- package/esm/snackbar/snackbar-context.js +1 -1
- package/form-control/index.d.ts +9 -0
- package/form-control/styled-components.js +0 -1
- package/form-control/styled-components.js.flow +0 -1
- package/index.d.ts +20 -35
- package/list/list-item.js +5 -1
- package/list/list-item.js.flow +4 -0
- package/list/menu-adapter.js +4 -0
- package/list/menu-adapter.js.flow +4 -0
- package/list/types.js.flow +4 -0
- package/package.json +2 -1
- package/select/index.d.ts +1 -0
- package/select/select-component.js +25 -16
- package/select/select-component.js.flow +30 -13
- package/select/styled-components.js +19 -13
- package/select/styled-components.js.flow +13 -8
- package/select/types.js.flow +1 -0
- package/select/utils/default-filter-options.js +1 -1
- package/select/utils/default-filter-options.js.flow +1 -1
- package/snackbar/snackbar-context.js +1 -1
- package/snackbar/snackbar-context.js.flow +1 -1
- package/spinner/index.d.ts +3 -2
- package/tag/types.js.flow +1 -1
|
@@ -17,13 +17,12 @@ import TriangleDownIcon from '../icon/triangle-down.js';
|
|
|
17
17
|
import SearchIconComponent from '../icon/search.js';
|
|
18
18
|
import { LocaleContext } from '../locale/index.js';
|
|
19
19
|
import { Popover, PLACEMENT } from '../popover/index.js';
|
|
20
|
-
import { Spinner } from '../spinner/index.js';
|
|
21
20
|
import { UIDConsumer } from 'react-uid';
|
|
22
21
|
import AutosizeInput from './autosize-input.js';
|
|
23
22
|
import { TYPE, STATE_CHANGE_TYPE } from './constants.js';
|
|
24
23
|
import defaultProps from './default-props.js';
|
|
25
24
|
import SelectDropdown from './dropdown.js';
|
|
26
|
-
import { StyledRoot, StyledControlContainer, StyledPlaceholder, StyledValueContainer, StyledInputContainer, StyledIconsContainer, StyledSelectArrow, StyledClearIcon,
|
|
25
|
+
import { StyledRoot, StyledControlContainer, StyledPlaceholder, StyledValueContainer, StyledInputContainer, StyledIconsContainer, StyledSelectArrow, StyledClearIcon, StyledSearchIconContainer, StyledLoadingIndicator } from './styled-components.js';
|
|
27
26
|
import { expandValue, normalizeOptions } from './utils/index.js';
|
|
28
27
|
|
|
29
28
|
function Noop() {
|
|
@@ -437,6 +436,12 @@ class Select extends React.Component {
|
|
|
437
436
|
_defineProperty(this, "handleInputRef", input => {
|
|
438
437
|
this.input = input;
|
|
439
438
|
|
|
439
|
+
if (typeof this.props.inputRef === 'function') {
|
|
440
|
+
this.props.inputRef(input);
|
|
441
|
+
} else if (this.props.inputRef) {
|
|
442
|
+
this.props.inputRef.current = input;
|
|
443
|
+
}
|
|
444
|
+
|
|
440
445
|
if (this.props.controlRef && typeof this.props.controlRef === 'function') {
|
|
441
446
|
this.props.controlRef(input);
|
|
442
447
|
}
|
|
@@ -667,20 +672,25 @@ class Select extends React.Component {
|
|
|
667
672
|
|
|
668
673
|
renderLoading() {
|
|
669
674
|
if (!this.props.isLoading) return;
|
|
670
|
-
const sharedProps = this.getSharedProps();
|
|
671
675
|
const {
|
|
672
676
|
overrides = {}
|
|
673
677
|
} = this.props;
|
|
674
|
-
const [LoadingIndicator, loadingIndicatorProps] = getOverrides(overrides.LoadingIndicator,
|
|
678
|
+
const [LoadingIndicator, loadingIndicatorProps] = getOverrides(overrides.LoadingIndicator, StyledLoadingIndicator);
|
|
675
679
|
return /*#__PURE__*/React.createElement(LoadingIndicator, _extends({
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
680
|
+
role: "status"
|
|
681
|
+
}, loadingIndicatorProps), /*#__PURE__*/React.createElement("span", {
|
|
682
|
+
style: {
|
|
683
|
+
position: 'absolute',
|
|
684
|
+
width: '1px',
|
|
685
|
+
height: '1px',
|
|
686
|
+
padding: 0,
|
|
687
|
+
margin: '-1px',
|
|
688
|
+
overflow: 'hidden',
|
|
689
|
+
clip: 'rect(0,0,0,0)',
|
|
690
|
+
whiteSpace: 'nowrap',
|
|
691
|
+
border: 0
|
|
692
|
+
}
|
|
693
|
+
}, "Loading"));
|
|
684
694
|
}
|
|
685
695
|
|
|
686
696
|
renderValue(valueArray, isOpen, locale) {
|
|
@@ -4,9 +4,10 @@ Copyright (c) Uber Technologies, Inc.
|
|
|
4
4
|
This source code is licensed under the MIT license found in the
|
|
5
5
|
LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import { styled } from '../styles/index.js';
|
|
7
|
+
import { styled, withStyle } from '../styles/index.js';
|
|
8
8
|
import { TYPE, SIZE } from './constants.js';
|
|
9
9
|
import { StyledList, StyledListItem } from '../menu/index.js';
|
|
10
|
+
import { Spinner } from '../spinner/index.js';
|
|
10
11
|
import { ellipsisText } from '../styles/util.js';
|
|
11
12
|
|
|
12
13
|
function getFont(size = SIZE.default, typography) {
|
|
@@ -432,19 +433,22 @@ export const StyledClearIcon = styled('svg', props => {
|
|
|
432
433
|
};
|
|
433
434
|
});
|
|
434
435
|
StyledClearIcon.displayName = "StyledClearIcon";
|
|
435
|
-
export const
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
436
|
+
export const StyledLoadingIndicator = withStyle(Spinner, ({
|
|
437
|
+
$theme
|
|
438
|
+
}) => {
|
|
439
|
+
return {
|
|
440
|
+
borderTopWidth: '2px',
|
|
441
|
+
borderRightWidth: '2px',
|
|
442
|
+
borderBottomWidth: '2px',
|
|
443
|
+
borderLeftWidth: '2px',
|
|
444
|
+
borderRightColor: $theme.colors.borderOpaque,
|
|
445
|
+
borderBottomColor: $theme.colors.borderOpaque,
|
|
446
|
+
borderLeftColor: $theme.colors.borderOpaque,
|
|
447
|
+
width: '16px',
|
|
448
|
+
height: '16px'
|
|
446
449
|
};
|
|
447
|
-
};
|
|
450
|
+
});
|
|
451
|
+
StyledLoadingIndicator.displayName = "StyledLoadingIndicator";
|
|
448
452
|
export const StyledSearchIconContainer = styled('div', props => {
|
|
449
453
|
const {
|
|
450
454
|
$disabled,
|
|
@@ -37,7 +37,7 @@ const filterOptions = (options, filterValue, excludeOptions, newProps) => {
|
|
|
37
37
|
acc.add(option[props.valueKey]);
|
|
38
38
|
return acc;
|
|
39
39
|
}, new Set());
|
|
40
|
-
const re = new RegExp(`${props.matchPos === 'start' ? '
|
|
40
|
+
const re = new RegExp(`${props.matchPos === 'start' ? '^' : ''}${escapeRegExp(filterValue)}`, props.ignoreCase ? 'i' : ''); // $FlowFixMe
|
|
41
41
|
|
|
42
42
|
return options.filter(option => {
|
|
43
43
|
if (excludeValues.has(option[props.valueKey])) return false;
|
|
@@ -536,7 +536,8 @@ export function DataTable(_ref2) {
|
|
|
536
536
|
sortIndex = _ref2.sortIndex,
|
|
537
537
|
sortDirection = _ref2.sortDirection,
|
|
538
538
|
_ref2$textQuery = _ref2.textQuery,
|
|
539
|
-
textQuery = _ref2$textQuery === void 0 ? '' : _ref2$textQuery
|
|
539
|
+
textQuery = _ref2$textQuery === void 0 ? '' : _ref2$textQuery,
|
|
540
|
+
controlRef = _ref2.controlRef;
|
|
540
541
|
|
|
541
542
|
var _useStyletron13 = useStyletron(),
|
|
542
543
|
_useStyletron14 = _slicedToArray(_useStyletron13, 2),
|
|
@@ -735,6 +736,13 @@ export function DataTable(_ref2) {
|
|
|
735
736
|
|
|
736
737
|
return result;
|
|
737
738
|
}, [sortedIndices, filteredIndices, onIncludedRowsChange, allRows]);
|
|
739
|
+
React.useImperativeHandle(controlRef, function () {
|
|
740
|
+
return {
|
|
741
|
+
getRows: function getRows() {
|
|
742
|
+
return rows;
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
}, [rows]);
|
|
738
746
|
|
|
739
747
|
var _React$useState19 = React.useState(0),
|
|
740
748
|
_React$useState20 = _slicedToArray(_React$useState19, 2),
|
|
@@ -315,12 +315,12 @@ var Calendar = /*#__PURE__*/function (_React$Component) {
|
|
|
315
315
|
_defineProperty(_assertThisInitialized(_this), "handleDateChange", function (data) {
|
|
316
316
|
var _this$props$onChange = _this.props.onChange,
|
|
317
317
|
onChange = _this$props$onChange === void 0 ? function (params) {} : _this$props$onChange;
|
|
318
|
-
var updatedDate = data.date; //
|
|
319
|
-
|
|
320
|
-
var newTimeState = _toConsumableArray(_this.state.time); // Apply the currently selected time values (saved in state) to the updated date
|
|
321
|
-
|
|
318
|
+
var updatedDate = data.date; // Apply the currently selected time values (saved in state) to the updated date
|
|
322
319
|
|
|
323
320
|
if (Array.isArray(data.date)) {
|
|
321
|
+
// We'll need to update the date in time values of internal state
|
|
322
|
+
var newTimeState = _toConsumableArray(_this.state.time);
|
|
323
|
+
|
|
324
324
|
var start = data.date[0] ? _this.dateHelpers.applyDateToTime(newTimeState[0], data.date[0]) : null;
|
|
325
325
|
var end = data.date[1] ? _this.dateHelpers.applyDateToTime(newTimeState[1], data.date[1]) : null;
|
|
326
326
|
newTimeState[0] = start;
|
|
@@ -330,16 +330,21 @@ var Calendar = /*#__PURE__*/function (_React$Component) {
|
|
|
330
330
|
newTimeState[1] = end;
|
|
331
331
|
} else {
|
|
332
332
|
updatedDate = [start];
|
|
333
|
-
}
|
|
333
|
+
} // Update the date in time values of internal state
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
_this.setState({
|
|
337
|
+
time: newTimeState
|
|
338
|
+
});
|
|
334
339
|
} else if (!Array.isArray(_this.props.value) && data.date) {
|
|
335
|
-
|
|
336
|
-
updatedDate = newTimeState[0];
|
|
337
|
-
} // Update the date in time values of internal state
|
|
340
|
+
var _newTimeState = _this.dateHelpers.applyDateToTime(_this.state.time[0], data.date);
|
|
338
341
|
|
|
342
|
+
updatedDate = _newTimeState; // Update the date in time values of internal state
|
|
339
343
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
344
|
+
_this.setState({
|
|
345
|
+
time: [_newTimeState]
|
|
346
|
+
});
|
|
347
|
+
}
|
|
343
348
|
|
|
344
349
|
onChange({
|
|
345
350
|
date: updatedDate
|
|
@@ -2,6 +2,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
|
|
2
2
|
|
|
3
3
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
4
|
|
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
+
|
|
7
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
8
|
+
|
|
5
9
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
10
|
|
|
7
11
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -10,10 +14,6 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.it
|
|
|
10
14
|
|
|
11
15
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
12
16
|
|
|
13
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
14
|
-
|
|
15
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
16
|
-
|
|
17
17
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
18
18
|
|
|
19
19
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
@@ -107,7 +107,39 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
107
107
|
|
|
108
108
|
_defineProperty(_assertThisInitialized(_this), "dateHelpers", void 0);
|
|
109
109
|
|
|
110
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
110
|
+
_defineProperty(_assertThisInitialized(_this), "handleChange", function (date) {
|
|
111
|
+
var onChange = _this.props.onChange;
|
|
112
|
+
var onRangeChange = _this.props.onRangeChange;
|
|
113
|
+
|
|
114
|
+
if (Array.isArray(date)) {
|
|
115
|
+
if (onChange && date.every(Boolean)) {
|
|
116
|
+
// flowlint-next-line unclear-type:off
|
|
117
|
+
onChange({
|
|
118
|
+
date: date
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (onRangeChange) {
|
|
123
|
+
onRangeChange({
|
|
124
|
+
date: _toConsumableArray(date)
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
if (onChange) {
|
|
129
|
+
onChange({
|
|
130
|
+
date: date
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (onRangeChange) {
|
|
135
|
+
onRangeChange({
|
|
136
|
+
date: date
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
_defineProperty(_assertThisInitialized(_this), "onCalendarSelect", function (data) {
|
|
111
143
|
var isOpen = false;
|
|
112
144
|
var isPseudoFocused = false;
|
|
113
145
|
var calendarFocused = false;
|
|
@@ -184,9 +216,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
184
216
|
inputValue: _this.formatDisplayValue(nextDate)
|
|
185
217
|
}));
|
|
186
218
|
|
|
187
|
-
_this.
|
|
188
|
-
date: nextDate
|
|
189
|
-
});
|
|
219
|
+
_this.handleChange(nextDate);
|
|
190
220
|
});
|
|
191
221
|
|
|
192
222
|
_defineProperty(_assertThisInitialized(_this), "formatDisplayValue", function (date) {
|
|
@@ -290,16 +320,10 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
290
320
|
var formatString = _this.normalizeDashes(_this.props.formatString);
|
|
291
321
|
|
|
292
322
|
if (typeof mask === 'string' && inputValue === mask.replace(/9/g, ' ') || inputValue.length === 0) {
|
|
293
|
-
if (_this.props.
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
});
|
|
298
|
-
} else {
|
|
299
|
-
_this.props.onChange({
|
|
300
|
-
date: null
|
|
301
|
-
});
|
|
302
|
-
}
|
|
323
|
+
if (_this.props.range) {
|
|
324
|
+
_this.handleChange([]);
|
|
325
|
+
} else {
|
|
326
|
+
_this.handleChange(null);
|
|
303
327
|
}
|
|
304
328
|
}
|
|
305
329
|
|
|
@@ -330,19 +354,13 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
330
354
|
endDate = parseDateString(right);
|
|
331
355
|
}
|
|
332
356
|
|
|
333
|
-
var
|
|
334
|
-
|
|
335
|
-
if (onChange) {
|
|
336
|
-
var datesValid = _this.dateHelpers.isValid(startDate) && _this.dateHelpers.isValid(endDate); // added equal case so that times within the same day can be expressed
|
|
357
|
+
var datesValid = _this.dateHelpers.isValid(startDate) && _this.dateHelpers.isValid(endDate); // added equal case so that times within the same day can be expressed
|
|
337
358
|
|
|
338
359
|
|
|
339
|
-
|
|
360
|
+
var rangeValid = _this.dateHelpers.isAfter(endDate, startDate) || _this.dateHelpers.isEqual(startDate, endDate);
|
|
340
361
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
date: [startDate, endDate]
|
|
344
|
-
});
|
|
345
|
-
}
|
|
362
|
+
if (datesValid && rangeValid) {
|
|
363
|
+
_this.handleChange([startDate, endDate]);
|
|
346
364
|
}
|
|
347
365
|
} else {
|
|
348
366
|
var dateString = _this.normalizeDashes(inputValue);
|
|
@@ -360,11 +378,10 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
360
378
|
|
|
361
379
|
var _this$props3 = _this.props,
|
|
362
380
|
displayValueAtRangeIndex = _this$props3.displayValueAtRangeIndex,
|
|
363
|
-
_onChange = _this$props3.onChange,
|
|
364
381
|
range = _this$props3.range,
|
|
365
382
|
value = _this$props3.value;
|
|
366
383
|
|
|
367
|
-
if (date && _this.dateHelpers.isValid(date)
|
|
384
|
+
if (date && _this.dateHelpers.isValid(date)) {
|
|
368
385
|
if (range && Array.isArray(value) && typeof displayValueAtRangeIndex === 'number') {
|
|
369
386
|
var _value = _slicedToArray(value, 2),
|
|
370
387
|
_left = _value[0],
|
|
@@ -374,22 +391,16 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
374
391
|
_left = date;
|
|
375
392
|
|
|
376
393
|
if (!_right) {
|
|
377
|
-
|
|
378
|
-
date: [_left]
|
|
379
|
-
});
|
|
394
|
+
_this.handleChange([_left]);
|
|
380
395
|
} else {
|
|
381
396
|
if (_this.dateHelpers.isAfter(_right, _left) || _this.dateHelpers.isEqual(_left, _right)) {
|
|
382
|
-
|
|
383
|
-
date: [_left, _right]
|
|
384
|
-
});
|
|
397
|
+
_this.handleChange([_left, _right]);
|
|
385
398
|
} else {
|
|
386
399
|
// Is resetting back to previous value appropriate? Invalid range is not
|
|
387
400
|
// communicated to the user, but if it was not reset the text value would
|
|
388
401
|
// show one value and date value another. This seems a bit better but clearly
|
|
389
402
|
// has a downside.
|
|
390
|
-
|
|
391
|
-
date: _toConsumableArray(value)
|
|
392
|
-
});
|
|
403
|
+
_this.handleChange(_toConsumableArray(value));
|
|
393
404
|
}
|
|
394
405
|
}
|
|
395
406
|
} else if (displayValueAtRangeIndex === 1) {
|
|
@@ -397,26 +408,18 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
397
408
|
|
|
398
409
|
if (!_left) {
|
|
399
410
|
// If start value is not defined, set start/end to the same day.
|
|
400
|
-
|
|
401
|
-
date: [_right, _right]
|
|
402
|
-
});
|
|
411
|
+
_this.handleChange([_right, _right]);
|
|
403
412
|
} else {
|
|
404
413
|
if (_this.dateHelpers.isAfter(_right, _left) || _this.dateHelpers.isEqual(_left, _right)) {
|
|
405
|
-
|
|
406
|
-
date: [_left, _right]
|
|
407
|
-
});
|
|
414
|
+
_this.handleChange([_left, _right]);
|
|
408
415
|
} else {
|
|
409
416
|
// See comment above about resetting dates on invalid range
|
|
410
|
-
|
|
411
|
-
date: _toConsumableArray(value)
|
|
412
|
-
});
|
|
417
|
+
_this.handleChange(_toConsumableArray(value));
|
|
413
418
|
}
|
|
414
419
|
}
|
|
415
420
|
}
|
|
416
421
|
} else {
|
|
417
|
-
|
|
418
|
-
date: date
|
|
419
|
-
});
|
|
422
|
+
_this.handleChange(date);
|
|
420
423
|
}
|
|
421
424
|
}
|
|
422
425
|
}
|
|
@@ -533,11 +536,6 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
533
536
|
endDate = _split2$2 === void 0 ? '' : _split2$2;
|
|
534
537
|
|
|
535
538
|
var value = inputRole === INPUT_ROLE.startDate ? startDate : inputRole === INPUT_ROLE.endDate ? endDate : this.state.inputValue;
|
|
536
|
-
|
|
537
|
-
var onChange = function onChange(event) {
|
|
538
|
-
return _this3.handleInputChange(event, inputRole);
|
|
539
|
-
};
|
|
540
|
-
|
|
541
539
|
return /*#__PURE__*/React.createElement(InputComponent, _extends({
|
|
542
540
|
"aria-disabled": this.props.disabled,
|
|
543
541
|
"aria-label": this.props['aria-label'] || (this.props.range ? locale.datepicker.ariaLabelRange : locale.datepicker.ariaLabel),
|
|
@@ -554,7 +552,9 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
554
552
|
},
|
|
555
553
|
onBlur: this.handleInputBlur,
|
|
556
554
|
onKeyDown: this.handleKeyDown,
|
|
557
|
-
onChange: onChange
|
|
555
|
+
onChange: function onChange(event) {
|
|
556
|
+
return _this3.handleInputChange(event, inputRole);
|
|
557
|
+
},
|
|
558
558
|
placeholder: placeholder,
|
|
559
559
|
mask: this.getMask(),
|
|
560
560
|
required: this.props.required,
|
|
@@ -614,7 +614,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
614
614
|
trapTabbing: true,
|
|
615
615
|
value: _this4.props.value
|
|
616
616
|
}, _this4.props, {
|
|
617
|
-
onChange: _this4.
|
|
617
|
+
onChange: _this4.onCalendarSelect,
|
|
618
618
|
selectedInput: _this4.state.selectedInput,
|
|
619
619
|
hasLockedBehavior: _this4.hasLockedBehavior()
|
|
620
620
|
}))
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
2
|
|
|
3
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
+
|
|
3
5
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
6
|
|
|
5
7
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
@@ -47,7 +49,10 @@ var StatefulComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
47
49
|
key: "render",
|
|
48
50
|
value: function render() {
|
|
49
51
|
return /*#__PURE__*/React.createElement(StatefulContainer, this.props, function (extendedProps) {
|
|
50
|
-
return /*#__PURE__*/React.createElement(Calendar, extendedProps
|
|
52
|
+
return /*#__PURE__*/React.createElement(Calendar, _extends({}, extendedProps, {
|
|
53
|
+
// flowlint-next-line unclear-type:off
|
|
54
|
+
onChange: extendedProps.onChange
|
|
55
|
+
}));
|
|
51
56
|
});
|
|
52
57
|
}
|
|
53
58
|
}]);
|
|
@@ -58,8 +58,29 @@ var StatefulContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
58
58
|
value: date
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
var onChange = _this.props.onChange;
|
|
62
|
+
|
|
63
|
+
if (onChange) {
|
|
64
|
+
if (Array.isArray(date)) {
|
|
65
|
+
if (date.every(Boolean)) {
|
|
66
|
+
// flowlint-next-line unclear-type:off
|
|
67
|
+
onChange({
|
|
68
|
+
date: date
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
onChange({
|
|
73
|
+
date: date
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
var onRangeChange = _this.props.onRangeChange;
|
|
79
|
+
|
|
80
|
+
if (onRangeChange) {
|
|
81
|
+
onRangeChange({
|
|
82
|
+
date: date
|
|
83
|
+
});
|
|
63
84
|
}
|
|
64
85
|
});
|
|
65
86
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
2
|
|
|
3
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
+
|
|
3
5
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
6
|
|
|
5
7
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
@@ -47,7 +49,10 @@ var StatefulComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
47
49
|
key: "render",
|
|
48
50
|
value: function render() {
|
|
49
51
|
return /*#__PURE__*/React.createElement(StatefulContainer, this.props, function (extendedProps) {
|
|
50
|
-
return /*#__PURE__*/React.createElement(Datepicker, extendedProps
|
|
52
|
+
return /*#__PURE__*/React.createElement(Datepicker, _extends({}, extendedProps, {
|
|
53
|
+
// flowlint-next-line unclear-type:off
|
|
54
|
+
onChange: extendedProps.onChange
|
|
55
|
+
}));
|
|
51
56
|
});
|
|
52
57
|
}
|
|
53
58
|
}]);
|
|
@@ -17,7 +17,6 @@ export var Label = styled('label', function (props) {
|
|
|
17
17
|
colors = _props$$theme.colors,
|
|
18
18
|
typography = _props$$theme.typography;
|
|
19
19
|
return _objectSpread(_objectSpread({}, typography.font250), {}, {
|
|
20
|
-
fontWeight: 500,
|
|
21
20
|
width: '100%',
|
|
22
21
|
color: $disabled ? colors.contentSecondary : colors.contentPrimary,
|
|
23
22
|
display: 'block',
|
package/esm/list/list-item.js
CHANGED
|
@@ -69,7 +69,11 @@ var ListItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
69
69
|
return /*#__PURE__*/React.createElement(Root // flowlint-next-line unclear-type:off
|
|
70
70
|
, _extends({
|
|
71
71
|
ref: ref,
|
|
72
|
-
$shape: props.shape || SHAPE.DEFAULT
|
|
72
|
+
$shape: props.shape || SHAPE.DEFAULT,
|
|
73
|
+
"aria-label": props['aria-label'],
|
|
74
|
+
"aria-selected": props['aria-selected'],
|
|
75
|
+
id: props.id,
|
|
76
|
+
role: props.role
|
|
73
77
|
}, rootProps), Artwork && /*#__PURE__*/React.createElement(ArtworkContainer, _extends({
|
|
74
78
|
$artworkSize: artworkSize,
|
|
75
79
|
$sublist: Boolean(props.sublist)
|
package/esm/list/menu-adapter.js
CHANGED
|
@@ -11,9 +11,13 @@ var MenuAdapter = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
11
11
|
return /*#__PURE__*/React.createElement(ListItem, {
|
|
12
12
|
ref: ref,
|
|
13
13
|
sublist: props.sublist || props.$size === 'compact',
|
|
14
|
+
"aria-label": props['aria-label'],
|
|
15
|
+
"aria-selected": props['aria-selected'],
|
|
14
16
|
artwork: props.artwork,
|
|
15
17
|
artworkSize: props.artworkSize,
|
|
16
18
|
endEnhancer: props.endEnhancer,
|
|
19
|
+
id: props.id,
|
|
20
|
+
role: props.role,
|
|
17
21
|
overrides: mergeOverrides({
|
|
18
22
|
Root: {
|
|
19
23
|
props: {
|
|
@@ -59,13 +59,12 @@ import TriangleDownIcon from '../icon/triangle-down.js';
|
|
|
59
59
|
import SearchIconComponent from '../icon/search.js';
|
|
60
60
|
import { LocaleContext } from '../locale/index.js';
|
|
61
61
|
import { Popover, PLACEMENT } from '../popover/index.js';
|
|
62
|
-
import { Spinner } from '../spinner/index.js';
|
|
63
62
|
import { UIDConsumer } from 'react-uid';
|
|
64
63
|
import AutosizeInput from './autosize-input.js';
|
|
65
64
|
import { TYPE, STATE_CHANGE_TYPE } from './constants.js';
|
|
66
65
|
import defaultProps from './default-props.js';
|
|
67
66
|
import SelectDropdown from './dropdown.js';
|
|
68
|
-
import { StyledRoot, StyledControlContainer, StyledPlaceholder, StyledValueContainer, StyledInputContainer, StyledIconsContainer, StyledSelectArrow, StyledClearIcon,
|
|
67
|
+
import { StyledRoot, StyledControlContainer, StyledPlaceholder, StyledValueContainer, StyledInputContainer, StyledIconsContainer, StyledSelectArrow, StyledClearIcon, StyledSearchIconContainer, StyledLoadingIndicator } from './styled-components.js';
|
|
69
68
|
import { expandValue, normalizeOptions } from './utils/index.js';
|
|
70
69
|
|
|
71
70
|
function Noop() {
|
|
@@ -512,6 +511,12 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
512
511
|
_defineProperty(_assertThisInitialized(_this), "handleInputRef", function (input) {
|
|
513
512
|
_this.input = input;
|
|
514
513
|
|
|
514
|
+
if (typeof _this.props.inputRef === 'function') {
|
|
515
|
+
_this.props.inputRef(input);
|
|
516
|
+
} else if (_this.props.inputRef) {
|
|
517
|
+
_this.props.inputRef.current = input;
|
|
518
|
+
}
|
|
519
|
+
|
|
515
520
|
if (_this.props.controlRef && typeof _this.props.controlRef === 'function') {
|
|
516
521
|
_this.props.controlRef(input);
|
|
517
522
|
}
|
|
@@ -776,24 +781,29 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
776
781
|
key: "renderLoading",
|
|
777
782
|
value: function renderLoading() {
|
|
778
783
|
if (!this.props.isLoading) return;
|
|
779
|
-
var sharedProps = this.getSharedProps();
|
|
780
784
|
var _this$props$overrides = this.props.overrides,
|
|
781
785
|
overrides = _this$props$overrides === void 0 ? {} : _this$props$overrides;
|
|
782
786
|
|
|
783
|
-
var _getOverrides = getOverrides(overrides.LoadingIndicator,
|
|
787
|
+
var _getOverrides = getOverrides(overrides.LoadingIndicator, StyledLoadingIndicator),
|
|
784
788
|
_getOverrides2 = _slicedToArray(_getOverrides, 2),
|
|
785
789
|
LoadingIndicator = _getOverrides2[0],
|
|
786
790
|
loadingIndicatorProps = _getOverrides2[1];
|
|
787
791
|
|
|
788
792
|
return /*#__PURE__*/React.createElement(LoadingIndicator, _extends({
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
793
|
+
role: "status"
|
|
794
|
+
}, loadingIndicatorProps), /*#__PURE__*/React.createElement("span", {
|
|
795
|
+
style: {
|
|
796
|
+
position: 'absolute',
|
|
797
|
+
width: '1px',
|
|
798
|
+
height: '1px',
|
|
799
|
+
padding: 0,
|
|
800
|
+
margin: '-1px',
|
|
801
|
+
overflow: 'hidden',
|
|
802
|
+
clip: 'rect(0,0,0,0)',
|
|
803
|
+
whiteSpace: 'nowrap',
|
|
804
|
+
border: 0
|
|
805
|
+
}
|
|
806
|
+
}, "Loading"));
|
|
797
807
|
}
|
|
798
808
|
}, {
|
|
799
809
|
key: "renderValue",
|
|
@@ -10,9 +10,10 @@ Copyright (c) Uber Technologies, Inc.
|
|
|
10
10
|
This source code is licensed under the MIT license found in the
|
|
11
11
|
LICENSE file in the root directory of this source tree.
|
|
12
12
|
*/
|
|
13
|
-
import { styled } from '../styles/index.js';
|
|
13
|
+
import { styled, withStyle } from '../styles/index.js';
|
|
14
14
|
import { TYPE, SIZE } from './constants.js';
|
|
15
15
|
import { StyledList, StyledListItem } from '../menu/index.js';
|
|
16
|
+
import { Spinner } from '../spinner/index.js';
|
|
16
17
|
import { ellipsisText } from '../styles/util.js';
|
|
17
18
|
|
|
18
19
|
function getFont() {
|
|
@@ -371,15 +372,21 @@ export var StyledClearIcon = styled('svg', function (props) {
|
|
|
371
372
|
});
|
|
372
373
|
});
|
|
373
374
|
StyledClearIcon.displayName = "StyledClearIcon";
|
|
374
|
-
export var
|
|
375
|
-
var $theme =
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
375
|
+
export var StyledLoadingIndicator = withStyle(Spinner, function (_ref5) {
|
|
376
|
+
var $theme = _ref5.$theme;
|
|
377
|
+
return {
|
|
378
|
+
borderTopWidth: '2px',
|
|
379
|
+
borderRightWidth: '2px',
|
|
380
|
+
borderBottomWidth: '2px',
|
|
381
|
+
borderLeftWidth: '2px',
|
|
382
|
+
borderRightColor: $theme.colors.borderOpaque,
|
|
383
|
+
borderBottomColor: $theme.colors.borderOpaque,
|
|
384
|
+
borderLeftColor: $theme.colors.borderOpaque,
|
|
385
|
+
width: '16px',
|
|
386
|
+
height: '16px'
|
|
387
|
+
};
|
|
388
|
+
});
|
|
389
|
+
StyledLoadingIndicator.displayName = "StyledLoadingIndicator";
|
|
383
390
|
export var StyledSearchIconContainer = styled('div', function (props) {
|
|
384
391
|
var _objectSpread4;
|
|
385
392
|
|