@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
package/esm/TimePickerMenu.js
CHANGED
|
@@ -1,296 +1,291 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
1
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import _possibleConstructorReturn from '@babel/runtime/helpers/esm/possibleConstructorReturn';
|
|
7
|
-
import _getPrototypeOf from '@babel/runtime/helpers/esm/getPrototypeOf';
|
|
8
|
-
import React, { Component } from 'react';
|
|
9
|
-
import PropTypes from 'prop-types';
|
|
7
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
8
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
9
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
10
|
+
import { Component } from 'react';
|
|
10
11
|
import { aggregatedClasses } from '@elliemae/ds-classnames';
|
|
11
12
|
import moment from 'moment';
|
|
12
13
|
import { range, addLeadingZeros } from '@elliemae/ds-utilities';
|
|
13
14
|
import { isAM } from './utils.js';
|
|
14
15
|
import PickerPanel from './PickerPanel.js';
|
|
15
|
-
import '@babel/runtime/helpers/esm/extends';
|
|
16
|
-
import '@babel/runtime/helpers/esm/slicedToArray';
|
|
17
|
-
import '@babel/runtime/helpers/esm/toArray';
|
|
18
|
-
import 'lodash';
|
|
19
|
-
import 'memoize-one';
|
|
20
|
-
import '@elliemae/ds-icons';
|
|
21
|
-
import '@elliemae/ds-button';
|
|
22
|
-
import './moveElementOnScroll.js';
|
|
23
16
|
|
|
24
17
|
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; }
|
|
25
18
|
|
|
26
19
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
20
|
+
const blockName = 'time-picker-menu';
|
|
21
|
+
const TimePickerContainer = aggregatedClasses('div')(blockName);
|
|
22
|
+
const TimePickerHeader = aggregatedClasses('div')(blockName, 'header');
|
|
23
|
+
const TimePickerPanelContainer = aggregatedClasses('div')(blockName, 'panel-container');
|
|
24
|
+
|
|
25
|
+
const generateOption = format => option => ({
|
|
26
|
+
value: option,
|
|
27
|
+
label: typeof format === 'function' ? format(option) : option
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
class TimePickerMenu extends Component {
|
|
31
|
+
constructor(props) {
|
|
32
|
+
super(props);
|
|
33
|
+
|
|
34
|
+
this.renderHeader = () => {
|
|
35
|
+
const {
|
|
36
|
+
time
|
|
37
|
+
} = this.state;
|
|
38
|
+
return /*#__PURE__*/_jsx(TimePickerHeader, {}, void 0, time.format('hh:mma'));
|
|
39
|
+
};
|
|
27
40
|
|
|
28
|
-
|
|
41
|
+
this.state = {
|
|
42
|
+
time: moment(props.time || '', props.format) || moment()
|
|
43
|
+
};
|
|
44
|
+
this.handleHoursChange = this.handleHoursChange.bind(this);
|
|
45
|
+
this.handleMinuteChange = this.handleMinuteChange.bind(this);
|
|
46
|
+
this.handleSecondsChange = this.handleSecondsChange.bind(this);
|
|
47
|
+
this.handleAMPMChange = this.handleAMPMChange.bind(this);
|
|
48
|
+
}
|
|
29
49
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
50
|
+
static getDerivedStateFromProps(props, state) {
|
|
51
|
+
if (props.time) {
|
|
52
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
53
|
+
time: moment(props.time)
|
|
54
|
+
});
|
|
55
|
+
}
|
|
35
56
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
label: typeof format === 'function' ? format(option) : option
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
};
|
|
57
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
58
|
+
time: undefined
|
|
59
|
+
});
|
|
60
|
+
}
|
|
44
61
|
|
|
45
|
-
|
|
46
|
-
|
|
62
|
+
componentDidMount() {
|
|
63
|
+
const {
|
|
64
|
+
time
|
|
65
|
+
} = this.state;
|
|
66
|
+
this.setState({
|
|
67
|
+
time
|
|
68
|
+
});
|
|
69
|
+
}
|
|
47
70
|
|
|
48
|
-
|
|
71
|
+
handleMinuteChange(value) {
|
|
72
|
+
const {
|
|
73
|
+
time
|
|
74
|
+
} = this.state;
|
|
75
|
+
this.updateTime(time.minute(value));
|
|
76
|
+
}
|
|
49
77
|
|
|
50
|
-
|
|
51
|
-
|
|
78
|
+
handleHoursChange(value) {
|
|
79
|
+
const {
|
|
80
|
+
time
|
|
81
|
+
} = this.state;
|
|
82
|
+
const {
|
|
83
|
+
use12Hours
|
|
84
|
+
} = this.props;
|
|
85
|
+
let nextHour = value;
|
|
86
|
+
|
|
87
|
+
if (use12Hours) {
|
|
88
|
+
if (!isAM(time)) {
|
|
89
|
+
nextHour = value % 12 + 12;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
52
92
|
|
|
53
|
-
|
|
93
|
+
this.updateTime(time.hour(nextHour));
|
|
94
|
+
}
|
|
54
95
|
|
|
55
|
-
|
|
96
|
+
handleSecondsChange(value) {
|
|
97
|
+
const {
|
|
98
|
+
time
|
|
99
|
+
} = this.state;
|
|
100
|
+
this.updateTime(time.second(value));
|
|
101
|
+
}
|
|
56
102
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
};
|
|
103
|
+
handleAMPMChange(value) {
|
|
104
|
+
const {
|
|
105
|
+
time
|
|
106
|
+
} = this.state;
|
|
107
|
+
const hour = time.hour();
|
|
108
|
+
const nextHour = value.toLowerCase() === 'am' ? hour % 12 : hour % 12 + 12;
|
|
109
|
+
this.updateTime(time.hour(nextHour));
|
|
110
|
+
}
|
|
61
111
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
112
|
+
updateTime(time) {
|
|
113
|
+
const {
|
|
114
|
+
onTimeChange
|
|
115
|
+
} = this.props;
|
|
116
|
+
onTimeChange(time);
|
|
117
|
+
this.setState({
|
|
118
|
+
time
|
|
119
|
+
});
|
|
70
120
|
}
|
|
71
121
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
122
|
+
renderHoursPanel() {
|
|
123
|
+
const {
|
|
124
|
+
time
|
|
125
|
+
} = this.state;
|
|
126
|
+
const {
|
|
127
|
+
showHours,
|
|
128
|
+
use12Hours,
|
|
129
|
+
format,
|
|
130
|
+
hasHeader,
|
|
131
|
+
disabledTimes
|
|
132
|
+
} = this.props;
|
|
133
|
+
if (!showHours) return null;
|
|
134
|
+
const hour = time.hour(); // in 24 format
|
|
135
|
+
|
|
136
|
+
let selectedHour = use12Hours ? hour % 12 || 12 : hour;
|
|
137
|
+
|
|
138
|
+
if (disabledTimes) {
|
|
139
|
+
const {
|
|
140
|
+
from,
|
|
141
|
+
to
|
|
142
|
+
} = disabledTimes;
|
|
143
|
+
|
|
144
|
+
if (hour > from.hour && hour < to.hour) {
|
|
145
|
+
if (to.hour < 24) {
|
|
146
|
+
const toFormatted = to.hour % 12 || 12;
|
|
147
|
+
if (selectedHour !== toFormatted) this.handleHoursChange(toFormatted);
|
|
148
|
+
selectedHour = toFormatted;
|
|
149
|
+
} else if (from) {
|
|
150
|
+
selectedHour = (from.hour - 1) % 12 || 12;
|
|
96
151
|
}
|
|
97
152
|
}
|
|
98
|
-
|
|
99
|
-
this.updateTime(time.hour(nextHour));
|
|
100
153
|
}
|
|
101
|
-
}, {
|
|
102
|
-
key: "handleSecondsChange",
|
|
103
|
-
value: function handleSecondsChange(value) {
|
|
104
|
-
var time = this.state.time;
|
|
105
|
-
this.updateTime(time.second(value));
|
|
106
|
-
}
|
|
107
|
-
}, {
|
|
108
|
-
key: "handleAMPMChange",
|
|
109
|
-
value: function handleAMPMChange(value) {
|
|
110
|
-
var time = this.state.time;
|
|
111
|
-
var hour = time.hour();
|
|
112
|
-
var nextHour = value.toLowerCase() === 'am' ? hour % 12 : hour % 12 + 12;
|
|
113
|
-
this.updateTime(time.hour(nextHour));
|
|
114
|
-
}
|
|
115
|
-
}, {
|
|
116
|
-
key: "updateTime",
|
|
117
|
-
value: function updateTime(time) {
|
|
118
|
-
var onTimeChange = this.props.onTimeChange;
|
|
119
|
-
onTimeChange(time);
|
|
120
|
-
this.setState({
|
|
121
|
-
time: time
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
}, {
|
|
125
|
-
key: "renderHoursPanel",
|
|
126
|
-
value: function renderHoursPanel() {
|
|
127
|
-
var time = this.state.time;
|
|
128
|
-
var _this$props = this.props,
|
|
129
|
-
showHours = _this$props.showHours,
|
|
130
|
-
use12Hours = _this$props.use12Hours,
|
|
131
|
-
format = _this$props.format,
|
|
132
|
-
hasHeader = _this$props.hasHeader,
|
|
133
|
-
disabledTimes = _this$props.disabledTimes;
|
|
134
|
-
if (!showHours) return null;
|
|
135
|
-
var hour = time.hour(); // in 24 format
|
|
136
|
-
|
|
137
|
-
var selectedHour = use12Hours ? hour % 12 || 12 : hour;
|
|
138
|
-
|
|
139
|
-
if (disabledTimes) {
|
|
140
|
-
var from = disabledTimes.from,
|
|
141
|
-
to = disabledTimes.to;
|
|
142
|
-
|
|
143
|
-
if (hour > from.hour && hour < to.hour) {
|
|
144
|
-
if (to.hour < 24) {
|
|
145
|
-
var toFormatted = to.hour % 12 || 12;
|
|
146
|
-
if (selectedHour !== toFormatted) this.handleHoursChange(toFormatted);
|
|
147
|
-
selectedHour = toFormatted;
|
|
148
|
-
} else if (from) {
|
|
149
|
-
selectedHour = (from.hour - 1) % 12 || 12;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
154
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
155
|
+
const meridiem = hour >= 12 ? 'PM' : 'AM';
|
|
156
|
+
const withLeadingZeros = format.indexOf('hh') > -1;
|
|
157
|
+
const rangeHours = use12Hours ? range(1, 13) : range(24);
|
|
158
|
+
const hoursOptions = rangeHours.map(generateOption(withLeadingZeros && addLeadingZeros(2)));
|
|
159
|
+
return /*#__PURE__*/_jsx(PickerPanel, {
|
|
160
|
+
type: "hour",
|
|
161
|
+
time: time,
|
|
162
|
+
meridiem: meridiem,
|
|
163
|
+
hasHeader: hasHeader,
|
|
164
|
+
header: "H",
|
|
165
|
+
onChange: this.handleHoursChange,
|
|
166
|
+
options: hoursOptions,
|
|
167
|
+
selected: selectedHour,
|
|
168
|
+
disabledTimes: disabledTimes
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
renderMinutesPanel() {
|
|
173
|
+
const {
|
|
174
|
+
time
|
|
175
|
+
} = this.state;
|
|
176
|
+
const {
|
|
177
|
+
showMinutes,
|
|
178
|
+
format,
|
|
179
|
+
hasHeader,
|
|
180
|
+
disabledTimes,
|
|
181
|
+
minutesInterval
|
|
182
|
+
} = this.props;
|
|
183
|
+
if (!showMinutes) return null;
|
|
184
|
+
const withLeadingZeros = format.indexOf('mm') > -1;
|
|
185
|
+
const rangeMinutes = range(0, 60, minutesInterval).map(generateOption(withLeadingZeros && addLeadingZeros(2)));
|
|
186
|
+
let selectedMinute = time.minute();
|
|
187
|
+
const selectedHour = time.hour();
|
|
188
|
+
|
|
189
|
+
if (disabledTimes) {
|
|
190
|
+
const {
|
|
191
|
+
from,
|
|
192
|
+
to
|
|
193
|
+
} = disabledTimes;
|
|
194
|
+
|
|
195
|
+
if (selectedHour <= to.hour && selectedHour > from.hour) {
|
|
196
|
+
if (to) {
|
|
197
|
+
if (selectedMinute < to.min) this.handleMinuteChange(to.min);
|
|
198
|
+
} else if (from) {
|
|
199
|
+
if (selectedMinute > from.min) this.handleMinuteChange(from.min - 1);
|
|
198
200
|
}
|
|
201
|
+
} else {
|
|
202
|
+
selectedMinute = time.minute();
|
|
199
203
|
}
|
|
200
|
-
|
|
201
|
-
return /*#__PURE__*/React.createElement(PickerPanel, {
|
|
202
|
-
type: "minutes",
|
|
203
|
-
time: time,
|
|
204
|
-
hasHeader: hasHeader,
|
|
205
|
-
header: "M",
|
|
206
|
-
onChange: this.handleMinuteChange,
|
|
207
|
-
options: rangeMinutes,
|
|
208
|
-
selected: selectedMinute,
|
|
209
|
-
disabledTimes: disabledTimes
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
}, {
|
|
213
|
-
key: "renderSecondsPanel",
|
|
214
|
-
value: function renderSecondsPanel() {
|
|
215
|
-
var time = this.state.time;
|
|
216
|
-
var _this$props3 = this.props,
|
|
217
|
-
showSeconds = _this$props3.showSeconds,
|
|
218
|
-
format = _this$props3.format,
|
|
219
|
-
hasHeader = _this$props3.hasHeader;
|
|
220
|
-
if (!showSeconds) return null;
|
|
221
|
-
var withLeadingZeros = format.indexOf('ss') > -1;
|
|
222
|
-
var rangeSeconds = range(60).map(generateOption(withLeadingZeros && addLeadingZeros(2)));
|
|
223
|
-
return /*#__PURE__*/React.createElement(PickerPanel, {
|
|
224
|
-
type: "seconds",
|
|
225
|
-
hasHeader: hasHeader,
|
|
226
|
-
header: "S",
|
|
227
|
-
onChange: this.handleSecondsChange,
|
|
228
|
-
options: rangeSeconds,
|
|
229
|
-
selected: time.second()
|
|
230
|
-
});
|
|
231
204
|
}
|
|
232
|
-
}, {
|
|
233
|
-
key: "renderAMPMPanel",
|
|
234
|
-
value: function renderAMPMPanel() {
|
|
235
|
-
var time = this.state.time;
|
|
236
|
-
var _this$props4 = this.props,
|
|
237
|
-
use12Hours = _this$props4.use12Hours,
|
|
238
|
-
hasHeader = _this$props4.hasHeader,
|
|
239
|
-
disabledTimes = _this$props4.disabledTimes;
|
|
240
|
-
if (!use12Hours) return null;
|
|
241
|
-
var meridiemSelected = !isAM(time) ? 'pm' : 'am';
|
|
242
|
-
|
|
243
|
-
if (disabledTimes && disabledTimes.to && meridiemSelected === 'am') {
|
|
244
|
-
meridiemSelected = disabledTimes.to.hour >= 12 ? 'pm' : 'am';
|
|
245
|
-
|
|
246
|
-
if (meridiemSelected === 'am' && time.hour() > 12) {
|
|
247
|
-
this.handleAMPMChange('am');
|
|
248
|
-
}
|
|
249
205
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
206
|
+
return /*#__PURE__*/_jsx(PickerPanel, {
|
|
207
|
+
type: "minutes",
|
|
208
|
+
time: time,
|
|
209
|
+
hasHeader: hasHeader,
|
|
210
|
+
header: "M",
|
|
211
|
+
onChange: this.handleMinuteChange,
|
|
212
|
+
options: rangeMinutes,
|
|
213
|
+
selected: selectedMinute,
|
|
214
|
+
disabledTimes: disabledTimes
|
|
215
|
+
});
|
|
216
|
+
}
|
|
254
217
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
218
|
+
renderSecondsPanel() {
|
|
219
|
+
const {
|
|
220
|
+
time
|
|
221
|
+
} = this.state;
|
|
222
|
+
const {
|
|
223
|
+
showSeconds,
|
|
224
|
+
format,
|
|
225
|
+
hasHeader
|
|
226
|
+
} = this.props;
|
|
227
|
+
if (!showSeconds) return null;
|
|
228
|
+
const withLeadingZeros = format.indexOf('ss') > -1;
|
|
229
|
+
const rangeSeconds = range(60).map(generateOption(withLeadingZeros && addLeadingZeros(2)));
|
|
230
|
+
return /*#__PURE__*/_jsx(PickerPanel, {
|
|
231
|
+
type: "seconds",
|
|
232
|
+
hasHeader: hasHeader,
|
|
233
|
+
header: "S",
|
|
234
|
+
onChange: this.handleSecondsChange,
|
|
235
|
+
options: rangeSeconds,
|
|
236
|
+
selected: time.second()
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
renderAMPMPanel() {
|
|
241
|
+
const {
|
|
242
|
+
time
|
|
243
|
+
} = this.state;
|
|
244
|
+
const {
|
|
245
|
+
use12Hours,
|
|
246
|
+
hasHeader,
|
|
247
|
+
disabledTimes
|
|
248
|
+
} = this.props;
|
|
249
|
+
if (!use12Hours) return null;
|
|
250
|
+
let meridiemSelected = !isAM(time) ? 'pm' : 'am';
|
|
251
|
+
|
|
252
|
+
if (disabledTimes && disabledTimes.to && meridiemSelected === 'am') {
|
|
253
|
+
meridiemSelected = disabledTimes.to.hour >= 12 ? 'pm' : 'am';
|
|
254
|
+
|
|
255
|
+
if (meridiemSelected === 'am' && time.hour() > 12) {
|
|
256
|
+
this.handleAMPMChange('am');
|
|
284
257
|
}
|
|
285
258
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
}
|
|
259
|
+
if (meridiemSelected === 'pm' && time.hour() <= 12) {
|
|
260
|
+
this.handleAMPMChange('pm');
|
|
261
|
+
}
|
|
289
262
|
}
|
|
290
|
-
}]);
|
|
291
263
|
|
|
292
|
-
|
|
293
|
-
|
|
264
|
+
return /*#__PURE__*/_jsx(PickerPanel, {
|
|
265
|
+
type: "meridiem",
|
|
266
|
+
hasHeader: hasHeader,
|
|
267
|
+
header: "",
|
|
268
|
+
onChange: this.handleAMPMChange,
|
|
269
|
+
options: [{
|
|
270
|
+
value: 'am',
|
|
271
|
+
label: 'am'
|
|
272
|
+
}, {
|
|
273
|
+
value: 'pm',
|
|
274
|
+
label: 'pm'
|
|
275
|
+
}],
|
|
276
|
+
selected: meridiemSelected,
|
|
277
|
+
disabledTimes: disabledTimes
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
render() {
|
|
282
|
+
const {
|
|
283
|
+
hasHeaderDisplay
|
|
284
|
+
} = this.props;
|
|
285
|
+
return /*#__PURE__*/_jsx(TimePickerContainer, {}, void 0, hasHeaderDisplay && this.renderHeader(), /*#__PURE__*/_jsx(TimePickerPanelContainer, {}, void 0, this.renderHoursPanel(), this.renderMinutesPanel(), this.renderSecondsPanel(), this.renderAMPMPanel()));
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
}
|
|
294
289
|
|
|
295
290
|
TimePickerMenu.defaultProps = {
|
|
296
291
|
time: moment(),
|
|
@@ -300,33 +295,7 @@ TimePickerMenu.defaultProps = {
|
|
|
300
295
|
showMinutes: true,
|
|
301
296
|
showHours: true,
|
|
302
297
|
disabledTimes: undefined,
|
|
303
|
-
onTimeChange:
|
|
304
|
-
return null;
|
|
305
|
-
}
|
|
306
|
-
};
|
|
307
|
-
TimePickerMenu.propTypes = {
|
|
308
|
-
/** Time value */
|
|
309
|
-
time: PropTypes.instanceOf(moment),
|
|
310
|
-
|
|
311
|
-
/** If the menu has header or not */
|
|
312
|
-
hasHeader: PropTypes.bool,
|
|
313
|
-
|
|
314
|
-
/** Whether to use the 12 hours format */
|
|
315
|
-
use12Hours: PropTypes.bool,
|
|
316
|
-
|
|
317
|
-
/** Whether show 'seconds' or not */
|
|
318
|
-
showSeconds: PropTypes.bool,
|
|
319
|
-
|
|
320
|
-
/** Whether show 'minutes' or not */
|
|
321
|
-
showMinutes: PropTypes.bool,
|
|
322
|
-
|
|
323
|
-
/** Whether show 'hours' or not */
|
|
324
|
-
showHours: PropTypes.bool,
|
|
325
|
-
|
|
326
|
-
/** Handler when time changes */
|
|
327
|
-
onTimeChange: PropTypes.func,
|
|
328
|
-
disabledTimes: PropTypes.object
|
|
298
|
+
onTimeChange: () => null
|
|
329
299
|
};
|
|
330
300
|
|
|
331
301
|
export { TimePickerMenu, TimePickerMenu as default };
|
|
332
|
-
//# sourceMappingURL=TimePickerMenu.js.map
|
package/esm/index.js
CHANGED
|
@@ -2,32 +2,3 @@ export { DSTimePicker, DSTimePickerWithSchema, DSTimePicker as default } from '.
|
|
|
2
2
|
export { TimePickerMenu } from './TimePickerMenu.js';
|
|
3
3
|
export { DSTimePickerMenu } from './DSTimePickerMenu.js';
|
|
4
4
|
export { convertTimeString } from './utils.js';
|
|
5
|
-
import 'react';
|
|
6
|
-
import 'react-desc';
|
|
7
|
-
import 'moment';
|
|
8
|
-
import './TimePickerImpl.js';
|
|
9
|
-
import '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
10
|
-
import '@babel/runtime/helpers/esm/extends';
|
|
11
|
-
import '@babel/runtime/helpers/esm/slicedToArray';
|
|
12
|
-
import 'prop-types';
|
|
13
|
-
import 'memoize-one';
|
|
14
|
-
import '@elliemae/ds-utilities';
|
|
15
|
-
import '@elliemae/ds-classnames';
|
|
16
|
-
import '@elliemae/ds-form';
|
|
17
|
-
import './TimePickerDropdown.js';
|
|
18
|
-
import '@elliemae/ds-icons';
|
|
19
|
-
import '@elliemae/ds-button';
|
|
20
|
-
import '@elliemae/ds-popper';
|
|
21
|
-
import '@babel/runtime/helpers/esm/defineProperty';
|
|
22
|
-
import '@babel/runtime/helpers/esm/classCallCheck';
|
|
23
|
-
import '@babel/runtime/helpers/esm/createClass';
|
|
24
|
-
import '@babel/runtime/helpers/esm/assertThisInitialized';
|
|
25
|
-
import '@babel/runtime/helpers/esm/inherits';
|
|
26
|
-
import '@babel/runtime/helpers/esm/possibleConstructorReturn';
|
|
27
|
-
import '@babel/runtime/helpers/esm/getPrototypeOf';
|
|
28
|
-
import './PickerPanel.js';
|
|
29
|
-
import '@babel/runtime/helpers/esm/toArray';
|
|
30
|
-
import 'lodash';
|
|
31
|
-
import './moveElementOnScroll.js';
|
|
32
|
-
import 'styled-components';
|
|
33
|
-
//# sourceMappingURL=index.js.map
|