@elliemae/ds-form-combobox 3.80.0-next.8 → 3.80.0-next.81
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/dist/cjs/DSCommonComboboxPropsT.js +7 -3
- package/dist/cjs/DSCommonComboboxPropsT.js.map +2 -2
- package/dist/cjs/TruncatedText.js +11 -7
- package/dist/cjs/TruncatedText.js.map +2 -2
- package/dist/cjs/config/useComboBox.js +21 -6
- package/dist/cjs/config/useComboBox.js.map +2 -2
- package/dist/cjs/parts/DropdownIndicator.js +4 -3
- package/dist/cjs/parts/DropdownIndicator.js.map +2 -2
- package/dist/cjs/parts/Section.js +18 -8
- package/dist/cjs/parts/Section.js.map +2 -2
- package/dist/cjs/parts/container/Container.js +5 -2
- package/dist/cjs/parts/container/Container.js.map +2 -2
- package/dist/cjs/parts/container/styled.js +4 -4
- package/dist/cjs/parts/container/styled.js.map +2 -2
- package/dist/cjs/parts/controls/Controls.js +10 -19
- package/dist/cjs/parts/controls/Controls.js.map +2 -2
- package/dist/cjs/parts/controls/styled.js +7 -7
- package/dist/cjs/parts/controls/styled.js.map +2 -2
- package/dist/cjs/parts/controls/useOnPillsNavigation.js +5 -13
- package/dist/cjs/parts/controls/useOnPillsNavigation.js.map +2 -2
- package/dist/cjs/parts/controls-input/ControlsInput.js +20 -19
- package/dist/cjs/parts/controls-input/ControlsInput.js.map +2 -2
- package/dist/cjs/parts/controls-input/styled.js +5 -2
- package/dist/cjs/parts/controls-input/styled.js.map +2 -2
- package/dist/cjs/parts/controls-input/useKeyboardNavigation.js +22 -15
- package/dist/cjs/parts/controls-input/useKeyboardNavigation.js.map +2 -2
- package/dist/cjs/parts/controls-input/useMaskedOnChange.js +11 -4
- package/dist/cjs/parts/controls-input/useMaskedOnChange.js.map +2 -2
- package/dist/cjs/parts/menu-list/useItemRenderer.js +22 -11
- package/dist/cjs/parts/menu-list/useItemRenderer.js.map +2 -2
- package/dist/cjs/parts/multi-selected-values-container/RemovableSelectedValuePill.js +4 -9
- package/dist/cjs/parts/multi-selected-values-container/RemovableSelectedValuePill.js.map +2 -2
- package/dist/cjs/parts/multi-selected-values-container/useGroupPills.js +10 -2
- package/dist/cjs/parts/multi-selected-values-container/useGroupPills.js.map +2 -2
- package/dist/cjs/parts/styled.js.map +2 -2
- package/dist/cjs/utils/listHelper.js +2 -0
- package/dist/cjs/utils/listHelper.js.map +2 -2
- package/dist/esm/DSCommonComboboxPropsT.js +7 -3
- package/dist/esm/DSCommonComboboxPropsT.js.map +2 -2
- package/dist/esm/TruncatedText.js +11 -7
- package/dist/esm/TruncatedText.js.map +2 -2
- package/dist/esm/config/useComboBox.js +22 -7
- package/dist/esm/config/useComboBox.js.map +2 -2
- package/dist/esm/parts/DropdownIndicator.js +5 -4
- package/dist/esm/parts/DropdownIndicator.js.map +2 -2
- package/dist/esm/parts/Section.js +18 -8
- package/dist/esm/parts/Section.js.map +2 -2
- package/dist/esm/parts/container/Container.js +5 -2
- package/dist/esm/parts/container/Container.js.map +2 -2
- package/dist/esm/parts/container/styled.js +5 -5
- package/dist/esm/parts/container/styled.js.map +2 -2
- package/dist/esm/parts/controls/Controls.js +10 -19
- package/dist/esm/parts/controls/Controls.js.map +2 -2
- package/dist/esm/parts/controls/styled.js +7 -7
- package/dist/esm/parts/controls/styled.js.map +2 -2
- package/dist/esm/parts/controls/useOnPillsNavigation.js +5 -13
- package/dist/esm/parts/controls/useOnPillsNavigation.js.map +2 -2
- package/dist/esm/parts/controls-input/ControlsInput.js +27 -20
- package/dist/esm/parts/controls-input/ControlsInput.js.map +2 -2
- package/dist/esm/parts/controls-input/styled.js +6 -3
- package/dist/esm/parts/controls-input/styled.js.map +2 -2
- package/dist/esm/parts/controls-input/useKeyboardNavigation.js +24 -16
- package/dist/esm/parts/controls-input/useKeyboardNavigation.js.map +2 -2
- package/dist/esm/parts/controls-input/useMaskedOnChange.js +11 -4
- package/dist/esm/parts/controls-input/useMaskedOnChange.js.map +2 -2
- package/dist/esm/parts/menu-list/useItemRenderer.js +24 -13
- package/dist/esm/parts/menu-list/useItemRenderer.js.map +2 -2
- package/dist/esm/parts/multi-selected-values-container/RemovableSelectedValuePill.js +5 -10
- package/dist/esm/parts/multi-selected-values-container/RemovableSelectedValuePill.js.map +2 -2
- package/dist/esm/parts/multi-selected-values-container/useGroupPills.js +10 -2
- package/dist/esm/parts/multi-selected-values-container/useGroupPills.js.map +2 -2
- package/dist/esm/parts/styled.js.map +2 -2
- package/dist/esm/utils/listHelper.js +2 -0
- package/dist/esm/utils/listHelper.js.map +2 -2
- package/dist/types/ComboBoxCTX.d.ts +3 -1
- package/dist/types/TruncatedText.d.ts +2 -1
- package/dist/types/config/useComboBox.d.ts +3 -1
- package/dist/types/parts/Section.d.ts +1 -0
- package/dist/types/parts/container/styled.d.ts +4 -4
- package/dist/types/parts/controls/styled.d.ts +7 -7
- package/dist/types/parts/controls-input/styled.d.ts +1 -1
- package/dist/types/parts/controls-input/useMaskedOnChange.d.ts +1 -1
- package/dist/types/parts/styled.d.ts +5 -0
- package/dist/types/utils/listHelper.d.ts +8 -0
- package/package.json +17 -17
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/controls/Controls.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { useOwnerProps } from '@elliemae/ds-props-helpers';\nimport React, { useCallback, useContext, useMemo } from 'react';\nimport ComboBoxContext from '../../ComboBoxCTX.js';\nimport { ComboboxDataTestid } from '../../ComboboxDataTestids.js';\nimport { TruncatedText } from '../../TruncatedText.js';\nimport { ControlsInput } from '../controls-input/ControlsInput.js';\nimport { DropdownIndicator } from '../DropdownIndicator.js';\nimport { MultiSelectedValuesContainer } from '../multi-selected-values-container/index.js';\nimport {\n StyledControlsWrapper,\n StyledHeaderActionsWrapper,\n StyledSelection,\n StyledSingleSelectWraper,\n StyleHeaderActionsSeparator,\n} from './styled.js';\nimport { useOnPillsNavigation } from './useOnPillsNavigation.js';\n\nexport const Controls = (): JSX.Element => {\n const {\n props,\n props: { inline, disabled, hasError, selectedValues, applyAriaDisabled, readOnly, isMenuOpenableWithReadOnly },\n selectedOptionsRef,\n setMenuState,\n setFocusOptionIdx,\n hasFocus,\n inputValue,\n listRef,\n focusOptionIdx,\n menuState,\n controlsWrapperRef,\n internalRef,\n shouldPreventContextMenuOpening,\n } = useContext(ComboBoxContext);\n\n const { getOwnerProps, getOwnerPropsArguments } = useOwnerProps(props);\n\n const handleOnClick = useCallback(() => {\n if (disabled) return;\n if (
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { useOwnerProps } from '@elliemae/ds-props-helpers';\nimport React, { useCallback, useContext, useMemo } from 'react';\nimport ComboBoxContext from '../../ComboBoxCTX.js';\nimport { ComboboxDataTestid } from '../../ComboboxDataTestids.js';\nimport { TruncatedText } from '../../TruncatedText.js';\nimport { ControlsInput } from '../controls-input/ControlsInput.js';\nimport { DropdownIndicator } from '../DropdownIndicator.js';\nimport { MultiSelectedValuesContainer } from '../multi-selected-values-container/index.js';\nimport {\n StyledControlsWrapper,\n StyledHeaderActionsWrapper,\n StyledSelection,\n StyledSingleSelectWraper,\n StyleHeaderActionsSeparator,\n} from './styled.js';\nimport { useOnPillsNavigation } from './useOnPillsNavigation.js';\n\nexport const Controls = (): JSX.Element => {\n const {\n props,\n props: { inline, disabled, hasError, selectedValues, applyAriaDisabled, readOnly, isMenuOpenableWithReadOnly },\n selectedOptionsRef,\n setMenuState,\n setFocusOptionIdx,\n hasFocus,\n inputValue,\n listRef,\n focusOptionIdx,\n menuState,\n controlsWrapperRef,\n internalRef,\n shouldPreventContextMenuOpening,\n } = useContext(ComboBoxContext);\n\n const { getOwnerProps, getOwnerPropsArguments } = useOwnerProps(props);\n\n const handleOnClick = useCallback(() => {\n if (disabled) return;\n if (shouldPreventContextMenuOpening) {\n internalRef.current?.focus();\n return;\n }\n if (hasFocus && menuState && !inline) {\n setMenuState(false, 'click');\n setFocusOptionIdx('');\n internalRef.current?.blur();\n return;\n }\n internalRef.current?.focus();\n setMenuState(true, 'click');\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n disabled,\n listRef,\n hasFocus,\n menuState,\n inline,\n setMenuState,\n focusOptionIdx,\n readOnly,\n applyAriaDisabled,\n isMenuOpenableWithReadOnly,\n ]);\n\n // this callback prevent to toggle the menu when clicking or removing pills\n const handleOnPillsClick: React.MouseEventHandler = useCallback(\n (e) => {\n if (menuState || disabled || shouldPreventContextMenuOpening) {\n e.stopPropagation();\n } else {\n internalRef.current?.focus();\n setMenuState(true, 'pill-click');\n }\n },\n [menuState, disabled, internalRef, setMenuState, shouldPreventContextMenuOpening],\n );\n\n // callback to prevent onBlur on the input when clicking in all the wrapper\n const handleOnMouseDown: React.MouseEventHandler = useCallback(\n (e) => {\n if (document.activeElement === internalRef.current || inline) {\n e.preventDefault();\n }\n },\n [internalRef, inline],\n );\n\n const { onKeyDownPills } = useOnPillsNavigation();\n\n const cols = useMemo(\n () => (!inline ? ['minmax(0px,max-content)', 'minmax(20px, auto)', '8px', '2.231rem'] : ['minmax(0px, auto)']),\n [inline],\n );\n return (\n <StyledControlsWrapper\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n innerRef={controlsWrapperRef}\n $readOnly={readOnly ?? false}\n cols={cols}\n $disabled={disabled ?? false}\n $applyAriaDisabled={applyAriaDisabled ?? false}\n hasError={hasError ?? false}\n inline={inline ?? false}\n onClick={handleOnClick}\n onMouseDown={handleOnMouseDown}\n onKeyDown={onKeyDownPills}\n aria-disabled={applyAriaDisabled || readOnly ? true : undefined}\n data-testid={ComboboxDataTestid.CONTROLS_WRAPPER}\n >\n {!inline && (\n <StyledSelection\n variant=\"b2\"\n component=\"div\"\n innerRef={selectedOptionsRef}\n onClick={handleOnPillsClick}\n getOwnerProps={getOwnerProps}\n >\n {Array.isArray(selectedValues) ? (\n <MultiSelectedValuesContainer />\n ) : (\n <StyledSingleSelectWraper\n $readOnly={readOnly ?? false}\n // legacy data-testid \u2014 preserved for QA/consumer compatibility, breaking change if removed\n data-testid={ComboboxDataTestid.SELECTED_VALUES}\n $disabled={disabled ?? false}\n $applyAriaDisabled={applyAriaDisabled ?? false}\n getOwnerProps={getOwnerProps}\n >\n {selectedValues && inputValue === '' ? <TruncatedText value={selectedValues.label} /> : null}\n </StyledSingleSelectWraper>\n )}\n </StyledSelection>\n )}\n\n <ControlsInput />\n {/** This empty div is a gap between the input and the drop down indicator */}\n <div />\n {!inline && (\n <StyledHeaderActionsWrapper\n justifyItems=\"center\"\n cols={['min-content', 'minmax(28px,max-content)']}\n justifyContent=\"flex-end\"\n getOwnerProps={getOwnerProps}\n >\n <StyleHeaderActionsSeparator getOwnerProps={getOwnerProps} />\n <DropdownIndicator />\n </StyledHeaderActionsWrapper>\n )}\n </StyledControlsWrapper>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD0HX;AAxHZ,8BAA8B;AAC9B,mBAAwD;AACxD,yBAA4B;AAC5B,iCAAmC;AACnC,2BAA8B;AAC9B,2BAA8B;AAC9B,+BAAkC;AAClC,6CAA6C;AAC7C,oBAMO;AACP,kCAAqC;AAE9B,MAAM,WAAW,MAAmB;AACzC,QAAM;AAAA,IACJ;AAAA,IACA,OAAO,EAAE,QAAQ,UAAU,UAAU,gBAAgB,mBAAmB,UAAU,2BAA2B;AAAA,IAC7G;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA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WAAW,YAAY;AAAA,MACvB;AAAA,MACA,WAAW,YAAY;AAAA,MACvB,oBAAoB,qBAAqB;AAAA,MACzC,UAAU,YAAY;AAAA,MACtB,QAAQ,UAAU;AAAA,MAClB,SAAS;AAAA,MACT,aAAa;AAAA,MACb,WAAW;AAAA,MACX,iBAAe,qBAAqB,WAAW,OAAO;AAAA,MACtD,eAAa,8CAAmB;AAAA,MAE/B;AAAA,SAAC,UACA;AAAA,UAAC;AAAA;AAAA,YACC,SAAQ;AAAA,YACR,WAAU;AAAA,YACV,UAAU;AAAA,YACV,SAAS;AAAA,YACT;AAAA,YAEC,gBAAM,QAAQ,cAAc,IAC3B,4CAAC,uEAA6B,IAE9B;AAAA,cAAC;AAAA;AAAA,gBACC,WAAW,YAAY;AAAA,gBAEvB,eAAa,8CAAmB;AAAA,gBAChC,WAAW,YAAY;AAAA,gBACvB,oBAAoB,qBAAqB;AAAA,gBACzC;AAAA,gBAEC,4BAAkB,eAAe,KAAK,4CAAC,sCAAc,OAAO,eAAe,OAAO,IAAK;AAAA;AAAA,YAC1F;AAAA;AAAA,QAEJ;AAAA,QAGF,4CAAC,sCAAc;AAAA,QAEf,4CAAC,SAAI;AAAA,QACJ,CAAC,UACA;AAAA,UAAC;AAAA;AAAA,YACC,cAAa;AAAA,YACb,MAAM,CAAC,eAAe,0BAA0B;AAAA,YAChD,gBAAe;AAAA,YACf;AAAA,YAEA;AAAA,0DAAC,6CAA4B,eAA8B;AAAA,cAC3D,4CAAC,8CAAkB;AAAA;AAAA;AAAA,QACrB;AAAA;AAAA;AAAA,EAEJ;AAEJ;",
|
|
6
6
|
"names": ["ComboBoxContext"]
|
|
7
7
|
}
|
|
@@ -47,14 +47,14 @@ const readOnlyBorder = import_ds_system.css`
|
|
|
47
47
|
`;
|
|
48
48
|
const borderStyles = import_ds_system.css`
|
|
49
49
|
border: 1px solid ${({ hasError, theme }) => hasError ? theme.colors.danger[900] : theme.colors.neutral[400]};
|
|
50
|
-
${({ readOnly, applyAriaDisabled }) => readOnly || applyAriaDisabled ? readOnlyBorder : ""}
|
|
50
|
+
${({ $readOnly, $applyAriaDisabled }) => $readOnly || $applyAriaDisabled ? readOnlyBorder : ""}
|
|
51
51
|
`;
|
|
52
52
|
const backgroundStyles = import_ds_system.css`
|
|
53
|
-
background: ${({ disabled, applyAriaDisabled, readOnly, theme }) => {
|
|
54
|
-
if (readOnly || applyAriaDisabled) {
|
|
53
|
+
background: ${({ $disabled, $applyAriaDisabled, $readOnly, theme }) => {
|
|
54
|
+
if ($readOnly || $applyAriaDisabled) {
|
|
55
55
|
return theme.colors.neutral["050"];
|
|
56
56
|
}
|
|
57
|
-
if (disabled) {
|
|
57
|
+
if ($disabled) {
|
|
58
58
|
return theme.colors.neutral["080"];
|
|
59
59
|
}
|
|
60
60
|
return "#ffffff";
|
|
@@ -85,7 +85,7 @@ const StyledControlsWrapper = (0, import_ds_system.styled)(import_ds_grid.Grid,
|
|
|
85
85
|
margin: ${({ inline }) => inline ? "8px 16px" : ""};
|
|
86
86
|
${borderStyles}
|
|
87
87
|
&:hover {
|
|
88
|
-
${({ disabled }) =>
|
|
88
|
+
${({ $disabled }) => !$disabled ? hoverBorder : ""}
|
|
89
89
|
}
|
|
90
90
|
&:focus-within {
|
|
91
91
|
${focusBorder}
|
|
@@ -98,8 +98,8 @@ const StyledSingleSelectWraper = (0, import_ds_system.styled)("div", {
|
|
|
98
98
|
display: flex;
|
|
99
99
|
width: 100%;
|
|
100
100
|
align-items: center;
|
|
101
|
-
color: ${({ disabled, readOnly, theme }) => disabled || readOnly ? theme.colors.neutral["600"] : theme.colors.neutral["700"]};
|
|
102
|
-
user-select: ${({ disabled, applyAriaDisabled }) => disabled || applyAriaDisabled ? "none" : ""};
|
|
101
|
+
color: ${({ $disabled, $readOnly, $applyAriaDisabled, theme }) => $disabled || $readOnly || $applyAriaDisabled ? theme.colors.neutral["600"] : theme.colors.neutral["700"]};
|
|
102
|
+
user-select: ${({ $disabled, $applyAriaDisabled }) => $disabled || $applyAriaDisabled ? "none" : ""};
|
|
103
103
|
`;
|
|
104
104
|
const StyledSelection = (0, import_ds_system.styled)(import_ds_typography.DSTypography, {
|
|
105
105
|
name: import_constants.DSFormComboboxName,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/controls/styled.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import { styled, css } from '@elliemae/ds-system';\nimport { Grid } from '@elliemae/ds-grid';\nimport { DSTypography } from '@elliemae/ds-typography';\nimport { DSFormComboboxName, FORM_COMBOBOX_SLOTS } from '../../constants/index.js';\n\ninterface StyledControlsWrapperT {\n hasError: boolean;\n inline: boolean;\n minWidth?: number;\n disabled: boolean;\n applyAriaDisabled: boolean;\n readOnly: boolean;\n}\n\nconst readOnlyBorder = css`\n border: 1px solid ${({ theme }) => theme.colors.neutral['080']};\n border-bottom: 1px solid ${({ theme }) => theme.colors.neutral[400]};\n`;\n\nconst borderStyles = css<{ hasError: boolean; readOnly: boolean; applyAriaDisabled: boolean }>`\n border: 1px solid ${({ hasError, theme }) => (hasError ? theme.colors.danger[900] : theme.colors.neutral[400])};\n ${({ readOnly, applyAriaDisabled }) => (readOnly || applyAriaDisabled ? readOnlyBorder : '')}\n`;\n\nconst backgroundStyles = css<{ disabled: boolean; applyAriaDisabled: boolean; readOnly: boolean }>`\n background: ${({ disabled, applyAriaDisabled, readOnly, theme }) => {\n if (readOnly || applyAriaDisabled) {\n return theme.colors.neutral['050'];\n }\n if (disabled) {\n return theme.colors.neutral['080'];\n }\n return '#ffffff';\n }};\n`;\n\nconst focusBorder = css`\n outline: 2px solid ${({ theme }) => theme.colors.brand[700]};\n outline-offset: -2px;\n`;\n\nconst hoverBorder = css`\n border: 1px solid ${({ theme }) => theme.colors.brand[600]};\n`;\n\nexport const StyledControlsWrapper = styled(Grid, {\n name: DSFormComboboxName,\n slot: FORM_COMBOBOX_SLOTS.INPUT_WRAPPER,\n})<StyledControlsWrapperT>`\n ${backgroundStyles}\n position: relative;\n border-radius: 2px;\n min-width: ${({ minWidth, inline }) => (inline || !minWidth ? '' : `${minWidth}px`)};\n align-items: center;\n align-content: center;\n min-height: 28px;\n /** PUI-15490: the spec's 5px vertical padding belongs to the TEXT LINE (StyledInputWrapper),\n * not here \u2014 padding the wrapper would also inset the separator + chevron column and inflate\n * the control past the spec's min-height. Right-side 8px comes from the grid gap column. */\n padding: 0px 0px 0px 8px;\n margin: ${({ inline }) => (inline ? '8px 16px' : '')};\n ${borderStyles}\n &:hover {\n ${({ disabled }) => (
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAA4B;AAC5B,qBAAqB;AACrB,2BAA6B;AAC7B,uBAAwD;AAWxD,MAAM,iBAAiB;AAAA,sBACD,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,QAAQ,KAAK,CAAC;AAAA,6BACnC,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,QAAQ,GAAG,CAAC;AAAA;AAGrE,MAAM,eAAe;AAAA,sBACC,CAAC,EAAE,UAAU,MAAM,MAAO,WAAW,MAAM,OAAO,OAAO,GAAG,IAAI,MAAM,OAAO,QAAQ,GAAG,CAAE;AAAA,IAC5G,CAAC,EAAE,
|
|
4
|
+
"sourcesContent": ["import { styled, css } from '@elliemae/ds-system';\nimport { Grid } from '@elliemae/ds-grid';\nimport { DSTypography } from '@elliemae/ds-typography';\nimport { DSFormComboboxName, FORM_COMBOBOX_SLOTS } from '../../constants/index.js';\n\ninterface StyledControlsWrapperT {\n hasError: boolean;\n inline: boolean;\n minWidth?: number;\n $disabled: boolean;\n $applyAriaDisabled: boolean;\n $readOnly: boolean;\n}\n\nconst readOnlyBorder = css`\n border: 1px solid ${({ theme }) => theme.colors.neutral['080']};\n border-bottom: 1px solid ${({ theme }) => theme.colors.neutral[400]};\n`;\n\nconst borderStyles = css<{ hasError: boolean; $readOnly: boolean; $applyAriaDisabled: boolean }>`\n border: 1px solid ${({ hasError, theme }) => (hasError ? theme.colors.danger[900] : theme.colors.neutral[400])};\n ${({ $readOnly, $applyAriaDisabled }) => ($readOnly || $applyAriaDisabled ? readOnlyBorder : '')}\n`;\n\nconst backgroundStyles = css<{ $disabled: boolean; $applyAriaDisabled: boolean; $readOnly: boolean }>`\n background: ${({ $disabled, $applyAriaDisabled, $readOnly, theme }) => {\n if ($readOnly || $applyAriaDisabled) {\n return theme.colors.neutral['050'];\n }\n if ($disabled) {\n return theme.colors.neutral['080'];\n }\n return '#ffffff';\n }};\n`;\n\nconst focusBorder = css`\n outline: 2px solid ${({ theme }) => theme.colors.brand[700]};\n outline-offset: -2px;\n`;\n\nconst hoverBorder = css`\n border: 1px solid ${({ theme }) => theme.colors.brand[600]};\n`;\n\nexport const StyledControlsWrapper = styled(Grid, {\n name: DSFormComboboxName,\n slot: FORM_COMBOBOX_SLOTS.INPUT_WRAPPER,\n})<StyledControlsWrapperT>`\n ${backgroundStyles}\n position: relative;\n border-radius: 2px;\n min-width: ${({ minWidth, inline }) => (inline || !minWidth ? '' : `${minWidth}px`)};\n align-items: center;\n align-content: center;\n min-height: 28px;\n /** PUI-15490: the spec's 5px vertical padding belongs to the TEXT LINE (StyledInputWrapper),\n * not here \u2014 padding the wrapper would also inset the separator + chevron column and inflate\n * the control past the spec's min-height. Right-side 8px comes from the grid gap column. */\n padding: 0px 0px 0px 8px;\n margin: ${({ inline }) => (inline ? '8px 16px' : '')};\n ${borderStyles}\n &:hover {\n ${({ $disabled }) => (!$disabled ? hoverBorder : '')}\n }\n &:focus-within {\n ${focusBorder}\n }\n`;\n\nexport const StyledSingleSelectWraper = styled('div', {\n name: DSFormComboboxName,\n slot: FORM_COMBOBOX_SLOTS.SELECTED_VALUES,\n})<{\n $disabled: boolean;\n $applyAriaDisabled: boolean;\n $readOnly: boolean;\n}>`\n display: flex;\n width: 100%;\n align-items: center;\n color: ${({ $disabled, $readOnly, $applyAriaDisabled, theme }) =>\n $disabled || $readOnly || $applyAriaDisabled ? theme.colors.neutral['600'] : theme.colors.neutral['700']};\n user-select: ${({ $disabled, $applyAriaDisabled }) => ($disabled || $applyAriaDisabled ? 'none' : '')};\n`;\n\nexport const StyledSelection = styled(DSTypography, {\n name: DSFormComboboxName,\n slot: FORM_COMBOBOX_SLOTS.SELECTION,\n})`\n margin-right: 3px;\n display: flex;\n /** PUI-15490 \u2014 no vertical padding here on purpose: the 5px text-line rhythm lives on\n * StyledInputWrapper (always rendered), so the control height stays constant and pills\n * (taller than the text line) center within it instead of growing the control. */\n align-self: center;\n`;\n\nexport const StyledHeaderActionsWrapper = styled(Grid, {\n name: DSFormComboboxName,\n slot: FORM_COMBOBOX_SLOTS.HEADER_ACTIONS,\n})`\n height: 100%;\n /** PUI-15490 \u2014 grid children otherwise stretch to the row height; the chevron button must\n * keep its spec box (size 's' square, icon + 2px) and the separator its fixed 20px. */\n align-items: center;\n .em-ds-button--text:focus::after {\n border: none;\n }\n`;\n\nexport const StyleDropdownIndicator = styled.div``;\n\nexport const StyleHeaderActionsSeparator = styled('span', {\n name: DSFormComboboxName,\n slot: FORM_COMBOBOX_SLOTS.HEADER_ACTIONS_SEPARATOR,\n})`\n /** PUI-15490 \u2014 fixed 20px per the box-model spec (was height: 100%, which stretched it\n * with the control row instead of staying at spec size). */\n height: 20px;\n align-self: center;\n width: 1px;\n background-color: ${({ theme }) => theme.colors.neutral['400']};\n`;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAA4B;AAC5B,qBAAqB;AACrB,2BAA6B;AAC7B,uBAAwD;AAWxD,MAAM,iBAAiB;AAAA,sBACD,CAAC,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AO;AAAA,EACpD,MAAM;AAAA,EACN,MAAM,qCAAoB;AAC5B,CAAC;AAAA;AAAA;AAAA;AAAA,WAQU,CAAC,EAAE,WAAW,WAAW,oBAAoB,MAAM,MAC1D,aAAa,aAAa,qBAAqB,MAAM,OAAO,QAAQ,KAAK,IAAI,MAAM,OAAO,QAAQ,KAAK,CAAC;AAAA,iBAC3F,CAAC,EAAE,WAAW,mBAAmB,MAAO,aAAa,qBAAqB,SAAS,EAAG;AAAA;AAGhG,MAAM,sBAAkB,yBAAO,mCAAc;AAAA,EAClD,MAAM;AAAA,EACN,MAAM,qCAAoB;AAC5B,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASM,MAAM,iCAA6B,yBAAO,qBAAM;AAAA,EACrD,MAAM;AAAA,EACN,MAAM,qCAAoB;AAC5B,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUM,MAAM,yBAAyB,wBAAO;AAEtC,MAAM,kCAA8B,yBAAO,QAAQ;AAAA,EACxD,MAAM;AAAA,EACN,MAAM,qCAAoB;AAC5B,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAMqB,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,QAAQ,KAAK,CAAC;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -41,18 +41,19 @@ const useOnPillsNavigation = () => {
|
|
|
41
41
|
hasFocus,
|
|
42
42
|
setMenuState,
|
|
43
43
|
selectedOptionsRef,
|
|
44
|
-
|
|
44
|
+
isMenuOpeningLocked,
|
|
45
|
+
props: { disabled }
|
|
45
46
|
} = (0, import_react.useContext)(import_ComboBoxCTX.default);
|
|
46
47
|
const REMOVABLE_PILL_SELECTOR = ".ds-pill-wrapper-removable button";
|
|
47
48
|
const onKeyDownPills = (0, import_react.useCallback)(
|
|
48
49
|
(e) => {
|
|
49
|
-
if (
|
|
50
|
+
if (disabled) {
|
|
50
51
|
return;
|
|
51
52
|
}
|
|
52
53
|
if ((e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "ArrowUp" || e.key === "ArrowDown") && inputValue === "") {
|
|
53
54
|
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
54
55
|
internalRef.current?.focus();
|
|
55
|
-
setMenuState(true, "open", e);
|
|
56
|
+
if (!isMenuOpeningLocked) setMenuState(true, "open", e);
|
|
56
57
|
return;
|
|
57
58
|
}
|
|
58
59
|
if (e.key === "ArrowLeft") {
|
|
@@ -67,16 +68,7 @@ const useOnPillsNavigation = () => {
|
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
},
|
|
70
|
-
[
|
|
71
|
-
inputValue,
|
|
72
|
-
internalRef,
|
|
73
|
-
setMenuState,
|
|
74
|
-
selectedOptionsRef,
|
|
75
|
-
hasFocus,
|
|
76
|
-
applyAriaDisabled,
|
|
77
|
-
readOnly,
|
|
78
|
-
isMenuOpenableWithReadOnly
|
|
79
|
-
]
|
|
71
|
+
[inputValue, internalRef, setMenuState, selectedOptionsRef, hasFocus, disabled, isMenuOpeningLocked]
|
|
80
72
|
);
|
|
81
73
|
return { onKeyDownPills };
|
|
82
74
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/controls/useOnPillsNavigation.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable max-depth */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport type React from 'react';\nimport { useCallback, useContext } from 'react';\nimport ComboBoxContext from '../../ComboBoxCTX.js';\n\nexport const useOnPillsNavigation = () => {\n const {\n internalRef,\n inputValue,\n hasFocus,\n setMenuState,\n selectedOptionsRef,\n props: {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADKvB,mBAAwC;AACxC,yBAA4B;AAErB,MAAM,uBAAuB,MAAM;AACxC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable max-depth */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport type React from 'react';\nimport { useCallback, useContext } from 'react';\nimport ComboBoxContext from '../../ComboBoxCTX.js';\n\nexport const useOnPillsNavigation = () => {\n const {\n internalRef,\n inputValue,\n hasFocus,\n setMenuState,\n selectedOptionsRef,\n isMenuOpeningLocked,\n props: { disabled },\n } = useContext(ComboBoxContext);\n\n // todo: constant must be defined on pills component\n const REMOVABLE_PILL_SELECTOR = '.ds-pill-wrapper-removable button';\n\n const onKeyDownPills: React.KeyboardEventHandler<HTMLInputElement> = useCallback(\n (e) => {\n // applyAriaDisabled and readOnly keep focus and arrow navigation; only opening the menu is locked\n if (disabled) {\n return;\n }\n if (\n (e.key === 'ArrowLeft' || e.key === 'ArrowRight' || e.key === 'ArrowUp' || e.key === 'ArrowDown') &&\n inputValue === ''\n ) {\n if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {\n internalRef.current?.focus();\n if (!isMenuOpeningLocked) setMenuState(true, 'open', e);\n return;\n }\n if (e.key === 'ArrowLeft') {\n const removablePills: NodeListOf<HTMLButtonElement> | undefined =\n selectedOptionsRef.current?.querySelectorAll(REMOVABLE_PILL_SELECTOR);\n\n if (hasFocus && removablePills) {\n removablePills[removablePills.length - 1]?.focus();\n }\n }\n if (e.key === 'ArrowRight') {\n e.preventDefault();\n internalRef.current?.focus();\n }\n }\n },\n [inputValue, internalRef, setMenuState, selectedOptionsRef, hasFocus, disabled, isMenuOpeningLocked],\n );\n\n return { onKeyDownPills };\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADKvB,mBAAwC;AACxC,yBAA4B;AAErB,MAAM,uBAAuB,MAAM;AACxC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,SAAS;AAAA,EACpB,QAAI,yBAAW,mBAAAA,OAAe;AAG9B,QAAM,0BAA0B;AAEhC,QAAM,qBAA+D;AAAA,IACnE,CAAC,MAAM;AAEL,UAAI,UAAU;AACZ;AAAA,MACF;AACA,WACG,EAAE,QAAQ,eAAe,EAAE,QAAQ,gBAAgB,EAAE,QAAQ,aAAa,EAAE,QAAQ,gBACrF,eAAe,IACf;AACA,YAAI,EAAE,QAAQ,aAAa,EAAE,QAAQ,aAAa;AAChD,sBAAY,SAAS,MAAM;AAC3B,cAAI,CAAC,oBAAqB,cAAa,MAAM,QAAQ,CAAC;AACtD;AAAA,QACF;AACA,YAAI,EAAE,QAAQ,aAAa;AACzB,gBAAM,iBACJ,mBAAmB,SAAS,iBAAiB,uBAAuB;AAEtE,cAAI,YAAY,gBAAgB;AAC9B,2BAAe,eAAe,SAAS,CAAC,GAAG,MAAM;AAAA,UACnD;AAAA,QACF;AACA,YAAI,EAAE,QAAQ,cAAc;AAC1B,YAAE,eAAe;AACjB,sBAAY,SAAS,MAAM;AAAA,QAC7B;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,YAAY,aAAa,cAAc,oBAAoB,UAAU,UAAU,mBAAmB;AAAA,EACrG;AAEA,SAAO,EAAE,eAAe;AAC1B;",
|
|
6
6
|
"names": ["ComboBoxContext"]
|
|
7
7
|
}
|
|
@@ -80,34 +80,30 @@ const ControlsInput = () => {
|
|
|
80
80
|
onFocus: handleOnFocus,
|
|
81
81
|
onBlur: handleOnBlur
|
|
82
82
|
});
|
|
83
|
+
const readOnlyHelperId = `${instanceUid}-read-only-helper-msg`;
|
|
83
84
|
const actualAriaDescribedBy = (0, import_react.useMemo)(() => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
return ariaDescribedBy;
|
|
89
|
-
}, [ariaDescribedBy, id]);
|
|
85
|
+
const internalIds = id ? `${id}_current_placeholder ${id}_feedback_message ${id}_error_message` : void 0;
|
|
86
|
+
return [ariaDescribedBy, internalIds, readOnly ? readOnlyHelperId : void 0].filter(Boolean).join(" ") || void 0;
|
|
87
|
+
}, [ariaDescribedBy, id, readOnly, readOnlyHelperId]);
|
|
90
88
|
const currentPlaceholder = (0, import_react.useMemo)(() => {
|
|
91
89
|
if ((0, import_listHelper.isArrayOfItems)(selectedValues)) {
|
|
92
|
-
return `options ${selectedValues.map((item) => item.label).join(", ")} selected
|
|
90
|
+
return `options ${selectedValues.map((item) => item.label).join(", ")} selected.`;
|
|
93
91
|
}
|
|
94
92
|
if ((0, import_typeGuards.isItemContainingALabel)(selectedValues)) {
|
|
95
|
-
return `option ${selectedValues.label} selected
|
|
96
|
-
}
|
|
97
|
-
if (readOnly) {
|
|
98
|
-
return `${placeholder}. Read only`;
|
|
93
|
+
return `option ${selectedValues.label} selected.`;
|
|
99
94
|
}
|
|
100
95
|
return placeholder;
|
|
101
|
-
}, [placeholder, selectedValues
|
|
96
|
+
}, [placeholder, selectedValues]);
|
|
102
97
|
const activeDescendant = (0, import_react.useMemo)(() => {
|
|
103
98
|
if (!isLoading && hasFocus && menuState) {
|
|
104
99
|
return focusOptionIdx;
|
|
105
100
|
}
|
|
106
101
|
return void 0;
|
|
107
102
|
}, [focusOptionIdx, hasFocus, isLoading, menuState]);
|
|
108
|
-
const isNonInteractive =
|
|
103
|
+
const isNonInteractive = (0, import_ds_props_helpers.isLocked)({ disabled, applyAriaDisabled, readOnly });
|
|
109
104
|
const handleOnPaste = (e) => {
|
|
110
105
|
e.preventDefault();
|
|
106
|
+
if (isNonInteractive) return;
|
|
111
107
|
setInputValue(e.clipboardData.getData("text/plain"));
|
|
112
108
|
internalRef.current?.focus();
|
|
113
109
|
};
|
|
@@ -126,6 +122,7 @@ const ControlsInput = () => {
|
|
|
126
122
|
),
|
|
127
123
|
menuState === false && !inline ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled.StyledHiddenDiv, { id: `combo-listbox-${instanceUid}` }) : null,
|
|
128
124
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled.StyledHiddenDiv, { id: `${id}_current_placeholder`, children: currentPlaceholder }),
|
|
125
|
+
readOnly ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { hidden: true, id: readOnlyHelperId, children: "Read only" }) : null,
|
|
129
126
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
130
127
|
import_styled.StyledInput,
|
|
131
128
|
{
|
|
@@ -134,7 +131,7 @@ const ControlsInput = () => {
|
|
|
134
131
|
onBlur: handleOnBlur,
|
|
135
132
|
onFocus: handleOnFocus,
|
|
136
133
|
readOnly: readOnly || onlySelectable,
|
|
137
|
-
...globalAttrs,
|
|
134
|
+
...(0, import_ds_props_helpers.omitLockedHandlers)(globalAttrs, isNonInteractive, "change"),
|
|
138
135
|
id,
|
|
139
136
|
"data-testid": import_ComboboxDataTestids.ComboboxDataTestid.INPUT,
|
|
140
137
|
autoFocus,
|
|
@@ -146,7 +143,7 @@ const ControlsInput = () => {
|
|
|
146
143
|
"aria-autocomplete": "list",
|
|
147
144
|
role: "combobox",
|
|
148
145
|
disabled,
|
|
149
|
-
applyAriaDisabled: applyAriaDisabled
|
|
146
|
+
applyAriaDisabled: Boolean(applyAriaDisabled || readOnly),
|
|
150
147
|
style: { width },
|
|
151
148
|
innerRef: (0, import_ds_system.mergeRefs)(innerRef, internalRef),
|
|
152
149
|
value: inputValue,
|
|
@@ -156,20 +153,24 @@ const ControlsInput = () => {
|
|
|
156
153
|
tabIndex,
|
|
157
154
|
withoutCaret: onlySelectable ?? false,
|
|
158
155
|
autoComplete: "off",
|
|
159
|
-
"aria-
|
|
156
|
+
"aria-disabled": (0, import_ds_props_helpers.resolveAriaDisabled)({
|
|
157
|
+
disabled,
|
|
158
|
+
softLocked: (0, import_ds_props_helpers.isLocked)({ applyAriaDisabled, readOnly }),
|
|
159
|
+
consumerValue: globalAttrs["aria-disabled"]
|
|
160
|
+
})
|
|
160
161
|
}
|
|
161
162
|
),
|
|
162
163
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
163
164
|
import_styled.StyleHiddenInput,
|
|
164
165
|
{
|
|
165
166
|
type: "text",
|
|
166
|
-
disabled
|
|
167
|
-
readOnly,
|
|
167
|
+
disabled,
|
|
168
|
+
readOnly: Boolean(applyAriaDisabled || readOnly),
|
|
168
169
|
name: "hidden",
|
|
169
170
|
tabIndex: -1,
|
|
170
171
|
onPaste: handleOnPaste,
|
|
171
172
|
"aria-hidden": "true",
|
|
172
|
-
|
|
173
|
+
$applyAriaDisabled: Boolean(applyAriaDisabled || readOnly)
|
|
173
174
|
}
|
|
174
175
|
)
|
|
175
176
|
] });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/controls-input/ControlsInput.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useContext, useMemo } from 'react';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["import React, { useContext, useMemo } from 'react';\nimport {\n isLocked,\n omitLockedHandlers,\n useGetGlobalAttributes,\n useOwnerProps,\n resolveAriaDisabled,\n} from '@elliemae/ds-props-helpers';\nimport { mergeRefs } from '@elliemae/ds-system';\nimport { TruncatedText } from '../../TruncatedText.js';\nimport { ComboBoxContext } from '../../ComboBoxCTX.js';\nimport { ComboboxDataTestid } from '../../ComboboxDataTestids.js';\nimport { isArrayOfItems } from '../../utils/listHelper.js';\nimport {\n StyledHiddenDiv,\n StyledInput,\n StyledInputPlaceHolder,\n StyledInputWidthReference,\n StyledInputWrapper,\n StyleHiddenInput,\n} from './styled.js';\nimport { useControlsInput } from './useControlsInput.js';\nimport { useKeyboardNavigation } from './useKeyboardNavigation.js';\nimport { isItemContainingALabel } from '../../utils/typeGuards.js';\n\n// aria-disabled is only printed as \"true\", and never next to the native disabled (`disabled` wins): a bare boolean\n// would print aria-disabled=\"false\" (PUI-16695)\nexport const ControlsInput = (): JSX.Element => {\n const {\n props,\n props: {\n autoFocus,\n inline,\n selectedValues,\n placeholder,\n disabled,\n innerRef,\n isLoading,\n onlySelectable,\n applyAriaDisabled,\n readOnly,\n ...restProps\n },\n focusOptionIdx,\n hasFocus,\n internalRef,\n inputValue,\n setInputValue,\n menuState,\n instanceUid,\n } = useContext(ComboBoxContext);\n const { onInputKeyDown } = useKeyboardNavigation();\n\n const { spanReference, width, spanReferenceText, showPlaceholder, handleOnBlur, handleOnChange, handleOnFocus } =\n useControlsInput();\n\n const { getOwnerProps, getOwnerPropsArguments } = useOwnerProps(props);\n\n const {\n tabIndex,\n id,\n 'aria-describedby': ariaDescribedBy,\n ...globalAttrs\n } = useGetGlobalAttributes(restProps, {\n onFocus: handleOnFocus,\n onBlur: handleOnBlur,\n });\n\n // Only readOnly references the helper: applyAriaDisabled alone does not render it (PUI-16695).\n const readOnlyHelperId = `${instanceUid}-read-only-helper-msg`;\n\n const actualAriaDescribedBy = useMemo(() => {\n const internalIds = id ? `${id}_current_placeholder ${id}_feedback_message ${id}_error_message` : undefined;\n return (\n [ariaDescribedBy, internalIds, readOnly ? readOnlyHelperId : undefined].filter(Boolean).join(' ') || undefined\n );\n }, [ariaDescribedBy, id, readOnly, readOnlyHelperId]);\n\n // \"Read only\" is announced once, through the hidden helper referenced by aria-describedby (see `readOnlyHelperId`)\n const currentPlaceholder = useMemo(() => {\n if (isArrayOfItems(selectedValues)) {\n return `options ${selectedValues.map((item) => item.label).join(', ')} selected.`;\n }\n if (isItemContainingALabel(selectedValues)) {\n return `option ${selectedValues.label} selected.`;\n }\n return placeholder;\n }, [placeholder, selectedValues]);\n\n const activeDescendant = useMemo(() => {\n if (!isLoading && hasFocus && menuState) {\n return focusOptionIdx;\n }\n return undefined;\n }, [focusOptionIdx, hasFocus, isLoading, menuState]);\n\n // any lock (PUI-16695): the consumer's action handlers are dropped from the global attributes spread below\n const isNonInteractive = isLocked({ disabled, applyAriaDisabled, readOnly });\n\n const handleOnPaste = (e: React.ClipboardEvent<HTMLInputElement>) => {\n e.preventDefault();\n if (isNonInteractive) return;\n setInputValue(e.clipboardData.getData('text/plain'));\n internalRef.current?.focus();\n };\n return (\n <StyledInputWrapper getOwnerProps={getOwnerProps}>\n <StyledInputWidthReference innerRef={spanReference}>{spanReferenceText}</StyledInputWidthReference>\n {showPlaceholder && (\n <StyledInputPlaceHolder\n variant=\"b2\"\n component=\"span\"\n getOwnerProps={getOwnerProps}\n aria-hidden=\"true\"\n $nonInteractive={isNonInteractive}\n >\n <TruncatedText value={showPlaceholder} />\n </StyledInputPlaceHolder>\n )}\n\n {/* The purpose of this div is to always have the 'combo-listbox-{uid}' present in the DOM */}\n {/* Fix for PUI-11597 */}\n {menuState === false && !inline ? <StyledHiddenDiv id={`combo-listbox-${instanceUid}`}></StyledHiddenDiv> : null}\n\n {/* The announcement of currentPlaceholder is being overridden by the value of actualAriaDescribedBy */}\n {/* and since this variable is necessary for the annoucement of FormLayoutBlockItem error and feedback */}\n {/* messages, we concatenate the value of actualPlaceholder with that aria description */}\n {/* Fix for PUI-9609 */}\n <StyledHiddenDiv id={`${id}_current_placeholder`}>{currentPlaceholder}</StyledHiddenDiv>\n\n {/* Read-only helper referenced by aria-describedby. Plain hidden <p>, not a styled slot: a new slot would */}\n {/* need a full slot contract. Rendered once per combobox (this component is the only input owner). */}\n {readOnly ? (\n <p hidden id={readOnlyHelperId}>\n Read only\n </p>\n ) : null}\n\n <StyledInput\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n onBlur={handleOnBlur}\n onFocus={handleOnFocus}\n readOnly={readOnly || onlySelectable}\n {...omitLockedHandlers(globalAttrs, isNonInteractive, 'change')}\n id={id}\n data-testid={ComboboxDataTestid.INPUT}\n autoFocus={autoFocus}\n placeholder={currentPlaceholder}\n aria-activedescendant={activeDescendant}\n aria-expanded={menuState}\n aria-controls={`combo-listbox-${instanceUid}`}\n aria-describedby={actualAriaDescribedBy}\n aria-autocomplete=\"list\"\n role=\"combobox\"\n disabled={disabled}\n applyAriaDisabled={Boolean(applyAriaDisabled || readOnly)}\n style={{ width }}\n innerRef={mergeRefs(innerRef, internalRef)}\n value={inputValue}\n type=\"text\"\n onKeyDown={onInputKeyDown}\n onChange={handleOnChange}\n tabIndex={tabIndex}\n withoutCaret={onlySelectable ?? false}\n autoComplete=\"off\"\n aria-disabled={resolveAriaDisabled({\n disabled,\n softLocked: isLocked({ applyAriaDisabled, readOnly }),\n consumerValue: globalAttrs['aria-disabled'],\n })}\n />\n {/* This input is used to handle the paste event */}\n <StyleHiddenInput\n type=\"text\"\n disabled={disabled}\n readOnly={Boolean(applyAriaDisabled || readOnly)}\n name=\"hidden\"\n tabIndex={-1}\n onPaste={handleOnPaste}\n aria-hidden=\"true\"\n $applyAriaDisabled={Boolean(applyAriaDisabled || readOnly)}\n />\n </StyledInputWrapper>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD0GnB;AA1GJ,mBAA2C;AAC3C,8BAMO;AACP,uBAA0B;AAC1B,2BAA8B;AAC9B,yBAAgC;AAChC,iCAAmC;AACnC,wBAA+B;AAC/B,oBAOO;AACP,8BAAiC;AACjC,mCAAsC;AACtC,wBAAuC;AAIhC,MAAM,gBAAgB,MAAmB;AAC9C,QAAM;AAAA,IACJ;AAAA,IACA,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AA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,QACP,MAAK;AAAA,QACL,WAAW;AAAA,QACX,UAAU;AAAA,QACV;AAAA,QACA,cAAc,kBAAkB;AAAA,QAChC,cAAa;AAAA,QACb,qBAAe,6CAAoB;AAAA,UACjC;AAAA,UACA,gBAAY,kCAAS,EAAE,mBAAmB,SAAS,CAAC;AAAA,UACpD,eAAe,YAAY,eAAe;AAAA,QAC5C,CAAC;AAAA;AAAA,IACH;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL;AAAA,QACA,UAAU,QAAQ,qBAAqB,QAAQ;AAAA,QAC/C,MAAK;AAAA,QACL,UAAU;AAAA,QACV,SAAS;AAAA,QACT,eAAY;AAAA,QACZ,oBAAoB,QAAQ,qBAAqB,QAAQ;AAAA;AAAA,IAC3D;AAAA,KACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -63,7 +63,7 @@ const StyleHiddenInput = (0, import_ds_system.styled)("input")`
|
|
|
63
63
|
&:focus {
|
|
64
64
|
outline: none;
|
|
65
65
|
}
|
|
66
|
-
${
|
|
66
|
+
${import_ds_system.lockedStateInteractionCss}
|
|
67
67
|
`;
|
|
68
68
|
const StyledInput = (0, import_ds_system.styled)("input", {
|
|
69
69
|
name: import_constants.DSFormComboboxName,
|
|
@@ -85,7 +85,10 @@ const StyledInput = (0, import_ds_system.styled)("input", {
|
|
|
85
85
|
color: transparent;
|
|
86
86
|
}
|
|
87
87
|
transition: none;
|
|
88
|
-
${({ applyAriaDisabled }) => applyAriaDisabled && `
|
|
88
|
+
${({ applyAriaDisabled }) => applyAriaDisabled && import_ds_system.css`
|
|
89
|
+
${import_ds_system.ariaDisabledInteractionCss}
|
|
90
|
+
caret-color: transparent;
|
|
91
|
+
`}
|
|
89
92
|
`;
|
|
90
93
|
const StyledInputPlaceHolder = (0, import_ds_system.styled)(import_ds_typography.DSTypography, {
|
|
91
94
|
name: import_constants.DSFormComboboxName,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/controls-input/styled.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import { styled, css } from '@elliemae/ds-system';\nimport { DSTypography, typographyFontFamily } from '@elliemae/ds-typography';\nimport { DSFormComboboxName, FORM_COMBOBOX_SLOTS } from '../../constants/index.js';\n\n/**\n * b2 typography mirrored as raw CSS for the native `<input>` and its hidden\n * width-measuring twin (`StyledInputWidthReference`). Neither can be a `DSTypography`\n * component \u2014 an `<input>` takes no children, and the reference must match the input's\n * exact font metrics or the autosizing (measured off the reference) drifts. ds-typography\n * does not export its VARIANTS_CSS_MAP, so the b2 values are duplicated here \u2014 keep in\n * sync with `ds-typography` b2 (`parts/variants/body.ts`). Text containers that CAN hold\n * children (placeholder, selection) use `styled(DSTypography)` with `variant=\"b2\"` instead.\n *\n * PUI-18977 \u2014 `typographyFontFamily` leads the block, as it does in b2 itself; without it\n * the input never resolves `theme.fonts.default`. It belongs in this shared block rather\n * than on `StyledInput` alone because font-family changes measured text width \u2014 the\n * reference twin must carry the identical family or the autosizing drifts. Precedent:\n * ds-form-input-text (PUI-18721).\n */\nconst b2InputTypography = css`\n ${typographyFontFamily}\n font-size: 0.8125rem;\n line-height: 1rem;\n font-weight: 400;\n @media (min-width: ${({ theme }) => theme.breakpoints.small}) {\n font-size: 1rem;\n line-height: 1.2307692308rem;\n }\n`;\n\nexport const StyleHiddenInput = styled('input')<{
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,
|
|
4
|
+
"sourcesContent": ["import { styled, css, ariaDisabledInteractionCss, lockedStateInteractionCss } from '@elliemae/ds-system';\nimport { DSTypography, typographyFontFamily } from '@elliemae/ds-typography';\nimport { DSFormComboboxName, FORM_COMBOBOX_SLOTS } from '../../constants/index.js';\n\n/**\n * b2 typography mirrored as raw CSS for the native `<input>` and its hidden\n * width-measuring twin (`StyledInputWidthReference`). Neither can be a `DSTypography`\n * component \u2014 an `<input>` takes no children, and the reference must match the input's\n * exact font metrics or the autosizing (measured off the reference) drifts. ds-typography\n * does not export its VARIANTS_CSS_MAP, so the b2 values are duplicated here \u2014 keep in\n * sync with `ds-typography` b2 (`parts/variants/body.ts`). Text containers that CAN hold\n * children (placeholder, selection) use `styled(DSTypography)` with `variant=\"b2\"` instead.\n *\n * PUI-18977 \u2014 `typographyFontFamily` leads the block, as it does in b2 itself; without it\n * the input never resolves `theme.fonts.default`. It belongs in this shared block rather\n * than on `StyledInput` alone because font-family changes measured text width \u2014 the\n * reference twin must carry the identical family or the autosizing drifts. Precedent:\n * ds-form-input-text (PUI-18721).\n */\nconst b2InputTypography = css`\n ${typographyFontFamily}\n font-size: 0.8125rem;\n line-height: 1rem;\n font-weight: 400;\n @media (min-width: ${({ theme }) => theme.breakpoints.small}) {\n font-size: 1rem;\n line-height: 1.2307692308rem;\n }\n`;\n\nexport const StyleHiddenInput = styled('input')<{ $applyAriaDisabled: boolean }>`\n color: transparent;\n position: absolute;\n top: 0;\n left: 0;\n z-index: 2;\n border: none;\n outline: none;\n background: transparent;\n width: 100%;\n &:focus {\n outline: none;\n }\n ${lockedStateInteractionCss}\n`;\n\nexport const StyledInput = styled('input', {\n name: DSFormComboboxName,\n slot: FORM_COMBOBOX_SLOTS.INPUT,\n})<{ withoutCaret: boolean; applyAriaDisabled: boolean }>`\n ${b2InputTypography}\n background: transparent;\n border: none;\n overflow: hidden;\n padding: 0;\n z-index: 2;\n outline: none;\n color: ${(props) => (props.disabled ? props.theme.colors.neutral[600] : props.theme.colors.neutral[700])};\n &:focus {\n outline: none;\n }\n ${({ withoutCaret }) => withoutCaret && 'caret-color: transparent;'}\n &::placeholder {\n color: transparent;\n }\n transition: none;\n ${({ applyAriaDisabled }) =>\n applyAriaDisabled &&\n css`\n ${ariaDisabledInteractionCss}\n caret-color: transparent;\n `}\n`;\n\nexport const StyledInputPlaceHolder = styled(DSTypography, {\n name: DSFormComboboxName,\n slot: FORM_COMBOBOX_SLOTS.INPUT_PLACEHOLDER,\n})<{ $nonInteractive?: boolean }>`\n font-style: italic;\n color: ${(props) => (props.$nonInteractive ? props.theme.colors.neutral[600] : props.theme.colors.neutral[500])};\n position: absolute;\n display: flex;\n align-items: center;\n width: 100%;\n user-select: none;\n\n & span::after {\n content: '';\n padding: 1px;\n // solve italic font style clipping issue with overflow hidden.\n }\n`;\n\nexport const StyledInputWidthReference = styled.span`\n ${b2InputTypography}\n visibility: hidden;\n position: absolute;\n top: -9999px;\n z-index: 1;\n`;\n\nexport const StyledInputWrapper = styled('div', {\n name: DSFormComboboxName,\n slot: FORM_COMBOBOX_SLOTS.INPUT_FIELD_WRAPPER,\n})`\n position: relative;\n align-items: center;\n display: flex;\n /** PUI-15490 \u2014 the spec's 5px vertical padding lives on the text line (this wrapper, always\n * rendered) so the control height is constant and breathing room survives text resize.\n * Mobile keeps the legacy 1.25px \u2014 no mobile spec exists (KNOWN_INTENTIONAL_DEVIATIONS \u00A75).\n * The 1px right padding is pre-existing (caret clipping). */\n padding: 5px 1px 5px 0px;\n @media (max-width: ${({ theme }) => theme.breakpoints.small}) {\n padding: 1.25px 1px 1.25px 0px;\n }\n overflow: hidden;\n`;\n\nexport const StyledHiddenDiv = styled('div')`\n display: none;\n`;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAAmF;AACnF,2BAAmD;AACnD,uBAAwD;AAiBxD,MAAM,oBAAoB;AAAA,IACtB,yCAAoB;AAAA;AAAA;AAAA;AAAA,uBAID,CAAC,EAAE,MAAM,MAAM,MAAM,YAAY,KAAK;AAAA;AAAA;AAAA;AAAA;AAMtD,MAAM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
@@ -33,6 +33,7 @@ __export(useKeyboardNavigation_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(useKeyboardNavigation_exports);
|
|
34
34
|
var React = __toESM(require("react"));
|
|
35
35
|
var import_react = require("react");
|
|
36
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
36
37
|
var import_ComboBoxCTX = require("../../ComboBoxCTX.js");
|
|
37
38
|
var import_listHelper = require("../../utils/listHelper.js");
|
|
38
39
|
var import_constants = require("../../constants.js");
|
|
@@ -54,8 +55,6 @@ const useKeyboardNavigation = () => {
|
|
|
54
55
|
selectedValues,
|
|
55
56
|
withoutPortal,
|
|
56
57
|
onlySelectable,
|
|
57
|
-
applyAriaDisabled,
|
|
58
|
-
readOnly,
|
|
59
58
|
isMenuOpenableWithReadOnly
|
|
60
59
|
},
|
|
61
60
|
inputValue,
|
|
@@ -66,7 +65,9 @@ const useKeyboardNavigation = () => {
|
|
|
66
65
|
setMenuState,
|
|
67
66
|
setInputValue,
|
|
68
67
|
scrollOptionIntoView,
|
|
69
|
-
setFocusOptionIdx
|
|
68
|
+
setFocusOptionIdx,
|
|
69
|
+
isInteractionLocked,
|
|
70
|
+
isMenuOpeningLocked
|
|
70
71
|
} = (0, import_react.useContext)(import_ComboBoxCTX.ComboBoxContext);
|
|
71
72
|
const multiple = Array.isArray(selectedValues);
|
|
72
73
|
const selectableOptions = (0, import_listHelper.getOptions)(filteredOptions);
|
|
@@ -74,9 +75,11 @@ const useKeyboardNavigation = () => {
|
|
|
74
75
|
const currentItem = filteredOptions.find((item) => item.dsId === focusOptionIdx);
|
|
75
76
|
const onInputKeyDown = (0, import_react.useCallback)(
|
|
76
77
|
(e) => {
|
|
77
|
-
if (
|
|
78
|
-
if (onKeyDown && currentItem?.type === import_constants.MENU_OPTION_TYPES.OPTION
|
|
79
|
-
|
|
78
|
+
if (disabled) return;
|
|
79
|
+
if (onKeyDown && currentItem?.type === import_constants.MENU_OPTION_TYPES.OPTION && !(isInteractionLocked && (0, import_ds_props_helpers.isActivationKey)(e))) {
|
|
80
|
+
onKeyDown(e, currentItem);
|
|
81
|
+
}
|
|
82
|
+
if (["ArrowDown", "ArrowUp", "Enter", "Spacebar"].includes(e.key) && !menuState && !isMenuOpeningLocked) {
|
|
80
83
|
setMenuState(true, import_constants.MENU_CONTROL_REASONS.OPEN, e);
|
|
81
84
|
}
|
|
82
85
|
if (e.key === "Escape") {
|
|
@@ -87,7 +90,7 @@ const useKeyboardNavigation = () => {
|
|
|
87
90
|
}
|
|
88
91
|
if (!inline) setMenuState(false, import_constants.MENU_CONTROL_REASONS.CLOSE, e);
|
|
89
92
|
}
|
|
90
|
-
if (!
|
|
93
|
+
if (!isInteractionLocked && e.key === "Enter" && currentItem?.type === import_constants.INTERNAL_MENU_OPTION_TYPES.CREATABLE && onCreate) {
|
|
91
94
|
e.preventDefault();
|
|
92
95
|
e.stopPropagation();
|
|
93
96
|
onCreate(inputValue);
|
|
@@ -101,8 +104,8 @@ const useKeyboardNavigation = () => {
|
|
|
101
104
|
setMenuState(true, import_constants.MENU_CONTROL_REASONS.OPEN, e);
|
|
102
105
|
}
|
|
103
106
|
}
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
const isSelectionKey = e.key === "Enter" || e.key === " " && e.altKey || e.key === "Tab" && !multiple && !inline;
|
|
108
|
+
if (isSelectionKey && !isInteractionLocked && !(0, import_listHelper.isOptionLocked)(currentItem)) {
|
|
106
109
|
if (e.key !== "Tab") e.preventDefault();
|
|
107
110
|
e.stopPropagation();
|
|
108
111
|
if (focusOptionIdx !== "" && (menuState || inline) && currentItem?.type === import_constants.MENU_OPTION_TYPES.OPTION && !currentItem.disabled) {
|
|
@@ -121,7 +124,7 @@ const useKeyboardNavigation = () => {
|
|
|
121
124
|
if (e.key === "Enter" && e.altKey) {
|
|
122
125
|
setMenuState(false, "selectOption", e);
|
|
123
126
|
}
|
|
124
|
-
if (e.key === "a" && e.ctrlKey && multiple && onSelectAll) {
|
|
127
|
+
if (e.key === "a" && e.ctrlKey && multiple && onSelectAll && !isInteractionLocked) {
|
|
125
128
|
onSelectAll(
|
|
126
129
|
filteredOptions.filter(
|
|
127
130
|
(option) => option.type === "option" && !option.disabled
|
|
@@ -154,7 +157,7 @@ const useKeyboardNavigation = () => {
|
|
|
154
157
|
if (menuState || inline) {
|
|
155
158
|
setFocusOptionIdx(filteredOptions[prevItemIndex].dsId);
|
|
156
159
|
scrollOptionIntoView(filteredOptions[prevItemIndex].dsId);
|
|
157
|
-
} else {
|
|
160
|
+
} else if (!isMenuOpeningLocked) {
|
|
158
161
|
setMenuState(true, import_constants.MENU_CONTROL_REASONS.OPEN, e);
|
|
159
162
|
const lastItemIndex = (0, import_listHelper.findInCircularList)(filteredOptions, 0, isOptionFocuseable, -1);
|
|
160
163
|
setFocusOptionIdx(filteredOptions[lastItemIndex].dsId);
|
|
@@ -165,9 +168,9 @@ const useKeyboardNavigation = () => {
|
|
|
165
168
|
}
|
|
166
169
|
}
|
|
167
170
|
if (e.key === "Backspace" && e.currentTarget.value.length <= 0 && !inline) {
|
|
168
|
-
if (
|
|
171
|
+
if (isInteractionLocked) return;
|
|
169
172
|
const lastValue = (0, import_listHelper.getLastValueSelected)(selectedValues);
|
|
170
|
-
if (!e.currentTarget.value && lastValue && !isNonClearable && !
|
|
173
|
+
if (!e.currentTarget.value && lastValue && !isNonClearable && !(0, import_listHelper.isOptionLocked)(lastValue)) {
|
|
171
174
|
onChange(
|
|
172
175
|
(0, import_listHelper.getSuggestedValueOnChange)(lastValue, selectedValues),
|
|
173
176
|
lastValue,
|
|
@@ -179,7 +182,7 @@ const useKeyboardNavigation = () => {
|
|
|
179
182
|
setMenuState(false, import_constants.MENU_CONTROL_REASONS.BLUR, e);
|
|
180
183
|
}
|
|
181
184
|
if (onlySelectable && /^[a-zA-Z\d]$/.test(e.key)) {
|
|
182
|
-
if (!menuState) {
|
|
185
|
+
if (!menuState && !isMenuOpeningLocked) {
|
|
183
186
|
setMenuState(true, import_constants.MENU_CONTROL_REASONS.OPEN, e);
|
|
184
187
|
}
|
|
185
188
|
const isOptionFocusableByLetter = (opt) => isOptionFocuseable(opt) && optionHasFirstLetter(opt, e.key);
|
|
@@ -192,6 +195,7 @@ const useKeyboardNavigation = () => {
|
|
|
192
195
|
},
|
|
193
196
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
194
197
|
[
|
|
198
|
+
disabled,
|
|
195
199
|
onKeyDown,
|
|
196
200
|
currentItem,
|
|
197
201
|
onCreate,
|
|
@@ -212,7 +216,10 @@ const useKeyboardNavigation = () => {
|
|
|
212
216
|
setFocusOptionIdx,
|
|
213
217
|
selectedValues,
|
|
214
218
|
onChange,
|
|
215
|
-
isNonClearable
|
|
219
|
+
isNonClearable,
|
|
220
|
+
isInteractionLocked,
|
|
221
|
+
isMenuOpeningLocked,
|
|
222
|
+
isMenuOpenableWithReadOnly
|
|
216
223
|
]
|
|
217
224
|
);
|
|
218
225
|
return { onInputKeyDown };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/controls-input/useKeyboardNavigation.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable max-depth */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { useCallback, useContext } from 'react';\nimport type { DSComboboxT } from '../../react-desc-prop-types.js';\nimport { ComboBoxContext } from '../../ComboBoxCTX.js';\nimport {\n findInCircularList,\n getOptions,\n getSuggestedValueOnChange,\n getLastValueSelected,\n} from '../../utils/listHelper.js';\nimport type { DSCommonComboboxPropsT } from '../../DSCommonComboboxPropsT.js';\nimport { INTERNAL_MENU_OPTION_TYPES, MENU_OPTION_TYPES, MENU_CONTROL_REASONS } from '../../constants.js';\nconst isOptionFocuseable = (opt: DSComboboxT.OptionTypes): boolean => !['section', 'separator'].includes(opt.type);\n\nconst optionHasFirstLetter = (opt: DSComboboxT.OptionTypes, letter: string): boolean =>\n opt.label !== undefined && opt.label.toLowerCase().startsWith(letter.toLowerCase());\n\nexport const useKeyboardNavigation = () => {\n const {\n props: {\n allOptions,\n isNonClearable,\n onCancel,\n disabled,\n onKeyDown,\n onChange,\n onCreate,\n onFilter,\n onSelectAll,\n inline,\n selectedValues,\n withoutPortal,\n onlySelectable,\n applyAriaDisabled,\n readOnly,\n isMenuOpenableWithReadOnly,\n },\n inputValue,\n correctOptions: filteredOptions,\n menuState,\n focusOptionIdx,\n listRef,\n setMenuState,\n setInputValue,\n scrollOptionIntoView,\n setFocusOptionIdx,\n } = useContext(ComboBoxContext);\n\n const multiple = Array.isArray(selectedValues);\n const selectableOptions = getOptions(filteredOptions);\n const currentItemIndex = filteredOptions.findIndex((opt) => opt.dsId === focusOptionIdx);\n const currentItem = filteredOptions.find((item) => item.dsId === focusOptionIdx);\n\n const onInputKeyDown: React.KeyboardEventHandler<HTMLInputElement> = useCallback(\n (e) => {\n if (applyAriaDisabled || (readOnly && !isMenuOpenableWithReadOnly) || disabled) return;\n\n // =============================================================================\n // CUSTOM KEYS\n // =============================================================================\n if (onKeyDown && currentItem?.type === MENU_OPTION_TYPES.OPTION) onKeyDown(e, currentItem);\n\n if (['ArrowDown', 'ArrowUp', 'Enter', 'Spacebar'].includes(e.key) && !menuState) {\n setMenuState(true, MENU_CONTROL_REASONS.OPEN, e);\n }\n // =============================================================================\n // ESCAPE\n // =============================================================================\n if (e.key === 'Escape') {\n if (onCancel) onCancel();\n if (inputValue) {\n if (onFilter) onFilter(allOptions, inputValue);\n setInputValue('');\n }\n if (!inline) setMenuState(false, MENU_CONTROL_REASONS.CLOSE, e);\n }\n // =============================================================================\n // ENTER KEY TO CREATE ELEMENTS\n // =============================================================================\n if (!readOnly && e.key === 'Enter' && currentItem?.type === INTERNAL_MENU_OPTION_TYPES.CREATABLE && onCreate) {\n e.preventDefault();\n e.stopPropagation();\n onCreate(inputValue);\n // blank active item to force search last one\n setFocusOptionIdx('');\n if (onFilter) onFilter(allOptions, '');\n setInputValue('');\n return;\n }\n\n // the following code is wrong but kept for backward compatibility to avoid breaking changes\n // when readonly the idea is not to open the menu when typing but currently it opens the menu\n // =============================================================================\n // OPEN MENU ON TYPE WHEN READONLY AND ISMENUOPENABLEWITHREADONLY IS TRUE\n // =============================================================================\n if (isMenuOpenableWithReadOnly && e.key.length === 1 && !e.ctrlKey && !e.altKey && !e.metaKey) {\n if (!menuState) {\n setMenuState(true, MENU_CONTROL_REASONS.OPEN, e);\n }\n }\n\n // =============================================================================\n // Enter, space and Tab on selection\n // =============================================================================\n if (e.key === 'Enter' || (e.key === ' ' && e.altKey) || (e.key === 'Tab' && !multiple && !inline)) {\n if (readOnly || currentItem?.applyAriaDisabled) return;\n\n if (e.key !== 'Tab') e.preventDefault();\n e.stopPropagation();\n\n if (\n focusOptionIdx !== '' &&\n (menuState || inline) &&\n currentItem?.type === MENU_OPTION_TYPES.OPTION &&\n !currentItem.disabled\n ) {\n if (onFilter) onFilter(allOptions, '');\n setInputValue('');\n if (!multiple) {\n setMenuState(false, MENU_CONTROL_REASONS.SELECT_OPTION, e);\n }\n // DSComboboxT.InternalProps is a conditional type that can't be resolved without an explicit type\n // parameter, so TypeScript treats onChange as a union of functions and requires intersection params.\n // The cast to SelectedOptionsT is safe \u2014 getSuggestedValueOnChange handles both multi/single at runtime.\n (onChange as (v: DSComboboxT.SelectedOptionsT, ...args: unknown[]) => void)(\n getSuggestedValueOnChange(currentItem, selectedValues, isNonClearable),\n currentItem,\n e,\n );\n }\n }\n\n if (e.key === 'Enter' && e.altKey) {\n setMenuState(false, 'selectOption', e);\n }\n\n if (e.key === 'a' && e.ctrlKey && multiple && onSelectAll) {\n onSelectAll(\n filteredOptions.filter(\n (option) => option.type === 'option' && !option.disabled,\n ) as DSCommonComboboxPropsT.SelectionableOptions[],\n e,\n );\n }\n // =============================================================================\n // ARROWS UP AND DOWN: LOGIC TO CALCULATE NEXT OR PREV ITEM TO PSEUDOFOCUS FROM INPUT\n // =============================================================================\n\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n e.stopPropagation();\n if ((menuState || inline) && (selectableOptions.length || onCreate)) {\n const nextItemIndexIndex = findInCircularList(filteredOptions, currentItemIndex, isOptionFocuseable);\n if (nextItemIndexIndex > -1) {\n setFocusOptionIdx(filteredOptions[nextItemIndexIndex].dsId);\n scrollOptionIntoView(filteredOptions[nextItemIndexIndex].dsId);\n }\n }\n }\n if (e.key === 'ArrowUp') {\n e.preventDefault();\n e.stopPropagation();\n if (!selectableOptions.length && !onCreate) return;\n const prevItemIndex = findInCircularList(\n filteredOptions,\n currentItemIndex === -1 ? 0 : currentItemIndex,\n isOptionFocuseable,\n -1,\n );\n if (prevItemIndex > -1) {\n if (menuState || inline) {\n setFocusOptionIdx(filteredOptions[prevItemIndex].dsId);\n scrollOptionIntoView(filteredOptions[prevItemIndex].dsId);\n } else {\n // open menu and search last item to focused\n setMenuState(true, MENU_CONTROL_REASONS.OPEN, e);\n const lastItemIndex = findInCircularList(filteredOptions, 0, isOptionFocuseable, -1);\n setFocusOptionIdx(filteredOptions[lastItemIndex].dsId);\n setTimeout(() => {\n scrollOptionIntoView(filteredOptions[lastItemIndex].dsId);\n });\n }\n }\n }\n\n // =============================================================================\n // BACKSPACE\n // =============================================================================\n if (e.key === 'Backspace' && e.currentTarget.value.length <= 0 && !inline) {\n if (readOnly) return;\n const lastValue = getLastValueSelected(selectedValues);\n if (!e.currentTarget.value && lastValue && !isNonClearable && !lastValue.applyAriaDisabled) {\n (onChange as (v: DSComboboxT.SelectedOptionsT, ...args: unknown[]) => void)(\n getSuggestedValueOnChange(lastValue, selectedValues),\n lastValue,\n e,\n );\n }\n }\n\n if (e.key === 'Tab' && !inline && menuState) {\n setMenuState(false, MENU_CONTROL_REASONS.BLUR, e);\n }\n\n // =============================================================================\n // ONLYSELECTABLE LETTER/NUMBER KEYS TO FOCUS OPTIONS\n // =============================================================================\n\n if (onlySelectable && /^[a-zA-Z\\d]$/.test(e.key)) {\n if (!menuState) {\n setMenuState(true, MENU_CONTROL_REASONS.OPEN, e);\n }\n\n const isOptionFocusableByLetter = (opt: DSComboboxT.OptionTypes): boolean =>\n isOptionFocuseable(opt) && optionHasFirstLetter(opt, e.key);\n\n const nextItemIndexIndex = findInCircularList(filteredOptions, currentItemIndex, isOptionFocusableByLetter);\n const nextItem = filteredOptions[nextItemIndexIndex];\n if (!nextItem) return;\n setFocusOptionIdx(filteredOptions[nextItemIndexIndex].dsId);\n scrollOptionIntoView(filteredOptions[nextItemIndexIndex].dsId);\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n onKeyDown,\n currentItem,\n onCreate,\n multiple,\n inputValue,\n inline,\n withoutPortal,\n setMenuState,\n onCancel,\n onFilter,\n setInputValue,\n listRef,\n focusOptionIdx,\n menuState,\n selectableOptions.length,\n filteredOptions,\n currentItemIndex,\n setFocusOptionIdx,\n selectedValues,\n onChange,\n isNonClearable,\n ],\n );\n\n return { onInputKeyDown };\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADIvB,mBAAwC;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable max-depth */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { useCallback, useContext } from 'react';\nimport { isActivationKey } from '@elliemae/ds-props-helpers';\nimport type { DSComboboxT } from '../../react-desc-prop-types.js';\nimport { ComboBoxContext } from '../../ComboBoxCTX.js';\nimport {\n findInCircularList,\n getOptions,\n getSuggestedValueOnChange,\n getLastValueSelected,\n isOptionLocked,\n} from '../../utils/listHelper.js';\nimport type { DSCommonComboboxPropsT } from '../../DSCommonComboboxPropsT.js';\nimport { INTERNAL_MENU_OPTION_TYPES, MENU_OPTION_TYPES, MENU_CONTROL_REASONS } from '../../constants.js';\nconst isOptionFocuseable = (opt: DSComboboxT.OptionTypes): boolean => !['section', 'separator'].includes(opt.type);\n\n// the generic lock rule: the consumer onKeyDown does not receive the activation keys while locked (`isActivationKey`).\n// Every other key, Backspace, Delete and Ctrl+A included, is only observed: the component's own removal and select-all\n// are gated below.\n\nconst optionHasFirstLetter = (opt: DSComboboxT.OptionTypes, letter: string): boolean =>\n opt.label !== undefined && opt.label.toLowerCase().startsWith(letter.toLowerCase());\n\nexport const useKeyboardNavigation = () => {\n const {\n props: {\n allOptions,\n isNonClearable,\n onCancel,\n disabled,\n onKeyDown,\n onChange,\n onCreate,\n onFilter,\n onSelectAll,\n inline,\n selectedValues,\n withoutPortal,\n onlySelectable,\n isMenuOpenableWithReadOnly,\n },\n inputValue,\n correctOptions: filteredOptions,\n menuState,\n focusOptionIdx,\n listRef,\n setMenuState,\n setInputValue,\n scrollOptionIntoView,\n setFocusOptionIdx,\n isInteractionLocked,\n isMenuOpeningLocked,\n } = useContext(ComboBoxContext);\n\n const multiple = Array.isArray(selectedValues);\n const selectableOptions = getOptions(filteredOptions);\n const currentItemIndex = filteredOptions.findIndex((opt) => opt.dsId === focusOptionIdx);\n const currentItem = filteredOptions.find((item) => item.dsId === focusOptionIdx);\n\n const onInputKeyDown: React.KeyboardEventHandler<HTMLInputElement> = useCallback(\n (e) => {\n // disabled blocks every key. applyAriaDisabled and readOnly keep focus and navigation (arrows, Tab, Escape)\n // and block every key that opens an option or changes the value (PUI-16695). They block the keys that open the\n // menu too, unless isMenuOpenableWithReadOnly is set: then the arrows, Enter and Space open it to be read.\n if (disabled) return;\n\n // =============================================================================\n // CUSTOM KEYS\n // =============================================================================\n if (onKeyDown && currentItem?.type === MENU_OPTION_TYPES.OPTION && !(isInteractionLocked && isActivationKey(e))) {\n onKeyDown(e, currentItem);\n }\n\n if (['ArrowDown', 'ArrowUp', 'Enter', 'Spacebar'].includes(e.key) && !menuState && !isMenuOpeningLocked) {\n setMenuState(true, MENU_CONTROL_REASONS.OPEN, e);\n }\n // =============================================================================\n // ESCAPE\n // =============================================================================\n if (e.key === 'Escape') {\n if (onCancel) onCancel();\n if (inputValue) {\n if (onFilter) onFilter(allOptions, inputValue);\n setInputValue('');\n }\n if (!inline) setMenuState(false, MENU_CONTROL_REASONS.CLOSE, e);\n }\n // =============================================================================\n // ENTER KEY TO CREATE ELEMENTS\n // =============================================================================\n if (\n !isInteractionLocked &&\n e.key === 'Enter' &&\n currentItem?.type === INTERNAL_MENU_OPTION_TYPES.CREATABLE &&\n onCreate\n ) {\n e.preventDefault();\n e.stopPropagation();\n onCreate(inputValue);\n // blank active item to force search last one\n setFocusOptionIdx('');\n if (onFilter) onFilter(allOptions, '');\n setInputValue('');\n return;\n }\n\n // under a soft lock (applyAriaDisabled or readOnly) typing opens the menu only when the consumer opts in with\n // isMenuOpenableWithReadOnly: opening is view-only, what the menu holds stays locked\n // =============================================================================\n // OPEN MENU ON TYPE WHEN READONLY AND ISMENUOPENABLEWITHREADONLY IS TRUE\n // =============================================================================\n if (isMenuOpenableWithReadOnly && e.key.length === 1 && !e.ctrlKey && !e.altKey && !e.metaKey) {\n if (!menuState) {\n setMenuState(true, MENU_CONTROL_REASONS.OPEN, e);\n }\n }\n\n // =============================================================================\n // Enter, space and Tab on selection\n // =============================================================================\n const isSelectionKey =\n e.key === 'Enter' || (e.key === ' ' && e.altKey) || (e.key === 'Tab' && !multiple && !inline);\n if (isSelectionKey && !isInteractionLocked && !isOptionLocked(currentItem)) {\n if (e.key !== 'Tab') e.preventDefault();\n e.stopPropagation();\n\n if (\n focusOptionIdx !== '' &&\n (menuState || inline) &&\n currentItem?.type === MENU_OPTION_TYPES.OPTION &&\n !currentItem.disabled\n ) {\n if (onFilter) onFilter(allOptions, '');\n setInputValue('');\n if (!multiple) {\n setMenuState(false, MENU_CONTROL_REASONS.SELECT_OPTION, e);\n }\n // DSComboboxT.InternalProps is a conditional type that can't be resolved without an explicit type\n // parameter, so TypeScript treats onChange as a union of functions and requires intersection params.\n // The cast to SelectedOptionsT is safe \u2014 getSuggestedValueOnChange handles both multi/single at runtime.\n (onChange as (v: DSComboboxT.SelectedOptionsT, ...args: unknown[]) => void)(\n getSuggestedValueOnChange(currentItem, selectedValues, isNonClearable),\n currentItem,\n e,\n );\n }\n }\n\n if (e.key === 'Enter' && e.altKey) {\n setMenuState(false, 'selectOption', e);\n }\n\n if (e.key === 'a' && e.ctrlKey && multiple && onSelectAll && !isInteractionLocked) {\n onSelectAll(\n filteredOptions.filter(\n (option) => option.type === 'option' && !option.disabled,\n ) as DSCommonComboboxPropsT.SelectionableOptions[],\n e,\n );\n }\n // =============================================================================\n // ARROWS UP AND DOWN: LOGIC TO CALCULATE NEXT OR PREV ITEM TO PSEUDOFOCUS FROM INPUT\n // =============================================================================\n\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n e.stopPropagation();\n if ((menuState || inline) && (selectableOptions.length || onCreate)) {\n const nextItemIndexIndex = findInCircularList(filteredOptions, currentItemIndex, isOptionFocuseable);\n if (nextItemIndexIndex > -1) {\n setFocusOptionIdx(filteredOptions[nextItemIndexIndex].dsId);\n scrollOptionIntoView(filteredOptions[nextItemIndexIndex].dsId);\n }\n }\n }\n if (e.key === 'ArrowUp') {\n e.preventDefault();\n e.stopPropagation();\n if (!selectableOptions.length && !onCreate) return;\n const prevItemIndex = findInCircularList(\n filteredOptions,\n currentItemIndex === -1 ? 0 : currentItemIndex,\n isOptionFocuseable,\n -1,\n );\n if (prevItemIndex > -1) {\n if (menuState || inline) {\n setFocusOptionIdx(filteredOptions[prevItemIndex].dsId);\n scrollOptionIntoView(filteredOptions[prevItemIndex].dsId);\n } else if (!isMenuOpeningLocked) {\n // open menu and search last item to focused\n setMenuState(true, MENU_CONTROL_REASONS.OPEN, e);\n const lastItemIndex = findInCircularList(filteredOptions, 0, isOptionFocuseable, -1);\n setFocusOptionIdx(filteredOptions[lastItemIndex].dsId);\n setTimeout(() => {\n scrollOptionIntoView(filteredOptions[lastItemIndex].dsId);\n });\n }\n }\n }\n\n // =============================================================================\n // BACKSPACE\n // =============================================================================\n if (e.key === 'Backspace' && e.currentTarget.value.length <= 0 && !inline) {\n if (isInteractionLocked) return;\n const lastValue = getLastValueSelected(selectedValues);\n if (!e.currentTarget.value && lastValue && !isNonClearable && !isOptionLocked(lastValue)) {\n (onChange as (v: DSComboboxT.SelectedOptionsT, ...args: unknown[]) => void)(\n getSuggestedValueOnChange(lastValue, selectedValues),\n lastValue,\n e,\n );\n }\n }\n\n if (e.key === 'Tab' && !inline && menuState) {\n setMenuState(false, MENU_CONTROL_REASONS.BLUR, e);\n }\n\n // =============================================================================\n // ONLYSELECTABLE LETTER/NUMBER KEYS TO FOCUS OPTIONS\n // =============================================================================\n\n if (onlySelectable && /^[a-zA-Z\\d]$/.test(e.key)) {\n if (!menuState && !isMenuOpeningLocked) {\n setMenuState(true, MENU_CONTROL_REASONS.OPEN, e);\n }\n\n const isOptionFocusableByLetter = (opt: DSComboboxT.OptionTypes): boolean =>\n isOptionFocuseable(opt) && optionHasFirstLetter(opt, e.key);\n\n const nextItemIndexIndex = findInCircularList(filteredOptions, currentItemIndex, isOptionFocusableByLetter);\n const nextItem = filteredOptions[nextItemIndexIndex];\n if (!nextItem) return;\n setFocusOptionIdx(filteredOptions[nextItemIndexIndex].dsId);\n scrollOptionIntoView(filteredOptions[nextItemIndexIndex].dsId);\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n disabled,\n onKeyDown,\n currentItem,\n onCreate,\n multiple,\n inputValue,\n inline,\n withoutPortal,\n setMenuState,\n onCancel,\n onFilter,\n setInputValue,\n listRef,\n focusOptionIdx,\n menuState,\n selectableOptions.length,\n filteredOptions,\n currentItemIndex,\n setFocusOptionIdx,\n selectedValues,\n onChange,\n isNonClearable,\n isInteractionLocked,\n isMenuOpeningLocked,\n isMenuOpenableWithReadOnly,\n ],\n );\n\n return { onInputKeyDown };\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA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