@semcore/select 16.1.12 → 17.0.0-prerelease.18

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.
@@ -1,15 +1,7 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
1
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
5
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
6
- import _createClass from "@babel/runtime/helpers/esm/createClass";
7
- import _callSuper from "@babel/runtime/helpers/esm/callSuper";
8
- import _superPropGet from "@babel/runtime/helpers/esm/superPropGet";
9
- import _inherits from "@babel/runtime/helpers/esm/inherits";
10
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
11
3
  import { sstyled, createComponent, lastInteraction, assignProps } from "@semcore/core";
12
- import { hideScrollBarsFromScreenReadersContext } from "@semcore/base-components";
4
+ import { useBox, isInputTriggerTag, hideScrollBarsFromScreenReadersContext } from "@semcore/base-components";
13
5
  import { ButtonTrigger } from "@semcore/base-trigger";
14
6
  import addonTextChildren from "@semcore/core/lib/utils/addonTextChildren";
15
7
  import { callAllEventHandlers } from "@semcore/core/lib/utils/assignProps";
@@ -19,31 +11,29 @@ import logger from "@semcore/core/lib/utils/logger";
19
11
  import Divider from "@semcore/divider";
20
12
  import Dropdown, { enhance, selectedIndexContext, AbstractDropdown } from "@semcore/dropdown";
21
13
  import DropdownMenu from "@semcore/dropdown-menu";
22
- import { useBox } from "@semcore/flex-box";
23
- import { isInputTriggerTag } from "@semcore/popper";
14
+ import { Text } from "@semcore/typography";
24
15
  import cn from "classnames";
25
16
  import React from "react";
26
17
  import { selectContext } from "./context.mjs";
27
18
  import InputSearch from "./InputSearch.mjs";
28
19
  import { localizedMessages } from "./translations/__intergalactic-dynamic-locales.mjs";
29
- var _excluded = ["Children", "options", "multiselect", "value", "uid", "forcedAdvancedMode"];
30
20
  /*!__reshadow-styles__:"./style/select.shadow.css"*/
31
- var style = (
21
+ const style = (
32
22
  /*__reshadow_css_start__*/
33
23
  (sstyled.insert(
34
24
  /*__inner_css_start__*/
35
- '.___SOptionCheckbox_1hlru_gg_{margin-top:var(--intergalactic-spacing-05x, 2px);margin-right:var(--intergalactic-spacing-2x, 8px);margin-bottom:auto;position:relative;flex-shrink:0;width:16px;height:16px}.___SOptionCheckbox_1hlru_gg_::before{content:"";position:absolute;top:0;left:0;right:0;bottom:0;background:var(--intergalactic-bg-primary-neutral, #ffffff);border:1px solid;border-radius:var(--intergalactic-addon-rounded, 4px);border-color:var(--intergalactic-border-primary, #c4c7cf)}.___SOptionCheckbox_1hlru_gg_::after{content:"";position:absolute;top:0;left:0;right:0;bottom:0;margin:0 var(--intergalactic-spacing-05x, 2px);background-repeat:no-repeat;background-position:center center}.___SOptionCheckbox_1hlru_gg_.__selected_1hlru_gg_::after{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAiIGhlaWdodD0iNyIgdmlld0JveD0iMCAwIDEwIDciIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik04LjI1IDFMNCA1LjI1TDEuNzUgMyIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPC9zdmc+Cg==)}.___SOptionCheckbox_1hlru_gg_._size_l_1hlru_gg_{width:20px;height:20px}.___SOptionCheckbox_1hlru_gg_._size_l_1hlru_gg_.__selected_1hlru_gg_::after{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iOSIgdmlld0JveD0iMCAwIDEyIDkiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik0xMSAxLjVMNC43NSA3Ljc1TDEgNCIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPC9zdmc+Cg==)}.___SOptionCheckbox_1hlru_gg_.__indeterminate_1hlru_gg_:before,.___SOptionCheckbox_1hlru_gg_.__selected_1hlru_gg_:before{background-color:var(--intergalactic-control-primary-info, #008ff8);border-color:var(--intergalactic-control-primary-info, #008ff8)}.___SOptionCheckbox_1hlru_gg_.__theme_1hlru_gg_:before{border-color:var(--theme_1hlru)}.___SOptionCheckbox_1hlru_gg_.__theme_1hlru_gg_.__indeterminate_1hlru_gg_:before,.___SOptionCheckbox_1hlru_gg_.__theme_1hlru_gg_.__selected_1hlru_gg_:before{background-color:var(--theme_1hlru);border-color:var(--theme_1hlru)}.___SOptionCheckbox_1hlru_gg_.__selected_1hlru_gg_{background-color:var(--intergalactic-dropdown-menu-item-selected, rgba(196, 229, 254, 0.7))}@media (hover:hover){.___SOptionCheckbox_1hlru_gg_.__selected_1hlru_gg_:hover{background-color:var(--intergalactic-dropdown-menu-item-selected-hover, #c4e5fe)}}.___SOptionCheckbox_1hlru_gg_.__indeterminate_1hlru_gg_:after{background-color:#fff;background-image:none;margin:auto;border-radius:1px}.___SOptionCheckbox_1hlru_gg_.__indeterminate_1hlru_gg_._size_l_1hlru_gg_:after{width:12px;height:2px}.___SOptionCheckbox_1hlru_gg_.__indeterminate_1hlru_gg_._size_m_1hlru_gg_:after{width:8px;height:2px}',
25
+ '.___SOptionCheckbox_ggett_gg_{margin-top:var(--intergalactic-spacing-05x, 2px);margin-right:var(--intergalactic-spacing-2x, 8px);margin-bottom:auto;position:relative;flex-shrink:0;width:16px;height:16px}.___SOptionCheckbox_ggett_gg_::before{content:"";position:absolute;top:0;left:0;right:0;bottom:0;background:var(--intergalactic-bg-primary-neutral, #ffffff);border:1px solid;border-radius:var(--intergalactic-addon-rounded, 4px);border-color:var(--intergalactic-border-primary, #c4c7cf)}.___SOptionCheckbox_ggett_gg_::after{content:"";position:absolute;top:0;left:0;right:0;bottom:0;margin:0 var(--intergalactic-spacing-05x, 2px);background-repeat:no-repeat;background-position:center center}.___SOptionCheckbox_ggett_gg_.__selected_ggett_gg_::after{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAiIGhlaWdodD0iNyIgdmlld0JveD0iMCAwIDEwIDciIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik04LjI1IDFMNCA1LjI1TDEuNzUgMyIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPC9zdmc+Cg==)}.___SOptionCheckbox_ggett_gg_._size_l_ggett_gg_{width:20px;height:20px}.___SOptionCheckbox_ggett_gg_._size_l_ggett_gg_.__selected_ggett_gg_::after{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iOSIgdmlld0JveD0iMCAwIDEyIDkiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik0xMSAxLjVMNC43NSA3Ljc1TDEgNCIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPC9zdmc+Cg==)}.___SOptionCheckbox_ggett_gg_.__indeterminate_ggett_gg_:before,.___SOptionCheckbox_ggett_gg_.__selected_ggett_gg_:before{background-color:var(--intergalactic-control-primary-info, #008ff8);border-color:var(--intergalactic-control-primary-info, #008ff8)}.___SOptionCheckbox_ggett_gg_.__theme_ggett_gg_:before{border-color:var(--theme_ggett)}.___SOptionCheckbox_ggett_gg_.__theme_ggett_gg_.__indeterminate_ggett_gg_:before,.___SOptionCheckbox_ggett_gg_.__theme_ggett_gg_.__selected_ggett_gg_:before{background-color:var(--theme_ggett);border-color:var(--theme_ggett)}.___SOptionCheckbox_ggett_gg_.__selected_ggett_gg_{background-color:var(--intergalactic-dropdown-menu-item-selected, rgba(196, 229, 254, 0.7))}@media (hover:hover){.___SOptionCheckbox_ggett_gg_.__selected_ggett_gg_:hover{background-color:var(--intergalactic-dropdown-menu-item-selected-hover, #c4e5fe)}}.___SOptionCheckbox_ggett_gg_.__indeterminate_ggett_gg_:after{background-color:#fff;background-image:none;margin:auto;border-radius:1px}.___SOptionCheckbox_ggett_gg_.__indeterminate_ggett_gg_._size_l_ggett_gg_:after{width:12px;height:2px}.___SOptionCheckbox_ggett_gg_.__indeterminate_ggett_gg_._size_m_ggett_gg_:after{width:8px;height:2px}',
36
26
  /*__inner_css_end__*/
37
- "1hlru_gg_"
27
+ "ggett_gg_"
38
28
  ), /*__reshadow_css_end__*/
39
29
  {
40
- "__SOptionCheckbox": "___SOptionCheckbox_1hlru_gg_",
41
- "_selected": "__selected_1hlru_gg_",
42
- "_size_l": "_size_l_1hlru_gg_",
43
- "_indeterminate": "__indeterminate_1hlru_gg_",
44
- "_theme": "__theme_1hlru_gg_",
45
- "--theme": "--theme_1hlru",
46
- "_size_m": "_size_m_1hlru_gg_"
30
+ "__SOptionCheckbox": "___SOptionCheckbox_ggett_gg_",
31
+ "_selected": "__selected_ggett_gg_",
32
+ "_size_l": "_size_l_ggett_gg_",
33
+ "_indeterminate": "__indeterminate_ggett_gg_",
34
+ "_theme": "__theme_ggett_gg_",
35
+ "--theme": "--theme_ggett",
36
+ "_size_m": "_size_m_ggett_gg_"
47
37
  })
48
38
  );
49
39
  function isSelectedOption(value, valueOption) {
@@ -55,257 +45,267 @@ function isEmptyValue(value) {
55
45
  function getEmptyValue(multiselect) {
56
46
  return multiselect ? [] : null;
57
47
  }
58
- var ListBoxContextProvider = function ListBoxContextProvider2(_ref9) {
59
- var children = _ref9.children;
60
- return /* @__PURE__ */ React.createElement(hideScrollBarsFromScreenReadersContext.Provider, {
61
- value: true
62
- }, children);
63
- };
64
- var RootSelect = /* @__PURE__ */ (function(_AbstractDropdown) {
65
- function RootSelect2() {
66
- var _this;
67
- _classCallCheck(this, RootSelect2);
68
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
69
- args[_key] = arguments[_key];
70
- }
71
- _this = _callSuper(this, RootSelect2, [].concat(args));
72
- _defineProperty(_this, "role", "listbox");
73
- _defineProperty(_this, "bindHandlerOptionClick", function(optionValue, index) {
74
- return function(e) {
75
- var newValue = optionValue;
76
- var _this$asProps = _this.asProps, value = _this$asProps.value, multiselect = _this$asProps.multiselect;
77
- if (Array.isArray(value)) {
78
- if (value.includes(optionValue)) {
79
- newValue = value.filter(function(v) {
80
- return v !== optionValue;
81
- });
82
- } else {
83
- newValue = value.concat(optionValue);
84
- }
85
- }
86
- _this.handlers.highlightedIndex(index);
87
- _this.handlers.value(newValue, e);
88
- if (!multiselect) {
89
- _this.handlers.visible(false);
90
- e.preventDefault();
48
+ const ListBoxContextProvider = ({
49
+ children
50
+ }) => /* @__PURE__ */ React.createElement(hideScrollBarsFromScreenReadersContext.Provider, {
51
+ value: true
52
+ }, children);
53
+ class RootSelect extends AbstractDropdown {
54
+ constructor(...args) {
55
+ super(...args);
56
+ _defineProperty(this, "role", "listbox");
57
+ _defineProperty(this, "bindHandlerOptionClick", (optionValue, index) => (e) => {
58
+ let newValue = optionValue;
59
+ const {
60
+ value,
61
+ multiselect
62
+ } = this.asProps;
63
+ if (Array.isArray(value)) {
64
+ if (value.includes(optionValue)) {
65
+ newValue = value.filter((v) => v !== optionValue);
66
+ } else {
67
+ newValue = value.concat(optionValue);
91
68
  }
92
- };
69
+ }
70
+ this.handlers.highlightedIndex(index);
71
+ this.handlers.value(newValue, e);
72
+ if (!multiselect) {
73
+ this.handlers.visible(false);
74
+ e.preventDefault();
75
+ }
93
76
  });
94
- _defineProperty(_this, "handlerClear", function(e) {
95
- var value = _this.asProps.value;
96
- var emptyValue = getEmptyValue(Array.isArray(value));
97
- _this.handlers.value(emptyValue, e);
98
- _this.handlers.visible(false);
77
+ _defineProperty(this, "handlerClear", (e) => {
78
+ const {
79
+ value
80
+ } = this.asProps;
81
+ const emptyValue = getEmptyValue(Array.isArray(value));
82
+ this.handlers.value(emptyValue, e);
83
+ this.handlers.visible(false);
99
84
  });
100
- return _this;
101
85
  }
102
- _inherits(RootSelect2, _AbstractDropdown);
103
- return _createClass(RootSelect2, [{
104
- key: "itemRef",
105
- value: function itemRef(props, index, node) {
106
- _superPropGet(RootSelect2, "itemRef", this, 3)([props, index, node]);
107
- var highlightedIndex = this.asProps.highlightedIndex;
108
- var isHighlighted = index === highlightedIndex;
109
- if (isHighlighted) {
110
- this.scrollToNode(node);
111
- }
86
+ itemRef(props, index, node) {
87
+ super.itemRef(props, index, node);
88
+ const {
89
+ highlightedIndex
90
+ } = this.asProps;
91
+ const isHighlighted = index === highlightedIndex;
92
+ if (isHighlighted) {
93
+ this.scrollToNode(node);
112
94
  }
113
- }, {
114
- key: "uncontrolledProps",
115
- value: function uncontrolledProps() {
116
- var _this2 = this;
117
- return _objectSpread(_objectSpread({}, _superPropGet(RootSelect2, "uncontrolledProps", this, 3)([])), {}, {
118
- visible: [null, function(visible) {
119
- if (visible === true) {
120
- var hasInputSearch = isAdvanceMode(_this2.asProps.Children, [Select.InputSearch.displayName, InputSearch.displayName], true);
121
- var defaultIndex = hasInputSearch || lastInteraction.isMouse() ? null : _this2.props.defaultHighlightedIndex;
122
- _this2.handlers.highlightedIndex(defaultIndex);
123
- setTimeout(function() {
124
- var _this2$menuRef$curren, _this2$menuRef$curren2;
125
- var options = (_this2$menuRef$curren = _this2.menuRef.current) === null || _this2$menuRef$curren === void 0 ? void 0 : _this2$menuRef$curren.querySelectorAll('[role="option"]');
126
- var selected = (_this2$menuRef$curren2 = _this2.menuRef.current) === null || _this2$menuRef$curren2 === void 0 ? void 0 : _this2$menuRef$curren2.querySelector('[aria-selected="true"]');
127
- if (selected && options) {
128
- _this2.scrollToNode(selected);
129
- for (var i = 0; i < options.length; i++) {
130
- if (options[i] === selected) {
131
- _this2.handlers.highlightedIndex(i);
132
- break;
133
- }
95
+ }
96
+ uncontrolledProps() {
97
+ return {
98
+ ...super.uncontrolledProps(),
99
+ visible: [null, (visible) => {
100
+ if (visible === true) {
101
+ const hasInputSearch = isAdvanceMode(this.asProps.Children, [Select.InputSearch.displayName, InputSearch.displayName], true);
102
+ const defaultIndex = hasInputSearch || lastInteraction.isMouse() ? null : this.props.defaultHighlightedIndex;
103
+ this.handlers.highlightedIndex(defaultIndex);
104
+ setTimeout(() => {
105
+ var _a, _b;
106
+ const options = (_a = this.menuRef.current) == null ? void 0 : _a.querySelectorAll('[role="option"]');
107
+ const selected = (_b = this.menuRef.current) == null ? void 0 : _b.querySelector('[aria-selected="true"]');
108
+ if (selected && options) {
109
+ this.scrollToNode(selected);
110
+ for (let i = 0; i < options.length; i++) {
111
+ if (options[i] === selected) {
112
+ this.handlers.highlightedIndex(i);
113
+ break;
134
114
  }
135
115
  }
136
- }, 30);
137
- }
138
- }],
139
- value: null
140
- });
141
- }
142
- }, {
143
- key: "getTriggerProps",
144
- value: function getTriggerProps() {
145
- var _this3 = this;
146
- var _this$asProps2 = this.asProps, disabled = _this$asProps2.disabled, visible = _this$asProps2.visible, state = _this$asProps2.state, placeholder = _this$asProps2.placeholder, value = _this$asProps2.value, options = _this$asProps2.options, forwardRef = _this$asProps2.forwardRef, name = _this$asProps2.name, multiselect = _this$asProps2.multiselect, getI18nText = _this$asProps2.getI18nText, highlightedIndex = _this$asProps2.highlightedIndex, uid = _this$asProps2.uid, Children = _this$asProps2.Children, hasChildren = _this$asProps2.children;
147
- var isMenu = isAdvanceMode(Children, [Select.Menu.displayName], true) || !hasChildren;
148
- var ariaControls = isMenu ? "igc-".concat(uid, "-list") : "igc-".concat(uid, "-popper");
149
- return _objectSpread(_objectSpread({}, _superPropGet(RootSelect2, "getTriggerProps", this, 3)([])), {}, {
150
- "onKeyDown": callAllEventHandlers(this.handlePreventCommonKeyDown.bind(this), this.handleOpenKeyDown.bind(this), this.handleArrowKeyDown.bind(this)),
151
- "aria-controls": visible ? ariaControls : void 0,
152
- "aria-haspopup": isMenu ? "listbox" : "dialog",
153
- "aria-disabled": disabled ? "true" : "false",
154
- "aria-activedescendant": visible && highlightedIndex !== null && this.itemRefs[highlightedIndex] ? "igc-".concat(uid, "-option-").concat(highlightedIndex) : void 0,
155
- "empty": isEmptyValue(value),
156
- value,
157
- name,
158
- "$hiddenRef": forwardRef,
159
- multiselect,
160
- state,
161
- placeholder,
162
- disabled,
163
- "active": visible,
164
- "onClear": this.handlerClear,
165
- "children": this.renderChildrenTrigger(value, options),
166
- getI18nText,
167
- "onBlur": function onBlur() {
168
- if (_this3.asProps.visible) {
169
- _this3.prevHighlightedIndex = _this3.asProps.highlightedIndex;
170
- _this3.handlers.highlightedIndex(null);
171
- }
172
- },
173
- "onFocus": function onFocus() {
174
- if (_this3.asProps.visible) {
175
- var index = _this3.prevHighlightedIndex;
176
- _this3.handlers.highlightedIndex(index);
177
- }
116
+ }
117
+ }, 30);
118
+ }
119
+ }],
120
+ value: null
121
+ };
122
+ }
123
+ getTriggerProps() {
124
+ const {
125
+ disabled,
126
+ visible,
127
+ state,
128
+ placeholder,
129
+ value,
130
+ options,
131
+ forwardRef,
132
+ name,
133
+ multiselect,
134
+ getI18nText,
135
+ highlightedIndex,
136
+ uid,
137
+ Children,
138
+ children: hasChildren
139
+ } = this.asProps;
140
+ const isMenu = isAdvanceMode(Children, [Select.Menu.displayName], true) || !hasChildren;
141
+ const ariaControls = isMenu ? `igc-${uid}-list` : `igc-${uid}-popper`;
142
+ return {
143
+ ...super.getTriggerProps(),
144
+ "onKeyDown": callAllEventHandlers(this.handlePreventCommonKeyDown.bind(this), this.handleOpenKeyDown.bind(this), this.handleArrowKeyDown.bind(this)),
145
+ "aria-controls": visible ? ariaControls : void 0,
146
+ "aria-haspopup": isMenu ? "listbox" : "dialog",
147
+ "aria-disabled": disabled ? "true" : "false",
148
+ "aria-activedescendant": visible && highlightedIndex !== null && this.itemRefs[highlightedIndex] ? `igc-${uid}-option-${highlightedIndex}` : void 0,
149
+ "empty": isEmptyValue(value),
150
+ value,
151
+ name,
152
+ "$hiddenRef": forwardRef,
153
+ multiselect,
154
+ state,
155
+ placeholder,
156
+ disabled,
157
+ "active": visible,
158
+ "onClear": this.handlerClear,
159
+ "children": this.renderChildrenTrigger(value, options),
160
+ getI18nText,
161
+ "onBlur": () => {
162
+ if (this.asProps.visible) {
163
+ this.prevHighlightedIndex = this.asProps.highlightedIndex;
164
+ this.handlers.highlightedIndex(null);
165
+ }
166
+ },
167
+ "onFocus": () => {
168
+ if (this.asProps.visible) {
169
+ const index = this.prevHighlightedIndex;
170
+ this.handlers.highlightedIndex(index);
178
171
  }
179
- });
180
- }
181
- }, {
182
- key: "getListProps",
183
- value: function getListProps() {
184
- var multiselect = this.asProps.multiselect;
185
- return _objectSpread(_objectSpread({}, _superPropGet(RootSelect2, "getListProps", this, 3)([])), {}, {
186
- "aria-multiselectable": multiselect ? "true" : void 0
187
- });
188
- }
189
- }, {
190
- key: "getPopperProps",
191
- value: function getPopperProps() {
192
- return _objectSpread(_objectSpread({}, _superPropGet(RootSelect2, "getPopperProps", this, 3)([])), {}, {
193
- onKeyDown: callAllEventHandlers(this.handlePreventCommonKeyDown.bind(this), this.handlePreventPopperKeyDown.bind(this), this.handleArrowKeyDown.bind(this))
194
- });
195
- }
196
- }, {
197
- key: "getOptionProps",
198
- value: function getOptionProps(props, index) {
199
- var _props$selected, _this4 = this;
200
- var _this$asProps3 = this.asProps, value = _this$asProps3.value, highlightedIndex = _this$asProps3.highlightedIndex, _this$asProps3$size = _this$asProps3.size, size = _this$asProps3$size === void 0 ? "m" : _this$asProps3$size;
201
- var highlighted = index === highlightedIndex && lastInteraction.isKeyboard() && !props.disabled;
202
- var selected = (_props$selected = props.selected) !== null && _props$selected !== void 0 ? _props$selected : isSelectedOption(value, props.value);
203
- return _objectSpread(_objectSpread({}, _superPropGet(RootSelect2, "getItemProps", this, 3)([props, index])), {}, {
204
- highlighted,
205
- selected,
206
- "aria-selected": selected ? "true" : "false",
207
- "aria-disabled": props.disabled ? "true" : "false",
208
- "role": "option",
209
- "onClick": this.bindHandlerOptionClick(props.value, index),
210
- "ref": function ref(node) {
211
- return _this4.itemRef(props, index, node);
212
- },
213
- size
214
- });
215
- }
216
- }, {
217
- key: "getOptionCheckboxProps",
218
- value: function getOptionCheckboxProps() {
219
- var _this$asProps4 = this.asProps, size = _this$asProps4.size, resolveColor = _this$asProps4.resolveColor;
220
- return {
221
- size,
222
- resolveColor
223
- };
224
- }
225
- }, {
226
- key: "getDividerProps",
227
- value: function getDividerProps() {
228
- return {
229
- "my": 1,
230
- "aria-disabled": "true"
231
- };
232
- }
233
- }, {
234
- key: "renderChildrenTrigger",
235
- value: function renderChildrenTrigger(value, options) {
236
- if (options) {
237
- return [].concat(value).reduce(function(acc, value2) {
238
- var selectedOption = options.find(function(o) {
239
- return isSelectedOption(value2, o.value);
240
- });
241
- if (!selectedOption) return acc;
242
- if (acc.length) acc.push(", ");
243
- acc.push(selectedOption.label || selectedOption.value);
244
- return acc;
245
- }, []);
246
172
  }
247
- return Array.isArray(value) ? value.reduce(function(acc, value2) {
173
+ };
174
+ }
175
+ getListProps() {
176
+ const {
177
+ multiselect
178
+ } = this.asProps;
179
+ return {
180
+ ...super.getListProps(),
181
+ "aria-multiselectable": multiselect ? "true" : void 0
182
+ };
183
+ }
184
+ getPopperProps() {
185
+ return {
186
+ ...super.getPopperProps(),
187
+ onKeyDown: callAllEventHandlers(this.handlePreventCommonKeyDown.bind(this), this.handlePreventPopperKeyDown.bind(this), this.handleArrowKeyDown.bind(this))
188
+ };
189
+ }
190
+ getOptionProps(props, index) {
191
+ const {
192
+ value,
193
+ highlightedIndex,
194
+ size = "m"
195
+ } = this.asProps;
196
+ const highlighted = index === highlightedIndex && lastInteraction.isKeyboard() && !props.disabled;
197
+ const selected = props.selected ?? isSelectedOption(value, props.value);
198
+ return {
199
+ ...super.getItemProps(props, index),
200
+ highlighted,
201
+ selected,
202
+ "aria-selected": selected ? "true" : "false",
203
+ "aria-disabled": props.disabled ? "true" : "false",
204
+ "role": "option",
205
+ "onClick": this.bindHandlerOptionClick(props.value, index),
206
+ "ref": (node) => this.itemRef(props, index, node),
207
+ size
208
+ };
209
+ }
210
+ getOptionCheckboxProps() {
211
+ const {
212
+ size,
213
+ resolveColor
214
+ } = this.asProps;
215
+ return {
216
+ size,
217
+ resolveColor
218
+ };
219
+ }
220
+ getDividerProps() {
221
+ return {
222
+ "my": 1,
223
+ "aria-disabled": "true"
224
+ };
225
+ }
226
+ renderChildrenTrigger(value, options) {
227
+ if (options) {
228
+ return [].concat(value).reduce((acc, value2) => {
229
+ const selectedOption = options.find((o) => isSelectedOption(value2, o.value));
230
+ if (!selectedOption) return acc;
248
231
  if (acc.length) acc.push(", ");
249
- acc.push(value2);
232
+ acc.push(selectedOption.label || selectedOption.value);
250
233
  return acc;
251
- }, []) : value;
234
+ }, []);
252
235
  }
253
- }, {
254
- key: "render",
255
- value: function render() {
256
- var _ref2 = this.asProps;
257
- var _this$asProps5 = this.asProps, Children = _this$asProps5.Children, options = _this$asProps5.options, multiselect = _this$asProps5.multiselect;
258
- _this$asProps5.value;
259
- var uid = _this$asProps5.uid, forcedAdvancedMode = _this$asProps5.forcedAdvancedMode, other = _objectWithoutProperties(_this$asProps5, _excluded);
260
- var advancedMode = forcedAdvancedMode || findComponent(Children, [Select.Trigger.displayName, Select.Popper.displayName]);
261
- logger.warn(options && advancedMode, "Don't use at the same time 'options' property and '<Select.Trigger/>/<Select.Popper/>'", other["data-ui-name"] || Select.displayName);
262
- this.itemProps = [];
263
- if (options) {
264
- var _ref = this.asProps;
265
- return /* @__PURE__ */ React.createElement(DropdownMenu, assignProps({}, _ref), /* @__PURE__ */ React.createElement(Select.Trigger, other), /* @__PURE__ */ React.createElement(Select.Menu, null, options.map(function(option, index) {
266
- return /* @__PURE__ */ React.createElement(Select.Option, _extends({
267
- key: option.value,
268
- id: "igc-".concat(uid, "-option-").concat(index)
269
- }, option), multiselect && /* @__PURE__ */ React.createElement(Select.Option.Checkbox, null), option.children);
270
- })));
271
- }
272
- return /* @__PURE__ */ React.createElement(DropdownMenu, assignProps({}, _ref2), /* @__PURE__ */ React.createElement(Children, null));
236
+ return Array.isArray(value) ? value.reduce((acc, value2) => {
237
+ if (acc.length) acc.push(", ");
238
+ acc.push(value2);
239
+ return acc;
240
+ }, []) : value;
241
+ }
242
+ render() {
243
+ var _ref2 = this.asProps;
244
+ const {
245
+ Children,
246
+ options,
247
+ multiselect,
248
+ value: _value,
249
+ uid,
250
+ forcedAdvancedMode,
251
+ ...other
252
+ } = this.asProps;
253
+ const advancedMode = forcedAdvancedMode || findComponent(Children, [Select.Trigger.displayName, Select.Popper.displayName]);
254
+ logger.warn(options && advancedMode, "Don't use at the same time 'options' property and '<Select.Trigger/>/<Select.Popper/>'", other["data-ui-name"] || Select.displayName);
255
+ this.itemProps = [];
256
+ if (options) {
257
+ var _ref = this.asProps;
258
+ return /* @__PURE__ */ React.createElement(DropdownMenu, assignProps({}, _ref), /* @__PURE__ */ React.createElement(Select.Trigger, other), /* @__PURE__ */ React.createElement(Select.Menu, null, options.map((option, index) => {
259
+ return /* @__PURE__ */ React.createElement(Select.Option, _extends({
260
+ key: option.value,
261
+ id: `igc-${uid}-option-${index}`
262
+ }, option), multiselect && /* @__PURE__ */ React.createElement(Select.Option.Checkbox, null), option.children);
263
+ })));
273
264
  }
274
- }]);
275
- })(AbstractDropdown);
265
+ return /* @__PURE__ */ React.createElement(DropdownMenu, assignProps({}, _ref2), /* @__PURE__ */ React.createElement(Children, null));
266
+ }
267
+ }
276
268
  _defineProperty(RootSelect, "displayName", "Select");
277
269
  _defineProperty(RootSelect, "style", style);
278
270
  _defineProperty(RootSelect, "enhance", Object.values(enhance).concat([resolveColorEnhance()]));
279
- _defineProperty(RootSelect, "defaultProps", function(props) {
280
- var _props$highlightedInd, _props$selectedIndex, _props$interaction, _props$timeout;
281
- var hasInputSearch = props.children && isAdvanceMode(props.children, [Select.InputSearch.displayName, InputSearch.displayName], true);
282
- var defaultIndex = hasInputSearch ? null : 0;
271
+ _defineProperty(RootSelect, "defaultProps", (props) => {
272
+ const hasInputSearch = props.children && isAdvanceMode(props.children, [Select.InputSearch.displayName, InputSearch.displayName], true);
273
+ const defaultIndex = hasInputSearch ? null : 0;
283
274
  return {
284
275
  placeholder: props.multiselect ? "Select options" : "Select option",
285
276
  size: "m",
286
277
  defaultValue: getEmptyValue(props.multiselect),
287
278
  defaultVisible: false,
288
- defaultHighlightedIndex: (_props$highlightedInd = props.highlightedIndex) !== null && _props$highlightedInd !== void 0 ? _props$highlightedInd : defaultIndex,
289
- defaultSelectedIndex: (_props$selectedIndex = props.selectedIndex) !== null && _props$selectedIndex !== void 0 ? _props$selectedIndex : defaultIndex,
279
+ defaultHighlightedIndex: props.highlightedIndex ?? defaultIndex,
280
+ defaultSelectedIndex: props.selectedIndex ?? defaultIndex,
290
281
  scrollToSelected: true,
291
282
  i18n: localizedMessages,
292
283
  locale: "en",
293
- interaction: (_props$interaction = props.interaction) !== null && _props$interaction !== void 0 ? _props$interaction : "click",
284
+ interaction: props.interaction ?? "click",
294
285
  inlineActions: false,
295
- timeout: (_props$timeout = props.timeout) !== null && _props$timeout !== void 0 ? _props$timeout : 0
286
+ timeout: props.timeout ?? 0
296
287
  };
297
288
  });
298
- function Trigger(_ref0) {
289
+ function Trigger({
290
+ Children,
291
+ name,
292
+ value,
293
+ styles,
294
+ $hiddenRef,
295
+ tag: Tag = ButtonTrigger,
296
+ getI18nText
297
+ }) {
299
298
  var _ref3 = arguments[0], _ref7;
300
- var Children = _ref0.Children, name = _ref0.name, value = _ref0.value, styles = _ref0.styles, $hiddenRef = _ref0.$hiddenRef, _ref0$tag = _ref0.tag, Tag = _ref0$tag === void 0 ? ButtonTrigger : _ref0$tag, getI18nText = _ref0.getI18nText;
301
- var hasInputTrigger = isInputTriggerTag(Tag);
302
- var SSelectTrigger = Dropdown.Trigger;
303
- return _ref7 = sstyled(styles), /* @__PURE__ */ React.createElement(SSelectTrigger, _ref7.cn("SSelectTrigger", _objectSpread({}, assignProps({
304
- "tag": Tag,
305
- "placeholder": getI18nText("selectPlaceholder"),
306
- "role": "combobox",
307
- "aria-autocomplete": hasInputTrigger && "list" || void 0
308
- }, _ref3))), addonTextChildren(Children, Tag.Text || Tag.Value || ButtonTrigger.Text, Tag.Addon || ButtonTrigger.Addon, true), name && /* @__PURE__ */ React.createElement("input", _ref7.cn("input", {
299
+ const hasInputTrigger = isInputTriggerTag(Tag);
300
+ const SSelectTrigger = Dropdown.Trigger;
301
+ return _ref7 = sstyled(styles), /* @__PURE__ */ React.createElement(SSelectTrigger, _ref7.cn("SSelectTrigger", {
302
+ ...assignProps({
303
+ "tag": Tag,
304
+ "placeholder": getI18nText("selectPlaceholder"),
305
+ "role": "combobox",
306
+ "aria-autocomplete": hasInputTrigger && "list" || void 0
307
+ }, _ref3)
308
+ }), addonTextChildren(Children, Tag.Text || Tag.Value || ButtonTrigger.Text, Tag.Addon || ButtonTrigger.Addon, true), name && /* @__PURE__ */ React.createElement("input", _ref7.cn("input", {
309
309
  "type": "hidden",
310
310
  "defaultValue": value,
311
311
  "name": name,
@@ -314,8 +314,16 @@ function Trigger(_ref0) {
314
314
  }
315
315
  function Menu(props) {
316
316
  var _ref4 = arguments[0];
317
- var visible = props.visible, disablePortal = props.disablePortal, ignorePortalsStacking = props.ignorePortalsStacking, disableEnforceFocus = props.disableEnforceFocus, interaction = props.interaction, autoFocus = props.autoFocus, animationsDisabled = props.animationsDisabled;
318
- var popperProps = {
317
+ const {
318
+ visible,
319
+ disablePortal,
320
+ ignorePortalsStacking,
321
+ disableEnforceFocus,
322
+ interaction,
323
+ autoFocus,
324
+ animationsDisabled
325
+ } = props;
326
+ const popperProps = {
319
327
  visible,
320
328
  disablePortal,
321
329
  ignorePortalsStacking,
@@ -328,46 +336,91 @@ function Menu(props) {
328
336
  role: null
329
337
  }), /* @__PURE__ */ React.createElement(Select.List, assignProps({}, _ref4))));
330
338
  }
331
- var optionPropsContext = /* @__PURE__ */ React.createContext({});
339
+ const optionPropsContext = /* @__PURE__ */ React.createContext({});
332
340
  function Option(props) {
333
341
  var _ref5 = arguments[0], _ref8;
334
- var SSelectOption = Dropdown.Item;
335
- var styles = props.styles, Children = props.Children;
336
- var hasCheckbox = isAdvanceMode(Children, [Select.Option.Checkbox.displayName]);
337
- var hasContent = isAdvanceMode(Children, [Select.Option.Content.displayName]);
338
- return _ref8 = sstyled(styles), /* @__PURE__ */ React.createElement(SSelectOption, _ref8.cn("SSelectOption", _objectSpread({}, assignProps({}, _ref5))), /* @__PURE__ */ React.createElement(optionPropsContext.Provider, {
339
- value: props
342
+ const SSelectOption = Dropdown.Item;
343
+ const {
344
+ styles,
345
+ Children,
346
+ highlighted
347
+ } = props;
348
+ const itemRef = React.useRef(null);
349
+ const hasCheckbox = isAdvanceMode(Children, [Select.Option.Checkbox.displayName]);
350
+ const hasContent = isAdvanceMode(Children, [Select.Option.Content.displayName]);
351
+ const optionPropsContextValue = {
352
+ ...props,
353
+ itemRef,
354
+ highlighted
355
+ };
356
+ return _ref8 = sstyled(styles), /* @__PURE__ */ React.createElement(SSelectOption, _ref8.cn("SSelectOption", {
357
+ ...assignProps({
358
+ "ref": itemRef
359
+ }, _ref5)
360
+ }), /* @__PURE__ */ React.createElement(optionPropsContext.Provider, {
361
+ value: optionPropsContextValue
340
362
  }, hasCheckbox && !hasContent ? /* @__PURE__ */ React.createElement(Select.Option.Content, null, /* @__PURE__ */ React.createElement(Children, _ref8.cn("Children", {}))) : /* @__PURE__ */ React.createElement(Children, _ref8.cn("Children", {}))));
341
363
  }
342
364
  function Checkbox(providedProps) {
343
- var optionProps = React.useContext(optionPropsContext);
344
- var props = React.useMemo(function() {
345
- return _objectSpread({
346
- selected: optionProps === null || optionProps === void 0 ? void 0 : optionProps.selected,
347
- disabled: optionProps === null || optionProps === void 0 ? void 0 : optionProps.disabled,
348
- size: optionProps === null || optionProps === void 0 ? void 0 : optionProps.size
349
- }, providedProps || {});
350
- }, [providedProps, optionProps]);
351
- var _useBox = useBox(props, props.forwardRef), _useBox2 = _slicedToArray(_useBox, 2), SOptionCheckbox = _useBox2[0], componentProps = _useBox2[1];
352
- var size = props.size, theme = props.theme, selected = props.selected, resolveColor = props.resolveColor, indeterminate = props.indeterminate;
353
- var styles = sstyled(props.styles);
354
- var _styles$cn = styles.cn("SOptionCheckbox", {
365
+ const optionProps = React.useContext(optionPropsContext);
366
+ const props = React.useMemo(() => ({
367
+ selected: optionProps == null ? void 0 : optionProps.selected,
368
+ disabled: optionProps == null ? void 0 : optionProps.disabled,
369
+ size: optionProps == null ? void 0 : optionProps.size,
370
+ ...providedProps || {}
371
+ }), [providedProps, optionProps]);
372
+ const [SOptionCheckbox, componentProps] = useBox(props, props.forwardRef);
373
+ const {
374
+ size,
375
+ theme,
376
+ selected,
377
+ resolveColor,
378
+ indeterminate
379
+ } = props;
380
+ const styles = sstyled(props.styles);
381
+ const {
382
+ className,
383
+ style: style2
384
+ } = styles.cn("SOptionCheckbox", {
355
385
  size,
356
386
  "use:theme": resolveColor(theme),
357
387
  indeterminate,
358
388
  selected
359
- }), className = _styles$cn.className, style2 = _styles$cn.style;
389
+ });
360
390
  return /* @__PURE__ */ React.createElement(SOptionCheckbox, _extends({}, componentProps, {
361
391
  className: cn(className, componentProps.className) || void 0,
362
- style: _objectSpread(_objectSpread({}, style2), componentProps.style),
392
+ style: {
393
+ ...style2,
394
+ ...componentProps.style
395
+ },
363
396
  tabIndex: -1
364
397
  }));
365
398
  }
366
- var InputSearchWrapper = function InputSearchWrapper2() {
399
+ function OptionText(providedProps) {
400
+ var _ref9;
401
+ const optionProps = React.useContext(optionPropsContext);
402
+ const selectedIndex = React.useContext(selectedIndexContext);
403
+ const props = React.useMemo(() => ({
404
+ key: optionProps == null ? void 0 : optionProps.id,
405
+ selected: optionProps == null ? void 0 : optionProps.selected,
406
+ disabled: optionProps == null ? void 0 : optionProps.disabled,
407
+ size: optionProps == null ? void 0 : optionProps.size,
408
+ hintProps: (optionProps == null ? void 0 : optionProps.hintProps) ?? {},
409
+ ...providedProps || {}
410
+ }), [providedProps, optionProps]);
411
+ if (optionProps.itemRef) {
412
+ props.hintProps.triggerRef = optionProps.itemRef;
413
+ }
414
+ props.hintProps.visible = selectedIndex === optionProps.index;
415
+ return _ref9 = sstyled(props.styles), /* @__PURE__ */ React.createElement(Text, _ref9.cn("Text", {
416
+ ...props
417
+ }));
418
+ }
419
+ const InputSearchWrapper = function() {
367
420
  var _ref6 = arguments[0];
368
421
  return /* @__PURE__ */ React.createElement(InputSearch, assignProps({}, _ref6));
369
422
  };
370
- var Select = createComponent(RootSelect, {
423
+ const Select = createComponent(RootSelect, {
371
424
  Trigger: [Trigger, {
372
425
  Addon: ButtonTrigger.Addon,
373
426
  Text: ButtonTrigger.Text
@@ -378,12 +431,11 @@ var Select = createComponent(RootSelect, {
378
431
  Option: [Option, {
379
432
  Addon: DropdownMenu.Item.Addon,
380
433
  Content: DropdownMenu.Item.Content,
434
+ Text: OptionText,
381
435
  Hint: DropdownMenu.Item.Hint,
382
436
  Checkbox
383
437
  }],
384
438
  Group: Dropdown.Group,
385
- OptionTitle: DropdownMenu.ItemTitle,
386
- OptionHint: DropdownMenu.ItemHint,
387
439
  Divider,
388
440
  InputSearch: [InputSearchWrapper, InputSearch._______childrenComponents],
389
441
  Input: [InputSearchWrapper, InputSearch._______childrenComponents]
@@ -391,9 +443,7 @@ var Select = createComponent(RootSelect, {
391
443
  parent: DropdownMenu,
392
444
  context: selectContext
393
445
  });
394
- var wrapSelect = function wrapSelect2(wrapper) {
395
- return wrapper;
396
- };
446
+ const wrapSelect = (wrapper) => wrapper;
397
447
  Select.selectedIndexContext = selectedIndexContext;
398
448
  export {
399
449
  Select as default,