@dxc-technology/halstack-react 0.0.0-e961efe → 0.0.0-ebb089f

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.
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.Primary = exports["default"] = void 0;
9
+
10
+ var _react = _interopRequireDefault(require("react"));
11
+
12
+ var _Button = _interopRequireDefault(require("./Button"));
13
+
14
+ var _default = {
15
+ title: "Button",
16
+ component: _Button["default"]
17
+ };
18
+ exports["default"] = _default;
19
+
20
+ var Primary = function Primary() {
21
+ return _react["default"].createElement(_Button["default"], {
22
+ mode: "primary",
23
+ label: "Primary Button"
24
+ });
25
+ };
26
+
27
+ exports.Primary = Primary;
@@ -62,7 +62,7 @@ function _templateObject26() {
62
62
  }
63
63
 
64
64
  function _templateObject25() {
65
- var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n height: 24px;\n width: 24px;\n margin-left: 8px;\n color: ", ";\n"]);
65
+ var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n height: 24px;\n width: 24px;\n ", "\n color: ", ";\n"]);
66
66
 
67
67
  _templateObject25 = function _templateObject25() {
68
68
  return data;
@@ -72,7 +72,7 @@ function _templateObject25() {
72
72
  }
73
73
 
74
74
  function _templateObject24() {
75
- var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n justify-content: space-between;\n width: 100%;\n overflow: hidden;\n padding-left: 8px;\n ", "\n"]);
75
+ var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n justify-content: space-between;\n width: 100%;\n overflow: hidden;\n ", "\n"]);
76
76
 
77
77
  _templateObject24 = function _templateObject24() {
78
78
  return data;
@@ -232,7 +232,7 @@ function _templateObject9() {
232
232
  }
233
233
 
234
234
  function _templateObject8() {
235
- var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n height: 24px;\n width: 24px;\n font-size: 1rem;\n font-family: ", ";\n border: 1px solid transparent;\n padding: 3px;\n ", "\n background-color: ", ";\n color: ", ";\n\n ", "\n\n svg {\n line-height: 18px;\n }\n"]);
235
+ var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n height: 24px;\n width: 24px;\n font-size: 1rem;\n font-family: ", ";\n border: 1px solid transparent;\n padding: 3px;\n ", "\n background-color: ", ";\n color: ", ";\n\n :focus-visible {\n outline: none;\n }\n ", "\n\n svg {\n line-height: 18px;\n }\n"]);
236
236
 
237
237
  _templateObject8 = function _templateObject8() {
238
238
  return data;
@@ -313,6 +313,7 @@ function _templateObject() {
313
313
 
314
314
  var selectIcons = {
315
315
  error: _react["default"].createElement("svg", {
316
+ role: "img",
316
317
  xmlns: "http://www.w3.org/2000/svg",
317
318
  height: "24px",
318
319
  viewBox: "0 0 24 24",
@@ -322,6 +323,7 @@ var selectIcons = {
322
323
  d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"
323
324
  })),
324
325
  arrowUp: _react["default"].createElement("svg", {
326
+ role: "img",
325
327
  xmlns: "http://www.w3.org/2000/svg",
326
328
  height: "24px",
327
329
  viewBox: "0 0 24 24",
@@ -334,6 +336,7 @@ var selectIcons = {
334
336
  d: "M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6 1.41 1.41z"
335
337
  })),
336
338
  arrowDown: _react["default"].createElement("svg", {
339
+ role: "img",
337
340
  xmlns: "http://www.w3.org/2000/svg",
338
341
  height: "24px",
339
342
  viewBox: "0 0 24 24",
@@ -346,6 +349,7 @@ var selectIcons = {
346
349
  d: "M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z"
347
350
  })),
348
351
  clear: _react["default"].createElement("svg", {
352
+ role: "img",
349
353
  xmlns: "http://www.w3.org/2000/svg",
350
354
  width: "24",
351
355
  height: "24",
@@ -358,6 +362,7 @@ var selectIcons = {
358
362
  d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"
359
363
  })),
360
364
  selected: _react["default"].createElement("svg", {
365
+ role: "img",
361
366
  xmlns: "http://www.w3.org/2000/svg",
362
367
  height: "24px",
363
368
  viewBox: "0 0 24 24",
@@ -370,6 +375,7 @@ var selectIcons = {
370
375
  d: "M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"
371
376
  })),
372
377
  searchOff: _react["default"].createElement("svg", {
378
+ role: "img",
373
379
  xmlns: "http://www.w3.org/2000/svg",
374
380
  height: "24px",
375
381
  viewBox: "0 0 24 24",
@@ -468,13 +474,83 @@ var DxcSelect = _react["default"].forwardRef(function (_ref, ref) {
468
474
  var selectSearchInputRef = (0, _react.useRef)(null);
469
475
  var selectOptionsListRef = (0, _react.useRef)(null);
470
476
  var colorsTheme = (0, _useTheme["default"])();
471
- var filteredOptions = (0, _react.useMemo)(function () {
472
- return filterOptionsBySearchValue(options, searchValue);
473
- }, [options, searchValue]);
474
477
  var optionalEmptyOption = {
475
478
  label: placeholder,
476
479
  value: ""
477
480
  };
481
+ var filteredOptions = (0, _react.useMemo)(function () {
482
+ return filterOptionsBySearchValue(options, searchValue);
483
+ }, [options, searchValue]);
484
+
485
+ var getLastOptionIndex = function getLastOptionIndex() {
486
+ var last = 0;
487
+
488
+ var reducer = function reducer(acc, current) {
489
+ var _current$options;
490
+
491
+ return acc + ((_current$options = current.options) === null || _current$options === void 0 ? void 0 : _current$options.length);
492
+ };
493
+
494
+ if (searchable && filteredOptions.length > 0) filteredOptions[0].options ? last = filteredOptions.reduce(reducer, 0) - 1 : last = filteredOptions.length - 1;else if ((options === null || options === void 0 ? void 0 : options.length) > 0) options[0].options ? last = options.reduce(reducer, 0) - 1 : last = options.length - 1;
495
+ return optional && !multiple ? last + 1 : last;
496
+ };
497
+
498
+ var lastOptionIndex = (0, _react.useMemo)(function () {
499
+ return getLastOptionIndex();
500
+ }, [searchable, optional, multiple, filteredOptions, options]);
501
+
502
+ var getSelectedOption = function getSelectedOption() {
503
+ var val = value !== null && value !== void 0 ? value : innerValue;
504
+ var selectedOption = multiple ? [] : "";
505
+ var singleSelectionIndex;
506
+
507
+ if (multiple) {
508
+ if ((options === null || options === void 0 ? void 0 : options.length) > 0) {
509
+ options.forEach(function (option) {
510
+ if (option.options) {
511
+ option.options.forEach(function (singleOption) {
512
+ if (val.includes(singleOption.value)) selectedOption.push(singleOption);
513
+ });
514
+ } else if (val.includes(option.value)) selectedOption.push(option);
515
+ });
516
+ }
517
+ } else {
518
+ if (optional && val === "") {
519
+ selectedOption = optionalEmptyOption;
520
+ singleSelectionIndex = 0;
521
+ } else if ((options === null || options === void 0 ? void 0 : options.length) > 0) {
522
+ var group_index = 0;
523
+ options.some(function (option, index) {
524
+ if (option.options) {
525
+ option.options.some(function (singleOption) {
526
+ if (singleOption.value === val) {
527
+ selectedOption = singleOption;
528
+ singleSelectionIndex = optional ? group_index + 1 : group_index;
529
+ return true;
530
+ }
531
+
532
+ group_index++;
533
+ });
534
+ } else if (option.value === val) {
535
+ selectedOption = option;
536
+ singleSelectionIndex = optional ? index + 1 : index;
537
+ return true;
538
+ }
539
+ });
540
+ }
541
+ }
542
+
543
+ return {
544
+ selectedOption: selectedOption,
545
+ singleSelectionIndex: singleSelectionIndex
546
+ };
547
+ };
548
+
549
+ var _useMemo = (0, _react.useMemo)(function () {
550
+ return getSelectedOption();
551
+ }, [options, multiple, value, innerValue]),
552
+ selectedOption = _useMemo.selectedOption,
553
+ singleSelectionIndex = _useMemo.singleSelectionIndex;
478
554
 
479
555
  var notOptionalCheck = function notOptionalCheck(value) {
480
556
  return value === "" && !optional;
@@ -547,16 +623,16 @@ var DxcSelect = _react["default"].forwardRef(function (_ref, ref) {
547
623
  };
548
624
 
549
625
  var handleSelectOnClick = function handleSelectOnClick() {
626
+ searchable && selectSearchInputRef.current.focus();
627
+
550
628
  if (isOpen) {
551
629
  closeOptions();
552
630
  setSearchValue("");
553
631
  } else openOptions();
554
-
555
- searchable && selectSearchInputRef.current.focus();
556
632
  };
557
633
 
558
- var handleSelectOnFocus = function handleSelectOnFocus() {
559
- searchable && selectSearchInputRef.current.focus();
634
+ var handleSelectOnFocus = function handleSelectOnFocus(event) {
635
+ if (!event.currentTarget.contains(event.relatedTarget)) searchable && selectSearchInputRef.current.focus();
560
636
  };
561
637
 
562
638
  var handleSelectOnBlur = function handleSelectOnBlur(event) {
@@ -579,7 +655,7 @@ var DxcSelect = _react["default"].forwardRef(function (_ref, ref) {
579
655
  case 40:
580
656
  // Arrow Down
581
657
  event.preventDefault();
582
- changeVisualFocusIndex(function (visualFocusIndex) {
658
+ singleSelectionIndex !== undefined && (!isOpen || visualFocusIndex === -1 && singleSelectionIndex > -1 && singleSelectionIndex <= lastOptionIndex) ? changeVisualFocusIndex(singleSelectionIndex) : changeVisualFocusIndex(function (visualFocusIndex) {
583
659
  if (visualFocusIndex < lastOptionIndex) return visualFocusIndex + 1;else if (visualFocusIndex === lastOptionIndex) return 0;
584
660
  });
585
661
  openOptions();
@@ -588,7 +664,7 @@ var DxcSelect = _react["default"].forwardRef(function (_ref, ref) {
588
664
  case 38:
589
665
  // Arrow Up
590
666
  event.preventDefault();
591
- changeVisualFocusIndex(function (visualFocusIndex) {
667
+ singleSelectionIndex !== undefined && (!isOpen || visualFocusIndex === -1 && singleSelectionIndex > -1 && singleSelectionIndex <= lastOptionIndex) ? changeVisualFocusIndex(singleSelectionIndex) : changeVisualFocusIndex(function (visualFocusIndex) {
592
668
  return visualFocusIndex === 0 || visualFocusIndex === -1 ? lastOptionIndex : visualFocusIndex - 1;
593
669
  });
594
670
  openOptions();
@@ -638,11 +714,6 @@ var DxcSelect = _react["default"].forwardRef(function (_ref, ref) {
638
714
  openOptions();
639
715
  };
640
716
 
641
- var handleClearActionOnClick = function handleClearActionOnClick(event) {
642
- event.stopPropagation();
643
- setSearchValue("");
644
- };
645
-
646
717
  var handleClearOptionsActionOnClick = function handleClearOptionsActionOnClick(event) {
647
718
  event.stopPropagation();
648
719
  value !== null && value !== void 0 ? value : setInnerValue([]);
@@ -650,76 +721,33 @@ var DxcSelect = _react["default"].forwardRef(function (_ref, ref) {
650
721
  value: [],
651
722
  error: getNotOptionalErrorMessage()
652
723
  });
653
- selectContainerRef.current.focus();
654
724
  };
655
725
 
656
- var getLastOptionIndex = function getLastOptionIndex() {
657
- var last = 0;
658
-
659
- var reducer = function reducer(acc, current) {
660
- var _current$options;
661
-
662
- return acc + ((_current$options = current.options) === null || _current$options === void 0 ? void 0 : _current$options.length);
663
- };
664
-
665
- if (searchable && filteredOptions.length > 0) filteredOptions[0].options ? last = filteredOptions.reduce(reducer, 0) - 1 : last = filteredOptions.length - 1;else if ((options === null || options === void 0 ? void 0 : options.length) > 0) options[0].options ? last = options.reduce(reducer, 0) - 1 : last = options.length - 1;
666
- return optional && !multiple ? last + 1 : last;
726
+ var handleClearSearchActionOnClick = function handleClearSearchActionOnClick(event) {
727
+ event.stopPropagation();
728
+ setSearchValue("");
667
729
  };
668
730
 
669
- var lastOptionIndex = (0, _react.useMemo)(function () {
670
- return getLastOptionIndex();
671
- }, [searchable, optional, multiple, searchable ? filteredOptions : options]);
672
-
673
- var getSelectedOption = function getSelectedOption() {
674
- var val = value !== null && value !== void 0 ? value : innerValue;
675
- var selectedOption = multiple ? [] : "";
731
+ (0, _react.useLayoutEffect)(function () {
732
+ if (isOpen && singleSelectionIndex) {
733
+ var _listEl$scrollTo;
676
734
 
677
- if (multiple) {
678
- if ((options === null || options === void 0 ? void 0 : options.length) > 0) {
679
- options.forEach(function (option) {
680
- if (option.options) {
681
- option.options.forEach(function (singleOption) {
682
- if (val.includes(singleOption.value)) selectedOption.push(singleOption);
683
- });
684
- } else if (val.includes(option.value)) selectedOption.push(option);
685
- });
686
- }
687
- } else {
688
- if ((options === null || options === void 0 ? void 0 : options.length) > 0) {
689
- options.forEach(function (option) {
690
- if (option.options) {
691
- option.options.forEach(function (singleOption) {
692
- if (singleOption.value === val) selectedOption = singleOption;
693
- });
694
- } else if (option.value === val) selectedOption = option;
695
- });
696
- }
735
+ var listEl = selectOptionsListRef === null || selectOptionsListRef === void 0 ? void 0 : selectOptionsListRef.current;
736
+ var selectedListOptionEl = listEl === null || listEl === void 0 ? void 0 : listEl.querySelector("[aria-selected='true']");
737
+ listEl === null || listEl === void 0 ? void 0 : (_listEl$scrollTo = listEl.scrollTo) === null || _listEl$scrollTo === void 0 ? void 0 : _listEl$scrollTo.call(listEl, {
738
+ top: (selectedListOptionEl === null || selectedListOptionEl === void 0 ? void 0 : selectedListOptionEl.offsetTop) - (listEl === null || listEl === void 0 ? void 0 : listEl.clientHeight) / 2
739
+ });
697
740
  }
698
-
699
- return selectedOption;
700
- };
701
-
702
- var selectedOption = (0, _react.useMemo)(function () {
703
- return getSelectedOption();
704
- }, [options, multiple, value !== null && value !== void 0 ? value : innerValue]);
741
+ }, [isOpen]);
705
742
  (0, _react.useLayoutEffect)(function () {
706
- var _selectOptionsListRef;
743
+ var _selectOptionsListRef, _visualFocusedOptionE;
707
744
 
708
745
  var visualFocusedOptionEl = selectOptionsListRef === null || selectOptionsListRef === void 0 ? void 0 : (_selectOptionsListRef = selectOptionsListRef.current) === null || _selectOptionsListRef === void 0 ? void 0 : _selectOptionsListRef.querySelectorAll("[role='option']")[visualFocusIndex];
709
- visualFocusedOptionEl === null || visualFocusedOptionEl === void 0 ? void 0 : visualFocusedOptionEl.scrollIntoView({
746
+ visualFocusedOptionEl === null || visualFocusedOptionEl === void 0 ? void 0 : (_visualFocusedOptionE = visualFocusedOptionEl.scrollIntoView) === null || _visualFocusedOptionE === void 0 ? void 0 : _visualFocusedOptionE.call(visualFocusedOptionEl, {
710
747
  block: "nearest",
711
748
  inline: "start"
712
749
  });
713
750
  }, [visualFocusIndex]);
714
- (0, _react.useLayoutEffect)(function () {
715
- if (isOpen && !multiple) {
716
- var listEl = selectOptionsListRef === null || selectOptionsListRef === void 0 ? void 0 : selectOptionsListRef.current;
717
- var selectedListOptionEl = listEl === null || listEl === void 0 ? void 0 : listEl.querySelector("[aria-selected='true']");
718
- listEl === null || listEl === void 0 ? void 0 : listEl.scrollTo({
719
- top: (selectedListOptionEl === null || selectedListOptionEl === void 0 ? void 0 : selectedListOptionEl.offsetTop) - (listEl === null || listEl === void 0 ? void 0 : listEl.clientHeight) / 2
720
- });
721
- }
722
- }, [isOpen]);
723
751
 
724
752
  var Option = function Option(_ref2) {
725
753
  var option = _ref2.option,
@@ -730,7 +758,7 @@ var DxcSelect = _react["default"].forwardRef(function (_ref, ref) {
730
758
  var isLastOption = index === lastOptionIndex;
731
759
  return _react["default"].createElement(OptionItem, {
732
760
  id: "option-".concat(index),
733
- onClick: function onClick(event) {
761
+ onClick: function onClick() {
734
762
  // left mouse button only
735
763
  handleSelectChangeValue(option);
736
764
  !multiple && closeOptions();
@@ -750,7 +778,9 @@ var DxcSelect = _react["default"].forwardRef(function (_ref, ref) {
750
778
  tabIndex: -1,
751
779
  checked: isSelected
752
780
  }), option.icon && _react["default"].createElement(OptionIcon, {
753
- selected: isSelected
781
+ grouped: isGroupedOption,
782
+ multiple: multiple,
783
+ role: !(typeof option.icon === "string") && "img"
754
784
  }, typeof option.icon === "string" ? _react["default"].createElement(OptionIconImg, {
755
785
  src: option.icon
756
786
  }) : option.icon), _react["default"].createElement(OptionContent, {
@@ -760,7 +790,7 @@ var DxcSelect = _react["default"].forwardRef(function (_ref, ref) {
760
790
  }, _react["default"].createElement(OptionLabel, null, option.label), !multiple && isSelected && _react["default"].createElement(OptionSelectedIndicator, null, selectIcons.selected))));
761
791
  };
762
792
 
763
- var global_index = optional && !multiple ? 0 : -1; // index for options (not groups), starting from 0 to options.length -1
793
+ var global_index = optional && !multiple ? 0 : -1; // index for options, starting from 0 to options.length -1
764
794
 
765
795
  var mapOptionFunc = function mapOptionFunc(option) {
766
796
  if (option.options) {
@@ -814,13 +844,17 @@ var DxcSelect = _react["default"].forwardRef(function (_ref, ref) {
814
844
  "aria-expanded": isOpen ? "true" : "false",
815
845
  "aria-haspopup": "listbox",
816
846
  "aria-labelledby": selectLabelId,
817
- "aria-activedescendant": visualFocusIndex >= 0 && "option-".concat(visualFocusIndex),
847
+ "aria-activedescendant": visualFocusIndex >= 0 ? "option-".concat(visualFocusIndex) : undefined,
818
848
  "aria-invalid": error ? "true" : "false",
819
849
  "aria-required": optional ? "false" : "true"
820
850
  }, multiple && selectedOption.length > 0 && _react["default"].createElement(SelectionIndicator, null, _react["default"].createElement(SelectionNumber, {
821
851
  disabled: disabled
822
852
  }, selectedOption.length, " "), _react["default"].createElement(ClearOptionsAction, {
823
853
  disabled: disabled,
854
+ onMouseDown: function onMouseDown(event) {
855
+ // Avoid input to lose focus when pressed
856
+ event.preventDefault();
857
+ },
824
858
  onClick: handleClearOptionsActionOnClick,
825
859
  tabIndex: -1,
826
860
  title: "Clear selected options",
@@ -828,7 +862,8 @@ var DxcSelect = _react["default"].forwardRef(function (_ref, ref) {
828
862
  }, selectIcons.clear)), _react["default"].createElement(SearchableValueContainer, null, _react["default"].createElement(ValueInput, {
829
863
  name: name,
830
864
  value: multiple ? (value !== null && value !== void 0 ? value : innerValue).join(", ") : value !== null && value !== void 0 ? value : innerValue,
831
- readOnly: true
865
+ readOnly: true,
866
+ "aria-hidden": "true"
832
867
  }), searchable && _react["default"].createElement(SearchInput, {
833
868
  value: searchValue,
834
869
  disabled: disabled,
@@ -844,8 +879,12 @@ var DxcSelect = _react["default"].forwardRef(function (_ref, ref) {
844
879
  }).join(", ")), selectedOption.length === 0 && placeholder) : _react["default"].createElement(SelectedOption, {
845
880
  disabled: disabled,
846
881
  atBackground: !(value !== null && value !== void 0 ? value : innerValue) || isOpen
847
- }, _react["default"].createElement(OptionLabel, null, (_ref3 = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) !== null && _ref3 !== void 0 ? _ref3 : placeholder)))), !disabled && error && _react["default"].createElement(ErrorIcon, null, selectIcons.error), searchable && searchValue.length > 0 && _react["default"].createElement(ClearAction, {
848
- onClick: handleClearActionOnClick,
882
+ }, _react["default"].createElement(OptionLabel, null, (_ref3 = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) !== null && _ref3 !== void 0 ? _ref3 : placeholder)))), !disabled && error && _react["default"].createElement(ErrorIcon, null, selectIcons.error), searchable && searchValue.length > 0 && _react["default"].createElement(ClearSearchAction, {
883
+ onMouseDown: function onMouseDown(event) {
884
+ // Avoid input to lose focus
885
+ event.preventDefault();
886
+ },
887
+ onClick: handleClearSearchActionOnClick,
849
888
  tabIndex: -1,
850
889
  title: "Clear search text",
851
890
  "aria-label": "Clear search text"
@@ -1020,7 +1059,7 @@ var CollapseIndicator = _styledComponents["default"].span(_templateObject15(), f
1020
1059
  return props.disabled ? props.theme.disabledColor : props.theme.collapseIndicatorColor;
1021
1060
  });
1022
1061
 
1023
- var ClearAction = _styledComponents["default"].button(_templateObject16(), function (props) {
1062
+ var ClearSearchAction = _styledComponents["default"].button(_templateObject16(), function (props) {
1024
1063
  return props.theme.fontFamily;
1025
1064
  }, function (props) {
1026
1065
  return props.disabled ? "cursor: not-allowed;" : "cursor: pointer;";
@@ -1077,10 +1116,12 @@ var StyledOption = _styledComponents["default"].span(_templateObject23(), functi
1077
1116
  });
1078
1117
 
1079
1118
  var OptionContent = _styledComponents["default"].span(_templateObject24(), function (props) {
1080
- return props.grouped && !props.multiple && !props.hasIcon && "padding-left: 16px;";
1119
+ return props.grouped && !props.multiple && !props.hasIcon ? "padding-left: 16px;" : "padding-left: 8px;";
1081
1120
  });
1082
1121
 
1083
1122
  var OptionIcon = _styledComponents["default"].span(_templateObject25(), function (props) {
1123
+ return props.grouped && !props.multiple ? "padding-left: 16px;" : "padding-left: 8px;";
1124
+ }, function (props) {
1084
1125
  return props.theme.listItemIconColor;
1085
1126
  });
1086
1127
 
@@ -8,28 +8,106 @@ type Margin = {
8
8
  };
9
9
 
10
10
  type OptionGroup = {
11
+ /**
12
+ * Label of the group to be shown in the select's listbox.
13
+ */
11
14
  label: string;
15
+ /**
16
+ * List of the grouped options.
17
+ */
12
18
  options: Option[];
13
19
  };
14
20
  type Option = {
15
- icon?: string | SVG;
21
+ /**
22
+ * Element used as the icon that will be placed before the option label.
23
+ * It can be a url of an image or an inline SVG. If the url option
24
+ * is the chosen one, take into account that the component's
25
+ * color styling tokens will not be applied to the image.
26
+ */
27
+ icon?: SVG;
28
+ /**
29
+ * Label of the option to be shown in the select's listbox.
30
+ */
16
31
  label: string;
32
+ /**
33
+ * Value of the option. It should be unique and
34
+ * not an empty string, which is reserved to the empty option added
35
+ * by optional prop.
36
+ */
17
37
  value: string;
18
38
  };
19
39
 
20
40
  type Props = {
41
+ /**
42
+ * Text to be placed above the select.
43
+ */
21
44
  label?: string;
45
+ /**
46
+ * Name attribute of the input element. This attribute will allow users
47
+ * to find the component's value during the submit event. In this event,
48
+ * the component's value will always be a regular string, for both single
49
+ * and multiple selection modes, been in the first one a single option
50
+ * value and in the multiple variant more than one option value,
51
+ * separated by commas.
52
+ */
22
53
  name?: string;
54
+ /**
55
+ * Value of the select. If undefined, the component will be uncontrolled
56
+ * and the value will be managed internally by the component.
57
+ */
23
58
  value?: string | string[];
59
+ /**
60
+ * An array of objects representing the selectable options.
61
+ */
24
62
  options?: Option[] | OptionGroup[];
63
+ /**
64
+ * Helper text to be placed above the select.
65
+ */
25
66
  helperText?: string;
67
+ /**
68
+ * Text to be put as placeholder of the select.
69
+ */
26
70
  placeholder?: string;
71
+ /**
72
+ * If true, the component will be disabled.
73
+ */
27
74
  disabled?: boolean;
75
+ /**
76
+ * If true, the select will be optional, showing '(Optional)'
77
+ * next to the label and adding a default first option with empty value, been
78
+ * the placeholder (if defined) its label. Otherwise, the field will be
79
+ * considered required and an error will be passed as a parameter to the
80
+ * OnBlur and onChange functions if an option wasn't selected.
81
+ */
28
82
  optional?: boolean;
83
+ /**
84
+ * If true, enables search functionality.
85
+ */
29
86
  searchable?: boolean;
87
+ /**
88
+ * If true, the select component will support multiple selected options.
89
+ * In that case, value will be an array of strings with each selected
90
+ * option value.
91
+ */
30
92
  multiple?: boolean;
93
+ /**
94
+ * This function will be called when the user selects an option.
95
+ * An object including the current value and the error (if the value entered is not valid)
96
+ * will be passed to this function. If there is no error, error will be null.
97
+ */
31
98
  onChange?: (value: string | string[]) => void;
99
+ /**
100
+ * This function will be called when the select loses the focus. An
101
+ * object including the value (or values) and the error (if the value
102
+ * selected is not valid) will be passed to this function. If there is no error,
103
+ * error will be null.
104
+ */
32
105
  onBlur?: (val: { value: string | string[]; error: string }) => void;
106
+ /**
107
+ * If it is defined, the component will change its appearance, showing
108
+ * the error below the select component. If it is not defined, the error
109
+ * messages will be managed internally, but never displayed on its own.
110
+ */
33
111
  error?: string;
34
112
  /**
35
113
  * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
@@ -715,7 +715,7 @@ var DxcTextInput = _react["default"].forwardRef(function (_ref, ref) {
715
715
  tabIndex: tabIndex,
716
716
  role: isTextInputType() && hasInputSuggestions() ? "combobox" : "textbox",
717
717
  "aria-autocomplete": isTextInputType() && hasInputSuggestions() ? "list" : undefined,
718
- "aria-controls": isTextInputType() && hasInputSuggestions() ? inputId : undefined,
718
+ "aria-controls": isTextInputType() && hasInputSuggestions() ? autosuggestId : undefined,
719
719
  "aria-expanded": isTextInputType() && hasInputSuggestions() ? isOpen ? "true" : "false" : undefined,
720
720
  "aria-activedescendant": isTextInputType() && hasInputSuggestions() && isOpen && visualFocusedSuggIndex !== -1 ? "suggestion-".concat(visualFocusedSuggIndex) : undefined,
721
721
  "aria-invalid": error ? "true" : "false",
@@ -877,7 +877,7 @@ var Action = _styledComponents["default"].button(_templateObject8(), function (p
877
877
  }, function (props) {
878
878
  return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledActionIconColorOnDark : props.theme.disabledActionIconColor : props.backgroundType === "dark" ? props.theme.actionIconColorOnDark : props.theme.actionIconColor;
879
879
  }, function (props) {
880
- return !props.disabled && "\n &:hover {\n background-color: ".concat(props.backgroundType === "dark" ? props.theme.hoverActionBackgroundColorOnDark : props.theme.hoverActionBackgroundColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.hoverActionIconColorOnDark : props.theme.hoverActionIconColor, ";\n }\n &:focus {\n outline: none;\n box-shadow: 0 0 0 2px ").concat(props.backgroundType === "dark" ? props.theme.focusActionBorderColorOnDark : props.theme.focusActionBorderColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.focusActionIconColorOnDark : props.theme.focusActionIconColor, ";\n }\n &:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px ").concat(props.backgroundType === "dark" ? props.theme.focusActionBorderColorOnDark : props.theme.focusActionBorderColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.focusActionIconColorOnDark : props.theme.focusActionIconColor, ";\n }\n &:active {\n background-color: ").concat(props.backgroundType === "dark" ? props.theme.activeActionBackgroundColorOnDark : props.theme.activeActionBackgroundColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.activeActionIconColorOnDark : props.theme.activeActionIconColor, ";\n }\n ");
880
+ return !props.disabled && "\n &:focus {\n outline: none;\n box-shadow: 0 0 0 2px ".concat(props.backgroundType === "dark" ? props.theme.focusActionBorderColorOnDark : props.theme.focusActionBorderColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.focusActionIconColorOnDark : props.theme.focusActionIconColor, ";\n }\n &:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px ").concat(props.backgroundType === "dark" ? props.theme.focusActionBorderColorOnDark : props.theme.focusActionBorderColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.focusActionIconColorOnDark : props.theme.focusActionIconColor, ";\n }\n &:hover {\n background-color: ").concat(props.backgroundType === "dark" ? props.theme.hoverActionBackgroundColorOnDark : props.theme.hoverActionBackgroundColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.hoverActionIconColorOnDark : props.theme.hoverActionIconColor, ";\n }\n &:active {\n background-color: ").concat(props.backgroundType === "dark" ? props.theme.activeActionBackgroundColorOnDark : props.theme.activeActionBackgroundColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.activeActionIconColorOnDark : props.theme.activeActionIconColor, ";\n }\n ");
881
881
  });
882
882
 
883
883
  var Prefix = _styledComponents["default"].span(_templateObject9(), function (props) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxc-technology/halstack-react",
3
- "version": "0.0.0-e961efe",
3
+ "version": "0.0.0-ebb089f",
4
4
  "description": "DXC Halstack React components library",
5
5
  "repository": "dxc-technology/halstack-react",
6
6
  "homepage": "http://developer.dxc.com/tools/react",