@instructure/ui-time-select 10.13.0 → 10.13.1-pr-snapshot-1741357986437
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 +8 -0
- package/lib/TimeSelect/__new-tests__/TimeSelect.test.js +4 -4
- package/lib/TimeSelect/index.js +23 -28
- package/lib/TimeSelect/props.js +10 -10
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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
|
+
## [10.13.1-pr-snapshot-1741357986437](https://github.com/instructure/instructure-ui/compare/v10.13.0...v10.13.1-pr-snapshot-1741357986437) (2025-03-07)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-time-select
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [10.13.0](https://github.com/instructure/instructure-ui/compare/v10.12.0...v10.13.0) (2025-03-06)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @instructure/ui-time-select
|
|
@@ -8,8 +8,8 @@ var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
|
8
8
|
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
|
9
9
|
require("@testing-library/jest-dom");
|
|
10
10
|
var _generateA11yTests = require("@instructure/ui-scripts/lib/test/generateA11yTests");
|
|
11
|
-
var
|
|
12
|
-
var
|
|
11
|
+
var _uiAxeCheck = require("@instructure/ui-axe-check");
|
|
12
|
+
var _uiI18n = require("@instructure/ui-i18n");
|
|
13
13
|
var _index = require("../index");
|
|
14
14
|
var _TimeSelect7 = _interopRequireDefault(require("../__examples__/TimeSelect.examples"));
|
|
15
15
|
var _TimeSelect, _TimeSelect2, _TimeSelect3, _TimeSelect4, _TimeSelect5, _TimeSelect6;
|
|
@@ -149,7 +149,7 @@ describe('<TimeSelect />', () => {
|
|
|
149
149
|
// 12-hour clock format
|
|
150
150
|
'UTC' // no time offset
|
|
151
151
|
);
|
|
152
|
-
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(
|
|
152
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_uiI18n.ApplyLocale, {
|
|
153
153
|
locale: "fr" // 24-hour clock format
|
|
154
154
|
,
|
|
155
155
|
timezone: "Africa/Nairobi" // UTC + 3
|
|
@@ -343,7 +343,7 @@ describe('<TimeSelect />', () => {
|
|
|
343
343
|
}) => {
|
|
344
344
|
const _render2 = (0, _react2.render)(content),
|
|
345
345
|
container = _render2.container;
|
|
346
|
-
const axeCheck = await (0,
|
|
346
|
+
const axeCheck = await (0, _uiAxeCheck.runAxeCheck)(container);
|
|
347
347
|
expect(axeCheck).toBe(true);
|
|
348
348
|
});
|
|
349
349
|
});
|
package/lib/TimeSelect/index.js
CHANGED
|
@@ -8,15 +8,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = exports.TimeSelect = void 0;
|
|
9
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
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 _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
19
|
-
var _Select = require("@instructure/ui-select/lib/Select");
|
|
11
|
+
var _uiI18n = require("@instructure/ui-i18n");
|
|
12
|
+
var _uiReactUtils = require("@instructure/ui-react-utils");
|
|
13
|
+
var _uiTestable = require("@instructure/ui-testable");
|
|
14
|
+
var _uiSelect = require("@instructure/ui-select");
|
|
20
15
|
var _props = require("./props");
|
|
21
16
|
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"];
|
|
22
17
|
var _dec, _dec2, _class, _TimeSelect;
|
|
@@ -50,7 +45,7 @@ category: components
|
|
|
50
45
|
|
|
51
46
|
A component used to select a time value.
|
|
52
47
|
**/
|
|
53
|
-
let TimeSelect = exports.TimeSelect = (_dec = (0,
|
|
48
|
+
let TimeSelect = exports.TimeSelect = (_dec = (0, _uiReactUtils.withDeterministicId)(), _dec2 = (0, _uiTestable.testable)(), _dec(_class = _dec2(_class = (_TimeSelect = class TimeSelect extends _react.Component {
|
|
54
49
|
constructor(props) {
|
|
55
50
|
super(props);
|
|
56
51
|
this.ref = null;
|
|
@@ -130,7 +125,7 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
130
125
|
isInputCleared = _this$state.isInputCleared;
|
|
131
126
|
let defaultValue = '';
|
|
132
127
|
if (this.props.defaultValue) {
|
|
133
|
-
const date =
|
|
128
|
+
const date = _uiI18n.DateTime.parse(this.props.defaultValue, this.locale(), this.timezone());
|
|
134
129
|
defaultValue = this.props.format ? date.format(this.props.format) : date.toISOString();
|
|
135
130
|
}
|
|
136
131
|
const selectedOption = this.getOption('id', selectedOptionId);
|
|
@@ -144,7 +139,7 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
144
139
|
newInputValue = selectedOption.label;
|
|
145
140
|
} else if (this.props.value) {
|
|
146
141
|
// If controlled and input is cleared and blurred after the first render, it should revert to value
|
|
147
|
-
const date =
|
|
142
|
+
const date = _uiI18n.DateTime.parse(this.props.value, this.locale(), this.timezone());
|
|
148
143
|
newInputValue = this.props.format ? date.format(this.props.format) : date.toISOString();
|
|
149
144
|
}
|
|
150
145
|
this.setState(() => ({
|
|
@@ -225,7 +220,7 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
225
220
|
}));
|
|
226
221
|
};
|
|
227
222
|
this.parseInputText = inputValue => {
|
|
228
|
-
const input =
|
|
223
|
+
const input = _uiI18n.DateTime.parse(inputValue, this.locale(), this.timezone(), [this.props.format], true);
|
|
229
224
|
const baseDate = this.getBaseDate();
|
|
230
225
|
input.year(baseDate.year());
|
|
231
226
|
input.month(baseDate.month());
|
|
@@ -250,7 +245,7 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
250
245
|
return typeof this.props.value !== 'undefined';
|
|
251
246
|
}
|
|
252
247
|
get interaction() {
|
|
253
|
-
return (0,
|
|
248
|
+
return (0, _uiReactUtils.getInteraction)({
|
|
254
249
|
props: this.props
|
|
255
250
|
});
|
|
256
251
|
}
|
|
@@ -266,7 +261,7 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
266
261
|
} else if (this.context && this.context.locale) {
|
|
267
262
|
return this.context.locale;
|
|
268
263
|
}
|
|
269
|
-
return
|
|
264
|
+
return _uiI18n.Locale.browserLocale();
|
|
270
265
|
}
|
|
271
266
|
timezone() {
|
|
272
267
|
if (this.props.timezone) {
|
|
@@ -274,7 +269,7 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
274
269
|
} else if (this.context && this.context.timezone) {
|
|
275
270
|
return this.context.timezone;
|
|
276
271
|
}
|
|
277
|
-
return
|
|
272
|
+
return _uiI18n.DateTime.browserTimeZone();
|
|
278
273
|
}
|
|
279
274
|
componentDidUpdate(prevProps) {
|
|
280
275
|
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) {
|
|
@@ -286,7 +281,7 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
286
281
|
if (this.props.value !== prevProps.value) {
|
|
287
282
|
let newValue;
|
|
288
283
|
if (this.props.value) {
|
|
289
|
-
newValue =
|
|
284
|
+
newValue = _uiI18n.DateTime.parse(this.props.value, this.locale(), this.timezone());
|
|
290
285
|
}
|
|
291
286
|
// value changed
|
|
292
287
|
const initState = this.getInitialState();
|
|
@@ -296,14 +291,14 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
296
291
|
if (!this.isControlled) {
|
|
297
292
|
// preserve current value when changing from controlled to uncontrolled
|
|
298
293
|
if (prevProps.value) {
|
|
299
|
-
option = this.getOption('id', this.getFormattedId(
|
|
294
|
+
option = this.getOption('id', this.getFormattedId(_uiI18n.DateTime.parse(prevProps.value, this.locale(), this.timezone())));
|
|
300
295
|
}
|
|
301
296
|
} else if (newValue) {
|
|
302
297
|
option = this.getOption('id', this.getFormattedId(newValue), initState.options);
|
|
303
298
|
}
|
|
304
299
|
const outsideVal = this.props.value ? this.props.value : '';
|
|
305
300
|
// value does not match an existing option
|
|
306
|
-
const date =
|
|
301
|
+
const date = _uiI18n.DateTime.parse(outsideVal, this.locale(), this.timezone());
|
|
307
302
|
let label = '';
|
|
308
303
|
if (date.isValid()) {
|
|
309
304
|
label = this.props.format ? date.format(this.props.format) : date.toISOString();
|
|
@@ -341,7 +336,7 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
341
336
|
format = _this$props11.format;
|
|
342
337
|
const initialValue = value || defaultValue;
|
|
343
338
|
if (typeof initialValue === 'string') {
|
|
344
|
-
const date =
|
|
339
|
+
const date = _uiI18n.DateTime.parse(initialValue, this.locale(), this.timezone());
|
|
345
340
|
// get option based on value or defaultValue, if provided
|
|
346
341
|
const option = this.getOption('value', date, options);
|
|
347
342
|
if (option) {
|
|
@@ -365,9 +360,9 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
365
360
|
let baseDate;
|
|
366
361
|
const baseValue = this.props.value || this.props.defaultValue;
|
|
367
362
|
if (baseValue) {
|
|
368
|
-
baseDate =
|
|
363
|
+
baseDate = _uiI18n.DateTime.parse(baseValue, this.locale(), this.timezone());
|
|
369
364
|
} else {
|
|
370
|
-
baseDate =
|
|
365
|
+
baseDate = _uiI18n.DateTime.now(this.locale(), this.timezone());
|
|
371
366
|
}
|
|
372
367
|
return baseDate.set({
|
|
373
368
|
second: 0,
|
|
@@ -431,7 +426,7 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
431
426
|
return filteredOptions.map(option => {
|
|
432
427
|
const id = option.id,
|
|
433
428
|
label = option.label;
|
|
434
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
429
|
+
return /*#__PURE__*/_react.default.createElement(_uiSelect.Select.Option, {
|
|
435
430
|
id: id,
|
|
436
431
|
key: id,
|
|
437
432
|
isHighlighted: id === highlightedOptionId,
|
|
@@ -440,11 +435,11 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
440
435
|
});
|
|
441
436
|
}
|
|
442
437
|
renderEmptyOption() {
|
|
443
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
438
|
+
return /*#__PURE__*/_react.default.createElement(_uiSelect.Select.Option, {
|
|
444
439
|
id: this._emptyOptionId,
|
|
445
440
|
isHighlighted: false,
|
|
446
441
|
isSelected: false
|
|
447
|
-
}, (0,
|
|
442
|
+
}, (0, _uiReactUtils.callRenderProp)(this.props.renderEmptyOption));
|
|
448
443
|
}
|
|
449
444
|
render() {
|
|
450
445
|
const _this$props12 = this.props,
|
|
@@ -477,7 +472,7 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
477
472
|
const _this$state5 = this.state,
|
|
478
473
|
inputValue = _this$state5.inputValue,
|
|
479
474
|
isShowingOptions = _this$state5.isShowingOptions;
|
|
480
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
475
|
+
return /*#__PURE__*/_react.default.createElement(_uiSelect.Select, Object.assign({
|
|
481
476
|
mountNode: mountNode,
|
|
482
477
|
renderLabel: renderLabel,
|
|
483
478
|
inputValue: inputValue,
|
|
@@ -506,7 +501,7 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
506
501
|
onRequestSelectOption: this.handleSelectOption,
|
|
507
502
|
onInputChange: this.handleInputChange,
|
|
508
503
|
onKeyDown: this.onKeyDown
|
|
509
|
-
}, (0,
|
|
504
|
+
}, (0, _uiReactUtils.passthroughProps)(rest)), isShowingOptions && this.renderOptions());
|
|
510
505
|
}
|
|
511
506
|
}, _TimeSelect.displayName = "TimeSelect", _TimeSelect.componentId = 'TimeSelect', _TimeSelect.allowedProps = _props.allowedProps, _TimeSelect.propTypes = _props.propTypes, _TimeSelect.defaultProps = {
|
|
512
507
|
defaultToFirstOption: false,
|
|
@@ -521,5 +516,5 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
521
516
|
renderEmptyOption: '---',
|
|
522
517
|
allowNonStepInput: false,
|
|
523
518
|
allowClearingSelection: false
|
|
524
|
-
}, _TimeSelect.contextType =
|
|
519
|
+
}, _TimeSelect.contextType = _uiI18n.ApplyLocaleContext, _TimeSelect)) || _class) || _class);
|
|
525
520
|
var _default = exports.default = TimeSelect;
|
package/lib/TimeSelect/props.js
CHANGED
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
9
|
+
var _uiPropTypes = require("@instructure/ui-prop-types");
|
|
10
|
+
var _uiI18n = require("@instructure/ui-i18n");
|
|
11
|
+
var _uiFormField = require("@instructure/ui-form-field");
|
|
12
|
+
var _uiPosition = require("@instructure/ui-position");
|
|
13
13
|
/*
|
|
14
14
|
* The MIT License (MIT)
|
|
15
15
|
*
|
|
@@ -37,8 +37,8 @@ var _PositionPropTypes = require("@instructure/ui-position/lib/PositionPropTypes
|
|
|
37
37
|
const propTypes = exports.propTypes = {
|
|
38
38
|
renderLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
|
|
39
39
|
defaultToFirstOption: _propTypes.default.bool,
|
|
40
|
-
value: (0,
|
|
41
|
-
defaultValue:
|
|
40
|
+
value: (0, _uiPropTypes.controllable)(_uiI18n.I18nPropTypes.iso8601, 'onChange'),
|
|
41
|
+
defaultValue: _uiI18n.I18nPropTypes.iso8601,
|
|
42
42
|
id: _propTypes.default.string,
|
|
43
43
|
format: _propTypes.default.string,
|
|
44
44
|
step: _propTypes.default.oneOf([5, 10, 15, 20, 30, 60]),
|
|
@@ -49,10 +49,10 @@ const propTypes = exports.propTypes = {
|
|
|
49
49
|
width: _propTypes.default.string,
|
|
50
50
|
optionsMaxWidth: _propTypes.default.string,
|
|
51
51
|
visibleOptionsCount: _propTypes.default.number,
|
|
52
|
-
messages: _propTypes.default.arrayOf(
|
|
53
|
-
placement:
|
|
54
|
-
constrain:
|
|
55
|
-
mountNode:
|
|
52
|
+
messages: _propTypes.default.arrayOf(_uiFormField.FormPropTypes.message),
|
|
53
|
+
placement: _uiPosition.PositionPropTypes.placement,
|
|
54
|
+
constrain: _uiPosition.PositionPropTypes.constrain,
|
|
55
|
+
mountNode: _uiPosition.PositionPropTypes.mountNode,
|
|
56
56
|
onChange: _propTypes.default.func,
|
|
57
57
|
onFocus: _propTypes.default.func,
|
|
58
58
|
onBlur: _propTypes.default.func,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-time-select",
|
|
3
|
-
"version": "10.13.
|
|
3
|
+
"version": "10.13.1-pr-snapshot-1741357986437",
|
|
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,21 +24,21 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.26.0",
|
|
27
|
-
"@instructure/shared-types": "10.13.
|
|
28
|
-
"@instructure/ui-form-field": "10.13.
|
|
29
|
-
"@instructure/ui-i18n": "10.13.
|
|
30
|
-
"@instructure/ui-position": "10.13.
|
|
31
|
-
"@instructure/ui-prop-types": "10.13.
|
|
32
|
-
"@instructure/ui-react-utils": "10.13.
|
|
33
|
-
"@instructure/ui-select": "10.13.
|
|
34
|
-
"@instructure/ui-testable": "10.13.
|
|
35
|
-
"@instructure/ui-utils": "10.13.
|
|
27
|
+
"@instructure/shared-types": "10.13.1-pr-snapshot-1741357986437",
|
|
28
|
+
"@instructure/ui-form-field": "10.13.1-pr-snapshot-1741357986437",
|
|
29
|
+
"@instructure/ui-i18n": "10.13.1-pr-snapshot-1741357986437",
|
|
30
|
+
"@instructure/ui-position": "10.13.1-pr-snapshot-1741357986437",
|
|
31
|
+
"@instructure/ui-prop-types": "10.13.1-pr-snapshot-1741357986437",
|
|
32
|
+
"@instructure/ui-react-utils": "10.13.1-pr-snapshot-1741357986437",
|
|
33
|
+
"@instructure/ui-select": "10.13.1-pr-snapshot-1741357986437",
|
|
34
|
+
"@instructure/ui-testable": "10.13.1-pr-snapshot-1741357986437",
|
|
35
|
+
"@instructure/ui-utils": "10.13.1-pr-snapshot-1741357986437",
|
|
36
36
|
"prop-types": "^15.8.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@instructure/ui-axe-check": "10.13.
|
|
40
|
-
"@instructure/ui-babel-preset": "10.13.
|
|
41
|
-
"@instructure/ui-test-utils": "10.13.
|
|
39
|
+
"@instructure/ui-axe-check": "10.13.1-pr-snapshot-1741357986437",
|
|
40
|
+
"@instructure/ui-babel-preset": "10.13.1-pr-snapshot-1741357986437",
|
|
41
|
+
"@instructure/ui-test-utils": "10.13.1-pr-snapshot-1741357986437",
|
|
42
42
|
"@testing-library/jest-dom": "^6.6.3",
|
|
43
43
|
"@testing-library/react": "^16.0.1",
|
|
44
44
|
"@testing-library/user-event": "^14.5.2",
|