@instructure/ui-time-select 8.8.1-snapshot.3 → 8.9.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-time-select",
3
- "version": "8.8.1-snapshot.3+d5d6d4cd8",
3
+ "version": "8.9.0",
4
4
  "description": "A component for selecting time values.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "type": "commonjs",
@@ -25,22 +25,22 @@
25
25
  "license": "MIT",
26
26
  "dependencies": {
27
27
  "@babel/runtime": "^7.13.10",
28
- "@instructure/console": "8.8.1-snapshot.3+d5d6d4cd8",
29
- "@instructure/ui-form-field": "8.8.1-snapshot.3+d5d6d4cd8",
30
- "@instructure/ui-i18n": "8.8.1-snapshot.3+d5d6d4cd8",
31
- "@instructure/ui-position": "8.8.1-snapshot.3+d5d6d4cd8",
32
- "@instructure/ui-prop-types": "8.8.1-snapshot.3+d5d6d4cd8",
33
- "@instructure/ui-react-utils": "8.8.1-snapshot.3+d5d6d4cd8",
34
- "@instructure/ui-select": "8.8.1-snapshot.3+d5d6d4cd8",
35
- "@instructure/ui-test-locator": "8.8.1-snapshot.3+d5d6d4cd8",
36
- "@instructure/ui-testable": "8.8.1-snapshot.3+d5d6d4cd8",
37
- "@instructure/uid": "8.8.1-snapshot.3+d5d6d4cd8",
28
+ "@instructure/console": "8.9.0",
29
+ "@instructure/ui-form-field": "8.9.0",
30
+ "@instructure/ui-i18n": "8.9.0",
31
+ "@instructure/ui-position": "8.9.0",
32
+ "@instructure/ui-prop-types": "8.9.0",
33
+ "@instructure/ui-react-utils": "8.9.0",
34
+ "@instructure/ui-select": "8.9.0",
35
+ "@instructure/ui-test-locator": "8.9.0",
36
+ "@instructure/ui-testable": "8.9.0",
37
+ "@instructure/uid": "8.9.0",
38
38
  "dayjs": "^1.10.6",
39
39
  "prop-types": "^15"
40
40
  },
41
41
  "devDependencies": {
42
- "@instructure/ui-babel-preset": "8.8.1-snapshot.3+d5d6d4cd8",
43
- "@instructure/ui-test-utils": "8.8.1-snapshot.3+d5d6d4cd8",
42
+ "@instructure/ui-babel-preset": "8.9.0",
43
+ "@instructure/ui-test-utils": "8.9.0",
44
44
  "moment-timezone": "^0.5.33"
45
45
  },
46
46
  "peerDependencies": {
@@ -49,6 +49,5 @@
49
49
  "publishConfig": {
50
50
  "access": "public"
51
51
  },
52
- "sideEffects": false,
53
- "gitHead": "d5d6d4cd8f300e8635c69248f5d794c002269e08"
52
+ "sideEffects": false
54
53
  }
@@ -23,9 +23,8 @@
23
23
  */
24
24
 
25
25
  import React, { Component } from 'react'
26
- import PropTypes from 'prop-types'
27
26
 
28
- import { I18nPropTypes, ApplyLocaleContext, Locale } from '@instructure/ui-i18n'
27
+ import { ApplyLocaleContext, Locale } from '@instructure/ui-i18n'
29
28
 
30
29
  import dayjs from 'dayjs'
31
30
  import utc from 'dayjs/plugin/utc'
@@ -37,18 +36,17 @@ dayjs.extend(utc)
37
36
  dayjs.extend(timezone)
38
37
  dayjs.extend(localizedFormat)
39
38
 
40
- import { controllable } from '@instructure/ui-prop-types'
41
39
  import {
42
40
  getInteraction,
43
41
  passthroughProps,
44
42
  callRenderProp
45
43
  } from '@instructure/ui-react-utils'
46
- import { FormPropTypes } from '@instructure/ui-form-field'
47
- import { PositionPropTypes } from '@instructure/ui-position'
44
+
48
45
  import { testable } from '@instructure/ui-testable'
49
46
  import { Select } from '@instructure/ui-select'
50
47
  import { uid } from '@instructure/uid'
51
- import { TimeSelectProps } from './types'
48
+ import type { TimeSelectProps } from './props'
49
+ import { allowedProps, propTypes } from './props'
52
50
 
53
51
  /**
54
52
  ---
@@ -60,179 +58,16 @@ category: components
60
58
  class TimeSelect extends Component<TimeSelectProps> {
61
59
  static readonly componentId = 'TimeSelect'
62
60
 
63
- static propTypes = {
64
- /**
65
- * The form field label.
66
- */
67
- renderLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
68
- .isRequired,
69
- /**
70
- * Whether to default to the first option when `defaultValue` hasn't been specified.
71
- */
72
- defaultToFirstOption: PropTypes.bool,
73
- /**
74
- * An ISO 8601 formatted date string representing the current selected value. If defined,
75
- * the component will act controlled and will not manage its own state.
76
- */
77
- value: controllable(I18nPropTypes.iso8601, 'onChange'),
78
- /**
79
- * An ISO 8601 formatted date string to use if `value` isn't provided.
80
- */
81
- defaultValue: I18nPropTypes.iso8601,
82
- /**
83
- * The id of the text input. One is generated if not supplied.
84
- */
85
- id: PropTypes.string,
86
- /**
87
- * The format to use when displaying the possible and currently selected options.
88
- *
89
- * See [moment.js formats](https://momentjs.com/docs/#/displaying/format/) for the list of available formats.
90
- */
91
- format: PropTypes.string,
92
- /**
93
- * The number of minutes to increment by when generating the allowable options.
94
- */
95
- step: PropTypes.oneOf([5, 10, 15, 20, 30, 60]),
96
- /**
97
- * Specifies if interaction with the input is enabled, disabled, or readonly.
98
- * When "disabled", the input changes visibly to indicate that it cannot
99
- * receive user interactions. When "readonly" the input still cannot receive
100
- * user interactions but it keeps the same styles as if it were enabled.
101
- */
102
- interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
103
- /**
104
- * Html placeholder text to display when the input has no value. This should
105
- * be hint text, not a label replacement.
106
- */
107
- placeholder: PropTypes.string,
108
- /**
109
- * Whether or not the text input is required.
110
- */
111
- isRequired: PropTypes.bool,
112
- /**
113
- * Whether the input is rendered inline with other elements or if it
114
- * is rendered as a block level element.
115
- */
116
- isInline: PropTypes.bool,
117
- /**
118
- * The width of the text input.
119
- */
120
- width: PropTypes.string,
121
- /**
122
- * The max width the options list can be before option text wraps. If not
123
- * set, the list will only display as wide as the text input.
124
- */
125
- optionsMaxWidth: PropTypes.string,
126
- /**
127
- * The number of options that should be visible before having to scroll.
128
- */
129
- visibleOptionsCount: PropTypes.number,
130
- /**
131
- * Displays messages and validation for the input. It should be an object
132
- * with the following shape:
133
- * `{
134
- * text: PropTypes.string,
135
- * type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
136
- * }`
137
- */
138
- messages: PropTypes.arrayOf(FormPropTypes.message),
139
- /**
140
- * The placement of the options list.
141
- */
142
- placement: PositionPropTypes.placement,
143
- /**
144
- * The parent in which to constrain the placement.
145
- */
146
- constrain: PositionPropTypes.constrain,
147
- /**
148
- * Callback fired when a new option is selected.
149
- * @param {Object} event - the event object
150
- * @param {Object} data - additional data
151
- * @param data.value - the value of selected option
152
- */
153
- onChange: PropTypes.func,
154
- /**
155
- * Callback fired when text input receives focus.
156
- */
157
- onFocus: PropTypes.func,
158
- /**
159
- * Callback fired when text input loses focus.
160
- */
161
- onBlur: PropTypes.func,
162
- /**
163
- * Callback fired when the options list is shown.
164
- */
165
- onShowOptions: PropTypes.func,
166
- /**
167
- * Callback fired when the options list is hidden.
168
- */
169
- onHideOptions: PropTypes.func,
170
- /**
171
- * A ref to the html `input` element.
172
- */
173
- inputRef: PropTypes.func,
174
- /**
175
- * A ref to the html `ul` element.
176
- */
177
- listRef: PropTypes.func,
178
- /**
179
- * Content to display in the list when no options are available.
180
- */
181
- renderEmptyOption: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
182
- /**
183
- * Content to display before the text input. This will commonly be an icon.
184
- */
185
- renderBeforeInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
186
- /**
187
- * Content to display after the text input. This content will replace the
188
- * default arrow icons.
189
- */
190
- renderAfterInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
191
-
192
- /* eslint-disable react/require-default-props */
193
- /**
194
- * A standard language identifier.
195
- *
196
- * See [moment.js i18n](https://momentjs.com/docs/#/i18n/) for more details.
197
- *
198
- * This property can also be set via a context property and if both are set then the component property takes
199
- * precedence over the context property.
200
- *
201
- * The web browser's locale will be used if no value is set via a component property or a context
202
- * property.
203
- */
204
- locale: PropTypes.string,
205
- /**
206
- * A timezone identifier in the format: Area/Location
207
- *
208
- * See [List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) for the list
209
- * of possible options.
210
- *
211
- * This property can also be set via a context property and if both are set then the component property takes
212
- * precedence over the context property.
213
- *
214
- * The web browser's timezone will be used if no value is set via a component property or a context
215
- * property.
216
- */
217
- timezone: PropTypes.string
218
- /* eslint-enable react/require-default-props */
219
- }
61
+ static allowedProps = allowedProps
62
+ static propTypes = propTypes
220
63
 
221
64
  static defaultProps = {
222
- value: undefined,
223
- defaultValue: undefined,
224
65
  defaultToFirstOption: false,
225
- id: undefined,
226
66
  format: 'LT',
227
67
  step: 30,
228
- interaction: undefined,
229
- placeholder: undefined,
230
68
  isRequired: false,
231
69
  isInline: false,
232
- width: undefined,
233
- optionsMaxWidth: undefined,
234
70
  visibleOptionsCount: 8,
235
- messages: undefined,
236
71
  placement: 'bottom stretch',
237
72
  constrain: 'window',
238
73
  // @ts-expect-error ts-migrate(6133) FIXME: 'event' is declared but its value is never read.
@@ -0,0 +1,268 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import React from 'react'
26
+ import PropTypes from 'prop-types'
27
+
28
+ import { controllable } from '@instructure/ui-prop-types'
29
+ import { I18nPropTypes } from '@instructure/ui-i18n'
30
+ import { FormPropTypes } from '@instructure/ui-form-field'
31
+ import { PositionPropTypes } from '@instructure/ui-position'
32
+
33
+ import type { FormMessage } from '@instructure/ui-form-field'
34
+ import type { PropValidators } from '@instructure/shared-types'
35
+ import type {
36
+ PlacementPropValues,
37
+ PositionConstraint
38
+ } from '@instructure/ui-position'
39
+
40
+ type TimeSelectOwnProps = {
41
+ renderLabel: React.ReactNode | ((...args: any[]) => any)
42
+ defaultToFirstOption?: boolean
43
+ value?: any // TODO: controllable(I18nPropTypes.iso8601, 'onChange'),
44
+ defaultValue?: string
45
+ id?: string
46
+ format?: string
47
+ step?: 5 | 10 | 15 | 20 | 30 | 60
48
+ interaction?: 'enabled' | 'disabled' | 'readonly'
49
+ placeholder?: string
50
+ isRequired?: boolean
51
+ isInline?: boolean
52
+ width?: string
53
+ optionsMaxWidth?: string
54
+ visibleOptionsCount?: number
55
+ messages?: FormMessage[]
56
+ placement?: PlacementPropValues
57
+ constrain?: PositionConstraint
58
+ onChange?: (...args: any[]) => any
59
+ onFocus?: (...args: any[]) => any
60
+ onBlur?: (...args: any[]) => any
61
+ onShowOptions?: (...args: any[]) => any
62
+ onHideOptions?: (...args: any[]) => any
63
+ inputRef?: (...args: any[]) => any
64
+ listRef?: (...args: any[]) => any
65
+ renderEmptyOption?: React.ReactNode | ((...args: any[]) => any)
66
+ renderBeforeInput?: React.ReactNode | ((...args: any[]) => any)
67
+ renderAfterInput?: React.ReactNode | ((...args: any[]) => any)
68
+ locale?: string
69
+ timezone?: string
70
+ }
71
+
72
+ type PropKeys = keyof TimeSelectOwnProps
73
+
74
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
75
+
76
+ type TimeSelectProps = TimeSelectOwnProps
77
+
78
+ const propTypes: PropValidators<PropKeys> = {
79
+ /**
80
+ * The form field label.
81
+ */
82
+ renderLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
83
+ /**
84
+ * Whether to default to the first option when `defaultValue` hasn't been specified.
85
+ */
86
+ defaultToFirstOption: PropTypes.bool,
87
+ /**
88
+ * An ISO 8601 formatted date string representing the current selected value. If defined,
89
+ * the component will act controlled and will not manage its own state.
90
+ */
91
+ value: controllable(I18nPropTypes.iso8601, 'onChange'),
92
+ /**
93
+ * An ISO 8601 formatted date string to use if `value` isn't provided.
94
+ */
95
+ defaultValue: I18nPropTypes.iso8601,
96
+ /**
97
+ * The id of the text input. One is generated if not supplied.
98
+ */
99
+ id: PropTypes.string,
100
+ /**
101
+ * The format to use when displaying the possible and currently selected options.
102
+ *
103
+ * See [moment.js formats](https://momentjs.com/docs/#/displaying/format/) for the list of available formats.
104
+ */
105
+ format: PropTypes.string,
106
+ /**
107
+ * The number of minutes to increment by when generating the allowable options.
108
+ */
109
+ step: PropTypes.oneOf([5, 10, 15, 20, 30, 60]),
110
+ /**
111
+ * Specifies if interaction with the input is enabled, disabled, or readonly.
112
+ * When "disabled", the input changes visibly to indicate that it cannot
113
+ * receive user interactions. When "readonly" the input still cannot receive
114
+ * user interactions but it keeps the same styles as if it were enabled.
115
+ */
116
+ interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
117
+ /**
118
+ * Html placeholder text to display when the input has no value. This should
119
+ * be hint text, not a label replacement.
120
+ */
121
+ placeholder: PropTypes.string,
122
+ /**
123
+ * Whether or not the text input is required.
124
+ */
125
+ isRequired: PropTypes.bool,
126
+ /**
127
+ * Whether the input is rendered inline with other elements or if it
128
+ * is rendered as a block level element.
129
+ */
130
+ isInline: PropTypes.bool,
131
+ /**
132
+ * The width of the text input.
133
+ */
134
+ width: PropTypes.string,
135
+ /**
136
+ * The max width the options list can be before option text wraps. If not
137
+ * set, the list will only display as wide as the text input.
138
+ */
139
+ optionsMaxWidth: PropTypes.string,
140
+ /**
141
+ * The number of options that should be visible before having to scroll.
142
+ */
143
+ visibleOptionsCount: PropTypes.number,
144
+ /**
145
+ * Displays messages and validation for the input. It should be an object
146
+ * with the following shape:
147
+ * `{
148
+ * text: PropTypes.string,
149
+ * type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
150
+ * }`
151
+ */
152
+ messages: PropTypes.arrayOf(FormPropTypes.message),
153
+ /**
154
+ * The placement of the options list.
155
+ */
156
+ placement: PositionPropTypes.placement,
157
+ /**
158
+ * The parent in which to constrain the placement.
159
+ */
160
+ constrain: PositionPropTypes.constrain,
161
+ /**
162
+ * Callback fired when a new option is selected.
163
+ * @param {Object} event - the event object
164
+ * @param {Object} data - additional data
165
+ * @param data.value - the value of selected option
166
+ */
167
+ onChange: PropTypes.func,
168
+ /**
169
+ * Callback fired when text input receives focus.
170
+ */
171
+ onFocus: PropTypes.func,
172
+ /**
173
+ * Callback fired when text input loses focus.
174
+ */
175
+ onBlur: PropTypes.func,
176
+ /**
177
+ * Callback fired when the options list is shown.
178
+ */
179
+ onShowOptions: PropTypes.func,
180
+ /**
181
+ * Callback fired when the options list is hidden.
182
+ */
183
+ onHideOptions: PropTypes.func,
184
+ /**
185
+ * A ref to the html `input` element.
186
+ */
187
+ inputRef: PropTypes.func,
188
+ /**
189
+ * A ref to the html `ul` element.
190
+ */
191
+ listRef: PropTypes.func,
192
+ /**
193
+ * Content to display in the list when no options are available.
194
+ */
195
+ renderEmptyOption: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
196
+ /**
197
+ * Content to display before the text input. This will commonly be an icon.
198
+ */
199
+ renderBeforeInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
200
+ /**
201
+ * Content to display after the text input. This content will replace the
202
+ * default arrow icons.
203
+ */
204
+ renderAfterInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
205
+
206
+ /* eslint-disable react/require-default-props */
207
+ /**
208
+ * A standard language identifier.
209
+ *
210
+ * See [moment.js i18n](https://momentjs.com/docs/#/i18n/) for more details.
211
+ *
212
+ * This property can also be set via a context property and if both are set then the component property takes
213
+ * precedence over the context property.
214
+ *
215
+ * The web browser's locale will be used if no value is set via a component property or a context
216
+ * property.
217
+ */
218
+ locale: PropTypes.string,
219
+ /**
220
+ * A timezone identifier in the format: Area/Location
221
+ *
222
+ * See [List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) for the list
223
+ * of possible options.
224
+ *
225
+ * This property can also be set via a context property and if both are set then the component property takes
226
+ * precedence over the context property.
227
+ *
228
+ * The web browser's timezone will be used if no value is set via a component property or a context
229
+ * property.
230
+ */
231
+ timezone: PropTypes.string
232
+ /* eslint-enable react/require-default-props */
233
+ }
234
+
235
+ const allowedProps: AllowedPropKeys = [
236
+ 'renderLabel',
237
+ 'defaultToFirstOption',
238
+ 'value',
239
+ 'defaultValue',
240
+ 'id',
241
+ 'format',
242
+ 'step',
243
+ 'interaction',
244
+ 'placeholder',
245
+ 'isRequired',
246
+ 'isInline',
247
+ 'width',
248
+ 'optionsMaxWidth',
249
+ 'visibleOptionsCount',
250
+ 'messages',
251
+ 'placement',
252
+ 'constrain',
253
+ 'onChange',
254
+ 'onFocus',
255
+ 'onBlur',
256
+ 'onShowOptions',
257
+ 'onHideOptions',
258
+ 'inputRef',
259
+ 'listRef',
260
+ 'renderEmptyOption',
261
+ 'renderBeforeInput',
262
+ 'renderAfterInput',
263
+ 'locale',
264
+ 'timezone'
265
+ ]
266
+
267
+ export type { TimeSelectProps }
268
+ export { propTypes, allowedProps }