primereact 10.4.0 → 10.5.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.
- package/calendar/calendar.cjs.js +12 -4
- package/calendar/calendar.cjs.min.js +1 -1
- package/calendar/calendar.esm.js +12 -4
- package/calendar/calendar.esm.min.js +1 -1
- package/calendar/calendar.js +12 -4
- package/calendar/calendar.min.js +1 -1
- package/checkbox/checkbox.cjs.js +2 -0
- package/checkbox/checkbox.cjs.min.js +1 -1
- package/checkbox/checkbox.esm.js +2 -0
- package/checkbox/checkbox.esm.min.js +1 -1
- package/checkbox/checkbox.js +2 -0
- package/checkbox/checkbox.min.js +1 -1
- package/chips/chips.cjs.js +109 -20
- package/chips/chips.cjs.min.js +1 -1
- package/chips/chips.esm.js +109 -20
- package/chips/chips.esm.min.js +1 -1
- package/chips/chips.js +109 -20
- package/chips/chips.min.js +1 -1
- package/core/core.js +643 -465
- package/core/core.min.js +4 -4
- package/dropdown/dropdown.cjs.js +313 -141
- package/dropdown/dropdown.cjs.min.js +1 -1
- package/dropdown/dropdown.esm.js +313 -141
- package/dropdown/dropdown.esm.min.js +1 -1
- package/dropdown/dropdown.js +313 -141
- package/dropdown/dropdown.min.js +1 -1
- package/inputnumber/inputnumber.cjs.js +21 -17
- package/inputnumber/inputnumber.cjs.min.js +1 -1
- package/inputnumber/inputnumber.esm.js +21 -17
- package/inputnumber/inputnumber.esm.min.js +1 -1
- package/inputnumber/inputnumber.js +21 -17
- package/inputnumber/inputnumber.min.js +1 -1
- package/inputswitch/inputswitch.cjs.js +3 -1
- package/inputswitch/inputswitch.cjs.min.js +1 -1
- package/inputswitch/inputswitch.esm.js +3 -1
- package/inputswitch/inputswitch.esm.min.js +1 -1
- package/inputswitch/inputswitch.js +3 -1
- package/inputswitch/inputswitch.min.js +1 -1
- package/knob/knob.cjs.js +62 -0
- package/knob/knob.cjs.min.js +1 -1
- package/knob/knob.esm.js +62 -0
- package/knob/knob.esm.min.js +1 -1
- package/knob/knob.js +62 -0
- package/knob/knob.min.js +1 -1
- package/listbox/listbox.cjs.js +362 -92
- package/listbox/listbox.cjs.min.js +1 -1
- package/listbox/listbox.esm.js +363 -93
- package/listbox/listbox.esm.min.js +1 -1
- package/listbox/listbox.js +362 -92
- package/listbox/listbox.min.js +1 -1
- package/menu/menu.cjs.js +4 -2
- package/menu/menu.cjs.min.js +1 -1
- package/menu/menu.esm.js +4 -2
- package/menu/menu.esm.min.js +1 -1
- package/menu/menu.js +5 -4
- package/menu/menu.min.js +1 -1
- package/multiselect/multiselect.cjs.js +377 -107
- package/multiselect/multiselect.cjs.min.js +1 -1
- package/multiselect/multiselect.esm.js +377 -107
- package/multiselect/multiselect.esm.min.js +1 -1
- package/multiselect/multiselect.js +377 -107
- package/multiselect/multiselect.min.js +1 -1
- package/package.json +1 -1
- package/paginator/paginator.cjs.js +251 -251
- package/paginator/paginator.cjs.min.js +1 -1
- package/paginator/paginator.esm.js +258 -258
- package/paginator/paginator.esm.min.js +1 -1
- package/paginator/paginator.js +251 -251
- package/paginator/paginator.min.js +1 -1
- package/panelmenu/panelmenu.cjs.js +2 -1
- package/panelmenu/panelmenu.cjs.min.js +1 -1
- package/panelmenu/panelmenu.esm.js +2 -1
- package/panelmenu/panelmenu.esm.min.js +1 -1
- package/panelmenu/panelmenu.js +3 -3
- package/panelmenu/panelmenu.min.js +1 -1
- package/passthrough/tailwind/index.cjs.js +3 -2
- package/passthrough/tailwind/index.cjs.min.js +1 -1
- package/passthrough/tailwind/index.esm.js +3 -2
- package/passthrough/tailwind/index.esm.min.js +1 -1
- package/passthrough/tailwind/index.js +3 -2
- package/passthrough/tailwind/index.min.js +1 -1
- package/password/password.cjs.js +22 -20
- package/password/password.cjs.min.js +1 -1
- package/password/password.esm.js +22 -20
- package/password/password.esm.min.js +1 -1
- package/password/password.js +22 -20
- package/password/password.min.js +1 -1
- package/primereact.all.cjs.js +1473 -485
- package/primereact.all.cjs.min.js +1 -1
- package/primereact.all.esm.js +1473 -485
- package/primereact.all.esm.min.js +1 -1
- package/primereact.all.js +1473 -485
- package/primereact.all.min.js +1 -1
- package/radiobutton/radiobutton.cjs.js +1 -0
- package/radiobutton/radiobutton.cjs.min.js +1 -1
- package/radiobutton/radiobutton.esm.js +1 -0
- package/radiobutton/radiobutton.esm.min.js +1 -1
- package/radiobutton/radiobutton.js +1 -0
- package/radiobutton/radiobutton.min.js +1 -1
- package/rating/rating.cjs.js +103 -4
- package/rating/rating.cjs.min.js +1 -1
- package/rating/rating.esm.js +103 -4
- package/rating/rating.esm.min.js +1 -1
- package/rating/rating.js +103 -4
- package/rating/rating.min.js +1 -1
- package/resources/themes/arya-blue/theme.css +328 -67
- package/resources/themes/arya-green/theme.css +328 -67
- package/resources/themes/arya-orange/theme.css +328 -67
- package/resources/themes/arya-purple/theme.css +26 -6
- package/resources/themes/bootstrap4-dark-blue/theme.css +328 -67
- package/resources/themes/bootstrap4-dark-purple/theme.css +26 -6
- package/resources/themes/bootstrap4-light-blue/theme.css +328 -67
- package/resources/themes/bootstrap4-light-purple/theme.css +26 -6
- package/resources/themes/fluent-light/theme.css +327 -66
- package/resources/themes/lara-dark-amber/theme.css +328 -67
- package/resources/themes/lara-dark-blue/theme.css +328 -67
- package/resources/themes/lara-dark-cyan/theme.css +328 -67
- package/resources/themes/lara-dark-green/theme.css +328 -67
- package/resources/themes/lara-dark-indigo/theme.css +328 -67
- package/resources/themes/lara-dark-pink/theme.css +328 -67
- package/resources/themes/lara-dark-purple/theme.css +26 -6
- package/resources/themes/lara-dark-teal/theme.css +328 -67
- package/resources/themes/lara-light-amber/theme.css +328 -67
- package/resources/themes/lara-light-blue/theme.css +328 -67
- package/resources/themes/lara-light-cyan/theme.css +328 -67
- package/resources/themes/lara-light-green/theme.css +328 -67
- package/resources/themes/lara-light-indigo/theme.css +328 -67
- package/resources/themes/lara-light-pink/theme.css +328 -67
- package/resources/themes/lara-light-purple/theme.css +26 -6
- package/resources/themes/lara-light-teal/theme.css +328 -67
- package/resources/themes/luna-amber/theme.css +328 -67
- package/resources/themes/luna-blue/theme.css +328 -67
- package/resources/themes/luna-green/theme.css +328 -67
- package/resources/themes/luna-pink/theme.css +328 -67
- package/resources/themes/md-dark-deeppurple/theme.css +158 -138
- package/resources/themes/md-dark-indigo/theme.css +454 -193
- package/resources/themes/md-light-deeppurple/theme.css +26 -6
- package/resources/themes/md-light-indigo/theme.css +328 -67
- package/resources/themes/mdc-dark-deeppurple/theme.css +158 -138
- package/resources/themes/mdc-dark-indigo/theme.css +454 -193
- package/resources/themes/mdc-light-deeppurple/theme.css +26 -6
- package/resources/themes/mdc-light-indigo/theme.css +328 -67
- package/resources/themes/mira/theme.css +328 -67
- package/resources/themes/nano/theme.css +328 -67
- package/resources/themes/nova/theme.css +328 -67
- package/resources/themes/nova-accent/theme.css +328 -67
- package/resources/themes/nova-alt/theme.css +328 -67
- package/resources/themes/rhea/theme.css +328 -67
- package/resources/themes/saga-blue/theme.css +328 -67
- package/resources/themes/saga-green/theme.css +328 -67
- package/resources/themes/saga-orange/theme.css +328 -67
- package/resources/themes/saga-purple/theme.css +26 -6
- package/resources/themes/soho-dark/theme.css +353 -92
- package/resources/themes/soho-light/theme.css +328 -67
- package/resources/themes/tailwind-light/theme.css +329 -71
- package/resources/themes/vela-blue/theme.css +328 -67
- package/resources/themes/vela-green/theme.css +328 -67
- package/resources/themes/vela-orange/theme.css +328 -67
- package/resources/themes/vela-purple/theme.css +26 -6
- package/resources/themes/viva-dark/theme.css +328 -67
- package/resources/themes/viva-light/theme.css +328 -67
- package/selectbutton/selectbutton.cjs.js +96 -50
- package/selectbutton/selectbutton.cjs.min.js +1 -1
- package/selectbutton/selectbutton.esm.js +96 -50
- package/selectbutton/selectbutton.esm.min.js +1 -1
- package/selectbutton/selectbutton.js +96 -50
- package/selectbutton/selectbutton.min.js +1 -1
- package/slider/slider.cjs.js +25 -4
- package/slider/slider.cjs.min.js +1 -1
- package/slider/slider.esm.js +25 -4
- package/slider/slider.esm.min.js +1 -1
- package/slider/slider.js +25 -4
- package/slider/slider.min.js +1 -1
- package/splitter/splitter.cjs.js +16 -15
- package/splitter/splitter.cjs.min.js +1 -1
- package/splitter/splitter.esm.js +16 -15
- package/splitter/splitter.esm.min.js +1 -1
- package/splitter/splitter.js +16 -15
- package/splitter/splitter.min.js +1 -1
- package/tabview/tabview.cjs.js +6 -5
- package/tabview/tabview.cjs.min.js +1 -1
- package/tabview/tabview.d.ts +39 -34
- package/tabview/tabview.esm.js +6 -5
- package/tabview/tabview.esm.min.js +1 -1
- package/tabview/tabview.js +6 -5
- package/tabview/tabview.min.js +1 -1
- package/togglebutton/togglebutton.cjs.js +15 -14
- package/togglebutton/togglebutton.cjs.min.js +1 -1
- package/togglebutton/togglebutton.esm.js +14 -13
- package/togglebutton/togglebutton.esm.min.js +1 -1
- package/togglebutton/togglebutton.js +15 -14
- package/togglebutton/togglebutton.min.js +1 -1
- package/tristatecheckbox/tristatecheckbox.cjs.js +3 -2
- package/tristatecheckbox/tristatecheckbox.cjs.min.js +1 -1
- package/tristatecheckbox/tristatecheckbox.esm.js +3 -2
- package/tristatecheckbox/tristatecheckbox.esm.min.js +1 -1
- package/tristatecheckbox/tristatecheckbox.js +3 -2
- package/tristatecheckbox/tristatecheckbox.min.js +1 -1
- package/web-types.json +1 -1
|
@@ -105,6 +105,10 @@ function _toConsumableArray(arr) {
|
|
|
105
105
|
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread();
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
function _readOnlyError(name) {
|
|
109
|
+
throw new TypeError("\"" + name + "\" is read-only");
|
|
110
|
+
}
|
|
111
|
+
|
|
108
112
|
function _arrayWithHoles(arr) {
|
|
109
113
|
if (Array.isArray(arr)) return arr;
|
|
110
114
|
}
|
|
@@ -206,7 +210,8 @@ var classes$1 = {
|
|
|
206
210
|
var props = _ref5.itemProps;
|
|
207
211
|
return classNames('p-multiselect-item', {
|
|
208
212
|
'p-highlight': props.selected,
|
|
209
|
-
'p-disabled': props.disabled
|
|
213
|
+
'p-disabled': props.disabled,
|
|
214
|
+
'p-focus': props.focusedOptionIndex === props.index
|
|
210
215
|
});
|
|
211
216
|
},
|
|
212
217
|
checkboxContainer: 'p-checkbox p-component',
|
|
@@ -219,7 +224,7 @@ var classes$1 = {
|
|
|
219
224
|
},
|
|
220
225
|
transition: 'p-connected-overlay'
|
|
221
226
|
};
|
|
222
|
-
var styles$1 = "\n@layer primereact {\n .p-multiselect {\n display: inline-flex;\n user-select: none;\n cursor: pointer;\n }\n \n .p-multiselect-trigger {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n cursor: pointer;\n }\n \n .p-multiselect-label-container {\n overflow: hidden;\n flex: 1 1 auto;\n cursor: pointer;\n }\n \n .p-multiselect-label {\n display: block;\n white-space: nowrap;\n cursor: pointer;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n \n .p-multiselect-label-empty {\n overflow: hidden;\n visibility: hidden;\n }\n \n .p-multiselect-token {\n cursor: default;\n display: inline-flex;\n align-items: center;\n flex: 0 0 auto;\n }\n \n .p-multiselect-token-icon {\n cursor: pointer;\n }\n \n .p-multiselect .p-multiselect-panel {\n min-width: 100%;\n }\n \n .p-multiselect-inline.p-multiselect-panel {\n border: none;\n position: initial;\n background: none;\n box-shadow: none;\n }\n \n .p-multiselect-inline.p-multiselect-panel .p-multiselect-items {\n padding: 0;\n }\n \n .p-multiselect-flex.p-multiselect-panel .p-multiselect-items {\n display: flex;\n flex-wrap: wrap;\n }\n \n .p-multiselect-items-wrapper {\n overflow: auto;\n }\n \n .p-multiselect-items {\n margin: 0;\n padding: 0;\n list-style-type: none;\n }\n \n .p-multiselect-item {\n cursor: pointer;\n display: flex;\n align-items: center;\n font-weight: normal;\n white-space: nowrap;\n position: relative;\n overflow: hidden;\n }\n \n .p-multiselect-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n }\n \n .p-multiselect-select-all-label {\n margin-left: 0.5rem;\n }\n \n .p-multiselect-filter-container {\n position: relative;\n flex: 1 1 auto;\n }\n \n .p-multiselect-filter-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n }\n \n .p-multiselect-filter-container .p-inputtext {\n width: 100%;\n }\n \n .p-multiselect-close {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n overflow: hidden;\n position: relative;\n margin-left: auto;\n }\n \n .p-multiselect-clear-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n }\n \n .p-fluid .p-multiselect {\n display: flex;\n }\n}\n";
|
|
227
|
+
var styles$1 = "\n@layer primereact {\n .p-multiselect {\n display: inline-flex;\n user-select: none;\n cursor: pointer;\n }\n \n .p-multiselect-trigger {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n cursor: pointer;\n }\n \n .p-multiselect-label-container {\n overflow: hidden;\n flex: 1 1 auto;\n cursor: pointer;\n }\n \n .p-multiselect-label {\n display: block;\n white-space: nowrap;\n cursor: pointer;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n \n .p-multiselect-label-empty {\n overflow: hidden;\n visibility: hidden;\n }\n \n .p-multiselect-token {\n cursor: default;\n display: inline-flex;\n align-items: center;\n flex: 0 0 auto;\n }\n \n .p-multiselect-token-icon {\n cursor: pointer;\n }\n \n .p-multiselect .p-multiselect-panel {\n min-width: 100%;\n }\n \n .p-multiselect-inline.p-multiselect-panel {\n border: none;\n position: initial;\n background: none;\n box-shadow: none;\n }\n \n .p-multiselect-inline.p-multiselect-panel .p-multiselect-items {\n padding: 0;\n }\n \n .p-multiselect-flex.p-multiselect-panel .p-multiselect-items {\n display: flex;\n flex-wrap: wrap;\n }\n \n .p-multiselect-items-wrapper {\n overflow: auto;\n }\n \n .p-multiselect-items {\n margin: 0;\n padding: 0;\n list-style-type: none;\n }\n \n .p-multiselect-item {\n cursor: pointer;\n display: flex;\n align-items: center;\n font-weight: normal;\n white-space: nowrap;\n position: relative;\n overflow: hidden;\n outline: none;\n }\n \n .p-multiselect-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n }\n \n .p-multiselect-select-all-label {\n margin-left: 0.5rem;\n }\n \n .p-multiselect-filter-container {\n position: relative;\n flex: 1 1 auto;\n }\n \n .p-multiselect-filter-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n }\n \n .p-multiselect-filter-container .p-inputtext {\n width: 100%;\n }\n \n .p-multiselect-close {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n overflow: hidden;\n position: relative;\n margin-left: auto;\n }\n \n .p-multiselect-clear-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n right: 3rem;\n }\n \n .p-fluid .p-multiselect {\n display: flex;\n }\n}\n";
|
|
223
228
|
var inlineStyles = {
|
|
224
229
|
root: function root(_ref7) {
|
|
225
230
|
var props = _ref7.props;
|
|
@@ -253,6 +258,8 @@ var MultiSelectBase = ComponentBase.extend({
|
|
|
253
258
|
filterBy: null,
|
|
254
259
|
filterInputAutoFocus: true,
|
|
255
260
|
filterLocale: undefined,
|
|
261
|
+
selectOnFocus: false,
|
|
262
|
+
autoOptionFocus: false,
|
|
256
263
|
filterMatchMode: 'contains',
|
|
257
264
|
filterPlaceholder: null,
|
|
258
265
|
filterTemplate: null,
|
|
@@ -505,6 +512,8 @@ var Checkbox = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function (
|
|
|
505
512
|
onClick: function onClick(e) {
|
|
506
513
|
return _onClick(e);
|
|
507
514
|
},
|
|
515
|
+
'data-p-highlight': checked,
|
|
516
|
+
'data-p-disabled': props.disabled,
|
|
508
517
|
onContextMenu: props.onContextMenu,
|
|
509
518
|
onMouseDown: props.onMouseDown
|
|
510
519
|
}, otherProps, ptm('root'));
|
|
@@ -712,7 +721,9 @@ var MultiSelectItem = /*#__PURE__*/React.memo(function (props) {
|
|
|
712
721
|
context: {
|
|
713
722
|
selected: props.selected,
|
|
714
723
|
disabled: props.disabled,
|
|
715
|
-
focused: focusedState
|
|
724
|
+
focused: focusedState,
|
|
725
|
+
focusedIndex: props.focusedIndex,
|
|
726
|
+
index: props.index
|
|
716
727
|
}
|
|
717
728
|
});
|
|
718
729
|
};
|
|
@@ -724,22 +735,11 @@ var MultiSelectItem = /*#__PURE__*/React.memo(function (props) {
|
|
|
724
735
|
};
|
|
725
736
|
var onClick = function onClick(event) {
|
|
726
737
|
if (props.onClick) {
|
|
727
|
-
props.onClick(
|
|
728
|
-
originalEvent: event,
|
|
729
|
-
option: props.option
|
|
730
|
-
});
|
|
738
|
+
props.onClick(event, props.option);
|
|
731
739
|
}
|
|
732
740
|
event.preventDefault();
|
|
733
741
|
event.stopPropagation();
|
|
734
742
|
};
|
|
735
|
-
var onKeyDown = function onKeyDown(event) {
|
|
736
|
-
if (props.onKeyDown) {
|
|
737
|
-
props.onKeyDown({
|
|
738
|
-
originalEvent: event,
|
|
739
|
-
option: props.option
|
|
740
|
-
});
|
|
741
|
-
}
|
|
742
|
-
};
|
|
743
743
|
var checkboxIconProps = mergeProps({
|
|
744
744
|
className: cx('checkboxIcon')
|
|
745
745
|
}, getPTOptions('checkboxIcon'));
|
|
@@ -748,7 +748,7 @@ var MultiSelectItem = /*#__PURE__*/React.memo(function (props) {
|
|
|
748
748
|
selected: props.selected
|
|
749
749
|
}) : null;
|
|
750
750
|
var content = props.template ? ObjectUtils.getJSXElement(props.template, props.option) : props.label;
|
|
751
|
-
var tabIndex = props.disabled ?
|
|
751
|
+
var tabIndex = props.disabled ? -1 : props.tabIndex;
|
|
752
752
|
var checkboxContainerProps = mergeProps({
|
|
753
753
|
className: cx('checkboxContainer')
|
|
754
754
|
}, getPTOptions('checkboxContainer'));
|
|
@@ -764,7 +764,6 @@ var MultiSelectItem = /*#__PURE__*/React.memo(function (props) {
|
|
|
764
764
|
})),
|
|
765
765
|
style: props.style,
|
|
766
766
|
onClick: onClick,
|
|
767
|
-
onKeyDown: onKeyDown,
|
|
768
767
|
onFocus: onFocus,
|
|
769
768
|
onBlur: onBlur,
|
|
770
769
|
tabIndex: tabIndex,
|
|
@@ -866,14 +865,15 @@ var MultiSelectPanel = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(fu
|
|
|
866
865
|
var selected = props.isSelected(option);
|
|
867
866
|
return /*#__PURE__*/React.createElement(MultiSelectItem, {
|
|
868
867
|
hostName: props.hostName,
|
|
868
|
+
index: j,
|
|
869
869
|
key: optionKey,
|
|
870
|
+
focusedOptionIndex: props.focusedOptionIndex,
|
|
870
871
|
label: optionLabel,
|
|
871
872
|
option: option,
|
|
872
873
|
style: style,
|
|
873
874
|
template: props.itemTemplate,
|
|
874
875
|
selected: selected,
|
|
875
876
|
onClick: props.onOptionSelect,
|
|
876
|
-
onKeyDown: props.onOptionKeyDown,
|
|
877
877
|
tabIndex: tabIndex,
|
|
878
878
|
disabled: disabled,
|
|
879
879
|
className: props.itemClassName,
|
|
@@ -924,13 +924,14 @@ var MultiSelectPanel = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(fu
|
|
|
924
924
|
return /*#__PURE__*/React.createElement(MultiSelectItem, {
|
|
925
925
|
hostName: props.hostName,
|
|
926
926
|
key: optionKey,
|
|
927
|
+
focusedOptionIndex: props.focusedOptionIndex,
|
|
927
928
|
label: optionLabel,
|
|
928
929
|
option: option,
|
|
929
930
|
style: style,
|
|
931
|
+
index: index,
|
|
930
932
|
template: props.itemTemplate,
|
|
931
933
|
selected: selected,
|
|
932
934
|
onClick: props.onOptionSelect,
|
|
933
|
-
onKeyDown: props.onOptionKeyDown,
|
|
934
935
|
tabIndex: tabIndex,
|
|
935
936
|
disabled: disabled,
|
|
936
937
|
className: props.itemClassName,
|
|
@@ -1059,19 +1060,35 @@ var MultiSelect = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(functio
|
|
|
1059
1060
|
var mergeProps = useMergeProps();
|
|
1060
1061
|
var context = React.useContext(PrimeReactContext);
|
|
1061
1062
|
var props = MultiSelectBase.getProps(inProps, context);
|
|
1062
|
-
var _React$useState = React.useState(
|
|
1063
|
+
var _React$useState = React.useState(null),
|
|
1063
1064
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
1064
|
-
|
|
1065
|
-
|
|
1065
|
+
focusedOptionIndex = _React$useState2[0],
|
|
1066
|
+
setFocusedOptionIndex = _React$useState2[1];
|
|
1066
1067
|
var _React$useState3 = React.useState(false),
|
|
1067
1068
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
var _React$useState5 = React.useState(
|
|
1069
|
+
clicked = _React$useState4[0],
|
|
1070
|
+
setClicked = _React$useState4[1];
|
|
1071
|
+
var _React$useState5 = React.useState(''),
|
|
1071
1072
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
1072
|
-
|
|
1073
|
-
|
|
1073
|
+
filterState = _React$useState6[0],
|
|
1074
|
+
setFilterState = _React$useState6[1];
|
|
1075
|
+
var _React$useState7 = React.useState(-1),
|
|
1076
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
1077
|
+
startRangeIndex = _React$useState8[0],
|
|
1078
|
+
setStartRangeIndex = _React$useState8[1];
|
|
1079
|
+
var _React$useState9 = React.useState(false),
|
|
1080
|
+
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
1081
|
+
focusedState = _React$useState10[0],
|
|
1082
|
+
setFocusedState = _React$useState10[1];
|
|
1083
|
+
var _React$useState11 = React.useState(props.inline),
|
|
1084
|
+
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
|
1085
|
+
overlayVisibleState = _React$useState12[0],
|
|
1086
|
+
setOverlayVisibleState = _React$useState12[1];
|
|
1074
1087
|
var elementRef = React.useRef(null);
|
|
1088
|
+
var searchValue = React.useRef(null);
|
|
1089
|
+
var searchTimeout = React.useRef(null);
|
|
1090
|
+
var firstHiddenFocusableElementOnOverlay = React.useRef(null);
|
|
1091
|
+
var lastHiddenFocusableElementOnOverlay = React.useRef(null);
|
|
1075
1092
|
var inputRef = React.useRef(props.inputRef);
|
|
1076
1093
|
var labelRef = React.useRef(null);
|
|
1077
1094
|
var overlayRef = React.useRef(null);
|
|
@@ -1113,6 +1130,14 @@ var MultiSelect = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(functio
|
|
|
1113
1130
|
_useOverlayListener2 = _slicedToArray(_useOverlayListener, 2),
|
|
1114
1131
|
bindOverlayListener = _useOverlayListener2[0],
|
|
1115
1132
|
unbindOverlayListener = _useOverlayListener2[1];
|
|
1133
|
+
var onFirstHiddenFocus = function onFirstHiddenFocus(event) {
|
|
1134
|
+
var focusableEl = event.relatedTarget === inputRef.current ? DomHandler.getFirstFocusableElement(overlayRef.current, ':not([data-p-hidden-focusable="true"])') : inputRef.current;
|
|
1135
|
+
DomHandler.focus(focusableEl);
|
|
1136
|
+
};
|
|
1137
|
+
var onLastHiddenFocus = function onLastHiddenFocus(event) {
|
|
1138
|
+
var focusableEl = event.relatedTarget === inputRef.current ? DomHandler.getLastFocusableElement(overlayRef.current, ':not([data-p-hidden-focusable="true"])') : inputRef.current;
|
|
1139
|
+
DomHandler.focus(focusableEl);
|
|
1140
|
+
};
|
|
1116
1141
|
var onPanelClick = function onPanelClick(event) {
|
|
1117
1142
|
OverlayService.emit('overlay-click', {
|
|
1118
1143
|
originalEvent: event,
|
|
@@ -1122,63 +1147,60 @@ var MultiSelect = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(functio
|
|
|
1122
1147
|
var allowOptionSelect = function allowOptionSelect() {
|
|
1123
1148
|
return !props.selectionLimit || !props.value || props.value && props.value.length < props.selectionLimit;
|
|
1124
1149
|
};
|
|
1125
|
-
var
|
|
1126
|
-
var
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1150
|
+
var findNextSelectedOptionIndex = function findNextSelectedOptionIndex(index) {
|
|
1151
|
+
var matchedOptionIndex = hasSelectedOption && index < visibleOptions.length - 1 ? visibleOptions.slice(index + 1).findIndex(function (option) {
|
|
1152
|
+
return isValidSelectedOption(option);
|
|
1153
|
+
}) : -1;
|
|
1154
|
+
return matchedOptionIndex > -1 ? matchedOptionIndex + index + 1 : -1;
|
|
1155
|
+
};
|
|
1156
|
+
var findPrevSelectedOptionIndex = function findPrevSelectedOptionIndex(index) {
|
|
1157
|
+
var matchedOptionIndex = hasSelectedOption && index > 0 ? ObjectUtils.findLastIndex(visibleOptions.slice(0, index), function (option) {
|
|
1158
|
+
return isValidSelectedOption(option);
|
|
1159
|
+
}) : -1;
|
|
1160
|
+
return matchedOptionIndex > -1 ? matchedOptionIndex : -1;
|
|
1161
|
+
};
|
|
1162
|
+
var findNearestSelectedOptionIndex = function findNearestSelectedOptionIndex(index) {
|
|
1163
|
+
var firstCheckUp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1164
|
+
var matchedOptionIndex = -1;
|
|
1165
|
+
if (hasSelectedOption) {
|
|
1166
|
+
if (firstCheckUp) {
|
|
1167
|
+
matchedOptionIndex = findPrevSelectedOptionIndex(index);
|
|
1168
|
+
matchedOptionIndex = matchedOptionIndex === -1 ? findNextSelectedOptionIndex(index) : matchedOptionIndex;
|
|
1169
|
+
} else {
|
|
1170
|
+
matchedOptionIndex = findNextSelectedOptionIndex(index);
|
|
1171
|
+
matchedOptionIndex = matchedOptionIndex === -1 ? findPrevSelectedOptionIndex(index) : matchedOptionIndex;
|
|
1172
|
+
}
|
|
1130
1173
|
}
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
var
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1174
|
+
return matchedOptionIndex > -1 ? matchedOptionIndex : index;
|
|
1175
|
+
};
|
|
1176
|
+
var onOptionSelectRange = function onOptionSelectRange(event) {
|
|
1177
|
+
var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
|
|
1178
|
+
var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;
|
|
1179
|
+
start === -1 && (start = findNearestSelectedOptionIndex(end, true));
|
|
1180
|
+
end === -1 && (end = findNearestSelectedOptionIndex(start));
|
|
1181
|
+
if (start !== -1 && end !== -1) {
|
|
1182
|
+
var rangeStart = Math.min(start, end);
|
|
1183
|
+
var rangeEnd = Math.max(start, end);
|
|
1184
|
+
var value = visibleOptions.slice(rangeStart, rangeEnd + 1).filter(function (option) {
|
|
1185
|
+
return isValidOption(option);
|
|
1186
|
+
}).map(function (option) {
|
|
1187
|
+
return getOptionValue(option);
|
|
1188
|
+
});
|
|
1189
|
+
updateModel(event, value);
|
|
1141
1190
|
}
|
|
1142
1191
|
};
|
|
1143
|
-
var
|
|
1144
|
-
var
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
//down
|
|
1148
|
-
case 40:
|
|
1149
|
-
var nextItem = findNextItem(listItem);
|
|
1150
|
-
nextItem && nextItem.focus();
|
|
1151
|
-
originalEvent.preventDefault();
|
|
1152
|
-
break;
|
|
1153
|
-
|
|
1154
|
-
//up
|
|
1155
|
-
case 38:
|
|
1156
|
-
var prevItem = findPrevItem(listItem);
|
|
1157
|
-
prevItem && prevItem.focus();
|
|
1158
|
-
originalEvent.preventDefault();
|
|
1159
|
-
break;
|
|
1160
|
-
|
|
1161
|
-
//enter and space
|
|
1162
|
-
case 13:
|
|
1163
|
-
case 32:
|
|
1164
|
-
onOptionSelect(event);
|
|
1165
|
-
originalEvent.preventDefault();
|
|
1166
|
-
break;
|
|
1167
|
-
|
|
1168
|
-
//escape
|
|
1169
|
-
case 27:
|
|
1170
|
-
hide();
|
|
1171
|
-
DomHandler.focus(inputRef.current);
|
|
1172
|
-
break;
|
|
1192
|
+
var onOptionSelect = function onOptionSelect(event, option) {
|
|
1193
|
+
var index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;
|
|
1194
|
+
if (props.disabled || isOptionDisabled(option)) {
|
|
1195
|
+
return;
|
|
1173
1196
|
}
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
return prevItem ? DomHandler.getAttribute(prevItem, 'data-p-disabled') === true || DomHandler.getAttribute(prevItem, 'data-pc-section') === 'itemgroup' ? findPrevItem(prevItem) : prevItem : null;
|
|
1197
|
+
var selected = isSelected(option);
|
|
1198
|
+
var value = null;
|
|
1199
|
+
if (selected) value = props.value.filter(function (val) {
|
|
1200
|
+
return !ObjectUtils.equals(val, getOptionValue(option), equalityKey);
|
|
1201
|
+
});else value = [].concat(_toConsumableArray(props.value || []), [getOptionValue(option)]);
|
|
1202
|
+
updateModel(event, value);
|
|
1203
|
+
index !== -1 && setFocusedOptionIndex(index);
|
|
1182
1204
|
};
|
|
1183
1205
|
var onClick = function onClick(event) {
|
|
1184
1206
|
if (!props.inline && !props.disabled && !props.loading && !isPanelClicked(event) && DomHandler.getAttribute(event.target, 'data-pc-section') !== 'removetokenicon' && !isClearClicked(event)) {
|
|
@@ -1186,42 +1208,170 @@ var MultiSelect = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(functio
|
|
|
1186
1208
|
DomHandler.focus(inputRef.current);
|
|
1187
1209
|
event.preventDefault();
|
|
1188
1210
|
}
|
|
1211
|
+
setClicked(true);
|
|
1212
|
+
};
|
|
1213
|
+
var onArrowDownKey = function onArrowDownKey(event) {
|
|
1214
|
+
if (!overlayVisibleState) {
|
|
1215
|
+
show();
|
|
1216
|
+
props.editable && changeFocusedOptionIndex(event, findSelectedOptionIndex());
|
|
1217
|
+
} else {
|
|
1218
|
+
var optionIndex = focusedOptionIndex !== -1 ? findNextOptionIndex(focusedOptionIndex) : clicked ? findFirstOptionIndex() : findFirstFocusedOptionIndex();
|
|
1219
|
+
if (event.shiftKey) {
|
|
1220
|
+
onOptionSelectRange(event, startRangeIndex, optionIndex);
|
|
1221
|
+
}
|
|
1222
|
+
changeFocusedOptionIndex(event, optionIndex);
|
|
1223
|
+
}
|
|
1224
|
+
event.preventDefault();
|
|
1225
|
+
};
|
|
1226
|
+
var onArrowUpKey = function onArrowUpKey(event) {
|
|
1227
|
+
var pressedInInputText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1228
|
+
if (event.altKey && !pressedInInputText) {
|
|
1229
|
+
if (focusedOptionIndex !== -1) {
|
|
1230
|
+
onOptionSelect(event, visibleOptions[focusedOptionIndex]);
|
|
1231
|
+
}
|
|
1232
|
+
overlayVisibleState && hide();
|
|
1233
|
+
event.preventDefault();
|
|
1234
|
+
} else {
|
|
1235
|
+
var optionIndex = focusedOptionIndex !== -1 ? findPrevOptionIndex(focusedOptionIndex) : clicked ? findLastOptionIndex() : findLastFocusedOptionIndex();
|
|
1236
|
+
changeFocusedOptionIndex(event, optionIndex);
|
|
1237
|
+
!overlayVisibleState && show();
|
|
1238
|
+
event.preventDefault();
|
|
1239
|
+
}
|
|
1240
|
+
};
|
|
1241
|
+
var onEnterKey = function onEnterKey(event) {
|
|
1242
|
+
if (!overlayVisibleState) {
|
|
1243
|
+
setFocusedOptionIndex(-1);
|
|
1244
|
+
onArrowDownKey(event);
|
|
1245
|
+
} else {
|
|
1246
|
+
if (focusedOptionIndex !== -1) {
|
|
1247
|
+
if (event.shiftKey) onOptionSelectRange(event, focusedOptionIndex);else onOptionSelect(event, visibleOptions[focusedOptionIndex]);
|
|
1248
|
+
}
|
|
1249
|
+
hide();
|
|
1250
|
+
}
|
|
1251
|
+
event.preventDefault();
|
|
1252
|
+
};
|
|
1253
|
+
var onHomeKey = function onHomeKey(event) {
|
|
1254
|
+
var pressedInInputText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1255
|
+
var currentTarget = event.currentTarget;
|
|
1256
|
+
if (pressedInInputText) {
|
|
1257
|
+
var len = currentTarget.value.length;
|
|
1258
|
+
currentTarget.setSelectionRange(0, event.shiftKey ? len : 0);
|
|
1259
|
+
setFocusedOptionIndex(-1);
|
|
1260
|
+
} else {
|
|
1261
|
+
var metaKey = event.metaKey || event.ctrlKey;
|
|
1262
|
+
var optionIndex = findFirstOptionIndex();
|
|
1263
|
+
if (event.shiftKey && metaKey) {
|
|
1264
|
+
onOptionSelectRange(event, optionIndex, startRangeIndex);
|
|
1265
|
+
}
|
|
1266
|
+
changeFocusedOptionIndex(event, optionIndex);
|
|
1267
|
+
!overlayVisibleState && show();
|
|
1268
|
+
}
|
|
1269
|
+
event.preventDefault();
|
|
1270
|
+
};
|
|
1271
|
+
var onEndKey = function onEndKey(event) {
|
|
1272
|
+
var pressedInInputText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1273
|
+
var currentTarget = event.currentTarget;
|
|
1274
|
+
if (pressedInInputText) {
|
|
1275
|
+
var len = currentTarget.value.length;
|
|
1276
|
+
currentTarget.setSelectionRange(event.shiftKey ? 0 : len, len);
|
|
1277
|
+
_readOnlyError("focusedOptionIndex");
|
|
1278
|
+
} else {
|
|
1279
|
+
var metaKey = event.metaKey || event.ctrlKey;
|
|
1280
|
+
var optionIndex = findLastOptionIndex();
|
|
1281
|
+
if (event.shiftKey && metaKey) {
|
|
1282
|
+
onOptionSelectRange(event, startRangeIndex, optionIndex);
|
|
1283
|
+
}
|
|
1284
|
+
changeFocusedOptionIndex(event, optionIndex);
|
|
1285
|
+
!overlayVisibleState && show();
|
|
1286
|
+
}
|
|
1287
|
+
event.preventDefault();
|
|
1288
|
+
};
|
|
1289
|
+
var onPageUpKey = function onPageUpKey(event) {
|
|
1290
|
+
event.preventDefault();
|
|
1291
|
+
};
|
|
1292
|
+
var onPageDownKey = function onPageDownKey(event) {
|
|
1293
|
+
event.preventDefault();
|
|
1294
|
+
};
|
|
1295
|
+
var onTabKey = function onTabKey(event) {
|
|
1296
|
+
var pressedInInputText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1297
|
+
if (!pressedInInputText) {
|
|
1298
|
+
if (overlayVisibleState && hasFocusableElements()) {
|
|
1299
|
+
DomHandler.focus(event.shiftKey ? lastHiddenFocusableElementOnOverlay.current : firstHiddenFocusableElementOnOverlay.current);
|
|
1300
|
+
event.preventDefault();
|
|
1301
|
+
} else {
|
|
1302
|
+
if (focusedOptionIndex !== -1) {
|
|
1303
|
+
onOptionSelect(event, visibleOptions[focusedOptionIndex]);
|
|
1304
|
+
}
|
|
1305
|
+
overlayVisibleState && hide(filter);
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
};
|
|
1309
|
+
var onShiftKey = function onShiftKey() {
|
|
1310
|
+
setStartRangeIndex(focusedOptionIndex);
|
|
1189
1311
|
};
|
|
1190
1312
|
var onKeyDown = function onKeyDown(event) {
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
case
|
|
1313
|
+
var metaKey = event.metaKey || event.ctrlKey;
|
|
1314
|
+
switch (event.code) {
|
|
1315
|
+
case 'ArrowUp':
|
|
1194
1316
|
if (props.inline) break;
|
|
1195
|
-
|
|
1196
|
-
show();
|
|
1197
|
-
event.preventDefault();
|
|
1198
|
-
}
|
|
1317
|
+
onArrowUpKey(event);
|
|
1199
1318
|
break;
|
|
1200
|
-
|
|
1201
|
-
//space
|
|
1202
|
-
case 32:
|
|
1319
|
+
case 'ArrowDown':
|
|
1203
1320
|
if (props.inline) break;
|
|
1204
|
-
|
|
1321
|
+
onArrowDownKey(event);
|
|
1322
|
+
break;
|
|
1323
|
+
case 'Space':
|
|
1324
|
+
case 'NumpadEnter':
|
|
1325
|
+
case 'Enter':
|
|
1326
|
+
if (props.inline) break;
|
|
1327
|
+
onEnterKey(event);
|
|
1328
|
+
break;
|
|
1329
|
+
case 'Home':
|
|
1330
|
+
if (props.inline) break;
|
|
1331
|
+
onHomeKey(event);
|
|
1205
1332
|
event.preventDefault();
|
|
1206
1333
|
break;
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1334
|
+
case 'End':
|
|
1335
|
+
if (props.inline) break;
|
|
1336
|
+
onEndKey(event);
|
|
1337
|
+
event.preventDefault();
|
|
1338
|
+
break;
|
|
1339
|
+
case 'PageDown':
|
|
1340
|
+
onPageDownKey(event);
|
|
1341
|
+
break;
|
|
1342
|
+
case 'PageUp':
|
|
1343
|
+
onPageUpKey(event);
|
|
1344
|
+
break;
|
|
1345
|
+
case 'Escape':
|
|
1210
1346
|
if (props.inline) break;
|
|
1211
1347
|
hide();
|
|
1212
1348
|
break;
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1349
|
+
case 'Tab':
|
|
1350
|
+
onTabKey(event);
|
|
1351
|
+
break;
|
|
1352
|
+
case 'ShiftLeft':
|
|
1353
|
+
case 'ShiftRight':
|
|
1354
|
+
onShiftKey();
|
|
1355
|
+
break;
|
|
1356
|
+
default:
|
|
1357
|
+
if (event.code === 'KeyA' && metaKey) {
|
|
1358
|
+
var value = visibleOptions.filter(function (option) {
|
|
1359
|
+
return isValidOption(option);
|
|
1360
|
+
}).map(function (option) {
|
|
1361
|
+
return getOptionValue(option);
|
|
1362
|
+
});
|
|
1363
|
+
updateModel(event, value);
|
|
1364
|
+
event.preventDefault();
|
|
1365
|
+
break;
|
|
1366
|
+
}
|
|
1367
|
+
if (!metaKey && ObjectUtils.isPrintableCharacter(event.key)) {
|
|
1368
|
+
!overlayVisibleState && show();
|
|
1369
|
+
searchOptions(event);
|
|
1370
|
+
event.preventDefault();
|
|
1222
1371
|
}
|
|
1223
1372
|
break;
|
|
1224
1373
|
}
|
|
1374
|
+
setClicked(false);
|
|
1225
1375
|
};
|
|
1226
1376
|
var onSelectAll = function onSelectAll(event) {
|
|
1227
1377
|
if (props.onSelectAll) {
|
|
@@ -1307,9 +1457,13 @@ var MultiSelect = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(functio
|
|
|
1307
1457
|
};
|
|
1308
1458
|
var show = function show() {
|
|
1309
1459
|
setOverlayVisibleState(true);
|
|
1460
|
+
setFocusedOptionIndex(focusedOptionIndex !== -1 ? focusedOptionIndex : props.autoOptionFocus ? findFirstFocusedOptionIndex() : findSelectedOptionIndex());
|
|
1461
|
+
DomHandler.focus(inputRef.current);
|
|
1310
1462
|
};
|
|
1311
1463
|
var hide = function hide() {
|
|
1464
|
+
setFocusedOptionIndex(-1);
|
|
1312
1465
|
setOverlayVisibleState(false);
|
|
1466
|
+
setClicked(false);
|
|
1313
1467
|
};
|
|
1314
1468
|
var onOverlayEnter = function onOverlayEnter(callback) {
|
|
1315
1469
|
ZIndexUtils.set('overlay', overlayRef.current, context && context.autoZIndex || PrimeReact.autoZIndex, context && context.zIndex['overlay'] || PrimeReact.zIndex['overlay']);
|
|
@@ -1503,6 +1657,100 @@ var MultiSelect = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(functio
|
|
|
1503
1657
|
var isOptionValueUsed = function isOptionValueUsed(option) {
|
|
1504
1658
|
return !props.useOptionAsValue && props.optionValue || option && option['value'] !== undefined;
|
|
1505
1659
|
};
|
|
1660
|
+
var isOptionGroup = function isOptionGroup(option) {
|
|
1661
|
+
return props.optionGroupLabel && option.optionGroup && option.group;
|
|
1662
|
+
};
|
|
1663
|
+
var hasSelectedOption = function hasSelectedOption() {
|
|
1664
|
+
return ObjectUtils.isNotEmpty(props.value);
|
|
1665
|
+
};
|
|
1666
|
+
var hasFocusableElements = function hasFocusableElements() {
|
|
1667
|
+
return DomHandler.getFocusableElements(overlayRef.current, ':not([data-p-hidden-focusable="true"])').length > 0;
|
|
1668
|
+
};
|
|
1669
|
+
var isOptionMatched = function isOptionMatched(option) {
|
|
1670
|
+
var _getOptionLabel;
|
|
1671
|
+
return isValidOption(option) && ((_getOptionLabel = getOptionLabel(option)) === null || _getOptionLabel === void 0 ? void 0 : _getOptionLabel.toLocaleLowerCase(props.filterLocale).startsWith(searchValue.current.toLocaleLowerCase(props.filterLocale)));
|
|
1672
|
+
};
|
|
1673
|
+
var isValidOption = function isValidOption(option) {
|
|
1674
|
+
return ObjectUtils.isNotEmpty(option) && !(isOptionDisabled(option) || isOptionGroup(option));
|
|
1675
|
+
};
|
|
1676
|
+
var isValidSelectedOption = function isValidSelectedOption(option) {
|
|
1677
|
+
return isValidOption(option) && isSelected(option);
|
|
1678
|
+
};
|
|
1679
|
+
var findSelectedOptionIndex = function findSelectedOptionIndex() {
|
|
1680
|
+
return hasSelectedOption ? visibleOptions === null || visibleOptions === void 0 ? void 0 : visibleOptions.findIndex(function (option) {
|
|
1681
|
+
return isValidSelectedOption(option);
|
|
1682
|
+
}) : -1;
|
|
1683
|
+
};
|
|
1684
|
+
var findFirstFocusedOptionIndex = function findFirstFocusedOptionIndex() {
|
|
1685
|
+
var selectedIndex = findSelectedOptionIndex();
|
|
1686
|
+
return selectedIndex < 0 ? findFirstOptionIndex() : selectedIndex;
|
|
1687
|
+
};
|
|
1688
|
+
var findLastFocusedOptionIndex = function findLastFocusedOptionIndex() {
|
|
1689
|
+
var selectedIndex = findSelectedOptionIndex();
|
|
1690
|
+
return selectedIndex < 0 ? findLastOptionIndex() : selectedIndex;
|
|
1691
|
+
};
|
|
1692
|
+
var findFirstOptionIndex = function findFirstOptionIndex() {
|
|
1693
|
+
return visibleOptions.findIndex(function (option) {
|
|
1694
|
+
return isValidOption(option);
|
|
1695
|
+
});
|
|
1696
|
+
};
|
|
1697
|
+
var findLastOptionIndex = function findLastOptionIndex() {
|
|
1698
|
+
return ObjectUtils.findLastIndex(visibleOptions, function (option) {
|
|
1699
|
+
return isValidOption(option);
|
|
1700
|
+
});
|
|
1701
|
+
};
|
|
1702
|
+
var findNextOptionIndex = function findNextOptionIndex(index) {
|
|
1703
|
+
var matchedOptionIndex = index < visibleOptions.length - 1 ? visibleOptions.slice(index + 1).findIndex(function (option) {
|
|
1704
|
+
return isValidOption(option);
|
|
1705
|
+
}) : -1;
|
|
1706
|
+
return matchedOptionIndex > -1 ? matchedOptionIndex + index + 1 : index;
|
|
1707
|
+
};
|
|
1708
|
+
var findPrevOptionIndex = function findPrevOptionIndex(index) {
|
|
1709
|
+
var matchedOptionIndex = index > 0 ? ObjectUtils.findLastIndex(visibleOptions.slice(0, index), function (option) {
|
|
1710
|
+
return isValidOption(option);
|
|
1711
|
+
}) : -1;
|
|
1712
|
+
return matchedOptionIndex > -1 ? matchedOptionIndex : index;
|
|
1713
|
+
};
|
|
1714
|
+
var searchOptions = function searchOptions(event) {
|
|
1715
|
+
searchValue.current = (searchValue.current || '') + event.key;
|
|
1716
|
+
var optionIndex = -1;
|
|
1717
|
+
if (ObjectUtils.isNotEmpty(searchValue.current)) {
|
|
1718
|
+
if (focusedOptionIndex !== -1) {
|
|
1719
|
+
optionIndex = visibleOptions.slice(focusedOptionIndex).findIndex(function (option) {
|
|
1720
|
+
return isOptionMatched(option);
|
|
1721
|
+
});
|
|
1722
|
+
optionIndex = optionIndex === -1 ? visibleOptions.slice(0, focusedOptionIndex).findIndex(function (option) {
|
|
1723
|
+
return isOptionMatched(option);
|
|
1724
|
+
}) : optionIndex + focusedOptionIndex;
|
|
1725
|
+
} else {
|
|
1726
|
+
optionIndex = visibleOptions.findIndex(function (option) {
|
|
1727
|
+
return isOptionMatched(option);
|
|
1728
|
+
});
|
|
1729
|
+
}
|
|
1730
|
+
if (optionIndex === -1 && focusedOptionIndex === -1) {
|
|
1731
|
+
optionIndex = findFirstFocusedOptionIndex();
|
|
1732
|
+
}
|
|
1733
|
+
if (optionIndex !== -1) {
|
|
1734
|
+
changeFocusedOptionIndex(event, optionIndex);
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
if (searchTimeout.current) {
|
|
1738
|
+
clearTimeout(searchTimeout.current);
|
|
1739
|
+
}
|
|
1740
|
+
searchTimeout.current = setTimeout(function () {
|
|
1741
|
+
searchValue.current = '';
|
|
1742
|
+
searchTimeout.current = null;
|
|
1743
|
+
}, 500);
|
|
1744
|
+
};
|
|
1745
|
+
var changeFocusedOptionIndex = function changeFocusedOptionIndex(event, index) {
|
|
1746
|
+
if (focusedOptionIndex !== index) {
|
|
1747
|
+
setFocusedOptionIndex(index);
|
|
1748
|
+
scrollInView();
|
|
1749
|
+
if (props.selectOnFocus) {
|
|
1750
|
+
onOptionSelect(event, visibleOptions[index], false);
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
};
|
|
1506
1754
|
var removeChip = function removeChip(event, item) {
|
|
1507
1755
|
var value = props.value.filter(function (val) {
|
|
1508
1756
|
return !ObjectUtils.equals(val, item, equalityKey);
|
|
@@ -1643,6 +1891,7 @@ var MultiSelect = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(functio
|
|
|
1643
1891
|
setTimeout(function () {
|
|
1644
1892
|
props.overlayVisible ? show() : hide();
|
|
1645
1893
|
}, 100);
|
|
1894
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1646
1895
|
}, [props.overlayVisible]);
|
|
1647
1896
|
useUpdateEffect(function () {
|
|
1648
1897
|
if (overlayVisibleState && filterState && hasFilter) {
|
|
@@ -1727,11 +1976,31 @@ var MultiSelect = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(functio
|
|
|
1727
1976
|
role: 'listbox',
|
|
1728
1977
|
'aria-expanded': overlayVisibleState,
|
|
1729
1978
|
disabled: props.disabled,
|
|
1730
|
-
tabIndex: props.tabIndex
|
|
1979
|
+
tabIndex: !props.disabled ? props.tabIndex : -1
|
|
1731
1980
|
}, ariaProps), ptm('input'));
|
|
1981
|
+
var firstHiddenElementProps = mergeProps({
|
|
1982
|
+
ref: firstHiddenFocusableElementOnOverlay,
|
|
1983
|
+
role: 'presentation',
|
|
1984
|
+
'aria-hidden': true,
|
|
1985
|
+
className: 'p-hidden-accessible p-hidden-focusable',
|
|
1986
|
+
tabIndex: '0',
|
|
1987
|
+
onFocus: onFirstHiddenFocus,
|
|
1988
|
+
'data-p-hidden-accessible': true,
|
|
1989
|
+
'data-p-hidden-focusable': true
|
|
1990
|
+
}, ptm('hiddenFirstFocusableEl'));
|
|
1991
|
+
var lastHiddenElementProps = mergeProps({
|
|
1992
|
+
ref: lastHiddenFocusableElementOnOverlay,
|
|
1993
|
+
role: 'presentation',
|
|
1994
|
+
'aria-hidden': true,
|
|
1995
|
+
className: 'p-hidden-accessible p-hidden-focusable',
|
|
1996
|
+
tabIndex: '0',
|
|
1997
|
+
onFocus: onLastHiddenFocus,
|
|
1998
|
+
'data-p-hidden-accessible': true,
|
|
1999
|
+
'data-p-hidden-focusable': true
|
|
2000
|
+
}, ptm('hiddenLastFocusableEl'));
|
|
1732
2001
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", rootProps, /*#__PURE__*/React.createElement("div", hiddenInputWrapperProps, /*#__PURE__*/React.createElement("input", _extends({}, inputProps, {
|
|
1733
2002
|
readOnly: true
|
|
1734
|
-
}))), !props.inline && /*#__PURE__*/React.createElement(React.Fragment, null, label, clearIcon, triggerIcon), /*#__PURE__*/React.createElement(MultiSelectPanel, _extends({
|
|
2003
|
+
}))), !props.inline && /*#__PURE__*/React.createElement(React.Fragment, null, label, clearIcon, triggerIcon), /*#__PURE__*/React.createElement("span", firstHiddenElementProps), /*#__PURE__*/React.createElement(MultiSelectPanel, _extends({
|
|
1735
2004
|
hostName: "MultiSelect",
|
|
1736
2005
|
ref: overlayRef,
|
|
1737
2006
|
visibleOptions: visibleOptions
|
|
@@ -1739,6 +2008,8 @@ var MultiSelect = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(functio
|
|
|
1739
2008
|
onClick: onPanelClick,
|
|
1740
2009
|
onOverlayHide: hide,
|
|
1741
2010
|
filterValue: filterState,
|
|
2011
|
+
focusedOptionIndex: focusedOptionIndex,
|
|
2012
|
+
setFocusedOptionIndex: setFocusedOptionIndex,
|
|
1742
2013
|
hasFilter: hasFilter,
|
|
1743
2014
|
onFilterInputChange: onFilterInputChange,
|
|
1744
2015
|
resetFilter: resetFilter,
|
|
@@ -1755,7 +2026,6 @@ var MultiSelect = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(functio
|
|
|
1755
2026
|
isAllSelected: isAllSelected,
|
|
1756
2027
|
onOptionSelect: onOptionSelect,
|
|
1757
2028
|
allowOptionSelect: allowOptionSelect,
|
|
1758
|
-
onOptionKeyDown: onOptionKeyDown,
|
|
1759
2029
|
"in": overlayVisibleState,
|
|
1760
2030
|
onEnter: onOverlayEnter,
|
|
1761
2031
|
onEntered: onOverlayEntered,
|
|
@@ -1766,7 +2036,7 @@ var MultiSelect = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(functio
|
|
|
1766
2036
|
sx: sx,
|
|
1767
2037
|
isUnstyled: isUnstyled,
|
|
1768
2038
|
metaData: metaData
|
|
1769
|
-
}))), hasTooltip && /*#__PURE__*/React.createElement(Tooltip, _extends({
|
|
2039
|
+
})), /*#__PURE__*/React.createElement("span", lastHiddenElementProps)), hasTooltip && /*#__PURE__*/React.createElement(Tooltip, _extends({
|
|
1770
2040
|
target: elementRef,
|
|
1771
2041
|
content: props.tooltip
|
|
1772
2042
|
}, props.tooltipOptions, {
|