@instructure/ui-time-select 8.56.0 → 8.56.2-pr-snapshot-1721749364069
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 +16 -0
- package/lib/TimeSelect/TimeSelectLocator.js +3 -3
- package/lib/TimeSelect/index.js +22 -27
- package/lib/TimeSelect/props.js +10 -10
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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.56.2-pr-snapshot-1721749364069](https://github.com/instructure/instructure-ui/compare/v8.56.1...v8.56.2-pr-snapshot-1721749364069) (2024-07-23)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-time-select
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [8.56.1](https://github.com/instructure/instructure-ui/compare/v8.56.0...v8.56.1) (2024-06-13)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @instructure/ui-time-select
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [8.56.0](https://github.com/instructure/instructure-ui/compare/v8.55.1...v8.56.0) (2024-05-06)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @instructure/ui-time-select
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.TimeSelectLocator = void 0;
|
|
7
|
-
var
|
|
8
|
-
var _SelectLocator = require("@instructure/ui-select/
|
|
7
|
+
var _uiTestLocator = require("@instructure/ui-test-locator");
|
|
8
|
+
var _SelectLocator = require("@instructure/ui-select/es/Select/SelectLocator");
|
|
9
9
|
var _index = require("./index");
|
|
10
10
|
/*
|
|
11
11
|
* The MIT License (MIT)
|
|
@@ -37,7 +37,7 @@ var _index = require("./index");
|
|
|
37
37
|
/* eslint-enable no-restricted-imports */
|
|
38
38
|
|
|
39
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
|
|
40
|
-
const TimeSelectLocator = exports.TimeSelectLocator = (0,
|
|
40
|
+
const TimeSelectLocator = exports.TimeSelectLocator = (0, _uiTestLocator.locator)(_index.TimeSelect.selector, {
|
|
41
41
|
findInput: _SelectLocator.SelectLocator.findInput,
|
|
42
42
|
// TODO these dont work because TS doesnt find its type declarations
|
|
43
43
|
findOptionsList: _SelectLocator.SelectLocator.findOptionsList
|
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, _class2;
|
|
@@ -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 = (_class2 = class TimeSelect extends _react.Component {
|
|
54
49
|
constructor(props) {
|
|
55
50
|
super(props);
|
|
56
51
|
this.ref = null;
|
|
@@ -132,7 +127,7 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
132
127
|
inputValue = _this$state.inputValue;
|
|
133
128
|
let defaultValue = '';
|
|
134
129
|
if (this.props.defaultValue) {
|
|
135
|
-
const date =
|
|
130
|
+
const date = _uiI18n.DateTime.parse(this.props.defaultValue, this.locale(), this.timezone());
|
|
136
131
|
defaultValue = this.props.format ? date.format(this.props.format) : date.toISOString();
|
|
137
132
|
}
|
|
138
133
|
const selectedOption = this.getOption('id', selectedOptionId);
|
|
@@ -215,7 +210,7 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
215
210
|
}));
|
|
216
211
|
};
|
|
217
212
|
this.parseInputText = inputValue => {
|
|
218
|
-
const input =
|
|
213
|
+
const input = _uiI18n.DateTime.parse(inputValue, this.locale(), this.timezone(), [this.props.format], true);
|
|
219
214
|
const baseDate = this.getBaseDate();
|
|
220
215
|
input.year(baseDate.year());
|
|
221
216
|
input.month(baseDate.month());
|
|
@@ -240,7 +235,7 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
240
235
|
return typeof this.props.value !== 'undefined';
|
|
241
236
|
}
|
|
242
237
|
get interaction() {
|
|
243
|
-
return (0,
|
|
238
|
+
return (0, _uiReactUtils.getInteraction)({
|
|
244
239
|
props: this.props
|
|
245
240
|
});
|
|
246
241
|
}
|
|
@@ -256,7 +251,7 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
256
251
|
} else if (this.context && this.context.locale) {
|
|
257
252
|
return this.context.locale;
|
|
258
253
|
}
|
|
259
|
-
return
|
|
254
|
+
return _uiI18n.Locale.browserLocale();
|
|
260
255
|
}
|
|
261
256
|
timezone() {
|
|
262
257
|
if (this.props.timezone) {
|
|
@@ -264,7 +259,7 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
264
259
|
} else if (this.context && this.context.timezone) {
|
|
265
260
|
return this.context.timezone;
|
|
266
261
|
}
|
|
267
|
-
return
|
|
262
|
+
return _uiI18n.DateTime.browserTimeZone();
|
|
268
263
|
}
|
|
269
264
|
componentDidUpdate(prevProps) {
|
|
270
265
|
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) {
|
|
@@ -276,7 +271,7 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
276
271
|
if (this.props.value !== prevProps.value) {
|
|
277
272
|
let newValue;
|
|
278
273
|
if (this.props.value) {
|
|
279
|
-
newValue =
|
|
274
|
+
newValue = _uiI18n.DateTime.parse(this.props.value, this.locale(), this.timezone());
|
|
280
275
|
}
|
|
281
276
|
// value changed
|
|
282
277
|
const initState = this.getInitialState();
|
|
@@ -286,14 +281,14 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
286
281
|
if (!this.isControlled) {
|
|
287
282
|
// preserve current value when changing from controlled to uncontrolled
|
|
288
283
|
if (prevProps.value) {
|
|
289
|
-
option = this.getOption('id', this.getFormattedId(
|
|
284
|
+
option = this.getOption('id', this.getFormattedId(_uiI18n.DateTime.parse(prevProps.value, this.locale(), this.timezone())));
|
|
290
285
|
}
|
|
291
286
|
} else if (newValue) {
|
|
292
287
|
option = this.getOption('id', this.getFormattedId(newValue), initState.options);
|
|
293
288
|
}
|
|
294
289
|
const outsideVal = this.props.value ? this.props.value : '';
|
|
295
290
|
// value does not match an existing option
|
|
296
|
-
const date =
|
|
291
|
+
const date = _uiI18n.DateTime.parse(outsideVal, this.locale(), this.timezone());
|
|
297
292
|
let label = '';
|
|
298
293
|
if (date.isValid()) {
|
|
299
294
|
label = this.props.format ? date.format(this.props.format) : date.toISOString();
|
|
@@ -330,7 +325,7 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
330
325
|
format = _this$props10.format;
|
|
331
326
|
const initialValue = value || defaultValue;
|
|
332
327
|
if (typeof initialValue === 'string') {
|
|
333
|
-
const date =
|
|
328
|
+
const date = _uiI18n.DateTime.parse(initialValue, this.locale(), this.timezone());
|
|
334
329
|
// get option based on value or defaultValue, if provided
|
|
335
330
|
const option = this.getOption('value', date, options);
|
|
336
331
|
if (option) {
|
|
@@ -354,9 +349,9 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
354
349
|
let baseDate;
|
|
355
350
|
const baseValue = this.props.value || this.props.defaultValue;
|
|
356
351
|
if (baseValue) {
|
|
357
|
-
baseDate =
|
|
352
|
+
baseDate = _uiI18n.DateTime.parse(baseValue, this.locale(), this.timezone());
|
|
358
353
|
} else {
|
|
359
|
-
baseDate =
|
|
354
|
+
baseDate = _uiI18n.DateTime.now(this.locale(), this.timezone());
|
|
360
355
|
}
|
|
361
356
|
return baseDate.set({
|
|
362
357
|
second: 0,
|
|
@@ -420,7 +415,7 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
420
415
|
return filteredOptions.map(option => {
|
|
421
416
|
const id = option.id,
|
|
422
417
|
label = option.label;
|
|
423
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
418
|
+
return /*#__PURE__*/_react.default.createElement(_uiSelect.Select.Option, {
|
|
424
419
|
id: id,
|
|
425
420
|
key: id,
|
|
426
421
|
isHighlighted: id === highlightedOptionId,
|
|
@@ -429,11 +424,11 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
429
424
|
});
|
|
430
425
|
}
|
|
431
426
|
renderEmptyOption() {
|
|
432
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
427
|
+
return /*#__PURE__*/_react.default.createElement(_uiSelect.Select.Option, {
|
|
433
428
|
id: this._emptyOptionId,
|
|
434
429
|
isHighlighted: false,
|
|
435
430
|
isSelected: false
|
|
436
|
-
}, (0,
|
|
431
|
+
}, (0, _uiReactUtils.callRenderProp)(this.props.renderEmptyOption));
|
|
437
432
|
}
|
|
438
433
|
render() {
|
|
439
434
|
const _this$props11 = this.props,
|
|
@@ -466,7 +461,7 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
466
461
|
const _this$state5 = this.state,
|
|
467
462
|
inputValue = _this$state5.inputValue,
|
|
468
463
|
isShowingOptions = _this$state5.isShowingOptions;
|
|
469
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
464
|
+
return /*#__PURE__*/_react.default.createElement(_uiSelect.Select, Object.assign({
|
|
470
465
|
mountNode: mountNode,
|
|
471
466
|
renderLabel: renderLabel,
|
|
472
467
|
inputValue: inputValue,
|
|
@@ -495,7 +490,7 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
495
490
|
onRequestSelectOption: this.handleSelectOption,
|
|
496
491
|
onInputChange: this.handleInputChange,
|
|
497
492
|
onKeyDown: this.onKeyDown
|
|
498
|
-
}, (0,
|
|
493
|
+
}, (0, _uiReactUtils.passthroughProps)(rest)), isShowingOptions && this.renderOptions());
|
|
499
494
|
}
|
|
500
495
|
}, _class2.displayName = "TimeSelect", _class2.componentId = 'TimeSelect', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
501
496
|
defaultToFirstOption: false,
|
|
@@ -509,5 +504,5 @@ let TimeSelect = exports.TimeSelect = (_dec = (0, _withDeterministicId.withDeter
|
|
|
509
504
|
constrain: 'window',
|
|
510
505
|
renderEmptyOption: '---',
|
|
511
506
|
allowNonStepInput: false
|
|
512
|
-
}, _class2.contextType =
|
|
507
|
+
}, _class2.contextType = _uiI18n.ApplyLocaleContext, _class2)) || _class) || _class);
|
|
513
508
|
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": "8.56.
|
|
3
|
+
"version": "8.56.2-pr-snapshot-1721749364069",
|
|
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.23.2",
|
|
27
|
-
"@instructure/shared-types": "8.56.
|
|
28
|
-
"@instructure/ui-form-field": "8.56.
|
|
29
|
-
"@instructure/ui-i18n": "8.56.
|
|
30
|
-
"@instructure/ui-position": "8.56.
|
|
31
|
-
"@instructure/ui-prop-types": "8.56.
|
|
32
|
-
"@instructure/ui-react-utils": "8.56.
|
|
33
|
-
"@instructure/ui-select": "8.56.
|
|
34
|
-
"@instructure/ui-test-locator": "8.56.
|
|
35
|
-
"@instructure/ui-testable": "8.56.
|
|
36
|
-
"@instructure/ui-utils": "8.56.
|
|
27
|
+
"@instructure/shared-types": "8.56.2-pr-snapshot-1721749364069",
|
|
28
|
+
"@instructure/ui-form-field": "8.56.2-pr-snapshot-1721749364069",
|
|
29
|
+
"@instructure/ui-i18n": "8.56.2-pr-snapshot-1721749364069",
|
|
30
|
+
"@instructure/ui-position": "8.56.2-pr-snapshot-1721749364069",
|
|
31
|
+
"@instructure/ui-prop-types": "8.56.2-pr-snapshot-1721749364069",
|
|
32
|
+
"@instructure/ui-react-utils": "8.56.2-pr-snapshot-1721749364069",
|
|
33
|
+
"@instructure/ui-select": "8.56.2-pr-snapshot-1721749364069",
|
|
34
|
+
"@instructure/ui-test-locator": "8.56.2-pr-snapshot-1721749364069",
|
|
35
|
+
"@instructure/ui-testable": "8.56.2-pr-snapshot-1721749364069",
|
|
36
|
+
"@instructure/ui-utils": "8.56.2-pr-snapshot-1721749364069",
|
|
37
37
|
"prop-types": "^15.8.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@instructure/ui-babel-preset": "8.56.
|
|
41
|
-
"@instructure/ui-test-utils": "8.56.
|
|
40
|
+
"@instructure/ui-babel-preset": "8.56.2-pr-snapshot-1721749364069",
|
|
41
|
+
"@instructure/ui-test-utils": "8.56.2-pr-snapshot-1721749364069",
|
|
42
42
|
"moment-timezone": "^0.5.43"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|