@elliemae/ds-controlled-form 2.3.0-next.1 → 2.3.0-next.14
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/cjs/controlled-autocomplete/parts/controls/styled.js +2 -2
- package/cjs/controlled-autocomplete/parts/menu-list/MenuList.js +2 -2
- package/cjs/controlled-checkbox/ControlledCheckbox.js +54 -40
- package/cjs/controlled-checkbox/config/useValidateProps.js +2 -2
- package/cjs/controlled-checkbox/react-desc-prop-types.js +32 -0
- package/cjs/controlled-checkbox/utils/styleHelpers.js +4 -4
- package/cjs/controlled-combobox/ComboBox.js +3 -6
- package/cjs/controlled-combobox/ComboBoxCTX.js +1 -4
- package/cjs/controlled-combobox/ComboboxDataTestids.js +2 -1
- package/cjs/controlled-combobox/config/useComboBox.js +19 -73
- package/cjs/controlled-combobox/config/useCorrectOptions.js +77 -0
- package/cjs/controlled-combobox/parts/a11y-messages/FocusMenuItem.js +46 -0
- package/cjs/controlled-combobox/parts/a11y-messages/{MultiAllyMessages.js → SelectedValuesAllyMsg.js} +21 -7
- package/cjs/controlled-combobox/parts/a11y-messages/index.js +4 -4
- package/cjs/controlled-combobox/parts/container/Container.js +32 -21
- package/cjs/controlled-combobox/parts/container/styled.js +9 -6
- package/cjs/controlled-combobox/parts/controls/Controls.js +31 -19
- package/cjs/controlled-combobox/parts/controls/styled.js +24 -12
- package/cjs/controlled-combobox/parts/controls/useOnPillsNavigation.js +51 -0
- package/cjs/controlled-combobox/parts/controls-input/ControlsInput.js +9 -7
- package/cjs/controlled-combobox/parts/controls-input/useControlsInput.js +16 -8
- package/cjs/controlled-combobox/parts/dropdown-indicator/DropdownIndicator.js +6 -3
- package/cjs/controlled-combobox/parts/dropdown-indicator/styled.js +2 -3
- package/cjs/controlled-combobox/parts/header-list/HeaderList.js +8 -13
- package/cjs/controlled-combobox/parts/header-list/useHeaderListHandlers.js +12 -5
- package/cjs/controlled-combobox/parts/menu-list/MenuList.js +13 -18
- package/cjs/controlled-combobox/parts/menu-list/styled.js +5 -1
- package/cjs/controlled-combobox/parts/menu-list/useItemRenderer.js +14 -17
- package/cjs/controlled-combobox/parts/menu-list/useMenuList.js +11 -13
- package/cjs/controlled-combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +33 -19
- package/cjs/controlled-combobox/parts/multi-selected-values-container/useGroupPills.js +5 -5
- package/cjs/controlled-combobox/react-desc-prop-types.js +42 -0
- package/cjs/{controlled-checkbox/index.d.js → controlled-combobox/sharedTypes.js} +0 -0
- package/cjs/controlled-combobox/utils/hooks/useKeyboardNavigation.js +19 -18
- package/cjs/controlled-combobox/utils/listHelper.js +2 -2
- package/cjs/controlled-date-time-picker/parts/ControlledDateTimePickerContent.js +2 -2
- package/cjs/controlled-date-time-picker/parts/DateInputs/DateInputs.js +2 -2
- package/cjs/controlled-date-time-picker/parts/Pickers/Calendar/Styleds.js +2 -2
- package/cjs/controlled-date-time-picker/parts/Pickers/TimeWheel/Styleds.js +2 -2
- package/cjs/controlled-date-time-picker/parts/Styleds.js +6 -6
- package/cjs/controlled-date-time-picker/parts/TimeInputs/TimeInputs.js +2 -2
- package/esm/controlled-checkbox/ControlledCheckbox.js +49 -37
- package/esm/controlled-checkbox/config/useValidateProps.js +2 -2
- package/esm/controlled-checkbox/react-desc-prop-types.js +23 -0
- package/esm/controlled-checkbox/utils/styleHelpers.js +4 -4
- package/esm/controlled-combobox/ComboBox.js +4 -7
- package/esm/controlled-combobox/ComboBoxCTX.js +1 -4
- package/esm/controlled-combobox/ComboboxDataTestids.js +2 -1
- package/esm/controlled-combobox/config/useComboBox.js +22 -76
- package/esm/controlled-combobox/config/useCorrectOptions.js +73 -0
- package/esm/controlled-combobox/parts/a11y-messages/FocusMenuItem.js +38 -0
- package/esm/controlled-combobox/parts/a11y-messages/SelectedValuesAllyMsg.js +39 -0
- package/esm/controlled-combobox/parts/a11y-messages/index.js +2 -2
- package/esm/controlled-combobox/parts/container/Container.js +30 -21
- package/esm/controlled-combobox/parts/container/styled.js +9 -6
- package/esm/controlled-combobox/parts/controls/Controls.js +32 -20
- package/esm/controlled-combobox/parts/controls/styled.js +22 -10
- package/esm/controlled-combobox/parts/controls/useOnPillsNavigation.js +47 -0
- package/esm/controlled-combobox/parts/controls-input/ControlsInput.js +9 -7
- package/esm/controlled-combobox/parts/controls-input/useControlsInput.js +16 -8
- package/esm/controlled-combobox/parts/dropdown-indicator/DropdownIndicator.js +6 -3
- package/esm/controlled-combobox/parts/dropdown-indicator/styled.js +3 -3
- package/esm/controlled-combobox/parts/header-list/HeaderList.js +8 -13
- package/esm/controlled-combobox/parts/header-list/useHeaderListHandlers.js +12 -5
- package/esm/controlled-combobox/parts/menu-list/MenuList.js +16 -21
- package/esm/controlled-combobox/parts/menu-list/styled.js +5 -2
- package/esm/controlled-combobox/parts/menu-list/useItemRenderer.js +12 -15
- package/esm/controlled-combobox/parts/menu-list/useMenuList.js +11 -13
- package/esm/controlled-combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +35 -20
- package/esm/controlled-combobox/parts/multi-selected-values-container/useGroupPills.js +5 -5
- package/esm/controlled-combobox/{propTypes.js → react-desc-prop-types.js} +17 -7
- package/esm/{controlled-checkbox/index.d.js → controlled-combobox/sharedTypes.js} +0 -0
- package/esm/controlled-combobox/utils/hooks/useKeyboardNavigation.js +19 -18
- package/esm/controlled-combobox/utils/listHelper.js +2 -2
- package/package.json +35 -59
- package/types/controlled-checkbox/ControlledCheckbox.d.ts +4 -70
- package/types/controlled-checkbox/config/useValidateProps.d.ts +2 -2
- package/types/controlled-checkbox/react-desc-prop-types.d.ts +32 -0
- package/types/controlled-checkbox/styles.d.ts +3 -3
- package/types/controlled-checkbox/utils/setMultipleRefs.d.ts +1 -1
- package/types/controlled-checkbox/utils/styleHelpers.d.ts +3 -3
- package/types/controlled-combobox/ComboBox.d.ts +4 -70
- package/types/controlled-combobox/ComboBoxCTX.d.ts +4 -3
- package/types/controlled-combobox/ComboboxDataTestids.d.ts +1 -0
- package/types/controlled-combobox/config/useComboBox.d.ts +3 -2
- package/types/controlled-combobox/config/useCorrectOptions.d.ts +3 -0
- package/types/controlled-combobox/parts/a11y-messages/FocusMenuItem.d.ts +3 -0
- package/types/controlled-combobox/parts/a11y-messages/SelectedValuesAllyMsg.d.ts +3 -0
- package/types/controlled-combobox/parts/a11y-messages/index.d.ts +2 -2
- package/types/controlled-combobox/parts/controls/styled.d.ts +10 -2
- package/types/controlled-combobox/parts/controls/useOnPillsNavigation.d.ts +4 -0
- package/types/controlled-combobox/parts/dropdown-indicator/styled.d.ts +2 -1
- package/types/controlled-combobox/parts/header-list/useHeaderListHandlers.d.ts +2 -1
- package/types/controlled-combobox/parts/menu-list/styled.d.ts +1 -0
- package/types/controlled-combobox/parts/menu-list/useItemRenderer.d.ts +2 -2
- package/types/controlled-combobox/react-desc-prop-types.d.ts +57 -0
- package/types/controlled-combobox/sharedTypes.d.ts +27 -0
- package/types/controlled-combobox/utils/hooks/useKeyboardNavigation.d.ts +1 -1
- package/types/controlled-combobox/utils/listHelper.d.ts +7 -7
- package/types/controlled-date-time-picker/parts/Pickers/Calendar/Styleds.d.ts +3 -12
- package/types/controlled-date-time-picker/parts/Pickers/CalendarWithTimeWheel/Styleds.d.ts +1 -4
- package/types/controlled-date-time-picker/parts/Pickers/TimeWheel/Styleds.d.ts +3 -12
- package/types/controlled-date-time-picker/parts/Styleds.d.ts +1 -4
- package/cjs/controlled-checkbox/propTypes.js +0 -22
- package/cjs/controlled-combobox/config/constants.js +0 -14
- package/cjs/controlled-combobox/config/useGetPropsWithDefault.js +0 -11
- package/cjs/controlled-combobox/index.d.js +0 -2
- package/cjs/controlled-combobox/parts/a11y-messages/SingleAllyMessages.js +0 -28
- package/cjs/controlled-combobox/parts/dropdown-indicator/index.js +0 -2
- package/cjs/controlled-combobox/parts/empty-state/index.js +0 -23
- package/cjs/controlled-combobox/parts/empty-state/styled.js +0 -19
- package/cjs/controlled-combobox/parts/multi-selected-values-container/styled.js +0 -23
- package/cjs/controlled-combobox/parts/single-selected-value-container/SingleSelectedValueContainer.js +0 -28
- package/cjs/controlled-combobox/parts/single-selected-value-container/index.js +0 -9
- package/cjs/controlled-combobox/parts/single-selected-value-container/styled.js +0 -15
- package/cjs/controlled-combobox/propTypes.js +0 -28
- package/esm/controlled-checkbox/propTypes.js +0 -18
- package/esm/controlled-combobox/config/constants.js +0 -10
- package/esm/controlled-combobox/config/useGetPropsWithDefault.js +0 -7
- package/esm/controlled-combobox/index.d.js +0 -1
- package/esm/controlled-combobox/parts/a11y-messages/MultiAllyMessages.js +0 -25
- package/esm/controlled-combobox/parts/a11y-messages/SingleAllyMessages.js +0 -20
- package/esm/controlled-combobox/parts/dropdown-indicator/index.js +0 -1
- package/esm/controlled-combobox/parts/empty-state/index.js +0 -15
- package/esm/controlled-combobox/parts/empty-state/styled.js +0 -10
- package/esm/controlled-combobox/parts/multi-selected-values-container/styled.js +0 -13
- package/esm/controlled-combobox/parts/single-selected-value-container/SingleSelectedValueContainer.js +0 -20
- package/esm/controlled-combobox/parts/single-selected-value-container/index.js +0 -1
- package/esm/controlled-combobox/parts/single-selected-value-container/styled.js +0 -7
- package/types/controlled-checkbox/index.d.d.ts +0 -29
- package/types/controlled-checkbox/propTypes.d.ts +0 -60
- package/types/controlled-combobox/config/constants.d.ts +0 -8
- package/types/controlled-combobox/config/useGetPropsWithDefault.d.ts +0 -2
- package/types/controlled-combobox/parts/a11y-messages/MultiAllyMessages.d.ts +0 -3
- package/types/controlled-combobox/parts/a11y-messages/SingleAllyMessages.d.ts +0 -3
- package/types/controlled-combobox/parts/dropdown-indicator/index.d.ts +0 -0
- package/types/controlled-combobox/parts/empty-state/index.d.ts +0 -3
- package/types/controlled-combobox/parts/empty-state/styled.d.ts +0 -2
- package/types/controlled-combobox/parts/multi-selected-values-container/styled.d.ts +0 -3
- package/types/controlled-combobox/parts/single-selected-value-container/SingleSelectedValueContainer.d.ts +0 -3
- package/types/controlled-combobox/parts/single-selected-value-container/index.d.ts +0 -1
- package/types/controlled-combobox/parts/single-selected-value-container/styled.d.ts +0 -1
- package/types/controlled-combobox/propTypes.d.ts +0 -60
- package/types/controlled-combobox/tests/combobox-special-keys.test.d.ts +0 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var styled = require('styled-components');
|
|
6
|
-
var
|
|
6
|
+
var dsGrid = require('@elliemae/ds-grid');
|
|
7
7
|
var DSButton = require('@elliemae/ds-button');
|
|
8
8
|
|
|
9
9
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -14,10 +14,10 @@ var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
|
14
14
|
const ResettedInput = /*#__PURE__*/styled__default["default"].input.withConfig({
|
|
15
15
|
componentId: "sc-1t4k08s-0"
|
|
16
16
|
})(["border:none;box-shadow:none;background:none;text-align:center;height:100%;display:flex;align-items:center;:focus{outline:none;}padding-top:2px;"]);
|
|
17
|
-
const StyledSeparator = /*#__PURE__*/styled__default["default"](
|
|
17
|
+
const StyledSeparator = /*#__PURE__*/styled__default["default"](dsGrid.Grid).withConfig({
|
|
18
18
|
componentId: "sc-1t4k08s-1"
|
|
19
19
|
})(["padding-top:2px;margin:auto;"]);
|
|
20
|
-
const StyledColonSeparator = /*#__PURE__*/styled__default["default"](
|
|
20
|
+
const StyledColonSeparator = /*#__PURE__*/styled__default["default"](dsGrid.Grid).withConfig({
|
|
21
21
|
componentId: "sc-1t4k08s-2"
|
|
22
22
|
})(["padding-bottom:1px;margin:auto;"]);
|
|
23
23
|
const Styled2DigitsInput = /*#__PURE__*/styled__default["default"](ResettedInput).withConfig({
|
|
@@ -36,7 +36,7 @@ const StyledMin4DigitsInput = /*#__PURE__*/styled__default["default"](ResettedIn
|
|
|
36
36
|
} = _ref2;
|
|
37
37
|
return disabled ? "color: #616b7f;" : "";
|
|
38
38
|
});
|
|
39
|
-
const StyledInputsWrapperGrid = /*#__PURE__*/styled__default["default"](
|
|
39
|
+
const StyledInputsWrapperGrid = /*#__PURE__*/styled__default["default"](dsGrid.Grid).withConfig({
|
|
40
40
|
componentId: "sc-1t4k08s-5"
|
|
41
41
|
})(["width:max-content;align-items:center;", " border-color:", ";border-radius:2px;padding-left:", ";padding-right:", ";position:relative;", ""], _ref3 => {
|
|
42
42
|
let {
|
|
@@ -75,7 +75,7 @@ const StyledDateInputsWrapperGrid = /*#__PURE__*/styled__default["default"].div.
|
|
|
75
75
|
const StyledTimeInputsWrapperGrid = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
76
76
|
componentId: "sc-1t4k08s-7"
|
|
77
77
|
})(["display:grid;grid-template-columns:24px min-content 24px min-content 24px min-content 24px;grid-template-rows:min-content;padding:6px 0;gap:0px 0px;align-items:center;input,p{margin:0;}"]);
|
|
78
|
-
const StyledPickersIconsWrapperGrid = /*#__PURE__*/styled__default["default"](
|
|
78
|
+
const StyledPickersIconsWrapperGrid = /*#__PURE__*/styled__default["default"](dsGrid.Grid).withConfig({
|
|
79
79
|
componentId: "sc-1t4k08s-8"
|
|
80
80
|
})(["position:relative;", ":before{content:'';position:absolute;top:0px;left:-1px;width:100%;height:100%;border-radius:2px;z-index:-1;", "}"], _ref8 => {
|
|
81
81
|
let {
|
|
@@ -90,7 +90,7 @@ const StyledPickersIconsWrapperGrid = /*#__PURE__*/styled__default["default"](Gr
|
|
|
90
90
|
} = _ref9;
|
|
91
91
|
return isControllerOnly ? "" : "\n border-left: 1px solid ".concat(hasError ? theme.colors.danger[900] : theme.colors.neutral[200], "\n ");
|
|
92
92
|
});
|
|
93
|
-
const StyledFocusWithIn = /*#__PURE__*/styled__default["default"](
|
|
93
|
+
const StyledFocusWithIn = /*#__PURE__*/styled__default["default"](dsGrid.Grid).withConfig({
|
|
94
94
|
componentId: "sc-1t4k08s-9"
|
|
95
95
|
})(["position:relative;&:focus-within{&:after{display:block;content:' ';position:absolute;top:-5px;left:-2px;width:calc(100% + 4px);height:calc(100% + 10px);border:2px solid ", ";border-radius:2px;pointer-events:none;}}"], _ref10 => {
|
|
96
96
|
let {
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var
|
|
7
|
+
var dsGrid = require('@elliemae/ds-grid');
|
|
8
8
|
var ControlledDateTimePickerCTX = require('../../ControlledDateTimePickerCTX.js');
|
|
9
9
|
var HHInput = require('./HHInput.js');
|
|
10
10
|
var MinutesInput = require('./MinutesInput.js');
|
|
@@ -49,7 +49,7 @@ const TimeInputs = () => {
|
|
|
49
49
|
meridiemInputRef,
|
|
50
50
|
ariaCurrentValueForInputs
|
|
51
51
|
} = React.useContext(ControlledDateTimePickerCTX.ControlledDateTimePickerContext);
|
|
52
|
-
return /*#__PURE__*/_jsx__default["default"](
|
|
52
|
+
return /*#__PURE__*/_jsx__default["default"](dsGrid.Grid, {
|
|
53
53
|
cols: [config.fixedValues.smallInputWidth, config.fixedValues.separatorWidth, config.fixedValues.smallInputWidth, config.fixedValues.separatorWidth, config.fixedValues.smallInputWidth]
|
|
54
54
|
}, void 0, /*#__PURE__*/_jsx__default["default"](Styleds.StyledFocusWithIn, {}, void 0, /*#__PURE__*/_jsx__default["default"](HHInput.HHInput, {
|
|
55
55
|
value: hours,
|
|
@@ -1,68 +1,80 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
1
6
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
7
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
8
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
2
9
|
import { useRef, useCallback } from 'react';
|
|
3
|
-
import { describe } from '
|
|
10
|
+
import { describe, useMemoMergePropsWithDefault, useGetGlobalAttributes } from '@elliemae/ds-props-helpers';
|
|
4
11
|
import { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';
|
|
5
|
-
import { propTypes } from './propTypes.js';
|
|
6
12
|
import { StyledContainer, StyledCheckBox, StyledInput, StyledLabel } from './styles.js';
|
|
7
|
-
import {
|
|
13
|
+
import { propTypes, defaultProps } from './react-desc-prop-types.js';
|
|
8
14
|
import { setMultipleRefs } from './utils/setMultipleRefs.js';
|
|
15
|
+
import { useValidateProps } from './config/useValidateProps.js';
|
|
9
16
|
import { jsx } from 'react/jsx-runtime';
|
|
10
17
|
|
|
18
|
+
const _excluded = ["id", "disabled", "readOnly", "label", "aria-label", "aria-controls", "onKeyDown", "className"];
|
|
19
|
+
|
|
20
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
+
|
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
23
|
+
|
|
11
24
|
const DSControlledCheckbox = props => {
|
|
25
|
+
const propsWithDefault = useMemoMergePropsWithDefault(props, defaultProps);
|
|
12
26
|
useValidateProps(props, propTypes);
|
|
13
|
-
const checkboxRef = useRef();
|
|
27
|
+
const checkboxRef = useRef(null);
|
|
14
28
|
const {
|
|
15
|
-
autoFocus,
|
|
16
29
|
checked,
|
|
17
|
-
ariaControls,
|
|
18
|
-
ariaLabel,
|
|
19
|
-
disabled,
|
|
20
|
-
id,
|
|
21
30
|
label,
|
|
22
31
|
hasError,
|
|
23
|
-
onChange,
|
|
24
|
-
onFocus,
|
|
25
|
-
onBlur,
|
|
26
|
-
value,
|
|
27
|
-
readOnly,
|
|
28
|
-
name,
|
|
29
32
|
innerRef,
|
|
30
|
-
tabIndex
|
|
31
|
-
|
|
33
|
+
tabIndex,
|
|
34
|
+
ariaLabel: legacyAriaLabel,
|
|
35
|
+
ariaControls: legacyAriaControls,
|
|
36
|
+
'data-testid': dataTestid = 'ds-checkbox-container'
|
|
37
|
+
} = propsWithDefault;
|
|
32
38
|
const handleOnKeyDown = useCallback(e => {
|
|
33
39
|
if (checkboxRef.current && e.key === 'Enter') {
|
|
34
40
|
checkboxRef.current.click();
|
|
35
41
|
}
|
|
36
42
|
}, []);
|
|
43
|
+
|
|
44
|
+
const _useGetGlobalAttribut = useGetGlobalAttributes(propsWithDefault, {
|
|
45
|
+
onKeyDown: handleOnKeyDown
|
|
46
|
+
}),
|
|
47
|
+
{
|
|
48
|
+
id,
|
|
49
|
+
disabled,
|
|
50
|
+
readOnly,
|
|
51
|
+
label: globalLabel,
|
|
52
|
+
'aria-label': ariaLabel,
|
|
53
|
+
'aria-controls': ariaControls,
|
|
54
|
+
onKeyDown,
|
|
55
|
+
className
|
|
56
|
+
} = _useGetGlobalAttribut,
|
|
57
|
+
restGlobals = _objectWithoutProperties(_useGetGlobalAttribut, _excluded);
|
|
58
|
+
|
|
37
59
|
return /*#__PURE__*/_jsx(StyledContainer, {
|
|
38
|
-
"data-testid":
|
|
60
|
+
"data-testid": dataTestid,
|
|
61
|
+
className: className
|
|
39
62
|
}, void 0, /*#__PURE__*/_jsx(StyledCheckBox, {
|
|
40
|
-
checked:
|
|
63
|
+
checked: checked,
|
|
41
64
|
hasError: hasError,
|
|
42
65
|
disabled: disabled,
|
|
43
66
|
readOnly: readOnly
|
|
44
|
-
}, void 0, /*#__PURE__*/jsx(StyledInput, {
|
|
45
|
-
|
|
67
|
+
}, void 0, /*#__PURE__*/jsx(StyledInput, _objectSpread(_objectSpread({}, restGlobals), {}, {
|
|
68
|
+
"data-testid": "ds-checkbox",
|
|
69
|
+
id: id,
|
|
46
70
|
ref: ref => setMultipleRefs([checkboxRef, innerRef])(ref),
|
|
47
71
|
onKeyDown: handleOnKeyDown,
|
|
48
72
|
type: "checkbox",
|
|
49
73
|
checked: checked !== 'mixed' ? checked : undefined,
|
|
50
|
-
"aria-
|
|
51
|
-
"aria-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"aria-readonly": readOnly,
|
|
55
|
-
"aria-label": ariaLabel || label,
|
|
56
|
-
onFocus: onFocus,
|
|
57
|
-
onBlur: onBlur,
|
|
58
|
-
name: name,
|
|
59
|
-
value: value,
|
|
60
|
-
onChange: onChange,
|
|
61
|
-
id: id,
|
|
62
|
-
"data-testid": "ds-checkbox",
|
|
63
|
-
autoFocus: autoFocus,
|
|
64
|
-
tabIndex: tabIndex || 0
|
|
65
|
-
})), label && /*#__PURE__*/_jsx(StyledLabel, {
|
|
74
|
+
"aria-label": ariaLabel || legacyAriaLabel || label,
|
|
75
|
+
"aria-controls": ariaControls || legacyAriaControls,
|
|
76
|
+
tabIndex: tabIndex
|
|
77
|
+
}))), label && /*#__PURE__*/_jsx(StyledLabel, {
|
|
66
78
|
htmlFor: id,
|
|
67
79
|
disabled: disabled,
|
|
68
80
|
readOnly: readOnly,
|
|
@@ -7,11 +7,11 @@ const throwError = message => {
|
|
|
7
7
|
const useValidateProps = (props, propTypes) => {
|
|
8
8
|
useValidateTypescriptPropTypes(props, propTypes);
|
|
9
9
|
|
|
10
|
-
if (typeof props.label === 'undefined' && typeof props
|
|
10
|
+
if (typeof props.label === 'undefined' && typeof props['aria-label'] === 'undefined') {
|
|
11
11
|
throwError("Please provide a label or ariaLabel property to use this component.");
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
if (props.checked === 'mixed' && typeof props
|
|
14
|
+
if (props.checked === 'mixed' && typeof props['aria-controls'] === 'undefined') {
|
|
15
15
|
throwError("Please provide an ariaControls property to use a checkbox mixed state. \n This property must be a string containing all the ids that this mixed checkbox is controlling.");
|
|
16
16
|
}
|
|
17
17
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import { PropTypes, globalAttributesPropTypes } from '@elliemae/ds-props-helpers';
|
|
8
|
+
|
|
9
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
|
+
|
|
11
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
12
|
+
const defaultProps = {
|
|
13
|
+
hasError: false,
|
|
14
|
+
tabIndex: undefined,
|
|
15
|
+
checked: false
|
|
16
|
+
};
|
|
17
|
+
const propTypes = _objectSpread(_objectSpread({}, globalAttributesPropTypes), {}, {
|
|
18
|
+
label: PropTypes.string.description('Checkbox Label property. This label is also going to be used as an aria-label for screen readers.'),
|
|
19
|
+
hasError: PropTypes.bool.description('Whether the checkbox has error or not.'),
|
|
20
|
+
innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description('Checkbox input ref.')
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export { defaultProps, propTypes };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable max-params */
|
|
2
|
-
const handleCheckMarkColor = (_ref,
|
|
2
|
+
const handleCheckMarkColor = (_ref, checked, isHovering, disabled, readOnly, hasError) => {
|
|
3
3
|
let {
|
|
4
4
|
colors
|
|
5
5
|
} = _ref;
|
|
@@ -22,14 +22,14 @@ const handleCheckmark = function (theme, checked, disabled, readOnly, hasError)
|
|
|
22
22
|
let isHovering = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
23
23
|
|
|
24
24
|
if (checked === 'mixed') {
|
|
25
|
-
return "&:before {\n position: absolute;\n content: '';\n top: 6px;\n left: 3px;\n background: ".concat(handleCheckMarkColor(theme,
|
|
25
|
+
return "&:before {\n position: absolute;\n content: '';\n top: 6px;\n left: 3px;\n background: ".concat(handleCheckMarkColor(theme, checked, isHovering, disabled, readOnly, hasError), ";\n width: ").concat(theme.space.xxs, ";\n height: 2px;\n }");
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
if (checked) {
|
|
29
|
-
return "&:before {\n position: absolute;\n content: '';\n top: 3px;\n left: 2px;\n border-left: 2px solid ".concat(handleCheckMarkColor(theme,
|
|
29
|
+
return "&:before {\n position: absolute;\n content: '';\n top: 3px;\n left: 2px;\n border-left: 2px solid ".concat(handleCheckMarkColor(theme, checked, isHovering, disabled, readOnly, hasError), ";\n border-bottom: 2px solid ").concat(handleCheckMarkColor(theme, checked, isHovering, disabled, readOnly, hasError), ";\n height: 5px;\n width: 10px;\n transform: rotate(-45deg);\n }");
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
return
|
|
32
|
+
return '';
|
|
33
33
|
};
|
|
34
34
|
const handleBackgroundColor = (_ref2, disabled) => {
|
|
35
35
|
let {
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
2
|
import 'react';
|
|
3
|
-
import { describe } from '
|
|
4
|
-
import { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';
|
|
3
|
+
import { describe } from '@elliemae/ds-props-helpers';
|
|
5
4
|
import { useComboBox } from './config/useComboBox.js';
|
|
6
5
|
import { Container } from './parts/container/Container.js';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { ComboBoxContext } from './ComboBoxCTX.js';
|
|
7
|
+
import { ComboboxPropTypes } from './react-desc-prop-types.js';
|
|
9
8
|
|
|
10
9
|
var _Container;
|
|
11
10
|
|
|
12
11
|
const DSComboBox = props => {
|
|
13
|
-
const propsWithDefault = useMemoMergePropsWithDefault(props, defaultProps);
|
|
14
|
-
useValidateTypescriptPropTypes(propsWithDefault, propTypes);
|
|
15
12
|
const ctx = useComboBox(props);
|
|
16
13
|
return /*#__PURE__*/_jsx(ComboBoxContext.Provider, {
|
|
17
14
|
value: ctx
|
|
@@ -19,6 +16,6 @@ const DSComboBox = props => {
|
|
|
19
16
|
};
|
|
20
17
|
|
|
21
18
|
const DSComboBoxWithSchema = describe(DSComboBox);
|
|
22
|
-
DSComboBoxWithSchema.propTypes =
|
|
19
|
+
DSComboBoxWithSchema.propTypes = ComboboxPropTypes;
|
|
23
20
|
|
|
24
21
|
export { DSComboBox, DSComboBoxWithSchema };
|
|
@@ -14,7 +14,7 @@ const defaultProps = {
|
|
|
14
14
|
onClearAll: noop,
|
|
15
15
|
onSelectAll: noop,
|
|
16
16
|
onCreate: noop,
|
|
17
|
-
|
|
17
|
+
onBlur: noop,
|
|
18
18
|
withoutPortal: true,
|
|
19
19
|
zIndex: 10,
|
|
20
20
|
onChange: noop,
|
|
@@ -32,15 +32,12 @@ const defaultContext = {
|
|
|
32
32
|
setHasFocus: noop,
|
|
33
33
|
pillGroupRef: /*#__PURE__*/createRef(),
|
|
34
34
|
setReferenceElement: noop,
|
|
35
|
-
inputRef: /*#__PURE__*/createRef(),
|
|
36
35
|
listRef: /*#__PURE__*/createRef(),
|
|
37
36
|
wrapperListRef: /*#__PURE__*/createRef(),
|
|
38
37
|
controlsWrapperRef: /*#__PURE__*/createRef(),
|
|
39
38
|
selectedOptionsRef: /*#__PURE__*/createRef(),
|
|
40
39
|
selectAllCheckboxRef: /*#__PURE__*/createRef(),
|
|
41
40
|
toggleSelectionButtonRef: /*#__PURE__*/createRef(),
|
|
42
|
-
showSelectedValue: false,
|
|
43
|
-
setShowSelectedValue: noop,
|
|
44
41
|
focusOptionIdx: '',
|
|
45
42
|
setCurrentOption: noop,
|
|
46
43
|
showSelectedOptions: false,
|
|
@@ -7,7 +7,8 @@ const ComboboxDataTestid = {
|
|
|
7
7
|
DROPDOWN: 'combobox-dropdown-btn',
|
|
8
8
|
OPTION: 'combobox-option',
|
|
9
9
|
SELECT_ALL_CHECKBOX: 'combobox-select-all-checkbox',
|
|
10
|
-
SHOW_SELECTED_OPTIONS_TOGGLE: 'combobox-selected-options-toggle'
|
|
10
|
+
SHOW_SELECTED_OPTIONS_TOGGLE: 'combobox-selected-options-toggle',
|
|
11
|
+
ALLY_SELECTED_VALUES: 'combobox-ally-selected-values'
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
export { ComboboxDataTestid };
|
|
@@ -1,93 +1,43 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
3
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
4
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
-
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
7
|
-
import 'core-js/modules/esnext.iterator.find.js';
|
|
8
1
|
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
9
3
|
import 'core-js/modules/esnext.iterator.filter.js';
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
8
|
+
import { useRef, useState, useCallback, useMemo } from 'react';
|
|
13
9
|
import { useVirtual } from 'react-virtual';
|
|
14
|
-
import {
|
|
10
|
+
import { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';
|
|
11
|
+
import { defaultProps } from '../ComboBoxCTX.js';
|
|
12
|
+
import { ComboboxPropTypes } from '../react-desc-prop-types.js';
|
|
13
|
+
import { useCorrectOptions } from './useCorrectOptions.js';
|
|
15
14
|
|
|
16
15
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
16
|
|
|
18
17
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
18
|
const useComboBox = props => {
|
|
19
|
+
const defaultPropsWithInnerRef = _objectSpread(_objectSpread({}, defaultProps), {}, {
|
|
20
|
+
innerRef: useRef(null)
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const propsWithDefaults = useMemoMergePropsWithDefault(props, defaultPropsWithInnerRef);
|
|
24
|
+
useValidateTypescriptPropTypes(propsWithDefaults, ComboboxPropTypes);
|
|
20
25
|
const [showPopover, setShowPopover] = useState(false);
|
|
21
26
|
const [referenceElement, setReferenceElement] = useState(null);
|
|
22
|
-
const [showSelectedValue, setShowSelectedValue] = useState(false);
|
|
23
27
|
const [showSelectedOptions, setShowSelectedOptions] = useState(false);
|
|
24
28
|
const [hasFocus, setHasFocus] = useState(false);
|
|
25
29
|
const [focusOptionIdx, setCurrentOption] = useState('');
|
|
26
|
-
const inputRef = useRef(null);
|
|
27
30
|
const listRef = useRef(null);
|
|
28
31
|
const wrapperListRef = useRef(null);
|
|
29
32
|
const selectedOptionsRef = useRef(null);
|
|
30
33
|
const controlsWrapperRef = useRef(null);
|
|
31
34
|
const selectAllCheckboxRef = useRef(null);
|
|
32
35
|
const toggleSelectionButtonRef = useRef(null);
|
|
33
|
-
const pillGroupRef = useRef(null);
|
|
34
|
-
const propsWithDefaults = useGetComboBoxWithDefaultsProps(props);
|
|
35
|
-
const {
|
|
36
|
-
options,
|
|
37
|
-
selectedValues,
|
|
38
|
-
onCreate
|
|
39
|
-
} = propsWithDefaults; // ---------------------------------------------------------------------------
|
|
36
|
+
const pillGroupRef = useRef(null); // ---------------------------------------------------------------------------
|
|
40
37
|
// Menu Options with/out selected filter
|
|
41
38
|
// ---------------------------------------------------------------------------
|
|
42
39
|
|
|
43
|
-
const
|
|
44
|
-
var _items2;
|
|
45
|
-
|
|
46
|
-
const multiSelectedValue = selectedValues;
|
|
47
|
-
const items = [];
|
|
48
|
-
options.forEach(option => {
|
|
49
|
-
const isSelectedValue = multiSelectedValue.find(item => item.dsId === option.dsId);
|
|
50
|
-
|
|
51
|
-
if (isSelectedValue) {
|
|
52
|
-
items.push(option);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (option.type === 'section') {
|
|
56
|
-
var _items;
|
|
57
|
-
|
|
58
|
-
if (((_items = items[items.length - 1]) === null || _items === void 0 ? void 0 : _items.type) === 'section') {
|
|
59
|
-
items[items.length - 1] = option;
|
|
60
|
-
} else {
|
|
61
|
-
items.push(option);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
if (((_items2 = items[items.length - 1]) === null || _items2 === void 0 ? void 0 : _items2.type) === 'section') {
|
|
67
|
-
items.pop();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return items;
|
|
71
|
-
}, [options, selectedValues]);
|
|
72
|
-
const correctOptions = useMemo(() => {
|
|
73
|
-
if (showSelectedOptions && Array.isArray(selectedValues) && selectedValues.length > 0) {
|
|
74
|
-
return selectedValuesWithSections();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (onCreate !== noop && inputRef.current && inputRef.current.value !== '') {
|
|
78
|
-
var _inputRef$current;
|
|
79
|
-
|
|
80
|
-
const creatableUuid = v4();
|
|
81
|
-
const creatableItem = {
|
|
82
|
-
dsId: "creatable-".concat(creatableUuid),
|
|
83
|
-
label: (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.value,
|
|
84
|
-
type: 'creatable'
|
|
85
|
-
};
|
|
86
|
-
return [creatableItem, ...options];
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return options;
|
|
90
|
-
}, [options, onCreate, selectedValuesWithSections, selectedValues, showSelectedOptions]); // ===========================================================================
|
|
40
|
+
const correctOptions = useCorrectOptions(propsWithDefaults, showSelectedOptions); // ===========================================================================
|
|
91
41
|
// Virtualization setup
|
|
92
42
|
// ===========================================================================
|
|
93
43
|
|
|
@@ -100,11 +50,10 @@ const useComboBox = props => {
|
|
|
100
50
|
// Scroll into view function
|
|
101
51
|
// ===========================================================================
|
|
102
52
|
|
|
103
|
-
const scrollOptionIntoView = useCallback(
|
|
104
|
-
|
|
53
|
+
const scrollOptionIntoView = useCallback(dsId => {
|
|
54
|
+
virtualListHelpers.scrollToIndex(correctOptions.findIndex(opt => opt.dsId === dsId), {
|
|
105
55
|
align: 'center'
|
|
106
|
-
};
|
|
107
|
-
virtualListHelpers.scrollToIndex(correctOptions.findIndex(opt => opt.dsId === dsId), opts);
|
|
56
|
+
});
|
|
108
57
|
}, [correctOptions, virtualListHelpers]);
|
|
109
58
|
const ctx = useMemo(() => ({
|
|
110
59
|
props: _objectSpread(_objectSpread({}, propsWithDefaults), {}, {
|
|
@@ -113,8 +62,6 @@ const useComboBox = props => {
|
|
|
113
62
|
virtualListHelpers,
|
|
114
63
|
showPopover,
|
|
115
64
|
referenceElement,
|
|
116
|
-
inputRef,
|
|
117
|
-
showSelectedValue,
|
|
118
65
|
listRef,
|
|
119
66
|
focusOptionIdx,
|
|
120
67
|
selectedOptionsRef,
|
|
@@ -129,10 +76,9 @@ const useComboBox = props => {
|
|
|
129
76
|
setHasFocus,
|
|
130
77
|
setCurrentOption,
|
|
131
78
|
scrollOptionIntoView,
|
|
132
|
-
setShowSelectedValue,
|
|
133
79
|
setReferenceElement,
|
|
134
80
|
setShowPopover
|
|
135
|
-
}), [scrollOptionIntoView, correctOptions, propsWithDefaults, virtualListHelpers, focusOptionIdx,
|
|
81
|
+
}), [scrollOptionIntoView, correctOptions, propsWithDefaults, virtualListHelpers, focusOptionIdx, wrapperListRef, showSelectedOptions, showPopover, pillGroupRef, referenceElement, selectedOptionsRef, controlsWrapperRef, selectAllCheckboxRef, toggleSelectionButtonRef, hasFocus, listRef]);
|
|
136
82
|
return ctx;
|
|
137
83
|
};
|
|
138
84
|
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.find.js';
|
|
6
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
7
|
+
import { useCallback, useMemo } from 'react';
|
|
8
|
+
import { v4 } from 'uuid';
|
|
9
|
+
import { noop } from 'lodash';
|
|
10
|
+
|
|
11
|
+
const useCorrectOptions = (propsWithDefaults, showSelectedOptions) => {
|
|
12
|
+
const {
|
|
13
|
+
options,
|
|
14
|
+
selectedValues,
|
|
15
|
+
onCreate,
|
|
16
|
+
innerRef
|
|
17
|
+
} = propsWithDefaults;
|
|
18
|
+
const selectedValuesWithSections = useCallback(() => {
|
|
19
|
+
var _items2;
|
|
20
|
+
|
|
21
|
+
const multiSelectedValue = selectedValues;
|
|
22
|
+
const items = [];
|
|
23
|
+
options.forEach(option => {
|
|
24
|
+
const isSelectedValue = multiSelectedValue.find(item => item.dsId === option.dsId);
|
|
25
|
+
|
|
26
|
+
if (isSelectedValue) {
|
|
27
|
+
items.push(option);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (option.type === 'section') {
|
|
31
|
+
var _items;
|
|
32
|
+
|
|
33
|
+
if (((_items = items[items.length - 1]) === null || _items === void 0 ? void 0 : _items.type) === 'section') {
|
|
34
|
+
items[items.length - 1] = option;
|
|
35
|
+
} else {
|
|
36
|
+
items.push(option);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (((_items2 = items[items.length - 1]) === null || _items2 === void 0 ? void 0 : _items2.type) === 'section') {
|
|
42
|
+
items.pop();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return items;
|
|
46
|
+
}, [options, selectedValues]);
|
|
47
|
+
const correctOptions = useMemo(() => {
|
|
48
|
+
if (showSelectedOptions && Array.isArray(selectedValues) && selectedValues.length > 0) {
|
|
49
|
+
return selectedValuesWithSections();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (onCreate !== noop && innerRef.current && innerRef.current.value !== '' && options.findIndex(option => {
|
|
53
|
+
var _innerRef$current;
|
|
54
|
+
|
|
55
|
+
return option.type === 'option' && option.label === (innerRef === null || innerRef === void 0 ? void 0 : (_innerRef$current = innerRef.current) === null || _innerRef$current === void 0 ? void 0 : _innerRef$current.value);
|
|
56
|
+
}) === -1) {
|
|
57
|
+
var _innerRef$current2;
|
|
58
|
+
|
|
59
|
+
const creatableUuid = v4();
|
|
60
|
+
const creatableItem = {
|
|
61
|
+
dsId: "creatable-".concat(creatableUuid),
|
|
62
|
+
label: (_innerRef$current2 = innerRef.current) === null || _innerRef$current2 === void 0 ? void 0 : _innerRef$current2.value,
|
|
63
|
+
type: 'creatable'
|
|
64
|
+
};
|
|
65
|
+
return [creatableItem, ...options];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return options;
|
|
69
|
+
}, [options, onCreate, innerRef, selectedValuesWithSections, selectedValues, showSelectedOptions]);
|
|
70
|
+
return correctOptions;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export { useCorrectOptions };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.find.js';
|
|
5
|
+
import { useContext, useMemo } from 'react';
|
|
6
|
+
import { ComboBoxContext } from '../../ComboBoxCTX.js';
|
|
7
|
+
import { StyledA11ySelectedValues } from './styled.js';
|
|
8
|
+
import { getSelectableOptions } from '../../utils/listHelper.js';
|
|
9
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
10
|
+
|
|
11
|
+
const FocusMenuItem = () => {
|
|
12
|
+
const {
|
|
13
|
+
props: {
|
|
14
|
+
options
|
|
15
|
+
},
|
|
16
|
+
focusOptionIdx,
|
|
17
|
+
showPopover
|
|
18
|
+
} = useContext(ComboBoxContext);
|
|
19
|
+
const selectabledOptions = getSelectableOptions(options);
|
|
20
|
+
const focusOption = options.find(option => option.dsId === focusOptionIdx);
|
|
21
|
+
const focusSelectableOptionIdx = selectabledOptions.findIndex(option => option.dsId === focusOptionIdx);
|
|
22
|
+
const msg = useMemo(() => {
|
|
23
|
+
if (showPopover) {
|
|
24
|
+
return /*#__PURE__*/_jsx(StyledA11ySelectedValues, {
|
|
25
|
+
"aria-live": "polite",
|
|
26
|
+
"aria-atomic": "false",
|
|
27
|
+
"aria-relevant": "additions text"
|
|
28
|
+
}, void 0, "option ".concat(focusOption === null || focusOption === void 0 ? void 0 : focusOption.label, " focused.").concat(focusSelectableOptionIdx + 1, " of ").concat(selectabledOptions.length, " "));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return /*#__PURE__*/jsx(Fragment, {});
|
|
32
|
+
}, [showPopover, focusOption, focusSelectableOptionIdx, selectabledOptions]);
|
|
33
|
+
return /*#__PURE__*/jsx(Fragment, {
|
|
34
|
+
children: msg
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { FocusMenuItem };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
4
|
+
import { useContext, useMemo } from 'react';
|
|
5
|
+
import { ComboBoxContext } from '../../ComboBoxCTX.js';
|
|
6
|
+
import { StyledA11ySelectedValues } from './styled.js';
|
|
7
|
+
import { ComboboxDataTestid } from '../../ComboboxDataTestids.js';
|
|
8
|
+
|
|
9
|
+
const SelectedValuesAllyMsg = () => {
|
|
10
|
+
const {
|
|
11
|
+
props: {
|
|
12
|
+
selectedValues
|
|
13
|
+
}
|
|
14
|
+
} = useContext(ComboBoxContext);
|
|
15
|
+
const msg = useMemo(() => {
|
|
16
|
+
if (Array.isArray(selectedValues)) {
|
|
17
|
+
if (selectedValues.length > 0) {
|
|
18
|
+
return "Options selected: ".concat(selectedValues.map(item => item.label).join(', '));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return 'No Options Selected';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (selectedValues) {
|
|
25
|
+
return "Option selected: ".concat(selectedValues === null || selectedValues === void 0 ? void 0 : selectedValues.label);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return 'No Option Selected';
|
|
29
|
+
}, [selectedValues]);
|
|
30
|
+
return /*#__PURE__*/_jsx(StyledA11ySelectedValues, {
|
|
31
|
+
id: "combobox-selected-items",
|
|
32
|
+
"data-testid": ComboboxDataTestid.ALLY_SELECTED_VALUES,
|
|
33
|
+
"aria-live": "polite",
|
|
34
|
+
"aria-atomic": "false",
|
|
35
|
+
"aria-relevant": "additions text"
|
|
36
|
+
}, void 0, msg);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export { SelectedValuesAllyMsg };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { SelectedValuesAllyMsg } from './SelectedValuesAllyMsg.js';
|
|
2
|
+
export { FocusMenuItem } from './FocusMenuItem.js';
|