linear-react-components-ui 1.1.22 → 1.1.24-beta.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/lib/@types/ColorStyles.d.ts +2 -1
- package/lib/@types/Position.d.ts +2 -1
- package/lib/BaseMask-3d5d581d.d.ts +24 -0
- package/lib/BaseNumber-797088d7.d.ts +23 -0
- package/lib/Cnpj-1602be21.d.ts +18 -0
- package/lib/Cpf-4d6b9079.d.ts +18 -0
- package/lib/Currency-b33d3a22.d.ts +18 -0
- package/lib/Decimal-55e836d5.d.ts +13 -0
- package/lib/Number-9c6aceff.d.ts +20 -0
- package/lib/Phone-79e5e3b4.d.ts +18 -0
- package/lib/ZipCode-8c2e9d8b.d.ts +13 -0
- package/lib/assets/styles/checkbox2.scss +199 -0
- package/lib/assets/styles/colorpicker.scss +1 -6
- package/lib/assets/styles/colors.scss +48 -12
- package/lib/assets/styles/datepicker2.scss +338 -0
- package/lib/assets/styles/label.scss +4 -2
- package/lib/assets/styles/select.scss +19 -15
- package/lib/assets/styles/selectfield.scss +409 -0
- package/lib/assets/styles/slot.scss +34 -0
- package/lib/assets/styles/textfield.scss +148 -0
- package/lib/buttons/ActivateButton.d.ts +1 -0
- package/lib/buttons/AddButton.d.ts +1 -0
- package/lib/buttons/Button.d.ts +1 -0
- package/lib/buttons/CancelButton.d.ts +1 -0
- package/lib/buttons/DangerButton.d.ts +1 -0
- package/lib/buttons/DefaultButton.d.ts +1 -0
- package/lib/buttons/DefaultButton.js +20 -12
- package/lib/buttons/DestroyButton.d.ts +1 -0
- package/lib/buttons/EditButton.d.ts +1 -0
- package/lib/buttons/InactivateButton.d.ts +1 -0
- package/lib/buttons/InfoButton.d.ts +1 -0
- package/lib/buttons/PrimaryButton.d.ts +1 -0
- package/lib/buttons/RestoreButton.d.ts +1 -0
- package/lib/buttons/SaveButton.d.ts +1 -0
- package/lib/buttons/SuccessButton.d.ts +1 -0
- package/lib/buttons/WarningButton.d.ts +1 -0
- package/lib/buttons/index.d.ts +1 -0
- package/lib/buttons/split_button/index.d.ts +1 -0
- package/lib/buttons/types.d.ts +2 -5
- package/lib/drawer/Drawer.js +10 -6
- package/lib/form/Field.d.ts +1 -1
- package/lib/form/FieldArray.d.ts +1 -1
- package/lib/form/FieldNumber.d.ts +1 -1
- package/lib/form/FieldPeriod.d.ts +1 -1
- package/lib/form/helpers.d.ts +1 -1
- package/lib/form/index.d.ts +1 -1
- package/lib/form/types.d.ts +1 -1
- package/lib/form/withFieldHOC.d.ts +1 -1
- package/lib/form/withFormSecurity.d.ts +1 -1
- package/lib/form2/helpers.d.ts +8 -0
- package/lib/form2/helpers.js +41 -0
- package/lib/form2/index.d.ts +9 -0
- package/lib/form2/index.js +36 -0
- package/lib/form2/types.d.ts +125 -0
- package/lib/form2/types.js +5 -0
- package/lib/form2/useForm/index.d.ts +5 -0
- package/lib/form2/useForm/index.js +203 -0
- package/lib/icons/helper.d.ts +4 -0
- package/lib/icons/helper.js +4 -0
- package/lib/icons/index.d.ts +4 -6
- package/lib/icons/index.js +14 -9
- package/lib/icons/types.d.ts +3 -6
- package/lib/index-18a64236.d.ts +23 -0
- package/lib/index-368f781f.d.ts +15 -0
- package/lib/index-43ad8140.d.ts +41 -0
- package/lib/index-772f9f1a.d.ts +44 -0
- package/lib/index-8a59cf4b.d.ts +23 -0
- package/lib/index-c9247c1f.d.ts +15 -0
- package/lib/index.d.ts +1 -0
- package/lib/inputs/base/InputTextBase.d.ts +1 -1
- package/lib/inputs/base/InputTextBase.js +18 -8
- package/lib/inputs/base/helpers.d.ts +1 -1
- package/lib/inputs/base/types.d.ts +5 -16
- package/lib/inputs/color/index.js +1 -1
- package/lib/inputs/color/types.d.ts +1 -1
- package/lib/inputs/date/Dialog.d.ts +1 -1
- package/lib/inputs/date/Dropdown.d.ts +1 -1
- package/lib/inputs/date/index.d.ts +1 -1
- package/lib/inputs/date/types.d.ts +2 -2
- package/lib/inputs/errorMessage/index.d.ts +1 -1
- package/lib/inputs/file/DefaultFile.d.ts +1 -1
- package/lib/inputs/file/DefaultFile.js +1 -1
- package/lib/inputs/file/DragDropFile.d.ts +1 -1
- package/lib/inputs/file/File.d.ts +1 -1
- package/lib/inputs/file/FileButtonSettings.d.ts +1 -1
- package/lib/inputs/file/helpers.d.ts +1 -1
- package/lib/inputs/file/index.d.ts +1 -1
- package/lib/inputs/file/types.d.ts +1 -1
- package/lib/inputs/inputHOC.d.ts +1 -1
- package/lib/inputs/mask/BaseMask.d.ts +1 -1
- package/lib/inputs/mask/BaseMask.js +9 -6
- package/lib/inputs/mask/Cnpj.d.ts +1 -1
- package/lib/inputs/mask/Cpf.d.ts +1 -1
- package/lib/inputs/mask/Phone.d.ts +1 -1
- package/lib/inputs/mask/ZipCode.d.ts +1 -1
- package/lib/inputs/mask/helpers.d.ts +1 -1
- package/lib/inputs/mask/helpers.js +1 -1
- package/lib/inputs/mask/index.d.ts +1 -1
- package/lib/inputs/mask/types.d.ts +2 -2
- package/lib/inputs/multiSelect/ActionButtons.d.ts +1 -1
- package/lib/inputs/multiSelect/Dropdown.d.ts +1 -1
- package/lib/inputs/multiSelect/helper.d.ts +1 -1
- package/lib/inputs/multiSelect/index.d.ts +1 -1
- package/lib/inputs/multiSelect/types.d.ts +2 -2
- package/lib/inputs/number/BaseNumber.d.ts +1 -1
- package/lib/inputs/number/BaseNumber.js +3 -2
- package/lib/inputs/number/Currency.d.ts +1 -1
- package/lib/inputs/number/Decimal.d.ts +1 -1
- package/lib/inputs/number/format_number.d.ts +1 -1
- package/lib/inputs/number/format_number.js +4 -2
- package/lib/inputs/number/index.d.ts +1 -1
- package/lib/inputs/number/types.d.ts +4 -4
- package/lib/inputs/period/Dialog.d.ts +1 -1
- package/lib/inputs/period/Dropdown.d.ts +1 -1
- package/lib/inputs/period/PeriodList.d.ts +1 -1
- package/lib/inputs/period/helper.d.ts +1 -1
- package/lib/inputs/period/index.d.ts +1 -1
- package/lib/inputs/period/index.js +8 -10
- package/lib/inputs/period/types.d.ts +2 -5
- package/lib/inputs/search/index.d.ts +1 -1
- package/lib/inputs/select/ActionButtons.d.ts +1 -1
- package/lib/inputs/select/Dropdown.d.ts +1 -1
- package/lib/inputs/select/helper.d.ts +1 -1
- package/lib/inputs/select/index.d.ts +1 -1
- package/lib/inputs/select/multiple/Selecteds.d.ts +2 -2
- package/lib/inputs/select/multiple/Selecteds.js +3 -1
- package/lib/inputs/select/multiple/index.d.ts +1 -1
- package/lib/inputs/select/multiple/index.js +3 -2
- package/lib/inputs/select/simple/index.d.ts +1 -1
- package/lib/inputs/select/simple/index.js +3 -3
- package/lib/inputs/select/types.d.ts +2 -1
- package/lib/inputs/text/index.d.ts +1 -1
- package/lib/inputs/text/types.d.ts +2 -3
- package/lib/inputs/textarea/index.d.ts +1 -1
- package/lib/inputs/textarea/types.d.ts +1 -1
- package/lib/inputs/types.d.ts +2 -2
- package/lib/inputs2/checkboxfield/index.d.ts +7 -0
- package/lib/inputs2/checkboxfield/index.js +146 -0
- package/lib/inputs2/colorfield/index.d.ts +9 -0
- package/lib/inputs2/colorfield/index.js +119 -0
- package/lib/inputs2/date/base/constants.d.ts +7 -0
- package/lib/inputs2/date/base/constants.js +43 -0
- package/lib/inputs2/date/base/index.d.ts +12 -0
- package/lib/inputs2/date/base/index.js +179 -0
- package/lib/inputs2/date/datefield/calendarbox.d.ts +7 -0
- package/lib/inputs2/date/datefield/calendarbox.js +115 -0
- package/lib/inputs2/date/datefield/context.d.ts +13 -0
- package/lib/inputs2/date/datefield/context.js +15 -0
- package/lib/inputs2/date/datefield/index.d.ts +9 -0
- package/lib/inputs2/date/datefield/index.js +334 -0
- package/lib/inputs2/date/datefield/triggers.d.ts +8 -0
- package/lib/inputs2/date/datefield/triggers.js +47 -0
- package/lib/inputs2/date/datefield/types.d.ts +61 -0
- package/lib/inputs2/date/datefield/types.js +5 -0
- package/lib/inputs2/date/dateperiodfield/calendarbox.d.ts +7 -0
- package/lib/inputs2/date/dateperiodfield/calendarbox.js +136 -0
- package/lib/inputs2/date/dateperiodfield/context.d.ts +13 -0
- package/lib/inputs2/date/dateperiodfield/context.js +17 -0
- package/lib/inputs2/date/dateperiodfield/index.d.ts +9 -0
- package/lib/inputs2/date/dateperiodfield/index.js +592 -0
- package/lib/inputs2/date/dateperiodfield/triggers.d.ts +6 -0
- package/lib/inputs2/date/dateperiodfield/triggers.js +120 -0
- package/lib/inputs2/date/dateperiodfield/types.d.ts +99 -0
- package/lib/inputs2/date/dateperiodfield/types.js +19 -0
- package/lib/inputs2/date/helpers.d.ts +20 -0
- package/lib/inputs2/date/helpers.js +62 -0
- package/lib/inputs2/date/types.d.ts +59 -0
- package/lib/inputs2/date/types.js +19 -0
- package/lib/inputs2/index.d.ts +29 -0
- package/lib/inputs2/index.js +38 -0
- package/lib/inputs2/mask/BaseMask.d.ts +10 -0
- package/lib/inputs2/mask/BaseMask.js +95 -0
- package/lib/inputs2/mask/Cnpj.d.ts +11 -0
- package/lib/inputs2/mask/Cnpj.js +57 -0
- package/lib/inputs2/mask/Cpf.d.ts +11 -0
- package/lib/inputs2/mask/Cpf.js +53 -0
- package/lib/inputs2/mask/Phone.d.ts +11 -0
- package/lib/inputs2/mask/Phone.js +26 -0
- package/lib/inputs2/mask/ZipCode.d.ts +11 -0
- package/lib/inputs2/mask/ZipCode.js +23 -0
- package/lib/inputs2/mask/helpers.d.ts +4 -0
- package/lib/inputs2/mask/helpers.js +57 -0
- package/lib/inputs2/number/BaseNumber.d.ts +10 -0
- package/lib/inputs2/number/BaseNumber.js +86 -0
- package/lib/inputs2/number/Currency.d.ts +11 -0
- package/lib/inputs2/number/Currency.js +47 -0
- package/lib/inputs2/number/Decimal.d.ts +11 -0
- package/lib/inputs2/number/Decimal.js +36 -0
- package/lib/inputs2/number/Number.d.ts +9 -0
- package/lib/inputs2/number/Number.js +49 -0
- package/lib/inputs2/number/format_number.d.ts +5 -0
- package/lib/inputs2/number/format_number.js +29 -0
- package/lib/inputs2/selectfield/context.d.ts +38 -0
- package/lib/inputs2/selectfield/context.js +15 -0
- package/lib/inputs2/selectfield/helpers.d.ts +6 -0
- package/lib/inputs2/selectfield/helpers.js +25 -0
- package/lib/inputs2/selectfield/index.d.ts +10 -0
- package/lib/inputs2/selectfield/index.js +491 -0
- package/lib/inputs2/selectfield/item.d.ts +11 -0
- package/lib/inputs2/selectfield/item.js +85 -0
- package/lib/inputs2/selectfield/listbox.d.ts +7 -0
- package/lib/inputs2/selectfield/listbox.js +103 -0
- package/lib/inputs2/selectfield/search.d.ts +7 -0
- package/lib/inputs2/selectfield/search.js +71 -0
- package/lib/inputs2/selectfield/selections.d.ts +10 -0
- package/lib/inputs2/selectfield/selections.js +86 -0
- package/lib/inputs2/selectfield/triggers.d.ts +8 -0
- package/lib/inputs2/selectfield/triggers.js +100 -0
- package/lib/inputs2/selectfield/types.d.ts +55 -0
- package/lib/inputs2/selectfield/types.js +21 -0
- package/lib/inputs2/slot/index.d.ts +14 -0
- package/lib/inputs2/slot/index.js +47 -0
- package/lib/inputs2/textfield/index.d.ts +8 -0
- package/lib/inputs2/textfield/index.js +159 -0
- package/lib/internals/types.d.ts +1 -17
- package/lib/labels/DangerLabel.d.ts +1 -0
- package/lib/labels/DefaultLabel.d.ts +3 -5
- package/lib/labels/DefaultLabel.js +15 -7
- package/lib/labels/InfoLabel.d.ts +1 -0
- package/lib/labels/PrimaryLabel.d.ts +1 -0
- package/lib/labels/SuccessLabel.d.ts +1 -0
- package/lib/labels/WarningLabel.d.ts +1 -0
- package/lib/labels/index.d.ts +3 -2
- package/lib/labels/types.d.ts +2 -5
- package/lib/list/Header.d.ts +1 -0
- package/lib/list/Item.d.ts +3 -5
- package/lib/list/Item.js +17 -12
- package/lib/list/helpers.d.ts +1 -0
- package/lib/list/index.d.ts +1 -0
- package/lib/list/types.d.ts +4 -6
- package/lib/menus/sidenav/ExpandMenu.d.ts +2 -2
- package/lib/menus/sidenav/MenuLink.d.ts +4 -7
- package/lib/menus/sidenav/MenuLink.js +20 -11
- package/lib/menus/sidenav/NavMenuGroup.d.ts +2 -2
- package/lib/menus/sidenav/NavMenuItem.d.ts +4 -7
- package/lib/menus/sidenav/NavMenuItem.js +16 -12
- package/lib/menus/sidenav/NavSubMenuItem.d.ts +2 -2
- package/lib/menus/sidenav/helpers.d.ts +2 -2
- package/lib/menus/sidenav/index.d.ts +2 -2
- package/lib/menus/sidenav/popup_menu_search/EmptyList.d.ts +2 -2
- package/lib/menus/sidenav/popup_menu_search/index.d.ts +2 -2
- package/lib/menus/sidenav/types.d.ts +6 -6
- package/lib/popover/PopoverText.js +11 -2
- package/lib/popover/types.d.ts +1 -0
- package/lib/textContent/index.d.ts +6 -11
- package/lib/textContent/index.js +20 -11
- package/lib/tooltip/TooltipContent.d.ts +7 -0
- package/lib/tooltip/TooltipContent.js +65 -0
- package/lib/tooltip/index.d.ts +4 -3
- package/lib/tooltip/index.js +36 -53
- package/lib/tooltip/types.d.ts +25 -3
- package/lib/tooltip/useTooltip.d.ts +30 -0
- package/lib/tooltip/useTooltip.js +128 -0
- package/package.json +4 -3
- package/lib/inputs/base/Label.d.ts +0 -14
- package/lib/inputs/base/Label.js +0 -35
- package/lib/internals/withTooltip.d.ts +0 -12
- package/lib/internals/withTooltip.js +0 -172
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Input = void 0;
|
|
7
|
+
Object.defineProperty(exports, "Item", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _item.Item;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "LeftSlot", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _slot.LeftSlot;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "RightSlot", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _slot.RightSlot;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
require("../../assets/styles/selectfield.scss");
|
|
26
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
27
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
28
|
+
var _uuid = require("uuid");
|
|
29
|
+
var _reactDom = require("react-dom");
|
|
30
|
+
var _hint = _interopRequireDefault(require("../../hint"));
|
|
31
|
+
var _gridlayout = _interopRequireDefault(require("../../gridlayout"));
|
|
32
|
+
var _popover = _interopRequireWildcard(require("../../popover"));
|
|
33
|
+
var _tooltip = require("../../tooltip");
|
|
34
|
+
var _helpers = require("../../form2/helpers");
|
|
35
|
+
var _permissionValidations = require("../../permissionValidations");
|
|
36
|
+
var _slot = require("../slot");
|
|
37
|
+
var _listbox = require("./listbox");
|
|
38
|
+
var _triggers = require("./triggers");
|
|
39
|
+
var _selections = require("./selections");
|
|
40
|
+
var _context = require("./context");
|
|
41
|
+
var _item = require("./item");
|
|
42
|
+
var _types = require("./types");
|
|
43
|
+
var _helpers2 = require("./helpers");
|
|
44
|
+
const _excluded = ["name", "label", "errors", "children", "gridLayout", "onChange", "tooltip", "tooltipPosition", "tooltipWidth", "hintPosition", "themePopover", "popoverAlign", "skeletonize", "striped", "undigitable", "externalSearch", "openDropdownOnFocus", "showClearButton", "textAlign", "searchOnDropdown", "onSearch", "permissionAttr", "customClass", "customClassLabel", "customClassWrapper", "customClassInputContainer", "onDeniedActions", "notFoundFilterLabel", "multipleInputLabelEmpty", "multipleInputLabelOneSelection", "multipleInputLabelManySelection", "searchInputPlaceholder", "dropdownAlignButton"];
|
|
45
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
46
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
47
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
48
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
49
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
50
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
51
|
+
const SELECT_FIELD_CONTROLS_ID = `select-field-controls-${(0, _uuid.v1)()}`;
|
|
52
|
+
const Input = exports.Input = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
53
|
+
const {
|
|
54
|
+
name,
|
|
55
|
+
label,
|
|
56
|
+
errors,
|
|
57
|
+
children,
|
|
58
|
+
gridLayout,
|
|
59
|
+
onChange,
|
|
60
|
+
tooltip,
|
|
61
|
+
tooltipPosition,
|
|
62
|
+
tooltipWidth,
|
|
63
|
+
hintPosition = 'below',
|
|
64
|
+
themePopover = 'light',
|
|
65
|
+
popoverAlign = 'left',
|
|
66
|
+
skeletonize = false,
|
|
67
|
+
striped = false,
|
|
68
|
+
undigitable = false,
|
|
69
|
+
externalSearch = false,
|
|
70
|
+
openDropdownOnFocus = true,
|
|
71
|
+
showClearButton = true,
|
|
72
|
+
textAlign = 'left',
|
|
73
|
+
searchOnDropdown = false,
|
|
74
|
+
onSearch = undefined,
|
|
75
|
+
permissionAttr = undefined,
|
|
76
|
+
customClass = '',
|
|
77
|
+
customClassLabel = '',
|
|
78
|
+
customClassWrapper = '',
|
|
79
|
+
customClassInputContainer = '',
|
|
80
|
+
onDeniedActions = undefined,
|
|
81
|
+
notFoundFilterLabel = 'Nenhuma opção encontrada.',
|
|
82
|
+
multipleInputLabelEmpty = 'Nenhum registro selecionado',
|
|
83
|
+
multipleInputLabelOneSelection = 'Um registro selecionado',
|
|
84
|
+
multipleInputLabelManySelection = 'Múltiplos registros selecionados',
|
|
85
|
+
searchInputPlaceholder = 'Pesquisar registros',
|
|
86
|
+
dropdownAlignButton = 'left'
|
|
87
|
+
} = props,
|
|
88
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
89
|
+
const onDenied = _react.default.useMemo(() => {
|
|
90
|
+
return onDeniedActions || (0, _permissionValidations.actionsOnPermissionDenied)(_helpers2.options, permissionAttr);
|
|
91
|
+
}, [onDeniedActions, permissionAttr]);
|
|
92
|
+
const {
|
|
93
|
+
hideContent,
|
|
94
|
+
unvisible
|
|
95
|
+
} = onDenied;
|
|
96
|
+
const [inputValue, setInputValue] = _react.default.useState('');
|
|
97
|
+
const [filterValue, setFilterValue] = _react.default.useState('');
|
|
98
|
+
const [listBoxOpen, setListBoxOpen] = _react.default.useState(false);
|
|
99
|
+
const [activeDescendant, setActiveDescendant] = _react.default.useState(undefined);
|
|
100
|
+
const isMultipleDefault = _lodash.default.isEqual(props?.multiple, _types.MultipleVariantEnum.default);
|
|
101
|
+
const isMultipleWithCheckboxes = _lodash.default.isEqual(props?.multiple, _types.MultipleVariantEnum.checkboxes);
|
|
102
|
+
const isMultipleSelect = isMultipleDefault || isMultipleWithCheckboxes;
|
|
103
|
+
const liSelectedRef = _react.default.useRef(null);
|
|
104
|
+
const selectInputRef = _react.default.useRef(null);
|
|
105
|
+
const selectListBoxRef = _react.default.useRef(null);
|
|
106
|
+
const selectContainerRef = _react.default.useRef(null);
|
|
107
|
+
const selectSearchInputRef = _react.default.useRef(null);
|
|
108
|
+
const listOptionsMap = _react.default.useMemo(() => {
|
|
109
|
+
const optionsMap = new Map();
|
|
110
|
+
_react.default.Children.forEach(children, child => {
|
|
111
|
+
if (/*#__PURE__*/_react.default.isValidElement(child)) {
|
|
112
|
+
optionsMap.set(child.props.value, child.props.label);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
return optionsMap;
|
|
116
|
+
}, [children]);
|
|
117
|
+
_react.default.useEffect(() => {
|
|
118
|
+
if (isMultipleWithCheckboxes) {
|
|
119
|
+
setInputValue(multipleInputLabelEmpty);
|
|
120
|
+
}
|
|
121
|
+
}, []);
|
|
122
|
+
_react.default.useEffect(() => {
|
|
123
|
+
if (openDropdownOnFocus && listBoxOpen) {
|
|
124
|
+
requestAnimationFrame(() => {
|
|
125
|
+
if (isMultipleWithCheckboxes) {
|
|
126
|
+
selectSearchInputRef.current?.focus?.();
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}, [listBoxOpen]);
|
|
131
|
+
_react.default.useEffect(() => {
|
|
132
|
+
if (!isMultipleWithCheckboxes && !props?.value) setInputValue('');
|
|
133
|
+
if (!props?.value || document.activeElement === selectInputRef.current) return;
|
|
134
|
+
const lazyInputValue = listOptionsMap.get(rest.value);
|
|
135
|
+
if (!isMultipleWithCheckboxes) setInputValue(lazyInputValue ?? '');
|
|
136
|
+
if (isMultipleWithCheckboxes) {
|
|
137
|
+
switch (_lodash.default.size(props?.value)) {
|
|
138
|
+
case 0:
|
|
139
|
+
return setInputValue(multipleInputLabelEmpty);
|
|
140
|
+
case 1:
|
|
141
|
+
return setInputValue(multipleInputLabelOneSelection);
|
|
142
|
+
default:
|
|
143
|
+
return setInputValue(multipleInputLabelManySelection);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}, [props?.value, listOptionsMap]);
|
|
147
|
+
const hasLabel = !_lodash.default.isEmpty(props?.label);
|
|
148
|
+
const hasHintMessages = Boolean(props.hint?.length);
|
|
149
|
+
const hasValidationErrors = Boolean(errors?.length);
|
|
150
|
+
const isReadOnly = Boolean(props.readOnly || onDenied.readOnly);
|
|
151
|
+
const isDisabled = Boolean(props.disabled || onDenied.disabled);
|
|
152
|
+
const {
|
|
153
|
+
leftSlotElements,
|
|
154
|
+
rightSlotElements
|
|
155
|
+
} = _react.default.useMemo(() => {
|
|
156
|
+
const left = [];
|
|
157
|
+
const right = [];
|
|
158
|
+
_react.default.Children.map(children, (childElement, index) => {
|
|
159
|
+
if (/*#__PURE__*/_react.default.isValidElement(childElement)) {
|
|
160
|
+
const clonedChild = /*#__PURE__*/_react.default.cloneElement(childElement, {
|
|
161
|
+
key: childElement.key ?? `slot-${index}`,
|
|
162
|
+
disabled: isDisabled || isReadOnly,
|
|
163
|
+
'aria-disabled': isDisabled || isReadOnly
|
|
164
|
+
});
|
|
165
|
+
if (childElement.type === _slot.LeftSlot) left.push(clonedChild);
|
|
166
|
+
if (childElement.type === _slot.RightSlot) right.push(clonedChild);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
return {
|
|
170
|
+
leftSlotElements: left,
|
|
171
|
+
rightSlotElements: right
|
|
172
|
+
};
|
|
173
|
+
}, [children, isDisabled, isReadOnly]);
|
|
174
|
+
const hasLeftSlotElements = Boolean(leftSlotElements?.length);
|
|
175
|
+
const hasRightSlotElements = Boolean(rightSlotElements?.length);
|
|
176
|
+
const handleCloseListBox = () => {
|
|
177
|
+
setListBoxOpen(false);
|
|
178
|
+
setFilterValue('');
|
|
179
|
+
};
|
|
180
|
+
const handleOpenListBox = () => {
|
|
181
|
+
const currentValue = !isMultipleSelect ? props?.value : _lodash.default.orderBy([...props.value], value => _lodash.default.toNumber(value), ['asc'])[0];
|
|
182
|
+
setActiveDescendant(_lodash.default.toString(currentValue) ?? undefined);
|
|
183
|
+
};
|
|
184
|
+
const handleChangeListBoxState = () => {
|
|
185
|
+
setListBoxOpen(prevState => {
|
|
186
|
+
if (prevState) {
|
|
187
|
+
setFilterValue('');
|
|
188
|
+
}
|
|
189
|
+
if (selectInputRef.current !== document.activeElement) {
|
|
190
|
+
selectInputRef?.current?.focus?.();
|
|
191
|
+
}
|
|
192
|
+
return !prevState;
|
|
193
|
+
});
|
|
194
|
+
};
|
|
195
|
+
const handleChangeLiSelected = liElement => {
|
|
196
|
+
liSelectedRef.current = liElement;
|
|
197
|
+
};
|
|
198
|
+
const handleOnChange = (value, inputLabel, addOrRemove) => {
|
|
199
|
+
let multipleValue = props?.value;
|
|
200
|
+
if (!addOrRemove) multipleValue = _lodash.default.union(props.value, [value]);
|
|
201
|
+
if (addOrRemove) multipleValue = _lodash.default.without(props.value, value);
|
|
202
|
+
const changedValue = !isMultipleSelect ? value : _lodash.default.orderBy(multipleValue, multiValue => _lodash.default.toNumber(multiValue), ['asc']);
|
|
203
|
+
const syntheticEvent = {
|
|
204
|
+
target: {
|
|
205
|
+
name,
|
|
206
|
+
value: changedValue
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
onChange?.(syntheticEvent);
|
|
210
|
+
if (!isMultipleSelect) {
|
|
211
|
+
setListBoxOpen(false);
|
|
212
|
+
setFilterValue('');
|
|
213
|
+
setInputValue(inputLabel ?? '');
|
|
214
|
+
if (document.activeElement === selectSearchInputRef.current) {
|
|
215
|
+
selectInputRef?.current?.focus?.();
|
|
216
|
+
setListBoxOpen(false);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
const handleCheckMultiple = checkOrUncheckAll => {
|
|
221
|
+
const checkAll = Boolean(checkOrUncheckAll);
|
|
222
|
+
let allValues = [];
|
|
223
|
+
listOptionsMap.forEach((__, key) => allValues.push(key));
|
|
224
|
+
const value = checkAll ? allValues : [];
|
|
225
|
+
const syntheticEvent = {
|
|
226
|
+
target: {
|
|
227
|
+
name,
|
|
228
|
+
value
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
onChange?.(syntheticEvent);
|
|
232
|
+
};
|
|
233
|
+
const handleClearValue = () => {
|
|
234
|
+
const resetValue = !isMultipleSelect ? '' : [];
|
|
235
|
+
const syntheticEvent = {
|
|
236
|
+
target: {
|
|
237
|
+
name,
|
|
238
|
+
value: resetValue
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
onChange?.(syntheticEvent);
|
|
242
|
+
setListBoxOpen(false);
|
|
243
|
+
if (!isMultipleSelect) {
|
|
244
|
+
setFilterValue('');
|
|
245
|
+
setInputValue('');
|
|
246
|
+
}
|
|
247
|
+
if (isMultipleWithCheckboxes) {
|
|
248
|
+
setInputValue(multipleInputLabelEmpty);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
const handleOnBlur = event => {
|
|
252
|
+
props?.onBlur?.(event);
|
|
253
|
+
if (!event.relatedTarget || event.relatedTarget !== selectSearchInputRef.current) {
|
|
254
|
+
setListBoxOpen(false);
|
|
255
|
+
}
|
|
256
|
+
setFilterValue('');
|
|
257
|
+
};
|
|
258
|
+
const handleOnFocus = event => {
|
|
259
|
+
props?.onFocus?.(event);
|
|
260
|
+
if (openDropdownOnFocus) {
|
|
261
|
+
setListBoxOpen(true);
|
|
262
|
+
handleOpenListBox();
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
const handleOnChangeInput = event => {
|
|
266
|
+
setFilterValue(event.target.value);
|
|
267
|
+
setInputValue(event.target.value);
|
|
268
|
+
};
|
|
269
|
+
const handleOnPaste = event => {
|
|
270
|
+
if (undigitable || isMultipleWithCheckboxes) {
|
|
271
|
+
event.preventDefault();
|
|
272
|
+
} else {
|
|
273
|
+
props.onPaste?.(event);
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
const handleOnBeforeInput = event => {
|
|
277
|
+
if (undigitable || isMultipleWithCheckboxes) {
|
|
278
|
+
event.preventDefault();
|
|
279
|
+
} else {
|
|
280
|
+
props.onBeforeInput?.(event);
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
const handleOnSearch = event => {
|
|
284
|
+
if (externalSearch) {
|
|
285
|
+
onSearch?.(event);
|
|
286
|
+
} else {
|
|
287
|
+
setFilterValue(event.target.value);
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
const handleOnKeyDown = event => {
|
|
291
|
+
props?.onKeyDown?.(event);
|
|
292
|
+
const notUndigitableKeys = [_types.Keys.backspace, _types.Keys.delete];
|
|
293
|
+
if (undigitable && notUndigitableKeys.includes(event.key)) {
|
|
294
|
+
event.preventDefault();
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
const shouldOpenByTyping = (0, _helpers2.isTypingKey)(event) || event.key === _types.Keys.arrowDown;
|
|
298
|
+
if (shouldOpenByTyping && selectInputRef.current === document.activeElement) {
|
|
299
|
+
if (event.key === _types.Keys.arrowDown) {
|
|
300
|
+
event.preventDefault();
|
|
301
|
+
}
|
|
302
|
+
requestAnimationFrame(() => {
|
|
303
|
+
const ulListElement = selectListBoxRef.current?.querySelector('ul[role="listbox"]');
|
|
304
|
+
const liElementsFiltered = ulListElement?.querySelectorAll('li[data-state-filtered="true"]') ?? [];
|
|
305
|
+
if (!listBoxOpen && event.key === _types.Keys.arrowDown) {
|
|
306
|
+
const currentValue = !isMultipleSelect ? props?.value : _lodash.default.orderBy([...props.value], value => _lodash.default.toNumber(value), ['asc'])[0];
|
|
307
|
+
setActiveDescendant(_lodash.default.toString(currentValue) ?? undefined);
|
|
308
|
+
} else {
|
|
309
|
+
setActiveDescendant(liElementsFiltered[0]?.id ?? undefined);
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
if (!listBoxOpen) {
|
|
313
|
+
setListBoxOpen(true);
|
|
314
|
+
handleOpenListBox();
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
if (listBoxOpen && _helpers2.NAVIGATION_KEYS.includes(event.key)) {
|
|
318
|
+
event.preventDefault();
|
|
319
|
+
}
|
|
320
|
+
requestAnimationFrame(() => {
|
|
321
|
+
const ulListElement = selectListBoxRef.current?.querySelector('ul[role="listbox"]');
|
|
322
|
+
const liElementsFiltered = ulListElement?.querySelectorAll('li[data-state-filtered="true"]') ?? [];
|
|
323
|
+
const currentElementIndex = Array.from(liElementsFiltered).findIndex(liElement => liElement.id === activeDescendant);
|
|
324
|
+
let nextElementIndex = currentElementIndex;
|
|
325
|
+
if (listBoxOpen) {
|
|
326
|
+
if (_helpers2.NAVIGATION_KEYS.includes(event.key)) {
|
|
327
|
+
switch (event.key) {
|
|
328
|
+
case _types.Keys.escape:
|
|
329
|
+
setListBoxOpen(false);
|
|
330
|
+
setFilterValue('');
|
|
331
|
+
selectInputRef.current?.focus();
|
|
332
|
+
if (event.target === selectSearchInputRef.current) {
|
|
333
|
+
setListBoxOpen(false);
|
|
334
|
+
}
|
|
335
|
+
break;
|
|
336
|
+
case _types.Keys.arrowDown:
|
|
337
|
+
nextElementIndex = Math.min(currentElementIndex + 1, liElementsFiltered.length - 1);
|
|
338
|
+
break;
|
|
339
|
+
case _types.Keys.arrowUp:
|
|
340
|
+
nextElementIndex = Math.max(currentElementIndex - 1, 0);
|
|
341
|
+
break;
|
|
342
|
+
case _types.Keys.enter:
|
|
343
|
+
if (activeDescendant) {
|
|
344
|
+
const selectedLIOption = liElementsFiltered[nextElementIndex];
|
|
345
|
+
if (selectedLIOption) {
|
|
346
|
+
selectedLIOption.click();
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
break;
|
|
350
|
+
default:
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
const nextLIOption = liElementsFiltered[nextElementIndex];
|
|
354
|
+
if (nextLIOption) {
|
|
355
|
+
setActiveDescendant(nextLIOption?.id ?? '');
|
|
356
|
+
nextLIOption.scrollIntoView({
|
|
357
|
+
block: 'nearest'
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
} else return null;
|
|
362
|
+
});
|
|
363
|
+
};
|
|
364
|
+
const contextValues = _react.default.useMemo(() => ({
|
|
365
|
+
selectFieldId: SELECT_FIELD_CONTROLS_ID,
|
|
366
|
+
label: props.label,
|
|
367
|
+
striped,
|
|
368
|
+
listBoxOpen,
|
|
369
|
+
filterValue,
|
|
370
|
+
isDisabled,
|
|
371
|
+
liSelectedRef,
|
|
372
|
+
selectInputRef,
|
|
373
|
+
selectSearchInputRef,
|
|
374
|
+
handleOnSearch,
|
|
375
|
+
searchOnDropdown,
|
|
376
|
+
nameSelect: String(props.name),
|
|
377
|
+
valueSelect: props?.value,
|
|
378
|
+
activeDescendant,
|
|
379
|
+
handleOnChange,
|
|
380
|
+
handleOnKeyDown,
|
|
381
|
+
selectContainerRef,
|
|
382
|
+
handleCloseListBox,
|
|
383
|
+
notFoundFilterLabel,
|
|
384
|
+
handleChangeLiSelected,
|
|
385
|
+
isMultipleSelect,
|
|
386
|
+
isMultipleDefault,
|
|
387
|
+
isMultipleWithCheckboxes,
|
|
388
|
+
searchInputPlaceholder,
|
|
389
|
+
showClearButton,
|
|
390
|
+
dropdownAlignButton,
|
|
391
|
+
handleClearValue,
|
|
392
|
+
handleCheckMultiple,
|
|
393
|
+
handleChangeListBoxState
|
|
394
|
+
}), [striped, listBoxOpen, isDisabled, filterValue, props?.name, props?.value, activeDescendant, notFoundFilterLabel, searchOnDropdown, isMultipleSelect, showClearButton, isMultipleDefault, isMultipleWithCheckboxes, searchInputPlaceholder, dropdownAlignButton]);
|
|
395
|
+
if (unvisible || hideContent) return null;
|
|
396
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_gridlayout.default, {
|
|
397
|
+
cols: gridLayout
|
|
398
|
+
}, /*#__PURE__*/_react.default.createElement(_context.SelectFieldContext.Provider, {
|
|
399
|
+
value: contextValues
|
|
400
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
401
|
+
"data-testid": "test-select-field-root",
|
|
402
|
+
className: `select-field-root ${customClassWrapper}`,
|
|
403
|
+
"data-state-error": hasValidationErrors,
|
|
404
|
+
"data-state-hint-position": hintPosition
|
|
405
|
+
}, hasLabel && /*#__PURE__*/_react.default.createElement("span", {
|
|
406
|
+
className: `root-label ${customClassLabel}`,
|
|
407
|
+
"data-state-skeletonize": skeletonize
|
|
408
|
+
}, /*#__PURE__*/_react.default.createElement("label", {
|
|
409
|
+
"data-testid": "test-select-field-label",
|
|
410
|
+
className: "label",
|
|
411
|
+
title: label,
|
|
412
|
+
htmlFor: name,
|
|
413
|
+
"aria-disabled": isDisabled,
|
|
414
|
+
"aria-readonly": isReadOnly,
|
|
415
|
+
"data-state-input-required": props.required
|
|
416
|
+
}, label), hasHintMessages && hintPosition === 'onLabelRight' && !skeletonize && /*#__PURE__*/_react.default.createElement(_popover.default, {
|
|
417
|
+
customClass: "label-popover",
|
|
418
|
+
theme: themePopover,
|
|
419
|
+
align: popoverAlign,
|
|
420
|
+
iconColor: "#03bde2"
|
|
421
|
+
}, /*#__PURE__*/_react.default.createElement(_popover.PopoverText, {
|
|
422
|
+
text: props?.hint ?? ''
|
|
423
|
+
}))), /*#__PURE__*/_react.default.createElement("div", {
|
|
424
|
+
ref: selectContainerRef,
|
|
425
|
+
className: `container ${customClassInputContainer}`,
|
|
426
|
+
"aria-expanded": listBoxOpen,
|
|
427
|
+
"data-state-skeletonize": skeletonize
|
|
428
|
+
}, hasLeftSlotElements && !skeletonize && leftSlotElements, /*#__PURE__*/_react.default.createElement("div", {
|
|
429
|
+
className: "input-root"
|
|
430
|
+
}, /*#__PURE__*/_react.default.createElement("input", _extends({}, rest, {
|
|
431
|
+
ref: (0, _helpers.mergeRefs)(ref, selectInputRef),
|
|
432
|
+
readOnly: props.readOnly || undigitable,
|
|
433
|
+
className: `input ${customClass}`,
|
|
434
|
+
placeholder: rest.placeholder,
|
|
435
|
+
"data-state-error": hasValidationErrors,
|
|
436
|
+
"data-state-multiple": isMultipleSelect,
|
|
437
|
+
"data-state-read-only": isReadOnly,
|
|
438
|
+
"data-state-text-align": textAlign,
|
|
439
|
+
"data-state-undigitable": undigitable,
|
|
440
|
+
"data-state-skeletonize": skeletonize,
|
|
441
|
+
"data-state-multiple-with-checkboxes": isMultipleWithCheckboxes,
|
|
442
|
+
id: name,
|
|
443
|
+
type: "text",
|
|
444
|
+
role: "combobox",
|
|
445
|
+
multiple: false,
|
|
446
|
+
"data-testid": "test-select-field-input",
|
|
447
|
+
"aria-autocomplete": "list",
|
|
448
|
+
"aria-expanded": listBoxOpen,
|
|
449
|
+
"aria-controls": SELECT_FIELD_CONTROLS_ID,
|
|
450
|
+
"aria-activedescendant": activeDescendant,
|
|
451
|
+
tabIndex: !isReadOnly && !skeletonize ? 0 : -1,
|
|
452
|
+
value: inputValue,
|
|
453
|
+
onBlur: handleOnBlur,
|
|
454
|
+
onFocus: handleOnFocus,
|
|
455
|
+
onKeyDown: handleOnKeyDown,
|
|
456
|
+
onChange: handleOnChangeInput,
|
|
457
|
+
onPaste: handleOnPaste,
|
|
458
|
+
onBeforeInput: handleOnBeforeInput
|
|
459
|
+
})), isMultipleDefault && /*#__PURE__*/_react.default.createElement(_selections.Selections, {
|
|
460
|
+
isDisabled: isDisabled,
|
|
461
|
+
isReadOnly: isReadOnly,
|
|
462
|
+
listOfOptionsToSelect: listOptionsMap
|
|
463
|
+
})), hasRightSlotElements && !skeletonize && rightSlotElements, /*#__PURE__*/_react.default.createElement("div", {
|
|
464
|
+
className: "triggers",
|
|
465
|
+
"data-state-disabled": isDisabled,
|
|
466
|
+
"data-state-read-only": isReadOnly,
|
|
467
|
+
"data-state-skeletonize": skeletonize
|
|
468
|
+
}, /*#__PURE__*/_react.default.createElement(_triggers.Triggers, null)), listBoxOpen && !hideContent && /*#__PURE__*/(0, _reactDom.createPortal)(/*#__PURE__*/_react.default.createElement(_listbox.ListBox, {
|
|
469
|
+
ref: selectListBoxRef
|
|
470
|
+
}, children), document.body)), hintPosition === 'below' && /*#__PURE__*/_react.default.createElement(_hint.default, {
|
|
471
|
+
customClass: "hint",
|
|
472
|
+
skeletonize: skeletonize,
|
|
473
|
+
description: props.hint,
|
|
474
|
+
disabled: isDisabled,
|
|
475
|
+
visible: hasHintMessages
|
|
476
|
+
}), hasValidationErrors && /*#__PURE__*/_react.default.createElement("span", {
|
|
477
|
+
"data-testid": "test-select-field-list-errors",
|
|
478
|
+
className: "error",
|
|
479
|
+
"data-state-skeletonize": skeletonize,
|
|
480
|
+
"aria-describedby": String(name).concat('-errors')
|
|
481
|
+
}, errors?.map((error, index) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
|
|
482
|
+
key: `${index + 1}-${error}`
|
|
483
|
+
}, error, "\xA0")))))), /*#__PURE__*/_react.default.createElement(_tooltip.Tooltip, {
|
|
484
|
+
targetRef: selectInputRef,
|
|
485
|
+
text: tooltip,
|
|
486
|
+
position: tooltipPosition,
|
|
487
|
+
width: tooltipWidth,
|
|
488
|
+
space: tooltipPosition === 'right' ? 64 : undefined
|
|
489
|
+
}));
|
|
490
|
+
});
|
|
491
|
+
Input.displayName = 'SelectFieldInput';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
interface SelectFieldItemProps extends React__default.ComponentProps<'li'> {
|
|
4
|
+
value: any;
|
|
5
|
+
label: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
children: React__default.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
declare const Item: React__default.ForwardRefExoticComponent<Pick<SelectFieldItemProps, "className" | "disabled" | "onClick" | "color" | "children" | "label" | "style" | "id" | "key" | "slot" | "title" | "hidden" | "onKeyPress" | "role" | "tabIndex" | "align" | "value" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "lang" | "nonce" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture"> & React__default.RefAttributes<HTMLLIElement>>;
|
|
10
|
+
|
|
11
|
+
export { Item, SelectFieldItemProps };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Item = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
|
+
var Checkbox = _interopRequireWildcard(require("../checkboxfield"));
|
|
10
|
+
var _context = require("./context");
|
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
15
|
+
const Item = exports.Item = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
16
|
+
const {
|
|
17
|
+
disabled,
|
|
18
|
+
children
|
|
19
|
+
} = props;
|
|
20
|
+
const {
|
|
21
|
+
striped,
|
|
22
|
+
filterValue,
|
|
23
|
+
valueSelect,
|
|
24
|
+
activeDescendant,
|
|
25
|
+
handleOnChange,
|
|
26
|
+
handleChangeLiSelected,
|
|
27
|
+
isMultipleSelect,
|
|
28
|
+
isMultipleDefault,
|
|
29
|
+
isMultipleWithCheckboxes
|
|
30
|
+
} = (0, _context.useSelectFieldContext)();
|
|
31
|
+
const valueToString = _lodash.default.toString(props.value);
|
|
32
|
+
const hasFocus = Boolean(activeDescendant === valueToString);
|
|
33
|
+
const ariaSelected = !isMultipleSelect ? Boolean(props.value === valueSelect) : [...valueSelect].includes(props.value);
|
|
34
|
+
const addOrRemove = !isMultipleSelect ? undefined : ariaSelected;
|
|
35
|
+
const hasPartOfFilter = Boolean(String(props.label).toLowerCase().includes(filterValue?.toString().toLowerCase() ?? ''));
|
|
36
|
+
const handleOnClickItem = event => {
|
|
37
|
+
if (isMultipleDefault && ariaSelected) event.preventDefault();else {
|
|
38
|
+
handleOnChange?.(props.value, props.label, addOrRemove);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
return /*#__PURE__*/_react.default.createElement("li", _extends({
|
|
42
|
+
ref: el => {
|
|
43
|
+
if (el) {
|
|
44
|
+
if (ariaSelected) {
|
|
45
|
+
handleChangeLiSelected(el);
|
|
46
|
+
}
|
|
47
|
+
if (typeof ref === 'function') {
|
|
48
|
+
ref(el);
|
|
49
|
+
} else if (ref) {
|
|
50
|
+
ref.current = el;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
key: props.value,
|
|
55
|
+
id: props.value,
|
|
56
|
+
hidden: props.hidden || !hasPartOfFilter,
|
|
57
|
+
tabIndex: -1,
|
|
58
|
+
title: props.label,
|
|
59
|
+
"aria-label": props.label,
|
|
60
|
+
"aria-selected": ariaSelected,
|
|
61
|
+
"aria-hidden": props['aria-hidden'] || !hasPartOfFilter,
|
|
62
|
+
"aria-disabled": disabled,
|
|
63
|
+
"data-content-value": props.value,
|
|
64
|
+
"data-content-label": props.label,
|
|
65
|
+
"data-state-striped": striped,
|
|
66
|
+
"data-state-in-focus": hasFocus,
|
|
67
|
+
"data-state-filtered": hasPartOfFilter,
|
|
68
|
+
"data-state-multiple-with-default": isMultipleDefault,
|
|
69
|
+
"data-state-multiple-with-checkboxes": isMultipleWithCheckboxes,
|
|
70
|
+
"data-testid": "test-select-field-listbox-item",
|
|
71
|
+
role: "option",
|
|
72
|
+
onClick: handleOnClickItem,
|
|
73
|
+
onMouseDown: event => {
|
|
74
|
+
event.preventDefault();
|
|
75
|
+
}
|
|
76
|
+
}, props), isMultipleWithCheckboxes && /*#__PURE__*/_react.default.createElement(Checkbox.Input, {
|
|
77
|
+
rounded: true,
|
|
78
|
+
checked: ariaSelected,
|
|
79
|
+
size: "default",
|
|
80
|
+
variant: "secondary",
|
|
81
|
+
"data-state-in-focus-select-field": hasFocus,
|
|
82
|
+
name: String(props.label).concat('-').concat(props.value)
|
|
83
|
+
}), children);
|
|
84
|
+
});
|
|
85
|
+
Item.displayName = 'SelectFieldItem';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
interface SelectFieldListBoxProps extends React__default.ComponentProps<'div'> {
|
|
4
|
+
}
|
|
5
|
+
declare const ListBox: React__default.ForwardRefExoticComponent<Pick<SelectFieldListBoxProps, "className" | "onClick" | "color" | "children" | "style" | "id" | "key" | "slot" | "title" | "hidden" | "onKeyPress" | "role" | "tabIndex" | "align" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "lang" | "nonce" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture"> & React__default.RefAttributes<HTMLDivElement>>;
|
|
6
|
+
|
|
7
|
+
export { ListBox, SelectFieldListBoxProps };
|