@instructure/ui-time-select 11.7.2-snapshot-48 → 11.7.2-snapshot-49

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.
@@ -0,0 +1,546 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = exports.TimeSelect = void 0;
9
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
+ var _react = require("react");
11
+ var _ApplyLocaleContext = require("@instructure/ui-i18n/lib/ApplyLocale/ApplyLocaleContext.js");
12
+ var _Locale = require("@instructure/ui-i18n/lib/Locale.js");
13
+ var _DateTime = require("@instructure/ui-i18n/lib/DateTime.js");
14
+ var _getInteraction = require("@instructure/ui-react-utils/lib/getInteraction.js");
15
+ var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
16
+ var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
17
+ var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
18
+ var _latest = require("@instructure/ui-select/latest");
19
+ var utils = _interopRequireWildcard(require("@instructure/ui-utils"));
20
+ var _props = require("./props");
21
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
22
+ const _excluded = ["value", "defaultValue", "placeholder", "renderLabel", "inputRef", "id", "listRef", "renderBeforeInput", "renderAfterInput", "isRequired", "isInline", "width", "format", "step", "optionsMaxWidth", "visibleOptionsCount", "messages", "placement", "constrain", "onFocus", "onShowOptions", "onHideOptions", "onInputChange", "onKeyDown", "mountNode"];
23
+ var _dec, _class, _TimeSelect;
24
+ /*
25
+ * The MIT License (MIT)
26
+ *
27
+ * Copyright (c) 2015 - present Instructure, Inc.
28
+ *
29
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
30
+ * of this software and associated documentation files (the "Software"), to deal
31
+ * in the Software without restriction, including without limitation the rights
32
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
33
+ * copies of the Software, and to permit persons to whom the Software is
34
+ * furnished to do so, subject to the following conditions:
35
+ *
36
+ * The above copyright notice and this permission notice shall be included in all
37
+ * copies or substantial portions of the Software.
38
+ *
39
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
40
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
41
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
42
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
43
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
44
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
45
+ * SOFTWARE.
46
+ */
47
+ /**
48
+ ---
49
+ category: components
50
+ ---
51
+
52
+ A component used to select a time value.
53
+ **/
54
+ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec(_class = (_TimeSelect = class TimeSelect extends _react.Component {
55
+ constructor(props) {
56
+ super(props);
57
+ this.ref = null;
58
+ this._emptyOptionId = this.props.deterministicId('Select-EmptyOption');
59
+ this.getOption = (field, value, options = this.state.options) => {
60
+ return options.find(option => option[field] === value);
61
+ };
62
+ this.handleRef = node => {
63
+ this.ref = node;
64
+ };
65
+ this.handleBlur = event => {
66
+ var _this$props$onBlur, _this$props;
67
+ (_this$props$onBlur = (_this$props = this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props, event);
68
+ };
69
+ this.handleInputChange = event => {
70
+ var _this$props$onInputCh, _this$props3;
71
+ const value = event.target.value;
72
+ const newOptions = this.filterOptions(value);
73
+ if ((newOptions === null || newOptions === void 0 ? void 0 : newOptions.length) == 1) {
74
+ // if there is only 1 option, it will be automatically selected except
75
+ // if in controlled mode (it would commit this change)
76
+ if (!this.isControlled) {
77
+ this.setState({
78
+ selectedOptionId: newOptions[0].id
79
+ });
80
+ }
81
+ this.setState({
82
+ fireChangeOnBlur: newOptions[0]
83
+ });
84
+ } else {
85
+ this.setState({
86
+ fireChangeOnBlur: void 0,
87
+ isInputCleared: this.props.allowClearingSelection && value === ''
88
+ });
89
+ }
90
+ this.setState({
91
+ inputValue: value,
92
+ filteredOptions: newOptions,
93
+ highlightedOptionId: newOptions.length > 0 ? newOptions[0].id : void 0,
94
+ isShowingOptions: true
95
+ });
96
+ if (!this.state.isShowingOptions) {
97
+ var _this$props$onShowOpt, _this$props2;
98
+ (_this$props$onShowOpt = (_this$props2 = this.props).onShowOptions) === null || _this$props$onShowOpt === void 0 ? void 0 : _this$props$onShowOpt.call(_this$props2, event);
99
+ }
100
+ const inputAsDate = this.parseInputText(value);
101
+ (_this$props$onInputCh = (_this$props3 = this.props).onInputChange) === null || _this$props$onInputCh === void 0 ? void 0 : _this$props$onInputCh.call(_this$props3, event, value, inputAsDate.isValid() ? inputAsDate.toISOString() : void 0);
102
+ };
103
+ this.onKeyDown = event => {
104
+ var _this$props$onKeyDown, _this$props4;
105
+ const input = this.parseInputText(this.state.inputValue);
106
+ if (event.key === 'Enter' && this.props.allowNonStepInput && input.isValid()) {
107
+ this.setState(() => ({
108
+ isShowingOptions: false,
109
+ highlightedOptionId: void 0
110
+ }));
111
+ // others are set in handleBlurOrEsc
112
+ }
113
+ (_this$props$onKeyDown = (_this$props4 = this.props).onKeyDown) === null || _this$props$onKeyDown === void 0 ? void 0 : _this$props$onKeyDown.call(_this$props4, event);
114
+ };
115
+ this.handleShowOptions = event => {
116
+ var _this$props$onShowOpt2, _this$props5;
117
+ this.setState({
118
+ isShowingOptions: true,
119
+ highlightedOptionId: this.state.selectedOptionId
120
+ });
121
+ (_this$props$onShowOpt2 = (_this$props5 = this.props).onShowOptions) === null || _this$props$onShowOpt2 === void 0 ? void 0 : _this$props$onShowOpt2.call(_this$props5, event);
122
+ if (event.type.startsWith('key')) {
123
+ const keyboardEvent = event;
124
+ const children = this.state.filteredOptions;
125
+ if (!this.state.inputValue && children.length > 0 && !this.props.allowClearingSelection) {
126
+ const optionId = keyboardEvent.key === 'ArrowDown' ? children[0].id : keyboardEvent.key === 'ArrowUp' ? children[children.length - 1].id : void 0;
127
+ optionId && this.setState({
128
+ highlightedOptionId: optionId
129
+ });
130
+ }
131
+ }
132
+ };
133
+ // Called when the input is blurred (=when clicking outside, tabbing away),
134
+ // when pressing ESC. NOT called when an item is selected via Enter/click,
135
+ // (but in this case it will be called later when the input is blurred.)
136
+ this.handleBlurOrEsc = event => {
137
+ var _this$props$onHideOpt, _this$props8;
138
+ const _this$state = this.state,
139
+ selectedOptionId = _this$state.selectedOptionId,
140
+ inputValue = _this$state.inputValue,
141
+ isInputCleared = _this$state.isInputCleared;
142
+ let defaultValue = '';
143
+ if (this.props.defaultValue) {
144
+ const date = _DateTime.DateTime.parse(this.props.defaultValue, this.locale(), this.timezone());
145
+ defaultValue = this.props.format ? date.format(this.props.format) : date.toISOString();
146
+ }
147
+ const selectedOption = this.getOption('id', selectedOptionId);
148
+ let newInputValue = defaultValue;
149
+ // if input was completely cleared, ensure it stays clear
150
+ // e.g. defaultValue defined, but no selection yet made
151
+ if (inputValue === '' && this.props.allowClearingSelection) {
152
+ newInputValue = '';
153
+ } else if (selectedOption) {
154
+ // If there is a selected option use its value in the input field.
155
+ newInputValue = selectedOption.label;
156
+ } else if (this.props.value) {
157
+ // If controlled and input is cleared and blurred after the first render, it should revert to value
158
+ const date = _DateTime.DateTime.parse(this.props.value, this.locale(), this.timezone());
159
+ newInputValue = this.props.format ? date.format(this.props.format) : date.toISOString();
160
+ }
161
+ this.setState(() => ({
162
+ isShowingOptions: false,
163
+ highlightedOptionId: void 0,
164
+ inputValue: newInputValue,
165
+ filteredOptions: this.filterOptions('')
166
+ }));
167
+ if (this.state.fireChangeOnBlur && event.key !== 'Escape') {
168
+ var _this$props$onChange, _this$props6;
169
+ this.setState(() => ({
170
+ fireChangeOnBlur: void 0
171
+ }));
172
+ (_this$props$onChange = (_this$props6 = this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props6, event, {
173
+ value: this.state.fireChangeOnBlur.value.toISOString(),
174
+ inputText: this.state.fireChangeOnBlur.label
175
+ });
176
+ } else if (isInputCleared && event.key !== 'Escape' && this.props.allowClearingSelection) {
177
+ var _this$props$onChange2, _this$props7;
178
+ this.setState(() => ({
179
+ isInputCleared: false
180
+ }));
181
+ (_this$props$onChange2 = (_this$props7 = this.props).onChange) === null || _this$props$onChange2 === void 0 ? void 0 : _this$props$onChange2.call(_this$props7, event, {
182
+ value: '',
183
+ inputText: ''
184
+ });
185
+ }
186
+ // TODO only fire this if handleSelectOption was not called before.
187
+ (_this$props$onHideOpt = (_this$props8 = this.props).onHideOptions) === null || _this$props$onHideOpt === void 0 ? void 0 : _this$props$onHideOpt.call(_this$props8, event);
188
+ };
189
+ // Called when an option is selected via mouse click or Enter.
190
+ this.handleSelectOption = (event, data) => {
191
+ var _this$props$onHideOpt2, _this$props0;
192
+ if (data.id === this._emptyOptionId) {
193
+ this.setState({
194
+ isShowingOptions: false
195
+ });
196
+ return;
197
+ }
198
+ const selectedOption = this.getOption('id', data.id);
199
+ let newInputValue;
200
+ const currentSelectedOptionId = this.state.selectedOptionId;
201
+
202
+ // Focus needs to be reapplied to input
203
+ // after selecting an item to make sure VoiceOver behaves correctly on iOS
204
+ if (utils.isAndroidOrIOS()) {
205
+ this.blur();
206
+ this.focus();
207
+ }
208
+ if (this.isControlled) {
209
+ // in controlled mode we leave to the user to set the value of the
210
+ // component e.g. in the onChange event handler.
211
+ // This is accomplished by not setting a selectedOptionId
212
+ const prev = this.getOption('id', this.state.selectedOptionId);
213
+ newInputValue = prev ? prev.label : '';
214
+ this.setState({
215
+ isShowingOptions: false
216
+ });
217
+ } else {
218
+ newInputValue = selectedOption.label;
219
+ this.setState({
220
+ isShowingOptions: false,
221
+ selectedOptionId: data.id,
222
+ inputValue: newInputValue
223
+ });
224
+ }
225
+ if (data.id !== currentSelectedOptionId) {
226
+ var _this$props$onChange3, _this$props9;
227
+ (_this$props$onChange3 = (_this$props9 = this.props).onChange) === null || _this$props$onChange3 === void 0 ? void 0 : _this$props$onChange3.call(_this$props9, event, {
228
+ value: selectedOption.value.toISOString(),
229
+ inputText: newInputValue
230
+ });
231
+ }
232
+ (_this$props$onHideOpt2 = (_this$props0 = this.props).onHideOptions) === null || _this$props$onHideOpt2 === void 0 ? void 0 : _this$props$onHideOpt2.call(_this$props0, event);
233
+ };
234
+ this.handleHighlightOption = (_event, data) => {
235
+ if (data.id === this._emptyOptionId) return;
236
+ this.setState(state => ({
237
+ highlightedOptionId: data.id,
238
+ inputValue: state.inputValue
239
+ }));
240
+ };
241
+ this.parseInputText = inputValue => {
242
+ const input = _DateTime.DateTime.parse(inputValue, this.locale(), this.timezone(), [this.props.format], true);
243
+ const baseDate = this.getBaseDate();
244
+ input.year(baseDate.year());
245
+ input.month(baseDate.month());
246
+ input.date(baseDate.date());
247
+ return input;
248
+ };
249
+ this.state = this.getInitialState();
250
+ }
251
+ componentDidMount() {
252
+ // we'll need to recalculate the state because the context value is
253
+ // set at this point (and it might change locale & timezone)
254
+ this.setState(this.getInitialState());
255
+ }
256
+ focus() {
257
+ var _this$ref;
258
+ (_this$ref = this.ref) === null || _this$ref === void 0 ? void 0 : _this$ref.focus();
259
+ }
260
+ blur() {
261
+ this.ref && this.ref.blur();
262
+ }
263
+ get _select() {
264
+ return this.ref;
265
+ }
266
+ get isControlled() {
267
+ return typeof this.props.value !== 'undefined';
268
+ }
269
+ get interaction() {
270
+ return (0, _getInteraction.getInteraction)({
271
+ props: this.props
272
+ });
273
+ }
274
+ get focused() {
275
+ return this.ref && this.ref.focused;
276
+ }
277
+ get id() {
278
+ return this.ref && this.ref.id;
279
+ }
280
+ locale() {
281
+ if (this.props.locale) {
282
+ return this.props.locale;
283
+ } else if (this.context && this.context.locale) {
284
+ return this.context.locale;
285
+ }
286
+ return _Locale.Locale.browserLocale();
287
+ }
288
+ timezone() {
289
+ if (this.props.timezone) {
290
+ return this.props.timezone;
291
+ } else if (this.context && this.context.timezone) {
292
+ return this.context.timezone;
293
+ }
294
+ return _DateTime.DateTime.browserTimeZone();
295
+ }
296
+ componentDidUpdate(prevProps) {
297
+ if (this.props.step !== prevProps.step || this.props.format !== prevProps.format || this.props.locale !== prevProps.locale || this.props.timezone !== prevProps.timezone || this.props.allowNonStepInput !== prevProps.allowNonStepInput) {
298
+ // options change, reset everything
299
+ // when controlled, selection will be preserved
300
+ // when uncontrolled, selection will be lost
301
+ this.setState(this.getInitialState());
302
+ }
303
+ if (this.props.value !== prevProps.value) {
304
+ let newValue;
305
+ if (this.props.value) {
306
+ newValue = _DateTime.DateTime.parse(this.props.value, this.locale(), this.timezone());
307
+ }
308
+ // value changed
309
+ const initState = this.getInitialState();
310
+ this.setState(initState);
311
+ // options need to be passed because state is not set immediately
312
+ let option;
313
+ if (!this.isControlled) {
314
+ // preserve current value when changing from controlled to uncontrolled
315
+ if (prevProps.value) {
316
+ option = this.getOption('id', this.getFormattedId(_DateTime.DateTime.parse(prevProps.value, this.locale(), this.timezone())));
317
+ }
318
+ } else if (newValue) {
319
+ option = this.getOption('id', this.getFormattedId(newValue), initState.options);
320
+ }
321
+ const outsideVal = this.props.value ? this.props.value : '';
322
+ // value does not match an existing option
323
+ const date = _DateTime.DateTime.parse(outsideVal, this.locale(), this.timezone());
324
+ let label = '';
325
+ if (date.isValid()) {
326
+ label = this.props.format ? date.format(this.props.format) : date.toISOString();
327
+ }
328
+ this.setState({
329
+ inputValue: option ? option.label : label,
330
+ selectedOptionId: option ? option.id : void 0
331
+ });
332
+ }
333
+ }
334
+ getFormattedId(date) {
335
+ // ISO8601 strings may contain a space. Remove any spaces before using the
336
+ // date as the id.
337
+ return date.toISOString().replace(/\s/g, '');
338
+ }
339
+ getInitialState() {
340
+ const initialOptions = this.generateOptions();
341
+ const initialSelection = this.getInitialOption(initialOptions);
342
+ return {
343
+ inputValue: initialSelection ? initialSelection.label : '',
344
+ options: initialOptions,
345
+ // 288 = 5 min step
346
+ filteredOptions: initialOptions.length > 288 ? initialOptions.filter(opt => opt.value.minute() % this.props.step === 0) : initialOptions,
347
+ isShowingOptions: false,
348
+ highlightedOptionId: initialSelection ? initialSelection.id : void 0,
349
+ selectedOptionId: initialSelection ? initialSelection.id : void 0,
350
+ isInputCleared: false
351
+ };
352
+ }
353
+ getInitialOption(options) {
354
+ const _this$props1 = this.props,
355
+ value = _this$props1.value,
356
+ defaultValue = _this$props1.defaultValue,
357
+ defaultToFirstOption = _this$props1.defaultToFirstOption,
358
+ format = _this$props1.format;
359
+ const initialValue = value || defaultValue;
360
+ if (typeof initialValue === 'string') {
361
+ const date = _DateTime.DateTime.parse(initialValue, this.locale(), this.timezone());
362
+ // get option based on value or defaultValue, if provided
363
+ const option = this.getOption('value', date, options);
364
+ if (option) {
365
+ // value matches an existing option
366
+ return option;
367
+ }
368
+ // value does not match an existing option
369
+ return {
370
+ id: this.getFormattedId(date),
371
+ label: format ? date.format(format) : date.toISOString(),
372
+ value: date
373
+ };
374
+ }
375
+ // otherwise, return first option, if desired
376
+ if (defaultToFirstOption) {
377
+ return options[0];
378
+ }
379
+ return void 0;
380
+ }
381
+ getBaseDate() {
382
+ let baseDate;
383
+ const baseValue = this.props.value || this.props.defaultValue;
384
+ if (baseValue) {
385
+ baseDate = _DateTime.DateTime.parse(baseValue, this.locale(), this.timezone());
386
+ } else {
387
+ baseDate = _DateTime.DateTime.now(this.locale(), this.timezone());
388
+ }
389
+ return baseDate.set({
390
+ second: 0,
391
+ millisecond: 0
392
+ }).clone();
393
+ }
394
+ generateOptions() {
395
+ const date = this.getBaseDate();
396
+ const options = [];
397
+ const step = this.props.step ? this.props.step : 30;
398
+ const maxMinute = this.props.allowNonStepInput ? 60 : 60 / step;
399
+ const minuteStep = this.props.allowNonStepInput ? 1 : step;
400
+ for (let hour = 0; hour < 24; hour++) {
401
+ for (let minute = 0; minute < maxMinute; minute++) {
402
+ const minutes = minute * minuteStep;
403
+ const newDate = date.set({
404
+ hour: hour,
405
+ minute: minutes
406
+ });
407
+ // store time options
408
+ options.push({
409
+ id: this.getFormattedId(newDate),
410
+ value: newDate.clone(),
411
+ label: this.props.format ? newDate.format(this.props.format) : newDate.toISOString()
412
+ });
413
+ }
414
+ }
415
+ return options;
416
+ }
417
+ filterOptions(inputValue) {
418
+ var _this$state3;
419
+ let inputNoSeconds = inputValue;
420
+ // if the input contains seconds disregard them (e.g. if format = LTS)
421
+ if (inputValue.length > 5) {
422
+ // e.g. "5:34:"
423
+ const input = this.parseInputText(inputValue);
424
+ if (input.isValid()) {
425
+ input.set({
426
+ second: 0
427
+ });
428
+ inputNoSeconds = input.format(this.props.format);
429
+ }
430
+ }
431
+ if (this.props.allowNonStepInput && inputNoSeconds.length < 3) {
432
+ var _this$state2;
433
+ // could show too many results, show only step values
434
+ return (_this$state2 = this.state) === null || _this$state2 === void 0 ? void 0 : _this$state2.options.filter(option => {
435
+ return option.label.toLowerCase().startsWith(inputNoSeconds.toLowerCase()) && option.value.minute() % this.props.step == 0;
436
+ });
437
+ }
438
+ return (_this$state3 = this.state) === null || _this$state3 === void 0 ? void 0 : _this$state3.options.filter(option => option.label.toLowerCase().startsWith(inputNoSeconds.toLowerCase()));
439
+ }
440
+ renderOptions() {
441
+ const _this$state4 = this.state,
442
+ filteredOptions = _this$state4.filteredOptions,
443
+ highlightedOptionId = _this$state4.highlightedOptionId,
444
+ selectedOptionId = _this$state4.selectedOptionId;
445
+ if (filteredOptions.length < 1) {
446
+ return this.renderEmptyOption();
447
+ }
448
+ return filteredOptions.map(option => {
449
+ const id = option.id,
450
+ label = option.label;
451
+ return (0, _jsxRuntime.jsx)(_latest.Select.Option, {
452
+ id: id,
453
+ isHighlighted: id === highlightedOptionId,
454
+ isSelected: id === selectedOptionId,
455
+ children: label
456
+ }, id);
457
+ });
458
+ }
459
+ renderEmptyOption() {
460
+ return (0, _jsxRuntime.jsx)(_latest.Select.Option, {
461
+ id: this._emptyOptionId,
462
+ isHighlighted: false,
463
+ isSelected: false,
464
+ children: (0, _callRenderProp.callRenderProp)(this.props.renderEmptyOption)
465
+ });
466
+ }
467
+ render() {
468
+ const _this$props10 = this.props,
469
+ value = _this$props10.value,
470
+ defaultValue = _this$props10.defaultValue,
471
+ placeholder = _this$props10.placeholder,
472
+ renderLabel = _this$props10.renderLabel,
473
+ inputRef = _this$props10.inputRef,
474
+ id = _this$props10.id,
475
+ listRef = _this$props10.listRef,
476
+ renderBeforeInput = _this$props10.renderBeforeInput,
477
+ renderAfterInput = _this$props10.renderAfterInput,
478
+ isRequired = _this$props10.isRequired,
479
+ isInline = _this$props10.isInline,
480
+ width = _this$props10.width,
481
+ format = _this$props10.format,
482
+ step = _this$props10.step,
483
+ optionsMaxWidth = _this$props10.optionsMaxWidth,
484
+ visibleOptionsCount = _this$props10.visibleOptionsCount,
485
+ messages = _this$props10.messages,
486
+ placement = _this$props10.placement,
487
+ constrain = _this$props10.constrain,
488
+ onFocus = _this$props10.onFocus,
489
+ onShowOptions = _this$props10.onShowOptions,
490
+ onHideOptions = _this$props10.onHideOptions,
491
+ onInputChange = _this$props10.onInputChange,
492
+ onKeyDown = _this$props10.onKeyDown,
493
+ mountNode = _this$props10.mountNode,
494
+ rest = (0, _objectWithoutProperties2.default)(_this$props10, _excluded);
495
+ const _this$state5 = this.state,
496
+ inputValue = _this$state5.inputValue,
497
+ isShowingOptions = _this$state5.isShowingOptions;
498
+ return (0, _jsxRuntime.jsx)(_latest.Select, {
499
+ mountNode: mountNode,
500
+ renderLabel: renderLabel,
501
+ inputValue: inputValue,
502
+ interaction: this.interaction,
503
+ placeholder: placeholder,
504
+ id: id,
505
+ onFocus: onFocus,
506
+ onBlur: this.handleBlur,
507
+ ref: this.handleRef,
508
+ inputRef: inputRef,
509
+ listRef: listRef,
510
+ isRequired: isRequired,
511
+ isInline: isInline,
512
+ width: width,
513
+ optionsMaxWidth: optionsMaxWidth,
514
+ visibleOptionsCount: visibleOptionsCount,
515
+ messages: messages,
516
+ placement: placement,
517
+ constrain: constrain,
518
+ renderBeforeInput: renderBeforeInput,
519
+ renderAfterInput: renderAfterInput,
520
+ isShowingOptions: isShowingOptions,
521
+ onRequestShowOptions: this.handleShowOptions,
522
+ onRequestHideOptions: this.handleBlurOrEsc,
523
+ onRequestHighlightOption: this.handleHighlightOption,
524
+ onRequestSelectOption: this.handleSelectOption,
525
+ onInputChange: this.handleInputChange,
526
+ onKeyDown: this.onKeyDown,
527
+ ...(0, _passthroughProps.passthroughProps)(rest),
528
+ "data-cid": "TimeSelect",
529
+ children: isShowingOptions && this.renderOptions()
530
+ });
531
+ }
532
+ }, _TimeSelect.displayName = "TimeSelect", _TimeSelect.componentId = 'TimeSelect', _TimeSelect.allowedProps = _props.allowedProps, _TimeSelect.defaultProps = {
533
+ defaultToFirstOption: false,
534
+ format: 'LT',
535
+ // see https://momentjs.com/docs/#/displaying/
536
+ step: 30,
537
+ isRequired: false,
538
+ isInline: false,
539
+ visibleOptionsCount: 8,
540
+ placement: 'bottom stretch',
541
+ constrain: 'window',
542
+ renderEmptyOption: '---',
543
+ allowNonStepInput: false,
544
+ allowClearingSelection: false
545
+ }, _TimeSelect.contextType = _ApplyLocaleContext.ApplyLocaleContext, _TimeSelect)) || _class);
546
+ var _default = exports.default = TimeSelect;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.allowedProps = void 0;
7
+ /*
8
+ * The MIT License (MIT)
9
+ *
10
+ * Copyright (c) 2015 - present Instructure, Inc.
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+
31
+ const allowedProps = exports.allowedProps = ['renderLabel', 'defaultToFirstOption', 'value', 'defaultValue', 'id', 'format', 'step', 'interaction', 'placeholder', 'isRequired', 'isInline', 'width', 'optionsMaxWidth', 'mountNode', 'visibleOptionsCount', 'messages', 'placement', 'constrain', 'onChange', 'onFocus', 'onBlur', 'onShowOptions', 'onHideOptions', 'inputRef', 'listRef', 'renderEmptyOption', 'renderBeforeInput', 'renderAfterInput', 'locale', 'timezone', 'allowNonStepInput', 'onInputChange', 'allowClearingSelection'];
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "TimeSelect", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _v.TimeSelect;
10
+ }
11
+ });
12
+ var _v = require("../TimeSelect/v2");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-time-select",
3
- "version": "11.7.2-snapshot-48",
3
+ "version": "11.7.2-snapshot-49",
4
4
  "description": "A component for selecting time values.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -15,13 +15,13 @@
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
17
  "@babel/runtime": "^7.27.6",
18
- "@instructure/shared-types": "11.7.2-snapshot-48",
19
- "@instructure/ui-i18n": "11.7.2-snapshot-48",
20
- "@instructure/ui-form-field": "11.7.2-snapshot-48",
21
- "@instructure/ui-position": "11.7.2-snapshot-48",
22
- "@instructure/ui-react-utils": "11.7.2-snapshot-48",
23
- "@instructure/ui-utils": "11.7.2-snapshot-48",
24
- "@instructure/ui-select": "11.7.2-snapshot-48"
18
+ "@instructure/shared-types": "11.7.2-snapshot-49",
19
+ "@instructure/ui-react-utils": "11.7.2-snapshot-49",
20
+ "@instructure/ui-position": "11.7.2-snapshot-49",
21
+ "@instructure/ui-i18n": "11.7.2-snapshot-49",
22
+ "@instructure/ui-form-field": "11.7.2-snapshot-49",
23
+ "@instructure/ui-select": "11.7.2-snapshot-49",
24
+ "@instructure/ui-utils": "11.7.2-snapshot-49"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@testing-library/jest-dom": "^6.6.3",
@@ -29,7 +29,7 @@
29
29
  "@testing-library/user-event": "^14.6.1",
30
30
  "moment-timezone": "^0.6.0",
31
31
  "vitest": "^3.2.2",
32
- "@instructure/ui-babel-preset": "11.7.2-snapshot-48"
32
+ "@instructure/ui-babel-preset": "11.7.2-snapshot-49"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": ">=18 <=19"
@@ -59,18 +59,18 @@
59
59
  "default": "./es/exports/a.js"
60
60
  },
61
61
  "./v11_7": {
62
- "src": "./src/exports/a.ts",
63
- "types": "./types/exports/a.d.ts",
64
- "import": "./es/exports/a.js",
65
- "require": "./lib/exports/a.js",
66
- "default": "./es/exports/a.js"
62
+ "src": "./src/exports/b.ts",
63
+ "types": "./types/exports/b.d.ts",
64
+ "import": "./es/exports/b.js",
65
+ "require": "./lib/exports/b.js",
66
+ "default": "./es/exports/b.js"
67
67
  },
68
68
  "./latest": {
69
- "src": "./src/exports/a.ts",
70
- "types": "./types/exports/a.d.ts",
71
- "import": "./es/exports/a.js",
72
- "require": "./lib/exports/a.js",
73
- "default": "./es/exports/a.js"
69
+ "src": "./src/exports/b.ts",
70
+ "types": "./types/exports/b.d.ts",
71
+ "import": "./es/exports/b.js",
72
+ "require": "./lib/exports/b.js",
73
+ "default": "./es/exports/b.js"
74
74
  }
75
75
  },
76
76
  "scripts": {