@instructure/ui-select 11.6.0 → 11.6.1-pr-snapshot-1779894247159

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 CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [11.6.1-pr-snapshot-1779894247159](https://github.com/instructure/instructure-ui/compare/v11.6.0...v11.6.1-pr-snapshot-1779894247159) (2026-05-27)
7
+
8
+ **Note:** Version bump only for package @instructure/ui-select
9
+
10
+
11
+
12
+
13
+
6
14
  # [11.6.0](https://github.com/instructure/instructure-ui/compare/v11.5.0...v11.6.0) (2026-02-18)
7
15
 
8
16
  **Note:** Version bump only for package @instructure/ui-select
@@ -1,9 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.allowedProps = void 0;
7
1
  /*
8
2
  * The MIT License (MIT)
9
3
  *
@@ -28,4 +22,16 @@ exports.allowedProps = void 0;
28
22
  * SOFTWARE.
29
23
  */
30
24
 
31
- const allowedProps = exports.allowedProps = ['renderLabel', 'children'];
25
+ module.exports = {
26
+ presets: [
27
+ [
28
+ require('@instructure/ui-babel-preset'),
29
+ {
30
+ coverage: Boolean(process.env.COVERAGE),
31
+ esModules: Boolean(process.env.ES_MODULES),
32
+ removeConsole: process.env.NODE_ENV === 'production',
33
+ transformImports: Boolean(process.env.TRANSFORM_IMPORTS)
34
+ }
35
+ ]
36
+ ]
37
+ }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@instructure/ui-select",
3
- "version": "11.6.0",
3
+ "version": "11.6.1-pr-snapshot-1779894247159",
4
+ "type": "module",
4
5
  "description": "A component for select and autocomplete behavior.",
5
6
  "author": "Instructure, Inc. Engineering and Product Design",
6
7
  "module": "./es/index.js",
7
- "main": "./lib/index.js",
8
8
  "types": "./types/index.d.ts",
9
9
  "repository": {
10
10
  "type": "git",
@@ -15,30 +15,30 @@
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
17
  "@babel/runtime": "^7.27.6",
18
- "@instructure/emotion": "11.6.0",
19
- "@instructure/shared-types": "11.6.0",
20
- "@instructure/ui-dom-utils": "11.6.0",
21
- "@instructure/ui-form-field": "11.6.0",
22
- "@instructure/ui-icons": "11.6.0",
23
- "@instructure/ui-popover": "11.6.0",
24
- "@instructure/ui-options": "11.6.0",
25
- "@instructure/ui-position": "11.6.0",
26
- "@instructure/ui-react-utils": "11.6.0",
27
- "@instructure/ui-selectable": "11.6.0",
28
- "@instructure/ui-text-input": "11.6.0",
29
- "@instructure/ui-utils": "11.6.0",
30
- "@instructure/ui-view": "11.6.0",
31
- "@instructure/uid": "11.6.0"
18
+ "@instructure/emotion": "11.6.1-pr-snapshot-1779894247159",
19
+ "@instructure/shared-types": "11.6.1-pr-snapshot-1779894247159",
20
+ "@instructure/ui-dom-utils": "11.6.1-pr-snapshot-1779894247159",
21
+ "@instructure/ui-form-field": "11.6.1-pr-snapshot-1779894247159",
22
+ "@instructure/ui-icons": "11.6.1-pr-snapshot-1779894247159",
23
+ "@instructure/ui-options": "11.6.1-pr-snapshot-1779894247159",
24
+ "@instructure/ui-popover": "11.6.1-pr-snapshot-1779894247159",
25
+ "@instructure/ui-selectable": "11.6.1-pr-snapshot-1779894247159",
26
+ "@instructure/ui-position": "11.6.1-pr-snapshot-1779894247159",
27
+ "@instructure/ui-react-utils": "11.6.1-pr-snapshot-1779894247159",
28
+ "@instructure/ui-utils": "11.6.1-pr-snapshot-1779894247159",
29
+ "@instructure/ui-view": "11.6.1-pr-snapshot-1779894247159",
30
+ "@instructure/uid": "11.6.1-pr-snapshot-1779894247159",
31
+ "@instructure/ui-text-input": "11.6.1-pr-snapshot-1779894247159"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@testing-library/jest-dom": "^6.6.3",
35
35
  "@testing-library/react": "15.0.7",
36
36
  "@testing-library/user-event": "^14.6.1",
37
37
  "vitest": "^3.2.2",
38
- "@instructure/ui-color-utils": "11.6.0",
39
- "@instructure/ui-babel-preset": "11.6.0",
40
- "@instructure/ui-scripts": "11.6.0",
41
- "@instructure/ui-themes": "11.6.0"
38
+ "@instructure/ui-color-utils": "11.6.1-pr-snapshot-1779894247159",
39
+ "@instructure/ui-babel-preset": "11.6.1-pr-snapshot-1779894247159",
40
+ "@instructure/ui-scripts": "11.6.1-pr-snapshot-1779894247159",
41
+ "@instructure/ui-themes": "11.6.1-pr-snapshot-1779894247159"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "react": ">=18 <=19"
@@ -51,10 +51,8 @@
51
51
  ".": {
52
52
  "types": "./types/index.d.ts",
53
53
  "import": "./es/index.js",
54
- "require": "./lib/index.js",
55
54
  "default": "./es/index.js"
56
55
  },
57
- "./lib/*": "./lib/*",
58
56
  "./es/*": "./es/*",
59
57
  "./types/*": "./types/*",
60
58
  "./package.json": "./package.json",
@@ -64,7 +62,7 @@
64
62
  "lint": "ui-scripts lint",
65
63
  "lint:fix": "ui-scripts lint --fix",
66
64
  "clean": "ui-scripts clean",
67
- "build": "ui-scripts build --modules es,cjs",
65
+ "build": "ui-scripts build",
68
66
  "build:watch": "pnpm run ts:check -- --watch & ui-scripts build --watch",
69
67
  "build:types": "tsc -p tsconfig.build.json",
70
68
  "ts:check": "tsc -p tsconfig.build.json --noEmit --emitDeclarationOnly false"
@@ -1,53 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.Group = void 0;
7
- var _react = require("react");
8
- var _props = require("./props");
9
- /*
10
- * The MIT License (MIT)
11
- *
12
- * Copyright (c) 2015 - present Instructure, Inc.
13
- *
14
- * Permission is hereby granted, free of charge, to any person obtaining a copy
15
- * of this software and associated documentation files (the "Software"), to deal
16
- * in the Software without restriction, including without limitation the rights
17
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
- * copies of the Software, and to permit persons to whom the Software is
19
- * furnished to do so, subject to the following conditions:
20
- *
21
- * The above copyright notice and this permission notice shall be included in all
22
- * copies or substantial portions of the Software.
23
- *
24
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
- * SOFTWARE.
31
- */
32
-
33
- /**
34
- ---
35
- parent: Select
36
- id: Select.Group
37
- ---
38
- @module Group
39
- **/
40
- class Group extends _react.Component {
41
- /* istanbul ignore next */
42
- render() {
43
- // this component is only used for prop validation. Select.Group children
44
- // are parsed in Select and rendered as Options components
45
- return null;
46
- }
47
- }
48
- exports.Group = Group;
49
- Group.displayName = "Group";
50
- Group.componentId = 'Select.Group';
51
- Group.allowedProps = _props.allowedProps;
52
- Group.defaultProps = {};
53
- var _default = exports.default = Group;
@@ -1,57 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.Option = void 0;
7
- var _react = require("react");
8
- var _props = require("./props");
9
- /*
10
- * The MIT License (MIT)
11
- *
12
- * Copyright (c) 2015 - present Instructure, Inc.
13
- *
14
- * Permission is hereby granted, free of charge, to any person obtaining a copy
15
- * of this software and associated documentation files (the "Software"), to deal
16
- * in the Software without restriction, including without limitation the rights
17
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
- * copies of the Software, and to permit persons to whom the Software is
19
- * furnished to do so, subject to the following conditions:
20
- *
21
- * The above copyright notice and this permission notice shall be included in all
22
- * copies or substantial portions of the Software.
23
- *
24
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
- * SOFTWARE.
31
- */
32
-
33
- /**
34
- ---
35
- parent: Select
36
- id: Select.Option
37
- ---
38
- @module Option
39
- **/
40
- class Option extends _react.Component {
41
- /* istanbul ignore next */
42
- render() {
43
- // this component is only used for prop validation. Select.Option children
44
- // are parsed in Select and rendered as Options.Item components
45
- return null;
46
- }
47
- }
48
- exports.Option = Option;
49
- Option.displayName = "Option";
50
- Option.componentId = 'Select.Option';
51
- Option.allowedProps = _props.allowedProps;
52
- Option.defaultProps = {
53
- isHighlighted: false,
54
- isSelected: false,
55
- isDisabled: false
56
- };
57
- var _default = exports.default = Option;
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.allowedProps = void 0;
7
- /*
8
- * The MIT License (MIT)
9
- *
10
- * Copyright (c) 2015 - present Instructure, Inc.
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining a copy
13
- * of this software and associated documentation files (the "Software"), to deal
14
- * in the Software without restriction, including without limitation the rights
15
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- * copies of the Software, and to permit persons to whom the Software is
17
- * furnished to do so, subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all
20
- * copies or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- * SOFTWARE.
29
- */
30
-
31
- const allowedProps = exports.allowedProps = ['id', 'isHighlighted', 'isSelected', 'isDisabled', 'renderBeforeLabel', 'renderAfterLabel', 'children'];
@@ -1,693 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = exports.Select = void 0;
9
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
- var _react = require("react");
11
- var utils = _interopRequireWildcard(require("@instructure/ui-utils"));
12
- var _combineDataCid = require("@instructure/ui-utils/lib/combineDataCid.js");
13
- var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
14
- var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
15
- var _getInteraction = require("@instructure/ui-react-utils/lib/getInteraction.js");
16
- var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
17
- var _getBoundingClientRect = require("@instructure/ui-dom-utils/lib/getBoundingClientRect.js");
18
- var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
19
- var _View = require("@instructure/ui-view/lib/View");
20
- var _Selectable = require("@instructure/ui-selectable/lib/Selectable");
21
- var _Popover = require("@instructure/ui-popover/lib/Popover");
22
- var _TextInput = require("@instructure/ui-text-input/lib/TextInput");
23
- var _Options = require("@instructure/ui-options/lib/Options");
24
- var _IconArrowOpenDownLine = require("@instructure/ui-icons/lib/IconArrowOpenDownLine.js");
25
- var _IconArrowOpenUpLine2 = require("@instructure/ui-icons/lib/IconArrowOpenUpLine.js");
26
- var _emotion = require("@instructure/emotion");
27
- var _styles = _interopRequireDefault(require("./styles"));
28
- var _theme = _interopRequireDefault(require("./theme"));
29
- var _Group = require("./Group");
30
- var _Option = require("./Option");
31
- var _props = require("./props");
32
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
33
- const _excluded = ["id", "renderLabel", "children"],
34
- _excluded2 = ["renderLabel", "inputValue", "placeholder", "isRequired", "shouldNotWrap", "size", "isInline", "width", "htmlSize", "messages", "renderBeforeInput", "renderAfterInput", "onFocus", "onBlur", "onInputChange", "onRequestHideOptions", "layout"],
35
- _excluded3 = ["ref"];
36
- var _dec, _dec2, _class, _Select, _Options$Separator, _Options$Separator2, _IconArrowOpenUpLine, _IconArrowOpenDownLin;
37
- /*
38
- * The MIT License (MIT)
39
- *
40
- * Copyright (c) 2015 - present Instructure, Inc.
41
- *
42
- * Permission is hereby granted, free of charge, to any person obtaining a copy
43
- * of this software and associated documentation files (the "Software"), to deal
44
- * in the Software without restriction, including without limitation the rights
45
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
46
- * copies of the Software, and to permit persons to whom the Software is
47
- * furnished to do so, subject to the following conditions:
48
- *
49
- * The above copyright notice and this permission notice shall be included in all
50
- * copies or substantial portions of the Software.
51
- *
52
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
53
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
54
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
55
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
56
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
57
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
58
- * SOFTWARE.
59
- */
60
- // This memoed Option component is used to prevent unnecessary re-renders of
61
- // Options.Item when the Select component is re-rendered. This is necessary
62
- // because the Select component is re-rendered on every prop change of the <Select.Option>
63
- // and with a large amount of options, this can cause a lot of unnecessary re-renders.
64
- const MemoedOption = /*#__PURE__*/(0, _react.memo)(function Opt(props) {
65
- const optionsItemProps = props.optionsItemProps,
66
- children = props.children;
67
- return (
68
- // The main <Options> that renders this is always an "ul"
69
- (0, _jsxRuntime.jsx)(_Options.Options.Item, {
70
- as: "li",
71
- ...optionsItemProps,
72
- children: children
73
- })
74
- );
75
- },
76
- // This is a custom equality function that checks if the props of the
77
- // <Select.Option> have changed. If they haven't, then the Options.Item
78
- // doesn't need to be re-rendered.
79
- (prevProps, nextProps) => {
80
- return prevProps.selectOption.props.isHighlighted === nextProps.selectOption.props.isHighlighted && prevProps.selectOption.props.isSelected === nextProps.selectOption.props.isSelected && prevProps.selectOption.props.isDisabled === nextProps.selectOption.props.isDisabled && prevProps.selectOption.props.children === nextProps.selectOption.props.children && prevProps.selectOption.props.id === nextProps.selectOption.props.id && prevProps.selectOption.props.renderBeforeLabel === nextProps.selectOption.props.renderBeforeLabel && prevProps.selectOption.props.renderAfterLabel === nextProps.selectOption.props.renderAfterLabel && prevProps.children === nextProps.children;
81
- });
82
- // This is needed so the propTypes in <Options> check are correct
83
- MemoedOption.displayName = 'Item';
84
-
85
- /**
86
- ---
87
- category: components
88
- tags: autocomplete, typeahead, combobox, dropdown, search, form
89
- ---
90
- **/
91
- let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = _dec2(_class = (_Select = class Select extends _react.Component {
92
- constructor(...args) {
93
- super(...args);
94
- this.SCROLL_TOLERANCE = 0.5;
95
- this.state = {
96
- hasInputRef: false
97
- };
98
- this.ref = null;
99
- this._input = null;
100
- this._defaultId = this.props.deterministicId();
101
- this._inputContainer = null;
102
- this._listView = null;
103
- // temporarily stores actionable options
104
- this._optionIds = [];
105
- // best guess for first calculation of list height
106
- this._optionHeight = 36;
107
- this.handleInputRef = node => {
108
- var _this$props$inputRef, _this$props;
109
- // ensures list is positioned with respect to input if list is open on mount
110
- if (!this.state.hasInputRef) {
111
- this.setState({
112
- hasInputRef: true
113
- });
114
- }
115
- this._input = node;
116
- (_this$props$inputRef = (_this$props = this.props).inputRef) === null || _this$props$inputRef === void 0 ? void 0 : _this$props$inputRef.call(_this$props, node);
117
- };
118
- this.handleListRef = node => {
119
- var _this$props$listRef, _this$props2;
120
- (_this$props$listRef = (_this$props2 = this.props).listRef) === null || _this$props$listRef === void 0 ? void 0 : _this$props$listRef.call(_this$props2, node);
121
-
122
- // store option height to calculate list maxHeight
123
- if (node && node.querySelector('[role="option"]')) {
124
- this._optionHeight = node.querySelector('[role="option"]').offsetHeight;
125
- }
126
- };
127
- this.handleInputContainerRef = node => {
128
- this._inputContainer = node;
129
- };
130
- }
131
- componentDidMount() {
132
- var _this$props$makeStyle, _this$props3;
133
- (_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
134
- }
135
- componentDidUpdate() {
136
- var _this$props$makeStyle2, _this$props4;
137
- (_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4);
138
- if (this.props.scrollToHighlightedOption) {
139
- // scroll option into view if needed
140
- requestAnimationFrame(() => this.scrollToOption(this.highlightedOptionId));
141
- }
142
- }
143
- focus() {
144
- this._input && this._input.focus();
145
- }
146
- blur() {
147
- this._input && this._input.blur();
148
- }
149
- get childrenArray() {
150
- return _react.Children.toArray(this.props.children);
151
- }
152
- getGroupChildrenArray(group) {
153
- return _react.Children.toArray(group.props.children);
154
- }
155
- get focused() {
156
- return this._input ? (0, _isActiveElement.isActiveElement)(this._input) : false;
157
- }
158
- get id() {
159
- return this.props.id || this._defaultId;
160
- }
161
- get width() {
162
- return this._inputContainer ? this._inputContainer.offsetWidth : void 0;
163
- }
164
- get interaction() {
165
- return (0, _getInteraction.getInteraction)({
166
- props: this.props
167
- });
168
- }
169
- get highlightedOptionId() {
170
- let highlightedOptionId;
171
- this.childrenArray.forEach(child => {
172
- if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Group.Group])) {
173
- // group found
174
- this.getGroupChildrenArray(child).forEach(option => {
175
- // check options in group
176
- if (option.props.isHighlighted) {
177
- highlightedOptionId = option.props.id;
178
- }
179
- });
180
- } else {
181
- // ungrouped option found
182
- if (child.props.isHighlighted) {
183
- highlightedOptionId = child.props.id;
184
- }
185
- }
186
- });
187
- return highlightedOptionId;
188
- }
189
- get selectedOptionId() {
190
- const selectedOptionId = [];
191
- this.childrenArray.forEach(child => {
192
- if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Group.Group])) {
193
- // group found
194
- this.getGroupChildrenArray(child).forEach(option => {
195
- // check options in group
196
- if (option.props.isSelected) {
197
- selectedOptionId.push(option.props.id);
198
- }
199
- });
200
- } else {
201
- // ungrouped option found
202
- if (child.props.isSelected) {
203
- selectedOptionId.push(child.props.id);
204
- }
205
- }
206
- });
207
- if (selectedOptionId.length === 1) {
208
- return selectedOptionId[0];
209
- }
210
- if (selectedOptionId.length === 0) {
211
- return void 0;
212
- }
213
- return selectedOptionId;
214
- }
215
- scrollToOption(id) {
216
- if (!this._listView || !id) return;
217
- const option = this._listView.querySelector(`[id="${CSS.escape(id)}"]`);
218
- if (!option) return;
219
- const listItem = option.parentNode;
220
- const parentTop = (0, _getBoundingClientRect.getBoundingClientRect)(this._listView).top;
221
- const elemTop = (0, _getBoundingClientRect.getBoundingClientRect)(listItem).top;
222
- const parentBottom = parentTop + this._listView.clientHeight;
223
- const elemBottom = elemTop + (listItem ? listItem.clientHeight : 0);
224
- if (elemBottom > parentBottom) {
225
- this._listView.scrollTop += elemBottom - parentBottom;
226
- } else if (elemTop < parentTop) {
227
- this._listView.scrollTop -= parentTop - elemTop;
228
- }
229
- }
230
- highlightOption(event, id) {
231
- const onRequestHighlightOption = this.props.onRequestHighlightOption;
232
- if (id) {
233
- onRequestHighlightOption === null || onRequestHighlightOption === void 0 ? void 0 : onRequestHighlightOption(event, {
234
- id
235
- });
236
- }
237
- }
238
- getEventHandlers() {
239
- const _this$props5 = this.props,
240
- isShowingOptions = _this$props5.isShowingOptions,
241
- onRequestShowOptions = _this$props5.onRequestShowOptions,
242
- onRequestHideOptions = _this$props5.onRequestHideOptions,
243
- onRequestSelectOption = _this$props5.onRequestSelectOption;
244
- return this.interaction === 'enabled' ? {
245
- onRequestShowOptions: event => {
246
- onRequestShowOptions === null || onRequestShowOptions === void 0 ? void 0 : onRequestShowOptions(event);
247
- const selectedOptionId = this.selectedOptionId;
248
- if (selectedOptionId && !Array.isArray(selectedOptionId)) {
249
- // highlight selected option on show
250
- this.highlightOption(event, selectedOptionId);
251
- }
252
- },
253
- onRequestHideOptions: event => {
254
- onRequestHideOptions === null || onRequestHideOptions === void 0 ? void 0 : onRequestHideOptions(event);
255
- },
256
- onRequestHighlightOption: (event, {
257
- id,
258
- direction
259
- }) => {
260
- if (!isShowingOptions) return;
261
- const highlightedOptionId = this.highlightedOptionId;
262
- // if id exists, use that
263
- let highlightId = this._optionIds.indexOf(id) > -1 ? id : void 0;
264
- if (!highlightId) {
265
- if (!highlightedOptionId) {
266
- // nothing highlighted yet, highlight first option
267
- highlightId = this._optionIds[0];
268
- } else {
269
- // find next id based on direction
270
- const index = this._optionIds.indexOf(highlightedOptionId);
271
- highlightId = index > -1 ? this._optionIds[index + direction] : void 0;
272
- }
273
- }
274
- if (highlightId) {
275
- // only highlight if id exists as a valid option
276
- this.highlightOption(event, highlightId);
277
- }
278
- },
279
- onRequestHighlightFirstOption: event => {
280
- this.highlightOption(event, this._optionIds[0]);
281
- },
282
- onRequestHighlightLastOption: event => {
283
- this.highlightOption(event, this._optionIds[this._optionIds.length - 1]);
284
- },
285
- onRequestSelectOption: (event, {
286
- id
287
- }) => {
288
- if (id && this._optionIds.indexOf(id) !== -1) {
289
- // only select if id exists as a valid option
290
- onRequestSelectOption === null || onRequestSelectOption === void 0 ? void 0 : onRequestSelectOption(event, {
291
- id
292
- });
293
- }
294
- }
295
- } : {};
296
- }
297
- renderOption(option, data) {
298
- const getOptionProps = data.getOptionProps,
299
- getDisabledOptionProps = data.getDisabledOptionProps;
300
- const _option$props = option.props,
301
- id = _option$props.id,
302
- isDisabled = _option$props.isDisabled,
303
- isHighlighted = _option$props.isHighlighted,
304
- isSelected = _option$props.isSelected,
305
- renderBeforeLabel = _option$props.renderBeforeLabel,
306
- renderAfterLabel = _option$props.renderAfterLabel,
307
- children = _option$props.children;
308
- const getRenderOptionLabel = renderOptionLabel => {
309
- var _renderOptionLabel$pr;
310
- return typeof renderOptionLabel === 'function' && !(renderOptionLabel !== null && renderOptionLabel !== void 0 && (_renderOptionLabel$pr = renderOptionLabel.prototype) !== null && _renderOptionLabel$pr !== void 0 && _renderOptionLabel$pr.isReactComponent) ? renderOptionLabel.bind(null, {
311
- id,
312
- isDisabled,
313
- isSelected,
314
- isHighlighted,
315
- children
316
- }) : renderOptionLabel;
317
- };
318
- let optionProps = {
319
- // passthrough props
320
- ...(0, _omitProps.omitProps)(option.props, [..._Option.Option.allowedProps, ..._Options.Options.Item.allowedProps]),
321
- // props from selectable
322
- ...getOptionProps({
323
- id
324
- }),
325
- // Options.Item props
326
- renderBeforeLabel: getRenderOptionLabel(renderBeforeLabel),
327
- renderAfterLabel: getRenderOptionLabel(renderAfterLabel)
328
- };
329
- // should option be treated as highlighted or selected
330
- if (isSelected && isHighlighted) {
331
- optionProps.variant = 'selected-highlighted';
332
- optionProps.isSelected = true;
333
- } else if (isSelected) {
334
- optionProps.variant = 'selected';
335
- optionProps.isSelected = true;
336
- } else if (isHighlighted) {
337
- optionProps.variant = 'highlighted';
338
- }
339
- // should option be treated as disabled
340
- if (isDisabled) {
341
- optionProps.variant = 'disabled';
342
- optionProps = {
343
- ...optionProps,
344
- ...getDisabledOptionProps()
345
- };
346
- } else {
347
- // track as valid option if not disabled
348
- this._optionIds.push(id);
349
- }
350
- return (0, _jsxRuntime.jsx)(MemoedOption, {
351
- optionsItemProps: optionProps,
352
- selectOption: option,
353
- children: children
354
- });
355
- }
356
- renderGroup(group, data) {
357
- const getOptionProps = data.getOptionProps,
358
- getDisabledOptionProps = data.getDisabledOptionProps,
359
- isFirstChild = data.isFirstChild,
360
- isLastChild = data.isLastChild,
361
- afterGroup = data.afterGroup;
362
- const _group$props = group.props,
363
- id = _group$props.id,
364
- renderLabel = _group$props.renderLabel,
365
- children = _group$props.children,
366
- rest = (0, _objectWithoutProperties2.default)(_group$props, _excluded);
367
- const groupChildren = [];
368
- // add a separator above
369
- if (!isFirstChild && !afterGroup) {
370
- groupChildren.push(_Options$Separator || (_Options$Separator = (0, _jsxRuntime.jsx)(_Options.Options.Separator, {})));
371
- }
372
- // create a sublist as a group
373
- // a wrapping listitem will be created by Options
374
- groupChildren.push((0, _jsxRuntime.jsx)(_Options.Options, {
375
- id: id,
376
- as: "ul",
377
- role: "group",
378
- renderLabel: renderLabel,
379
- ...(0, _omitProps.omitProps)(rest, [..._Options.Options.allowedProps, ..._Group.Group.allowedProps]),
380
- children: _react.Children.map(children, child => {
381
- return this.renderOption(child, {
382
- getOptionProps,
383
- getDisabledOptionProps
384
- });
385
- })
386
- }));
387
- // add a separator below
388
- if (!isLastChild) {
389
- groupChildren.push(_Options$Separator2 || (_Options$Separator2 = (0, _jsxRuntime.jsx)(_Options.Options.Separator, {})));
390
- }
391
- return groupChildren;
392
- }
393
- renderList(data) {
394
- const getListProps = data.getListProps,
395
- getOptionProps = data.getOptionProps,
396
- getDisabledOptionProps = data.getDisabledOptionProps;
397
- const _this$props6 = this.props,
398
- isShowingOptions = _this$props6.isShowingOptions,
399
- optionsMaxWidth = _this$props6.optionsMaxWidth,
400
- optionsMaxHeight = _this$props6.optionsMaxHeight,
401
- visibleOptionsCount = _this$props6.visibleOptionsCount,
402
- children = _this$props6.children;
403
- let lastWasGroup = false;
404
- const viewProps = isShowingOptions ? {
405
- display: 'block',
406
- overflowY: 'auto',
407
- maxHeight: optionsMaxHeight || this._optionHeight * visibleOptionsCount - (
408
- // in Chrome, we need to prevent scrolling when the bottom area of last item is hovered
409
- utils.isChromium() ? this.SCROLL_TOLERANCE : 0),
410
- maxWidth: optionsMaxWidth || this.width,
411
- background: 'primary',
412
- elementRef: node => this._listView = node,
413
- borderRadius: 'medium'
414
- } : {
415
- maxHeight: 0
416
- };
417
- return (0, _jsxRuntime.jsx)(_View.View, {
418
- ...viewProps,
419
- children: (0, _jsxRuntime.jsx)(_Options.Options, {
420
- ...getListProps({
421
- as: 'ul',
422
- elementRef: this.handleListRef
423
- }),
424
- children: isShowingOptions ? _react.Children.map(children, (child, index) => {
425
- if (!child || !(0, _matchComponentTypes.matchComponentTypes)(child, [_Group.Group, _Option.Option])) {
426
- return; // ignore invalid children
427
- }
428
- if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Option.Option])) {
429
- lastWasGroup = false;
430
- return this.renderOption(child, {
431
- getOptionProps,
432
- getDisabledOptionProps
433
- });
434
- }
435
- if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Group.Group])) {
436
- const afterGroup = lastWasGroup;
437
- lastWasGroup = true;
438
- return this.renderGroup(child, {
439
- getOptionProps,
440
- getDisabledOptionProps,
441
- // for rendering separators appropriately
442
- isFirstChild: index === 0,
443
- isLastChild: index === _react.Children.count(children) - 1,
444
- afterGroup
445
- });
446
- }
447
- return;
448
- }) : null
449
- })
450
- });
451
- }
452
- renderIcon() {
453
- const _this$props7 = this.props,
454
- styles = _this$props7.styles,
455
- isShowingOptions = _this$props7.isShowingOptions;
456
- return (0, _jsxRuntime.jsx)("span", {
457
- css: styles === null || styles === void 0 ? void 0 : styles.icon,
458
- children: isShowingOptions ? _IconArrowOpenUpLine || (_IconArrowOpenUpLine = (0, _jsxRuntime.jsx)(_IconArrowOpenUpLine2.IconArrowOpenUpLine, {
459
- inline: false
460
- })) : _IconArrowOpenDownLin || (_IconArrowOpenDownLin = (0, _jsxRuntime.jsx)(_IconArrowOpenDownLine.IconArrowOpenDownLine, {
461
- inline: false
462
- }))
463
- });
464
- }
465
- renderContentBeforeOrAfterInput(position) {
466
- for (const child of this.childrenArray) {
467
- if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Group.Group])) {
468
- // Group found
469
- const options = this.getGroupChildrenArray(child);
470
- for (const option of options) {
471
- if (option.props.isSelected) {
472
- return position === 'before' ? option.props.renderBeforeLabel : option.props.renderAfterLabel ? option.props.renderAfterLabel : this.renderIcon();
473
- }
474
- }
475
- } else {
476
- // Ungrouped option found
477
- if (child.props.isSelected) {
478
- return position === 'before' ? child.props.renderBeforeLabel : child.props.renderAfterLabel ? child.props.renderAfterLabel : this.renderIcon();
479
- }
480
- }
481
- }
482
- // if no option with isSelected is found
483
- if (position === 'after') {
484
- return this.renderIcon();
485
- }
486
- return void 0;
487
- }
488
- handleInputContentRender(renderLabelInput, inputValue, isOptionContentAppliedToInput, position, defaultReturn) {
489
- const isInputValueEmpty = !inputValue || inputValue === '';
490
- if (renderLabelInput && isOptionContentAppliedToInput) {
491
- if (!isInputValueEmpty) {
492
- return this.renderContentBeforeOrAfterInput(position);
493
- }
494
- return renderLabelInput;
495
- }
496
- if (isOptionContentAppliedToInput) {
497
- if (isInputValueEmpty) {
498
- return defaultReturn;
499
- }
500
- return this.renderContentBeforeOrAfterInput(position);
501
- }
502
- if (renderLabelInput) {
503
- return renderLabelInput;
504
- }
505
- return defaultReturn;
506
- }
507
- handleRenderBeforeInput() {
508
- const _this$props8 = this.props,
509
- renderBeforeInput = _this$props8.renderBeforeInput,
510
- inputValue = _this$props8.inputValue,
511
- isOptionContentAppliedToInput = _this$props8.isOptionContentAppliedToInput;
512
- return this.handleInputContentRender(renderBeforeInput, inputValue, isOptionContentAppliedToInput, 'before', null // default for before
513
- );
514
- }
515
- handleRenderAfterInput() {
516
- const _this$props9 = this.props,
517
- renderAfterInput = _this$props9.renderAfterInput,
518
- inputValue = _this$props9.inputValue,
519
- isOptionContentAppliedToInput = _this$props9.isOptionContentAppliedToInput;
520
- return this.handleInputContentRender(renderAfterInput, inputValue, isOptionContentAppliedToInput, 'after', this.renderIcon() // default for after
521
- );
522
- }
523
- renderInput(data) {
524
- const getInputProps = data.getInputProps,
525
- getTriggerProps = data.getTriggerProps;
526
- const _this$props0 = this.props,
527
- renderLabel = _this$props0.renderLabel,
528
- inputValue = _this$props0.inputValue,
529
- placeholder = _this$props0.placeholder,
530
- isRequired = _this$props0.isRequired,
531
- shouldNotWrap = _this$props0.shouldNotWrap,
532
- size = _this$props0.size,
533
- isInline = _this$props0.isInline,
534
- width = _this$props0.width,
535
- htmlSize = _this$props0.htmlSize,
536
- messages = _this$props0.messages,
537
- renderBeforeInput = _this$props0.renderBeforeInput,
538
- renderAfterInput = _this$props0.renderAfterInput,
539
- onFocus = _this$props0.onFocus,
540
- onBlur = _this$props0.onBlur,
541
- onInputChange = _this$props0.onInputChange,
542
- onRequestHideOptions = _this$props0.onRequestHideOptions,
543
- layout = _this$props0.layout,
544
- rest = (0, _objectWithoutProperties2.default)(_this$props0, _excluded2);
545
- const interaction = this.interaction;
546
- const passthroughProps = (0, _omitProps.omitProps)(rest, Select.allowedProps);
547
- const _getTriggerProps = getTriggerProps({
548
- ...passthroughProps
549
- }),
550
- ref = _getTriggerProps.ref,
551
- triggerProps = (0, _objectWithoutProperties2.default)(_getTriggerProps, _excluded3);
552
- const isEditable = typeof onInputChange !== 'undefined';
553
-
554
- // props to ensure screen readers treat uneditable selects as accessible
555
- // popup buttons rather than comboboxes.
556
- const overrideProps = !isEditable ? {
557
- // We need role="combobox" for the 'open list' button shortcut to work
558
- // with desktop screenreaders.
559
- // But desktop Safari with Voiceover does not support proper combobox
560
- // handling, a 'button' role is set as a workaround.
561
- // See https://bugs.webkit.org/show_bug.cgi?id=236881
562
- // Also on iOS Chrome with role='combobox' it announces unnecessarily
563
- // that its 'read-only' and that this is a 'textfield', see INSTUI-4500
564
- role: utils.isSafari() || utils.isAndroidOrIOS() || interaction === 'disabled' && utils.isChromium() ? 'button' : 'combobox',
565
- title: inputValue,
566
- 'aria-autocomplete': void 0,
567
- 'aria-readonly': true
568
- } : interaction === 'disabled' && utils.isChromium() ? {
569
- role: 'button'
570
- } : {};
571
-
572
- // backdoor to autocomplete attr to work around chrome autofill issues
573
- if (passthroughProps['autoComplete']) {
574
- overrideProps.autoComplete = passthroughProps['autoComplete'];
575
- }
576
- const inputProps = {
577
- id: this.id,
578
- renderLabel,
579
- placeholder,
580
- size,
581
- width,
582
- htmlSize,
583
- messages,
584
- value: inputValue,
585
- inputRef: utils.createChainedFunction(ref, this.handleInputRef),
586
- inputContainerRef: this.handleInputContainerRef,
587
- interaction: interaction === 'enabled' && !isEditable ? 'readonly' // prevent keyboard cursor
588
- : interaction,
589
- isRequired,
590
- shouldNotWrap,
591
- layout,
592
- display: isInline ? 'inline-block' : 'block',
593
- renderBeforeInput: this.handleRenderBeforeInput(),
594
- // On iOS VoiceOver, if there is a custom element instead of the changing up and down arrow button
595
- // the listbox closes on a swipe, so a DOM change is enforced by the key change
596
- // that seems to inform VoiceOver to behave the correct way
597
- renderAfterInput: utils.isAndroidOrIOS() && renderAfterInput !== void 0 ? (0, _jsxRuntime.jsx)("span", {
598
- children: this.handleRenderAfterInput()
599
- }, this.props.isShowingOptions ? 'open' : 'closed') : this.handleRenderAfterInput(),
600
- // If `inputValue` is provided, we need to pass a default onChange handler,
601
- // because TextInput `value` is a controlled prop,
602
- // and onChange is not required for Select
603
- // (before it was handled by TextInput's defaultProp)
604
- onChange: typeof onInputChange === 'function' ? onInputChange : inputValue ? () => {} : void 0,
605
- onFocus,
606
- onBlur: utils.createChainedFunction(onBlur, onRequestHideOptions),
607
- ...overrideProps
608
- };
609
- // suppressHydrationWarning is needed because `role` depends on the browser type
610
- return (0, _jsxRuntime.jsx)(_TextInput.TextInput, {
611
- ...triggerProps,
612
- ...getInputProps(inputProps),
613
- suppressHydrationWarning: true
614
- });
615
- }
616
- render() {
617
- const _this$props1 = this.props,
618
- constrain = _this$props1.constrain,
619
- placement = _this$props1.placement,
620
- mountNode = _this$props1.mountNode,
621
- assistiveText = _this$props1.assistiveText,
622
- isShowingOptions = _this$props1.isShowingOptions,
623
- styles = _this$props1.styles;
624
- // clear temporary option store
625
- this._optionIds = [];
626
- const highlightedOptionId = this.highlightedOptionId;
627
- const selectedOptionId = this.selectedOptionId;
628
- return (0, _jsxRuntime.jsx)(_Selectable.Selectable, {
629
- highlightedOptionId: highlightedOptionId,
630
- isShowingOptions: isShowingOptions,
631
- selectedOptionId: selectedOptionId,
632
- ...this.getEventHandlers(),
633
- children: ({
634
- getRootProps,
635
- getInputProps,
636
- getTriggerProps,
637
- getListProps,
638
- getOptionProps,
639
- getDisabledOptionProps,
640
- getDescriptionProps
641
- }) => (0, _jsxRuntime.jsxs)("span", {
642
- ...getRootProps({
643
- css: styles === null || styles === void 0 ? void 0 : styles.select
644
- }),
645
- ref: el => {
646
- this.ref = el;
647
- },
648
- "data-cid": (0, _combineDataCid.combineDataCid)('Select', this.props),
649
- children: [this.renderInput({
650
- getInputProps,
651
- getTriggerProps
652
- }), (0, _jsxRuntime.jsx)("span", {
653
- ...getDescriptionProps(),
654
- css: styles === null || styles === void 0 ? void 0 : styles.assistiveText,
655
- children: assistiveText
656
- }), (0, _jsxRuntime.jsx)(_Popover.Popover, {
657
- constrain: constrain,
658
- placement: placement
659
- // On iOS VoiceOver, the Popover is mounted right after the input
660
- // in order to be able to navigate through the list items with a swipe.
661
- // The swipe would result in closing the listbox if mounted elsewhere.
662
- ,
663
- mountNode: mountNode !== void 0 ? mountNode : utils.isAndroidOrIOS() ? this.ref : void 0,
664
- positionTarget: this._inputContainer,
665
- isShowingContent: isShowingOptions,
666
- shouldReturnFocus: false,
667
- withArrow: false,
668
- borderWidth: styles === null || styles === void 0 ? void 0 : styles.popoverBorderWidth,
669
- children: this.renderList({
670
- getListProps,
671
- getOptionProps,
672
- getDisabledOptionProps
673
- })
674
- })]
675
- })
676
- });
677
- }
678
- }, _Select.displayName = "Select", _Select.componentId = 'Select', _Select.allowedProps = _props.allowedProps, _Select.defaultProps = {
679
- inputValue: '',
680
- isShowingOptions: false,
681
- size: 'medium',
682
- // Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
683
- interaction: void 0,
684
- isRequired: false,
685
- isInline: false,
686
- visibleOptionsCount: 8,
687
- placement: 'bottom stretch',
688
- constrain: 'window',
689
- shouldNotWrap: false,
690
- scrollToHighlightedOption: true,
691
- isOptionContentAppliedToInput: false
692
- }, _Select.Option = _Option.Option, _Select.Group = _Group.Group, _Select)) || _class) || _class);
693
- var _default = exports.default = Select;
@@ -1,40 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.allowedProps = void 0;
7
- /*
8
- * The MIT License (MIT)
9
- *
10
- * Copyright (c) 2015 - present Instructure, Inc.
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining a copy
13
- * of this software and associated documentation files (the "Software"), to deal
14
- * in the Software without restriction, including without limitation the rights
15
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- * copies of the Software, and to permit persons to whom the Software is
17
- * furnished to do so, subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all
20
- * copies or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- * SOFTWARE.
29
- */
30
-
31
- // These props are directly passed to Selectable
32
- // TODO: import these from Selectable once TS types can be imported
33
-
34
- // These props are directly passed to TextInput
35
- // TODO: import these from TextInput once TS types can be imported
36
-
37
- // These props are directly passed to Popover
38
- // TODO: import these from Popover once TS types can be imported
39
-
40
- const allowedProps = exports.allowedProps = ['renderLabel', 'inputValue', 'isShowingOptions', 'id', 'size', 'assistiveText', 'placeholder', 'interaction', 'isRequired', 'isInline', 'width', 'htmlSize', 'visibleOptionsCount', 'isOptionContentAppliedToInput', 'optionsMaxHeight', 'optionsMaxWidth', 'messages', 'placement', 'constrain', 'mountNode', 'onFocus', 'onBlur', 'onInputChange', 'onRequestShowOptions', 'onRequestHideOptions', 'onRequestHighlightOption', 'onRequestSelectOption', 'inputRef', 'listRef', 'renderBeforeInput', 'renderAfterInput', 'children', 'shouldNotWrap', 'scrollToHighlightedOption', 'layout'];
@@ -1,70 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- /*
8
- * The MIT License (MIT)
9
- *
10
- * Copyright (c) 2015 - present Instructure, Inc.
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining a copy
13
- * of this software and associated documentation files (the "Software"), to deal
14
- * in the Software without restriction, including without limitation the rights
15
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- * copies of the Software, and to permit persons to whom the Software is
17
- * furnished to do so, subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all
20
- * copies or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- * SOFTWARE.
29
- */
30
-
31
- /**
32
- * Generates the style object from the theme and provided additional information
33
- * @param {Object} componentTheme The theme variable object.
34
- * @param {Object} props the props of the component, the style is applied to
35
- * @param {Object} state the state of the component, the style is applied to
36
- * @return {Object} The final style object, which will be used in the component
37
- */
38
- const generateStyle = (componentTheme, props) => {
39
- const size = props.size;
40
- const iconSizeVariants = {
41
- small: {
42
- fontSize: componentTheme.smallIconSize
43
- },
44
- medium: {
45
- fontSize: componentTheme.mediumIconSize
46
- },
47
- large: {
48
- fontSize: componentTheme.largeIconSize
49
- }
50
- };
51
- return {
52
- select: {
53
- label: 'select',
54
- fontSize: componentTheme.fontSize,
55
- fontFamily: componentTheme.fontFamily,
56
- fontWeight: componentTheme.fontWeight,
57
- color: componentTheme.color
58
- },
59
- icon: {
60
- label: 'select__icon',
61
- ...iconSizeVariants[size]
62
- },
63
- assistiveText: {
64
- label: 'select__assistiveText',
65
- display: 'none'
66
- },
67
- popoverBorderWidth: componentTheme.popoverBorderWidth
68
- };
69
- };
70
- var _default = exports.default = generateStyle;
@@ -1,55 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- /*
8
- * The MIT License (MIT)
9
- *
10
- * Copyright (c) 2015 - present Instructure, Inc.
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining a copy
13
- * of this software and associated documentation files (the "Software"), to deal
14
- * in the Software without restriction, including without limitation the rights
15
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- * copies of the Software, and to permit persons to whom the Software is
17
- * furnished to do so, subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all
20
- * copies or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- * SOFTWARE.
29
- */
30
-
31
- /**
32
- * Generates the theme object for the component from the theme and provided additional information
33
- * @param {Object} theme The actual theme object.
34
- * @return {Object} The final theme object with the overrides and component variables
35
- */
36
- const generateComponentTheme = theme => {
37
- var _colors$contrasts, _colors$contrasts2;
38
- const colors = theme.colors,
39
- typography = theme.typography;
40
- const componentVariables = {
41
- fontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeMedium,
42
- fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
43
- fontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightNormal,
44
- smallIconSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeXSmall,
45
- mediumIconSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeSmall,
46
- largeIconSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeMedium,
47
- color: colors === null || colors === void 0 ? void 0 : (_colors$contrasts = colors.contrasts) === null || _colors$contrasts === void 0 ? void 0 : _colors$contrasts.grey125125,
48
- background: colors === null || colors === void 0 ? void 0 : (_colors$contrasts2 = colors.contrasts) === null || _colors$contrasts2 === void 0 ? void 0 : _colors$contrasts2.white1010,
49
- popoverBorderWidth: 'small'
50
- };
51
- return {
52
- ...componentVariables
53
- };
54
- };
55
- var _default = exports.default = generateComponentTheme;
package/lib/index.js DELETED
@@ -1,26 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "Select", {
7
- enumerable: true,
8
- get: function () {
9
- return _Select.Select;
10
- }
11
- });
12
- Object.defineProperty(exports, "SelectGroup", {
13
- enumerable: true,
14
- get: function () {
15
- return _Group.Group;
16
- }
17
- });
18
- Object.defineProperty(exports, "SelectOption", {
19
- enumerable: true,
20
- get: function () {
21
- return _Option.Option;
22
- }
23
- });
24
- var _Select = require("./Select");
25
- var _Group = require("./Select/Group");
26
- var _Option = require("./Select/Option");
package/lib/package.json DELETED
@@ -1 +0,0 @@
1
- {"type":"commonjs"}