@elliemae/ds-time-picker 2.2.0-alpha.2 → 2.2.0-beta.0
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 +115 -100
- package/cjs/DSTimePickerMenu.js +33 -46
- package/cjs/PickerPanel.js +254 -151
- package/cjs/TimePickerDropdown.js +52 -73
- package/cjs/TimePickerImpl.js +138 -146
- package/cjs/TimePickerMenu.js +209 -138
- package/cjs/index.js +17 -40
- package/cjs/moveElementOnScroll.js +39 -57
- package/cjs/utils.js +24 -57
- package/esm/DSTimePicker.js +105 -71
- package/esm/DSTimePickerMenu.js +22 -17
- package/esm/PickerPanel.js +242 -120
- package/esm/TimePickerDropdown.js +44 -44
- package/esm/TimePickerImpl.js +117 -106
- package/esm/TimePickerMenu.js +191 -102
- package/esm/index.js +4 -11
- package/esm/moveElementOnScroll.js +34 -28
- package/esm/utils.js +17 -28
- package/package.json +7 -7
- package/types/DSTimePicker.d.ts +1 -20
- package/types/PickerPanel.d.ts +0 -1
- package/types/TimePickerDropdown.d.ts +0 -1
- package/types/TimePickerImpl.d.ts +0 -1
- package/cjs/DSTimePicker.js.map +0 -7
- package/cjs/DSTimePickerMenu.js.map +0 -7
- package/cjs/PickerPanel.js.map +0 -7
- package/cjs/TimePickerDropdown.js.map +0 -7
- package/cjs/TimePickerImpl.js.map +0 -7
- package/cjs/TimePickerMenu.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/moveElementOnScroll.js.map +0 -7
- package/cjs/utils.js.map +0 -7
- package/esm/DSTimePicker.js.map +0 -7
- package/esm/DSTimePickerMenu.js.map +0 -7
- package/esm/PickerPanel.js.map +0 -7
- package/esm/TimePickerDropdown.js.map +0 -7
- package/esm/TimePickerImpl.js.map +0 -7
- package/esm/TimePickerMenu.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/moveElementOnScroll.js.map +0 -7
- package/esm/utils.js.map +0 -7
package/cjs/PickerPanel.js
CHANGED
|
@@ -1,117 +1,157 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
26
59
|
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var PickerPanel_exports = {};
|
|
29
|
-
__export(PickerPanel_exports, {
|
|
30
|
-
PickerPanel: () => PickerPanel,
|
|
31
|
-
default: () => PickerPanel
|
|
32
60
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var import_utils = __toESM(require("./utils"));
|
|
42
|
-
const blockName = "time-picker-panel";
|
|
43
|
-
const Container = (0, import_ds_classnames.aggregatedClasses)("div")(blockName, null, ({ scrolling }) => ({ scrolling }));
|
|
44
|
-
const Wrapper = (0, import_ds_classnames.aggregatedClasses)("div")(blockName, "wrapper");
|
|
45
|
-
const PickerItemListContainer = (0, import_ds_classnames.aggregatedClasses)("div")(blockName, "item-list-container");
|
|
46
|
-
const PickerItemList = (0, import_ds_classnames.aggregatedClasses)("div")(blockName, "item-list");
|
|
47
|
-
const PickerHeader = (0, import_ds_classnames.aggregatedClasses)("div")(blockName, "header");
|
|
48
|
-
const PickerItemContainer = (0, import_ds_classnames.aggregatedClasses)("div")(blockName, "item", ({ selected, disabled }) => ({
|
|
49
|
-
selected,
|
|
50
|
-
disabled
|
|
51
|
-
}));
|
|
52
|
-
const PickerSelectedOptionSelected = (0, import_ds_classnames.aggregatedClasses)("div")(blockName, "selected-container");
|
|
53
|
-
const SelectedCircle = (0, import_ds_classnames.aggregatedClasses)("div")(blockName, "selected-circle");
|
|
54
|
-
const ArrowButtonContainer = (0, import_ds_classnames.aggregatedClasses)("div")(blockName, "arrow-container");
|
|
55
|
-
const getOptionIndex = (options, selectedOption, valueProperty = "value") => {
|
|
56
|
-
const index = options.findIndex((option) => option[valueProperty] === selectedOption);
|
|
57
|
-
return (0, import_utils.validateIndex)(index, options);
|
|
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);
|
|
58
69
|
};
|
|
70
|
+
|
|
59
71
|
const arrowProps = {
|
|
60
|
-
buttonType:
|
|
72
|
+
buttonType: 'text',
|
|
61
73
|
fluidHeight: true,
|
|
62
74
|
fluidWidth: true,
|
|
63
|
-
size:
|
|
75
|
+
size: 's'
|
|
64
76
|
};
|
|
65
|
-
class PickerPanel extends
|
|
77
|
+
class PickerPanel extends React.Component {
|
|
66
78
|
constructor(props) {
|
|
67
79
|
super(props);
|
|
68
|
-
this.computeContainerTranslation =
|
|
69
|
-
const {
|
|
70
|
-
|
|
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;
|
|
71
89
|
const selectedOptionIndex = index || getOptionIndex(options, selectedOption, valueProperty);
|
|
72
90
|
const listYPosition = this.minYListPosition - selectedOptionIndex * this.optionHeight;
|
|
73
|
-
if (this.scrollHandler && !scrolling)
|
|
74
|
-
this.scrollHandler.updatePosition(listYPosition);
|
|
91
|
+
if (this.scrollHandler && !scrolling) this.scrollHandler.updatePosition(listYPosition);
|
|
75
92
|
return listYPosition;
|
|
76
93
|
});
|
|
94
|
+
|
|
77
95
|
this.renderHeader = () => {
|
|
78
|
-
const {
|
|
79
|
-
|
|
96
|
+
const {
|
|
97
|
+
header
|
|
98
|
+
} = this.props;
|
|
99
|
+
return /*#__PURE__*/_jsx__default["default"](PickerHeader, {}, void 0, header);
|
|
80
100
|
};
|
|
81
|
-
|
|
82
|
-
this.
|
|
83
|
-
this.
|
|
84
|
-
this.
|
|
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();
|
|
85
106
|
this.state = {
|
|
86
107
|
selectedOption: props.selected,
|
|
87
108
|
activeIndex: 0,
|
|
109
|
+
// eslint-disable-next-line react/no-unused-state
|
|
88
110
|
prevProps: {}
|
|
89
111
|
};
|
|
112
|
+
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
113
|
+
this.handleStepMoveUp = this.handleStepMoveUp.bind(this);
|
|
114
|
+
this.handleStepMoveDown = this.handleStepMoveDown.bind(this);
|
|
90
115
|
}
|
|
116
|
+
|
|
91
117
|
componentDidMount() {
|
|
92
118
|
this.computeSizes();
|
|
93
119
|
const pickerListContainerEl = this.pickerListContainerRef.current;
|
|
94
120
|
const pickerListEl = this.pickerListRef.current;
|
|
95
|
-
this.scrollHandler = new
|
|
121
|
+
this.scrollHandler = new moveElementOnScroll.MoveElementOnScroll(pickerListEl, {
|
|
96
122
|
container: pickerListContainerEl,
|
|
97
123
|
min: -this.minYListPosition,
|
|
98
124
|
max: this.maxYListPosition,
|
|
99
125
|
onUpdate: (pos, delta) => {
|
|
100
|
-
const {
|
|
126
|
+
const {
|
|
127
|
+
options
|
|
128
|
+
} = this.props;
|
|
101
129
|
const index = options.length - -Math.floor((pos - this.maxYListPosition) / this.optionHeight) + (delta > 0 ? 1 : -1);
|
|
102
130
|
this.moveTo(index, true);
|
|
103
131
|
},
|
|
104
132
|
onEndScroll: () => {
|
|
105
|
-
this.setState({
|
|
133
|
+
this.setState({
|
|
134
|
+
scrolling: false
|
|
135
|
+
});
|
|
106
136
|
}
|
|
107
137
|
});
|
|
108
138
|
this.computeContainerTranslation();
|
|
109
139
|
}
|
|
140
|
+
|
|
110
141
|
componentWillUnmount() {
|
|
111
142
|
this.scrollHandler.unsubscribe();
|
|
112
143
|
}
|
|
113
|
-
|
|
114
|
-
|
|
144
|
+
|
|
145
|
+
static getDerivedStateFromProps(nextProps, _ref3) {
|
|
146
|
+
let {
|
|
147
|
+
prevProps
|
|
148
|
+
} = _ref3;
|
|
149
|
+
const {
|
|
150
|
+
selected,
|
|
151
|
+
valueProperty,
|
|
152
|
+
options
|
|
153
|
+
} = nextProps;
|
|
154
|
+
|
|
115
155
|
if (selected !== prevProps.selected) {
|
|
116
156
|
return {
|
|
117
157
|
selectedOption: selected,
|
|
@@ -119,181 +159,244 @@ class PickerPanel extends import_react.Component {
|
|
|
119
159
|
prevProps: nextProps
|
|
120
160
|
};
|
|
121
161
|
}
|
|
162
|
+
|
|
122
163
|
return null;
|
|
123
164
|
}
|
|
165
|
+
|
|
124
166
|
getOptionValue(option) {
|
|
125
|
-
const {
|
|
167
|
+
const {
|
|
168
|
+
valueProperty
|
|
169
|
+
} = this.props;
|
|
126
170
|
return option[valueProperty];
|
|
127
171
|
}
|
|
172
|
+
|
|
128
173
|
getOptionLabel(option) {
|
|
129
|
-
const {
|
|
174
|
+
const {
|
|
175
|
+
labelProperty
|
|
176
|
+
} = this.props;
|
|
130
177
|
return option[labelProperty];
|
|
131
178
|
}
|
|
179
|
+
|
|
132
180
|
computeSizes() {
|
|
133
|
-
const {
|
|
134
|
-
|
|
181
|
+
const {
|
|
182
|
+
options,
|
|
183
|
+
numberItemsOnScreen
|
|
184
|
+
} = this.props;
|
|
185
|
+
const {
|
|
186
|
+
offsetHeight: optionHeight
|
|
187
|
+
} = this.pickerItemRef.current;
|
|
135
188
|
this.optionHeight = optionHeight;
|
|
136
189
|
this.listHeight = this.optionHeight * numberItemsOnScreen;
|
|
137
190
|
this.minYListPosition = this.listHeight / 2 - this.optionHeight / 2;
|
|
138
191
|
this.maxYListPosition = this.optionHeight * (options.length - Math.ceil(numberItemsOnScreen / 2));
|
|
139
192
|
}
|
|
193
|
+
|
|
140
194
|
handleOptionSelect(optionValue, index, scrolling) {
|
|
141
|
-
const {
|
|
142
|
-
|
|
143
|
-
|
|
195
|
+
const {
|
|
196
|
+
onChange
|
|
197
|
+
} = this.props;
|
|
198
|
+
this.setState(state => _objectSpread(_objectSpread({}, state), {}, {
|
|
144
199
|
scrolling,
|
|
145
200
|
selectedOption: optionValue,
|
|
146
201
|
activeIndex: index
|
|
147
202
|
}), () => {
|
|
148
203
|
onChange(optionValue, index);
|
|
149
204
|
});
|
|
150
|
-
}
|
|
205
|
+
} // TODO: this needs a refactor from de FocusGroup
|
|
206
|
+
// eslint-disable-next-line max-statements
|
|
207
|
+
|
|
208
|
+
|
|
151
209
|
handleKeyDown(e) {
|
|
152
|
-
const {
|
|
153
|
-
|
|
154
|
-
|
|
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');
|
|
155
217
|
const [lastColumn] = restColumns.slice(-1);
|
|
156
|
-
const [prev] = document.getElementsByClassName(
|
|
218
|
+
const [prev] = document.getElementsByClassName('DayPickerNavigation_button');
|
|
157
219
|
const focusedElement = document.activeElement;
|
|
220
|
+
|
|
158
221
|
switch (e.key) {
|
|
159
|
-
case
|
|
222
|
+
case 'Home':
|
|
160
223
|
this.moveTo(0);
|
|
161
224
|
break;
|
|
162
|
-
|
|
225
|
+
|
|
226
|
+
case 'End':
|
|
163
227
|
this.moveTo(options.length - 1);
|
|
164
228
|
break;
|
|
165
|
-
|
|
229
|
+
|
|
230
|
+
case 'ArrowUp':
|
|
166
231
|
this.moveTo(activeIndex - 1);
|
|
167
232
|
break;
|
|
168
|
-
|
|
233
|
+
|
|
234
|
+
case 'ArrowDown':
|
|
169
235
|
this.moveTo(activeIndex + 1);
|
|
170
236
|
break;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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;
|
|
180
252
|
}
|
|
181
|
-
break;
|
|
182
|
-
}
|
|
183
|
-
default:
|
|
184
|
-
break;
|
|
185
253
|
}
|
|
186
254
|
}
|
|
255
|
+
|
|
187
256
|
moveTo(index, scrolling) {
|
|
188
|
-
const {
|
|
189
|
-
|
|
190
|
-
|
|
257
|
+
const {
|
|
258
|
+
options
|
|
259
|
+
} = this.props;
|
|
260
|
+
const {
|
|
261
|
+
selectedOption
|
|
262
|
+
} = this.state;
|
|
263
|
+
const validIndex = utils.validateIndex(index, options);
|
|
191
264
|
const option = options[validIndex];
|
|
192
265
|
const optionValue = this.getOptionValue(option);
|
|
266
|
+
|
|
193
267
|
if (selectedOption !== optionValue && option.disabled !== true) {
|
|
194
268
|
this.handleOptionSelect(optionValue, validIndex, scrolling);
|
|
195
|
-
}
|
|
269
|
+
} // TO-DO: if date disabled, add nextValidOption selection
|
|
270
|
+
|
|
196
271
|
}
|
|
272
|
+
|
|
197
273
|
handleStepMoveUp() {
|
|
198
|
-
const {
|
|
199
|
-
|
|
274
|
+
const {
|
|
275
|
+
activeIndex
|
|
276
|
+
} = this.state;
|
|
277
|
+
const {
|
|
278
|
+
arrowStep,
|
|
279
|
+
options
|
|
280
|
+
} = this.props;
|
|
200
281
|
const supposedPos = activeIndex - arrowStep;
|
|
201
282
|
const nextPos = supposedPos >= 0 ? supposedPos : activeIndex - 1;
|
|
202
|
-
const nextValidOption = options.find(
|
|
283
|
+
const nextValidOption = options.find(op => !op.disabled);
|
|
203
284
|
this.moveTo(nextPos, true, nextValidOption);
|
|
204
285
|
}
|
|
286
|
+
|
|
205
287
|
handleStepMoveDown() {
|
|
206
|
-
const {
|
|
207
|
-
|
|
288
|
+
const {
|
|
289
|
+
activeIndex
|
|
290
|
+
} = this.state;
|
|
291
|
+
const {
|
|
292
|
+
arrowStep,
|
|
293
|
+
options
|
|
294
|
+
} = this.props;
|
|
208
295
|
const supposedPos = activeIndex + arrowStep;
|
|
209
296
|
const nextPos = supposedPos <= options.length ? supposedPos : activeIndex + 1;
|
|
210
297
|
this.moveTo(nextPos);
|
|
211
298
|
}
|
|
299
|
+
|
|
212
300
|
render() {
|
|
213
|
-
const {
|
|
214
|
-
|
|
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;
|
|
215
314
|
const listYPosition = this.computeContainerTranslation(activeIndex);
|
|
216
|
-
return
|
|
217
|
-
classProps: {
|
|
315
|
+
return /*#__PURE__*/_jsx__default["default"](Wrapper, {}, void 0, hasHeader && this.renderHeader(), /*#__PURE__*/_jsx__default["default"](Container, {
|
|
316
|
+
classProps: {
|
|
317
|
+
scrolling
|
|
318
|
+
},
|
|
218
319
|
onKeyDown: this.handleKeyDown,
|
|
219
320
|
tabIndex: 0
|
|
220
|
-
},
|
|
321
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"](PickerSelectedOptionSelected, {
|
|
221
322
|
innerRef: this.selectedOptionRef
|
|
222
|
-
},
|
|
223
|
-
...arrowProps,
|
|
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), {}, {
|
|
224
324
|
"aria-label": "Chevron Up",
|
|
225
|
-
"data-testid":
|
|
325
|
+
"data-testid": "".concat(type, "-chevron-up"),
|
|
226
326
|
disabled: activeIndex <= 0,
|
|
227
|
-
icon:
|
|
327
|
+
icon: _ChevronSmallUp || (_ChevronSmallUp = /*#__PURE__*/_jsx__default["default"](dsIcons.ChevronSmallUp, {})),
|
|
228
328
|
onClick: this.handleStepMoveUp,
|
|
229
329
|
tabIndex: -1
|
|
230
|
-
})),
|
|
330
|
+
}))), /*#__PURE__*/_jsx__default["default"](PickerItemListContainer, {
|
|
231
331
|
innerRef: this.pickerListContainerRef,
|
|
232
332
|
style: {
|
|
233
333
|
height: this.listHeight
|
|
234
334
|
}
|
|
235
|
-
},
|
|
236
|
-
"data-testid":
|
|
335
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"](PickerItemList, {
|
|
336
|
+
"data-testid": "".concat(type, "-list"),
|
|
237
337
|
innerRef: this.pickerListRef,
|
|
238
338
|
style: {
|
|
239
|
-
transform:
|
|
339
|
+
transform: "translateY(".concat(listYPosition, "px)")
|
|
240
340
|
}
|
|
241
|
-
}, options.map((option, index) => {
|
|
341
|
+
}, void 0, options.map((option, index) => {
|
|
242
342
|
const value = this.getOptionValue(option);
|
|
243
343
|
const label = this.getOptionLabel(option);
|
|
244
344
|
let valueFormatted;
|
|
245
|
-
if (meridiem ===
|
|
246
|
-
valueFormatted = value;
|
|
247
|
-
else if (meridiem === "PM" && value === 12)
|
|
248
|
-
valueFormatted = value;
|
|
249
|
-
else if (meridiem === "PM")
|
|
250
|
-
valueFormatted = value + 12;
|
|
345
|
+
if (meridiem === 'AM') valueFormatted = value;else if (meridiem === 'PM' && value === 12) valueFormatted = value;else if (meridiem === 'PM') valueFormatted = value + 12;
|
|
251
346
|
let disabled = false;
|
|
347
|
+
|
|
252
348
|
if (disabledTimes) {
|
|
253
|
-
const {
|
|
254
|
-
|
|
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)) {
|
|
255
355
|
disabled = true;
|
|
256
356
|
}
|
|
257
|
-
|
|
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))) {
|
|
258
359
|
disabled = false;
|
|
259
360
|
}
|
|
260
|
-
|
|
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) {
|
|
261
363
|
disabled = true;
|
|
262
364
|
}
|
|
263
|
-
|
|
365
|
+
|
|
366
|
+
if (label === 'pm' && (to === null || to === void 0 ? void 0 : to.hour) == 24) {
|
|
264
367
|
disabled = true;
|
|
265
368
|
}
|
|
266
369
|
}
|
|
370
|
+
|
|
267
371
|
option.disabled = disabled;
|
|
268
|
-
return
|
|
269
|
-
key: value,
|
|
372
|
+
return /*#__PURE__*/_jsx__default["default"](PickerItemContainer, {
|
|
270
373
|
classProps: {
|
|
271
374
|
selected: selectedOption ? value === selectedOption : index === 0,
|
|
272
375
|
disabled
|
|
273
376
|
},
|
|
274
377
|
innerRef: this.pickerItemRef,
|
|
275
378
|
onClick: () => {
|
|
276
|
-
if (!disabled)
|
|
277
|
-
this.handleOptionSelect(value, index);
|
|
379
|
+
if (!disabled) this.handleOptionSelect(value, index);
|
|
278
380
|
}
|
|
279
|
-
}, label);
|
|
280
|
-
}))),
|
|
281
|
-
...arrowProps,
|
|
381
|
+
}, value, label);
|
|
382
|
+
}))), /*#__PURE__*/_jsx__default["default"](ArrowButtonContainer, {}, void 0, /*#__PURE__*/jsxRuntime.jsx(DSButton__default["default"], _objectSpread(_objectSpread({}, arrowProps), {}, {
|
|
282
383
|
"aria-label": "Chevron Down",
|
|
283
|
-
"data-testid":
|
|
384
|
+
"data-testid": "".concat(type, "-chevron-down"),
|
|
284
385
|
disabled: activeIndex >= options.length - 1,
|
|
285
|
-
icon:
|
|
386
|
+
icon: _ChevronSmallDown || (_ChevronSmallDown = /*#__PURE__*/_jsx__default["default"](dsIcons.ChevronSmallDown, {})),
|
|
286
387
|
onClick: this.handleStepMoveDown,
|
|
287
388
|
tabIndex: -1
|
|
288
|
-
}))));
|
|
389
|
+
})))));
|
|
289
390
|
}
|
|
391
|
+
|
|
290
392
|
}
|
|
291
393
|
PickerPanel.defaultProps = {
|
|
292
|
-
valueProperty:
|
|
293
|
-
labelProperty:
|
|
394
|
+
valueProperty: 'value',
|
|
395
|
+
labelProperty: 'label',
|
|
294
396
|
numberItemsOnScreen: 5,
|
|
397
|
+
// this number should be impair
|
|
295
398
|
options: [],
|
|
296
399
|
arrowStep: 1
|
|
297
400
|
};
|
|
298
|
-
|
|
299
|
-
|
|
401
|
+
|
|
402
|
+
module.exports = PickerPanel;
|