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