@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.
- package/CHANGELOG.md +8 -0
- package/es/SimpleSelect/Group/index.js +4 -15
- package/{src/SimpleSelect/Group/types.ts → es/SimpleSelect/Group/props.js} +15 -3
- package/es/SimpleSelect/Option/index.js +4 -35
- package/es/SimpleSelect/Option/props.js +57 -0
- package/es/SimpleSelect/index.js +3 -175
- package/es/SimpleSelect/props.js +192 -0
- package/lib/SimpleSelect/Group/index.js +3 -18
- package/{src/SimpleSelect/Option/types.ts → lib/SimpleSelect/Group/props.js} +28 -7
- package/lib/SimpleSelect/Option/index.js +3 -36
- package/lib/SimpleSelect/Option/props.js +68 -0
- package/lib/SimpleSelect/index.js +3 -178
- package/lib/SimpleSelect/props.js +208 -0
- package/package.json +15 -16
- package/src/SimpleSelect/Group/index.tsx +4 -16
- package/src/SimpleSelect/{types.ts → Group/props.ts} +31 -35
- package/src/SimpleSelect/Option/index.tsx +4 -31
- package/src/SimpleSelect/Option/props.ts +80 -0
- package/src/SimpleSelect/index.tsx +5 -149
- package/src/SimpleSelect/props.ts +247 -0
- package/src/index.ts +3 -3
- package/types/SimpleSelect/Group/index.d.ts +9 -15
- package/types/SimpleSelect/Group/index.d.ts.map +1 -1
- package/types/SimpleSelect/Group/props.d.ts +14 -0
- package/types/SimpleSelect/Group/props.d.ts.map +1 -0
- package/types/SimpleSelect/Option/index.d.ts +17 -30
- package/types/SimpleSelect/Option/index.d.ts.map +1 -1
- package/types/SimpleSelect/Option/props.d.ts +18 -0
- package/types/SimpleSelect/Option/props.d.ts.map +1 -0
- package/types/SimpleSelect/index.d.ts +61 -150
- package/types/SimpleSelect/index.d.ts.map +1 -1
- package/types/SimpleSelect/{types.d.ts → props.d.ts} +11 -2
- package/types/SimpleSelect/props.d.ts.map +1 -0
- package/types/index.d.ts +3 -3
- package/LICENSE.md +0 -27
- package/es/SimpleSelect/Group/types.js +0 -1
- package/es/SimpleSelect/Option/types.js +0 -1
- package/es/SimpleSelect/types.js +0 -1
- package/lib/SimpleSelect/Group/types.js +0 -1
- package/lib/SimpleSelect/Option/types.js +0 -1
- package/lib/SimpleSelect/types.js +0 -1
- package/types/SimpleSelect/Group/types.d.ts +0 -5
- package/types/SimpleSelect/Group/types.d.ts.map +0 -1
- package/types/SimpleSelect/Option/types.d.ts +0 -9
- package/types/SimpleSelect/Option/types.d.ts.map +0 -1
- package/types/SimpleSelect/types.d.ts.map +0 -1
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
@@ -9,11 +7,7 @@ exports.Group = exports.default = void 0;
|
|
|
9
7
|
|
|
10
8
|
var _react = require("react");
|
|
11
9
|
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
var _Children = require("@instructure/ui-prop-types/lib/Children.js");
|
|
15
|
-
|
|
16
|
-
var _Option = require("../Option");
|
|
10
|
+
var _props = require("./props");
|
|
17
11
|
|
|
18
12
|
/*
|
|
19
13
|
* The MIT License (MIT)
|
|
@@ -58,17 +52,8 @@ class Group extends _react.Component {
|
|
|
58
52
|
exports.Group = Group;
|
|
59
53
|
Group.displayName = "Group";
|
|
60
54
|
Group.componentId = 'SimpleSelect.Group';
|
|
61
|
-
Group.
|
|
62
|
-
|
|
63
|
-
* The label associated with the group options.
|
|
64
|
-
*/
|
|
65
|
-
renderLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Children of type `<SimpleSelect.Option />` that will be considered part of the group.
|
|
69
|
-
*/
|
|
70
|
-
children: _Children.Children.oneOf([_Option.Option])
|
|
71
|
-
};
|
|
55
|
+
Group.allowedProps = _props.allowedProps;
|
|
56
|
+
Group.propTypes = _props.propTypes;
|
|
72
57
|
Group.defaultProps = {
|
|
73
58
|
children: null
|
|
74
59
|
};
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.allowedProps = exports.propTypes = void 0;
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _Children = require("@instructure/ui-prop-types/lib/Children.js");
|
|
13
|
+
|
|
14
|
+
var _Option = require("../Option");
|
|
15
|
+
|
|
1
16
|
/*
|
|
2
17
|
* The MIT License (MIT)
|
|
3
18
|
*
|
|
@@ -21,11 +36,17 @@
|
|
|
21
36
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
37
|
* SOFTWARE.
|
|
23
38
|
*/
|
|
39
|
+
const propTypes = {
|
|
40
|
+
/**
|
|
41
|
+
* The label associated with the group options.
|
|
42
|
+
*/
|
|
43
|
+
renderLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
|
|
24
44
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Children of type `<SimpleSelect.Option />` that will be considered part of the group.
|
|
47
|
+
*/
|
|
48
|
+
children: _Children.Children.oneOf([_Option.Option])
|
|
49
|
+
};
|
|
50
|
+
exports.propTypes = propTypes;
|
|
51
|
+
const allowedProps = ['renderLabel', 'children'];
|
|
52
|
+
exports.allowedProps = allowedProps;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
@@ -9,7 +7,7 @@ exports.Option = exports.default = void 0;
|
|
|
9
7
|
|
|
10
8
|
var _react = require("react");
|
|
11
9
|
|
|
12
|
-
var
|
|
10
|
+
var _props = require("./props");
|
|
13
11
|
|
|
14
12
|
/*
|
|
15
13
|
* The MIT License (MIT)
|
|
@@ -54,41 +52,10 @@ class Option extends _react.Component {
|
|
|
54
52
|
exports.Option = Option;
|
|
55
53
|
Option.displayName = "Option";
|
|
56
54
|
Option.componentId = 'SimpleSelect.Option';
|
|
57
|
-
Option.
|
|
58
|
-
|
|
59
|
-
* The id for the option.
|
|
60
|
-
*/
|
|
61
|
-
id: _propTypes.default.string.isRequired,
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* The value for the option.
|
|
65
|
-
*/
|
|
66
|
-
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]).isRequired,
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Whether or not this option is disabled.
|
|
70
|
-
*/
|
|
71
|
-
isDisabled: _propTypes.default.bool,
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Content to display before the option label, such as an icon.
|
|
75
|
-
*/
|
|
76
|
-
renderBeforeLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Content to display after the option label, such as an icon.
|
|
80
|
-
*/
|
|
81
|
-
renderAfterLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Content to display as the option label.
|
|
85
|
-
*/
|
|
86
|
-
children: _propTypes.default.string
|
|
87
|
-
};
|
|
55
|
+
Option.allowedProps = _props.allowedProps;
|
|
56
|
+
Option.propTypes = _props.propTypes;
|
|
88
57
|
Option.defaultProps = {
|
|
89
58
|
isDisabled: false,
|
|
90
|
-
renderBeforeLabel: void 0,
|
|
91
|
-
renderAfterLabel: void 0,
|
|
92
59
|
children: null
|
|
93
60
|
};
|
|
94
61
|
var _default = Option;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.allowedProps = exports.propTypes = void 0;
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* The MIT License (MIT)
|
|
14
|
+
*
|
|
15
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
16
|
+
*
|
|
17
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
18
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
19
|
+
* in the Software without restriction, including without limitation the rights
|
|
20
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
21
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
22
|
+
* furnished to do so, subject to the following conditions:
|
|
23
|
+
*
|
|
24
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
25
|
+
* copies or substantial portions of the Software.
|
|
26
|
+
*
|
|
27
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
28
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
29
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
30
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
31
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
32
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
|
+
* SOFTWARE.
|
|
34
|
+
*/
|
|
35
|
+
const propTypes = {
|
|
36
|
+
/**
|
|
37
|
+
* The id for the option.
|
|
38
|
+
*/
|
|
39
|
+
id: _propTypes.default.string.isRequired,
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The value for the option.
|
|
43
|
+
*/
|
|
44
|
+
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]).isRequired,
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Whether or not this option is disabled.
|
|
48
|
+
*/
|
|
49
|
+
isDisabled: _propTypes.default.bool,
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Content to display before the option label, such as an icon.
|
|
53
|
+
*/
|
|
54
|
+
renderBeforeLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Content to display after the option label, such as an icon.
|
|
58
|
+
*/
|
|
59
|
+
renderAfterLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Content to display as the option label.
|
|
63
|
+
*/
|
|
64
|
+
children: _propTypes.default.string
|
|
65
|
+
};
|
|
66
|
+
exports.propTypes = propTypes;
|
|
67
|
+
const allowedProps = ['id', 'value', 'isDisabled', 'renderBeforeLabel', 'renderAfterLabel', 'children'];
|
|
68
|
+
exports.allowedProps = allowedProps;
|
|
@@ -13,14 +13,6 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
|
13
13
|
|
|
14
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
15
|
|
|
16
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
|
-
|
|
18
|
-
var _Children = require("@instructure/ui-prop-types/lib/Children.js");
|
|
19
|
-
|
|
20
|
-
var _FormPropTypes = require("@instructure/ui-form-field/lib/FormPropTypes.js");
|
|
21
|
-
|
|
22
|
-
var _PositionPropTypes = require("@instructure/ui-position/lib/PositionPropTypes.js");
|
|
23
|
-
|
|
24
16
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
25
17
|
|
|
26
18
|
var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
|
|
@@ -39,6 +31,8 @@ var _Option = require("./Option");
|
|
|
39
31
|
|
|
40
32
|
var _Group = require("./Group");
|
|
41
33
|
|
|
34
|
+
var _props = require("./props");
|
|
35
|
+
|
|
42
36
|
const _excluded = ["id", "value", "children", "renderBeforeLabel", "renderAfterLabel"],
|
|
43
37
|
_excluded2 = ["id", "renderLabel", "children"],
|
|
44
38
|
_excluded3 = ["renderLabel", "value", "defaultValue", "id", "size", "assistiveText", "placeholder", "interaction", "isRequired", "isInline", "width", "optionsMaxWidth", "visibleOptionsCount", "messages", "placement", "constrain", "mountNode", "inputRef", "listRef", "renderEmptyOption", "renderBeforeInput", "renderAfterInput", "onFocus", "onBlur", "onShowOptions", "onHideOptions", "children"];
|
|
@@ -392,182 +386,13 @@ let SimpleSelect = (_dec = (0, _testable.testable)(), _dec(_class = (_temp = _cl
|
|
|
392
386
|
}, (0, _passthroughProps.passthroughProps)(rest)), this.renderChildren(children));
|
|
393
387
|
}
|
|
394
388
|
|
|
395
|
-
}, _class2.displayName = "SimpleSelect", _class2.componentId = 'SimpleSelect', _class2.Option = _Option.Option, _class2.Group = _Group.Group, _class2.propTypes = {
|
|
396
|
-
/**
|
|
397
|
-
* The form field label.
|
|
398
|
-
*/
|
|
399
|
-
renderLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* The value corresponding to the value of the selected option. If defined,
|
|
403
|
-
* the component will act controlled and will not manage its own state.
|
|
404
|
-
*/
|
|
405
|
-
// TODO: it was using the "controllable" util, in the TS migration mimic that behaviour
|
|
406
|
-
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* The value of the option to select by default, when uncontrolled.
|
|
410
|
-
*/
|
|
411
|
-
defaultValue: _propTypes.default.string,
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* The id of the text input. One is generated if not supplied.
|
|
415
|
-
*/
|
|
416
|
-
id: _propTypes.default.string,
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* The size of the text input.
|
|
420
|
-
*/
|
|
421
|
-
size: _propTypes.default.oneOf(['small', 'medium', 'large']),
|
|
422
|
-
|
|
423
|
-
/**
|
|
424
|
-
* Additional helpful text to provide to screen readers about the operation
|
|
425
|
-
* of the component. Provided via aria-describedby.
|
|
426
|
-
*/
|
|
427
|
-
assistiveText: _propTypes.default.string,
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* Html placeholder text to display when the input has no value. This should
|
|
431
|
-
* be hint text, not a label replacement.
|
|
432
|
-
*/
|
|
433
|
-
placeholder: _propTypes.default.string,
|
|
434
|
-
|
|
435
|
-
/**
|
|
436
|
-
* Specifies if interaction with the input is enabled, disabled, or readonly.
|
|
437
|
-
* When "disabled", the input changes visibly to indicate that it cannot
|
|
438
|
-
* receive user interactions. When "readonly" the input still cannot receive
|
|
439
|
-
* user interactions but it keeps the same styles as if it were enabled.
|
|
440
|
-
*/
|
|
441
|
-
interaction: _propTypes.default.oneOf(['enabled', 'disabled', 'readonly']),
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* Whether or not the text input is required.
|
|
445
|
-
*/
|
|
446
|
-
isRequired: _propTypes.default.bool,
|
|
447
|
-
|
|
448
|
-
/**
|
|
449
|
-
* Whether the input is rendered inline with other elements or if it
|
|
450
|
-
* is rendered as a block level element.
|
|
451
|
-
*/
|
|
452
|
-
isInline: _propTypes.default.bool,
|
|
453
|
-
|
|
454
|
-
/**
|
|
455
|
-
* The width of the text input.
|
|
456
|
-
*/
|
|
457
|
-
width: _propTypes.default.string,
|
|
458
|
-
|
|
459
|
-
/**
|
|
460
|
-
* The max width the options list can be before option text wraps. If not
|
|
461
|
-
* set, the list will only display as wide as the text input.
|
|
462
|
-
*/
|
|
463
|
-
optionsMaxWidth: _propTypes.default.string,
|
|
464
|
-
|
|
465
|
-
/**
|
|
466
|
-
* The number of options that should be visible before having to scroll.
|
|
467
|
-
*/
|
|
468
|
-
visibleOptionsCount: _propTypes.default.number,
|
|
469
|
-
|
|
470
|
-
/**
|
|
471
|
-
* Displays messages and validation for the input. It should be an object
|
|
472
|
-
* with the following shape:
|
|
473
|
-
* `{
|
|
474
|
-
* text: PropTypes.string,
|
|
475
|
-
* type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
|
|
476
|
-
* }`
|
|
477
|
-
*/
|
|
478
|
-
messages: _propTypes.default.arrayOf(_FormPropTypes.FormPropTypes.message),
|
|
479
|
-
|
|
480
|
-
/**
|
|
481
|
-
* The placement of the options list.
|
|
482
|
-
*/
|
|
483
|
-
placement: _PositionPropTypes.PositionPropTypes.placement,
|
|
484
|
-
|
|
485
|
-
/**
|
|
486
|
-
* The parent in which to constrain the placement.
|
|
487
|
-
*/
|
|
488
|
-
constrain: _PositionPropTypes.PositionPropTypes.constrain,
|
|
489
|
-
|
|
490
|
-
/**
|
|
491
|
-
* An element or a function returning an element to use mount the options
|
|
492
|
-
* list to in the DOM (defaults to `document.body`)
|
|
493
|
-
*/
|
|
494
|
-
mountNode: _PositionPropTypes.PositionPropTypes.mountNode,
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* Callback fired when a new option is selected.
|
|
498
|
-
* @param {Object} event - the event object
|
|
499
|
-
* @param {Object} data - additional data
|
|
500
|
-
* @param data.value - the value of selected option
|
|
501
|
-
* @param data.id - the id of the selected option
|
|
502
|
-
*/
|
|
503
|
-
onChange: _propTypes.default.func,
|
|
504
|
-
|
|
505
|
-
/**
|
|
506
|
-
* Callback fired when text input receives focus.
|
|
507
|
-
*/
|
|
508
|
-
onFocus: _propTypes.default.func,
|
|
509
|
-
|
|
510
|
-
/**
|
|
511
|
-
* Callback fired when text input loses focus.
|
|
512
|
-
*/
|
|
513
|
-
onBlur: _propTypes.default.func,
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
* Callback fired when the options list is shown.
|
|
517
|
-
*/
|
|
518
|
-
onShowOptions: _propTypes.default.func,
|
|
519
|
-
|
|
520
|
-
/**
|
|
521
|
-
* Callback fired when the options list is hidden.
|
|
522
|
-
*/
|
|
523
|
-
onHideOptions: _propTypes.default.func,
|
|
524
|
-
|
|
525
|
-
/**
|
|
526
|
-
* A ref to the html `input` element.
|
|
527
|
-
*/
|
|
528
|
-
inputRef: _propTypes.default.func,
|
|
529
|
-
|
|
530
|
-
/**
|
|
531
|
-
* A ref to the html `ul` element.
|
|
532
|
-
*/
|
|
533
|
-
listRef: _propTypes.default.func,
|
|
534
|
-
|
|
535
|
-
/**
|
|
536
|
-
* Content to display in the list when no options are available.
|
|
537
|
-
*/
|
|
538
|
-
renderEmptyOption: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
539
|
-
|
|
540
|
-
/**
|
|
541
|
-
* Content to display before the text input. This will commonly be an icon.
|
|
542
|
-
*/
|
|
543
|
-
renderBeforeInput: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
544
|
-
|
|
545
|
-
/**
|
|
546
|
-
* Content to display after the text input. This content will replace the
|
|
547
|
-
* default arrow icons.
|
|
548
|
-
*/
|
|
549
|
-
renderAfterInput: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
550
|
-
|
|
551
|
-
/**
|
|
552
|
-
* Children of type `<SimpleSelect.Option />` or `<SimpleSelect.Group />`.
|
|
553
|
-
*/
|
|
554
|
-
children: _Children.Children.oneOf([_Group.Group, _Option.Option])
|
|
555
|
-
}, _class2.defaultProps = {
|
|
556
|
-
value: void 0,
|
|
557
|
-
defaultValue: void 0,
|
|
558
|
-
id: void 0,
|
|
389
|
+
}, _class2.displayName = "SimpleSelect", _class2.componentId = 'SimpleSelect', _class2.Option = _Option.Option, _class2.Group = _Group.Group, _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
559
390
|
size: 'medium',
|
|
560
|
-
assistiveText: void 0,
|
|
561
391
|
placeholder: null,
|
|
562
|
-
interaction: void 0,
|
|
563
392
|
isRequired: false,
|
|
564
393
|
isInline: false,
|
|
565
|
-
width: void 0,
|
|
566
|
-
optionsMaxWidth: void 0,
|
|
567
394
|
visibleOptionsCount: 8,
|
|
568
|
-
messages: void 0,
|
|
569
395
|
placement: 'bottom stretch',
|
|
570
|
-
mountNode: void 0,
|
|
571
396
|
constrain: 'window',
|
|
572
397
|
onChange: (event, data) => {},
|
|
573
398
|
onFocus: event => {},
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.allowedProps = exports.propTypes = void 0;
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _Children = require("@instructure/ui-prop-types/lib/Children.js");
|
|
13
|
+
|
|
14
|
+
var _FormPropTypes = require("@instructure/ui-form-field/lib/FormPropTypes.js");
|
|
15
|
+
|
|
16
|
+
var _PositionPropTypes = require("@instructure/ui-position/lib/PositionPropTypes.js");
|
|
17
|
+
|
|
18
|
+
var _Group = require("./Group");
|
|
19
|
+
|
|
20
|
+
var _Option = require("./Option");
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
* The MIT License (MIT)
|
|
24
|
+
*
|
|
25
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
26
|
+
*
|
|
27
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
28
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
29
|
+
* in the Software without restriction, including without limitation the rights
|
|
30
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
31
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
32
|
+
* furnished to do so, subject to the following conditions:
|
|
33
|
+
*
|
|
34
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
35
|
+
* copies or substantial portions of the Software.
|
|
36
|
+
*
|
|
37
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
38
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
39
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
40
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
41
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
42
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
43
|
+
* SOFTWARE.
|
|
44
|
+
*/
|
|
45
|
+
const propTypes = {
|
|
46
|
+
/**
|
|
47
|
+
* The form field label.
|
|
48
|
+
*/
|
|
49
|
+
renderLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The value corresponding to the value of the selected option. If defined,
|
|
53
|
+
* the component will act controlled and will not manage its own state.
|
|
54
|
+
*/
|
|
55
|
+
// TODO: it was using the "controllable" util, in the TS migration mimic that behaviour
|
|
56
|
+
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The value of the option to select by default, when uncontrolled.
|
|
60
|
+
*/
|
|
61
|
+
defaultValue: _propTypes.default.string,
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The id of the text input. One is generated if not supplied.
|
|
65
|
+
*/
|
|
66
|
+
id: _propTypes.default.string,
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The size of the text input.
|
|
70
|
+
*/
|
|
71
|
+
size: _propTypes.default.oneOf(['small', 'medium', 'large']),
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Additional helpful text to provide to screen readers about the operation
|
|
75
|
+
* of the component. Provided via aria-describedby.
|
|
76
|
+
*/
|
|
77
|
+
assistiveText: _propTypes.default.string,
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Html placeholder text to display when the input has no value. This should
|
|
81
|
+
* be hint text, not a label replacement.
|
|
82
|
+
*/
|
|
83
|
+
placeholder: _propTypes.default.string,
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Specifies if interaction with the input is enabled, disabled, or readonly.
|
|
87
|
+
* When "disabled", the input changes visibly to indicate that it cannot
|
|
88
|
+
* receive user interactions. When "readonly" the input still cannot receive
|
|
89
|
+
* user interactions but it keeps the same styles as if it were enabled.
|
|
90
|
+
*/
|
|
91
|
+
interaction: _propTypes.default.oneOf(['enabled', 'disabled', 'readonly']),
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Whether or not the text input is required.
|
|
95
|
+
*/
|
|
96
|
+
isRequired: _propTypes.default.bool,
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Whether the input is rendered inline with other elements or if it
|
|
100
|
+
* is rendered as a block level element.
|
|
101
|
+
*/
|
|
102
|
+
isInline: _propTypes.default.bool,
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The width of the text input.
|
|
106
|
+
*/
|
|
107
|
+
width: _propTypes.default.string,
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The max width the options list can be before option text wraps. If not
|
|
111
|
+
* set, the list will only display as wide as the text input.
|
|
112
|
+
*/
|
|
113
|
+
optionsMaxWidth: _propTypes.default.string,
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The number of options that should be visible before having to scroll.
|
|
117
|
+
*/
|
|
118
|
+
visibleOptionsCount: _propTypes.default.number,
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Displays messages and validation for the input. It should be an object
|
|
122
|
+
* with the following shape:
|
|
123
|
+
* `{
|
|
124
|
+
* text: PropTypes.string,
|
|
125
|
+
* type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
|
|
126
|
+
* }`
|
|
127
|
+
*/
|
|
128
|
+
messages: _propTypes.default.arrayOf(_FormPropTypes.FormPropTypes.message),
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The placement of the options list.
|
|
132
|
+
*/
|
|
133
|
+
placement: _PositionPropTypes.PositionPropTypes.placement,
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* The parent in which to constrain the placement.
|
|
137
|
+
*/
|
|
138
|
+
constrain: _PositionPropTypes.PositionPropTypes.constrain,
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* An element or a function returning an element to use mount the options
|
|
142
|
+
* list to in the DOM (defaults to `document.body`)
|
|
143
|
+
*/
|
|
144
|
+
mountNode: _PositionPropTypes.PositionPropTypes.mountNode,
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Callback fired when a new option is selected.
|
|
148
|
+
* @param {Object} event - the event object
|
|
149
|
+
* @param {Object} data - additional data
|
|
150
|
+
* @param data.value - the value of selected option
|
|
151
|
+
* @param data.id - the id of the selected option
|
|
152
|
+
*/
|
|
153
|
+
onChange: _propTypes.default.func,
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Callback fired when text input receives focus.
|
|
157
|
+
*/
|
|
158
|
+
onFocus: _propTypes.default.func,
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Callback fired when text input loses focus.
|
|
162
|
+
*/
|
|
163
|
+
onBlur: _propTypes.default.func,
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Callback fired when the options list is shown.
|
|
167
|
+
*/
|
|
168
|
+
onShowOptions: _propTypes.default.func,
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Callback fired when the options list is hidden.
|
|
172
|
+
*/
|
|
173
|
+
onHideOptions: _propTypes.default.func,
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* A ref to the html `input` element.
|
|
177
|
+
*/
|
|
178
|
+
inputRef: _propTypes.default.func,
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* A ref to the html `ul` element.
|
|
182
|
+
*/
|
|
183
|
+
listRef: _propTypes.default.func,
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Content to display in the list when no options are available.
|
|
187
|
+
*/
|
|
188
|
+
renderEmptyOption: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Content to display before the text input. This will commonly be an icon.
|
|
192
|
+
*/
|
|
193
|
+
renderBeforeInput: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Content to display after the text input. This content will replace the
|
|
197
|
+
* default arrow icons.
|
|
198
|
+
*/
|
|
199
|
+
renderAfterInput: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Children of type `<SimpleSelect.Option />` or `<SimpleSelect.Group />`.
|
|
203
|
+
*/
|
|
204
|
+
children: _Children.Children.oneOf([_Group.Group, _Option.Option])
|
|
205
|
+
};
|
|
206
|
+
exports.propTypes = propTypes;
|
|
207
|
+
const allowedProps = ['renderLabel', 'value', 'defaultValue', 'id', 'size', 'assistiveText', 'placeholder', 'interaction', 'isRequired', 'isInline', 'width', 'optionsMaxWidth', 'visibleOptionsCount', 'messages', 'placement', 'constrain', 'mountNode', 'onChange', 'onFocus', 'onBlur', 'onShowOptions', 'onHideOptions', 'inputRef', 'listRef', 'renderEmptyOption', 'renderBeforeInput', 'renderAfterInput', 'children'];
|
|
208
|
+
exports.allowedProps = allowedProps;
|