@elliemae/ds-time-picker 2.0.0-next.7 → 2.0.0-rc.10
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 +42 -39
- package/cjs/DSTimePickerMenu.js +5 -0
- package/cjs/PickerPanel.js +42 -29
- package/cjs/TimePickerDropdown.js +36 -34
- package/cjs/TimePickerImpl.js +38 -33
- package/cjs/TimePickerMenu.js +16 -10
- package/cjs/moveElementOnScroll.js +10 -9
- package/cjs/utils.js +2 -1
- package/esm/DSTimePicker.js +42 -39
- package/esm/DSTimePickerMenu.js +5 -0
- package/esm/PickerPanel.js +39 -24
- package/esm/TimePickerDropdown.js +36 -33
- package/esm/TimePickerImpl.js +34 -27
- 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 +134 -19
- package/types/TimePickerDropdown.d.ts +1 -1
package/cjs/DSTimePicker.js
CHANGED
|
@@ -12,45 +12,48 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
12
12
|
|
|
13
13
|
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
14
14
|
|
|
15
|
-
const DSTimePicker =
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
15
|
+
const DSTimePicker = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
containerProps = {},
|
|
18
|
+
innerRef,
|
|
19
|
+
className = '',
|
|
20
|
+
disabled = false,
|
|
21
|
+
value = '',
|
|
22
|
+
format,
|
|
23
|
+
style = {},
|
|
24
|
+
onChange = () => null,
|
|
25
|
+
onOpen = () => null,
|
|
26
|
+
isOpen = undefined,
|
|
27
|
+
clearable = false,
|
|
28
|
+
hasHeader = true,
|
|
29
|
+
hasHeaderDisplay = false,
|
|
30
|
+
'aria-label': ariaLabel,
|
|
31
|
+
zIndex = 'auto',
|
|
32
|
+
placement = 'bottom',
|
|
33
|
+
disabledTimes,
|
|
34
|
+
minutesInterval = 1
|
|
35
|
+
} = _ref;
|
|
36
|
+
return /*#__PURE__*/jsxRuntime.jsx(TimePickerImpl, {
|
|
37
|
+
ref: innerRef,
|
|
38
|
+
"aria-label": ariaLabel,
|
|
39
|
+
className: className,
|
|
40
|
+
clearable: clearable,
|
|
41
|
+
containerProps: containerProps,
|
|
42
|
+
disabled: disabled,
|
|
43
|
+
format: format,
|
|
44
|
+
hasHeader: hasHeader,
|
|
45
|
+
hasHeaderDisplay: hasHeaderDisplay,
|
|
46
|
+
isOpen: isOpen,
|
|
47
|
+
onChange: onChange,
|
|
48
|
+
onOpen: onOpen,
|
|
49
|
+
placement: placement,
|
|
50
|
+
style: style,
|
|
51
|
+
value: value,
|
|
52
|
+
zIndex: zIndex,
|
|
53
|
+
minutesInterval: minutesInterval,
|
|
54
|
+
disabledTimes: disabledTimes
|
|
55
|
+
});
|
|
56
|
+
};
|
|
54
57
|
|
|
55
58
|
DSTimePicker.defaultProps = {
|
|
56
59
|
format: 'hh:mm:ss A'
|
package/cjs/DSTimePickerMenu.js
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
5
10
|
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
11
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
7
12
|
require('react');
|
package/cjs/PickerPanel.js
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
4
3
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
5
5
|
require('core-js/modules/web.dom-collections.iterator.js');
|
|
6
|
+
require('core-js/modules/esnext.async-iterator.find.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.find.js');
|
|
9
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
10
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
11
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
12
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
13
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
14
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
6
15
|
var React = require('react');
|
|
7
16
|
var lodash = require('lodash');
|
|
8
17
|
var dsClassnames = require('@elliemae/ds-classnames');
|
|
9
18
|
var memoizeOne = require('memoize-one');
|
|
10
|
-
var
|
|
11
|
-
var ChevronSmallDown = require('@elliemae/ds-icons/ChevronSmallDown');
|
|
19
|
+
var dsIcons = require('@elliemae/ds-icons');
|
|
12
20
|
var DSButton = require('@elliemae/ds-button');
|
|
13
21
|
var moveElementOnScroll = require('./moveElementOnScroll.js');
|
|
14
22
|
var utils = require('./utils.js');
|
|
@@ -16,12 +24,10 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
16
24
|
|
|
17
25
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
26
|
|
|
19
|
-
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
20
27
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
28
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
21
29
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
22
30
|
var memoizeOne__default = /*#__PURE__*/_interopDefaultLegacy(memoizeOne);
|
|
23
|
-
var ChevronSmallUp__default = /*#__PURE__*/_interopDefaultLegacy(ChevronSmallUp);
|
|
24
|
-
var ChevronSmallDown__default = /*#__PURE__*/_interopDefaultLegacy(ChevronSmallDown);
|
|
25
31
|
var DSButton__default = /*#__PURE__*/_interopDefaultLegacy(DSButton);
|
|
26
32
|
|
|
27
33
|
var _SelectedCircle, _ChevronSmallUp, _ChevronSmallDown;
|
|
@@ -30,27 +36,34 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
30
36
|
|
|
31
37
|
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; }
|
|
32
38
|
const blockName = 'time-picker-panel';
|
|
33
|
-
const Container = dsClassnames.aggregatedClasses('div')(blockName, null,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
const Container = dsClassnames.aggregatedClasses('div')(blockName, null, _ref => {
|
|
40
|
+
let {
|
|
41
|
+
scrolling
|
|
42
|
+
} = _ref;
|
|
43
|
+
return {
|
|
44
|
+
scrolling
|
|
45
|
+
};
|
|
46
|
+
});
|
|
38
47
|
const Wrapper = dsClassnames.aggregatedClasses('div')(blockName, 'wrapper');
|
|
39
48
|
const PickerItemListContainer = dsClassnames.aggregatedClasses('div')(blockName, 'item-list-container');
|
|
40
49
|
const PickerItemList = dsClassnames.aggregatedClasses('div')(blockName, 'item-list');
|
|
41
50
|
const PickerHeader = dsClassnames.aggregatedClasses('div')(blockName, 'header');
|
|
42
|
-
const PickerItemContainer = dsClassnames.aggregatedClasses('div')(blockName, 'item',
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
const PickerItemContainer = dsClassnames.aggregatedClasses('div')(blockName, 'item', _ref2 => {
|
|
52
|
+
let {
|
|
53
|
+
selected,
|
|
54
|
+
disabled
|
|
55
|
+
} = _ref2;
|
|
56
|
+
return {
|
|
57
|
+
selected,
|
|
58
|
+
disabled
|
|
59
|
+
};
|
|
60
|
+
});
|
|
49
61
|
const PickerSelectedOptionSelected = dsClassnames.aggregatedClasses('div')(blockName, 'selected-container');
|
|
50
62
|
const SelectedCircle = dsClassnames.aggregatedClasses('div')(blockName, 'selected-circle');
|
|
51
63
|
const ArrowButtonContainer = dsClassnames.aggregatedClasses('div')(blockName, 'arrow-container');
|
|
52
64
|
|
|
53
|
-
const getOptionIndex = (options, selectedOption
|
|
65
|
+
const getOptionIndex = function (options, selectedOption) {
|
|
66
|
+
let valueProperty = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'value';
|
|
54
67
|
const index = options.findIndex(option => option[valueProperty] === selectedOption);
|
|
55
68
|
return utils.validateIndex(index, options);
|
|
56
69
|
};
|
|
@@ -64,8 +77,7 @@ const arrowProps = {
|
|
|
64
77
|
class PickerPanel extends React.Component {
|
|
65
78
|
constructor(props) {
|
|
66
79
|
super(props);
|
|
67
|
-
|
|
68
|
-
_defineProperty__default["default"](this, "computeContainerTranslation", memoizeOne__default["default"](index => {
|
|
80
|
+
this.computeContainerTranslation = memoizeOne__default["default"](index => {
|
|
69
81
|
const {
|
|
70
82
|
options,
|
|
71
83
|
valueProperty
|
|
@@ -78,14 +90,14 @@ class PickerPanel extends React.Component {
|
|
|
78
90
|
const listYPosition = this.minYListPosition - selectedOptionIndex * this.optionHeight;
|
|
79
91
|
if (this.scrollHandler && !scrolling) this.scrollHandler.updatePosition(listYPosition);
|
|
80
92
|
return listYPosition;
|
|
81
|
-
})
|
|
93
|
+
});
|
|
82
94
|
|
|
83
|
-
|
|
95
|
+
this.renderHeader = () => {
|
|
84
96
|
const {
|
|
85
97
|
header
|
|
86
98
|
} = this.props;
|
|
87
99
|
return /*#__PURE__*/_jsx__default["default"](PickerHeader, {}, void 0, header);
|
|
88
|
-
}
|
|
100
|
+
};
|
|
89
101
|
|
|
90
102
|
this.pickerListContainerRef = /*#__PURE__*/React__default["default"].createRef();
|
|
91
103
|
this.pickerListRef = /*#__PURE__*/React__default["default"].createRef();
|
|
@@ -130,9 +142,10 @@ class PickerPanel extends React.Component {
|
|
|
130
142
|
this.scrollHandler.unsubscribe();
|
|
131
143
|
}
|
|
132
144
|
|
|
133
|
-
static getDerivedStateFromProps(nextProps, {
|
|
134
|
-
|
|
135
|
-
|
|
145
|
+
static getDerivedStateFromProps(nextProps, _ref3) {
|
|
146
|
+
let {
|
|
147
|
+
prevProps
|
|
148
|
+
} = _ref3;
|
|
136
149
|
const {
|
|
137
150
|
selected,
|
|
138
151
|
valueProperty,
|
|
@@ -311,7 +324,7 @@ class PickerPanel extends React.Component {
|
|
|
311
324
|
"aria-label": "Chevron Up",
|
|
312
325
|
"data-testid": "".concat(type, "-chevron-up"),
|
|
313
326
|
disabled: activeIndex <= 0,
|
|
314
|
-
icon: _ChevronSmallUp || (_ChevronSmallUp = /*#__PURE__*/_jsx__default["default"](
|
|
327
|
+
icon: _ChevronSmallUp || (_ChevronSmallUp = /*#__PURE__*/_jsx__default["default"](dsIcons.ChevronSmallUp, {})),
|
|
315
328
|
onClick: this.handleStepMoveUp,
|
|
316
329
|
tabIndex: -1
|
|
317
330
|
}))), /*#__PURE__*/_jsx__default["default"](PickerItemListContainer, {
|
|
@@ -370,7 +383,7 @@ class PickerPanel extends React.Component {
|
|
|
370
383
|
"aria-label": "Chevron Down",
|
|
371
384
|
"data-testid": "".concat(type, "-chevron-down"),
|
|
372
385
|
disabled: activeIndex >= options.length - 1,
|
|
373
|
-
icon: _ChevronSmallDown || (_ChevronSmallDown = /*#__PURE__*/_jsx__default["default"](
|
|
386
|
+
icon: _ChevronSmallDown || (_ChevronSmallDown = /*#__PURE__*/_jsx__default["default"](dsIcons.ChevronSmallDown, {})),
|
|
374
387
|
onClick: this.handleStepMoveDown,
|
|
375
388
|
tabIndex: -1
|
|
376
389
|
})))));
|
|
@@ -2,50 +2,52 @@
|
|
|
2
2
|
|
|
3
3
|
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
4
4
|
require('react');
|
|
5
|
-
var
|
|
5
|
+
var dsIcons = require('@elliemae/ds-icons');
|
|
6
6
|
var DSButton = require('@elliemae/ds-button');
|
|
7
7
|
var DSPopper = require('@elliemae/ds-popper');
|
|
8
8
|
|
|
9
9
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
10
|
|
|
11
11
|
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
12
|
-
var RecentDocuments__default = /*#__PURE__*/_interopDefaultLegacy(RecentDocuments);
|
|
13
12
|
var DSButton__default = /*#__PURE__*/_interopDefaultLegacy(DSButton);
|
|
14
13
|
var DSPopper__default = /*#__PURE__*/_interopDefaultLegacy(DSPopper);
|
|
15
14
|
|
|
16
15
|
var _RecentDocuments;
|
|
17
16
|
|
|
18
|
-
const TimePickerDropdown =
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
})
|
|
17
|
+
const TimePickerDropdown = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
disabled = false,
|
|
20
|
+
onClick,
|
|
21
|
+
onOpen,
|
|
22
|
+
isOpen,
|
|
23
|
+
menu,
|
|
24
|
+
zIndex,
|
|
25
|
+
blockName,
|
|
26
|
+
placement
|
|
27
|
+
} = _ref;
|
|
28
|
+
return /*#__PURE__*/_jsx__default["default"](DSPopper__default["default"], {
|
|
29
|
+
blockName: blockName,
|
|
30
|
+
placement: placement,
|
|
31
|
+
contentComponent: menu,
|
|
32
|
+
isOpen: isOpen,
|
|
33
|
+
onOpen: onOpen,
|
|
34
|
+
modifiers: {
|
|
35
|
+
preventOverflow: {
|
|
36
|
+
enabled: true,
|
|
37
|
+
padding: 0,
|
|
38
|
+
boundariesElement: 'window'
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
showArrow: false,
|
|
42
|
+
triggerComponent: /*#__PURE__*/_jsx__default["default"](DSButton__default["default"], {
|
|
43
|
+
buttonType: "secondary",
|
|
44
|
+
disabled: disabled,
|
|
45
|
+
icon: _RecentDocuments || (_RecentDocuments = /*#__PURE__*/_jsx__default["default"](dsIcons.RecentDocuments, {})),
|
|
46
|
+
iconSize: "s",
|
|
47
|
+
onClick: onClick
|
|
48
|
+
}),
|
|
49
|
+
zIndex: zIndex
|
|
50
|
+
});
|
|
51
|
+
};
|
|
50
52
|
|
|
51
53
|
module.exports = TimePickerDropdown;
|
package/cjs/TimePickerImpl.js
CHANGED
|
@@ -4,14 +4,17 @@ var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProp
|
|
|
4
4
|
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
5
5
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
6
|
require('core-js/modules/web.dom-collections.iterator.js');
|
|
7
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
10
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
11
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
7
12
|
var React = require('react');
|
|
8
13
|
var moment = require('moment');
|
|
9
14
|
var memoizeOne = require('memoize-one');
|
|
10
|
-
var
|
|
15
|
+
var dsUtilities = require('@elliemae/ds-utilities');
|
|
11
16
|
var dsClassnames = require('@elliemae/ds-classnames');
|
|
12
|
-
var
|
|
13
|
-
var TimeInput = require('@elliemae/ds-form/TimeInput');
|
|
14
|
-
var DSInput = require('@elliemae/ds-form/Input');
|
|
17
|
+
var dsForm = require('@elliemae/ds-form');
|
|
15
18
|
var TimePickerMenu = require('./TimePickerMenu.js');
|
|
16
19
|
var TimePickerDropdown = require('./TimePickerDropdown.js');
|
|
17
20
|
var utils = require('./utils.js');
|
|
@@ -24,8 +27,6 @@ var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
|
24
27
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
25
28
|
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
26
29
|
var memoizeOne__default = /*#__PURE__*/_interopDefaultLegacy(memoizeOne);
|
|
27
|
-
var DSInputGroup__default = /*#__PURE__*/_interopDefaultLegacy(DSInputGroup);
|
|
28
|
-
var DSInput__default = /*#__PURE__*/_interopDefaultLegacy(DSInput);
|
|
29
30
|
|
|
30
31
|
const _excluded = ["onChange"];
|
|
31
32
|
|
|
@@ -33,27 +34,31 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
33
34
|
|
|
34
35
|
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; }
|
|
35
36
|
const blockName = 'time-picker';
|
|
36
|
-
const TimePickerContainer = dsClassnames.aggregatedClasses(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
37
|
+
const TimePickerContainer = dsClassnames.aggregatedClasses(dsForm.DSInputGroup)(blockName, null, _ref => {
|
|
38
|
+
let {
|
|
39
|
+
isMenuOpened
|
|
40
|
+
} = _ref;
|
|
41
|
+
return {
|
|
42
|
+
isMenuOpened
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const TimePickerImpl = _ref2 => {
|
|
47
|
+
let {
|
|
48
|
+
value,
|
|
49
|
+
onChange,
|
|
50
|
+
onOpen,
|
|
51
|
+
format,
|
|
52
|
+
disabled,
|
|
53
|
+
hasHeader,
|
|
54
|
+
hasHeaderDisplay,
|
|
55
|
+
className,
|
|
56
|
+
containerProps,
|
|
57
|
+
placement,
|
|
58
|
+
zIndex,
|
|
59
|
+
disabledTimes,
|
|
60
|
+
minutesInterval
|
|
61
|
+
} = _ref2;
|
|
57
62
|
const [time, setTime] = React.useState();
|
|
58
63
|
const [isMenuOpened, setIsMenuOpened] = React.useState(false);
|
|
59
64
|
const [focusedColumn, setFocusedColumn] = React.useState(null);
|
|
@@ -110,7 +115,7 @@ const TimePickerImpl = ({
|
|
|
110
115
|
if (!isOpen) setFocusedColumn(null);
|
|
111
116
|
};
|
|
112
117
|
|
|
113
|
-
const getVisibleTimePanels = memoizeOne__default["default"](format =>
|
|
118
|
+
const getVisibleTimePanels = memoizeOne__default["default"](format => dsUtilities.getVisibleTimeByFormat(format));
|
|
114
119
|
const timePickerBlockName = dsClassnames.convertPropToCssClassName(blockName);
|
|
115
120
|
const visiblePanels = getVisibleTimePanels(format);
|
|
116
121
|
const disabledTimeRange = disabledTimes && {
|
|
@@ -146,14 +151,14 @@ const TimePickerImpl = ({
|
|
|
146
151
|
}, visiblePanels))
|
|
147
152
|
})
|
|
148
153
|
})
|
|
149
|
-
}, void 0, /*#__PURE__*/_jsx__default["default"](
|
|
150
|
-
customInputType:
|
|
154
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"](dsForm.DSInput, {
|
|
155
|
+
customInputType: _ref3 => {
|
|
151
156
|
let {
|
|
152
157
|
onChange: handleChange
|
|
153
|
-
} =
|
|
154
|
-
restInputProps = _objectWithoutProperties__default["default"](
|
|
158
|
+
} = _ref3,
|
|
159
|
+
restInputProps = _objectWithoutProperties__default["default"](_ref3, _excluded);
|
|
155
160
|
|
|
156
|
-
return /*#__PURE__*/jsxRuntime.jsx(
|
|
161
|
+
return /*#__PURE__*/jsxRuntime.jsx(dsForm.TimeInputImpl, _objectSpread({
|
|
157
162
|
clearable: true,
|
|
158
163
|
disabled: disabled,
|
|
159
164
|
format: format,
|
package/cjs/TimePickerMenu.js
CHANGED
|
@@ -2,20 +2,26 @@
|
|
|
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; }
|
|
@@ -35,12 +41,12 @@ 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
48
|
return /*#__PURE__*/_jsx__default["default"](TimePickerHeader, {}, void 0, time.format('hh:mma'));
|
|
43
|
-
}
|
|
49
|
+
};
|
|
44
50
|
|
|
45
51
|
this.state = {
|
|
46
52
|
time: moment__default["default"](props.time || '', props.format) || moment__default["default"]()
|
|
@@ -158,8 +164,8 @@ 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 &&
|
|
167
|
+
const rangeHours = use12Hours ? dsUtilities.range(1, 13) : dsUtilities.range(24);
|
|
168
|
+
const hoursOptions = rangeHours.map(generateOption(withLeadingZeros && dsUtilities.addLeadingZeros(2)));
|
|
163
169
|
return /*#__PURE__*/_jsx__default["default"](PickerPanel, {
|
|
164
170
|
type: "hour",
|
|
165
171
|
time: time,
|
|
@@ -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
|
|
|
@@ -230,7 +236,7 @@ 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 =
|
|
239
|
+
const rangeSeconds = dsUtilities.range(60).map(generateOption(withLeadingZeros && dsUtilities.addLeadingZeros(2)));
|
|
234
240
|
return /*#__PURE__*/_jsx__default["default"](PickerPanel, {
|
|
235
241
|
type: "seconds",
|
|
236
242
|
hasHeader: hasHeader,
|
|
@@ -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
|
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,12 +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';
|
|
3
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';
|
|
4
13
|
import React, { Component } from 'react';
|
|
5
14
|
import { findIndex } from 'lodash';
|
|
6
15
|
import { aggregatedClasses } from '@elliemae/ds-classnames';
|
|
7
16
|
import memoizeOne from 'memoize-one';
|
|
8
|
-
import ChevronSmallUp from '@elliemae/ds-icons
|
|
9
|
-
import ChevronSmallDown from '@elliemae/ds-icons/ChevronSmallDown';
|
|
17
|
+
import { ChevronSmallUp, ChevronSmallDown } from '@elliemae/ds-icons';
|
|
10
18
|
import DSButton from '@elliemae/ds-button';
|
|
11
19
|
import { MoveElementOnScroll } from './moveElementOnScroll.js';
|
|
12
20
|
import { validateIndex } from './utils.js';
|
|
@@ -18,27 +26,34 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
18
26
|
|
|
19
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; }
|
|
20
28
|
const blockName = 'time-picker-panel';
|
|
21
|
-
const Container = aggregatedClasses('div')(blockName, null,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
const Container = aggregatedClasses('div')(blockName, null, _ref => {
|
|
30
|
+
let {
|
|
31
|
+
scrolling
|
|
32
|
+
} = _ref;
|
|
33
|
+
return {
|
|
34
|
+
scrolling
|
|
35
|
+
};
|
|
36
|
+
});
|
|
26
37
|
const Wrapper = aggregatedClasses('div')(blockName, 'wrapper');
|
|
27
38
|
const PickerItemListContainer = aggregatedClasses('div')(blockName, 'item-list-container');
|
|
28
39
|
const PickerItemList = aggregatedClasses('div')(blockName, 'item-list');
|
|
29
40
|
const PickerHeader = aggregatedClasses('div')(blockName, 'header');
|
|
30
|
-
const PickerItemContainer = aggregatedClasses('div')(blockName, 'item',
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
const PickerItemContainer = aggregatedClasses('div')(blockName, 'item', _ref2 => {
|
|
42
|
+
let {
|
|
43
|
+
selected,
|
|
44
|
+
disabled
|
|
45
|
+
} = _ref2;
|
|
46
|
+
return {
|
|
47
|
+
selected,
|
|
48
|
+
disabled
|
|
49
|
+
};
|
|
50
|
+
});
|
|
37
51
|
const PickerSelectedOptionSelected = aggregatedClasses('div')(blockName, 'selected-container');
|
|
38
52
|
const SelectedCircle = aggregatedClasses('div')(blockName, 'selected-circle');
|
|
39
53
|
const ArrowButtonContainer = aggregatedClasses('div')(blockName, 'arrow-container');
|
|
40
54
|
|
|
41
|
-
const getOptionIndex = (options, selectedOption
|
|
55
|
+
const getOptionIndex = function (options, selectedOption) {
|
|
56
|
+
let valueProperty = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'value';
|
|
42
57
|
const index = options.findIndex(option => option[valueProperty] === selectedOption);
|
|
43
58
|
return validateIndex(index, options);
|
|
44
59
|
};
|
|
@@ -52,8 +67,7 @@ const arrowProps = {
|
|
|
52
67
|
class PickerPanel extends Component {
|
|
53
68
|
constructor(props) {
|
|
54
69
|
super(props);
|
|
55
|
-
|
|
56
|
-
_defineProperty(this, "computeContainerTranslation", memoizeOne(index => {
|
|
70
|
+
this.computeContainerTranslation = memoizeOne(index => {
|
|
57
71
|
const {
|
|
58
72
|
options,
|
|
59
73
|
valueProperty
|
|
@@ -66,14 +80,14 @@ class PickerPanel extends Component {
|
|
|
66
80
|
const listYPosition = this.minYListPosition - selectedOptionIndex * this.optionHeight;
|
|
67
81
|
if (this.scrollHandler && !scrolling) this.scrollHandler.updatePosition(listYPosition);
|
|
68
82
|
return listYPosition;
|
|
69
|
-
})
|
|
83
|
+
});
|
|
70
84
|
|
|
71
|
-
|
|
85
|
+
this.renderHeader = () => {
|
|
72
86
|
const {
|
|
73
87
|
header
|
|
74
88
|
} = this.props;
|
|
75
89
|
return /*#__PURE__*/_jsx(PickerHeader, {}, void 0, header);
|
|
76
|
-
}
|
|
90
|
+
};
|
|
77
91
|
|
|
78
92
|
this.pickerListContainerRef = /*#__PURE__*/React.createRef();
|
|
79
93
|
this.pickerListRef = /*#__PURE__*/React.createRef();
|
|
@@ -118,9 +132,10 @@ class PickerPanel extends Component {
|
|
|
118
132
|
this.scrollHandler.unsubscribe();
|
|
119
133
|
}
|
|
120
134
|
|
|
121
|
-
static getDerivedStateFromProps(nextProps, {
|
|
122
|
-
|
|
123
|
-
|
|
135
|
+
static getDerivedStateFromProps(nextProps, _ref3) {
|
|
136
|
+
let {
|
|
137
|
+
prevProps
|
|
138
|
+
} = _ref3;
|
|
124
139
|
const {
|
|
125
140
|
selected,
|
|
126
141
|
valueProperty,
|
|
@@ -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,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 _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';
|
|
@@ -5,11 +10,9 @@ import 'core-js/modules/web.dom-collections.iterator.js';
|
|
|
5
10
|
import { useState, useRef, useEffect } from 'react';
|
|
6
11
|
import moment from 'moment';
|
|
7
12
|
import memoizeOne from 'memoize-one';
|
|
8
|
-
import { getVisibleTimeByFormat } from '@elliemae/ds-utilities
|
|
13
|
+
import { getVisibleTimeByFormat } from '@elliemae/ds-utilities';
|
|
9
14
|
import { aggregatedClasses, convertPropToCssClassName } from '@elliemae/ds-classnames';
|
|
10
|
-
import DSInputGroup from '@elliemae/ds-form
|
|
11
|
-
import { TimeInputImpl } from '@elliemae/ds-form/TimeInput';
|
|
12
|
-
import DSInput from '@elliemae/ds-form/Input';
|
|
15
|
+
import { DSInputGroup, DSInput, TimeInputImpl } from '@elliemae/ds-form';
|
|
13
16
|
import { TimePickerMenu } from './TimePickerMenu.js';
|
|
14
17
|
import TimePickerDropdown from './TimePickerDropdown.js';
|
|
15
18
|
import { convertTimeString } from './utils.js';
|
|
@@ -21,27 +24,31 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
21
24
|
|
|
22
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; }
|
|
23
26
|
const blockName = 'time-picker';
|
|
24
|
-
const TimePickerContainer = aggregatedClasses(DSInputGroup)(blockName, null,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
const TimePickerContainer = aggregatedClasses(DSInputGroup)(blockName, null, _ref => {
|
|
28
|
+
let {
|
|
29
|
+
isMenuOpened
|
|
30
|
+
} = _ref;
|
|
31
|
+
return {
|
|
32
|
+
isMenuOpened
|
|
33
|
+
};
|
|
34
|
+
});
|
|
29
35
|
|
|
30
|
-
const TimePickerImpl =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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;
|
|
45
52
|
const [time, setTime] = useState();
|
|
46
53
|
const [isMenuOpened, setIsMenuOpened] = useState(false);
|
|
47
54
|
const [focusedColumn, setFocusedColumn] = useState(null);
|
|
@@ -135,11 +142,11 @@ const TimePickerImpl = ({
|
|
|
135
142
|
})
|
|
136
143
|
})
|
|
137
144
|
}, void 0, /*#__PURE__*/_jsx(DSInput, {
|
|
138
|
-
customInputType:
|
|
145
|
+
customInputType: _ref3 => {
|
|
139
146
|
let {
|
|
140
147
|
onChange: handleChange
|
|
141
|
-
} =
|
|
142
|
-
restInputProps = _objectWithoutProperties(
|
|
148
|
+
} = _ref3,
|
|
149
|
+
restInputProps = _objectWithoutProperties(_ref3, _excluded);
|
|
143
150
|
|
|
144
151
|
return /*#__PURE__*/jsx(TimeInputImpl, _objectSpread({
|
|
145
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()
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
function MoveElementOnScroll(element, {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
function MoveElementOnScroll(element, _ref) {
|
|
2
|
+
let {
|
|
3
|
+
container,
|
|
4
|
+
min = 0,
|
|
5
|
+
max = element.offsetHeight,
|
|
6
|
+
speed = 1,
|
|
7
|
+
smooth = 2,
|
|
8
|
+
onUpdate = () => null,
|
|
9
|
+
onEndScroll = () => null
|
|
10
|
+
} = _ref;
|
|
10
11
|
let moving = false;
|
|
11
12
|
let pos = min;
|
|
12
13
|
let lastPos = pos; // todo: move this to utils if we finally need it
|
package/esm/utils.js
CHANGED
|
@@ -3,7 +3,8 @@ const validateIndex = (index, options) => {
|
|
|
3
3
|
if (index >= options.length) return options.length - 1;
|
|
4
4
|
return index;
|
|
5
5
|
};
|
|
6
|
-
const getOptionIndex = (options, selectedOption
|
|
6
|
+
const getOptionIndex = function (options, selectedOption) {
|
|
7
|
+
let valueProperty = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'value';
|
|
7
8
|
const index = options.findIndex(option => option[valueProperty] === selectedOption);
|
|
8
9
|
return validateIndex(index, options);
|
|
9
10
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-time-picker",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-rc.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Time Picker",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -64,25 +64,25 @@
|
|
|
64
64
|
"build": "node ../../scripts/build/build.js"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@elliemae/ds-button": "2.0.0-
|
|
68
|
-
"@elliemae/ds-classnames": "2.0.0-
|
|
69
|
-
"@elliemae/ds-form": "2.0.0-
|
|
70
|
-
"@elliemae/ds-icons": "2.0.0-
|
|
71
|
-
"@elliemae/ds-popper": "2.0.0-
|
|
72
|
-
"@elliemae/ds-utilities": "2.0.0-
|
|
67
|
+
"@elliemae/ds-button": "2.0.0-rc.10",
|
|
68
|
+
"@elliemae/ds-classnames": "2.0.0-rc.10",
|
|
69
|
+
"@elliemae/ds-form": "2.0.0-rc.10",
|
|
70
|
+
"@elliemae/ds-icons": "2.0.0-rc.10",
|
|
71
|
+
"@elliemae/ds-popper": "2.0.0-rc.10",
|
|
72
|
+
"@elliemae/ds-utilities": "2.0.0-rc.10",
|
|
73
73
|
"memoize-one": "~5.1.1",
|
|
74
74
|
"moment": "~2.29.1",
|
|
75
75
|
"prop-types": "~15.7.2",
|
|
76
76
|
"react-desc": "~4.1.3"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"styled-components": "~5.3.
|
|
79
|
+
"styled-components": "~5.3.3"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
82
|
"lodash": "^4.17.21",
|
|
83
83
|
"react": "^17.0.2",
|
|
84
84
|
"react-dom": "^17.0.2",
|
|
85
|
-
"styled-components": "^5.3.
|
|
85
|
+
"styled-components": "^5.3.3"
|
|
86
86
|
},
|
|
87
87
|
"publishConfig": {
|
|
88
88
|
"access": "public",
|
package/types/DSTimePicker.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference path="../../../../shared/typings/react-desc.d.ts" />
|
|
1
2
|
/// <reference types="react" />
|
|
2
3
|
declare const DSTimePicker: {
|
|
3
4
|
({ containerProps, innerRef, className, disabled, value, format, style, onChange, onOpen, isOpen, clearable, hasHeader, hasHeaderDisplay, "aria-label": ariaLabel, zIndex, placement, disabledTimes, minutesInterval, }: {
|
|
@@ -25,43 +26,157 @@ declare const DSTimePicker: {
|
|
|
25
26
|
};
|
|
26
27
|
propTypes: {
|
|
27
28
|
/** a11y label */
|
|
28
|
-
'aria-label':
|
|
29
|
+
'aria-label': {
|
|
30
|
+
defaultValue<T = unknown>(arg: T): {
|
|
31
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
32
|
+
};
|
|
33
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
34
|
+
};
|
|
29
35
|
/** inject props to time picker wrapper */
|
|
30
|
-
containerProps:
|
|
36
|
+
containerProps: {
|
|
37
|
+
defaultValue<T = unknown>(arg: T): {
|
|
38
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
39
|
+
};
|
|
40
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
41
|
+
};
|
|
31
42
|
/** Whether the time picker is disabled or not */
|
|
32
|
-
disabled:
|
|
43
|
+
disabled: {
|
|
44
|
+
defaultValue<T = unknown>(arg: T): {
|
|
45
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
46
|
+
};
|
|
47
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
48
|
+
};
|
|
33
49
|
/** Time picker value */
|
|
34
|
-
value:
|
|
50
|
+
value: {
|
|
51
|
+
defaultValue<T = unknown>(arg: T): {
|
|
52
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
53
|
+
};
|
|
54
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
55
|
+
};
|
|
35
56
|
/** Time format (hh:mm:ss, H:m:s) */
|
|
36
|
-
format:
|
|
57
|
+
format: {
|
|
58
|
+
defaultValue<T = unknown>(arg: T): {
|
|
59
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
60
|
+
};
|
|
61
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
62
|
+
};
|
|
37
63
|
/** toggle header style */
|
|
38
|
-
hasHeader:
|
|
64
|
+
hasHeader: {
|
|
65
|
+
defaultValue<T = unknown>(arg: T): {
|
|
66
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
67
|
+
};
|
|
68
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
69
|
+
};
|
|
39
70
|
/** toggle header display */
|
|
40
|
-
hasHeaderDisplay:
|
|
71
|
+
hasHeaderDisplay: {
|
|
72
|
+
defaultValue<T = unknown>(arg: T): {
|
|
73
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
74
|
+
};
|
|
75
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
76
|
+
};
|
|
41
77
|
/** Handler when time picker value changes */
|
|
42
|
-
onChange:
|
|
78
|
+
onChange: {
|
|
79
|
+
defaultValue<T = unknown>(arg: T): {
|
|
80
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
81
|
+
};
|
|
82
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
83
|
+
};
|
|
43
84
|
/** Handler when the time picker menu opens */
|
|
44
|
-
onOpen:
|
|
85
|
+
onOpen: {
|
|
86
|
+
defaultValue<T = unknown>(arg: T): {
|
|
87
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
88
|
+
};
|
|
89
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
90
|
+
};
|
|
45
91
|
/** Whether the time picker menu is opened or not */
|
|
46
|
-
isOpen:
|
|
92
|
+
isOpen: {
|
|
93
|
+
defaultValue<T = unknown>(arg: T): {
|
|
94
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
95
|
+
};
|
|
96
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
97
|
+
};
|
|
47
98
|
/** ref for time picker input */
|
|
48
|
-
innerRef:
|
|
99
|
+
innerRef: {
|
|
100
|
+
defaultValue<T = unknown>(arg: T): {
|
|
101
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
102
|
+
};
|
|
103
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
104
|
+
};
|
|
49
105
|
/** Enable to clear the time picker value */
|
|
50
|
-
clearable:
|
|
106
|
+
clearable: {
|
|
107
|
+
defaultValue<T = unknown>(arg: T): {
|
|
108
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
109
|
+
};
|
|
110
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
111
|
+
};
|
|
51
112
|
/** class for time picker */
|
|
52
|
-
className:
|
|
113
|
+
className: {
|
|
114
|
+
defaultValue<T = unknown>(arg: T): {
|
|
115
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
116
|
+
};
|
|
117
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
118
|
+
};
|
|
53
119
|
/** style object */
|
|
54
|
-
style:
|
|
120
|
+
style: {
|
|
121
|
+
defaultValue<T = unknown>(arg: T): {
|
|
122
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
123
|
+
};
|
|
124
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
125
|
+
};
|
|
55
126
|
/** z index for menu */
|
|
56
|
-
zIndex:
|
|
127
|
+
zIndex: {
|
|
128
|
+
defaultValue<T = unknown>(arg: T): {
|
|
129
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
130
|
+
};
|
|
131
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
132
|
+
};
|
|
57
133
|
/** DSPopper placement */
|
|
58
|
-
placement:
|
|
134
|
+
placement: {
|
|
135
|
+
defaultValue<T = unknown>(arg: T): {
|
|
136
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
137
|
+
};
|
|
138
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
139
|
+
};
|
|
59
140
|
/** disabled time */
|
|
60
|
-
disabledTimes:
|
|
141
|
+
disabledTimes: {
|
|
142
|
+
defaultValue<T = unknown>(arg: T): {
|
|
143
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
144
|
+
};
|
|
145
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
146
|
+
};
|
|
61
147
|
/** steps for the picker */
|
|
62
|
-
minutesInterval:
|
|
148
|
+
minutesInterval: {
|
|
149
|
+
defaultValue<T = unknown>(arg: T): {
|
|
150
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
151
|
+
};
|
|
152
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
153
|
+
};
|
|
63
154
|
};
|
|
64
155
|
};
|
|
65
|
-
declare const DSTimePickerWithSchema:
|
|
156
|
+
declare const DSTimePickerWithSchema: {
|
|
157
|
+
(props?: {
|
|
158
|
+
containerProps?: {} | undefined;
|
|
159
|
+
innerRef: any;
|
|
160
|
+
className?: string | undefined;
|
|
161
|
+
disabled?: boolean | undefined;
|
|
162
|
+
value?: string | undefined;
|
|
163
|
+
format: any;
|
|
164
|
+
style?: {} | undefined;
|
|
165
|
+
onChange?: (() => null) | undefined;
|
|
166
|
+
onOpen?: (() => null) | undefined;
|
|
167
|
+
isOpen?: undefined;
|
|
168
|
+
clearable?: boolean | undefined;
|
|
169
|
+
hasHeader?: boolean | undefined;
|
|
170
|
+
hasHeaderDisplay?: boolean | undefined;
|
|
171
|
+
"aria-label": any;
|
|
172
|
+
zIndex?: string | undefined;
|
|
173
|
+
placement?: string | undefined;
|
|
174
|
+
disabledTimes: any;
|
|
175
|
+
minutesInterval?: number | undefined;
|
|
176
|
+
} | undefined): JSX.Element;
|
|
177
|
+
propTypes: unknown;
|
|
178
|
+
/** toggle header display */
|
|
179
|
+
toTypescript: () => import("react-desc").TypescriptSchema;
|
|
180
|
+
};
|
|
66
181
|
export { DSTimePicker, DSTimePickerWithSchema };
|
|
67
182
|
export default DSTimePicker;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
declare const TimePickerDropdown: {
|
|
4
|
-
({ disabled, onClick, onOpen, isOpen, menu, zIndex, blockName, placement
|
|
4
|
+
({ disabled, onClick, onOpen, isOpen, menu, zIndex, blockName, placement }: {
|
|
5
5
|
disabled?: boolean | undefined;
|
|
6
6
|
onClick: any;
|
|
7
7
|
onOpen: any;
|