@semcore/select 4.51.0 → 16.0.0-prerelease.11

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