@instructure/ui-select 10.16.1-snapshot-0 → 10.16.1-snapshot-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 +1 -1
- package/es/Select/__new-tests__/Select.test.js +279 -221
- package/es/Select/index.js +110 -88
- package/lib/Select/__new-tests__/Select.test.js +278 -221
- package/lib/Select/index.js +109 -87
- package/package.json +23 -23
- package/src/Select/__new-tests__/Select.test.tsx +5 -4
- package/src/Select/index.tsx +4 -5
- package/src/Select/props.ts +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Select/__new-tests__/Select.test.d.ts.map +1 -1
- package/types/Select/index.d.ts +13 -15
- package/types/Select/index.d.ts.map +1 -1
- package/types/Select/props.d.ts +1 -1
- package/types/Select/props.d.ts.map +1 -1
package/es/Select/index.js
CHANGED
|
@@ -27,8 +27,7 @@ var _dec, _dec2, _dec3, _class, _Select, _Options$Separator, _Options$Separator2
|
|
|
27
27
|
* SOFTWARE.
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
import React, { Children, Component, memo } from 'react';
|
|
30
|
+
import { Children, Component, memo } from 'react';
|
|
32
31
|
import * as utils from '@instructure/ui-utils';
|
|
33
32
|
import { testable } from '@instructure/ui-testable';
|
|
34
33
|
import { matchComponentTypes, omitProps, getInteraction, withDeterministicId } from '@instructure/ui-react-utils';
|
|
@@ -39,12 +38,13 @@ import { Popover } from '@instructure/ui-popover';
|
|
|
39
38
|
import { TextInput } from '@instructure/ui-text-input';
|
|
40
39
|
import { Options } from '@instructure/ui-options';
|
|
41
40
|
import { IconArrowOpenDownLine, IconArrowOpenUpLine } from '@instructure/ui-icons';
|
|
42
|
-
import { withStyle
|
|
41
|
+
import { withStyle } from '@instructure/emotion';
|
|
43
42
|
import generateStyle from './styles';
|
|
44
43
|
import generateComponentTheme from './theme';
|
|
45
44
|
import { Group } from './Group';
|
|
46
45
|
import { Option } from './Option';
|
|
47
46
|
import { allowedProps, propTypes } from './props';
|
|
47
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
48
48
|
// This memoed Option component is used to prevent unnecessary re-renders of
|
|
49
49
|
// Options.Item when the Select component is re-rendered. This is necessary
|
|
50
50
|
// because the Select component is re-rendered on every prop change of the <Select.Option>
|
|
@@ -54,9 +54,11 @@ const MemoedOption = /*#__PURE__*/memo(function Opt(props) {
|
|
|
54
54
|
children = props.children;
|
|
55
55
|
return (
|
|
56
56
|
// The main <Options> that renders this is always an "ul"
|
|
57
|
-
|
|
58
|
-
as: "li"
|
|
59
|
-
|
|
57
|
+
_jsx(Options.Item, {
|
|
58
|
+
as: "li",
|
|
59
|
+
...optionsItemProps,
|
|
60
|
+
children: children
|
|
61
|
+
})
|
|
60
62
|
);
|
|
61
63
|
},
|
|
62
64
|
// This is a custom equality function that checks if the props of the
|
|
@@ -327,10 +329,11 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
327
329
|
// track as valid option if not disabled
|
|
328
330
|
this._optionIds.push(id);
|
|
329
331
|
}
|
|
330
|
-
return
|
|
332
|
+
return _jsx(MemoedOption, {
|
|
331
333
|
optionsItemProps: optionProps,
|
|
332
|
-
selectOption: option
|
|
333
|
-
|
|
334
|
+
selectOption: option,
|
|
335
|
+
children: children
|
|
336
|
+
});
|
|
334
337
|
}
|
|
335
338
|
renderGroup(group, data) {
|
|
336
339
|
const getOptionProps = data.getOptionProps,
|
|
@@ -346,24 +349,26 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
346
349
|
const groupChildren = [];
|
|
347
350
|
// add a separator above
|
|
348
351
|
if (!isFirstChild && !afterGroup) {
|
|
349
|
-
groupChildren.push(_Options$Separator || (_Options$Separator =
|
|
352
|
+
groupChildren.push(_Options$Separator || (_Options$Separator = _jsx(Options.Separator, {})));
|
|
350
353
|
}
|
|
351
354
|
// create a sublist as a group
|
|
352
355
|
// a wrapping listitem will be created by Options
|
|
353
|
-
groupChildren.push(
|
|
356
|
+
groupChildren.push(_jsx(Options, {
|
|
354
357
|
id: id,
|
|
355
358
|
as: "ul",
|
|
356
359
|
role: "group",
|
|
357
|
-
renderLabel: renderLabel
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
360
|
+
renderLabel: renderLabel,
|
|
361
|
+
...omitProps(rest, [...Options.allowedProps, ...Group.allowedProps]),
|
|
362
|
+
children: Children.map(children, child => {
|
|
363
|
+
return this.renderOption(child, {
|
|
364
|
+
getOptionProps,
|
|
365
|
+
getDisabledOptionProps
|
|
366
|
+
});
|
|
367
|
+
})
|
|
368
|
+
}));
|
|
364
369
|
// add a separator below
|
|
365
370
|
if (!isLastChild) {
|
|
366
|
-
groupChildren.push(_Options$Separator2 || (_Options$Separator2 =
|
|
371
|
+
groupChildren.push(_Options$Separator2 || (_Options$Separator2 = _jsx(Options.Separator, {})));
|
|
367
372
|
}
|
|
368
373
|
return groupChildren;
|
|
369
374
|
}
|
|
@@ -389,46 +394,53 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
389
394
|
} : {
|
|
390
395
|
maxHeight: 0
|
|
391
396
|
};
|
|
392
|
-
return
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
397
|
+
return _jsx(View, {
|
|
398
|
+
...viewProps,
|
|
399
|
+
children: _jsx(Options, {
|
|
400
|
+
...getListProps({
|
|
401
|
+
as: 'ul',
|
|
402
|
+
elementRef: this.handleListRef
|
|
403
|
+
}),
|
|
404
|
+
children: isShowingOptions ? Children.map(children, (child, index) => {
|
|
405
|
+
if (!child || !matchComponentTypes(child, [Group, Option])) {
|
|
406
|
+
return; // ignore invalid children
|
|
407
|
+
}
|
|
408
|
+
if (matchComponentTypes(child, [Option])) {
|
|
409
|
+
lastWasGroup = false;
|
|
410
|
+
return this.renderOption(child, {
|
|
411
|
+
getOptionProps,
|
|
412
|
+
getDisabledOptionProps
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
if (matchComponentTypes(child, [Group])) {
|
|
416
|
+
const afterGroup = lastWasGroup;
|
|
417
|
+
lastWasGroup = true;
|
|
418
|
+
return this.renderGroup(child, {
|
|
419
|
+
getOptionProps,
|
|
420
|
+
getDisabledOptionProps,
|
|
421
|
+
// for rendering separators appropriately
|
|
422
|
+
isFirstChild: index === 0,
|
|
423
|
+
isLastChild: index === Children.count(children) - 1,
|
|
424
|
+
afterGroup
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
return;
|
|
428
|
+
}) : null
|
|
429
|
+
})
|
|
430
|
+
});
|
|
420
431
|
}
|
|
421
432
|
renderIcon() {
|
|
422
433
|
const _this$props7 = this.props,
|
|
423
434
|
styles = _this$props7.styles,
|
|
424
435
|
isShowingOptions = _this$props7.isShowingOptions;
|
|
425
|
-
return
|
|
426
|
-
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
436
|
+
return _jsx("span", {
|
|
437
|
+
css: styles === null || styles === void 0 ? void 0 : styles.icon,
|
|
438
|
+
children: isShowingOptions ? _IconArrowOpenUpLine || (_IconArrowOpenUpLine = _jsx(IconArrowOpenUpLine, {
|
|
439
|
+
inline: false
|
|
440
|
+
})) : _IconArrowOpenDownLin || (_IconArrowOpenDownLin = _jsx(IconArrowOpenDownLine, {
|
|
441
|
+
inline: false
|
|
442
|
+
}))
|
|
443
|
+
});
|
|
432
444
|
}
|
|
433
445
|
renderContentBeforeOrAfterInput(position) {
|
|
434
446
|
for (const child of this.childrenArray) {
|
|
@@ -565,7 +577,10 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
565
577
|
onBlur: utils.createChainedFunction(onBlur, onRequestHideOptions),
|
|
566
578
|
...overrideProps
|
|
567
579
|
};
|
|
568
|
-
return
|
|
580
|
+
return _jsx(TextInput, {
|
|
581
|
+
...triggerProps,
|
|
582
|
+
...getInputProps(inputProps)
|
|
583
|
+
});
|
|
569
584
|
}
|
|
570
585
|
render() {
|
|
571
586
|
const _this$props11 = this.props,
|
|
@@ -579,41 +594,48 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
579
594
|
this._optionIds = [];
|
|
580
595
|
const highlightedOptionId = this.highlightedOptionId;
|
|
581
596
|
const selectedOptionId = this.selectedOptionId;
|
|
582
|
-
return
|
|
597
|
+
return _jsx(Selectable, {
|
|
583
598
|
highlightedOptionId: highlightedOptionId,
|
|
584
599
|
isShowingOptions: isShowingOptions,
|
|
585
|
-
selectedOptionId: selectedOptionId
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
600
|
+
selectedOptionId: selectedOptionId,
|
|
601
|
+
...this.getEventHandlers(),
|
|
602
|
+
children: ({
|
|
603
|
+
getRootProps,
|
|
604
|
+
getInputProps,
|
|
605
|
+
getTriggerProps,
|
|
606
|
+
getListProps,
|
|
607
|
+
getOptionProps,
|
|
608
|
+
getDisabledOptionProps,
|
|
609
|
+
getDescriptionProps
|
|
610
|
+
}) => _jsxs("span", {
|
|
611
|
+
...getRootProps({
|
|
612
|
+
css: styles === null || styles === void 0 ? void 0 : styles.select
|
|
613
|
+
}),
|
|
614
|
+
ref: el => this.ref = el,
|
|
615
|
+
children: [this.renderInput({
|
|
616
|
+
getInputProps,
|
|
617
|
+
getTriggerProps
|
|
618
|
+
}), _jsx("span", {
|
|
619
|
+
...getDescriptionProps(),
|
|
620
|
+
css: styles === null || styles === void 0 ? void 0 : styles.assistiveText,
|
|
621
|
+
children: assistiveText
|
|
622
|
+
}), _jsx(Popover, {
|
|
623
|
+
constrain: constrain,
|
|
624
|
+
placement: placement,
|
|
625
|
+
mountNode: mountNode,
|
|
626
|
+
positionTarget: this._inputContainer,
|
|
627
|
+
isShowingContent: isShowingOptions,
|
|
628
|
+
shouldReturnFocus: false,
|
|
629
|
+
withArrow: false,
|
|
630
|
+
borderWidth: styles === null || styles === void 0 ? void 0 : styles.popoverBorderWidth,
|
|
631
|
+
children: this.renderList({
|
|
632
|
+
getListProps,
|
|
633
|
+
getOptionProps,
|
|
634
|
+
getDisabledOptionProps
|
|
635
|
+
})
|
|
636
|
+
})]
|
|
637
|
+
})
|
|
638
|
+
});
|
|
617
639
|
}
|
|
618
640
|
}, _Select.displayName = "Select", _Select.componentId = 'Select', _Select.allowedProps = allowedProps, _Select.propTypes = propTypes, _Select.defaultProps = {
|
|
619
641
|
inputValue: '',
|