@elliemae/ds-time-picker 2.2.0-alpha.3 → 2.2.0-next.2
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/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/TimePickerMenu.js
CHANGED
|
@@ -1,241 +1,312 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var import_ds_classnames = __toESM(require("@elliemae/ds-classnames"));
|
|
37
|
-
var import_moment = __toESM(require("moment"));
|
|
38
|
-
var import_ds_utilities = __toESM(require("@elliemae/ds-utilities"));
|
|
39
|
-
var import_utils = __toESM(require("./utils"));
|
|
40
|
-
var import_PickerPanel = __toESM(require("./PickerPanel"));
|
|
41
|
-
const blockName = "time-picker-menu";
|
|
42
|
-
const TimePickerContainer = (0, import_ds_classnames.aggregatedClasses)("div")(blockName);
|
|
43
|
-
const TimePickerHeader = (0, import_ds_classnames.aggregatedClasses)("div")(blockName, "header");
|
|
44
|
-
const TimePickerPanelContainer = (0, import_ds_classnames.aggregatedClasses)("div")(blockName, "panel-container");
|
|
45
|
-
const generateOption = (format) => (option) => ({
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
7
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
9
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
10
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
11
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
12
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
13
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
14
|
+
var React = require('react');
|
|
15
|
+
var dsClassnames = require('@elliemae/ds-classnames');
|
|
16
|
+
var moment = require('moment');
|
|
17
|
+
var dsUtilities = require('@elliemae/ds-utilities');
|
|
18
|
+
var utils = require('./utils.js');
|
|
19
|
+
var PickerPanel = require('./PickerPanel.js');
|
|
20
|
+
|
|
21
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
22
|
+
|
|
23
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
24
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
25
|
+
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
26
|
+
|
|
27
|
+
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; }
|
|
28
|
+
|
|
29
|
+
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; }
|
|
30
|
+
const blockName = 'time-picker-menu';
|
|
31
|
+
const TimePickerContainer = dsClassnames.aggregatedClasses('div')(blockName);
|
|
32
|
+
const TimePickerHeader = dsClassnames.aggregatedClasses('div')(blockName, 'header');
|
|
33
|
+
const TimePickerPanelContainer = dsClassnames.aggregatedClasses('div')(blockName, 'panel-container');
|
|
34
|
+
|
|
35
|
+
const generateOption = format => option => ({
|
|
46
36
|
value: option,
|
|
47
|
-
label: typeof format ===
|
|
37
|
+
label: typeof format === 'function' ? format(option) : option
|
|
48
38
|
});
|
|
49
|
-
|
|
39
|
+
|
|
40
|
+
class TimePickerMenu extends React.Component {
|
|
50
41
|
constructor(props) {
|
|
51
42
|
super(props);
|
|
43
|
+
|
|
52
44
|
this.renderHeader = () => {
|
|
53
|
-
const {
|
|
54
|
-
|
|
45
|
+
const {
|
|
46
|
+
time
|
|
47
|
+
} = this.state;
|
|
48
|
+
return /*#__PURE__*/_jsx__default["default"](TimePickerHeader, {}, void 0, time.format('hh:mma'));
|
|
55
49
|
};
|
|
50
|
+
|
|
56
51
|
this.state = {
|
|
57
|
-
time:
|
|
52
|
+
time: moment__default["default"](props.time || '', props.format) || moment__default["default"]()
|
|
58
53
|
};
|
|
54
|
+
this.handleHoursChange = this.handleHoursChange.bind(this);
|
|
55
|
+
this.handleMinuteChange = this.handleMinuteChange.bind(this);
|
|
56
|
+
this.handleSecondsChange = this.handleSecondsChange.bind(this);
|
|
57
|
+
this.handleAMPMChange = this.handleAMPMChange.bind(this);
|
|
59
58
|
}
|
|
59
|
+
|
|
60
60
|
static getDerivedStateFromProps(props, state) {
|
|
61
61
|
if (props.time) {
|
|
62
|
-
return {
|
|
62
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
63
|
+
time: moment__default["default"](props.time)
|
|
64
|
+
});
|
|
63
65
|
}
|
|
64
|
-
|
|
66
|
+
|
|
67
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
68
|
+
time: undefined
|
|
69
|
+
});
|
|
65
70
|
}
|
|
71
|
+
|
|
66
72
|
componentDidMount() {
|
|
67
|
-
const {
|
|
68
|
-
|
|
73
|
+
const {
|
|
74
|
+
time
|
|
75
|
+
} = this.state;
|
|
76
|
+
this.setState({
|
|
77
|
+
time
|
|
78
|
+
});
|
|
69
79
|
}
|
|
80
|
+
|
|
70
81
|
handleMinuteChange(value) {
|
|
71
|
-
const {
|
|
82
|
+
const {
|
|
83
|
+
time
|
|
84
|
+
} = this.state;
|
|
72
85
|
this.updateTime(time.minute(value));
|
|
73
86
|
}
|
|
87
|
+
|
|
74
88
|
handleHoursChange(value) {
|
|
75
|
-
const {
|
|
76
|
-
|
|
89
|
+
const {
|
|
90
|
+
time
|
|
91
|
+
} = this.state;
|
|
92
|
+
const {
|
|
93
|
+
use12Hours
|
|
94
|
+
} = this.props;
|
|
77
95
|
let nextHour = value;
|
|
96
|
+
|
|
78
97
|
if (use12Hours) {
|
|
79
|
-
if (!
|
|
98
|
+
if (!utils.isAM(time)) {
|
|
80
99
|
nextHour = value % 12 + 12;
|
|
81
100
|
}
|
|
82
101
|
}
|
|
102
|
+
|
|
83
103
|
this.updateTime(time.hour(nextHour));
|
|
84
104
|
}
|
|
105
|
+
|
|
85
106
|
handleSecondsChange(value) {
|
|
86
|
-
const {
|
|
107
|
+
const {
|
|
108
|
+
time
|
|
109
|
+
} = this.state;
|
|
87
110
|
this.updateTime(time.second(value));
|
|
88
111
|
}
|
|
112
|
+
|
|
89
113
|
handleAMPMChange(value) {
|
|
90
|
-
const {
|
|
114
|
+
const {
|
|
115
|
+
time
|
|
116
|
+
} = this.state;
|
|
91
117
|
const hour = time.hour();
|
|
92
|
-
const nextHour = value.toLowerCase() ===
|
|
118
|
+
const nextHour = value.toLowerCase() === 'am' ? hour % 12 : hour % 12 + 12;
|
|
93
119
|
this.updateTime(time.hour(nextHour));
|
|
94
120
|
}
|
|
121
|
+
|
|
95
122
|
updateTime(time) {
|
|
96
|
-
const {
|
|
123
|
+
const {
|
|
124
|
+
onTimeChange
|
|
125
|
+
} = this.props;
|
|
97
126
|
onTimeChange(time);
|
|
98
|
-
this.setState({
|
|
127
|
+
this.setState({
|
|
128
|
+
time
|
|
129
|
+
});
|
|
99
130
|
}
|
|
131
|
+
|
|
100
132
|
renderHoursPanel() {
|
|
101
|
-
const {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
133
|
+
const {
|
|
134
|
+
time
|
|
135
|
+
} = this.state;
|
|
136
|
+
const {
|
|
137
|
+
showHours,
|
|
138
|
+
use12Hours,
|
|
139
|
+
format,
|
|
140
|
+
hasHeader,
|
|
141
|
+
disabledTimes
|
|
142
|
+
} = this.props;
|
|
143
|
+
if (!showHours) return null;
|
|
144
|
+
const hour = time.hour(); // in 24 format
|
|
145
|
+
|
|
106
146
|
let selectedHour = use12Hours ? hour % 12 || 12 : hour;
|
|
147
|
+
|
|
107
148
|
if (disabledTimes) {
|
|
108
|
-
const {
|
|
149
|
+
const {
|
|
150
|
+
from,
|
|
151
|
+
to
|
|
152
|
+
} = disabledTimes;
|
|
153
|
+
|
|
109
154
|
if (hour > from.hour && hour < to.hour) {
|
|
110
155
|
if (to.hour < 24) {
|
|
111
156
|
const toFormatted = to.hour % 12 || 12;
|
|
112
|
-
if (selectedHour !== toFormatted)
|
|
113
|
-
this.handleHoursChange(toFormatted);
|
|
157
|
+
if (selectedHour !== toFormatted) this.handleHoursChange(toFormatted);
|
|
114
158
|
selectedHour = toFormatted;
|
|
115
159
|
} else if (from) {
|
|
116
160
|
selectedHour = (from.hour - 1) % 12 || 12;
|
|
117
161
|
}
|
|
118
162
|
}
|
|
119
163
|
}
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
const
|
|
123
|
-
const
|
|
124
|
-
|
|
164
|
+
|
|
165
|
+
const meridiem = hour >= 12 ? 'PM' : 'AM';
|
|
166
|
+
const withLeadingZeros = format.indexOf('hh') > -1;
|
|
167
|
+
const rangeHours = use12Hours ? dsUtilities.range(1, 13) : dsUtilities.range(24);
|
|
168
|
+
const hoursOptions = rangeHours.map(generateOption(withLeadingZeros && dsUtilities.addLeadingZeros(2)));
|
|
169
|
+
return /*#__PURE__*/_jsx__default["default"](PickerPanel, {
|
|
125
170
|
type: "hour",
|
|
126
|
-
time,
|
|
127
|
-
meridiem,
|
|
128
|
-
hasHeader,
|
|
171
|
+
time: time,
|
|
172
|
+
meridiem: meridiem,
|
|
173
|
+
hasHeader: hasHeader,
|
|
129
174
|
header: "H",
|
|
130
175
|
onChange: this.handleHoursChange,
|
|
131
176
|
options: hoursOptions,
|
|
132
177
|
selected: selectedHour,
|
|
133
|
-
disabledTimes
|
|
178
|
+
disabledTimes: disabledTimes
|
|
134
179
|
});
|
|
135
180
|
}
|
|
181
|
+
|
|
136
182
|
renderMinutesPanel() {
|
|
137
|
-
const {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
183
|
+
const {
|
|
184
|
+
time
|
|
185
|
+
} = this.state;
|
|
186
|
+
const {
|
|
187
|
+
showMinutes,
|
|
188
|
+
format,
|
|
189
|
+
hasHeader,
|
|
190
|
+
disabledTimes,
|
|
191
|
+
minutesInterval
|
|
192
|
+
} = this.props;
|
|
193
|
+
if (!showMinutes) return null;
|
|
194
|
+
const withLeadingZeros = format.indexOf('mm') > -1;
|
|
195
|
+
const rangeMinutes = dsUtilities.range(0, 60, minutesInterval).map(generateOption(withLeadingZeros && dsUtilities.addLeadingZeros(2)));
|
|
143
196
|
let selectedMinute = time.minute();
|
|
144
197
|
const selectedHour = time.hour();
|
|
198
|
+
|
|
145
199
|
if (disabledTimes) {
|
|
146
|
-
const {
|
|
200
|
+
const {
|
|
201
|
+
from,
|
|
202
|
+
to
|
|
203
|
+
} = disabledTimes;
|
|
204
|
+
|
|
147
205
|
if (selectedHour <= to.hour && selectedHour > from.hour) {
|
|
148
206
|
if (to) {
|
|
149
|
-
if (selectedMinute < to.min)
|
|
150
|
-
this.handleMinuteChange(to.min);
|
|
207
|
+
if (selectedMinute < to.min) this.handleMinuteChange(to.min);
|
|
151
208
|
} else if (from) {
|
|
152
|
-
if (selectedMinute > from.min)
|
|
153
|
-
this.handleMinuteChange(from.min - 1);
|
|
209
|
+
if (selectedMinute > from.min) this.handleMinuteChange(from.min - 1);
|
|
154
210
|
}
|
|
155
211
|
} else {
|
|
156
212
|
selectedMinute = time.minute();
|
|
157
213
|
}
|
|
158
214
|
}
|
|
159
|
-
|
|
215
|
+
|
|
216
|
+
return /*#__PURE__*/_jsx__default["default"](PickerPanel, {
|
|
160
217
|
type: "minutes",
|
|
161
|
-
time,
|
|
162
|
-
hasHeader,
|
|
218
|
+
time: time,
|
|
219
|
+
hasHeader: hasHeader,
|
|
163
220
|
header: "M",
|
|
164
221
|
onChange: this.handleMinuteChange,
|
|
165
222
|
options: rangeMinutes,
|
|
166
223
|
selected: selectedMinute,
|
|
167
|
-
disabledTimes
|
|
224
|
+
disabledTimes: disabledTimes
|
|
168
225
|
});
|
|
169
226
|
}
|
|
227
|
+
|
|
170
228
|
renderSecondsPanel() {
|
|
171
|
-
const {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
229
|
+
const {
|
|
230
|
+
time
|
|
231
|
+
} = this.state;
|
|
232
|
+
const {
|
|
233
|
+
showSeconds,
|
|
234
|
+
format,
|
|
235
|
+
hasHeader
|
|
236
|
+
} = this.props;
|
|
237
|
+
if (!showSeconds) return null;
|
|
238
|
+
const withLeadingZeros = format.indexOf('ss') > -1;
|
|
239
|
+
const rangeSeconds = dsUtilities.range(60).map(generateOption(withLeadingZeros && dsUtilities.addLeadingZeros(2)));
|
|
240
|
+
return /*#__PURE__*/_jsx__default["default"](PickerPanel, {
|
|
178
241
|
type: "seconds",
|
|
179
|
-
hasHeader,
|
|
242
|
+
hasHeader: hasHeader,
|
|
180
243
|
header: "S",
|
|
181
244
|
onChange: this.handleSecondsChange,
|
|
182
245
|
options: rangeSeconds,
|
|
183
246
|
selected: time.second()
|
|
184
247
|
});
|
|
185
248
|
}
|
|
249
|
+
|
|
186
250
|
renderAMPMPanel() {
|
|
187
|
-
const {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
251
|
+
const {
|
|
252
|
+
time
|
|
253
|
+
} = this.state;
|
|
254
|
+
const {
|
|
255
|
+
use12Hours,
|
|
256
|
+
hasHeader,
|
|
257
|
+
disabledTimes
|
|
258
|
+
} = this.props;
|
|
259
|
+
if (!use12Hours) return null;
|
|
260
|
+
let meridiemSelected = !utils.isAM(time) ? 'pm' : 'am';
|
|
261
|
+
|
|
262
|
+
if (disabledTimes && disabledTimes.to && meridiemSelected === 'am') {
|
|
263
|
+
meridiemSelected = disabledTimes.to.hour >= 12 ? 'pm' : 'am';
|
|
264
|
+
|
|
265
|
+
if (meridiemSelected === 'am' && time.hour() > 12) {
|
|
266
|
+
this.handleAMPMChange('am');
|
|
196
267
|
}
|
|
197
|
-
|
|
198
|
-
|
|
268
|
+
|
|
269
|
+
if (meridiemSelected === 'pm' && time.hour() <= 12) {
|
|
270
|
+
this.handleAMPMChange('pm');
|
|
199
271
|
}
|
|
200
272
|
}
|
|
201
|
-
|
|
273
|
+
|
|
274
|
+
return /*#__PURE__*/_jsx__default["default"](PickerPanel, {
|
|
202
275
|
type: "meridiem",
|
|
203
|
-
hasHeader,
|
|
276
|
+
hasHeader: hasHeader,
|
|
204
277
|
header: "",
|
|
205
278
|
onChange: this.handleAMPMChange,
|
|
206
|
-
options: [
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
279
|
+
options: [{
|
|
280
|
+
value: 'am',
|
|
281
|
+
label: 'am'
|
|
282
|
+
}, {
|
|
283
|
+
value: 'pm',
|
|
284
|
+
label: 'pm'
|
|
285
|
+
}],
|
|
210
286
|
selected: meridiemSelected,
|
|
211
|
-
disabledTimes
|
|
287
|
+
disabledTimes: disabledTimes
|
|
212
288
|
});
|
|
213
289
|
}
|
|
290
|
+
|
|
214
291
|
render() {
|
|
215
|
-
const {
|
|
216
|
-
|
|
292
|
+
const {
|
|
293
|
+
hasHeaderDisplay
|
|
294
|
+
} = this.props;
|
|
295
|
+
return /*#__PURE__*/_jsx__default["default"](TimePickerContainer, {}, void 0, hasHeaderDisplay && this.renderHeader(), /*#__PURE__*/_jsx__default["default"](TimePickerPanelContainer, {}, void 0, this.renderHoursPanel(), this.renderMinutesPanel(), this.renderSecondsPanel(), this.renderAMPMPanel()));
|
|
217
296
|
}
|
|
297
|
+
|
|
218
298
|
}
|
|
299
|
+
|
|
219
300
|
TimePickerMenu.defaultProps = {
|
|
220
|
-
time:
|
|
301
|
+
time: moment__default["default"](),
|
|
221
302
|
hasHeader: false,
|
|
222
303
|
use12Hours: true,
|
|
223
304
|
showSeconds: true,
|
|
224
305
|
showMinutes: true,
|
|
225
306
|
showHours: true,
|
|
226
|
-
disabledTimes:
|
|
307
|
+
disabledTimes: undefined,
|
|
227
308
|
onTimeChange: () => null
|
|
228
309
|
};
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
use12Hours: import_prop_types.default.bool,
|
|
233
|
-
showSeconds: import_prop_types.default.bool,
|
|
234
|
-
showMinutes: import_prop_types.default.bool,
|
|
235
|
-
showHours: import_prop_types.default.bool,
|
|
236
|
-
onTimeChange: import_prop_types.default.func,
|
|
237
|
-
disabledTimes: import_prop_types.default.object
|
|
238
|
-
};
|
|
239
|
-
var TimePickerMenu_default = TimePickerMenu;
|
|
240
|
-
module.exports = __toCommonJS(TimePickerMenu_exports);
|
|
241
|
-
//# sourceMappingURL=TimePickerMenu.js.map
|
|
310
|
+
|
|
311
|
+
exports.TimePickerMenu = TimePickerMenu;
|
|
312
|
+
exports["default"] = TimePickerMenu;
|
package/cjs/index.js
CHANGED
|
@@ -1,40 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var src_exports = {};
|
|
29
|
-
__export(src_exports, {
|
|
30
|
-
convertTimeString: () => import_utils.convertTimeString,
|
|
31
|
-
default: () => import_DSTimePicker.default
|
|
32
|
-
});
|
|
33
|
-
var React = __toESM(require("react"));
|
|
34
|
-
__reExport(src_exports, __toESM(require("./DSTimePicker")));
|
|
35
|
-
__reExport(src_exports, __toESM(require("./TimePickerMenu")));
|
|
36
|
-
__reExport(src_exports, __toESM(require("./DSTimePickerMenu")));
|
|
37
|
-
var import_utils = __toESM(require("./utils"));
|
|
38
|
-
var import_DSTimePicker = __toESM(require("./DSTimePicker"));
|
|
39
|
-
module.exports = __toCommonJS(src_exports);
|
|
40
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var DSTimePicker = require('./DSTimePicker.js');
|
|
6
|
+
var TimePickerMenu = require('./TimePickerMenu.js');
|
|
7
|
+
var DSTimePickerMenu = require('./DSTimePickerMenu.js');
|
|
8
|
+
var utils = require('./utils.js');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
exports.DSTimePicker = DSTimePicker.DSTimePicker;
|
|
13
|
+
exports.DSTimePickerWithSchema = DSTimePicker.DSTimePickerWithSchema;
|
|
14
|
+
exports["default"] = DSTimePicker.DSTimePicker;
|
|
15
|
+
exports.TimePickerMenu = TimePickerMenu.TimePickerMenu;
|
|
16
|
+
exports.DSTimePickerMenu = DSTimePickerMenu.DSTimePickerMenu;
|
|
17
|
+
exports.convertTimeString = utils.convertTimeString;
|
|
@@ -1,57 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var moveElementOnScroll_exports = {};
|
|
29
|
-
__export(moveElementOnScroll_exports, {
|
|
30
|
-
MoveElementOnScroll: () => MoveElementOnScroll,
|
|
31
|
-
default: () => moveElementOnScroll_default
|
|
32
|
-
});
|
|
33
|
-
var React = __toESM(require("react"));
|
|
34
|
-
function MoveElementOnScroll(element, {
|
|
35
|
-
container,
|
|
36
|
-
min = 0,
|
|
37
|
-
max = element.offsetHeight,
|
|
38
|
-
speed = 1,
|
|
39
|
-
smooth = 2,
|
|
40
|
-
onUpdate = () => null,
|
|
41
|
-
onEndScroll = () => null
|
|
42
|
-
}) {
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function MoveElementOnScroll(element, _ref) {
|
|
6
|
+
let {
|
|
7
|
+
container,
|
|
8
|
+
min = 0,
|
|
9
|
+
max = element.offsetHeight,
|
|
10
|
+
speed = 1,
|
|
11
|
+
smooth = 2,
|
|
12
|
+
onUpdate = () => null,
|
|
13
|
+
onEndScroll = () => null
|
|
14
|
+
} = _ref;
|
|
43
15
|
let moving = false;
|
|
44
16
|
let pos = min;
|
|
45
|
-
let lastPos = pos;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
17
|
+
let lastPos = pos; // todo: move this to utils if we finally need it
|
|
18
|
+
|
|
19
|
+
const requestFrame = function () {
|
|
20
|
+
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (func) {
|
|
21
|
+
window.setTimeout(func, 1000 / 50);
|
|
49
22
|
};
|
|
50
23
|
}();
|
|
24
|
+
|
|
51
25
|
function update() {
|
|
52
26
|
moving = true;
|
|
53
27
|
const delta = (pos - lastPos) / smooth;
|
|
54
28
|
lastPos += delta;
|
|
29
|
+
|
|
55
30
|
if (Math.abs(delta) > 0.7) {
|
|
56
31
|
requestFrame(() => {
|
|
57
32
|
onUpdate(lastPos, delta);
|
|
@@ -62,32 +37,39 @@ function MoveElementOnScroll(element, {
|
|
|
62
37
|
moving = false;
|
|
63
38
|
}
|
|
64
39
|
}
|
|
40
|
+
|
|
65
41
|
function scrolling(e) {
|
|
66
|
-
e.preventDefault();
|
|
42
|
+
e.preventDefault(); // disable default scrolling
|
|
43
|
+
|
|
67
44
|
let delta = e.delta || e.wheelDelta;
|
|
68
|
-
|
|
45
|
+
|
|
46
|
+
if (delta === undefined) {
|
|
47
|
+
// for firefox
|
|
69
48
|
delta = -e.detail;
|
|
70
49
|
delta *= 10 * speed;
|
|
71
50
|
}
|
|
51
|
+
|
|
72
52
|
pos += -delta * speed;
|
|
73
|
-
pos = Math.max(min, Math.min(pos, max));
|
|
53
|
+
pos = Math.max(min, Math.min(pos, max)); // limit scrolling
|
|
54
|
+
|
|
74
55
|
if (!moving) {
|
|
75
56
|
update();
|
|
76
57
|
}
|
|
77
58
|
}
|
|
78
|
-
|
|
79
|
-
container.addEventListener(
|
|
59
|
+
|
|
60
|
+
container.addEventListener('mousewheel', scrolling, false);
|
|
61
|
+
container.addEventListener('DOMMouseScroll', scrolling, false);
|
|
80
62
|
return {
|
|
81
63
|
unsubscribe: () => {
|
|
82
|
-
container.removeEventListener(
|
|
83
|
-
container.removeEventListener(
|
|
64
|
+
container.removeEventListener('mousewheel', scrolling);
|
|
65
|
+
container.removeEventListener('DOMMouseScroll', scrolling);
|
|
84
66
|
},
|
|
85
|
-
updatePosition:
|
|
67
|
+
updatePosition: newPos => {
|
|
86
68
|
pos = -newPos;
|
|
87
69
|
lastPos = -pos;
|
|
88
70
|
}
|
|
89
71
|
};
|
|
90
72
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
73
|
+
|
|
74
|
+
exports.MoveElementOnScroll = MoveElementOnScroll;
|
|
75
|
+
exports["default"] = MoveElementOnScroll;
|