@instructure/ui-time-select 8.33.1 → 8.33.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/CHANGELOG.md +4 -0
- package/es/TimeSelect/TimeSelectLocator.js +3 -2
- package/es/TimeSelect/__examples__/TimeSelect.examples.js +1 -0
- package/es/TimeSelect/index.js +62 -133
- package/es/TimeSelect/props.js +1 -0
- package/es/index.js +1 -0
- package/lib/TimeSelect/TimeSelectLocator.js +1 -4
- package/lib/TimeSelect/__examples__/TimeSelect.examples.js +0 -1
- package/lib/TimeSelect/index.js +61 -149
- package/lib/TimeSelect/props.js +1 -7
- package/lib/index.js +0 -1
- package/package.json +12 -12
- package/tsconfig.build.tsbuildinfo +1 -1
package/lib/TimeSelect/index.js
CHANGED
|
@@ -1,42 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.default = exports.TimeSelect = void 0;
|
|
11
|
-
|
|
12
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
|
-
|
|
14
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
-
|
|
16
11
|
var _ApplyLocaleContext = require("@instructure/ui-i18n/lib/ApplyLocale/ApplyLocaleContext.js");
|
|
17
|
-
|
|
18
12
|
var _Locale = require("@instructure/ui-i18n/lib/Locale.js");
|
|
19
|
-
|
|
20
13
|
var _DateTime = require("@instructure/ui-i18n/lib/DateTime.js");
|
|
21
|
-
|
|
22
14
|
var _getInteraction = require("@instructure/ui-react-utils/lib/getInteraction.js");
|
|
23
|
-
|
|
24
15
|
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
|
25
|
-
|
|
26
16
|
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
|
27
|
-
|
|
28
17
|
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
29
|
-
|
|
30
18
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
31
|
-
|
|
32
19
|
var _Select = require("@instructure/ui-select/lib/Select");
|
|
33
|
-
|
|
34
20
|
var _props = require("./props");
|
|
35
|
-
|
|
36
21
|
const _excluded = ["value", "defaultValue", "placeholder", "renderLabel", "inputRef", "id", "listRef", "renderBeforeInput", "renderAfterInput", "isRequired", "isInline", "width", "format", "step", "optionsMaxWidth", "visibleOptionsCount", "messages", "placement", "constrain", "onFocus", "onShowOptions", "onHideOptions"];
|
|
37
|
-
|
|
38
22
|
var _dec, _dec2, _class, _class2;
|
|
39
|
-
|
|
40
23
|
/**
|
|
41
24
|
---
|
|
42
25
|
category: components
|
|
@@ -48,30 +31,24 @@ A component used to select a time value.
|
|
|
48
31
|
let TimeSelect = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_class2 = class TimeSelect extends _react.Component {
|
|
49
32
|
constructor(props) {
|
|
50
33
|
var _this;
|
|
51
|
-
|
|
52
34
|
super(props);
|
|
53
35
|
_this = this;
|
|
54
36
|
this.ref = null;
|
|
55
37
|
this._emptyOptionId = this.props.deterministicId('Select-EmptyOption');
|
|
56
|
-
|
|
57
38
|
this.getOption = function (field, value) {
|
|
58
39
|
let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : _this.state.options;
|
|
59
40
|
return options.find(option => option[field] === value);
|
|
60
41
|
};
|
|
61
|
-
|
|
62
42
|
this.handleRef = node => {
|
|
63
43
|
this.ref = node;
|
|
64
44
|
};
|
|
65
|
-
|
|
66
45
|
this.handleBlur = event => {
|
|
67
46
|
var _this$props$onBlur, _this$props;
|
|
68
|
-
|
|
69
47
|
this.setState({
|
|
70
48
|
highlightedOptionId: void 0
|
|
71
49
|
});
|
|
72
50
|
(_this$props$onBlur = (_this$props = this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props, event);
|
|
73
51
|
};
|
|
74
|
-
|
|
75
52
|
this.handleInputChange = event => {
|
|
76
53
|
const value = event.target.value;
|
|
77
54
|
const newOptions = this.filterOptions(value);
|
|
@@ -81,37 +58,28 @@ let TimeSelect = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2
|
|
|
81
58
|
highlightedOptionId: newOptions.length > 0 ? newOptions[0].id : void 0,
|
|
82
59
|
isShowingOptions: true
|
|
83
60
|
});
|
|
84
|
-
|
|
85
61
|
if (!this.state.isShowingOptions) {
|
|
86
62
|
var _this$props$onShowOpt, _this$props2;
|
|
87
|
-
|
|
88
63
|
(_this$props$onShowOpt = (_this$props2 = this.props).onShowOptions) === null || _this$props$onShowOpt === void 0 ? void 0 : _this$props$onShowOpt.call(_this$props2, event);
|
|
89
64
|
}
|
|
90
65
|
};
|
|
91
|
-
|
|
92
66
|
this.handleShowOptions = event => {
|
|
93
67
|
var _this$props$onShowOpt2, _this$props3;
|
|
94
|
-
|
|
95
68
|
this.setState({
|
|
96
69
|
isShowingOptions: true,
|
|
97
70
|
highlightedOptionId: this.state.selectedOptionId
|
|
98
71
|
});
|
|
99
72
|
(_this$props$onShowOpt2 = (_this$props3 = this.props).onShowOptions) === null || _this$props$onShowOpt2 === void 0 ? void 0 : _this$props$onShowOpt2.call(_this$props3, event);
|
|
100
73
|
};
|
|
101
|
-
|
|
102
74
|
this.handleHideOptions = event => {
|
|
103
75
|
var _this$props$onHideOpt, _this$props4;
|
|
104
|
-
|
|
105
76
|
const selectedOptionId = this.state.selectedOptionId;
|
|
106
77
|
const option = this.getOption('id', selectedOptionId);
|
|
107
78
|
let prevValue = '';
|
|
108
|
-
|
|
109
79
|
if (this.props.defaultValue) {
|
|
110
80
|
const date = _DateTime.DateTime.parse(this.props.defaultValue, this.locale(), this.timezone());
|
|
111
|
-
|
|
112
81
|
prevValue = this.props.format ? date.format(this.props.format) : date.toISOString();
|
|
113
82
|
}
|
|
114
|
-
|
|
115
83
|
this.setState(() => ({
|
|
116
84
|
isShowingOptions: false,
|
|
117
85
|
highlightedOptionId: void 0,
|
|
@@ -121,7 +89,6 @@ let TimeSelect = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2
|
|
|
121
89
|
}));
|
|
122
90
|
(_this$props$onHideOpt = (_this$props4 = this.props).onHideOptions) === null || _this$props$onHideOpt === void 0 ? void 0 : _this$props$onHideOpt.call(_this$props4, event);
|
|
123
91
|
};
|
|
124
|
-
|
|
125
92
|
this.handleHighlightOption = (event, _ref) => {
|
|
126
93
|
let id = _ref.id;
|
|
127
94
|
if (id === this._emptyOptionId) return;
|
|
@@ -132,22 +99,17 @@ let TimeSelect = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2
|
|
|
132
99
|
inputValue: type === 'keydown' ? option : state.inputValue
|
|
133
100
|
}));
|
|
134
101
|
};
|
|
135
|
-
|
|
136
102
|
this.handleSelectOption = (event, _ref2) => {
|
|
137
103
|
var _this$props$onHideOpt2, _this$props6;
|
|
138
|
-
|
|
139
104
|
let id = _ref2.id;
|
|
140
|
-
|
|
141
105
|
if (id === this._emptyOptionId) {
|
|
142
106
|
this.setState({
|
|
143
107
|
isShowingOptions: false
|
|
144
108
|
});
|
|
145
109
|
return;
|
|
146
110
|
}
|
|
147
|
-
|
|
148
111
|
const option = this.getOption('id', id);
|
|
149
112
|
let newInputValue;
|
|
150
|
-
|
|
151
113
|
if (this.isControlled) {
|
|
152
114
|
const prev = this.getOption('id', this.state.selectedOptionId);
|
|
153
115
|
newInputValue = prev ? prev.label : '';
|
|
@@ -165,76 +127,59 @@ let TimeSelect = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2
|
|
|
165
127
|
filteredOptions: this.filterOptions('')
|
|
166
128
|
});
|
|
167
129
|
}
|
|
168
|
-
|
|
169
130
|
if (id !== this.state.selectedOptionId) {
|
|
170
131
|
var _this$props$onChange, _this$props5;
|
|
171
|
-
|
|
172
132
|
(_this$props$onChange = (_this$props5 = this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props5, event, {
|
|
173
133
|
value: option.value,
|
|
174
134
|
inputText: newInputValue
|
|
175
135
|
});
|
|
176
136
|
}
|
|
177
|
-
|
|
178
137
|
(_this$props$onHideOpt2 = (_this$props6 = this.props).onHideOptions) === null || _this$props$onHideOpt2 === void 0 ? void 0 : _this$props$onHideOpt2.call(_this$props6, event);
|
|
179
138
|
};
|
|
180
|
-
|
|
181
139
|
this.state = this.getInitialState();
|
|
182
140
|
}
|
|
183
|
-
|
|
184
141
|
componentDidMount() {
|
|
185
142
|
// we'll need to recalculate the state because the context value is
|
|
186
143
|
// set at this point (and it might change locale & timezone)
|
|
187
144
|
this.setState(this.getInitialState());
|
|
188
145
|
}
|
|
189
|
-
|
|
190
146
|
focus() {
|
|
191
147
|
var _this$ref;
|
|
192
|
-
|
|
193
148
|
(_this$ref = this.ref) === null || _this$ref === void 0 ? void 0 : _this$ref.focus();
|
|
194
149
|
}
|
|
195
|
-
|
|
196
150
|
get _select() {
|
|
197
151
|
return this.ref;
|
|
198
152
|
}
|
|
199
|
-
|
|
200
153
|
get isControlled() {
|
|
201
154
|
return typeof this.props.value !== 'undefined';
|
|
202
155
|
}
|
|
203
|
-
|
|
204
156
|
get interaction() {
|
|
205
157
|
return (0, _getInteraction.getInteraction)({
|
|
206
158
|
props: this.props
|
|
207
159
|
});
|
|
208
160
|
}
|
|
209
|
-
|
|
210
161
|
get focused() {
|
|
211
162
|
return this.ref && this.ref.focused;
|
|
212
163
|
}
|
|
213
|
-
|
|
214
164
|
get id() {
|
|
215
165
|
return this.ref && this.ref.id;
|
|
216
166
|
}
|
|
217
|
-
|
|
218
167
|
locale() {
|
|
219
168
|
if (this.props.locale) {
|
|
220
169
|
return this.props.locale;
|
|
221
170
|
} else if (this.context && this.context.locale) {
|
|
222
171
|
return this.context.locale;
|
|
223
172
|
}
|
|
224
|
-
|
|
225
173
|
return _Locale.Locale.browserLocale();
|
|
226
174
|
}
|
|
227
|
-
|
|
228
175
|
timezone() {
|
|
229
176
|
if (this.props.timezone) {
|
|
230
177
|
return this.props.timezone;
|
|
231
178
|
} else if (this.context && this.context.timezone) {
|
|
232
179
|
return this.context.timezone;
|
|
233
180
|
}
|
|
234
|
-
|
|
235
181
|
return _DateTime.DateTime.browserTimeZone();
|
|
236
182
|
}
|
|
237
|
-
|
|
238
183
|
componentDidUpdate(prevProps) {
|
|
239
184
|
if (this.props.step !== prevProps.step || this.props.format !== prevProps.format || this.props.locale !== prevProps.locale || this.props.timezone !== prevProps.timezone) {
|
|
240
185
|
// options change, reset everything
|
|
@@ -242,42 +187,36 @@ let TimeSelect = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2
|
|
|
242
187
|
// when uncontrolled, selection will be lost
|
|
243
188
|
this.setState(this.getInitialState());
|
|
244
189
|
}
|
|
245
|
-
|
|
246
190
|
if (this.props.value !== prevProps.value) {
|
|
247
|
-
const normalizedValue = this.normalizeISOTime(this.props.value);
|
|
248
|
-
|
|
191
|
+
const normalizedValue = this.normalizeISOTime(this.props.value);
|
|
192
|
+
// value changed
|
|
249
193
|
const initState = this.getInitialState();
|
|
250
|
-
this.setState(initState);
|
|
251
|
-
|
|
194
|
+
this.setState(initState);
|
|
195
|
+
// options need to be passed because state is not set immediately
|
|
252
196
|
let option = this.getOption('value', normalizedValue, initState.options);
|
|
253
|
-
|
|
254
197
|
if (typeof normalizedValue === 'undefined') {
|
|
255
198
|
// preserve current value when changing from controlled to uncontrolled
|
|
256
199
|
option = this.getOption('value', this.normalizeISOTime(prevProps.value));
|
|
257
200
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
201
|
+
const outsideVal = this.props.value ? this.props.value : '';
|
|
202
|
+
// value does not match an existing option
|
|
261
203
|
const date = _DateTime.DateTime.parse(outsideVal, this.locale(), this.timezone());
|
|
262
|
-
|
|
263
204
|
const label = this.props.format ? date.format(this.props.format) : date.toISOString();
|
|
264
205
|
this.setState({
|
|
265
206
|
inputValue: option ? option.label : label,
|
|
266
207
|
selectedOptionId: option ? option.id : void 0
|
|
267
208
|
});
|
|
268
209
|
}
|
|
269
|
-
}
|
|
270
|
-
// 2022-03-29T19:00:00.000Z refer to the same time in the same timezone.
|
|
271
|
-
|
|
210
|
+
}
|
|
272
211
|
|
|
212
|
+
// value needs to be normalized because e.g. 2022-03-29T19:00Z and
|
|
213
|
+
// 2022-03-29T19:00:00.000Z refer to the same time in the same timezone.
|
|
273
214
|
normalizeISOTime(value) {
|
|
274
215
|
if (!value) {
|
|
275
216
|
return value;
|
|
276
217
|
}
|
|
277
|
-
|
|
278
218
|
return _DateTime.DateTime.parse(value, this.locale(), this.timezone()).toISOString();
|
|
279
219
|
}
|
|
280
|
-
|
|
281
220
|
getInitialState() {
|
|
282
221
|
const initialOptions = this.generateOptions();
|
|
283
222
|
const initialSelection = this.getInitialOption(initialOptions);
|
|
@@ -290,74 +229,61 @@ let TimeSelect = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2
|
|
|
290
229
|
selectedOptionId: initialSelection ? initialSelection.id : void 0
|
|
291
230
|
};
|
|
292
231
|
}
|
|
293
|
-
|
|
294
232
|
getInitialOption(options) {
|
|
295
233
|
const _this$props7 = this.props,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
234
|
+
value = _this$props7.value,
|
|
235
|
+
defaultValue = _this$props7.defaultValue,
|
|
236
|
+
defaultToFirstOption = _this$props7.defaultToFirstOption,
|
|
237
|
+
format = _this$props7.format;
|
|
300
238
|
const initialValue = value || defaultValue;
|
|
301
|
-
|
|
302
239
|
if (typeof initialValue === 'string') {
|
|
303
240
|
// get option based on value or defaultValue, if provided
|
|
304
241
|
const option = this.getOption('value', this.normalizeISOTime(initialValue), options);
|
|
305
|
-
|
|
306
242
|
if (option) {
|
|
307
243
|
// value matches an existing option
|
|
308
244
|
return option;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
|
|
245
|
+
}
|
|
246
|
+
// value does not match an existing option
|
|
312
247
|
const date = _DateTime.DateTime.parse(initialValue, this.locale(), this.timezone());
|
|
313
|
-
|
|
314
248
|
return {
|
|
315
249
|
label: format ? date.format(format) : date.toISOString()
|
|
316
250
|
};
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
|
|
251
|
+
}
|
|
252
|
+
// otherwise, return first option, if desired
|
|
320
253
|
if (defaultToFirstOption) {
|
|
321
254
|
return options[0];
|
|
322
255
|
}
|
|
323
|
-
|
|
324
256
|
return void 0;
|
|
325
257
|
}
|
|
326
|
-
|
|
327
258
|
getFormattedId(date) {
|
|
328
259
|
// ISO8601 strings may contain a space. Remove any spaces before using the
|
|
329
260
|
// date as the id.
|
|
330
261
|
return date.toISOString().replace(/\s/g, '');
|
|
331
262
|
}
|
|
332
|
-
|
|
333
263
|
getBaseDate() {
|
|
334
264
|
let baseDate;
|
|
335
265
|
const baseValue = this.props.value || this.props.defaultValue;
|
|
336
|
-
|
|
337
266
|
if (baseValue) {
|
|
338
267
|
baseDate = _DateTime.DateTime.parse(baseValue, this.locale(), this.timezone());
|
|
339
268
|
} else {
|
|
340
269
|
baseDate = _DateTime.DateTime.now(this.locale(), this.timezone());
|
|
341
270
|
}
|
|
342
|
-
|
|
343
271
|
return baseDate.set({
|
|
344
272
|
second: 0,
|
|
345
273
|
millisecond: 0
|
|
346
274
|
}).clone();
|
|
347
275
|
}
|
|
348
|
-
|
|
349
276
|
generateOptions() {
|
|
350
277
|
const date = this.getBaseDate();
|
|
351
278
|
const options = [];
|
|
352
|
-
|
|
353
279
|
for (let hour = 0; hour < 24; hour++) {
|
|
354
280
|
for (let minute = 0; minute < 60 / this.props.step; minute++) {
|
|
355
281
|
const minutes = minute * this.props.step;
|
|
356
282
|
const newDate = date.set({
|
|
357
283
|
hour: hour,
|
|
358
284
|
minute: minutes
|
|
359
|
-
});
|
|
360
|
-
|
|
285
|
+
});
|
|
286
|
+
// store time options
|
|
361
287
|
options.push({
|
|
362
288
|
id: this.getFormattedId(newDate),
|
|
363
289
|
// iso no spaces
|
|
@@ -366,26 +292,23 @@ let TimeSelect = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2
|
|
|
366
292
|
});
|
|
367
293
|
}
|
|
368
294
|
}
|
|
369
|
-
|
|
370
295
|
return options;
|
|
371
296
|
}
|
|
372
|
-
|
|
373
297
|
filterOptions(inputValue) {
|
|
374
298
|
var _this$state;
|
|
375
|
-
|
|
376
299
|
return (_this$state = this.state) === null || _this$state === void 0 ? void 0 : _this$state.options.filter(option => option.label.toLowerCase().startsWith(inputValue.toLowerCase()));
|
|
377
300
|
}
|
|
378
|
-
|
|
379
301
|
matchValue() {
|
|
380
302
|
const _this$state2 = this.state,
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
303
|
+
inputValue = _this$state2.inputValue,
|
|
304
|
+
filteredOptions = _this$state2.filteredOptions,
|
|
305
|
+
highlightedOptionId = _this$state2.highlightedOptionId,
|
|
306
|
+
selectedOptionId = _this$state2.selectedOptionId;
|
|
385
307
|
|
|
308
|
+
// an option matching user input exists
|
|
386
309
|
if (filteredOptions.length === 1) {
|
|
387
|
-
const onlyOption = filteredOptions[0];
|
|
388
|
-
|
|
310
|
+
const onlyOption = filteredOptions[0];
|
|
311
|
+
// automatically select the matching option
|
|
389
312
|
if (onlyOption.label.toLowerCase() === inputValue.toLowerCase()) {
|
|
390
313
|
return {
|
|
391
314
|
inputValue: onlyOption.label,
|
|
@@ -393,18 +316,15 @@ let TimeSelect = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2
|
|
|
393
316
|
filteredOptions: this.filterOptions('')
|
|
394
317
|
};
|
|
395
318
|
}
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
|
|
319
|
+
}
|
|
320
|
+
// no match found, return selected option label to input
|
|
399
321
|
const selectedOption = this.getOption('id', selectedOptionId);
|
|
400
|
-
|
|
401
322
|
if (selectedOption) {
|
|
402
323
|
return {
|
|
403
324
|
inputValue: selectedOption.label
|
|
404
325
|
};
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
|
|
326
|
+
}
|
|
327
|
+
// input value is from highlighted option, not user input
|
|
408
328
|
if (highlightedOptionId) {
|
|
409
329
|
if (inputValue === this.getOption('id', highlightedOptionId).label) {
|
|
410
330
|
return {
|
|
@@ -412,32 +332,27 @@ let TimeSelect = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2
|
|
|
412
332
|
filteredOptions: this.filterOptions('')
|
|
413
333
|
};
|
|
414
334
|
}
|
|
415
|
-
}
|
|
335
|
+
}
|
|
336
|
+
// if input was completely cleared, ensure it stays clear
|
|
416
337
|
// e.g. defaultValue defined, but no selection yet made
|
|
417
|
-
|
|
418
|
-
|
|
419
338
|
if (inputValue === '') {
|
|
420
339
|
return {
|
|
421
340
|
inputValue: ''
|
|
422
341
|
};
|
|
423
342
|
}
|
|
424
|
-
|
|
425
343
|
return void 0;
|
|
426
344
|
}
|
|
427
|
-
|
|
428
345
|
renderOptions() {
|
|
429
346
|
const _this$state3 = this.state,
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
347
|
+
filteredOptions = _this$state3.filteredOptions,
|
|
348
|
+
highlightedOptionId = _this$state3.highlightedOptionId,
|
|
349
|
+
selectedOptionId = _this$state3.selectedOptionId;
|
|
434
350
|
if (filteredOptions.length < 1) {
|
|
435
351
|
return this.renderEmptyOption();
|
|
436
352
|
}
|
|
437
|
-
|
|
438
353
|
return filteredOptions.map(option => {
|
|
439
354
|
const id = option.id,
|
|
440
|
-
|
|
355
|
+
label = option.label;
|
|
441
356
|
return /*#__PURE__*/_react.default.createElement(_Select.Select.Option, {
|
|
442
357
|
id: id,
|
|
443
358
|
key: id,
|
|
@@ -446,7 +361,6 @@ let TimeSelect = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2
|
|
|
446
361
|
}, label);
|
|
447
362
|
});
|
|
448
363
|
}
|
|
449
|
-
|
|
450
364
|
renderEmptyOption() {
|
|
451
365
|
return /*#__PURE__*/_react.default.createElement(_Select.Select.Option, {
|
|
452
366
|
id: this._emptyOptionId,
|
|
@@ -454,35 +368,34 @@ let TimeSelect = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2
|
|
|
454
368
|
isSelected: false
|
|
455
369
|
}, (0, _callRenderProp.callRenderProp)(this.props.renderEmptyOption));
|
|
456
370
|
}
|
|
457
|
-
|
|
458
371
|
render() {
|
|
459
372
|
const _this$props8 = this.props,
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
373
|
+
value = _this$props8.value,
|
|
374
|
+
defaultValue = _this$props8.defaultValue,
|
|
375
|
+
placeholder = _this$props8.placeholder,
|
|
376
|
+
renderLabel = _this$props8.renderLabel,
|
|
377
|
+
inputRef = _this$props8.inputRef,
|
|
378
|
+
id = _this$props8.id,
|
|
379
|
+
listRef = _this$props8.listRef,
|
|
380
|
+
renderBeforeInput = _this$props8.renderBeforeInput,
|
|
381
|
+
renderAfterInput = _this$props8.renderAfterInput,
|
|
382
|
+
isRequired = _this$props8.isRequired,
|
|
383
|
+
isInline = _this$props8.isInline,
|
|
384
|
+
width = _this$props8.width,
|
|
385
|
+
format = _this$props8.format,
|
|
386
|
+
step = _this$props8.step,
|
|
387
|
+
optionsMaxWidth = _this$props8.optionsMaxWidth,
|
|
388
|
+
visibleOptionsCount = _this$props8.visibleOptionsCount,
|
|
389
|
+
messages = _this$props8.messages,
|
|
390
|
+
placement = _this$props8.placement,
|
|
391
|
+
constrain = _this$props8.constrain,
|
|
392
|
+
onFocus = _this$props8.onFocus,
|
|
393
|
+
onShowOptions = _this$props8.onShowOptions,
|
|
394
|
+
onHideOptions = _this$props8.onHideOptions,
|
|
395
|
+
rest = (0, _objectWithoutProperties2.default)(_this$props8, _excluded);
|
|
483
396
|
const _this$state4 = this.state,
|
|
484
|
-
|
|
485
|
-
|
|
397
|
+
inputValue = _this$state4.inputValue,
|
|
398
|
+
isShowingOptions = _this$state4.isShowingOptions;
|
|
486
399
|
return /*#__PURE__*/_react.default.createElement(_Select.Select, Object.assign({
|
|
487
400
|
renderLabel: renderLabel,
|
|
488
401
|
inputValue: inputValue,
|
|
@@ -512,7 +425,6 @@ let TimeSelect = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2
|
|
|
512
425
|
onInputChange: this.handleInputChange
|
|
513
426
|
}, (0, _passthroughProps.passthroughProps)(rest)), isShowingOptions && this.renderOptions());
|
|
514
427
|
}
|
|
515
|
-
|
|
516
428
|
}, _class2.displayName = "TimeSelect", _class2.componentId = 'TimeSelect', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
517
429
|
defaultToFirstOption: false,
|
|
518
430
|
format: 'LT',
|
package/lib/TimeSelect/props.js
CHANGED
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _controllable = require("@instructure/ui-prop-types/lib/controllable.js");
|
|
13
|
-
|
|
14
10
|
var _I18nPropTypes = require("@instructure/ui-i18n/lib/I18nPropTypes.js");
|
|
15
|
-
|
|
16
11
|
var _FormPropTypes = require("@instructure/ui-form-field/lib/FormPropTypes.js");
|
|
17
|
-
|
|
18
12
|
var _PositionPropTypes = require("@instructure/ui-position/lib/PositionPropTypes.js");
|
|
19
|
-
|
|
20
13
|
/*
|
|
21
14
|
* The MIT License (MIT)
|
|
22
15
|
*
|
|
@@ -40,6 +33,7 @@ var _PositionPropTypes = require("@instructure/ui-position/lib/PositionPropTypes
|
|
|
40
33
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
41
34
|
* SOFTWARE.
|
|
42
35
|
*/
|
|
36
|
+
|
|
43
37
|
const propTypes = {
|
|
44
38
|
renderLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
|
|
45
39
|
defaultToFirstOption: _propTypes.default.bool,
|
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-time-select",
|
|
3
|
-
"version": "8.33.
|
|
3
|
+
"version": "8.33.2",
|
|
4
4
|
"description": "A component for selecting time values.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -24,20 +24,20 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.13.10",
|
|
27
|
-
"@instructure/shared-types": "8.33.
|
|
28
|
-
"@instructure/ui-form-field": "8.33.
|
|
29
|
-
"@instructure/ui-i18n": "8.33.
|
|
30
|
-
"@instructure/ui-position": "8.33.
|
|
31
|
-
"@instructure/ui-prop-types": "8.33.
|
|
32
|
-
"@instructure/ui-react-utils": "8.33.
|
|
33
|
-
"@instructure/ui-select": "8.33.
|
|
34
|
-
"@instructure/ui-test-locator": "8.33.
|
|
35
|
-
"@instructure/ui-testable": "8.33.
|
|
27
|
+
"@instructure/shared-types": "8.33.2",
|
|
28
|
+
"@instructure/ui-form-field": "8.33.2",
|
|
29
|
+
"@instructure/ui-i18n": "8.33.2",
|
|
30
|
+
"@instructure/ui-position": "8.33.2",
|
|
31
|
+
"@instructure/ui-prop-types": "8.33.2",
|
|
32
|
+
"@instructure/ui-react-utils": "8.33.2",
|
|
33
|
+
"@instructure/ui-select": "8.33.2",
|
|
34
|
+
"@instructure/ui-test-locator": "8.33.2",
|
|
35
|
+
"@instructure/ui-testable": "8.33.2",
|
|
36
36
|
"prop-types": "^15"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@instructure/ui-babel-preset": "8.33.
|
|
40
|
-
"@instructure/ui-test-utils": "8.33.
|
|
39
|
+
"@instructure/ui-babel-preset": "8.33.2",
|
|
40
|
+
"@instructure/ui-test-utils": "8.33.2",
|
|
41
41
|
"moment-timezone": "^0.5.33"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|