@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.
@@ -27,8 +27,7 @@ var _dec, _dec2, _dec3, _class, _Select, _Options$Separator, _Options$Separator2
27
27
  * SOFTWARE.
28
28
  */
29
29
 
30
- /** @jsx jsx */
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, jsx } from '@instructure/emotion';
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
- jsx(Options.Item, Object.assign({
58
- as: "li"
59
- }, optionsItemProps), children)
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 jsx(MemoedOption, {
332
+ return _jsx(MemoedOption, {
331
333
  optionsItemProps: optionProps,
332
- selectOption: option
333
- }, children);
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 = jsx(Options.Separator, null)));
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(jsx(Options, Object.assign({
356
+ groupChildren.push(_jsx(Options, {
354
357
  id: id,
355
358
  as: "ul",
356
359
  role: "group",
357
- renderLabel: renderLabel
358
- }, omitProps(rest, [...Options.allowedProps, ...Group.allowedProps])), Children.map(children, child => {
359
- return this.renderOption(child, {
360
- getOptionProps,
361
- getDisabledOptionProps
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 = jsx(Options.Separator, null)));
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 jsx(View, viewProps, jsx(Options, getListProps({
393
- as: 'ul',
394
- elementRef: this.handleListRef
395
- }), isShowingOptions ? Children.map(children, (child, index) => {
396
- if (!child || !matchComponentTypes(child, [Group, Option])) {
397
- return; // ignore invalid children
398
- }
399
- if (matchComponentTypes(child, [Option])) {
400
- lastWasGroup = false;
401
- return this.renderOption(child, {
402
- getOptionProps,
403
- getDisabledOptionProps
404
- });
405
- }
406
- if (matchComponentTypes(child, [Group])) {
407
- const afterGroup = lastWasGroup;
408
- lastWasGroup = true;
409
- return this.renderGroup(child, {
410
- getOptionProps,
411
- getDisabledOptionProps,
412
- // for rendering separators appropriately
413
- isFirstChild: index === 0,
414
- isLastChild: index === Children.count(children) - 1,
415
- afterGroup
416
- });
417
- }
418
- return;
419
- }) : null));
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 jsx("span", {
426
- css: styles === null || styles === void 0 ? void 0 : styles.icon
427
- }, isShowingOptions ? _IconArrowOpenUpLine || (_IconArrowOpenUpLine = jsx(IconArrowOpenUpLine, {
428
- inline: false
429
- })) : _IconArrowOpenDownLin || (_IconArrowOpenDownLin = jsx(IconArrowOpenDownLine, {
430
- inline: false
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 jsx(TextInput, Object.assign({}, triggerProps, getInputProps(inputProps)));
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 jsx(Selectable, Object.assign({
597
+ return _jsx(Selectable, {
583
598
  highlightedOptionId: highlightedOptionId,
584
599
  isShowingOptions: isShowingOptions,
585
- selectedOptionId: selectedOptionId
586
- }, this.getEventHandlers()), ({
587
- getRootProps,
588
- getInputProps,
589
- getTriggerProps,
590
- getListProps,
591
- getOptionProps,
592
- getDisabledOptionProps,
593
- getDescriptionProps
594
- }) => jsx("span", Object.assign({}, getRootProps({
595
- css: styles === null || styles === void 0 ? void 0 : styles.select
596
- }), {
597
- ref: el => this.ref = el
598
- }), this.renderInput({
599
- getInputProps,
600
- getTriggerProps
601
- }), jsx("span", Object.assign({}, getDescriptionProps(), {
602
- css: styles === null || styles === void 0 ? void 0 : styles.assistiveText
603
- }), assistiveText), jsx(Popover, {
604
- constrain: constrain,
605
- placement: placement,
606
- mountNode: mountNode,
607
- positionTarget: this._inputContainer,
608
- isShowingContent: isShowingOptions,
609
- shouldReturnFocus: false,
610
- withArrow: false,
611
- borderWidth: styles === null || styles === void 0 ? void 0 : styles.popoverBorderWidth
612
- }, this.renderList({
613
- getListProps,
614
- getOptionProps,
615
- getDisabledOptionProps
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: '',