@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.
Files changed (41) hide show
  1. package/cjs/DSTimePicker.js +115 -100
  2. package/cjs/DSTimePickerMenu.js +33 -46
  3. package/cjs/PickerPanel.js +254 -151
  4. package/cjs/TimePickerDropdown.js +52 -73
  5. package/cjs/TimePickerImpl.js +138 -146
  6. package/cjs/TimePickerMenu.js +209 -138
  7. package/cjs/index.js +17 -40
  8. package/cjs/moveElementOnScroll.js +39 -57
  9. package/cjs/utils.js +24 -57
  10. package/esm/DSTimePicker.js +105 -71
  11. package/esm/DSTimePickerMenu.js +22 -17
  12. package/esm/PickerPanel.js +242 -120
  13. package/esm/TimePickerDropdown.js +44 -44
  14. package/esm/TimePickerImpl.js +117 -106
  15. package/esm/TimePickerMenu.js +191 -102
  16. package/esm/index.js +4 -11
  17. package/esm/moveElementOnScroll.js +34 -28
  18. package/esm/utils.js +17 -28
  19. package/package.json +7 -7
  20. package/types/DSTimePicker.d.ts +1 -20
  21. package/types/PickerPanel.d.ts +0 -1
  22. package/types/TimePickerDropdown.d.ts +0 -1
  23. package/types/TimePickerImpl.d.ts +0 -1
  24. package/cjs/DSTimePicker.js.map +0 -7
  25. package/cjs/DSTimePickerMenu.js.map +0 -7
  26. package/cjs/PickerPanel.js.map +0 -7
  27. package/cjs/TimePickerDropdown.js.map +0 -7
  28. package/cjs/TimePickerImpl.js.map +0 -7
  29. package/cjs/TimePickerMenu.js.map +0 -7
  30. package/cjs/index.js.map +0 -7
  31. package/cjs/moveElementOnScroll.js.map +0 -7
  32. package/cjs/utils.js.map +0 -7
  33. package/esm/DSTimePicker.js.map +0 -7
  34. package/esm/DSTimePickerMenu.js.map +0 -7
  35. package/esm/PickerPanel.js.map +0 -7
  36. package/esm/TimePickerDropdown.js.map +0 -7
  37. package/esm/TimePickerImpl.js.map +0 -7
  38. package/esm/TimePickerMenu.js.map +0 -7
  39. package/esm/index.js.map +0 -7
  40. package/esm/moveElementOnScroll.js.map +0 -7
  41. package/esm/utils.js.map +0 -7
@@ -1,117 +1,157 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __reExport = (target, module2, copyDefault, desc) => {
13
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
- for (let key of __getOwnPropNames(module2))
15
- if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
- }
18
- return target;
19
- };
20
- var __toESM = (module2, isNodeMode) => {
21
- return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
- };
23
- var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
- return (module2, temp) => {
25
- return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
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
- var React = __toESM(require("react"));
34
- var import_react = __toESM(require("react"));
35
- var import_lodash = __toESM(require("lodash"));
36
- var import_ds_classnames = __toESM(require("@elliemae/ds-classnames"));
37
- var import_memoize_one = __toESM(require("memoize-one"));
38
- var import_ds_icons = __toESM(require("@elliemae/ds-icons"));
39
- var import_ds_button = __toESM(require("@elliemae/ds-button"));
40
- var import_moveElementOnScroll = __toESM(require("./moveElementOnScroll"));
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: "text",
72
+ buttonType: 'text',
61
73
  fluidHeight: true,
62
74
  fluidWidth: true,
63
- size: "s"
75
+ size: 's'
64
76
  };
65
- class PickerPanel extends import_react.Component {
77
+ class PickerPanel extends React.Component {
66
78
  constructor(props) {
67
79
  super(props);
68
- this.computeContainerTranslation = (0, import_memoize_one.default)((index) => {
69
- const { options, valueProperty } = this.props;
70
- const { selectedOption, scrolling } = this.state;
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 { header } = this.props;
79
- return /* @__PURE__ */ import_react.default.createElement(PickerHeader, null, header);
96
+ const {
97
+ header
98
+ } = this.props;
99
+ return /*#__PURE__*/_jsx__default["default"](PickerHeader, {}, void 0, header);
80
100
  };
81
- this.pickerListContainerRef = import_react.default.createRef();
82
- this.pickerListRef = import_react.default.createRef();
83
- this.pickerItemRef = import_react.default.createRef();
84
- this.selectedOptionRef = import_react.default.createRef();
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 import_moveElementOnScroll.MoveElementOnScroll(pickerListEl, {
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 { options } = this.props;
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({ scrolling: false });
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
- static getDerivedStateFromProps(nextProps, { prevProps }) {
114
- const { selected, valueProperty, options } = nextProps;
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 { valueProperty } = this.props;
167
+ const {
168
+ valueProperty
169
+ } = this.props;
126
170
  return option[valueProperty];
127
171
  }
172
+
128
173
  getOptionLabel(option) {
129
- const { labelProperty } = this.props;
174
+ const {
175
+ labelProperty
176
+ } = this.props;
130
177
  return option[labelProperty];
131
178
  }
179
+
132
180
  computeSizes() {
133
- const { options, numberItemsOnScreen } = this.props;
134
- const { offsetHeight: optionHeight } = this.pickerItemRef.current;
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 { onChange } = this.props;
142
- this.setState((state) => ({
143
- ...state,
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 { activeIndex } = this.state;
153
- const { options } = this.props;
154
- const [firstColumn, ...restColumns] = document.getElementsByClassName("em-ds-time-picker-panel");
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("DayPickerNavigation_button");
218
+ const [prev] = document.getElementsByClassName('DayPickerNavigation_button');
157
219
  const focusedElement = document.activeElement;
220
+
158
221
  switch (e.key) {
159
- case "Home":
222
+ case 'Home':
160
223
  this.moveTo(0);
161
224
  break;
162
- case "End":
225
+
226
+ case 'End':
163
227
  this.moveTo(options.length - 1);
164
228
  break;
165
- case "ArrowUp":
229
+
230
+ case 'ArrowUp':
166
231
  this.moveTo(activeIndex - 1);
167
232
  break;
168
- case "ArrowDown":
233
+
234
+ case 'ArrowDown':
169
235
  this.moveTo(activeIndex + 1);
170
236
  break;
171
- case "Tab": {
172
- e.preventDefault();
173
- if (prev && focusedElement === lastColumn) {
174
- prev.focus();
175
- } else if (focusedElement === lastColumn) {
176
- firstColumn.focus();
177
- } else {
178
- const position = (0, import_lodash.findIndex)(restColumns, focusedElement);
179
- restColumns[position + 1].focus();
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 { options } = this.props;
189
- const { selectedOption } = this.state;
190
- const validIndex = (0, import_utils.validateIndex)(index, options);
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 { activeIndex } = this.state;
199
- const { arrowStep, options } = this.props;
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((op) => !op.disabled);
283
+ const nextValidOption = options.find(op => !op.disabled);
203
284
  this.moveTo(nextPos, true, nextValidOption);
204
285
  }
286
+
205
287
  handleStepMoveDown() {
206
- const { activeIndex } = this.state;
207
- const { arrowStep, options } = this.props;
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 { options, hasHeader, type, time, meridiem, disabledTimes } = this.props;
214
- const { selectedOption, activeIndex, scrolling } = this.state;
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 /* @__PURE__ */ import_react.default.createElement(Wrapper, null, hasHeader && this.renderHeader(), /* @__PURE__ */ import_react.default.createElement(Container, {
217
- classProps: { scrolling },
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
- }, /* @__PURE__ */ import_react.default.createElement(PickerSelectedOptionSelected, {
321
+ }, void 0, /*#__PURE__*/_jsx__default["default"](PickerSelectedOptionSelected, {
221
322
  innerRef: this.selectedOptionRef
222
- }, /* @__PURE__ */ import_react.default.createElement(SelectedCircle, null)), /* @__PURE__ */ import_react.default.createElement(ArrowButtonContainer, null, /* @__PURE__ */ import_react.default.createElement(import_ds_button.DSButton, {
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": `${type}-chevron-up`,
325
+ "data-testid": "".concat(type, "-chevron-up"),
226
326
  disabled: activeIndex <= 0,
227
- icon: /* @__PURE__ */ import_react.default.createElement(import_ds_icons.ChevronSmallUp, null),
327
+ icon: _ChevronSmallUp || (_ChevronSmallUp = /*#__PURE__*/_jsx__default["default"](dsIcons.ChevronSmallUp, {})),
228
328
  onClick: this.handleStepMoveUp,
229
329
  tabIndex: -1
230
- })), /* @__PURE__ */ import_react.default.createElement(PickerItemListContainer, {
330
+ }))), /*#__PURE__*/_jsx__default["default"](PickerItemListContainer, {
231
331
  innerRef: this.pickerListContainerRef,
232
332
  style: {
233
333
  height: this.listHeight
234
334
  }
235
- }, /* @__PURE__ */ import_react.default.createElement(PickerItemList, {
236
- "data-testid": `${type}-list`,
335
+ }, void 0, /*#__PURE__*/_jsx__default["default"](PickerItemList, {
336
+ "data-testid": "".concat(type, "-list"),
237
337
  innerRef: this.pickerListRef,
238
338
  style: {
239
- transform: `translateY(${listYPosition}px)`
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 === "AM")
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 { from, to } = disabledTimes;
254
- if (type === "hour" && valueFormatted >= from?.hour && valueFormatted < to?.hour || type === "minutes" && value >= from?.min && value < to?.min) {
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
- if (type === "minutes" && (time?.hour() > to?.hour || time?.hour() < from?.hour)) {
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
- if (label === "am" && from?.hour == 0 && to?.hour >= 12) {
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
- if (label === "pm" && to?.hour == 24) {
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 /* @__PURE__ */ import_react.default.createElement(PickerItemContainer, {
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
- }))), /* @__PURE__ */ import_react.default.createElement(ArrowButtonContainer, null, /* @__PURE__ */ import_react.default.createElement(import_ds_button.DSButton, {
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": `${type}-chevron-down`,
384
+ "data-testid": "".concat(type, "-chevron-down"),
284
385
  disabled: activeIndex >= options.length - 1,
285
- icon: /* @__PURE__ */ import_react.default.createElement(import_ds_icons.ChevronSmallDown, null),
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: "value",
293
- labelProperty: "label",
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
- module.exports = __toCommonJS(PickerPanel_exports);
299
- //# sourceMappingURL=PickerPanel.js.map
401
+
402
+ module.exports = PickerPanel;