@instructure/ui-simple-select 11.7.2-snapshot-48 → 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 (39) hide show
  1. package/CHANGELOG.md +12 -2
  2. package/es/SimpleSelect/v2/Group/index.js +46 -0
  3. package/es/SimpleSelect/v2/Group/props.js +26 -0
  4. package/es/SimpleSelect/v2/Option/index.js +48 -0
  5. package/es/SimpleSelect/v2/Option/props.js +26 -0
  6. package/es/SimpleSelect/v2/index.js +444 -0
  7. package/es/SimpleSelect/v2/props.js +26 -0
  8. package/es/exports/b.js +26 -0
  9. package/lib/SimpleSelect/v2/Group/index.js +52 -0
  10. package/lib/SimpleSelect/v2/Group/props.js +31 -0
  11. package/lib/SimpleSelect/v2/Option/index.js +54 -0
  12. package/lib/SimpleSelect/v2/Option/props.js +31 -0
  13. package/lib/SimpleSelect/v2/index.js +454 -0
  14. package/lib/SimpleSelect/v2/props.js +31 -0
  15. package/lib/exports/b.js +26 -0
  16. package/package.json +21 -21
  17. package/src/SimpleSelect/v2/Group/index.tsx +51 -0
  18. package/src/SimpleSelect/v2/Group/props.ts +49 -0
  19. package/src/SimpleSelect/v2/Option/index.tsx +52 -0
  20. package/src/SimpleSelect/v2/Option/props.ts +83 -0
  21. package/src/SimpleSelect/v2/README.md +157 -0
  22. package/src/SimpleSelect/v2/index.tsx +559 -0
  23. package/src/SimpleSelect/v2/props.ts +300 -0
  24. package/src/exports/b.ts +31 -0
  25. package/tsconfig.build.tsbuildinfo +1 -1
  26. package/types/SimpleSelect/v2/Group/index.d.ts +20 -0
  27. package/types/SimpleSelect/v2/Group/index.d.ts.map +1 -0
  28. package/types/SimpleSelect/v2/Group/props.d.ts +19 -0
  29. package/types/SimpleSelect/v2/Group/props.d.ts.map +1 -0
  30. package/types/SimpleSelect/v2/Option/index.d.ts +26 -0
  31. package/types/SimpleSelect/v2/Option/index.d.ts.map +1 -0
  32. package/types/SimpleSelect/v2/Option/props.d.ts +45 -0
  33. package/types/SimpleSelect/v2/Option/props.d.ts.map +1 -0
  34. package/types/SimpleSelect/v2/index.d.ts +90 -0
  35. package/types/SimpleSelect/v2/index.d.ts.map +1 -0
  36. package/types/SimpleSelect/v2/props.d.ts +180 -0
  37. package/types/SimpleSelect/v2/props.d.ts.map +1 -0
  38. package/types/exports/b.d.ts +7 -0
  39. package/types/exports/b.d.ts.map +1 -0
@@ -0,0 +1,300 @@
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 { FormMessage } from '@instructure/ui-form-field/latest'
28
+ import type {
29
+ OtherHTMLAttributes,
30
+ PickPropsWithExceptions
31
+ } from '@instructure/shared-types'
32
+ import type {
33
+ PlacementPropValues,
34
+ PositionConstraint,
35
+ PositionMountNode
36
+ } from '@instructure/ui-position'
37
+ import type { SelectOwnProps } from '@instructure/ui-select/latest'
38
+ import type { WithDeterministicIdProps } from '@instructure/ui-react-utils'
39
+ import { Renderable } from '@instructure/shared-types'
40
+
41
+ type SimpleSelectOwnProps = PropsPassedToSelect & {
42
+ /**
43
+ * The value corresponding to the value of the selected option. If defined,
44
+ * the component will act controlled and will not manage its own state.
45
+ */
46
+ value?: string | number // TODO: it was using the "controllable" util, in the TS migration mimic that behaviour
47
+
48
+ /**
49
+ * The value of the option to select by default, when uncontrolled.
50
+ */
51
+ defaultValue?: string
52
+
53
+ /**
54
+ * Callback fired when a new option is selected.
55
+ */
56
+ onChange?: (
57
+ event: React.SyntheticEvent,
58
+ data: {
59
+ value?: string | number
60
+ id?: string
61
+ }
62
+ ) => void
63
+
64
+ // passed to Select as onRequestShowOptions
65
+ /**
66
+ * Callback fired when the options list is shown.
67
+ */
68
+ onShowOptions?: (event: React.SyntheticEvent) => void
69
+
70
+ // passed to Select as onRequestHideOptions
71
+ /**
72
+ * Callback fired when the options list is hidden.
73
+ */
74
+ onHideOptions?: (event: React.SyntheticEvent) => void
75
+
76
+ /**
77
+ * Content to display in the list when no options are available.
78
+ */
79
+ renderEmptyOption?: Renderable
80
+
81
+ /**
82
+ * Children of type `<SimpleSelect.Option />` or `<SimpleSelect.Group />`.
83
+ */
84
+ children?: React.ReactNode // TODO: ChildrenPropTypes.oneOf([Group, Option])
85
+ }
86
+
87
+ type PropsPassedToSelect = {
88
+ /**
89
+ * The form field label.
90
+ */
91
+ renderLabel: Renderable
92
+
93
+ /**
94
+ * The id of the text input. One is generated if not supplied.
95
+ */
96
+ id?: string
97
+
98
+ /**
99
+ * The size of the text input.
100
+ */
101
+ size?: 'small' | 'medium' | 'large'
102
+
103
+ /**
104
+ * Additional helpful text to provide to screen readers about the operation
105
+ * of the component. Provided via aria-describedby.
106
+ */
107
+ assistiveText?: string
108
+
109
+ /**
110
+ * Html placeholder text to display when the input has no value. This should
111
+ * be hint text, not a label replacement.
112
+ */
113
+ placeholder?: string
114
+
115
+ /**
116
+ * Specifies if interaction with the input is enabled, disabled, or readonly.
117
+ * When "disabled", the input changes visibly to indicate that it cannot
118
+ * receive user interactions. When "readonly" the input still cannot receive
119
+ * user interactions but it keeps the same styles as if it were enabled.
120
+ */
121
+ interaction?: 'enabled' | 'disabled' | 'readonly'
122
+
123
+ /**
124
+ * Whether or not the text input is required.
125
+ */
126
+ isRequired?: boolean
127
+
128
+ /**
129
+ * Whether the input is rendered inline with other elements or if it
130
+ * is rendered as a block level element.
131
+ */
132
+ isInline?: boolean
133
+
134
+ /**
135
+ * The width of the text input.
136
+ */
137
+ width?: string
138
+
139
+ /**
140
+ * The number of options that should be visible before having to scroll. Works best when the options are the same height.
141
+ */
142
+ visibleOptionsCount?: number
143
+
144
+ /**
145
+ * The max height the options list can be before having to scroll. If
146
+ * set, it will __override__ the `visibleOptionsCount` prop.
147
+ */
148
+ optionsMaxHeight?: string
149
+
150
+ /**
151
+ * The max width the options list can be before option text wraps. If not
152
+ * set, the list will only display as wide as the text input.
153
+ */
154
+ optionsMaxWidth?: string
155
+
156
+ /**
157
+ * Displays messages and validation for the input. It should be an array of
158
+ * objects with the following shape:
159
+ * `{
160
+ * text: ReactNode,
161
+ * type: One of: ['newError', 'error', 'hint', 'success', 'screenreader-only']
162
+ * }`
163
+ */
164
+ messages?: FormMessage[]
165
+
166
+ /**
167
+ * The placement of the options list.
168
+ */
169
+ placement?: PlacementPropValues
170
+
171
+ /**
172
+ * The parent in which to constrain the placement.
173
+ */
174
+ constrain?: PositionConstraint
175
+
176
+ /**
177
+ * An element or a function returning an element to use mount the options
178
+ * list to in the DOM (defaults to `document.body`)
179
+ */
180
+ mountNode?: PositionMountNode
181
+
182
+ /**
183
+ * A ref to the html `input` element.
184
+ */
185
+ inputRef?: (inputElement: HTMLInputElement | null) => void
186
+
187
+ /**
188
+ * A ref to the html `ul` element.
189
+ */
190
+ listRef?: (listElement: HTMLUListElement | null) => void
191
+
192
+ /**
193
+ * Content to display before the text input. This will commonly be an icon.
194
+ */
195
+ renderBeforeInput?: Renderable
196
+
197
+ /**
198
+ * Content to display after the text input. This content will replace the
199
+ * default arrow icons.
200
+ */
201
+ renderAfterInput?: Renderable
202
+
203
+ /**
204
+ * Callback fired when text input receives focus.
205
+ */
206
+ onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void
207
+
208
+ /**
209
+ * Callback fired when text input loses focus.
210
+ */
211
+ onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void
212
+ /**
213
+ * Whether or not the content of the selected `SimpleSelect.Option`'s `renderBeforeLabel` and `renderAfterLabel` appear in the input field.
214
+ *
215
+ * If the selected `SimpleSelect.Option` has both `renderBeforeLabel` and `renderAfterLabel` content, both will be displayed in the input field.
216
+ *
217
+ * `SimpleSelect.Option`'s `renderBeforeLabel` and `renderAfterLabel` content will not be displayed, if `SimpleSelect`'s `inputValue` is an empty value, null or undefined.
218
+ *
219
+ * If `true` and the selected `SimpleSelect.Option` has a `renderAfterLabel` value, it will replace the default arrow icon.
220
+ *
221
+ * If `true` and `SimpleSelect`'s `renderBeforeInput` or `renderAfterInput` prop is set, it will display the selected `SimpleSelect.Option`'s `renderBeforeLabel` and `renderAfterLabel` instead of `SimpleSelect`'s `renderBeforeInput` or `renderAfterInput` value.
222
+ *
223
+ * If the selected `SimpleSelect.Option`'s `renderAfterLabel` value is empty, default arrow icon will be rendered.
224
+ */
225
+ isOptionContentAppliedToInput?: boolean
226
+
227
+ /**
228
+ * In `stacked` mode the input is below the label.
229
+ *
230
+ * In `inline` mode the input is to the right/left (depending on text direction) of the label,
231
+ * and the layout will look like `stacked` for small screens.
232
+ */
233
+ layout?: 'stacked' | 'inline'
234
+ }
235
+
236
+ type PropKeys = keyof SimpleSelectOwnProps
237
+
238
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
239
+
240
+ type SimpleSelectProps = PickPropsWithExceptions<
241
+ SelectOwnProps,
242
+ | keyof PropsPassedToSelect
243
+ | 'children'
244
+ | 'onRequestShowOptions'
245
+ | 'onRequestHideOptions'
246
+ | 'onRequestHighlightOption'
247
+ | 'onRequestSelectOption'
248
+ | 'inputValue'
249
+ | 'isShowingOptions'
250
+ | 'layout'
251
+ > &
252
+ SimpleSelectOwnProps &
253
+ OtherHTMLAttributes<
254
+ SimpleSelectOwnProps,
255
+ InputHTMLAttributes<SimpleSelectOwnProps & Element>
256
+ > &
257
+ WithDeterministicIdProps
258
+
259
+ type SimpleSelectState = {
260
+ inputValue?: string
261
+ isShowingOptions: boolean
262
+ highlightedOptionId?: string
263
+ selectedOptionId?: string
264
+ }
265
+
266
+ const allowedProps: AllowedPropKeys = [
267
+ 'renderLabel',
268
+ 'value',
269
+ 'defaultValue',
270
+ 'id',
271
+ 'size',
272
+ 'assistiveText',
273
+ 'placeholder',
274
+ 'interaction',
275
+ 'isRequired',
276
+ 'isInline',
277
+ 'width',
278
+ 'visibleOptionsCount',
279
+ 'optionsMaxHeight',
280
+ 'optionsMaxWidth',
281
+ 'messages',
282
+ 'placement',
283
+ 'constrain',
284
+ 'mountNode',
285
+ 'onChange',
286
+ 'onFocus',
287
+ 'onBlur',
288
+ 'onShowOptions',
289
+ 'onHideOptions',
290
+ 'inputRef',
291
+ 'listRef',
292
+ 'renderEmptyOption',
293
+ 'renderBeforeInput',
294
+ 'renderAfterInput',
295
+ 'children',
296
+ 'layout'
297
+ ]
298
+
299
+ export type { SimpleSelectProps, SimpleSelectState }
300
+ export { allowedProps }
@@ -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 { SimpleSelect } from '../SimpleSelect/v2'
26
+ export { Group as SimpleSelectGroup } from '../SimpleSelect/v2/Group'
27
+ export { Option as SimpleSelectOption } from '../SimpleSelect/v2/Option'
28
+
29
+ export type { SimpleSelectProps } from '../SimpleSelect/v2/props'
30
+ export type { SimpleSelectGroupProps } from '../SimpleSelect/v2/Group/props'
31
+ export type { SimpleSelectOptionProps } from '../SimpleSelect/v2/Option/props'