@elliemae/ds-time-picker 1.60.0 → 2.0.0-alpha.12
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 +28 -71
- package/cjs/DSTimePickerMenu.js +17 -27
- package/cjs/PickerPanel.js +323 -340
- package/cjs/TimePickerDropdown.js +19 -29
- package/cjs/TimePickerImpl.js +89 -124
- package/cjs/TimePickerMenu.js +257 -295
- package/cjs/index.js +1 -30
- package/cjs/moveElementOnScroll.js +19 -28
- package/cjs/utils.js +14 -19
- package/esm/DSTimePicker.js +27 -69
- package/esm/DSTimePickerMenu.js +14 -25
- package/esm/PickerPanel.js +321 -330
- package/esm/TimePickerDropdown.js +18 -27
- package/esm/TimePickerImpl.js +84 -117
- package/esm/TimePickerMenu.js +254 -285
- package/esm/index.js +0 -29
- package/esm/moveElementOnScroll.js +18 -27
- package/esm/utils.js +14 -19
- package/package.json +66 -17
- package/types/DSTimePicker.d.ts +181 -0
- package/types/DSTimePickerMenu.d.ts +4 -0
- package/types/PickerPanel.d.ts +24 -0
- package/types/TimePickerDropdown.d.ts +25 -0
- package/types/TimePickerImpl.d.ts +35 -0
- package/types/TimePickerMenu.d.ts +19 -0
- package/types/index.d.ts +5 -0
- package/types/moveElementOnScroll.d.ts +13 -0
- package/types/utils.d.ts +8 -0
- package/DSTimePicker/package.json +0 -10
- package/DSTimePickerMenu/package.json +0 -10
- package/PickerPanel/package.json +0 -10
- package/TimePickerDropdown/package.json +0 -10
- package/TimePickerImpl/package.json +0 -10
- package/TimePickerMenu/package.json +0 -10
- package/cjs/DSTimePicker.js.map +0 -1
- package/cjs/DSTimePickerMenu.js.map +0 -1
- package/cjs/PickerPanel.js.map +0 -1
- package/cjs/TimePickerDropdown.js.map +0 -1
- package/cjs/TimePickerImpl.js.map +0 -1
- package/cjs/TimePickerMenu.js.map +0 -1
- package/cjs/index.js.map +0 -1
- package/cjs/moveElementOnScroll.js.map +0 -1
- package/cjs/utils.js.map +0 -1
- package/esm/DSTimePicker.js.map +0 -1
- package/esm/DSTimePickerMenu.js.map +0 -1
- package/esm/PickerPanel.js.map +0 -1
- package/esm/TimePickerDropdown.js.map +0 -1
- package/esm/TimePickerImpl.js.map +0 -1
- package/esm/TimePickerMenu.js.map +0 -1
- package/esm/index.js.map +0 -1
- package/esm/moveElementOnScroll.js.map +0 -1
- package/esm/utils.js.map +0 -1
- package/moveElementOnScroll/package.json +0 -10
- package/utils/package.json +0 -10
|
@@ -3,28 +3,20 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
function MoveElementOnScroll(element, _ref) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} : _ref$onUpdate,
|
|
19
|
-
_ref$onEndScroll = _ref.onEndScroll,
|
|
20
|
-
onEndScroll = _ref$onEndScroll === void 0 ? function () {
|
|
21
|
-
return null;
|
|
22
|
-
} : _ref$onEndScroll;
|
|
23
|
-
var moving = false;
|
|
24
|
-
var pos = min;
|
|
25
|
-
var lastPos = pos; // todo: move this to utils if we finally need it
|
|
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;
|
|
15
|
+
let moving = false;
|
|
16
|
+
let pos = min;
|
|
17
|
+
let lastPos = pos; // todo: move this to utils if we finally need it
|
|
26
18
|
|
|
27
|
-
|
|
19
|
+
const requestFrame = function () {
|
|
28
20
|
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (func) {
|
|
29
21
|
window.setTimeout(func, 1000 / 50);
|
|
30
22
|
};
|
|
@@ -32,11 +24,11 @@ function MoveElementOnScroll(element, _ref) {
|
|
|
32
24
|
|
|
33
25
|
function update() {
|
|
34
26
|
moving = true;
|
|
35
|
-
|
|
27
|
+
const delta = (pos - lastPos) / smooth;
|
|
36
28
|
lastPos += delta;
|
|
37
29
|
|
|
38
30
|
if (Math.abs(delta) > 0.7) {
|
|
39
|
-
requestFrame(
|
|
31
|
+
requestFrame(() => {
|
|
40
32
|
onUpdate(lastPos, delta);
|
|
41
33
|
update();
|
|
42
34
|
});
|
|
@@ -49,7 +41,7 @@ function MoveElementOnScroll(element, _ref) {
|
|
|
49
41
|
function scrolling(e) {
|
|
50
42
|
e.preventDefault(); // disable default scrolling
|
|
51
43
|
|
|
52
|
-
|
|
44
|
+
let delta = e.delta || e.wheelDelta;
|
|
53
45
|
|
|
54
46
|
if (delta === undefined) {
|
|
55
47
|
// for firefox
|
|
@@ -68,11 +60,11 @@ function MoveElementOnScroll(element, _ref) {
|
|
|
68
60
|
container.addEventListener('mousewheel', scrolling, false);
|
|
69
61
|
container.addEventListener('DOMMouseScroll', scrolling, false);
|
|
70
62
|
return {
|
|
71
|
-
unsubscribe:
|
|
63
|
+
unsubscribe: () => {
|
|
72
64
|
container.removeEventListener('mousewheel', scrolling);
|
|
73
65
|
container.removeEventListener('DOMMouseScroll', scrolling);
|
|
74
66
|
},
|
|
75
|
-
updatePosition:
|
|
67
|
+
updatePosition: newPos => {
|
|
76
68
|
pos = -newPos;
|
|
77
69
|
lastPos = -pos;
|
|
78
70
|
}
|
|
@@ -80,5 +72,4 @@ function MoveElementOnScroll(element, _ref) {
|
|
|
80
72
|
}
|
|
81
73
|
|
|
82
74
|
exports.MoveElementOnScroll = MoveElementOnScroll;
|
|
83
|
-
exports[
|
|
84
|
-
//# sourceMappingURL=moveElementOnScroll.js.map
|
|
75
|
+
exports["default"] = MoveElementOnScroll;
|
package/cjs/utils.js
CHANGED
|
@@ -2,37 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const validateIndex = (index, options) => {
|
|
6
6
|
if (index < 0) return 0;
|
|
7
7
|
if (index >= options.length) return options.length - 1;
|
|
8
8
|
return index;
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return option[valueProperty] === selectedOption;
|
|
14
|
-
});
|
|
10
|
+
const getOptionIndex = function (options, selectedOption) {
|
|
11
|
+
let valueProperty = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'value';
|
|
12
|
+
const index = options.findIndex(option => option[valueProperty] === selectedOption);
|
|
15
13
|
return validateIndex(index, options);
|
|
16
14
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
var convertTimeString = function convertTimeString(string) {
|
|
15
|
+
const isAM = time => time && time.hour() < 12;
|
|
16
|
+
const convertTimeString = string => {
|
|
21
17
|
if (!string) return null;
|
|
22
|
-
|
|
18
|
+
let meridiem = 'AM';
|
|
23
19
|
if (string.toUpperCase().includes('PM')) meridiem = 'PM';
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
const arr = string.split(':');
|
|
21
|
+
let hour = parseInt(arr[0], 10);
|
|
26
22
|
if (meridiem === 'PM' && hour !== 12) hour += 12; // formats to 24
|
|
27
23
|
|
|
28
24
|
if (meridiem === 'AM' && hour === 12) hour = 0;
|
|
29
25
|
if (meridiem === 'PM' && hour === 12) hour = 12;
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
const min = parseInt(arr[1], 10);
|
|
27
|
+
const sec = parseInt(arr[2], 10);
|
|
32
28
|
return {
|
|
33
|
-
hour
|
|
34
|
-
min
|
|
35
|
-
sec
|
|
29
|
+
hour,
|
|
30
|
+
min,
|
|
31
|
+
sec
|
|
36
32
|
};
|
|
37
33
|
};
|
|
38
34
|
|
|
@@ -40,4 +36,3 @@ exports.convertTimeString = convertTimeString;
|
|
|
40
36
|
exports.getOptionIndex = getOptionIndex;
|
|
41
37
|
exports.isAM = isAM;
|
|
42
38
|
exports.validateIndex = validateIndex;
|
|
43
|
-
//# sourceMappingURL=utils.js.map
|
package/esm/DSTimePicker.js
CHANGED
|
@@ -1,71 +1,31 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'react';
|
|
2
2
|
import { PropTypes, describe } from 'react-desc';
|
|
3
3
|
import moment from 'moment';
|
|
4
4
|
import TimePickerImpl from './TimePickerImpl.js';
|
|
5
|
-
import '
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
import '@elliemae/ds-popper';
|
|
30
|
-
|
|
31
|
-
var DSTimePicker = function DSTimePicker(_ref) {
|
|
32
|
-
var _ref$containerProps = _ref.containerProps,
|
|
33
|
-
containerProps = _ref$containerProps === void 0 ? {} : _ref$containerProps,
|
|
34
|
-
innerRef = _ref.innerRef,
|
|
35
|
-
_ref$className = _ref.className,
|
|
36
|
-
className = _ref$className === void 0 ? '' : _ref$className,
|
|
37
|
-
_ref$disabled = _ref.disabled,
|
|
38
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
39
|
-
_ref$value = _ref.value,
|
|
40
|
-
value = _ref$value === void 0 ? '' : _ref$value,
|
|
41
|
-
format = _ref.format,
|
|
42
|
-
_ref$style = _ref.style,
|
|
43
|
-
style = _ref$style === void 0 ? {} : _ref$style,
|
|
44
|
-
_ref$onChange = _ref.onChange,
|
|
45
|
-
onChange = _ref$onChange === void 0 ? function () {
|
|
46
|
-
return null;
|
|
47
|
-
} : _ref$onChange,
|
|
48
|
-
_ref$onOpen = _ref.onOpen,
|
|
49
|
-
onOpen = _ref$onOpen === void 0 ? function () {
|
|
50
|
-
return null;
|
|
51
|
-
} : _ref$onOpen,
|
|
52
|
-
_ref$isOpen = _ref.isOpen,
|
|
53
|
-
isOpen = _ref$isOpen === void 0 ? undefined : _ref$isOpen,
|
|
54
|
-
_ref$clearable = _ref.clearable,
|
|
55
|
-
clearable = _ref$clearable === void 0 ? false : _ref$clearable,
|
|
56
|
-
_ref$hasHeader = _ref.hasHeader,
|
|
57
|
-
hasHeader = _ref$hasHeader === void 0 ? true : _ref$hasHeader,
|
|
58
|
-
_ref$hasHeaderDisplay = _ref.hasHeaderDisplay,
|
|
59
|
-
hasHeaderDisplay = _ref$hasHeaderDisplay === void 0 ? false : _ref$hasHeaderDisplay,
|
|
60
|
-
ariaLabel = _ref['aria-label'],
|
|
61
|
-
_ref$zIndex = _ref.zIndex,
|
|
62
|
-
zIndex = _ref$zIndex === void 0 ? 'auto' : _ref$zIndex,
|
|
63
|
-
_ref$placement = _ref.placement,
|
|
64
|
-
placement = _ref$placement === void 0 ? 'bottom' : _ref$placement,
|
|
65
|
-
disabledTimes = _ref.disabledTimes,
|
|
66
|
-
_ref$minutesInterval = _ref.minutesInterval,
|
|
67
|
-
minutesInterval = _ref$minutesInterval === void 0 ? 1 : _ref$minutesInterval;
|
|
68
|
-
return /*#__PURE__*/React.createElement(TimePickerImpl, {
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
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, {
|
|
69
29
|
ref: innerRef,
|
|
70
30
|
"aria-label": ariaLabel,
|
|
71
31
|
className: className,
|
|
@@ -90,7 +50,7 @@ var DSTimePicker = function DSTimePicker(_ref) {
|
|
|
90
50
|
DSTimePicker.defaultProps = {
|
|
91
51
|
format: 'hh:mm:ss A'
|
|
92
52
|
};
|
|
93
|
-
|
|
53
|
+
const props = {
|
|
94
54
|
/** a11y label */
|
|
95
55
|
'aria-label': PropTypes.string.description('a11y label'),
|
|
96
56
|
|
|
@@ -145,9 +105,7 @@ var props = {
|
|
|
145
105
|
/** steps for the picker */
|
|
146
106
|
minutesInterval: PropTypes.number.description('steps for the picker')
|
|
147
107
|
};
|
|
148
|
-
|
|
149
|
-
var DSTimePickerWithSchema = describe(DSTimePicker);
|
|
108
|
+
const DSTimePickerWithSchema = describe(DSTimePicker);
|
|
150
109
|
DSTimePickerWithSchema.propTypes = props;
|
|
151
110
|
|
|
152
111
|
export { DSTimePicker, DSTimePickerWithSchema, DSTimePicker as default };
|
|
153
|
-
//# sourceMappingURL=DSTimePicker.js.map
|
package/esm/DSTimePickerMenu.js
CHANGED
|
@@ -1,35 +1,24 @@
|
|
|
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';
|
|
6
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
7
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
8
|
+
import 'react';
|
|
2
9
|
import styled from 'styled-components';
|
|
3
10
|
import { TimePickerMenu } from './TimePickerMenu.js';
|
|
4
|
-
import '
|
|
5
|
-
import '@babel/runtime/helpers/esm/classCallCheck';
|
|
6
|
-
import '@babel/runtime/helpers/esm/createClass';
|
|
7
|
-
import '@babel/runtime/helpers/esm/assertThisInitialized';
|
|
8
|
-
import '@babel/runtime/helpers/esm/inherits';
|
|
9
|
-
import '@babel/runtime/helpers/esm/possibleConstructorReturn';
|
|
10
|
-
import '@babel/runtime/helpers/esm/getPrototypeOf';
|
|
11
|
-
import 'prop-types';
|
|
12
|
-
import '@elliemae/ds-classnames';
|
|
13
|
-
import 'moment';
|
|
14
|
-
import '@elliemae/ds-utilities';
|
|
15
|
-
import './utils.js';
|
|
16
|
-
import './PickerPanel.js';
|
|
17
|
-
import '@babel/runtime/helpers/esm/extends';
|
|
18
|
-
import '@babel/runtime/helpers/esm/slicedToArray';
|
|
19
|
-
import '@babel/runtime/helpers/esm/toArray';
|
|
20
|
-
import 'lodash';
|
|
21
|
-
import 'memoize-one';
|
|
22
|
-
import '@elliemae/ds-icons';
|
|
23
|
-
import '@elliemae/ds-button';
|
|
24
|
-
import './moveElementOnScroll.js';
|
|
11
|
+
import { jsx } from 'react/jsx-runtime';
|
|
25
12
|
|
|
26
|
-
var
|
|
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
|
+
const DSTimePickerMenuWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
27
17
|
componentId: "sc-1lnruj5-0"
|
|
28
18
|
})(["display:flex;height:18.6rem;"]);
|
|
29
19
|
|
|
30
20
|
function DSTimePickerMenu(props) {
|
|
31
|
-
return /*#__PURE__*/
|
|
21
|
+
return /*#__PURE__*/_jsx(DSTimePickerMenuWrapper, {}, void 0, /*#__PURE__*/jsx(TimePickerMenu, _objectSpread({}, props)));
|
|
32
22
|
}
|
|
33
23
|
|
|
34
24
|
export { DSTimePickerMenu, DSTimePickerMenu as default };
|
|
35
|
-
//# sourceMappingURL=DSTimePickerMenu.js.map
|