@elliemae/ds-time-picker 2.0.0-alpha.1 → 2.0.0-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/DSTimePicker.js +44 -41
- package/cjs/DSTimePickerMenu.js +9 -4
- package/cjs/PickerPanel.js +60 -46
- package/cjs/TimePickerDropdown.js +36 -34
- package/cjs/TimePickerImpl.js +46 -40
- package/cjs/TimePickerMenu.js +27 -21
- package/cjs/index.js +1 -1
- package/cjs/moveElementOnScroll.js +11 -10
- package/cjs/utils.js +2 -1
- package/esm/DSTimePicker.js +42 -39
- package/esm/DSTimePickerMenu.js +5 -0
- package/esm/PickerPanel.js +44 -28
- package/esm/TimePickerDropdown.js +36 -33
- package/esm/TimePickerImpl.js +36 -28
- package/esm/TimePickerMenu.js +11 -5
- package/esm/moveElementOnScroll.js +10 -9
- package/esm/utils.js +2 -1
- package/package.json +9 -9
- package/types/DSTimePicker.d.ts +133 -19
- package/types/TimePickerDropdown.d.ts +1 -1
- package/cjs/package.json +0 -7
- package/esm/package.json +0 -7
package/cjs/TimePickerMenu.js
CHANGED
|
@@ -2,25 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
5
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
7
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
9
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
10
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
11
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
12
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
13
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
7
14
|
var React = require('react');
|
|
8
|
-
var utils$1 = require('@elliemae/ds-utilities/utils');
|
|
9
15
|
var dsClassnames = require('@elliemae/ds-classnames');
|
|
10
16
|
var moment = require('moment');
|
|
11
|
-
var
|
|
17
|
+
var dsUtilities = require('@elliemae/ds-utilities');
|
|
12
18
|
var utils = require('./utils.js');
|
|
13
19
|
var PickerPanel = require('./PickerPanel.js');
|
|
14
20
|
|
|
15
21
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
22
|
|
|
17
|
-
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
18
23
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
24
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
19
25
|
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
20
26
|
|
|
21
27
|
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; }
|
|
22
28
|
|
|
23
|
-
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__default[
|
|
29
|
+
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__default["default"](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; }
|
|
24
30
|
const blockName = 'time-picker-menu';
|
|
25
31
|
const TimePickerContainer = dsClassnames.aggregatedClasses('div')(blockName);
|
|
26
32
|
const TimePickerHeader = dsClassnames.aggregatedClasses('div')(blockName, 'header');
|
|
@@ -35,15 +41,15 @@ class TimePickerMenu extends React.Component {
|
|
|
35
41
|
constructor(props) {
|
|
36
42
|
super(props);
|
|
37
43
|
|
|
38
|
-
|
|
44
|
+
this.renderHeader = () => {
|
|
39
45
|
const {
|
|
40
46
|
time
|
|
41
47
|
} = this.state;
|
|
42
|
-
return /*#__PURE__*/_jsx__default[
|
|
43
|
-
}
|
|
48
|
+
return /*#__PURE__*/_jsx__default["default"](TimePickerHeader, {}, void 0, time.format('hh:mma'));
|
|
49
|
+
};
|
|
44
50
|
|
|
45
51
|
this.state = {
|
|
46
|
-
time: moment__default[
|
|
52
|
+
time: moment__default["default"](props.time || '', props.format) || moment__default["default"]()
|
|
47
53
|
};
|
|
48
54
|
this.handleHoursChange = this.handleHoursChange.bind(this);
|
|
49
55
|
this.handleMinuteChange = this.handleMinuteChange.bind(this);
|
|
@@ -54,7 +60,7 @@ class TimePickerMenu extends React.Component {
|
|
|
54
60
|
static getDerivedStateFromProps(props, state) {
|
|
55
61
|
if (props.time) {
|
|
56
62
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
57
|
-
time: moment__default[
|
|
63
|
+
time: moment__default["default"](props.time)
|
|
58
64
|
});
|
|
59
65
|
}
|
|
60
66
|
|
|
@@ -158,9 +164,9 @@ class TimePickerMenu extends React.Component {
|
|
|
158
164
|
|
|
159
165
|
const meridiem = hour >= 12 ? 'PM' : 'AM';
|
|
160
166
|
const withLeadingZeros = format.indexOf('hh') > -1;
|
|
161
|
-
const rangeHours = use12Hours ?
|
|
162
|
-
const hoursOptions = rangeHours.map(generateOption(withLeadingZeros &&
|
|
163
|
-
return /*#__PURE__*/_jsx__default[
|
|
167
|
+
const rangeHours = use12Hours ? dsUtilities.range(1, 13) : dsUtilities.range(24);
|
|
168
|
+
const hoursOptions = rangeHours.map(generateOption(withLeadingZeros && dsUtilities.addLeadingZeros(2)));
|
|
169
|
+
return /*#__PURE__*/_jsx__default["default"](PickerPanel, {
|
|
164
170
|
type: "hour",
|
|
165
171
|
time: time,
|
|
166
172
|
meridiem: meridiem,
|
|
@@ -186,7 +192,7 @@ class TimePickerMenu extends React.Component {
|
|
|
186
192
|
} = this.props;
|
|
187
193
|
if (!showMinutes) return null;
|
|
188
194
|
const withLeadingZeros = format.indexOf('mm') > -1;
|
|
189
|
-
const rangeMinutes =
|
|
195
|
+
const rangeMinutes = dsUtilities.range(0, 60, minutesInterval).map(generateOption(withLeadingZeros && dsUtilities.addLeadingZeros(2)));
|
|
190
196
|
let selectedMinute = time.minute();
|
|
191
197
|
const selectedHour = time.hour();
|
|
192
198
|
|
|
@@ -207,7 +213,7 @@ class TimePickerMenu extends React.Component {
|
|
|
207
213
|
}
|
|
208
214
|
}
|
|
209
215
|
|
|
210
|
-
return /*#__PURE__*/_jsx__default[
|
|
216
|
+
return /*#__PURE__*/_jsx__default["default"](PickerPanel, {
|
|
211
217
|
type: "minutes",
|
|
212
218
|
time: time,
|
|
213
219
|
hasHeader: hasHeader,
|
|
@@ -230,8 +236,8 @@ class TimePickerMenu extends React.Component {
|
|
|
230
236
|
} = this.props;
|
|
231
237
|
if (!showSeconds) return null;
|
|
232
238
|
const withLeadingZeros = format.indexOf('ss') > -1;
|
|
233
|
-
const rangeSeconds =
|
|
234
|
-
return /*#__PURE__*/_jsx__default[
|
|
239
|
+
const rangeSeconds = dsUtilities.range(60).map(generateOption(withLeadingZeros && dsUtilities.addLeadingZeros(2)));
|
|
240
|
+
return /*#__PURE__*/_jsx__default["default"](PickerPanel, {
|
|
235
241
|
type: "seconds",
|
|
236
242
|
hasHeader: hasHeader,
|
|
237
243
|
header: "S",
|
|
@@ -265,7 +271,7 @@ class TimePickerMenu extends React.Component {
|
|
|
265
271
|
}
|
|
266
272
|
}
|
|
267
273
|
|
|
268
|
-
return /*#__PURE__*/_jsx__default[
|
|
274
|
+
return /*#__PURE__*/_jsx__default["default"](PickerPanel, {
|
|
269
275
|
type: "meridiem",
|
|
270
276
|
hasHeader: hasHeader,
|
|
271
277
|
header: "",
|
|
@@ -286,13 +292,13 @@ class TimePickerMenu extends React.Component {
|
|
|
286
292
|
const {
|
|
287
293
|
hasHeaderDisplay
|
|
288
294
|
} = this.props;
|
|
289
|
-
return /*#__PURE__*/_jsx__default[
|
|
295
|
+
return /*#__PURE__*/_jsx__default["default"](TimePickerContainer, {}, void 0, hasHeaderDisplay && this.renderHeader(), /*#__PURE__*/_jsx__default["default"](TimePickerPanelContainer, {}, void 0, this.renderHoursPanel(), this.renderMinutesPanel(), this.renderSecondsPanel(), this.renderAMPMPanel()));
|
|
290
296
|
}
|
|
291
297
|
|
|
292
298
|
}
|
|
293
299
|
|
|
294
300
|
TimePickerMenu.defaultProps = {
|
|
295
|
-
time: moment__default[
|
|
301
|
+
time: moment__default["default"](),
|
|
296
302
|
hasHeader: false,
|
|
297
303
|
use12Hours: true,
|
|
298
304
|
showSeconds: true,
|
|
@@ -303,4 +309,4 @@ TimePickerMenu.defaultProps = {
|
|
|
303
309
|
};
|
|
304
310
|
|
|
305
311
|
exports.TimePickerMenu = TimePickerMenu;
|
|
306
|
-
exports[
|
|
312
|
+
exports["default"] = TimePickerMenu;
|
package/cjs/index.js
CHANGED
|
@@ -11,7 +11,7 @@ var utils = require('./utils.js');
|
|
|
11
11
|
|
|
12
12
|
exports.DSTimePicker = DSTimePicker.DSTimePicker;
|
|
13
13
|
exports.DSTimePickerWithSchema = DSTimePicker.DSTimePickerWithSchema;
|
|
14
|
-
exports
|
|
14
|
+
exports["default"] = DSTimePicker.DSTimePicker;
|
|
15
15
|
exports.TimePickerMenu = TimePickerMenu.TimePickerMenu;
|
|
16
16
|
exports.DSTimePickerMenu = DSTimePickerMenu.DSTimePickerMenu;
|
|
17
17
|
exports.convertTimeString = utils.convertTimeString;
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
function MoveElementOnScroll(element, {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
function MoveElementOnScroll(element, _ref) {
|
|
6
|
+
let {
|
|
7
|
+
container,
|
|
8
|
+
min = 0,
|
|
9
|
+
max = element.offsetHeight,
|
|
10
|
+
speed = 1,
|
|
11
|
+
smooth = 2,
|
|
12
|
+
onUpdate = () => null,
|
|
13
|
+
onEndScroll = () => null
|
|
14
|
+
} = _ref;
|
|
14
15
|
let moving = false;
|
|
15
16
|
let pos = min;
|
|
16
17
|
let lastPos = pos; // todo: move this to utils if we finally need it
|
|
@@ -71,4 +72,4 @@ function MoveElementOnScroll(element, {
|
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
exports.MoveElementOnScroll = MoveElementOnScroll;
|
|
74
|
-
exports[
|
|
75
|
+
exports["default"] = MoveElementOnScroll;
|
package/cjs/utils.js
CHANGED
|
@@ -7,7 +7,8 @@ const validateIndex = (index, options) => {
|
|
|
7
7
|
if (index >= options.length) return options.length - 1;
|
|
8
8
|
return index;
|
|
9
9
|
};
|
|
10
|
-
const getOptionIndex = (options, selectedOption
|
|
10
|
+
const getOptionIndex = function (options, selectedOption) {
|
|
11
|
+
let valueProperty = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'value';
|
|
11
12
|
const index = options.findIndex(option => option[valueProperty] === selectedOption);
|
|
12
13
|
return validateIndex(index, options);
|
|
13
14
|
};
|
package/esm/DSTimePicker.js
CHANGED
|
@@ -4,45 +4,48 @@ import moment from 'moment';
|
|
|
4
4
|
import TimePickerImpl from './TimePickerImpl.js';
|
|
5
5
|
import { jsx } from 'react/jsx-runtime';
|
|
6
6
|
|
|
7
|
-
const DSTimePicker =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
7
|
+
const DSTimePicker = _ref => {
|
|
8
|
+
let {
|
|
9
|
+
containerProps = {},
|
|
10
|
+
innerRef,
|
|
11
|
+
className = '',
|
|
12
|
+
disabled = false,
|
|
13
|
+
value = '',
|
|
14
|
+
format,
|
|
15
|
+
style = {},
|
|
16
|
+
onChange = () => null,
|
|
17
|
+
onOpen = () => null,
|
|
18
|
+
isOpen = undefined,
|
|
19
|
+
clearable = false,
|
|
20
|
+
hasHeader = true,
|
|
21
|
+
hasHeaderDisplay = false,
|
|
22
|
+
'aria-label': ariaLabel,
|
|
23
|
+
zIndex = 'auto',
|
|
24
|
+
placement = 'bottom',
|
|
25
|
+
disabledTimes,
|
|
26
|
+
minutesInterval = 1
|
|
27
|
+
} = _ref;
|
|
28
|
+
return /*#__PURE__*/jsx(TimePickerImpl, {
|
|
29
|
+
ref: innerRef,
|
|
30
|
+
"aria-label": ariaLabel,
|
|
31
|
+
className: className,
|
|
32
|
+
clearable: clearable,
|
|
33
|
+
containerProps: containerProps,
|
|
34
|
+
disabled: disabled,
|
|
35
|
+
format: format,
|
|
36
|
+
hasHeader: hasHeader,
|
|
37
|
+
hasHeaderDisplay: hasHeaderDisplay,
|
|
38
|
+
isOpen: isOpen,
|
|
39
|
+
onChange: onChange,
|
|
40
|
+
onOpen: onOpen,
|
|
41
|
+
placement: placement,
|
|
42
|
+
style: style,
|
|
43
|
+
value: value,
|
|
44
|
+
zIndex: zIndex,
|
|
45
|
+
minutesInterval: minutesInterval,
|
|
46
|
+
disabledTimes: disabledTimes
|
|
47
|
+
});
|
|
48
|
+
};
|
|
46
49
|
|
|
47
50
|
DSTimePicker.defaultProps = {
|
|
48
51
|
format: 'hh:mm:ss A'
|
package/esm/DSTimePickerMenu.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
1
6
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
7
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
3
8
|
import 'react';
|
package/esm/PickerPanel.js
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
3
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
2
5
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
6
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
7
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
8
|
+
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
9
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
10
|
+
import 'core-js/modules/esnext.iterator.find.js';
|
|
11
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
12
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
3
13
|
import React, { Component } from 'react';
|
|
4
14
|
import { findIndex } from 'lodash';
|
|
5
15
|
import { aggregatedClasses } from '@elliemae/ds-classnames';
|
|
6
16
|
import memoizeOne from 'memoize-one';
|
|
7
|
-
import ChevronSmallUp from '@elliemae/ds-icons
|
|
8
|
-
import ChevronSmallDown from '@elliemae/ds-icons/ChevronSmallDown';
|
|
17
|
+
import { ChevronSmallUp, ChevronSmallDown } from '@elliemae/ds-icons';
|
|
9
18
|
import DSButton from '@elliemae/ds-button';
|
|
10
19
|
import { MoveElementOnScroll } from './moveElementOnScroll.js';
|
|
11
20
|
import { validateIndex } from './utils.js';
|
|
@@ -17,27 +26,34 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
17
26
|
|
|
18
27
|
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; }
|
|
19
28
|
const blockName = 'time-picker-panel';
|
|
20
|
-
const Container = aggregatedClasses('div')(blockName, null,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
const Container = aggregatedClasses('div')(blockName, null, _ref => {
|
|
30
|
+
let {
|
|
31
|
+
scrolling
|
|
32
|
+
} = _ref;
|
|
33
|
+
return {
|
|
34
|
+
scrolling
|
|
35
|
+
};
|
|
36
|
+
});
|
|
25
37
|
const Wrapper = aggregatedClasses('div')(blockName, 'wrapper');
|
|
26
38
|
const PickerItemListContainer = aggregatedClasses('div')(blockName, 'item-list-container');
|
|
27
39
|
const PickerItemList = aggregatedClasses('div')(blockName, 'item-list');
|
|
28
40
|
const PickerHeader = aggregatedClasses('div')(blockName, 'header');
|
|
29
|
-
const PickerItemContainer = aggregatedClasses('div')(blockName, 'item',
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
const PickerItemContainer = aggregatedClasses('div')(blockName, 'item', _ref2 => {
|
|
42
|
+
let {
|
|
43
|
+
selected,
|
|
44
|
+
disabled
|
|
45
|
+
} = _ref2;
|
|
46
|
+
return {
|
|
47
|
+
selected,
|
|
48
|
+
disabled
|
|
49
|
+
};
|
|
50
|
+
});
|
|
36
51
|
const PickerSelectedOptionSelected = aggregatedClasses('div')(blockName, 'selected-container');
|
|
37
52
|
const SelectedCircle = aggregatedClasses('div')(blockName, 'selected-circle');
|
|
38
53
|
const ArrowButtonContainer = aggregatedClasses('div')(blockName, 'arrow-container');
|
|
39
54
|
|
|
40
|
-
const getOptionIndex = (options, selectedOption
|
|
55
|
+
const getOptionIndex = function (options, selectedOption) {
|
|
56
|
+
let valueProperty = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'value';
|
|
41
57
|
const index = options.findIndex(option => option[valueProperty] === selectedOption);
|
|
42
58
|
return validateIndex(index, options);
|
|
43
59
|
};
|
|
@@ -51,8 +67,7 @@ const arrowProps = {
|
|
|
51
67
|
class PickerPanel extends Component {
|
|
52
68
|
constructor(props) {
|
|
53
69
|
super(props);
|
|
54
|
-
|
|
55
|
-
_defineProperty(this, "computeContainerTranslation", memoizeOne(index => {
|
|
70
|
+
this.computeContainerTranslation = memoizeOne(index => {
|
|
56
71
|
const {
|
|
57
72
|
options,
|
|
58
73
|
valueProperty
|
|
@@ -65,14 +80,14 @@ class PickerPanel extends Component {
|
|
|
65
80
|
const listYPosition = this.minYListPosition - selectedOptionIndex * this.optionHeight;
|
|
66
81
|
if (this.scrollHandler && !scrolling) this.scrollHandler.updatePosition(listYPosition);
|
|
67
82
|
return listYPosition;
|
|
68
|
-
})
|
|
83
|
+
});
|
|
69
84
|
|
|
70
|
-
|
|
85
|
+
this.renderHeader = () => {
|
|
71
86
|
const {
|
|
72
87
|
header
|
|
73
88
|
} = this.props;
|
|
74
89
|
return /*#__PURE__*/_jsx(PickerHeader, {}, void 0, header);
|
|
75
|
-
}
|
|
90
|
+
};
|
|
76
91
|
|
|
77
92
|
this.pickerListContainerRef = /*#__PURE__*/React.createRef();
|
|
78
93
|
this.pickerListRef = /*#__PURE__*/React.createRef();
|
|
@@ -117,9 +132,10 @@ class PickerPanel extends Component {
|
|
|
117
132
|
this.scrollHandler.unsubscribe();
|
|
118
133
|
}
|
|
119
134
|
|
|
120
|
-
static getDerivedStateFromProps(nextProps, {
|
|
121
|
-
|
|
122
|
-
|
|
135
|
+
static getDerivedStateFromProps(nextProps, _ref3) {
|
|
136
|
+
let {
|
|
137
|
+
prevProps
|
|
138
|
+
} = _ref3;
|
|
123
139
|
const {
|
|
124
140
|
selected,
|
|
125
141
|
valueProperty,
|
|
@@ -296,7 +312,7 @@ class PickerPanel extends Component {
|
|
|
296
312
|
innerRef: this.selectedOptionRef
|
|
297
313
|
}, void 0, _SelectedCircle || (_SelectedCircle = /*#__PURE__*/_jsx(SelectedCircle, {}))), /*#__PURE__*/_jsx(ArrowButtonContainer, {}, void 0, /*#__PURE__*/jsx(DSButton, _objectSpread(_objectSpread({}, arrowProps), {}, {
|
|
298
314
|
"aria-label": "Chevron Up",
|
|
299
|
-
"data-testid":
|
|
315
|
+
"data-testid": "".concat(type, "-chevron-up"),
|
|
300
316
|
disabled: activeIndex <= 0,
|
|
301
317
|
icon: _ChevronSmallUp || (_ChevronSmallUp = /*#__PURE__*/_jsx(ChevronSmallUp, {})),
|
|
302
318
|
onClick: this.handleStepMoveUp,
|
|
@@ -307,10 +323,10 @@ class PickerPanel extends Component {
|
|
|
307
323
|
height: this.listHeight
|
|
308
324
|
}
|
|
309
325
|
}, void 0, /*#__PURE__*/_jsx(PickerItemList, {
|
|
310
|
-
"data-testid":
|
|
326
|
+
"data-testid": "".concat(type, "-list"),
|
|
311
327
|
innerRef: this.pickerListRef,
|
|
312
328
|
style: {
|
|
313
|
-
transform:
|
|
329
|
+
transform: "translateY(".concat(listYPosition, "px)")
|
|
314
330
|
}
|
|
315
331
|
}, void 0, options.map((option, index) => {
|
|
316
332
|
const value = this.getOptionValue(option);
|
|
@@ -355,7 +371,7 @@ class PickerPanel extends Component {
|
|
|
355
371
|
}, value, label);
|
|
356
372
|
}))), /*#__PURE__*/_jsx(ArrowButtonContainer, {}, void 0, /*#__PURE__*/jsx(DSButton, _objectSpread(_objectSpread({}, arrowProps), {}, {
|
|
357
373
|
"aria-label": "Chevron Down",
|
|
358
|
-
"data-testid":
|
|
374
|
+
"data-testid": "".concat(type, "-chevron-down"),
|
|
359
375
|
disabled: activeIndex >= options.length - 1,
|
|
360
376
|
icon: _ChevronSmallDown || (_ChevronSmallDown = /*#__PURE__*/_jsx(ChevronSmallDown, {})),
|
|
361
377
|
onClick: this.handleStepMoveDown,
|
|
@@ -1,42 +1,45 @@
|
|
|
1
1
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
2
|
import 'react';
|
|
3
|
-
import RecentDocuments from '@elliemae/ds-icons
|
|
3
|
+
import { RecentDocuments } from '@elliemae/ds-icons';
|
|
4
4
|
import DSButton from '@elliemae/ds-button';
|
|
5
5
|
import DSPopper from '@elliemae/ds-popper';
|
|
6
6
|
|
|
7
7
|
var _RecentDocuments;
|
|
8
8
|
|
|
9
|
-
const TimePickerDropdown =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
})
|
|
9
|
+
const TimePickerDropdown = _ref => {
|
|
10
|
+
let {
|
|
11
|
+
disabled = false,
|
|
12
|
+
onClick,
|
|
13
|
+
onOpen,
|
|
14
|
+
isOpen,
|
|
15
|
+
menu,
|
|
16
|
+
zIndex,
|
|
17
|
+
blockName,
|
|
18
|
+
placement
|
|
19
|
+
} = _ref;
|
|
20
|
+
return /*#__PURE__*/_jsx(DSPopper, {
|
|
21
|
+
blockName: blockName,
|
|
22
|
+
placement: placement,
|
|
23
|
+
contentComponent: menu,
|
|
24
|
+
isOpen: isOpen,
|
|
25
|
+
onOpen: onOpen,
|
|
26
|
+
modifiers: {
|
|
27
|
+
preventOverflow: {
|
|
28
|
+
enabled: true,
|
|
29
|
+
padding: 0,
|
|
30
|
+
boundariesElement: 'window'
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
showArrow: false,
|
|
34
|
+
triggerComponent: /*#__PURE__*/_jsx(DSButton, {
|
|
35
|
+
buttonType: "secondary",
|
|
36
|
+
disabled: disabled,
|
|
37
|
+
icon: _RecentDocuments || (_RecentDocuments = /*#__PURE__*/_jsx(RecentDocuments, {})),
|
|
38
|
+
iconSize: "s",
|
|
39
|
+
onClick: onClick
|
|
40
|
+
}),
|
|
41
|
+
zIndex: zIndex
|
|
42
|
+
});
|
|
43
|
+
};
|
|
41
44
|
|
|
42
45
|
export { TimePickerDropdown as default };
|
package/esm/TimePickerImpl.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
1
6
|
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
2
7
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
3
8
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
9
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
4
10
|
import { useState, useRef, useEffect } from 'react';
|
|
5
11
|
import moment from 'moment';
|
|
6
12
|
import memoizeOne from 'memoize-one';
|
|
7
|
-
import { getVisibleTimeByFormat } from '@elliemae/ds-utilities
|
|
13
|
+
import { getVisibleTimeByFormat } from '@elliemae/ds-utilities';
|
|
8
14
|
import { aggregatedClasses, convertPropToCssClassName } from '@elliemae/ds-classnames';
|
|
9
|
-
import DSInputGroup from '@elliemae/ds-form
|
|
10
|
-
import { TimeInputImpl } from '@elliemae/ds-form/TimeInput';
|
|
11
|
-
import DSInput from '@elliemae/ds-form/Input';
|
|
15
|
+
import { DSInputGroup, DSInput, TimeInputImpl } from '@elliemae/ds-form';
|
|
12
16
|
import { TimePickerMenu } from './TimePickerMenu.js';
|
|
13
17
|
import TimePickerDropdown from './TimePickerDropdown.js';
|
|
14
18
|
import { convertTimeString } from './utils.js';
|
|
@@ -20,27 +24,31 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
20
24
|
|
|
21
25
|
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; }
|
|
22
26
|
const blockName = 'time-picker';
|
|
23
|
-
const TimePickerContainer = aggregatedClasses(DSInputGroup)(blockName, null,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
const TimePickerContainer = aggregatedClasses(DSInputGroup)(blockName, null, _ref => {
|
|
28
|
+
let {
|
|
29
|
+
isMenuOpened
|
|
30
|
+
} = _ref;
|
|
31
|
+
return {
|
|
32
|
+
isMenuOpened
|
|
33
|
+
};
|
|
34
|
+
});
|
|
28
35
|
|
|
29
|
-
const TimePickerImpl =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
const TimePickerImpl = _ref2 => {
|
|
37
|
+
let {
|
|
38
|
+
value,
|
|
39
|
+
onChange,
|
|
40
|
+
onOpen,
|
|
41
|
+
format,
|
|
42
|
+
disabled,
|
|
43
|
+
hasHeader,
|
|
44
|
+
hasHeaderDisplay,
|
|
45
|
+
className,
|
|
46
|
+
containerProps,
|
|
47
|
+
placement,
|
|
48
|
+
zIndex,
|
|
49
|
+
disabledTimes,
|
|
50
|
+
minutesInterval
|
|
51
|
+
} = _ref2;
|
|
44
52
|
const [time, setTime] = useState();
|
|
45
53
|
const [isMenuOpened, setIsMenuOpened] = useState(false);
|
|
46
54
|
const [focusedColumn, setFocusedColumn] = useState(null);
|
|
@@ -105,7 +113,7 @@ const TimePickerImpl = ({
|
|
|
105
113
|
to: convertTimeString(disabledTimes.to)
|
|
106
114
|
};
|
|
107
115
|
return /*#__PURE__*/_jsx(TimePickerContainer, {
|
|
108
|
-
className:
|
|
116
|
+
className: "".concat(className, " variant-").concat(!disabled ? 'default' : 'disabled'),
|
|
109
117
|
containerProps: containerProps,
|
|
110
118
|
disabled: disabled,
|
|
111
119
|
rightAddon: /*#__PURE__*/_jsx(TimePickerDropdown, {
|
|
@@ -134,11 +142,11 @@ const TimePickerImpl = ({
|
|
|
134
142
|
})
|
|
135
143
|
})
|
|
136
144
|
}, void 0, /*#__PURE__*/_jsx(DSInput, {
|
|
137
|
-
customInputType:
|
|
145
|
+
customInputType: _ref3 => {
|
|
138
146
|
let {
|
|
139
147
|
onChange: handleChange
|
|
140
|
-
} =
|
|
141
|
-
restInputProps = _objectWithoutProperties(
|
|
148
|
+
} = _ref3,
|
|
149
|
+
restInputProps = _objectWithoutProperties(_ref3, _excluded);
|
|
142
150
|
|
|
143
151
|
return /*#__PURE__*/jsx(TimeInputImpl, _objectSpread({
|
|
144
152
|
clearable: true,
|
package/esm/TimePickerMenu.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
2
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
8
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
9
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
3
10
|
import { Component } from 'react';
|
|
4
|
-
import { range } from '@elliemae/ds-utilities/utils';
|
|
5
11
|
import { aggregatedClasses } from '@elliemae/ds-classnames';
|
|
6
12
|
import moment from 'moment';
|
|
7
|
-
import { addLeadingZeros } from '@elliemae/ds-utilities
|
|
13
|
+
import { range, addLeadingZeros } from '@elliemae/ds-utilities';
|
|
8
14
|
import { isAM } from './utils.js';
|
|
9
15
|
import PickerPanel from './PickerPanel.js';
|
|
10
16
|
|
|
@@ -25,12 +31,12 @@ class TimePickerMenu extends Component {
|
|
|
25
31
|
constructor(props) {
|
|
26
32
|
super(props);
|
|
27
33
|
|
|
28
|
-
|
|
34
|
+
this.renderHeader = () => {
|
|
29
35
|
const {
|
|
30
36
|
time
|
|
31
37
|
} = this.state;
|
|
32
38
|
return /*#__PURE__*/_jsx(TimePickerHeader, {}, void 0, time.format('hh:mma'));
|
|
33
|
-
}
|
|
39
|
+
};
|
|
34
40
|
|
|
35
41
|
this.state = {
|
|
36
42
|
time: moment(props.time || '', props.format) || moment()
|