@elliemae/ds-controlled-form 2.4.2-rc.0 → 2.4.2-rc.1
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/autocomplete/config/useAutocomplete.js +1 -3
- package/cjs/checkbox/ControlledCheckbox.js +49 -33
- package/cjs/checkbox/exported-related/data-test-ids.js +10 -0
- package/cjs/checkbox/exported-related/index.js +12 -0
- package/cjs/checkbox/exported-related/theming.js +13 -0
- package/cjs/checkbox/react-desc-prop-types.js +0 -1
- package/cjs/checkbox/styles.js +26 -15
- package/cjs/combobox/ComboBoxCTX.js +1 -1
- package/cjs/combobox/ComboboxDataTestids.js +1 -1
- package/cjs/combobox/config/useComboBox.js +6 -4
- package/cjs/combobox/index.js +5 -0
- package/cjs/combobox/parts/DropdownIndicator.js +2 -2
- package/cjs/combobox/parts/container/Container.js +5 -5
- package/cjs/combobox/parts/container/styled.js +13 -7
- package/cjs/combobox/parts/controls/Controls.js +14 -4
- package/cjs/combobox/parts/controls/styled.js +22 -13
- package/cjs/combobox/parts/controls-input/ControlsInput.js +1 -1
- package/cjs/combobox/parts/controls-input/styled.js +7 -3
- package/cjs/combobox/parts/controls-input/useControlsInput.js +3 -4
- package/cjs/combobox/parts/controls-input/useKeyboardNavigation.js +30 -15
- package/cjs/combobox/parts/header-list/HeaderList.js +4 -3
- package/cjs/combobox/parts/header-list/useHeaderListHandlers.js +9 -5
- package/cjs/combobox/parts/menu-list/MenuList.js +5 -2
- package/cjs/combobox/parts/menu-list/styled.js +12 -7
- package/cjs/combobox/parts/menu-list/useItemRenderer.js +5 -4
- package/cjs/combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +1 -1
- package/cjs/combobox/parts/multi-selected-values-container/RemovableSelectedValuePill.js +2 -0
- package/cjs/combobox/parts/multi-selected-values-container/useGroupPills.js +13 -10
- package/cjs/combobox/theming.js +13 -0
- package/cjs/combobox/utils/listHelper.js +2 -1
- package/cjs/index.js +16 -7
- package/cjs/input-group/InputGroup.js +69 -0
- package/cjs/input-group/InputGroupDataTestIds.js +12 -0
- package/cjs/input-group/index.js +12 -0
- package/cjs/input-group/react-desc-prop-types.js +14 -0
- package/cjs/input-group/styled.js +46 -0
- package/cjs/mask-hook/hooks/index.js +0 -1
- package/cjs/mask-hook/hooks/usePhoneMask.js +2 -2
- package/cjs/mask-hook/hooks/useRegExpMask.js +0 -1
- package/cjs/mask-hook/index.js +0 -1
- package/cjs/text-input/styled/borders.js +1 -1
- package/esm/autocomplete/config/useAutocomplete.js +1 -3
- package/esm/checkbox/ControlledCheckbox.js +52 -36
- package/esm/checkbox/exported-related/data-test-ids.js +6 -0
- package/esm/checkbox/exported-related/index.js +2 -0
- package/esm/checkbox/exported-related/theming.js +8 -0
- package/esm/checkbox/react-desc-prop-types.js +0 -1
- package/esm/checkbox/styles.js +25 -15
- package/esm/combobox/ComboBoxCTX.js +1 -1
- package/esm/combobox/ComboboxDataTestids.js +1 -1
- package/esm/combobox/config/useComboBox.js +6 -4
- package/esm/combobox/index.js +2 -0
- package/esm/combobox/parts/DropdownIndicator.js +2 -2
- package/esm/combobox/parts/container/Container.js +7 -7
- package/esm/combobox/parts/container/styled.js +13 -6
- package/esm/combobox/parts/controls/Controls.js +14 -4
- package/esm/combobox/parts/controls/styled.js +22 -13
- package/esm/combobox/parts/controls-input/ControlsInput.js +1 -1
- package/esm/combobox/parts/controls-input/styled.js +7 -3
- package/esm/combobox/parts/controls-input/useControlsInput.js +3 -4
- package/esm/combobox/parts/controls-input/useKeyboardNavigation.js +30 -15
- package/esm/combobox/parts/header-list/HeaderList.js +4 -3
- package/esm/combobox/parts/header-list/useHeaderListHandlers.js +9 -5
- package/esm/combobox/parts/menu-list/MenuList.js +5 -2
- package/esm/combobox/parts/menu-list/styled.js +12 -7
- package/esm/combobox/parts/menu-list/useItemRenderer.js +5 -4
- package/esm/combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +1 -1
- package/esm/combobox/parts/multi-selected-values-container/RemovableSelectedValuePill.js +2 -0
- package/esm/combobox/parts/multi-selected-values-container/useGroupPills.js +13 -10
- package/esm/combobox/theming.js +8 -0
- package/esm/combobox/utils/listHelper.js +2 -1
- package/esm/index.js +5 -1
- package/esm/input-group/InputGroup.js +59 -0
- package/esm/input-group/InputGroupDataTestIds.js +8 -0
- package/esm/input-group/index.js +2 -0
- package/esm/input-group/react-desc-prop-types.js +10 -0
- package/esm/input-group/styled.js +35 -0
- package/esm/mask-hook/hooks/index.js +1 -1
- package/esm/mask-hook/hooks/usePhoneMask.js +2 -2
- package/esm/mask-hook/hooks/useRegExpMask.js +1 -1
- package/esm/mask-hook/index.js +1 -1
- package/esm/text-input/styled/borders.js +1 -1
- package/package.json +51 -19
- package/types/checkbox/exported-related/data-test-ids.d.ts +4 -0
- package/types/checkbox/exported-related/index.d.ts +2 -0
- package/types/checkbox/exported-related/theming.d.ts +6 -0
- package/types/checkbox/react-desc-prop-types.d.ts +3 -3
- package/types/checkbox/styles.d.ts +5 -5
- package/types/combobox/ComboboxDataTestids.d.ts +1 -1
- package/types/combobox/index.d.ts +2 -0
- package/types/combobox/parts/container/styled.d.ts +1 -2
- package/types/combobox/theming.d.ts +6 -0
- package/types/index.d.ts +1 -0
- package/types/input-group/InputGroup.d.ts +5 -0
- package/types/input-group/InputGroupDataTestIds.d.ts +6 -0
- package/types/input-group/index.d.ts +2 -0
- package/types/input-group/react-desc-prop-types.d.ts +19 -0
- package/types/input-group/styled.d.ts +7 -0
- package/types/input-group/tests/DSInputGroup.test.d.ts +1 -0
- package/types/mask-hook/hooks/useRegExpMask.d.ts +0 -1
- package/types/text-input/config/useInputText.d.ts +5 -5
- package/cjs/combobox/parts/menu-list/useMenuListSetFocusOption.js +0 -51
- package/esm/combobox/parts/menu-list/useMenuListSetFocusOption.js +0 -47
- package/types/combobox/parts/menu-list/useMenuListSetFocusOption.d.ts +0 -1
|
@@ -27,7 +27,6 @@ const useAutocomplete = props => {
|
|
|
27
27
|
const [focusOptionIdx, setCurrentOption] = useState('');
|
|
28
28
|
const inputRef = useRef(null);
|
|
29
29
|
const listRef = useRef(null);
|
|
30
|
-
const selectedOptionsRef = useRef(null);
|
|
31
30
|
const {
|
|
32
31
|
options,
|
|
33
32
|
filter
|
|
@@ -66,12 +65,11 @@ const useAutocomplete = props => {
|
|
|
66
65
|
inputRef,
|
|
67
66
|
listRef,
|
|
68
67
|
focusOptionIdx,
|
|
69
|
-
selectedOptionsRef,
|
|
70
68
|
setCurrentOption,
|
|
71
69
|
scrollOptionIntoView,
|
|
72
70
|
setReferenceElement,
|
|
73
71
|
setShowPopover
|
|
74
|
-
}), [scrollOptionIntoView, propsWithDefault, virtualListHelpers, focusOptionIdx, showPopover, referenceElement, inputRef,
|
|
72
|
+
}), [scrollOptionIntoView, propsWithDefault, virtualListHelpers, focusOptionIdx, showPopover, referenceElement, inputRef, listRef]);
|
|
75
73
|
return ctx;
|
|
76
74
|
};
|
|
77
75
|
|
|
@@ -7,15 +7,15 @@ import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
|
7
7
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
8
8
|
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
9
9
|
import { useRef, useCallback } from 'react';
|
|
10
|
-
import { describe, useMemoMergePropsWithDefault, useGetGlobalAttributes } from '@elliemae/ds-props-helpers';
|
|
10
|
+
import { describe, useMemoMergePropsWithDefault, useGetGlobalAttributes, useGetXstyledProps } from '@elliemae/ds-props-helpers';
|
|
11
11
|
import { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';
|
|
12
|
-
import { StyledContainer, StyledCheckBox, StyledInput, StyledLabel } from './styles.js';
|
|
12
|
+
import { StyledContainer, StyledCheckBox, StyledInputMixed, StyledInput, StyledLabel } from './styles.js';
|
|
13
13
|
import { propTypes, defaultProps } from './react-desc-prop-types.js';
|
|
14
14
|
import { setMultipleRefs } from './utils/setMultipleRefs.js';
|
|
15
15
|
import { useValidateProps } from './config/useValidateProps.js';
|
|
16
|
-
import { jsx } from 'react/jsx-runtime';
|
|
16
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
17
17
|
|
|
18
|
-
const _excluded = ["id", "disabled", "readOnly", "label", "aria-label", "aria-controls", "onKeyDown", "className"];
|
|
18
|
+
const _excluded = ["id", "disabled", "readOnly", "label", "aria-label", "aria-controls", "onKeyDown", "className", "onChange"];
|
|
19
19
|
|
|
20
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
21
|
|
|
@@ -31,10 +31,8 @@ const DSControlledCheckbox = props => {
|
|
|
31
31
|
hasError,
|
|
32
32
|
innerRef,
|
|
33
33
|
wrapLabel,
|
|
34
|
-
tabIndex,
|
|
35
34
|
ariaLabel: legacyAriaLabel,
|
|
36
|
-
ariaControls: legacyAriaControls
|
|
37
|
-
'data-testid': dataTestid = 'ds-checkbox-container'
|
|
35
|
+
ariaControls: legacyAriaControls
|
|
38
36
|
} = propsWithDefault;
|
|
39
37
|
|
|
40
38
|
const _useGetGlobalAttribut = useGetGlobalAttributes(propsWithDefault),
|
|
@@ -46,10 +44,12 @@ const DSControlledCheckbox = props => {
|
|
|
46
44
|
'aria-label': ariaLabel,
|
|
47
45
|
'aria-controls': ariaControls,
|
|
48
46
|
onKeyDown: userOnKeyDown,
|
|
49
|
-
className
|
|
47
|
+
className,
|
|
48
|
+
onChange
|
|
50
49
|
} = _useGetGlobalAttribut,
|
|
51
50
|
restGlobals = _objectWithoutProperties(_useGetGlobalAttribut, _excluded);
|
|
52
51
|
|
|
52
|
+
const xstyledProps = useGetXstyledProps(propsWithDefault);
|
|
53
53
|
const handleOnKeyDown = useCallback(e => {
|
|
54
54
|
if (checkboxRef.current && e.key === 'Enter') {
|
|
55
55
|
checkboxRef.current.click();
|
|
@@ -57,35 +57,51 @@ const DSControlledCheckbox = props => {
|
|
|
57
57
|
|
|
58
58
|
if (userOnKeyDown) userOnKeyDown(e);
|
|
59
59
|
}, [userOnKeyDown]);
|
|
60
|
-
return /*#__PURE__*/
|
|
61
|
-
"data-testid":
|
|
60
|
+
return /*#__PURE__*/jsxs(StyledContainer, _objectSpread(_objectSpread({
|
|
61
|
+
"data-testid": "ds-checkbox-container",
|
|
62
62
|
className: className
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
63
|
+
}, xstyledProps), {}, {
|
|
64
|
+
children: [/*#__PURE__*/_jsx(StyledCheckBox, {
|
|
65
|
+
checked: checked,
|
|
66
|
+
hasError: hasError,
|
|
67
|
+
disabled: disabled,
|
|
68
|
+
readOnly: readOnly
|
|
69
|
+
}, void 0, ariaControls || legacyAriaControls ? /*#__PURE__*/jsx(StyledInputMixed, _objectSpread(_objectSpread({
|
|
70
|
+
role: "checkbox",
|
|
71
|
+
"data-testid": "ds-checkbox",
|
|
72
|
+
id: id,
|
|
73
|
+
ref: ref => setMultipleRefs([checkboxRef, innerRef])(ref),
|
|
74
|
+
onKeyDown: handleOnKeyDown,
|
|
75
|
+
"aria-label": ariaLabel || legacyAriaLabel || label,
|
|
76
|
+
"aria-controls": ariaControls || legacyAriaControls,
|
|
77
|
+
disabled: disabled,
|
|
78
|
+
readOnly: readOnly,
|
|
79
|
+
onClick: onChange,
|
|
80
|
+
"aria-checked": checked
|
|
81
|
+
}, restGlobals), {}, {
|
|
82
|
+
tabIndex: 0
|
|
83
|
+
})) : /*#__PURE__*/jsx(StyledInput, _objectSpread({
|
|
84
|
+
"data-testid": "ds-checkbox",
|
|
85
|
+
id: id,
|
|
86
|
+
ref: ref => setMultipleRefs([checkboxRef, innerRef])(ref),
|
|
87
|
+
onKeyDown: handleOnKeyDown,
|
|
88
|
+
type: "checkbox",
|
|
89
|
+
checked: checked,
|
|
90
|
+
"aria-label": ariaLabel || legacyAriaLabel || label,
|
|
91
|
+
disabled: disabled,
|
|
92
|
+
readOnly: readOnly,
|
|
93
|
+
onChange: onChange
|
|
94
|
+
}, restGlobals))), label && /*#__PURE__*/_jsx(StyledLabel, {
|
|
95
|
+
htmlFor: id,
|
|
96
|
+
disabled: disabled,
|
|
97
|
+
readOnly: readOnly,
|
|
98
|
+
checked: checked,
|
|
99
|
+
"data-testid": "ds-checkbox-label",
|
|
100
|
+
wrapLabel: wrapLabel
|
|
101
|
+
}, void 0, wrapLabel ? label : /*#__PURE__*/_jsx(SimpleTruncatedTooltipText, {
|
|
102
|
+
value: label
|
|
103
|
+
}))]
|
|
104
|
+
}));
|
|
89
105
|
};
|
|
90
106
|
|
|
91
107
|
const DSControlledCheckboxWithSchema = describe(DSControlledCheckbox);
|
|
@@ -17,7 +17,6 @@ const defaultProps = {
|
|
|
17
17
|
};
|
|
18
18
|
const propTypes = _objectSpread(_objectSpread({}, globalAttributesPropTypes), {}, {
|
|
19
19
|
label: PropTypes.string.description('Checkbox Label property. This label is also going to be used as an aria-label for screen readers.'),
|
|
20
|
-
wrapLabel: PropTypes.bool.description('Whether to wrap or truncate label'),
|
|
21
20
|
hasError: PropTypes.bool.description('Whether the checkbox has error or not.'),
|
|
22
21
|
innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description('Checkbox input ref.')
|
|
23
22
|
});
|
package/esm/checkbox/styles.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
|
|
2
|
+
import { styled, css } from '@elliemae/ds-system';
|
|
2
3
|
import { handleBackgroundColor, handleCheckmark } from './utils/styleHelpers.js';
|
|
4
|
+
import { DSCheckboxName, DSCheckboxSlots } from './exported-related/theming.js';
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
7
|
+
const StyledContainer = styled('div', {
|
|
8
|
+
name: DSCheckboxName,
|
|
9
|
+
slot: DSCheckboxSlots.CONTAINER
|
|
10
|
+
})(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-grid;\n grid-template-rows: min-content;\n grid-template-columns: ", " auto;\n align-items: center;\n"])), _ref => {
|
|
7
11
|
let {
|
|
8
12
|
theme
|
|
9
13
|
} = _ref;
|
|
10
14
|
return theme.space.xs;
|
|
11
15
|
});
|
|
12
|
-
const StyledCheckBox =
|
|
13
|
-
componentId: "sc-flv7d2-1"
|
|
14
|
-
})(["width:", ";height:", ";border:1px solid ", ";border-radius:2px;position:relative;background:", ";", " &:focus-within{", ";&:hover{", "}}&:hover{background:", ";", ";}"], _ref2 => {
|
|
16
|
+
const StyledCheckBox = styled('span')(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: ", ";\n height: ", ";\n border: 1px solid ", ";\n border-radius: 2px;\n position: relative;\n background: ", ";\n ", "\n &:focus-within {\n ", ";\n &:hover {\n ", "\n }\n }\n &:hover {\n background: ", ";\n ", ";\n }\n"])), _ref2 => {
|
|
15
17
|
let {
|
|
16
18
|
theme
|
|
17
19
|
} = _ref2;
|
|
@@ -74,16 +76,24 @@ const StyledCheckBox = /*#__PURE__*/styled.span.withConfig({
|
|
|
74
76
|
} = _ref10;
|
|
75
77
|
return !hasError && !disabled && !readOnly ? " border: 1px solid ".concat(theme.colors.brand[600]) : undefined;
|
|
76
78
|
});
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
const checkboxStyles = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n &:hover {\n cursor: pointer;\n }\n &:disabled {\n cursor: not-allowed;\n }\n width: 100%;\n height: 100%;\n position: absolute;\n top: 0;\n left: 0;\n opacity: 0;\n"])));
|
|
80
|
+
const StyledInput = styled('input', {
|
|
81
|
+
name: DSCheckboxName,
|
|
82
|
+
slot: DSCheckboxSlots.INPUT
|
|
83
|
+
})(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", "\n"])), checkboxStyles);
|
|
84
|
+
const StyledInputMixed = styled('div', {
|
|
85
|
+
name: DSCheckboxName,
|
|
86
|
+
slot: DSCheckboxSlots.INPUT
|
|
87
|
+
})(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n ", "\n"])), checkboxStyles);
|
|
88
|
+
const StyledLabel = styled('label', {
|
|
89
|
+
name: DSCheckboxName,
|
|
90
|
+
slot: DSCheckboxSlots.LABEL
|
|
91
|
+
})(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n &:hover {\n cursor: pointer;\n }\n ", ";\n\n color: ", ";\n font-size: 13px;\n line-height: 13px;\n display: inherit;\n"])), _ref11 => {
|
|
83
92
|
let {
|
|
93
|
+
wrapLabel,
|
|
84
94
|
theme
|
|
85
95
|
} = _ref11;
|
|
86
|
-
return theme.space.xxs;
|
|
96
|
+
return wrapLabel ? 'padding: 8px' : "padding-left: ".concat(theme.space.xxs);
|
|
87
97
|
}, _ref12 => {
|
|
88
98
|
let {
|
|
89
99
|
theme,
|
|
@@ -94,4 +104,4 @@ const StyledLabel = /*#__PURE__*/styled.label.withConfig({
|
|
|
94
104
|
return disabled && checked !== true || readOnly ? theme.colors.neutral[500] : theme.colors.neutral[800];
|
|
95
105
|
});
|
|
96
106
|
|
|
97
|
-
export { StyledCheckBox, StyledContainer, StyledInput, StyledLabel };
|
|
107
|
+
export { StyledCheckBox, StyledContainer, StyledInput, StyledInputMixed, StyledLabel };
|
|
@@ -66,17 +66,19 @@ const useComboBox = props => {
|
|
|
66
66
|
|
|
67
67
|
const [focusOptionIdx, setFocusOptionIdx] = useState('');
|
|
68
68
|
useEffect(() => {
|
|
69
|
-
//
|
|
70
|
-
//
|
|
69
|
+
// this code calculate the option to be focused when opening the menu
|
|
70
|
+
// when losing focus we remove the focused one
|
|
71
|
+
// when focus adquired again getFirstOption calculate the correct one
|
|
72
|
+
if (!hasFocus) setFocusOptionIdx('');
|
|
73
|
+
|
|
71
74
|
if (hasFocus && (focusOptionIdx === '' || inputValue !== '' || showSelectedOptions)) {
|
|
72
75
|
const focusedValue = getFirstOption(correctOptions, selectedValues, inputValue);
|
|
73
76
|
setFocusOptionIdx(focusedValue);
|
|
74
77
|
scrollOptionIntoView(focusedValue, {
|
|
75
78
|
align: 'center'
|
|
76
79
|
});
|
|
77
|
-
}
|
|
80
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78
81
|
|
|
79
|
-
if (!hasFocus) setFocusOptionIdx(''); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80
82
|
}, [showPopover, hasFocus, correctOptions, selectedValues, inputValue]);
|
|
81
83
|
useEffect(() => {
|
|
82
84
|
if (!showPopover) {
|
package/esm/combobox/index.js
CHANGED
|
@@ -8,12 +8,12 @@ import { ComboBoxContext } from '../ComboBoxCTX.js';
|
|
|
8
8
|
import { ComboboxDataTestid } from '../ComboboxDataTestids.js';
|
|
9
9
|
|
|
10
10
|
var _templateObject;
|
|
11
|
-
const StyledDropDownButton = styled(DSButtonV2)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &:focus::after {\n border: none;\n }\n & svg {\n fill: ", ";\n }\n"])), _ref => {
|
|
11
|
+
const StyledDropDownButton = styled(DSButtonV2)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &:focus::after {\n border: none;\n }\n &:hover:not(:disabled) {\n background-color: transparent;\n }\n\n & svg {\n fill: ", ";\n }\n"])), _ref => {
|
|
12
12
|
let {
|
|
13
13
|
theme,
|
|
14
14
|
disabled
|
|
15
15
|
} = _ref;
|
|
16
|
-
return disabled ? '
|
|
16
|
+
return disabled ? theme.colors.neutral['400'] : theme.colors.brand['700'];
|
|
17
17
|
});
|
|
18
18
|
const DropdownIndicator = () => {
|
|
19
19
|
const {
|
|
@@ -7,10 +7,10 @@ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
|
7
7
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
8
8
|
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
9
9
|
import { useContext, useCallback, useEffect, useMemo } from 'react';
|
|
10
|
-
import { useGetGlobalAttributes } from '@elliemae/ds-props-helpers';
|
|
10
|
+
import { useGetGlobalAttributes, useGetXstyledProps } from '@elliemae/ds-props-helpers';
|
|
11
11
|
import { DSPopperJS } from '@elliemae/ds-popperjs';
|
|
12
12
|
import { ComboBoxContext } from '../../ComboBoxCTX.js';
|
|
13
|
-
import {
|
|
13
|
+
import { StyledContainer, StyledPopperWrapper } from './styled.js';
|
|
14
14
|
import { Controls } from '../controls/Controls.js';
|
|
15
15
|
import { MenuList } from '../menu-list/MenuList.js';
|
|
16
16
|
import { ComboboxDataTestid } from '../../ComboboxDataTestids.js';
|
|
@@ -43,8 +43,8 @@ const Container = () => {
|
|
|
43
43
|
withoutPortal,
|
|
44
44
|
zIndex
|
|
45
45
|
} = props;
|
|
46
|
-
const
|
|
47
|
-
const
|
|
46
|
+
const globalAttributes = useGetGlobalAttributes(props);
|
|
47
|
+
const xStyledProps = useGetXstyledProps(props); // Removing possible collisionable props
|
|
48
48
|
|
|
49
49
|
const globalsAttrs = _objectWithoutProperties(globalAttributes, _excluded);
|
|
50
50
|
|
|
@@ -66,10 +66,10 @@ const Container = () => {
|
|
|
66
66
|
useEffect(() => {
|
|
67
67
|
if (onMenuOpen && showPopover) onMenuOpen();else if (onMenuClose && !showPopover) onMenuClose();
|
|
68
68
|
}, [showPopover, onMenuOpen, onMenuClose]);
|
|
69
|
-
return useMemo(() => /*#__PURE__*/jsx(StyledContainer, _objectSpread(_objectSpread({
|
|
69
|
+
return useMemo(() => /*#__PURE__*/jsx(StyledContainer, _objectSpread(_objectSpread(_objectSpread({
|
|
70
70
|
"data-testid": ComboboxDataTestid.CONTAINER,
|
|
71
71
|
ref: setReferenceElement
|
|
72
|
-
}, globalsAttrs), {}, {
|
|
72
|
+
}, globalsAttrs), xStyledProps), {}, {
|
|
73
73
|
children: inline ? /*#__PURE__*/jsxs(Fragment, {
|
|
74
74
|
children: [_Controls || (_Controls = /*#__PURE__*/_jsx(Controls, {})), _MenuList || (_MenuList = /*#__PURE__*/_jsx(MenuList, {}))]
|
|
75
75
|
}) : /*#__PURE__*/jsxs(Fragment, {
|
|
@@ -89,7 +89,7 @@ const Container = () => {
|
|
|
89
89
|
onMouseDown: handleMouseDown
|
|
90
90
|
}, void 0, _MenuList2 || (_MenuList2 = /*#__PURE__*/_jsx(MenuList, {})))))]
|
|
91
91
|
})
|
|
92
|
-
})), [inline,
|
|
92
|
+
})), [inline, setReferenceElement, globalsAttrs, referenceElement, showPopover, xStyledProps, handleCloseMenu, startPlacementPreference, placementOrderPreference, withoutPortal, zIndex, handleMouseDown]);
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
export { Container };
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
|
|
2
2
|
import { styled } from '@elliemae/ds-system';
|
|
3
|
+
import { DSComboBoxName, DSComboboxSlots } from '../../theming.js';
|
|
3
4
|
|
|
4
|
-
var _templateObject, _templateObject2
|
|
5
|
-
const
|
|
5
|
+
var _templateObject, _templateObject2;
|
|
6
|
+
const StyledContainer = styled('div', {
|
|
7
|
+
name: DSComboBoxName,
|
|
8
|
+
slot: DSComboboxSlots.CONTAINER
|
|
9
|
+
})(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n cursor: ", ";\n"])), _ref => {
|
|
6
10
|
let {
|
|
7
11
|
disabled
|
|
8
12
|
} = _ref;
|
|
9
13
|
return disabled ? 'not-allowed' : 'default';
|
|
10
14
|
});
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
const StyledPopperWrapper = styled('div')(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n cursor: ", ";\n overflow: auto;\n"])), _ref2 => {
|
|
16
|
+
let {
|
|
17
|
+
disabled
|
|
18
|
+
} = _ref2;
|
|
19
|
+
return disabled ? 'not-allowed' : 'default';
|
|
20
|
+
});
|
|
14
21
|
|
|
15
|
-
export {
|
|
22
|
+
export { StyledContainer, StyledPopperWrapper };
|
|
@@ -25,9 +25,10 @@ const Controls = () => {
|
|
|
25
25
|
},
|
|
26
26
|
selectedOptionsRef,
|
|
27
27
|
setShowPopover,
|
|
28
|
+
setFocusOptionIdx,
|
|
28
29
|
hasFocus,
|
|
30
|
+
listRef,
|
|
29
31
|
focusOptionIdx,
|
|
30
|
-
scrollOptionIntoView,
|
|
31
32
|
showPopover,
|
|
32
33
|
controlsWrapperRef
|
|
33
34
|
} = useContext(ComboBoxContext);
|
|
@@ -40,13 +41,22 @@ const Controls = () => {
|
|
|
40
41
|
var _innerRef$current;
|
|
41
42
|
|
|
42
43
|
setShowPopover(false);
|
|
44
|
+
setFocusOptionIdx('');
|
|
43
45
|
(_innerRef$current = innerRef.current) === null || _innerRef$current === void 0 ? void 0 : _innerRef$current.blur();
|
|
44
46
|
return;
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
(_innerRef$current2 = innerRef.current) === null || _innerRef$current2 === void 0 ? void 0 : _innerRef$current2.focus();
|
|
48
|
-
setShowPopover(true);
|
|
49
|
-
|
|
50
|
+
setShowPopover(true);
|
|
51
|
+
window.requestAnimationFrame(() => {
|
|
52
|
+
if (listRef.current && window.scrollY < listRef.current.scrollHeight) {
|
|
53
|
+
window.scrollTo({
|
|
54
|
+
top: listRef.current.scrollHeight,
|
|
55
|
+
behavior: 'smooth'
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
59
|
+
}, [disabled, listRef, hasFocus, showPopover, inline, innerRef, setShowPopover, focusOptionIdx]); // this callback prevent to toggle the menu when clicking or removing pills
|
|
50
60
|
|
|
51
61
|
const handleOnPillsClick = useCallback(e => {
|
|
52
62
|
if (showPopover || disabled) {
|
|
@@ -89,7 +99,7 @@ const Controls = () => {
|
|
|
89
99
|
}))]
|
|
90
100
|
}), _ControlsInput || (_ControlsInput = /*#__PURE__*/_jsx(ControlsInput, {})), !inline && /*#__PURE__*/_jsx(StyledHeaderActionsWrapper, {
|
|
91
101
|
justifyContent: "center",
|
|
92
|
-
cols: ['
|
|
102
|
+
cols: ['min-content', 'min-content']
|
|
93
103
|
}, void 0, /*#__PURE__*/_jsx(StyleHeaderActionsSeparator, {
|
|
94
104
|
disabled: disabled
|
|
95
105
|
}), _DropdownIndicator || (_DropdownIndicator = /*#__PURE__*/_jsx(DropdownIndicator, {})))]
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
|
|
2
2
|
import { css, styled } from '@elliemae/ds-system';
|
|
3
3
|
import { Grid } from '@elliemae/ds-grid';
|
|
4
|
+
import { DSComboBoxName, DSComboboxSlots } from '../../theming.js';
|
|
4
5
|
|
|
5
6
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
|
|
6
7
|
const normalBorder = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n border: 1px solid ", ";\n"])), _ref => {
|
|
@@ -10,39 +11,47 @@ const normalBorder = css(_templateObject || (_templateObject = _taggedTemplateLi
|
|
|
10
11
|
} = _ref;
|
|
11
12
|
return hasError ? theme.colors.danger[900] : theme.colors.neutral[400];
|
|
12
13
|
});
|
|
13
|
-
const focusBorder = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n
|
|
14
|
+
const focusBorder = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n outline: 2px solid ", ";\n outline-offset: -2px;\n"])), _ref2 => {
|
|
14
15
|
let {
|
|
15
16
|
theme
|
|
16
17
|
} = _ref2;
|
|
17
18
|
return theme.colors.brand[700];
|
|
18
19
|
});
|
|
19
|
-
const
|
|
20
|
-
const StyledControlsWrapper = styled(Grid)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n background: ", ";\n position: relative;\n border-radius: 2px;\n min-width: ", ";\n align-items: center;\n align-content: center;\n height: 28px;\n padding-left: 8px;\n margin: ", ";\n &::after {\n ", "\n ", "\n }\n\n &:focus-within {\n &::after {\n ", "\n ", "\n }\n }\n"])), _ref3 => {
|
|
20
|
+
const hoverBorder = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n border: 1px solid ", ";\n"])), _ref3 => {
|
|
21
21
|
let {
|
|
22
|
-
disabled,
|
|
23
22
|
theme
|
|
24
23
|
} = _ref3;
|
|
24
|
+
return theme.colors.brand[700];
|
|
25
|
+
});
|
|
26
|
+
const StyledControlsWrapper = styled(Grid, {
|
|
27
|
+
name: DSComboBoxName,
|
|
28
|
+
slot: DSComboboxSlots.INPUT_WRAPPER
|
|
29
|
+
})(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n background: ", ";\n position: relative;\n border-radius: 2px;\n min-width: ", ";\n align-items: center;\n align-content: center;\n height: 28px;\n padding-left: 8px;\n margin: ", ";\n ", "\n &:hover {\n ", "\n }\n &:focus-within {\n ", "\n }\n"])), _ref4 => {
|
|
30
|
+
let {
|
|
31
|
+
disabled,
|
|
32
|
+
theme
|
|
33
|
+
} = _ref4;
|
|
25
34
|
return disabled ? theme.colors.neutral['080'] : '#ffffff';
|
|
26
|
-
},
|
|
35
|
+
}, _ref5 => {
|
|
27
36
|
let {
|
|
28
37
|
minWidth,
|
|
29
38
|
inline
|
|
30
|
-
} =
|
|
39
|
+
} = _ref5;
|
|
31
40
|
return inline || !minWidth ? '' : "".concat(minWidth, "px");
|
|
32
|
-
},
|
|
41
|
+
}, _ref6 => {
|
|
33
42
|
let {
|
|
34
43
|
inline
|
|
35
|
-
} =
|
|
36
|
-
return inline ? '10px 16px' : '
|
|
37
|
-
},
|
|
38
|
-
const StyledSelection = styled.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n font-size: 13px;\n margin-right: 3px;\n
|
|
44
|
+
} = _ref6;
|
|
45
|
+
return inline ? '10px 16px' : '';
|
|
46
|
+
}, normalBorder, hoverBorder, focusBorder);
|
|
47
|
+
const StyledSelection = styled.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n font-size: 13px;\n margin-right: 3px;\n display: flex;\n"])));
|
|
39
48
|
const StyledHeaderActionsWrapper = styled(Grid)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n height: 100%;\n .em-ds-button--text:focus::after {\n border: none;\n }\n"])));
|
|
40
49
|
const StyleDropdownIndicator = styled.div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral([""])));
|
|
41
|
-
const StyleHeaderActionsSeparator = styled.span(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n align-self: stretch;\n margin: 4px 0px;\n width: 1px;\n background-color: ", ";\n"])),
|
|
50
|
+
const StyleHeaderActionsSeparator = styled.span(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n align-self: stretch;\n margin: 4px 0px;\n width: 1px;\n background-color: ", ";\n"])), _ref7 => {
|
|
42
51
|
let {
|
|
43
52
|
theme,
|
|
44
53
|
disabled
|
|
45
|
-
} =
|
|
54
|
+
} = _ref7;
|
|
46
55
|
return disabled ? theme.colors.neutral['400'] : theme.colors.neutral['500'];
|
|
47
56
|
});
|
|
48
57
|
|
|
@@ -45,7 +45,7 @@ const ControlsInput = () => {
|
|
|
45
45
|
"aria-controls": "combo-listbox",
|
|
46
46
|
"aria-activedescendant": focusOptionIdx,
|
|
47
47
|
"aria-expanded": showPopover,
|
|
48
|
-
"aria-haspopup": "
|
|
48
|
+
"aria-haspopup": "listbox",
|
|
49
49
|
"aria-describedby": "combobox-selected-items",
|
|
50
50
|
role: "combobox",
|
|
51
51
|
disabled: disabled,
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
|
|
2
2
|
import { styled } from '@elliemae/ds-system';
|
|
3
|
+
import { DSComboBoxName, DSComboboxSlots } from '../../theming.js';
|
|
3
4
|
|
|
4
5
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
5
|
-
const StyledInput = styled
|
|
6
|
+
const StyledInput = styled('input', {
|
|
7
|
+
name: DSComboBoxName,
|
|
8
|
+
slot: DSComboboxSlots.INPUT
|
|
9
|
+
})(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n font-size: 13px;\n line-height: 13px;\n border: none;\n padding: 0;\n outline: none;\n color: ", ";\n &:focus {\n outline: none;\n }\n ", "\n &::placeholder {\n color: transparent;\n }\n"])), props => props.theme.colors.neutral[700], _ref => {
|
|
6
10
|
let {
|
|
7
11
|
withoutCaret
|
|
8
12
|
} = _ref;
|
|
9
13
|
return withoutCaret && 'caret-color: transparent;';
|
|
10
14
|
});
|
|
11
|
-
const StyledInputPlaceHolder = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n font-style: italic;\n color: ", ";\n position: absolute;\n display: flex;\n align-items: center;\n width: 100%;\n user-select: none;\n height: 28px;\n & span {\n
|
|
15
|
+
const StyledInputPlaceHolder = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n font-style: italic;\n color: ", ";\n position: absolute;\n display: flex;\n align-items: center;\n width: 100%;\n user-select: none;\n height: 28px;\n font-size: 13px;\n & span::after {\n content: '';\n padding: 1px;\n }\n"])), props => props.theme.colors.neutral[500]);
|
|
12
16
|
const StyledInputWidthReference = styled.span(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n visibility: hidden;\n position: absolute;\n top: -9999px;\n"])));
|
|
13
|
-
const StyledInputWrapper = styled
|
|
17
|
+
const StyledInputWrapper = styled('div')(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n position: relative;\n align-items: center;\n display: flex;\n"])));
|
|
14
18
|
|
|
15
19
|
export { StyledInput, StyledInputPlaceHolder, StyledInputWidthReference, StyledInputWrapper };
|
|
@@ -15,8 +15,7 @@ const useControlsInput = () => {
|
|
|
15
15
|
},
|
|
16
16
|
setHasFocus,
|
|
17
17
|
inputValue,
|
|
18
|
-
setInputValue
|
|
19
|
-
setShowSelectedOptions
|
|
18
|
+
setInputValue
|
|
20
19
|
} = useContext(ComboBoxContext);
|
|
21
20
|
const [width, setWidth] = useState(1); // use span reference to calculate the real width for the input
|
|
22
21
|
|
|
@@ -34,8 +33,8 @@ const useControlsInput = () => {
|
|
|
34
33
|
const handleOnBlur = useCallback(() => {
|
|
35
34
|
setInputValue('');
|
|
36
35
|
if (onFilter) onFilter(allOptions, inputValue);
|
|
37
|
-
setHasFocus(false);
|
|
38
|
-
}, [setInputValue, onFilter, allOptions, inputValue, setHasFocus
|
|
36
|
+
setHasFocus(false);
|
|
37
|
+
}, [setInputValue, onFilter, allOptions, inputValue, setHasFocus]);
|
|
39
38
|
const handleOnFocus = useCallback(() => {
|
|
40
39
|
setHasFocus(true);
|
|
41
40
|
}, [setHasFocus]);
|