@semcore/select 4.52.0 → 4.52.1-prerelease.0

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,102 +1,133 @@
1
- import K from "@babel/runtime/helpers/esm/slicedToArray";
2
- import M from "@babel/runtime/helpers/esm/extends";
3
- import J from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
- import h from "@babel/runtime/helpers/esm/objectSpread2";
5
- import Q from "@babel/runtime/helpers/esm/classCallCheck";
6
- import V from "@babel/runtime/helpers/esm/createClass";
7
- import A from "@babel/runtime/helpers/esm/assertThisInitialized";
8
- import y from "@babel/runtime/helpers/esm/get";
9
- import C from "@babel/runtime/helpers/esm/getPrototypeOf";
10
- import U from "@babel/runtime/helpers/esm/inherits";
11
- import X from "@babel/runtime/helpers/esm/createSuper";
12
- import b from "@babel/runtime/helpers/esm/defineProperty";
13
- import { sstyled as F } from "@semcore/utils/lib/core/index";
14
- import q, { assignProps as S, sstyled as R } from "@semcore/core";
15
- import g from "react";
16
- import Y from "classnames";
17
- import v from "@semcore/dropdown-menu";
18
- import w, { enhance as ee, selectedIndexContext as te, AbstractDropdown as re } from "@semcore/dropdown";
19
- import { ButtonTrigger as I } from "@semcore/base-trigger";
20
- import ne from "@semcore/divider";
21
- import ie, { isAdvanceMode as k } from "@semcore/utils/lib/findComponent";
22
- import oe from "@semcore/utils/lib/logger";
23
- import ae from "@semcore/utils/lib/enhances/resolveColorEnhance";
24
- import le from "@semcore/utils/lib/addonTextChildren";
25
- import D from "./InputSearch.mjs";
26
- import { useBox as se } from "@semcore/flex-box";
27
- import { selectContext as de } from "./context.mjs";
28
- import { localizedMessages as ce } from "./translations/__intergalactic-dynamic-locales.mjs";
29
- import { isInputTriggerTag as _e } from "@semcore/popper";
30
- import { callAllEventHandlers as N } from "@semcore/utils/lib/assignProps";
31
- var ge = ["Children", "options", "multiselect", "value", "uid", "forcedAdvancedMode"], ue = (
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ 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 _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
8
+ import _get from "@babel/runtime/helpers/esm/get";
9
+ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
10
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
11
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
12
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
13
+ import { sstyled } from "@semcore/utils/lib/core/index";
14
+ import createComponent, { assignProps, sstyled as sstyled$1 } from "@semcore/core";
15
+ import React from "react";
16
+ import cn from "classnames";
17
+ import DropdownMenu from "@semcore/dropdown-menu";
18
+ import Dropdown, { enhance, selectedIndexContext, AbstractDropdown } from "@semcore/dropdown";
19
+ import { ButtonTrigger } from "@semcore/base-trigger";
20
+ import Divider from "@semcore/divider";
21
+ import findComponent, { isAdvanceMode } from "@semcore/utils/lib/findComponent";
22
+ import logger from "@semcore/utils/lib/logger";
23
+ import resolveColorEnhance from "@semcore/utils/lib/enhances/resolveColorEnhance";
24
+ import addonTextChildren from "@semcore/utils/lib/addonTextChildren";
25
+ import InputSearch from "./InputSearch.mjs";
26
+ import { useBox } from "@semcore/flex-box";
27
+ import { selectContext } from "./context.mjs";
28
+ import { localizedMessages } from "./translations/__intergalactic-dynamic-locales.mjs";
29
+ import { isInputTriggerTag } from "@semcore/popper";
30
+ import { callAllEventHandlers } from "@semcore/utils/lib/assignProps";
31
+ var _excluded = ["Children", "options", "multiselect", "value", "uid", "forcedAdvancedMode"];
32
+ /*!__reshadow-styles__:"./style/select.shadow.css"*/
33
+ var style = (
32
34
  /*__reshadow_css_start__*/
33
- (F.insert(
35
+ (sstyled.insert(
34
36
  /*__inner_css_start__*/
35
- '.___SOptionCheckbox_r4x1n_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_r4x1n_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_r4x1n_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_r4x1n_gg_.__selected_r4x1n_gg_::after{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAiIGhlaWdodD0iNyIgdmlld0JveD0iMCAwIDEwIDciIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik04LjI1IDFMNCA1LjI1TDEuNzUgMyIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPC9zdmc+Cg==)}.___SOptionCheckbox_r4x1n_gg_._size_l_r4x1n_gg_{width:20px;height:20px}.___SOptionCheckbox_r4x1n_gg_._size_l_r4x1n_gg_.__selected_r4x1n_gg_::after{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iOSIgdmlld0JveD0iMCAwIDEyIDkiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik0xMSAxLjVMNC43NSA3Ljc1TDEgNCIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPC9zdmc+Cg==)}.___SOptionCheckbox_r4x1n_gg_.__indeterminate_r4x1n_gg_:before,.___SOptionCheckbox_r4x1n_gg_.__selected_r4x1n_gg_:before{background-color:var(--intergalactic-control-primary-info, #008ff8);border-color:var(--intergalactic-control-primary-info, #008ff8)}.___SOptionCheckbox_r4x1n_gg_.__theme_r4x1n_gg_:before{border-color:var(--theme_r4x1n)}.___SOptionCheckbox_r4x1n_gg_.__theme_r4x1n_gg_.__indeterminate_r4x1n_gg_:before,.___SOptionCheckbox_r4x1n_gg_.__theme_r4x1n_gg_.__selected_r4x1n_gg_:before{background-color:var(--theme_r4x1n);border-color:var(--theme_r4x1n)}.___SOptionCheckbox_r4x1n_gg_.__selected_r4x1n_gg_{background-color:var(--intergalactic-dropdown-menu-item-selected, rgba(196, 229, 254, 0.7))}@media (hover:hover){.___SOptionCheckbox_r4x1n_gg_.__selected_r4x1n_gg_:hover{background-color:var(--intergalactic-dropdown-menu-item-selected-hover, #c4e5fe)}}.___SOptionCheckbox_r4x1n_gg_.__indeterminate_r4x1n_gg_:after{background-color:#fff;background-image:none;margin:auto;border-radius:1px}.___SOptionCheckbox_r4x1n_gg_.__indeterminate_r4x1n_gg_._size_l_r4x1n_gg_:after{width:12px;height:2px}.___SOptionCheckbox_r4x1n_gg_.__indeterminate_r4x1n_gg_._size_m_r4x1n_gg_:after{width:8px;height:2px}',
36
- "r4x1n_gg_"
37
- ), {
38
- __SOptionCheckbox: "___SOptionCheckbox_r4x1n_gg_",
39
- _selected: "__selected_r4x1n_gg_",
40
- _size_l: "_size_l_r4x1n_gg_",
41
- _indeterminate: "__indeterminate_r4x1n_gg_",
42
- _theme: "__theme_r4x1n_gg_",
43
- "--theme": "--theme_r4x1n",
44
- _size_m: "_size_m_r4x1n_gg_"
37
+ '.___SOptionCheckbox_1k85u_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_1k85u_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_1k85u_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_1k85u_gg_.__selected_1k85u_gg_::after{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAiIGhlaWdodD0iNyIgdmlld0JveD0iMCAwIDEwIDciIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik04LjI1IDFMNCA1LjI1TDEuNzUgMyIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPC9zdmc+Cg==)}.___SOptionCheckbox_1k85u_gg_._size_l_1k85u_gg_{width:20px;height:20px}.___SOptionCheckbox_1k85u_gg_._size_l_1k85u_gg_.__selected_1k85u_gg_::after{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iOSIgdmlld0JveD0iMCAwIDEyIDkiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik0xMSAxLjVMNC43NSA3Ljc1TDEgNCIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPC9zdmc+Cg==)}.___SOptionCheckbox_1k85u_gg_.__indeterminate_1k85u_gg_:before,.___SOptionCheckbox_1k85u_gg_.__selected_1k85u_gg_:before{background-color:var(--intergalactic-control-primary-info, #008ff8);border-color:var(--intergalactic-control-primary-info, #008ff8)}.___SOptionCheckbox_1k85u_gg_.__theme_1k85u_gg_:before{border-color:var(--theme_1k85u)}.___SOptionCheckbox_1k85u_gg_.__theme_1k85u_gg_.__indeterminate_1k85u_gg_:before,.___SOptionCheckbox_1k85u_gg_.__theme_1k85u_gg_.__selected_1k85u_gg_:before{background-color:var(--theme_1k85u);border-color:var(--theme_1k85u)}.___SOptionCheckbox_1k85u_gg_.__selected_1k85u_gg_{background-color:var(--intergalactic-dropdown-menu-item-selected, rgba(196, 229, 254, 0.7))}@media (hover:hover){.___SOptionCheckbox_1k85u_gg_.__selected_1k85u_gg_:hover{background-color:var(--intergalactic-dropdown-menu-item-selected-hover, #c4e5fe)}}.___SOptionCheckbox_1k85u_gg_.__indeterminate_1k85u_gg_:after{background-color:#fff;background-image:none;margin:auto;border-radius:1px}.___SOptionCheckbox_1k85u_gg_.__indeterminate_1k85u_gg_._size_l_1k85u_gg_:after{width:12px;height:2px}.___SOptionCheckbox_1k85u_gg_.__indeterminate_1k85u_gg_._size_m_1k85u_gg_:after{width:8px;height:2px}',
38
+ /*__inner_css_end__*/
39
+ "1k85u_gg_"
40
+ ), /*__reshadow_css_end__*/
41
+ {
42
+ "__SOptionCheckbox": "___SOptionCheckbox_1k85u_gg_",
43
+ "_selected": "__selected_1k85u_gg_",
44
+ "_size_l": "_size_l_1k85u_gg_",
45
+ "_indeterminate": "__indeterminate_1k85u_gg_",
46
+ "_theme": "__theme_1k85u_gg_",
47
+ "--theme": "--theme_1k85u",
48
+ "_size_m": "_size_m_1k85u_gg_"
45
49
  })
46
50
  );
47
- function E(n, l) {
48
- return Array.isArray(n) ? n.includes(l) : l === n;
51
+ function isSelectedOption(value, valueOption) {
52
+ return Array.isArray(value) ? value.includes(valueOption) : valueOption === value;
49
53
  }
50
- function he(n) {
51
- return Array.isArray(n) ? n.length === 0 : n === null;
54
+ function isEmptyValue(value) {
55
+ return Array.isArray(value) ? value.length === 0 : value === null;
52
56
  }
53
- function $(n) {
54
- return n ? [] : null;
57
+ function getEmptyValue(multiselect) {
58
+ return multiselect ? [] : null;
55
59
  }
56
- var O = /* @__PURE__ */ function(n) {
57
- U(i, n);
58
- var l = X(i);
59
- function i() {
60
- var o;
61
- Q(this, i);
62
- for (var e = arguments.length, t = new Array(e), r = 0; r < e; r++)
63
- t[r] = arguments[r];
64
- return o = l.call.apply(l, [this].concat(t)), b(A(o), "role", "listbox"), b(A(o), "bindHandlerOptionClick", function(a, s) {
65
- return function(d) {
66
- var _ = a, u = o.asProps, c = u.value, f = u.multiselect;
67
- Array.isArray(c) && (c.includes(a) ? _ = c.filter(function(m) {
68
- return m !== a;
69
- }) : _ = c.concat(a)), o.handlers.value(_, d), f || (o.handlers.visible(!1), d.preventDefault());
60
+ var RootSelect = /* @__PURE__ */ function(_AbstractDropdown) {
61
+ _inherits(RootSelect2, _AbstractDropdown);
62
+ var _super = _createSuper(RootSelect2);
63
+ function RootSelect2() {
64
+ var _this;
65
+ _classCallCheck(this, RootSelect2);
66
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
67
+ args[_key] = arguments[_key];
68
+ }
69
+ _this = _super.call.apply(_super, [this].concat(args));
70
+ _defineProperty(_assertThisInitialized(_this), "role", "listbox");
71
+ _defineProperty(_assertThisInitialized(_this), "bindHandlerOptionClick", function(optionValue, index) {
72
+ return function(e) {
73
+ var newValue = optionValue;
74
+ var _this$asProps = _this.asProps, value = _this$asProps.value, multiselect = _this$asProps.multiselect;
75
+ if (Array.isArray(value)) {
76
+ if (value.includes(optionValue)) {
77
+ newValue = value.filter(function(v) {
78
+ return v !== optionValue;
79
+ });
80
+ } else {
81
+ newValue = value.concat(optionValue);
82
+ }
83
+ }
84
+ _this.handlers.value(newValue, e);
85
+ if (!multiselect) {
86
+ _this.handlers.visible(false);
87
+ e.preventDefault();
88
+ }
70
89
  };
71
- }), b(A(o), "handlerClear", function(a) {
72
- var s = o.asProps.value, d = $(Array.isArray(s));
73
- o.handlers.value(d, a), o.handlers.visible(!1);
74
- }), o;
90
+ });
91
+ _defineProperty(_assertThisInitialized(_this), "handlerClear", function(e) {
92
+ var value = _this.asProps.value;
93
+ var emptyValue = getEmptyValue(Array.isArray(value));
94
+ _this.handlers.value(emptyValue, e);
95
+ _this.handlers.visible(false);
96
+ });
97
+ return _this;
75
98
  }
76
- return V(i, [{
99
+ _createClass(RootSelect2, [{
77
100
  key: "itemRef",
78
- value: function(e, t, r) {
79
- y(C(i.prototype), "itemRef", this).call(this, e, t, r);
80
- var a = this.asProps.highlightedIndex, s = t === a;
81
- s && this.scrollToNode(r);
101
+ value: function itemRef(props, index, node) {
102
+ _get(_getPrototypeOf(RootSelect2.prototype), "itemRef", this).call(this, props, index, node);
103
+ var highlightedIndex = this.asProps.highlightedIndex;
104
+ var isHighlighted = index === highlightedIndex;
105
+ if (isHighlighted) {
106
+ this.scrollToNode(node);
107
+ }
82
108
  }
83
109
  }, {
84
110
  key: "uncontrolledProps",
85
- value: function() {
86
- var e = this;
87
- return h(h({}, y(C(i.prototype), "uncontrolledProps", this).call(this)), {}, {
88
- visible: [null, function(t) {
89
- if (t === !0) {
90
- var r = k(e.asProps.Children, [p.InputSearch.displayName], !0), a = r ? null : e.props.defaultHighlightedIndex;
91
- e.handlers.highlightedIndex(a), setTimeout(function() {
92
- var s, d, _ = (s = e.menuRef.current) === null || s === void 0 ? void 0 : s.querySelectorAll('[role="option"]'), u = (d = e.menuRef.current) === null || d === void 0 ? void 0 : d.querySelector('[aria-selected="true"]');
93
- if (u && _) {
94
- e.scrollToNode(u);
95
- for (var c = 0; c < _.length; c++)
96
- if (_[c] === u) {
97
- e.handlers.highlightedIndex(c);
111
+ value: function uncontrolledProps() {
112
+ var _this2 = this;
113
+ return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(RootSelect2.prototype), "uncontrolledProps", this).call(this)), {}, {
114
+ visible: [null, function(visible) {
115
+ if (visible === true) {
116
+ var hasInputSearch = isAdvanceMode(_this2.asProps.Children, [Select.InputSearch.displayName], true);
117
+ var defaultIndex = hasInputSearch ? null : _this2.props.defaultHighlightedIndex;
118
+ _this2.handlers.highlightedIndex(defaultIndex);
119
+ setTimeout(function() {
120
+ var _this2$menuRef$curren, _this2$menuRef$curren2;
121
+ var options = (_this2$menuRef$curren = _this2.menuRef.current) === null || _this2$menuRef$curren === void 0 ? void 0 : _this2$menuRef$curren.querySelectorAll('[role="option"]');
122
+ var selected = (_this2$menuRef$curren2 = _this2.menuRef.current) === null || _this2$menuRef$curren2 === void 0 ? void 0 : _this2$menuRef$curren2.querySelector('[aria-selected="true"]');
123
+ if (selected && options) {
124
+ _this2.scrollToNode(selected);
125
+ for (var i = 0; i < options.length; i++) {
126
+ if (options[i] === selected) {
127
+ _this2.handlers.highlightedIndex(i);
98
128
  break;
99
129
  }
130
+ }
100
131
  }
101
132
  }, 30);
102
133
  }
@@ -106,81 +137,90 @@ var O = /* @__PURE__ */ function(n) {
106
137
  }
107
138
  }, {
108
139
  key: "getTriggerProps",
109
- value: function() {
110
- var e = this, t = this.asProps, r = t.disabled, a = t.visible, s = t.state, d = t.placeholder, _ = t.value, u = t.options, c = t.forwardRef, f = t.name, m = t.multiselect, x = t.getI18nText, T = t.highlightedIndex, P = t.uid, G = t.Children, Z = t.children, z = k(G, [p.Menu.displayName], !0) || !Z, j = z ? "igc-".concat(P, "-list") : "igc-".concat(P, "-popper");
111
- return h(h({}, y(C(i.prototype), "getTriggerProps", this).call(this)), {}, {
112
- onKeyDown: N(this.handlePreventCommonKeyDown.bind(this), this.handleOpenKeyDown.bind(this), this.handleArrowKeyDown.bind(this)),
113
- "aria-controls": a ? j : void 0,
114
- "aria-haspopup": z ? "listbox" : "dialog",
115
- "aria-disabled": r ? "true" : "false",
116
- "aria-activedescendant": a && T !== null && this.itemRefs[T] ? "igc-".concat(P, "-option-").concat(T) : void 0,
117
- empty: he(_),
118
- value: _,
119
- name: f,
120
- $hiddenRef: c,
121
- multiselect: m,
122
- state: s,
123
- placeholder: d,
124
- disabled: r,
125
- active: a,
140
+ value: function getTriggerProps() {
141
+ var _this3 = this;
142
+ 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;
143
+ var isMenu = isAdvanceMode(Children, [Select.Menu.displayName], true) || !hasChildren;
144
+ var ariaControls = isMenu ? "igc-".concat(uid, "-list") : "igc-".concat(uid, "-popper");
145
+ return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(RootSelect2.prototype), "getTriggerProps", this).call(this)), {}, {
146
+ onKeyDown: callAllEventHandlers(this.handlePreventCommonKeyDown.bind(this), this.handleOpenKeyDown.bind(this), this.handleArrowKeyDown.bind(this)),
147
+ "aria-controls": visible ? ariaControls : void 0,
148
+ "aria-haspopup": isMenu ? "listbox" : "dialog",
149
+ "aria-disabled": disabled ? "true" : "false",
150
+ "aria-activedescendant": visible && highlightedIndex !== null && this.itemRefs[highlightedIndex] ? "igc-".concat(uid, "-option-").concat(highlightedIndex) : void 0,
151
+ empty: isEmptyValue(value),
152
+ value,
153
+ name,
154
+ $hiddenRef: forwardRef,
155
+ multiselect,
156
+ state,
157
+ placeholder,
158
+ disabled,
159
+ active: visible,
126
160
  onClear: this.handlerClear,
127
- children: this.renderChildrenTrigger(_, u),
128
- getI18nText: x,
129
- onBlur: function() {
130
- e.asProps.visible && (e.prevHighlightedIndex = e.asProps.highlightedIndex, e.handlers.highlightedIndex(null));
161
+ children: this.renderChildrenTrigger(value, options),
162
+ getI18nText,
163
+ onBlur: function onBlur() {
164
+ if (_this3.asProps.visible) {
165
+ _this3.prevHighlightedIndex = _this3.asProps.highlightedIndex;
166
+ _this3.handlers.highlightedIndex(null);
167
+ }
131
168
  },
132
- onFocus: function() {
133
- if (e.asProps.visible) {
134
- var B = e.prevHighlightedIndex;
135
- e.handlers.highlightedIndex(B);
169
+ onFocus: function onFocus() {
170
+ if (_this3.asProps.visible) {
171
+ var index = _this3.prevHighlightedIndex;
172
+ _this3.handlers.highlightedIndex(index);
136
173
  }
137
174
  }
138
175
  });
139
176
  }
140
177
  }, {
141
178
  key: "getListProps",
142
- value: function() {
143
- var e = this.asProps.multiselect;
144
- return h(h({}, y(C(i.prototype), "getListProps", this).call(this)), {}, {
145
- "aria-multiselectable": e ? "true" : void 0
179
+ value: function getListProps() {
180
+ var multiselect = this.asProps.multiselect;
181
+ return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(RootSelect2.prototype), "getListProps", this).call(this)), {}, {
182
+ "aria-multiselectable": multiselect ? "true" : void 0
146
183
  });
147
184
  }
148
185
  }, {
149
186
  key: "getPopperProps",
150
- value: function() {
151
- return h(h({}, y(C(i.prototype), "getPopperProps", this).call(this)), {}, {
152
- onKeyDown: N(this.handlePreventCommonKeyDown.bind(this), this.handlePreventPopperKeyDown.bind(this), this.handleArrowKeyDown.bind(this))
187
+ value: function getPopperProps() {
188
+ return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(RootSelect2.prototype), "getPopperProps", this).call(this)), {}, {
189
+ onKeyDown: callAllEventHandlers(this.handlePreventCommonKeyDown.bind(this), this.handlePreventPopperKeyDown.bind(this), this.handleArrowKeyDown.bind(this))
153
190
  });
154
191
  }
155
192
  }, {
156
193
  key: "getOptionProps",
157
- value: function(e, t) {
158
- var r, a = this, s = this.asProps, d = s.value, _ = s.highlightedIndex, u = s.focusSourceRef, c = s.size, f = c === void 0 ? "m" : c, m = t === _ && u.current === "keyboard" && !e.disabled, x = (r = e.selected) !== null && r !== void 0 ? r : E(d, e.value);
159
- return h(h({}, y(C(i.prototype), "getItemProps", this).call(this, e, t)), {}, {
160
- highlighted: m,
161
- selected: x,
162
- "aria-selected": x ? "true" : "false",
163
- "aria-disabled": e.disabled ? "true" : "false",
194
+ value: function getOptionProps(props, index) {
195
+ var _props$selected, _this4 = this;
196
+ var _this$asProps3 = this.asProps, value = _this$asProps3.value, highlightedIndex = _this$asProps3.highlightedIndex, focusSourceRef = _this$asProps3.focusSourceRef, _this$asProps3$size = _this$asProps3.size, size = _this$asProps3$size === void 0 ? "m" : _this$asProps3$size;
197
+ var highlighted = index === highlightedIndex && focusSourceRef.current === "keyboard" && !props.disabled;
198
+ var selected = (_props$selected = props.selected) !== null && _props$selected !== void 0 ? _props$selected : isSelectedOption(value, props.value);
199
+ return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(RootSelect2.prototype), "getItemProps", this).call(this, props, index)), {}, {
200
+ highlighted,
201
+ selected,
202
+ "aria-selected": selected ? "true" : "false",
203
+ "aria-disabled": props.disabled ? "true" : "false",
164
204
  role: "option",
165
- onClick: this.bindHandlerOptionClick(e.value, t),
166
- ref: function(P) {
167
- return a.itemRef(e, t, P);
205
+ onClick: this.bindHandlerOptionClick(props.value, index),
206
+ ref: function ref(node) {
207
+ return _this4.itemRef(props, index, node);
168
208
  },
169
- size: f
209
+ size
170
210
  });
171
211
  }
172
212
  }, {
173
213
  key: "getOptionCheckboxProps",
174
- value: function() {
175
- var e = this.asProps, t = e.size, r = e.resolveColor;
214
+ value: function getOptionCheckboxProps() {
215
+ var _this$asProps4 = this.asProps, size = _this$asProps4.size, resolveColor = _this$asProps4.resolveColor;
176
216
  return {
177
- size: t,
178
- resolveColor: r
217
+ size,
218
+ resolveColor
179
219
  };
180
220
  }
181
221
  }, {
182
222
  key: "getDividerProps",
183
- value: function() {
223
+ value: function getDividerProps() {
184
224
  return {
185
225
  my: 1,
186
226
  "aria-disabled": "true"
@@ -188,126 +228,155 @@ var O = /* @__PURE__ */ function(n) {
188
228
  }
189
229
  }, {
190
230
  key: "renderChildrenTrigger",
191
- value: function(e, t) {
192
- return t ? [].concat(e).reduce(function(r, a) {
193
- var s = t.find(function(d) {
194
- return E(a, d.value);
195
- });
196
- return s && (r.length && r.push(", "), r.push(s.label || s.value)), r;
197
- }, []) : Array.isArray(e) ? e.reduce(function(r, a) {
198
- return r.length && r.push(", "), r.push(a), r;
199
- }, []) : e;
231
+ value: function renderChildrenTrigger(value, options) {
232
+ if (options) {
233
+ return [].concat(value).reduce(function(acc, value2) {
234
+ var selectedOption = options.find(function(o) {
235
+ return isSelectedOption(value2, o.value);
236
+ });
237
+ if (!selectedOption) return acc;
238
+ if (acc.length) acc.push(", ");
239
+ acc.push(selectedOption.label || selectedOption.value);
240
+ return acc;
241
+ }, []);
242
+ }
243
+ return Array.isArray(value) ? value.reduce(function(acc, value2) {
244
+ if (acc.length) acc.push(", ");
245
+ acc.push(value2);
246
+ return acc;
247
+ }, []) : value;
200
248
  }
201
249
  }, {
202
250
  key: "render",
203
- value: function() {
204
- var e = this.asProps, t = this.asProps, r = t.Children, a = t.options, s = t.multiselect;
205
- t.value;
206
- var d = t.uid, _ = t.forcedAdvancedMode, u = J(t, ge), c = _ || ie(r, [p.Trigger.displayName, p.Popper.displayName]);
207
- if (oe.warn(a && c, "Don't use at the same time 'options' property and '<Select.Trigger/>/<Select.Popper/>'", u["data-ui-name"] || p.displayName), this.itemProps = [], a) {
208
- var f = this.asProps;
209
- return /* @__PURE__ */ g.createElement(v, S({}, f), /* @__PURE__ */ g.createElement(p.Trigger, u), /* @__PURE__ */ g.createElement(p.Menu, null, a.map(function(m, x) {
210
- return /* @__PURE__ */ g.createElement(p.Option, M({
211
- key: m.value,
212
- id: "igc-".concat(d, "-option-").concat(x)
213
- }, m), s && /* @__PURE__ */ g.createElement(p.Option.Checkbox, null), m.children);
251
+ value: function render() {
252
+ var _ref2 = this.asProps;
253
+ var _this$asProps5 = this.asProps, Children = _this$asProps5.Children, options = _this$asProps5.options, multiselect = _this$asProps5.multiselect;
254
+ _this$asProps5.value;
255
+ var uid = _this$asProps5.uid, forcedAdvancedMode = _this$asProps5.forcedAdvancedMode, other = _objectWithoutProperties(_this$asProps5, _excluded);
256
+ var advancedMode = forcedAdvancedMode || findComponent(Children, [Select.Trigger.displayName, Select.Popper.displayName]);
257
+ logger.warn(options && advancedMode, "Don't use at the same time 'options' property and '<Select.Trigger/>/<Select.Popper/>'", other["data-ui-name"] || Select.displayName);
258
+ this.itemProps = [];
259
+ if (options) {
260
+ var _ref = this.asProps;
261
+ return /* @__PURE__ */ React.createElement(DropdownMenu, assignProps({}, _ref), /* @__PURE__ */ React.createElement(Select.Trigger, other), /* @__PURE__ */ React.createElement(Select.Menu, null, options.map(function(option, index) {
262
+ return /* @__PURE__ */ React.createElement(Select.Option, _extends({
263
+ key: option.value,
264
+ id: "igc-".concat(uid, "-option-").concat(index)
265
+ }, option), multiselect && /* @__PURE__ */ React.createElement(Select.Option.Checkbox, null), option.children);
214
266
  })));
215
267
  }
216
- return /* @__PURE__ */ g.createElement(v, S({}, e), /* @__PURE__ */ g.createElement(r, null));
268
+ return /* @__PURE__ */ React.createElement(DropdownMenu, assignProps({}, _ref2), /* @__PURE__ */ React.createElement(Children, null));
217
269
  }
218
- }]), i;
219
- }(re);
220
- b(O, "displayName", "Select");
221
- b(O, "style", ue);
222
- b(O, "enhance", Object.values(ee).concat([ae()]));
223
- b(O, "defaultProps", function(n) {
224
- var l, i, o, e, t = n.children && k(n.children, [p.InputSearch.displayName], !0), r = t ? null : 0;
270
+ }]);
271
+ return RootSelect2;
272
+ }(AbstractDropdown);
273
+ _defineProperty(RootSelect, "displayName", "Select");
274
+ _defineProperty(RootSelect, "style", style);
275
+ _defineProperty(RootSelect, "enhance", Object.values(enhance).concat([resolveColorEnhance()]));
276
+ _defineProperty(RootSelect, "defaultProps", function(props) {
277
+ var _props$highlightedInd, _props$selectedIndex, _props$interaction, _props$timeout;
278
+ var hasInputSearch = props.children && isAdvanceMode(props.children, [Select.InputSearch.displayName], true);
279
+ var defaultIndex = hasInputSearch ? null : 0;
225
280
  return {
226
- placeholder: n.multiselect ? "Select options" : "Select option",
281
+ placeholder: props.multiselect ? "Select options" : "Select option",
227
282
  size: "m",
228
- defaultValue: $(n.multiselect),
229
- defaultVisible: !1,
230
- defaultHighlightedIndex: (l = n.highlightedIndex) !== null && l !== void 0 ? l : r,
231
- defaultSelectedIndex: (i = n.selectedIndex) !== null && i !== void 0 ? i : r,
232
- scrollToSelected: !0,
233
- i18n: ce,
283
+ defaultValue: getEmptyValue(props.multiselect),
284
+ defaultVisible: false,
285
+ defaultHighlightedIndex: (_props$highlightedInd = props.highlightedIndex) !== null && _props$highlightedInd !== void 0 ? _props$highlightedInd : defaultIndex,
286
+ defaultSelectedIndex: (_props$selectedIndex = props.selectedIndex) !== null && _props$selectedIndex !== void 0 ? _props$selectedIndex : defaultIndex,
287
+ scrollToSelected: true,
288
+ i18n: localizedMessages,
234
289
  locale: "en",
235
- interaction: (o = n.interaction) !== null && o !== void 0 ? o : "click",
236
- inlineActions: !1,
237
- timeout: (e = n.timeout) !== null && e !== void 0 ? e : 0
290
+ interaction: (_props$interaction = props.interaction) !== null && _props$interaction !== void 0 ? _props$interaction : "click",
291
+ inlineActions: false,
292
+ timeout: (_props$timeout = props.timeout) !== null && _props$timeout !== void 0 ? _props$timeout : 0
238
293
  };
239
294
  });
240
- function pe(n) {
241
- var l = arguments[0], i, o = n.Children, e = n.name, t = n.value, r = n.styles, a = n.$hiddenRef, s = n.tag, d = s === void 0 ? I : s, _ = n.getI18nText, u = _e(d), c = w.Trigger;
242
- return i = R(r), /* @__PURE__ */ g.createElement(c, i.cn("SSelectTrigger", h({}, S({
243
- tag: d,
244
- placeholder: _("selectPlaceholder"),
245
- role: "combobox",
246
- "aria-autocomplete": u && "list" || void 0
247
- }, l))), le(o, d.Text || I.Text, d.Value || I.Text, d.Addon || I.Addon, !0), e && /* @__PURE__ */ g.createElement("input", i.cn("input", {
248
- type: "hidden",
249
- defaultValue: t,
250
- name: e,
251
- ref: a
295
+ function Trigger(_ref8) {
296
+ var _ref3 = arguments[0], _ref6;
297
+ var Children = _ref8.Children, name = _ref8.name, value = _ref8.value, styles = _ref8.styles, $hiddenRef = _ref8.$hiddenRef, _ref8$tag = _ref8.tag, Tag = _ref8$tag === void 0 ? ButtonTrigger : _ref8$tag, getI18nText = _ref8.getI18nText;
298
+ var hasInputTrigger = isInputTriggerTag(Tag);
299
+ var SSelectTrigger = Dropdown.Trigger;
300
+ return _ref6 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SSelectTrigger, _ref6.cn("SSelectTrigger", _objectSpread({}, assignProps({
301
+ "tag": Tag,
302
+ "placeholder": getI18nText("selectPlaceholder"),
303
+ "role": "combobox",
304
+ "aria-autocomplete": hasInputTrigger && "list" || void 0
305
+ }, _ref3))), addonTextChildren(Children, Tag.Text || ButtonTrigger.Text, Tag.Value || ButtonTrigger.Text, Tag.Addon || ButtonTrigger.Addon, true), name && /* @__PURE__ */ React.createElement("input", _ref6.cn("input", {
306
+ "type": "hidden",
307
+ "defaultValue": value,
308
+ "name": name,
309
+ "ref": $hiddenRef
252
310
  })));
253
311
  }
254
- var L = /* @__PURE__ */ g.createContext({});
255
- function me(n) {
256
- var l = arguments[0], i, o = w.Item, e = n.styles, t = n.Children, r = k(t, [p.Option.Checkbox.displayName]), a = k(t, [p.Option.Content.displayName]);
257
- return i = R(e), /* @__PURE__ */ g.createElement(o, i.cn("SSelectOption", h({}, S({}, l))), /* @__PURE__ */ g.createElement(L.Provider, {
258
- value: n
259
- }, r && !a ? /* @__PURE__ */ g.createElement(p.Option.Content, null, /* @__PURE__ */ g.createElement(t, i.cn("Children", {}))) : /* @__PURE__ */ g.createElement(t, i.cn("Children", {}))));
312
+ var optionPropsContext = /* @__PURE__ */ React.createContext({});
313
+ function Option(props) {
314
+ var _ref4 = arguments[0], _ref7;
315
+ var SSelectOption = Dropdown.Item;
316
+ var styles = props.styles, Children = props.Children;
317
+ var hasCheckbox = isAdvanceMode(Children, [Select.Option.Checkbox.displayName]);
318
+ var hasContent = isAdvanceMode(Children, [Select.Option.Content.displayName]);
319
+ return _ref7 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SSelectOption, _ref7.cn("SSelectOption", _objectSpread({}, assignProps({}, _ref4))), /* @__PURE__ */ React.createElement(optionPropsContext.Provider, {
320
+ value: props
321
+ }, hasCheckbox && !hasContent ? /* @__PURE__ */ React.createElement(Select.Option.Content, null, /* @__PURE__ */ React.createElement(Children, _ref7.cn("Children", {}))) : /* @__PURE__ */ React.createElement(Children, _ref7.cn("Children", {}))));
260
322
  }
261
- function fe(n) {
262
- var l = g.useContext(L), i = g.useMemo(function() {
263
- return h({
264
- selected: l == null ? void 0 : l.selected,
265
- disabled: l == null ? void 0 : l.disabled,
266
- size: l == null ? void 0 : l.size
267
- }, n || {});
268
- }, [n, l]), o = se(i, i.forwardRef), e = K(o, 2), t = e[0], r = e[1], a = i.size, s = i.theme, d = i.selected, _ = i.resolveColor, u = i.indeterminate, c = R(i.styles), f = c.cn("SOptionCheckbox", {
269
- size: a,
270
- "use:theme": _(s),
271
- indeterminate: u,
272
- selected: d
273
- }), m = f.className, x = f.style;
274
- return /* @__PURE__ */ g.createElement(t, M({}, r, {
275
- className: Y(m, r.className) || void 0,
276
- style: h(h({}, x), r.style),
323
+ function Checkbox(providedProps) {
324
+ var optionProps = React.useContext(optionPropsContext);
325
+ var props = React.useMemo(function() {
326
+ return _objectSpread({
327
+ selected: optionProps === null || optionProps === void 0 ? void 0 : optionProps.selected,
328
+ disabled: optionProps === null || optionProps === void 0 ? void 0 : optionProps.disabled,
329
+ size: optionProps === null || optionProps === void 0 ? void 0 : optionProps.size
330
+ }, providedProps || {});
331
+ }, [providedProps, optionProps]);
332
+ var _useBox = useBox(props, props.forwardRef), _useBox2 = _slicedToArray(_useBox, 2), SOptionCheckbox = _useBox2[0], componentProps = _useBox2[1];
333
+ var size = props.size, theme = props.theme, selected = props.selected, resolveColor = props.resolveColor, indeterminate = props.indeterminate;
334
+ var styles = sstyled$1(props.styles);
335
+ var _styles$cn = styles.cn("SOptionCheckbox", {
336
+ size,
337
+ "use:theme": resolveColor(theme),
338
+ indeterminate,
339
+ selected
340
+ }), className = _styles$cn.className, style2 = _styles$cn.style;
341
+ return /* @__PURE__ */ React.createElement(SOptionCheckbox, _extends({}, componentProps, {
342
+ className: cn(className, componentProps.className) || void 0,
343
+ style: _objectSpread(_objectSpread({}, style2), componentProps.style),
277
344
  tabIndex: -1
278
345
  }));
279
346
  }
280
- var H = function() {
281
- var l = arguments[0];
282
- return /* @__PURE__ */ g.createElement(D, S({}, l));
283
- }, p = q(O, {
284
- Trigger: [pe, {
285
- Addon: I.Addon,
286
- Text: I.Text
347
+ var InputSearchWrapper = function InputSearchWrapper2() {
348
+ var _ref5 = arguments[0];
349
+ return /* @__PURE__ */ React.createElement(InputSearch, assignProps({}, _ref5));
350
+ };
351
+ var Select = createComponent(RootSelect, {
352
+ Trigger: [Trigger, {
353
+ Addon: ButtonTrigger.Addon,
354
+ Text: ButtonTrigger.Text
287
355
  }],
288
- Popper: w.Popper,
289
- List: v.List,
290
- Menu: v.Menu,
291
- Option: [me, {
292
- Addon: v.Item.Addon,
293
- Content: v.Item.Content,
294
- Hint: v.Item.Hint,
295
- Checkbox: fe
356
+ Popper: Dropdown.Popper,
357
+ List: DropdownMenu.List,
358
+ Menu: DropdownMenu.Menu,
359
+ Option: [Option, {
360
+ Addon: DropdownMenu.Item.Addon,
361
+ Content: DropdownMenu.Item.Content,
362
+ Hint: DropdownMenu.Item.Hint,
363
+ Checkbox
296
364
  }],
297
- Group: w.Group,
298
- OptionTitle: v.ItemTitle,
299
- OptionHint: v.ItemHint,
300
- Divider: ne,
301
- InputSearch: [H, D._______childrenComponents],
302
- Input: [H, D._______childrenComponents]
365
+ Group: Dropdown.Group,
366
+ OptionTitle: DropdownMenu.ItemTitle,
367
+ OptionHint: DropdownMenu.ItemHint,
368
+ Divider,
369
+ InputSearch: [InputSearchWrapper, InputSearch._______childrenComponents],
370
+ Input: [InputSearchWrapper, InputSearch._______childrenComponents]
303
371
  }, {
304
- parent: v,
305
- context: de
306
- }), Ve = function(l) {
307
- return l;
372
+ parent: DropdownMenu,
373
+ context: selectContext
374
+ });
375
+ var wrapSelect = function wrapSelect2(wrapper) {
376
+ return wrapper;
308
377
  };
309
- p.selectedIndexContext = te;
378
+ Select.selectedIndexContext = selectedIndexContext;
310
379
  export {
311
- p as default,
312
- Ve as wrapSelect
380
+ Select as default,
381
+ wrapSelect
313
382
  };