@instructure/ui-simple-select 8.8.1-snapshot.8 → 8.9.1

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 (46) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/es/SimpleSelect/Group/index.js +4 -15
  3. package/{src/SimpleSelect/Group/types.ts → es/SimpleSelect/Group/props.js} +15 -3
  4. package/es/SimpleSelect/Option/index.js +4 -35
  5. package/es/SimpleSelect/Option/props.js +57 -0
  6. package/es/SimpleSelect/index.js +3 -175
  7. package/es/SimpleSelect/props.js +192 -0
  8. package/lib/SimpleSelect/Group/index.js +3 -18
  9. package/{src/SimpleSelect/Option/types.ts → lib/SimpleSelect/Group/props.js} +28 -7
  10. package/lib/SimpleSelect/Option/index.js +3 -36
  11. package/lib/SimpleSelect/Option/props.js +68 -0
  12. package/lib/SimpleSelect/index.js +3 -178
  13. package/lib/SimpleSelect/props.js +208 -0
  14. package/package.json +15 -16
  15. package/src/SimpleSelect/Group/index.tsx +4 -16
  16. package/src/SimpleSelect/{types.ts → Group/props.ts} +31 -35
  17. package/src/SimpleSelect/Option/index.tsx +4 -31
  18. package/src/SimpleSelect/Option/props.ts +80 -0
  19. package/src/SimpleSelect/index.tsx +5 -149
  20. package/src/SimpleSelect/props.ts +247 -0
  21. package/src/index.ts +3 -3
  22. package/types/SimpleSelect/Group/index.d.ts +9 -15
  23. package/types/SimpleSelect/Group/index.d.ts.map +1 -1
  24. package/types/SimpleSelect/Group/props.d.ts +14 -0
  25. package/types/SimpleSelect/Group/props.d.ts.map +1 -0
  26. package/types/SimpleSelect/Option/index.d.ts +17 -30
  27. package/types/SimpleSelect/Option/index.d.ts.map +1 -1
  28. package/types/SimpleSelect/Option/props.d.ts +18 -0
  29. package/types/SimpleSelect/Option/props.d.ts.map +1 -0
  30. package/types/SimpleSelect/index.d.ts +61 -150
  31. package/types/SimpleSelect/index.d.ts.map +1 -1
  32. package/types/SimpleSelect/{types.d.ts → props.d.ts} +11 -2
  33. package/types/SimpleSelect/props.d.ts.map +1 -0
  34. package/types/index.d.ts +3 -3
  35. package/LICENSE.md +0 -27
  36. package/es/SimpleSelect/Group/types.js +0 -1
  37. package/es/SimpleSelect/Option/types.js +0 -1
  38. package/es/SimpleSelect/types.js +0 -1
  39. package/lib/SimpleSelect/Group/types.js +0 -1
  40. package/lib/SimpleSelect/Option/types.js +0 -1
  41. package/lib/SimpleSelect/types.js +0 -1
  42. package/types/SimpleSelect/Group/types.d.ts +0 -5
  43. package/types/SimpleSelect/Group/types.d.ts.map +0 -1
  44. package/types/SimpleSelect/Option/types.d.ts +0 -9
  45. package/types/SimpleSelect/Option/types.d.ts.map +0 -1
  46. package/types/SimpleSelect/types.d.ts.map +0 -1
@@ -0,0 +1,247 @@
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 { Children as ChildrenPropTypes } from '@instructure/ui-prop-types'
29
+ import { FormPropTypes } from '@instructure/ui-form-field'
30
+ import { PositionPropTypes } from '@instructure/ui-position'
31
+
32
+ import { Group } from './Group'
33
+ import { Option } from './Option'
34
+
35
+ import type { FormMessage } from '@instructure/ui-form-field'
36
+ import type { PropValidators } from '@instructure/shared-types'
37
+ import type {
38
+ PlacementPropValues,
39
+ PositionConstraint,
40
+ PositionMountNode
41
+ } from '@instructure/ui-position'
42
+
43
+ type SimpleSelectOwnProps = {
44
+ renderLabel: React.ReactNode | ((...args: any[]) => any)
45
+ value?: string | number // TODO: it was using the "controllable" util, in the TS migration mimic that behaviour
46
+ defaultValue?: string
47
+ id?: string
48
+ size?: 'small' | 'medium' | 'large'
49
+ assistiveText?: string
50
+ placeholder?: string
51
+ interaction?: 'enabled' | 'disabled' | 'readonly'
52
+ isRequired?: boolean
53
+ isInline?: boolean
54
+ width?: string
55
+ optionsMaxWidth?: string
56
+ visibleOptionsCount?: number
57
+ messages?: FormMessage[]
58
+ placement?: PlacementPropValues
59
+ constrain?: PositionConstraint
60
+ mountNode?: PositionMountNode
61
+ onChange?: (...args: any[]) => any
62
+ onFocus?: (...args: any[]) => any
63
+ onBlur?: (...args: any[]) => any
64
+ onShowOptions?: (...args: any[]) => any
65
+ onHideOptions?: (...args: any[]) => any
66
+ inputRef?: (...args: any[]) => any
67
+ listRef?: (...args: any[]) => any
68
+ renderEmptyOption?: React.ReactNode | ((...args: any[]) => any)
69
+ renderBeforeInput?: React.ReactNode | ((...args: any[]) => any)
70
+ renderAfterInput?: React.ReactNode | ((...args: any[]) => any)
71
+ children?: React.ReactNode
72
+ }
73
+
74
+ type PropKeys = keyof SimpleSelectOwnProps
75
+
76
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
77
+
78
+ type SimpleSelectProps = SimpleSelectOwnProps
79
+
80
+ const propTypes: PropValidators<PropKeys> = {
81
+ /**
82
+ * The form field label.
83
+ */
84
+ renderLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
85
+ /**
86
+ * The value corresponding to the value of the selected option. If defined,
87
+ * the component will act controlled and will not manage its own state.
88
+ */
89
+ // TODO: it was using the "controllable" util, in the TS migration mimic that behaviour
90
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
91
+ /**
92
+ * The value of the option to select by default, when uncontrolled.
93
+ */
94
+ defaultValue: PropTypes.string,
95
+ /**
96
+ * The id of the text input. One is generated if not supplied.
97
+ */
98
+ id: PropTypes.string,
99
+ /**
100
+ * The size of the text input.
101
+ */
102
+ size: PropTypes.oneOf(['small', 'medium', 'large']),
103
+ /**
104
+ * Additional helpful text to provide to screen readers about the operation
105
+ * of the component. Provided via aria-describedby.
106
+ */
107
+ assistiveText: PropTypes.string,
108
+ /**
109
+ * Html placeholder text to display when the input has no value. This should
110
+ * be hint text, not a label replacement.
111
+ */
112
+ placeholder: PropTypes.string,
113
+ /**
114
+ * Specifies if interaction with the input is enabled, disabled, or readonly.
115
+ * When "disabled", the input changes visibly to indicate that it cannot
116
+ * receive user interactions. When "readonly" the input still cannot receive
117
+ * user interactions but it keeps the same styles as if it were enabled.
118
+ */
119
+ interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
120
+ /**
121
+ * Whether or not the text input is required.
122
+ */
123
+ isRequired: PropTypes.bool,
124
+ /**
125
+ * Whether the input is rendered inline with other elements or if it
126
+ * is rendered as a block level element.
127
+ */
128
+ isInline: PropTypes.bool,
129
+ /**
130
+ * The width of the text input.
131
+ */
132
+ width: PropTypes.string,
133
+ /**
134
+ * The max width the options list can be before option text wraps. If not
135
+ * set, the list will only display as wide as the text input.
136
+ */
137
+ optionsMaxWidth: PropTypes.string,
138
+ /**
139
+ * The number of options that should be visible before having to scroll.
140
+ */
141
+ visibleOptionsCount: PropTypes.number,
142
+ /**
143
+ * Displays messages and validation for the input. It should be an object
144
+ * with the following shape:
145
+ * `{
146
+ * text: PropTypes.string,
147
+ * type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
148
+ * }`
149
+ */
150
+ messages: PropTypes.arrayOf(FormPropTypes.message),
151
+ /**
152
+ * The placement of the options list.
153
+ */
154
+ placement: PositionPropTypes.placement,
155
+ /**
156
+ * The parent in which to constrain the placement.
157
+ */
158
+ constrain: PositionPropTypes.constrain,
159
+ /**
160
+ * An element or a function returning an element to use mount the options
161
+ * list to in the DOM (defaults to `document.body`)
162
+ */
163
+ mountNode: PositionPropTypes.mountNode,
164
+ /**
165
+ * Callback fired when a new option is selected.
166
+ * @param {Object} event - the event object
167
+ * @param {Object} data - additional data
168
+ * @param data.value - the value of selected option
169
+ * @param data.id - the id of the selected option
170
+ */
171
+ onChange: PropTypes.func,
172
+ /**
173
+ * Callback fired when text input receives focus.
174
+ */
175
+ onFocus: PropTypes.func,
176
+ /**
177
+ * Callback fired when text input loses focus.
178
+ */
179
+ onBlur: PropTypes.func,
180
+ /**
181
+ * Callback fired when the options list is shown.
182
+ */
183
+ onShowOptions: PropTypes.func,
184
+ /**
185
+ * Callback fired when the options list is hidden.
186
+ */
187
+ onHideOptions: PropTypes.func,
188
+ /**
189
+ * A ref to the html `input` element.
190
+ */
191
+ inputRef: PropTypes.func,
192
+ /**
193
+ * A ref to the html `ul` element.
194
+ */
195
+ listRef: PropTypes.func,
196
+ /**
197
+ * Content to display in the list when no options are available.
198
+ */
199
+ renderEmptyOption: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
200
+ /**
201
+ * Content to display before the text input. This will commonly be an icon.
202
+ */
203
+ renderBeforeInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
204
+ /**
205
+ * Content to display after the text input. This content will replace the
206
+ * default arrow icons.
207
+ */
208
+ renderAfterInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
209
+ /**
210
+ * Children of type `<SimpleSelect.Option />` or `<SimpleSelect.Group />`.
211
+ */
212
+ children: ChildrenPropTypes.oneOf([Group, Option])
213
+ }
214
+
215
+ const allowedProps: AllowedPropKeys = [
216
+ 'renderLabel',
217
+ 'value',
218
+ 'defaultValue',
219
+ 'id',
220
+ 'size',
221
+ 'assistiveText',
222
+ 'placeholder',
223
+ 'interaction',
224
+ 'isRequired',
225
+ 'isInline',
226
+ 'width',
227
+ 'optionsMaxWidth',
228
+ 'visibleOptionsCount',
229
+ 'messages',
230
+ 'placement',
231
+ 'constrain',
232
+ 'mountNode',
233
+ 'onChange',
234
+ 'onFocus',
235
+ 'onBlur',
236
+ 'onShowOptions',
237
+ 'onHideOptions',
238
+ 'inputRef',
239
+ 'listRef',
240
+ 'renderEmptyOption',
241
+ 'renderBeforeInput',
242
+ 'renderAfterInput',
243
+ 'children'
244
+ ]
245
+
246
+ export type { SimpleSelectProps }
247
+ export { propTypes, allowedProps }
package/src/index.ts CHANGED
@@ -24,6 +24,6 @@
24
24
 
25
25
  export { SimpleSelect } from './SimpleSelect'
26
26
 
27
- export type { SimpleSelectProps } from './SimpleSelect/types'
28
- export type { SimpleSelectGroupProps } from './SimpleSelect/Group/types'
29
- export type { SimpleSelectOptionProps } from './SimpleSelect/Option/types'
27
+ export type { SimpleSelectProps } from './SimpleSelect/props'
28
+ export type { SimpleSelectGroupProps } from './SimpleSelect/Group/props'
29
+ export type { SimpleSelectOptionProps } from './SimpleSelect/Option/props'
@@ -1,6 +1,5 @@
1
1
  import { Component } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { SimpleSelectGroupProps } from './types';
2
+ import type { SimpleSelectGroupProps } from './props';
4
3
  /**
5
4
  ---
6
5
  parent: SimpleSelect
@@ -9,19 +8,14 @@ id: SimpleSelect.Group
9
8
  **/
10
9
  declare class Group extends Component<SimpleSelectGroupProps> {
11
10
  static readonly componentId = "SimpleSelect.Group";
12
- static propTypes: {
13
- /**
14
- * The label associated with the group options.
15
- */
16
- renderLabel: PropTypes.Validator<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
17
- /**
18
- * Children of type `<SimpleSelect.Option />` that will be considered part of the group.
19
- */
20
- children: {
21
- (props: Record<string, any>, propName: string, componentName: string): Error | null;
22
- isRequired: (props: Record<string, any>, propName: string, componentName: string, location?: string | undefined, propFullName?: string | undefined) => Error | null;
23
- };
24
- };
11
+ static allowedProps: readonly (keyof {
12
+ renderLabel: import("react").ReactNode | ((...args: any[]) => any);
13
+ children?: import("react").ReactNode;
14
+ })[];
15
+ static propTypes: import("@instructure/shared-types/types/UtilityTypes").PropValidators<keyof {
16
+ renderLabel: import("react").ReactNode | ((...args: any[]) => any);
17
+ children?: import("react").ReactNode;
18
+ }>;
25
19
  static defaultProps: {
26
20
  children: null;
27
21
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/SimpleSelect/Group/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,SAAS,MAAM,YAAY,CAAA;AAIlC,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAEhD;;;;;GAKG;AACH,cAAM,KAAM,SAAQ,SAAS,CAAC,sBAAsB,CAAC;IACnD,MAAM,CAAC,QAAQ,CAAC,WAAW,wBAAuB;IAElD,MAAM,CAAC,SAAS;QACd;;WAEG;;QAGH;;WAEG;;;;;MAEJ;IAED,MAAM,CAAC,YAAY;;MAElB;IAGD,MAAM;CAKP;AAED,eAAe,KAAK,CAAA;AACpB,OAAO,EAAE,KAAK,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/SimpleSelect/Group/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAGrD;;;;;GAKG;AACH,cAAM,KAAM,SAAQ,SAAS,CAAC,sBAAsB,CAAC;IACnD,MAAM,CAAC,QAAQ,CAAC,WAAW,wBAAuB;IAClD,MAAM,CAAC,YAAY;;;SAAe;IAClC,MAAM,CAAC,SAAS;;;OAAY;IAE5B,MAAM,CAAC,YAAY;;MAElB;IAGD,MAAM;CAKP;AAED,eAAe,KAAK,CAAA;AACpB,OAAO,EAAE,KAAK,EAAE,CAAA"}
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import type { PropValidators } from '@instructure/shared-types';
3
+ declare type SimpleSelectGroupOwnProps = {
4
+ renderLabel: React.ReactNode | ((...args: any[]) => any);
5
+ children?: React.ReactNode;
6
+ };
7
+ declare type PropKeys = keyof SimpleSelectGroupOwnProps;
8
+ declare type AllowedPropKeys = Readonly<Array<PropKeys>>;
9
+ declare type SimpleSelectGroupProps = SimpleSelectGroupOwnProps;
10
+ declare const propTypes: PropValidators<PropKeys>;
11
+ declare const allowedProps: AllowedPropKeys;
12
+ export type { SimpleSelectGroupProps };
13
+ export { propTypes, allowedProps };
14
+ //# sourceMappingURL=props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../src/SimpleSelect/Group/props.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,MAAM,OAAO,CAAA;AAOzB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAE/D,aAAK,yBAAyB,GAAG;IAC/B,WAAW,EAAE,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,CAAA;IACxD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B,CAAA;AACD,aAAK,QAAQ,GAAG,MAAM,yBAAyB,CAAA;AAE/C,aAAK,eAAe,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;AAEhD,aAAK,sBAAsB,GAAG,yBAAyB,CAAA;AAEvD,QAAA,MAAM,SAAS,EAAE,cAAc,CAAC,QAAQ,CASvC,CAAA;AAED,QAAA,MAAM,YAAY,EAAE,eAA6C,CAAA;AAEjE,YAAY,EAAE,sBAAsB,EAAE,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAA"}
@@ -1,6 +1,5 @@
1
1
  import { Component } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { SimpleSelectOptionProps } from './types';
2
+ import type { SimpleSelectOptionProps } from './props';
4
3
  /**
5
4
  ---
6
5
  parent: SimpleSelect
@@ -9,36 +8,24 @@ id: SimpleSelect.Option
9
8
  **/
10
9
  declare class Option extends Component<SimpleSelectOptionProps> {
11
10
  static readonly componentId = "SimpleSelect.Option";
12
- static propTypes: {
13
- /**
14
- * The id for the option.
15
- */
16
- id: PropTypes.Validator<string>;
17
- /**
18
- * The value for the option.
19
- */
20
- value: PropTypes.Validator<string | number>;
21
- /**
22
- * Whether or not this option is disabled.
23
- */
24
- isDisabled: PropTypes.Requireable<boolean>;
25
- /**
26
- * Content to display before the option label, such as an icon.
27
- */
28
- renderBeforeLabel: PropTypes.Requireable<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
29
- /**
30
- * Content to display after the option label, such as an icon.
31
- */
32
- renderAfterLabel: PropTypes.Requireable<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
33
- /**
34
- * Content to display as the option label.
35
- */
36
- children: PropTypes.Requireable<string>;
37
- };
11
+ static allowedProps: readonly (keyof {
12
+ id: string;
13
+ value: string | number;
14
+ isDisabled?: boolean | undefined;
15
+ renderBeforeLabel?: import("react").ReactNode | ((...args: any[]) => any);
16
+ renderAfterLabel?: import("react").ReactNode | ((...args: any[]) => any);
17
+ children?: import("react").ReactNode;
18
+ })[];
19
+ static propTypes: import("@instructure/shared-types/types/UtilityTypes").PropValidators<keyof {
20
+ id: string;
21
+ value: string | number;
22
+ isDisabled?: boolean | undefined;
23
+ renderBeforeLabel?: import("react").ReactNode | ((...args: any[]) => any);
24
+ renderAfterLabel?: import("react").ReactNode | ((...args: any[]) => any);
25
+ children?: import("react").ReactNode;
26
+ }>;
38
27
  static defaultProps: {
39
28
  isDisabled: boolean;
40
- renderBeforeLabel: undefined;
41
- renderAfterLabel: undefined;
42
29
  children: null;
43
30
  };
44
31
  render(): null;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/SimpleSelect/Option/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAEjD;;;;;GAKG;AACH,cAAM,MAAO,SAAQ,SAAS,CAAC,uBAAuB,CAAC;IACrD,MAAM,CAAC,QAAQ,CAAC,WAAW,yBAAwB;IAEnD,MAAM,CAAC,SAAS;QACd;;WAEG;;QAEH;;WAEG;;QAEH;;WAEG;;QAEH;;WAEG;;QAEH;;WAEG;;QAEH;;WAEG;;MAEJ;IAED,MAAM,CAAC,YAAY;;;;;MAKlB;IAGD,MAAM;CAKP;AAED,eAAe,MAAM,CAAA;AACrB,OAAO,EAAE,MAAM,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/SimpleSelect/Option/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAGtD;;;;;GAKG;AACH,cAAM,MAAO,SAAQ,SAAS,CAAC,uBAAuB,CAAC;IACrD,MAAM,CAAC,QAAQ,CAAC,WAAW,yBAAwB;IAEnD,MAAM,CAAC,YAAY;;;;;;;SAAe;IAClC,MAAM,CAAC,SAAS;;;;;;;OAAY;IAC5B,MAAM,CAAC,YAAY;;;MAGlB;IAGD,MAAM;CAKP;AAED,eAAe,MAAM,CAAA;AACrB,OAAO,EAAE,MAAM,EAAE,CAAA"}
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import type { PropValidators } from '@instructure/shared-types';
3
+ declare type SimpleSelectOptionOwnProps = {
4
+ id: string;
5
+ value: string | number;
6
+ isDisabled?: boolean;
7
+ renderBeforeLabel?: React.ReactNode | ((...args: any[]) => any);
8
+ renderAfterLabel?: React.ReactNode | ((...args: any[]) => any);
9
+ children?: React.ReactNode;
10
+ };
11
+ declare type PropKeys = keyof SimpleSelectOptionOwnProps;
12
+ declare type AllowedPropKeys = Readonly<Array<PropKeys>>;
13
+ declare type SimpleSelectOptionProps = SimpleSelectOptionOwnProps;
14
+ declare const propTypes: PropValidators<PropKeys>;
15
+ declare const allowedProps: AllowedPropKeys;
16
+ export type { SimpleSelectOptionProps };
17
+ export { propTypes, allowedProps };
18
+ //# sourceMappingURL=props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../src/SimpleSelect/Option/props.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAE/D,aAAK,0BAA0B,GAAG;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,iBAAiB,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,CAAA;IAC/D,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,CAAA;IAC9D,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B,CAAA;AACD,aAAK,QAAQ,GAAG,MAAM,0BAA0B,CAAA;AAEhD,aAAK,eAAe,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;AAEhD,aAAK,uBAAuB,GAAG,0BAA0B,CAAA;AAEzD,QAAA,MAAM,SAAS,EAAE,cAAc,CAAC,QAAQ,CAyBvC,CAAA;AAED,QAAA,MAAM,YAAY,EAAE,eAOnB,CAAA;AAED,YAAY,EAAE,uBAAuB,EAAE,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAA"}
@@ -1,8 +1,7 @@
1
1
  import React, { Component } from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import { Option } from './Option';
4
3
  import { Group } from './Group';
5
- import { SimpleSelectProps } from './types';
4
+ import type { SimpleSelectProps } from './props';
6
5
  /**
7
6
  ---
8
7
  category: components
@@ -13,161 +12,73 @@ declare class SimpleSelect extends Component<SimpleSelectProps> {
13
12
  static readonly componentId = "SimpleSelect";
14
13
  static Option: typeof Option;
15
14
  static Group: typeof Group;
16
- static propTypes: {
17
- /**
18
- * The form field label.
19
- */
20
- renderLabel: PropTypes.Validator<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
21
- /**
22
- * The value corresponding to the value of the selected option. If defined,
23
- * the component will act controlled and will not manage its own state.
24
- */
25
- value: PropTypes.Requireable<string | number>;
26
- /**
27
- * The value of the option to select by default, when uncontrolled.
28
- */
29
- defaultValue: PropTypes.Requireable<string>;
30
- /**
31
- * The id of the text input. One is generated if not supplied.
32
- */
33
- id: PropTypes.Requireable<string>;
34
- /**
35
- * The size of the text input.
36
- */
37
- size: PropTypes.Requireable<string>;
38
- /**
39
- * Additional helpful text to provide to screen readers about the operation
40
- * of the component. Provided via aria-describedby.
41
- */
42
- assistiveText: PropTypes.Requireable<string>;
43
- /**
44
- * Html placeholder text to display when the input has no value. This should
45
- * be hint text, not a label replacement.
46
- */
47
- placeholder: PropTypes.Requireable<string>;
48
- /**
49
- * Specifies if interaction with the input is enabled, disabled, or readonly.
50
- * When "disabled", the input changes visibly to indicate that it cannot
51
- * receive user interactions. When "readonly" the input still cannot receive
52
- * user interactions but it keeps the same styles as if it were enabled.
53
- */
54
- interaction: PropTypes.Requireable<string>;
55
- /**
56
- * Whether or not the text input is required.
57
- */
58
- isRequired: PropTypes.Requireable<boolean>;
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: PropTypes.Requireable<boolean>;
64
- /**
65
- * The width of the text input.
66
- */
67
- width: PropTypes.Requireable<string>;
68
- /**
69
- * The max width the options list can be before option text wraps. If not
70
- * set, the list will only display as wide as the text input.
71
- */
72
- optionsMaxWidth: PropTypes.Requireable<string>;
73
- /**
74
- * The number of options that should be visible before having to scroll.
75
- */
76
- visibleOptionsCount: PropTypes.Requireable<number>;
77
- /**
78
- * Displays messages and validation for the input. It should be an object
79
- * with the following shape:
80
- * `{
81
- * text: PropTypes.string,
82
- * type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
83
- * }`
84
- */
85
- messages: PropTypes.Requireable<(PropTypes.InferProps<{
86
- text: PropTypes.Requireable<string>;
87
- type: PropTypes.Requireable<string>;
88
- }> | null | undefined)[]>;
89
- /**
90
- * The placement of the options list.
91
- */
92
- placement: PropTypes.Requireable<string>;
93
- /**
94
- * The parent in which to constrain the placement.
95
- */
96
- constrain: PropTypes.Requireable<string | PropTypes.ReactElementLike | Element | ((...args: any[]) => any)>;
97
- /**
98
- * An element or a function returning an element to use mount the options
99
- * list to in the DOM (defaults to `document.body`)
100
- */
101
- mountNode: PropTypes.Requireable<PropTypes.ReactElementLike | Element | ((...args: any[]) => any)>;
102
- /**
103
- * Callback fired when a new option is selected.
104
- * @param {Object} event - the event object
105
- * @param {Object} data - additional data
106
- * @param data.value - the value of selected option
107
- * @param data.id - the id of the selected option
108
- */
109
- onChange: PropTypes.Requireable<(...args: any[]) => any>;
110
- /**
111
- * Callback fired when text input receives focus.
112
- */
113
- onFocus: PropTypes.Requireable<(...args: any[]) => any>;
114
- /**
115
- * Callback fired when text input loses focus.
116
- */
117
- onBlur: PropTypes.Requireable<(...args: any[]) => any>;
118
- /**
119
- * Callback fired when the options list is shown.
120
- */
121
- onShowOptions: PropTypes.Requireable<(...args: any[]) => any>;
122
- /**
123
- * Callback fired when the options list is hidden.
124
- */
125
- onHideOptions: PropTypes.Requireable<(...args: any[]) => any>;
126
- /**
127
- * A ref to the html `input` element.
128
- */
129
- inputRef: PropTypes.Requireable<(...args: any[]) => any>;
130
- /**
131
- * A ref to the html `ul` element.
132
- */
133
- listRef: PropTypes.Requireable<(...args: any[]) => any>;
134
- /**
135
- * Content to display in the list when no options are available.
136
- */
137
- renderEmptyOption: PropTypes.Requireable<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
138
- /**
139
- * Content to display before the text input. This will commonly be an icon.
140
- */
141
- renderBeforeInput: PropTypes.Requireable<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
142
- /**
143
- * Content to display after the text input. This content will replace the
144
- * default arrow icons.
145
- */
146
- renderAfterInput: PropTypes.Requireable<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
147
- /**
148
- * Children of type `<SimpleSelect.Option />` or `<SimpleSelect.Group />`.
149
- */
150
- children: {
151
- (props: Record<string, any>, propName: string, componentName: string): Error | null;
152
- isRequired: (props: Record<string, any>, propName: string, componentName: string, location?: string | undefined, propFullName?: string | undefined) => Error | null;
153
- };
154
- };
15
+ static allowedProps: readonly (keyof {
16
+ renderLabel: React.ReactNode | ((...args: any[]) => any);
17
+ value?: string | number | undefined;
18
+ defaultValue?: string | undefined;
19
+ id?: string | undefined;
20
+ size?: "small" | "medium" | "large" | undefined;
21
+ assistiveText?: string | undefined;
22
+ placeholder?: string | undefined;
23
+ interaction?: "enabled" | "disabled" | "readonly" | undefined;
24
+ isRequired?: boolean | undefined;
25
+ isInline?: boolean | undefined;
26
+ width?: string | undefined;
27
+ optionsMaxWidth?: string | undefined;
28
+ visibleOptionsCount?: number | undefined;
29
+ messages?: import("@instructure/ui-form-field").FormMessage[] | undefined;
30
+ placement?: import("@instructure/ui-position").PlacementPropValues | undefined;
31
+ constrain?: import("@instructure/ui-position").PositionConstraint | undefined;
32
+ mountNode?: import("@instructure/ui-position").PositionMountNode | undefined;
33
+ onChange?: ((...args: any[]) => any) | undefined;
34
+ onFocus?: ((...args: any[]) => any) | undefined;
35
+ onBlur?: ((...args: any[]) => any) | undefined;
36
+ onShowOptions?: ((...args: any[]) => any) | undefined;
37
+ onHideOptions?: ((...args: any[]) => any) | undefined;
38
+ inputRef?: ((...args: any[]) => any) | undefined;
39
+ listRef?: ((...args: any[]) => any) | undefined;
40
+ renderEmptyOption?: React.ReactNode | ((...args: any[]) => any);
41
+ renderBeforeInput?: React.ReactNode | ((...args: any[]) => any);
42
+ renderAfterInput?: React.ReactNode | ((...args: any[]) => any);
43
+ children?: React.ReactNode;
44
+ })[];
45
+ static propTypes: import("@instructure/shared-types/types/UtilityTypes").PropValidators<keyof {
46
+ renderLabel: React.ReactNode | ((...args: any[]) => any);
47
+ value?: string | number | undefined;
48
+ defaultValue?: string | undefined;
49
+ id?: string | undefined;
50
+ size?: "small" | "medium" | "large" | undefined;
51
+ assistiveText?: string | undefined;
52
+ placeholder?: string | undefined;
53
+ interaction?: "enabled" | "disabled" | "readonly" | undefined;
54
+ isRequired?: boolean | undefined;
55
+ isInline?: boolean | undefined;
56
+ width?: string | undefined;
57
+ optionsMaxWidth?: string | undefined;
58
+ visibleOptionsCount?: number | undefined;
59
+ messages?: import("@instructure/ui-form-field").FormMessage[] | undefined;
60
+ placement?: import("@instructure/ui-position").PlacementPropValues | undefined;
61
+ constrain?: import("@instructure/ui-position").PositionConstraint | undefined;
62
+ mountNode?: import("@instructure/ui-position").PositionMountNode | undefined;
63
+ onChange?: ((...args: any[]) => any) | undefined;
64
+ onFocus?: ((...args: any[]) => any) | undefined;
65
+ onBlur?: ((...args: any[]) => any) | undefined;
66
+ onShowOptions?: ((...args: any[]) => any) | undefined;
67
+ onHideOptions?: ((...args: any[]) => any) | undefined;
68
+ inputRef?: ((...args: any[]) => any) | undefined;
69
+ listRef?: ((...args: any[]) => any) | undefined;
70
+ renderEmptyOption?: React.ReactNode | ((...args: any[]) => any);
71
+ renderBeforeInput?: React.ReactNode | ((...args: any[]) => any);
72
+ renderAfterInput?: React.ReactNode | ((...args: any[]) => any);
73
+ children?: React.ReactNode;
74
+ }>;
155
75
  static defaultProps: {
156
- value: undefined;
157
- defaultValue: undefined;
158
- id: undefined;
159
76
  size: string;
160
- assistiveText: undefined;
161
77
  placeholder: null;
162
- interaction: undefined;
163
78
  isRequired: boolean;
164
79
  isInline: boolean;
165
- width: undefined;
166
- optionsMaxWidth: undefined;
167
80
  visibleOptionsCount: number;
168
- messages: undefined;
169
81
  placement: string;
170
- mountNode: undefined;
171
82
  constrain: string;
172
83
  onChange: (event: any, data: any) => void;
173
84
  onFocus: (event: any) => void;