@elliemae/ds-time-picker 2.2.2-rc.1 → 2.3.0-alpha.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/dist/cjs/DSTimePicker.js +106 -0
- package/dist/cjs/DSTimePicker.js.map +7 -0
- package/dist/cjs/DSTimePickerMenu.js +48 -0
- package/dist/cjs/DSTimePickerMenu.js.map +7 -0
- package/dist/cjs/PickerPanel.js +299 -0
- package/dist/cjs/PickerPanel.js.map +7 -0
- package/dist/cjs/TimePickerDropdown.js +74 -0
- package/dist/cjs/TimePickerDropdown.js.map +7 -0
- package/dist/cjs/TimePickerImpl.js +183 -0
- package/dist/cjs/TimePickerImpl.js.map +7 -0
- package/dist/cjs/TimePickerMenu.js +241 -0
- package/dist/cjs/TimePickerMenu.js.map +7 -0
- package/dist/cjs/index.js +40 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/moveElementOnScroll.js +93 -0
- package/dist/cjs/moveElementOnScroll.js.map +7 -0
- package/dist/cjs/utils.js +71 -0
- package/dist/cjs/utils.js.map +7 -0
- package/dist/esm/DSTimePicker.js +77 -0
- package/dist/esm/DSTimePicker.js.map +7 -0
- package/dist/esm/DSTimePickerMenu.js +19 -0
- package/dist/esm/DSTimePickerMenu.js.map +7 -0
- package/dist/esm/PickerPanel.js +270 -0
- package/dist/esm/PickerPanel.js.map +7 -0
- package/dist/esm/TimePickerDropdown.js +45 -0
- package/dist/esm/TimePickerDropdown.js.map +7 -0
- package/dist/esm/TimePickerImpl.js +154 -0
- package/dist/esm/TimePickerImpl.js.map +7 -0
- package/dist/esm/TimePickerMenu.js +212 -0
- package/dist/esm/TimePickerMenu.js.map +7 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/moveElementOnScroll.js +64 -0
- package/dist/esm/moveElementOnScroll.js.map +7 -0
- package/dist/esm/utils.js +42 -0
- package/dist/esm/utils.js.map +7 -0
- package/{types → dist/types}/DSTimePicker.d.ts +0 -0
- package/{types → dist/types}/DSTimePickerMenu.d.ts +0 -0
- package/{types → dist/types}/PickerPanel.d.ts +1 -0
- package/{types → dist/types}/TimePickerDropdown.d.ts +1 -0
- package/{types → dist/types}/TimePickerImpl.d.ts +1 -0
- package/{types → dist/types}/TimePickerMenu.d.ts +0 -0
- package/{types → dist/types}/index.d.ts +0 -0
- package/{types → dist/types}/moveElementOnScroll.d.ts +0 -0
- package/{types → dist/types}/utils.d.ts +0 -0
- package/package.json +40 -38
- package/cjs/DSTimePicker.js +0 -121
- package/cjs/DSTimePickerMenu.js +0 -35
- package/cjs/PickerPanel.js +0 -402
- package/cjs/TimePickerDropdown.js +0 -53
- package/cjs/TimePickerImpl.js +0 -175
- package/cjs/TimePickerMenu.js +0 -312
- package/cjs/index.js +0 -17
- package/cjs/moveElementOnScroll.js +0 -75
- package/cjs/utils.js +0 -38
- package/esm/DSTimePicker.js +0 -111
- package/esm/DSTimePickerMenu.js +0 -24
- package/esm/PickerPanel.js +0 -392
- package/esm/TimePickerDropdown.js +0 -45
- package/esm/TimePickerImpl.js +0 -165
- package/esm/TimePickerMenu.js +0 -301
- package/esm/index.js +0 -4
- package/esm/moveElementOnScroll.js +0 -70
- package/esm/utils.js +0 -31
package/package.json
CHANGED
|
@@ -1,47 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-time-picker",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0-alpha.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Time Picker",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"module": "./dist/esm/index.js",
|
|
10
|
+
"main": "./dist/cjs/index.js",
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
9
12
|
"exports": {
|
|
10
13
|
".": {
|
|
11
|
-
"import": "./esm/index.js",
|
|
12
|
-
"require": "./cjs/index.js"
|
|
14
|
+
"import": "./dist/esm/index.js",
|
|
15
|
+
"require": "./dist/cjs/index.js"
|
|
13
16
|
},
|
|
14
17
|
"./utils": {
|
|
15
|
-
"import": "./esm/utils.js",
|
|
16
|
-
"require": "./cjs/utils.js"
|
|
18
|
+
"import": "./dist/esm/utils.js",
|
|
19
|
+
"require": "./dist/cjs/utils.js"
|
|
17
20
|
},
|
|
18
21
|
"./TimePickerMenu": {
|
|
19
|
-
"import": "./esm/TimePickerMenu.js",
|
|
20
|
-
"require": "./cjs/TimePickerMenu.js"
|
|
22
|
+
"import": "./dist/esm/TimePickerMenu.js",
|
|
23
|
+
"require": "./dist/cjs/TimePickerMenu.js"
|
|
21
24
|
},
|
|
22
25
|
"./TimePickerImpl": {
|
|
23
|
-
"import": "./esm/TimePickerImpl.js",
|
|
24
|
-
"require": "./cjs/TimePickerImpl.js"
|
|
26
|
+
"import": "./dist/esm/TimePickerImpl.js",
|
|
27
|
+
"require": "./dist/cjs/TimePickerImpl.js"
|
|
25
28
|
},
|
|
26
29
|
"./TimePickerDropdown": {
|
|
27
|
-
"import": "./esm/TimePickerDropdown.js",
|
|
28
|
-
"require": "./cjs/TimePickerDropdown.js"
|
|
30
|
+
"import": "./dist/esm/TimePickerDropdown.js",
|
|
31
|
+
"require": "./dist/cjs/TimePickerDropdown.js"
|
|
29
32
|
},
|
|
30
33
|
"./PickerPanel": {
|
|
31
|
-
"import": "./esm/PickerPanel.js",
|
|
32
|
-
"require": "./cjs/PickerPanel.js"
|
|
34
|
+
"import": "./dist/esm/PickerPanel.js",
|
|
35
|
+
"require": "./dist/cjs/PickerPanel.js"
|
|
33
36
|
},
|
|
34
37
|
"./moveElementOnScroll": {
|
|
35
|
-
"import": "./esm/moveElementOnScroll.js",
|
|
36
|
-
"require": "./cjs/moveElementOnScroll.js"
|
|
38
|
+
"import": "./dist/esm/moveElementOnScroll.js",
|
|
39
|
+
"require": "./dist/cjs/moveElementOnScroll.js"
|
|
37
40
|
},
|
|
38
41
|
"./DSTimePickerMenu": {
|
|
39
|
-
"import": "./esm/DSTimePickerMenu.js",
|
|
40
|
-
"require": "./cjs/DSTimePickerMenu.js"
|
|
42
|
+
"import": "./dist/esm/DSTimePickerMenu.js",
|
|
43
|
+
"require": "./dist/cjs/DSTimePickerMenu.js"
|
|
41
44
|
},
|
|
42
45
|
"./DSTimePicker": {
|
|
43
|
-
"import": "./esm/DSTimePicker.js",
|
|
44
|
-
"require": "./cjs/DSTimePicker.js"
|
|
46
|
+
"import": "./dist/esm/DSTimePicker.js",
|
|
47
|
+
"require": "./dist/cjs/DSTimePicker.js"
|
|
45
48
|
}
|
|
46
49
|
},
|
|
47
50
|
"sideEffects": [
|
|
@@ -53,23 +56,17 @@
|
|
|
53
56
|
"url": "https://git.elliemae.io/platform-ui/dimsum.git"
|
|
54
57
|
},
|
|
55
58
|
"engines": {
|
|
56
|
-
"
|
|
57
|
-
"node": ">=
|
|
59
|
+
"pnpm": ">=6",
|
|
60
|
+
"node": ">=16"
|
|
58
61
|
},
|
|
59
62
|
"author": "ICE MT",
|
|
60
|
-
"scripts": {
|
|
61
|
-
"dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
|
|
62
|
-
"prebuild": "exit 0",
|
|
63
|
-
"predev": "exit 0",
|
|
64
|
-
"build": "node ../../scripts/build/build.js"
|
|
65
|
-
},
|
|
66
63
|
"dependencies": {
|
|
67
|
-
"@elliemae/ds-button": "2.
|
|
68
|
-
"@elliemae/ds-classnames": "2.
|
|
69
|
-
"@elliemae/ds-form": "2.
|
|
70
|
-
"@elliemae/ds-icons": "2.
|
|
71
|
-
"@elliemae/ds-popper": "2.
|
|
72
|
-
"@elliemae/ds-utilities": "2.
|
|
64
|
+
"@elliemae/ds-button": "2.3.0-alpha.10",
|
|
65
|
+
"@elliemae/ds-classnames": "2.3.0-alpha.10",
|
|
66
|
+
"@elliemae/ds-form": "2.3.0-alpha.10",
|
|
67
|
+
"@elliemae/ds-icons": "2.3.0-alpha.10",
|
|
68
|
+
"@elliemae/ds-popper": "2.3.0-alpha.10",
|
|
69
|
+
"@elliemae/ds-utilities": "2.3.0-alpha.10",
|
|
73
70
|
"memoize-one": "~5.1.1",
|
|
74
71
|
"moment": "~2.29.1",
|
|
75
72
|
"prop-types": "~15.7.2",
|
|
@@ -86,7 +83,12 @@
|
|
|
86
83
|
},
|
|
87
84
|
"publishConfig": {
|
|
88
85
|
"access": "public",
|
|
89
|
-
"
|
|
90
|
-
|
|
86
|
+
"typeSafety": false
|
|
87
|
+
},
|
|
88
|
+
"scripts": {
|
|
89
|
+
"dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
|
|
90
|
+
"prebuild": "exit 0",
|
|
91
|
+
"predev": "exit 0",
|
|
92
|
+
"build": "node ../../scripts/build/build.js"
|
|
91
93
|
}
|
|
92
94
|
}
|
package/cjs/DSTimePicker.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
require('react');
|
|
6
|
-
var reactDesc = require('react-desc');
|
|
7
|
-
var moment = require('moment');
|
|
8
|
-
var TimePickerImpl = require('./TimePickerImpl.js');
|
|
9
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
10
|
-
|
|
11
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
|
-
|
|
13
|
-
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
14
|
-
|
|
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
|
-
};
|
|
57
|
-
|
|
58
|
-
DSTimePicker.defaultProps = {
|
|
59
|
-
format: 'hh:mm:ss A'
|
|
60
|
-
};
|
|
61
|
-
const props = {
|
|
62
|
-
/** a11y label */
|
|
63
|
-
'aria-label': reactDesc.PropTypes.string.description('a11y label'),
|
|
64
|
-
|
|
65
|
-
/** inject props to time picker wrapper */
|
|
66
|
-
containerProps: reactDesc.PropTypes.object.description('inject props to time picker wrapper'),
|
|
67
|
-
|
|
68
|
-
/** Whether the time picker is disabled or not */
|
|
69
|
-
disabled: reactDesc.PropTypes.bool.description('Whether the time picker is disabled or not'),
|
|
70
|
-
|
|
71
|
-
/** Time picker value */
|
|
72
|
-
value: reactDesc.PropTypes.instanceOf(moment__default["default"]).description('Time picker value'),
|
|
73
|
-
|
|
74
|
-
/** Time format (hh:mm:ss, H:m:s) */
|
|
75
|
-
format: reactDesc.PropTypes.string.description('Time format (hh:mm:ss, H:m:s)'),
|
|
76
|
-
|
|
77
|
-
/** toggle header style */
|
|
78
|
-
hasHeader: reactDesc.PropTypes.bool.description('toggle header style'),
|
|
79
|
-
|
|
80
|
-
/** toggle header display */
|
|
81
|
-
hasHeaderDisplay: reactDesc.PropTypes.bool.description('toggle header display'),
|
|
82
|
-
|
|
83
|
-
/** Handler when time picker value changes */
|
|
84
|
-
onChange: reactDesc.PropTypes.func.description('Handler when time picker value changes'),
|
|
85
|
-
|
|
86
|
-
/** Handler when the time picker menu opens */
|
|
87
|
-
onOpen: reactDesc.PropTypes.func.description('Handler when the time picker menu opens'),
|
|
88
|
-
|
|
89
|
-
/** Whether the time picker menu is opened or not */
|
|
90
|
-
isOpen: reactDesc.PropTypes.bool.description('Whether the time picker menu is opened or not'),
|
|
91
|
-
|
|
92
|
-
/** ref for time picker input */
|
|
93
|
-
innerRef: reactDesc.PropTypes.func.description('ref for time picker input'),
|
|
94
|
-
|
|
95
|
-
/** Enable to clear the time picker value */
|
|
96
|
-
clearable: reactDesc.PropTypes.bool.description('Enable to clear the time picker value'),
|
|
97
|
-
|
|
98
|
-
/** class for time picker */
|
|
99
|
-
className: reactDesc.PropTypes.string.description('class for time picker'),
|
|
100
|
-
|
|
101
|
-
/** style object */
|
|
102
|
-
style: reactDesc.PropTypes.object.description('style object'),
|
|
103
|
-
|
|
104
|
-
/** z index for menu */
|
|
105
|
-
zIndex: reactDesc.PropTypes.number.description('z index for menu'),
|
|
106
|
-
|
|
107
|
-
/** DSPopper placement */
|
|
108
|
-
placement: reactDesc.PropTypes.string.description('DSPopper placement'),
|
|
109
|
-
|
|
110
|
-
/** disabled time */
|
|
111
|
-
disabledTimes: reactDesc.PropTypes.object.description('disabled time'),
|
|
112
|
-
|
|
113
|
-
/** steps for the picker */
|
|
114
|
-
minutesInterval: reactDesc.PropTypes.number.description('steps for the picker')
|
|
115
|
-
};
|
|
116
|
-
const DSTimePickerWithSchema = reactDesc.describe(DSTimePicker);
|
|
117
|
-
DSTimePickerWithSchema.propTypes = props;
|
|
118
|
-
|
|
119
|
-
exports.DSTimePicker = DSTimePicker;
|
|
120
|
-
exports.DSTimePickerWithSchema = DSTimePickerWithSchema;
|
|
121
|
-
exports["default"] = DSTimePicker;
|
package/cjs/DSTimePickerMenu.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
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');
|
|
10
|
-
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
11
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
12
|
-
require('react');
|
|
13
|
-
var styled = require('styled-components');
|
|
14
|
-
var TimePickerMenu = require('./TimePickerMenu.js');
|
|
15
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
16
|
-
|
|
17
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
|
-
|
|
19
|
-
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
20
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
21
|
-
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
22
|
-
|
|
23
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
24
|
-
|
|
25
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
26
|
-
const DSTimePickerMenuWrapper = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
27
|
-
componentId: "sc-1lnruj5-0"
|
|
28
|
-
})(["display:flex;height:18.6rem;"]);
|
|
29
|
-
|
|
30
|
-
function DSTimePickerMenu(props) {
|
|
31
|
-
return /*#__PURE__*/_jsx__default["default"](DSTimePickerMenuWrapper, {}, void 0, /*#__PURE__*/jsxRuntime.jsx(TimePickerMenu.TimePickerMenu, _objectSpread({}, props)));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
exports.DSTimePickerMenu = DSTimePickerMenu;
|
|
35
|
-
exports["default"] = DSTimePickerMenu;
|
package/cjs/PickerPanel.js
DELETED
|
@@ -1,402 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
-
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
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');
|
|
15
|
-
var React = require('react');
|
|
16
|
-
var lodash = require('lodash');
|
|
17
|
-
var dsClassnames = require('@elliemae/ds-classnames');
|
|
18
|
-
var memoizeOne = require('memoize-one');
|
|
19
|
-
var dsIcons = require('@elliemae/ds-icons');
|
|
20
|
-
var DSButton = require('@elliemae/ds-button');
|
|
21
|
-
var moveElementOnScroll = require('./moveElementOnScroll.js');
|
|
22
|
-
var utils = require('./utils.js');
|
|
23
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
24
|
-
|
|
25
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
26
|
-
|
|
27
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
28
|
-
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
29
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
30
|
-
var memoizeOne__default = /*#__PURE__*/_interopDefaultLegacy(memoizeOne);
|
|
31
|
-
var DSButton__default = /*#__PURE__*/_interopDefaultLegacy(DSButton);
|
|
32
|
-
|
|
33
|
-
var _SelectedCircle, _ChevronSmallUp, _ChevronSmallDown;
|
|
34
|
-
|
|
35
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
36
|
-
|
|
37
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
38
|
-
const blockName = 'time-picker-panel';
|
|
39
|
-
const Container = dsClassnames.aggregatedClasses('div')(blockName, null, _ref => {
|
|
40
|
-
let {
|
|
41
|
-
scrolling
|
|
42
|
-
} = _ref;
|
|
43
|
-
return {
|
|
44
|
-
scrolling
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
const Wrapper = dsClassnames.aggregatedClasses('div')(blockName, 'wrapper');
|
|
48
|
-
const PickerItemListContainer = dsClassnames.aggregatedClasses('div')(blockName, 'item-list-container');
|
|
49
|
-
const PickerItemList = dsClassnames.aggregatedClasses('div')(blockName, 'item-list');
|
|
50
|
-
const PickerHeader = dsClassnames.aggregatedClasses('div')(blockName, 'header');
|
|
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
|
-
});
|
|
61
|
-
const PickerSelectedOptionSelected = dsClassnames.aggregatedClasses('div')(blockName, 'selected-container');
|
|
62
|
-
const SelectedCircle = dsClassnames.aggregatedClasses('div')(blockName, 'selected-circle');
|
|
63
|
-
const ArrowButtonContainer = dsClassnames.aggregatedClasses('div')(blockName, 'arrow-container');
|
|
64
|
-
|
|
65
|
-
const getOptionIndex = function (options, selectedOption) {
|
|
66
|
-
let valueProperty = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'value';
|
|
67
|
-
const index = options.findIndex(option => option[valueProperty] === selectedOption);
|
|
68
|
-
return utils.validateIndex(index, options);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const arrowProps = {
|
|
72
|
-
buttonType: 'text',
|
|
73
|
-
fluidHeight: true,
|
|
74
|
-
fluidWidth: true,
|
|
75
|
-
size: 's'
|
|
76
|
-
};
|
|
77
|
-
class PickerPanel extends React.Component {
|
|
78
|
-
constructor(props) {
|
|
79
|
-
super(props);
|
|
80
|
-
this.computeContainerTranslation = memoizeOne__default["default"](index => {
|
|
81
|
-
const {
|
|
82
|
-
options,
|
|
83
|
-
valueProperty
|
|
84
|
-
} = this.props;
|
|
85
|
-
const {
|
|
86
|
-
selectedOption,
|
|
87
|
-
scrolling
|
|
88
|
-
} = this.state;
|
|
89
|
-
const selectedOptionIndex = index || getOptionIndex(options, selectedOption, valueProperty);
|
|
90
|
-
const listYPosition = this.minYListPosition - selectedOptionIndex * this.optionHeight;
|
|
91
|
-
if (this.scrollHandler && !scrolling) this.scrollHandler.updatePosition(listYPosition);
|
|
92
|
-
return listYPosition;
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
this.renderHeader = () => {
|
|
96
|
-
const {
|
|
97
|
-
header
|
|
98
|
-
} = this.props;
|
|
99
|
-
return /*#__PURE__*/_jsx__default["default"](PickerHeader, {}, void 0, header);
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
this.pickerListContainerRef = /*#__PURE__*/React__default["default"].createRef();
|
|
103
|
-
this.pickerListRef = /*#__PURE__*/React__default["default"].createRef();
|
|
104
|
-
this.pickerItemRef = /*#__PURE__*/React__default["default"].createRef();
|
|
105
|
-
this.selectedOptionRef = /*#__PURE__*/React__default["default"].createRef();
|
|
106
|
-
this.state = {
|
|
107
|
-
selectedOption: props.selected,
|
|
108
|
-
activeIndex: 0,
|
|
109
|
-
// eslint-disable-next-line react/no-unused-state
|
|
110
|
-
prevProps: {}
|
|
111
|
-
};
|
|
112
|
-
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
113
|
-
this.handleStepMoveUp = this.handleStepMoveUp.bind(this);
|
|
114
|
-
this.handleStepMoveDown = this.handleStepMoveDown.bind(this);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
componentDidMount() {
|
|
118
|
-
this.computeSizes();
|
|
119
|
-
const pickerListContainerEl = this.pickerListContainerRef.current;
|
|
120
|
-
const pickerListEl = this.pickerListRef.current;
|
|
121
|
-
this.scrollHandler = new moveElementOnScroll.MoveElementOnScroll(pickerListEl, {
|
|
122
|
-
container: pickerListContainerEl,
|
|
123
|
-
min: -this.minYListPosition,
|
|
124
|
-
max: this.maxYListPosition,
|
|
125
|
-
onUpdate: (pos, delta) => {
|
|
126
|
-
const {
|
|
127
|
-
options
|
|
128
|
-
} = this.props;
|
|
129
|
-
const index = options.length - -Math.floor((pos - this.maxYListPosition) / this.optionHeight) + (delta > 0 ? 1 : -1);
|
|
130
|
-
this.moveTo(index, true);
|
|
131
|
-
},
|
|
132
|
-
onEndScroll: () => {
|
|
133
|
-
this.setState({
|
|
134
|
-
scrolling: false
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
this.computeContainerTranslation();
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
componentWillUnmount() {
|
|
142
|
-
this.scrollHandler.unsubscribe();
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
static getDerivedStateFromProps(nextProps, _ref3) {
|
|
146
|
-
let {
|
|
147
|
-
prevProps
|
|
148
|
-
} = _ref3;
|
|
149
|
-
const {
|
|
150
|
-
selected,
|
|
151
|
-
valueProperty,
|
|
152
|
-
options
|
|
153
|
-
} = nextProps;
|
|
154
|
-
|
|
155
|
-
if (selected !== prevProps.selected) {
|
|
156
|
-
return {
|
|
157
|
-
selectedOption: selected,
|
|
158
|
-
activeIndex: getOptionIndex(options, selected, valueProperty),
|
|
159
|
-
prevProps: nextProps
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return null;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
getOptionValue(option) {
|
|
167
|
-
const {
|
|
168
|
-
valueProperty
|
|
169
|
-
} = this.props;
|
|
170
|
-
return option[valueProperty];
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
getOptionLabel(option) {
|
|
174
|
-
const {
|
|
175
|
-
labelProperty
|
|
176
|
-
} = this.props;
|
|
177
|
-
return option[labelProperty];
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
computeSizes() {
|
|
181
|
-
const {
|
|
182
|
-
options,
|
|
183
|
-
numberItemsOnScreen
|
|
184
|
-
} = this.props;
|
|
185
|
-
const {
|
|
186
|
-
offsetHeight: optionHeight
|
|
187
|
-
} = this.pickerItemRef.current;
|
|
188
|
-
this.optionHeight = optionHeight;
|
|
189
|
-
this.listHeight = this.optionHeight * numberItemsOnScreen;
|
|
190
|
-
this.minYListPosition = this.listHeight / 2 - this.optionHeight / 2;
|
|
191
|
-
this.maxYListPosition = this.optionHeight * (options.length - Math.ceil(numberItemsOnScreen / 2));
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
handleOptionSelect(optionValue, index, scrolling) {
|
|
195
|
-
const {
|
|
196
|
-
onChange
|
|
197
|
-
} = this.props;
|
|
198
|
-
this.setState(state => _objectSpread(_objectSpread({}, state), {}, {
|
|
199
|
-
scrolling,
|
|
200
|
-
selectedOption: optionValue,
|
|
201
|
-
activeIndex: index
|
|
202
|
-
}), () => {
|
|
203
|
-
onChange(optionValue, index);
|
|
204
|
-
});
|
|
205
|
-
} // TODO: this needs a refactor from de FocusGroup
|
|
206
|
-
// eslint-disable-next-line max-statements
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
handleKeyDown(e) {
|
|
210
|
-
const {
|
|
211
|
-
activeIndex
|
|
212
|
-
} = this.state;
|
|
213
|
-
const {
|
|
214
|
-
options
|
|
215
|
-
} = this.props;
|
|
216
|
-
const [firstColumn, ...restColumns] = document.getElementsByClassName('em-ds-time-picker-panel');
|
|
217
|
-
const [lastColumn] = restColumns.slice(-1);
|
|
218
|
-
const [prev] = document.getElementsByClassName('DayPickerNavigation_button');
|
|
219
|
-
const focusedElement = document.activeElement;
|
|
220
|
-
|
|
221
|
-
switch (e.key) {
|
|
222
|
-
case 'Home':
|
|
223
|
-
this.moveTo(0);
|
|
224
|
-
break;
|
|
225
|
-
|
|
226
|
-
case 'End':
|
|
227
|
-
this.moveTo(options.length - 1);
|
|
228
|
-
break;
|
|
229
|
-
|
|
230
|
-
case 'ArrowUp':
|
|
231
|
-
this.moveTo(activeIndex - 1);
|
|
232
|
-
break;
|
|
233
|
-
|
|
234
|
-
case 'ArrowDown':
|
|
235
|
-
this.moveTo(activeIndex + 1);
|
|
236
|
-
break;
|
|
237
|
-
|
|
238
|
-
case 'Tab':
|
|
239
|
-
{
|
|
240
|
-
e.preventDefault(); // If it is DateTimePicker, move focus to prev arrow element
|
|
241
|
-
|
|
242
|
-
if (prev && focusedElement === lastColumn) {
|
|
243
|
-
prev.focus();
|
|
244
|
-
} else if (focusedElement === lastColumn) {
|
|
245
|
-
firstColumn.focus();
|
|
246
|
-
} else {
|
|
247
|
-
const position = lodash.findIndex(restColumns, focusedElement);
|
|
248
|
-
restColumns[position + 1].focus();
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
break;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
moveTo(index, scrolling) {
|
|
257
|
-
const {
|
|
258
|
-
options
|
|
259
|
-
} = this.props;
|
|
260
|
-
const {
|
|
261
|
-
selectedOption
|
|
262
|
-
} = this.state;
|
|
263
|
-
const validIndex = utils.validateIndex(index, options);
|
|
264
|
-
const option = options[validIndex];
|
|
265
|
-
const optionValue = this.getOptionValue(option);
|
|
266
|
-
|
|
267
|
-
if (selectedOption !== optionValue && option.disabled !== true) {
|
|
268
|
-
this.handleOptionSelect(optionValue, validIndex, scrolling);
|
|
269
|
-
} // TO-DO: if date disabled, add nextValidOption selection
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
handleStepMoveUp() {
|
|
274
|
-
const {
|
|
275
|
-
activeIndex
|
|
276
|
-
} = this.state;
|
|
277
|
-
const {
|
|
278
|
-
arrowStep,
|
|
279
|
-
options
|
|
280
|
-
} = this.props;
|
|
281
|
-
const supposedPos = activeIndex - arrowStep;
|
|
282
|
-
const nextPos = supposedPos >= 0 ? supposedPos : activeIndex - 1;
|
|
283
|
-
const nextValidOption = options.find(op => !op.disabled);
|
|
284
|
-
this.moveTo(nextPos, true, nextValidOption);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
handleStepMoveDown() {
|
|
288
|
-
const {
|
|
289
|
-
activeIndex
|
|
290
|
-
} = this.state;
|
|
291
|
-
const {
|
|
292
|
-
arrowStep,
|
|
293
|
-
options
|
|
294
|
-
} = this.props;
|
|
295
|
-
const supposedPos = activeIndex + arrowStep;
|
|
296
|
-
const nextPos = supposedPos <= options.length ? supposedPos : activeIndex + 1;
|
|
297
|
-
this.moveTo(nextPos);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
render() {
|
|
301
|
-
const {
|
|
302
|
-
options,
|
|
303
|
-
hasHeader,
|
|
304
|
-
type,
|
|
305
|
-
time,
|
|
306
|
-
meridiem,
|
|
307
|
-
disabledTimes
|
|
308
|
-
} = this.props;
|
|
309
|
-
const {
|
|
310
|
-
selectedOption,
|
|
311
|
-
activeIndex,
|
|
312
|
-
scrolling
|
|
313
|
-
} = this.state;
|
|
314
|
-
const listYPosition = this.computeContainerTranslation(activeIndex);
|
|
315
|
-
return /*#__PURE__*/_jsx__default["default"](Wrapper, {}, void 0, hasHeader && this.renderHeader(), /*#__PURE__*/_jsx__default["default"](Container, {
|
|
316
|
-
classProps: {
|
|
317
|
-
scrolling
|
|
318
|
-
},
|
|
319
|
-
onKeyDown: this.handleKeyDown,
|
|
320
|
-
tabIndex: 0
|
|
321
|
-
}, void 0, /*#__PURE__*/_jsx__default["default"](PickerSelectedOptionSelected, {
|
|
322
|
-
innerRef: this.selectedOptionRef
|
|
323
|
-
}, void 0, _SelectedCircle || (_SelectedCircle = /*#__PURE__*/_jsx__default["default"](SelectedCircle, {}))), /*#__PURE__*/_jsx__default["default"](ArrowButtonContainer, {}, void 0, /*#__PURE__*/jsxRuntime.jsx(DSButton__default["default"], _objectSpread(_objectSpread({}, arrowProps), {}, {
|
|
324
|
-
"aria-label": "Chevron Up",
|
|
325
|
-
"data-testid": "".concat(type, "-chevron-up"),
|
|
326
|
-
disabled: activeIndex <= 0,
|
|
327
|
-
icon: _ChevronSmallUp || (_ChevronSmallUp = /*#__PURE__*/_jsx__default["default"](dsIcons.ChevronSmallUp, {})),
|
|
328
|
-
onClick: this.handleStepMoveUp,
|
|
329
|
-
tabIndex: -1
|
|
330
|
-
}))), /*#__PURE__*/_jsx__default["default"](PickerItemListContainer, {
|
|
331
|
-
innerRef: this.pickerListContainerRef,
|
|
332
|
-
style: {
|
|
333
|
-
height: this.listHeight
|
|
334
|
-
}
|
|
335
|
-
}, void 0, /*#__PURE__*/_jsx__default["default"](PickerItemList, {
|
|
336
|
-
"data-testid": "".concat(type, "-list"),
|
|
337
|
-
innerRef: this.pickerListRef,
|
|
338
|
-
style: {
|
|
339
|
-
transform: "translateY(".concat(listYPosition, "px)")
|
|
340
|
-
}
|
|
341
|
-
}, void 0, options.map((option, index) => {
|
|
342
|
-
const value = this.getOptionValue(option);
|
|
343
|
-
const label = this.getOptionLabel(option);
|
|
344
|
-
let valueFormatted;
|
|
345
|
-
if (meridiem === 'AM') valueFormatted = value;else if (meridiem === 'PM' && value === 12) valueFormatted = value;else if (meridiem === 'PM') valueFormatted = value + 12;
|
|
346
|
-
let disabled = false;
|
|
347
|
-
|
|
348
|
-
if (disabledTimes) {
|
|
349
|
-
const {
|
|
350
|
-
from,
|
|
351
|
-
to
|
|
352
|
-
} = disabledTimes;
|
|
353
|
-
|
|
354
|
-
if (type === 'hour' && valueFormatted >= (from === null || from === void 0 ? void 0 : from.hour) && valueFormatted < (to === null || to === void 0 ? void 0 : to.hour) || type === 'minutes' && value >= (from === null || from === void 0 ? void 0 : from.min) && value < (to === null || to === void 0 ? void 0 : to.min)) {
|
|
355
|
-
disabled = true;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
if (type === 'minutes' && ((time === null || time === void 0 ? void 0 : time.hour()) > (to === null || to === void 0 ? void 0 : to.hour) || (time === null || time === void 0 ? void 0 : time.hour()) < (from === null || from === void 0 ? void 0 : from.hour))) {
|
|
359
|
-
disabled = false;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
if (label === 'am' && (from === null || from === void 0 ? void 0 : from.hour) == 0 && (to === null || to === void 0 ? void 0 : to.hour) >= 12) {
|
|
363
|
-
disabled = true;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
if (label === 'pm' && (to === null || to === void 0 ? void 0 : to.hour) == 24) {
|
|
367
|
-
disabled = true;
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
option.disabled = disabled;
|
|
372
|
-
return /*#__PURE__*/_jsx__default["default"](PickerItemContainer, {
|
|
373
|
-
classProps: {
|
|
374
|
-
selected: selectedOption ? value === selectedOption : index === 0,
|
|
375
|
-
disabled
|
|
376
|
-
},
|
|
377
|
-
innerRef: this.pickerItemRef,
|
|
378
|
-
onClick: () => {
|
|
379
|
-
if (!disabled) this.handleOptionSelect(value, index);
|
|
380
|
-
}
|
|
381
|
-
}, value, label);
|
|
382
|
-
}))), /*#__PURE__*/_jsx__default["default"](ArrowButtonContainer, {}, void 0, /*#__PURE__*/jsxRuntime.jsx(DSButton__default["default"], _objectSpread(_objectSpread({}, arrowProps), {}, {
|
|
383
|
-
"aria-label": "Chevron Down",
|
|
384
|
-
"data-testid": "".concat(type, "-chevron-down"),
|
|
385
|
-
disabled: activeIndex >= options.length - 1,
|
|
386
|
-
icon: _ChevronSmallDown || (_ChevronSmallDown = /*#__PURE__*/_jsx__default["default"](dsIcons.ChevronSmallDown, {})),
|
|
387
|
-
onClick: this.handleStepMoveDown,
|
|
388
|
-
tabIndex: -1
|
|
389
|
-
})))));
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
}
|
|
393
|
-
PickerPanel.defaultProps = {
|
|
394
|
-
valueProperty: 'value',
|
|
395
|
-
labelProperty: 'label',
|
|
396
|
-
numberItemsOnScreen: 5,
|
|
397
|
-
// this number should be impair
|
|
398
|
-
options: [],
|
|
399
|
-
arrowStep: 1
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
module.exports = PickerPanel;
|