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