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