@instructure/ui-select 11.7.2-snapshot-47 → 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.
Files changed (44) hide show
  1. package/CHANGELOG.md +12 -2
  2. package/es/Select/v2/Group/index.js +47 -0
  3. package/es/Select/v2/Group/props.js +26 -0
  4. package/es/Select/v2/Option/index.js +51 -0
  5. package/es/Select/v2/Option/props.js +26 -0
  6. package/es/Select/v2/index.js +704 -0
  7. package/es/Select/v2/props.js +35 -0
  8. package/es/Select/v2/styles.js +41 -0
  9. package/es/exports/b.js +26 -0
  10. package/lib/Select/v2/Group/index.js +53 -0
  11. package/lib/Select/v2/Group/props.js +31 -0
  12. package/lib/Select/v2/Option/index.js +57 -0
  13. package/lib/Select/v2/Option/props.js +31 -0
  14. package/lib/Select/v2/index.js +714 -0
  15. package/lib/Select/v2/props.js +40 -0
  16. package/lib/Select/v2/styles.js +47 -0
  17. package/lib/exports/b.js +26 -0
  18. package/package.json +29 -29
  19. package/src/Select/v2/Group/index.tsx +52 -0
  20. package/src/Select/v2/Group/props.ts +48 -0
  21. package/src/Select/v2/Option/index.tsx +56 -0
  22. package/src/Select/v2/Option/props.ts +82 -0
  23. package/src/Select/v2/README.md +1342 -0
  24. package/src/Select/v2/index.tsx +897 -0
  25. package/src/Select/v2/props.ts +333 -0
  26. package/src/Select/v2/styles.ts +48 -0
  27. package/src/exports/b.ts +31 -0
  28. package/tsconfig.build.tsbuildinfo +1 -1
  29. package/types/Select/v2/Group/index.d.ts +21 -0
  30. package/types/Select/v2/Group/index.d.ts.map +1 -0
  31. package/types/Select/v2/Group/props.d.ts +19 -0
  32. package/types/Select/v2/Group/props.d.ts.map +1 -0
  33. package/types/Select/v2/Option/index.d.ts +28 -0
  34. package/types/Select/v2/Option/index.d.ts.map +1 -0
  35. package/types/Select/v2/Option/props.d.ts +43 -0
  36. package/types/Select/v2/Option/props.d.ts.map +1 -0
  37. package/types/Select/v2/index.d.ts +138 -0
  38. package/types/Select/v2/index.d.ts.map +1 -0
  39. package/types/Select/v2/props.d.ts +206 -0
  40. package/types/Select/v2/props.d.ts.map +1 -0
  41. package/types/Select/v2/styles.d.ts +12 -0
  42. package/types/Select/v2/styles.d.ts.map +1 -0
  43. package/types/exports/b.d.ts +7 -0
  44. package/types/exports/b.d.ts.map +1 -0
@@ -0,0 +1,333 @@
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 { InputHTMLAttributes } from 'react'
26
+
27
+ import type { OtherHTMLAttributes } from '@instructure/shared-types'
28
+ import type { FormMessage } from '@instructure/ui-form-field/latest'
29
+ import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
30
+ import type { NewComponentTypes } from '@instructure/ui-themes'
31
+ import type {
32
+ PlacementPropValues,
33
+ PositionConstraint,
34
+ PositionMountNode
35
+ } from '@instructure/ui-position'
36
+ import type { WithDeterministicIdProps } from '@instructure/ui-react-utils'
37
+ import { Renderable } from '@instructure/shared-types'
38
+
39
+ type SelectOwnProps = {
40
+ /**
41
+ * The id of the text input. One is generated if not supplied.
42
+ */
43
+ id?: string
44
+
45
+ /**
46
+ * Additional helpful text to provide to screen readers about the operation
47
+ * of the component.
48
+ */
49
+ assistiveText?: string
50
+
51
+ /**
52
+ * Specifies if interaction with the input is enabled, disabled, or readonly.
53
+ * When "disabled", the input changes visibly to indicate that it cannot
54
+ * receive user interactions. When "readonly" the input still cannot receive
55
+ * user interactions but it keeps the same styles as if it were enabled.
56
+ */
57
+ interaction?: 'enabled' | 'disabled' | 'readonly'
58
+
59
+ /**
60
+ * Whether the input is rendered inline with other elements or if it
61
+ * is rendered as a block level element.
62
+ */
63
+ isInline?: boolean
64
+
65
+ /**
66
+ * The number of options that should be visible before having to scroll. Works best when the options are the same height.
67
+ */
68
+ visibleOptionsCount?: number
69
+
70
+ /**
71
+ * Whether or not the content of the selected `Select.Option`'s `renderBeforeLabel` and `renderAfterLabel` appear in the input field.
72
+ *
73
+ * If the selected `Select.Option` has both `renderBeforeLabel` and `renderAfterLabel` content, both will be displayed in the input field.
74
+ *
75
+ * One of the `Select.Option`'s `isSelected` prop should be `true` in order to display the content in the input field.
76
+ *
77
+ * `Select.Option`'s `renderBeforeLabel` and `renderAfterLabel` content will not be displayed, if `Select`'s `inputValue` is an empty value, null or undefined.
78
+ *
79
+ * If `true` and the selected `Select.Option` has a `renderAfterLabel` value, it will replace the default arrow icon.
80
+ *
81
+ * If `true` and `Select`'s `renderBeforeInput` or `renderAfterInput` prop is set, it will display the selected `Select.Option`'s `renderBeforeLabel` and `renderAfterLabel` instead of `Select`'s `renderBeforeInput` or `renderAfterInput` value.
82
+ *
83
+ * If the selected `Select.Option`'s `renderAfterLabel` value is empty, default arrow icon will be rendered.
84
+ */
85
+ isOptionContentAppliedToInput?: boolean
86
+
87
+ /**
88
+ * The max height the options list can be before having to scroll. If
89
+ * set, it will __override__ the `visibleOptionsCount` prop.
90
+ */
91
+ optionsMaxHeight?: string
92
+
93
+ /**
94
+ * The max width the options list can be before option text wraps. If not
95
+ * set, the list will only display as wide as the text input.
96
+ */
97
+ optionsMaxWidth?: string
98
+
99
+ // Passed directly to TextInput as `value`
100
+ /**
101
+ * The value to display in the text input.
102
+ */
103
+ inputValue?: string
104
+
105
+ // Passed directly to TextInput as `onChange`
106
+ /**
107
+ * Callback fired when text input value changes.
108
+ */
109
+ onInputChange?: (
110
+ event: React.ChangeEvent<HTMLInputElement>,
111
+ value: string
112
+ ) => void
113
+
114
+ /**
115
+ * A ref to the html `ul` element.
116
+ */
117
+ listRef?: (listElement: HTMLUListElement | null) => void
118
+
119
+ /**
120
+ * Enable/disable auto scroll to the highlighted option on every re-render
121
+ */
122
+ scrollToHighlightedOption?: boolean
123
+
124
+ /**
125
+ * Children of type `<Select.Option />` or `<Select.Group />`.
126
+ */
127
+ children?: React.ReactNode // TODO: ChildrenPropTypes.oneOf([Group, Option])
128
+ } & PropsFromSelectable &
129
+ PropsFromTextInput &
130
+ PropsFromPopover
131
+
132
+ // These props are directly passed to Selectable
133
+ // TODO: import these from Selectable once TS types can be imported
134
+ type PropsFromSelectable = {
135
+ /**
136
+ * Whether or not to show the options list.
137
+ */
138
+ isShowingOptions?: boolean
139
+
140
+ /**
141
+ * Callback fired requesting that the options list be shown.
142
+ */
143
+ onRequestShowOptions?: (event: React.KeyboardEvent | React.MouseEvent) => void
144
+
145
+ /**
146
+ * Callback fired requesting that the options list be hidden.
147
+ */
148
+ onRequestHideOptions?: (
149
+ event: React.KeyboardEvent | React.MouseEvent | React.FocusEvent
150
+ ) => void
151
+
152
+ /**
153
+ * Callback fired requesting a particular option be highlighted.
154
+ */
155
+ onRequestHighlightOption?: (
156
+ event: React.KeyboardEvent | React.MouseEvent,
157
+ data: { id?: string; direction?: 1 | -1 }
158
+ ) => void
159
+
160
+ /**
161
+ * Callback fired requesting a particular option be selected.
162
+ */
163
+ onRequestSelectOption?: (
164
+ event: React.KeyboardEvent | React.MouseEvent,
165
+ data: { id?: string }
166
+ ) => void
167
+ }
168
+
169
+ // These props are directly passed to TextInput
170
+ // TODO: import these from TextInput once TS types can be imported
171
+ type PropsFromTextInput = {
172
+ /**
173
+ * The form field label.
174
+ */
175
+ renderLabel: Renderable
176
+
177
+ /**
178
+ * The size of the text input.
179
+ */
180
+ size?: 'small' | 'medium' | 'large'
181
+
182
+ /**
183
+ * Html placeholder text to display when the input has no value. This should
184
+ * be hint text, not a label replacement.
185
+ */
186
+ placeholder?: string
187
+
188
+ /**
189
+ * Whether or not the text input is required.
190
+ */
191
+ isRequired?: boolean
192
+
193
+ /**
194
+ * The width of the text input.
195
+ */
196
+ width?: string
197
+
198
+ /**
199
+ * The width of the input (integer value 0 or higher), if a width is not explicitly
200
+ * provided via the `width` prop.
201
+ *
202
+ * Only applicable if `isInline={true}`.
203
+ *
204
+ * For more see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/size
205
+ */
206
+ htmlSize?: number
207
+
208
+ /**
209
+ * Displays messages and validation for the input. It should be an object
210
+ * with the following shape:
211
+ * `{
212
+ * text: React.ReactNode,
213
+ * type: One of: ['newError', 'error', 'hint', 'success', 'screenreader-only']
214
+ * }`
215
+ */
216
+ messages?: FormMessage[]
217
+
218
+ /**
219
+ * Callback fired when text input receives focus.
220
+ */
221
+ onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void
222
+
223
+ /**
224
+ * Callback fired when text input loses focus.
225
+ */
226
+ onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void
227
+
228
+ /**
229
+ * A ref to the html `input` element.
230
+ */
231
+ inputRef?: (inputElement: HTMLInputElement | null) => void
232
+
233
+ /**
234
+ * Content to display before the text input. This will commonly be an icon or
235
+ * tags to show multiple selections.
236
+ */
237
+ renderBeforeInput?: Renderable
238
+
239
+ /**
240
+ * Content to display after the text input. This content will replace the
241
+ * default arrow icons.
242
+ */
243
+ renderAfterInput?: Renderable
244
+
245
+ /**
246
+ * Prevents the default behavior of wrapping the input and rendered content
247
+ * when available space is exceeded.
248
+ */
249
+ shouldNotWrap?: boolean
250
+
251
+ /**
252
+ * In `stacked` mode the input is below the label.
253
+ *
254
+ * In `inline` mode the input is to the right/left (depending on text direction) of the label,
255
+ * and the layout will look like `stacked` for small screens.
256
+ */
257
+ layout?: 'stacked' | 'inline'
258
+ }
259
+
260
+ // These props are directly passed to Popover
261
+ // TODO: import these from Popover once TS types can be imported
262
+ type PropsFromPopover = {
263
+ /**
264
+ * The placement of the options list.
265
+ */
266
+ placement?: PlacementPropValues
267
+
268
+ /**
269
+ * The parent in which to constrain the placement.
270
+ */
271
+ constrain?: PositionConstraint
272
+
273
+ /**
274
+ * An element or a function returning an element to use mount the options
275
+ * list to in the DOM (defaults to `document.body`)
276
+ */
277
+ mountNode?: PositionMountNode
278
+ }
279
+
280
+ type PropKeys = keyof SelectOwnProps
281
+
282
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
283
+
284
+ type SelectProps = SelectOwnProps &
285
+ WithStyleProps<NewComponentTypes['Select'], SelectStyle> &
286
+ OtherHTMLAttributes<
287
+ SelectOwnProps,
288
+ InputHTMLAttributes<SelectOwnProps & Element>
289
+ > &
290
+ WithDeterministicIdProps
291
+
292
+ type SelectStyle = ComponentStyle<'assistiveText' | 'popoverBorderWidth'>
293
+
294
+ const allowedProps: AllowedPropKeys = [
295
+ 'renderLabel',
296
+ 'inputValue',
297
+ 'isShowingOptions',
298
+ 'id',
299
+ 'size',
300
+ 'assistiveText',
301
+ 'placeholder',
302
+ 'interaction',
303
+ 'isRequired',
304
+ 'isInline',
305
+ 'width',
306
+ 'htmlSize',
307
+ 'visibleOptionsCount',
308
+ 'isOptionContentAppliedToInput',
309
+ 'optionsMaxHeight',
310
+ 'optionsMaxWidth',
311
+ 'messages',
312
+ 'placement',
313
+ 'constrain',
314
+ 'mountNode',
315
+ 'onFocus',
316
+ 'onBlur',
317
+ 'onInputChange',
318
+ 'onRequestShowOptions',
319
+ 'onRequestHideOptions',
320
+ 'onRequestHighlightOption',
321
+ 'onRequestSelectOption',
322
+ 'inputRef',
323
+ 'listRef',
324
+ 'renderBeforeInput',
325
+ 'renderAfterInput',
326
+ 'children',
327
+ 'shouldNotWrap',
328
+ 'scrollToHighlightedOption',
329
+ 'layout'
330
+ ]
331
+
332
+ export type { SelectProps, SelectOwnProps, SelectStyle }
333
+ export { allowedProps }
@@ -0,0 +1,48 @@
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 type { NewComponentTypes } from '@instructure/ui-themes'
26
+ import type { SelectProps, SelectStyle } from './props'
27
+
28
+ /**
29
+ * Generates the style object from the theme and provided additional information
30
+ * @param {Object} componentTheme The theme variable object.
31
+ * @param {Object} props the props of the component, the style is applied to
32
+ * @param {Object} state the state of the component, the style is applied to
33
+ * @return {Object} The final style object, which will be used in the component
34
+ */
35
+ const generateStyle = (
36
+ componentTheme: NewComponentTypes['Select'],
37
+ _props: SelectProps
38
+ ): SelectStyle => {
39
+ return {
40
+ assistiveText: {
41
+ label: 'select__assistiveText',
42
+ display: 'none'
43
+ },
44
+ popoverBorderWidth: componentTheme.popoverBorderWidth
45
+ }
46
+ }
47
+
48
+ export default generateStyle
@@ -0,0 +1,31 @@
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
+ export { Select } from '../Select/v2'
26
+ export { Group as SelectGroup } from '../Select/v2/Group'
27
+ export { Option as SelectOption } from '../Select/v2/Option'
28
+
29
+ export type { SelectProps, SelectOwnProps } from '../Select/v2/props'
30
+ export type { SelectGroupProps } from '../Select/v2/Group/props'
31
+ export type { SelectOptionProps } from '../Select/v2/Option/props'