@pega/cosmos-react-core 9.0.0-build.12.9 → 9.0.0-build.13.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/lib/components/Actions/Actions.d.ts +1 -0
- package/lib/components/Actions/Actions.d.ts.map +1 -1
- package/lib/components/Actions/Actions.js +28 -4
- package/lib/components/Actions/Actions.js.map +1 -1
- package/lib/components/AppShell/AppShell.types.d.ts +2 -0
- package/lib/components/AppShell/AppShell.types.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.types.js.map +1 -1
- package/lib/components/AppShell/NavigationListItemWrapper.d.ts.map +1 -1
- package/lib/components/AppShell/NavigationListItemWrapper.js +30 -4
- package/lib/components/AppShell/NavigationListItemWrapper.js.map +1 -1
- package/lib/components/Menu/Menu.d.ts.map +1 -1
- package/lib/components/Menu/Menu.js +13 -3
- package/lib/components/Menu/Menu.js.map +1 -1
- package/lib/components/Menu/Menu.styles.d.ts +2 -0
- package/lib/components/Menu/Menu.styles.d.ts.map +1 -1
- package/lib/components/Menu/Menu.styles.js +58 -1
- package/lib/components/Menu/Menu.styles.js.map +1 -1
- package/lib/components/Menu/Menu.types.d.ts +3 -0
- package/lib/components/Menu/Menu.types.d.ts.map +1 -1
- package/lib/components/Menu/Menu.types.js.map +1 -1
- package/lib/components/MenuButton/MenuButton.d.ts.map +1 -1
- package/lib/components/MenuButton/MenuButton.js +12 -2
- package/lib/components/MenuButton/MenuButton.js.map +1 -1
- package/lib/components/TextArea/TextArea.d.ts.map +1 -1
- package/lib/components/TextArea/TextArea.js +2 -12
- package/lib/components/TextArea/TextArea.js.map +1 -1
- package/lib/hooks/useI18n.d.ts +9 -1
- package/lib/hooks/useI18n.d.ts.map +1 -1
- package/lib/i18n/default.d.ts +9 -1
- package/lib/i18n/default.d.ts.map +1 -1
- package/lib/i18n/default.js +9 -1
- package/lib/i18n/default.js.map +1 -1
- package/lib/i18n/i18n.d.ts +9 -1
- package/lib/i18n/i18n.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hideVisually, mix, rgba } from 'polished';
|
|
1
|
+
import { hideVisually, mix, rgba, transparentize } from 'polished';
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
3
|
import { defaultThemeProp } from '../../theme';
|
|
4
4
|
import { StyledEmptyState } from '../EmptyState';
|
|
@@ -13,6 +13,7 @@ import { readableColor } from '../../styles';
|
|
|
13
13
|
import { StyledPrimary, StyledSecondary, StyledSummaryItem, StyledSummaryItemActions, StyledVisual } from '../SummaryItem';
|
|
14
14
|
import { ellipsisOverflow } from '../../styles/mixins';
|
|
15
15
|
import { StyledFlex } from '../Flex';
|
|
16
|
+
import { StyledFormControl } from '../FormControl';
|
|
16
17
|
export const StyledExpandButton = styled(Button) `
|
|
17
18
|
align-self: center;
|
|
18
19
|
`;
|
|
@@ -377,4 +378,60 @@ export const StyledMenu = styled.div(({ theme }) => {
|
|
|
377
378
|
`;
|
|
378
379
|
});
|
|
379
380
|
StyledMenu.defaultProps = defaultThemeProp;
|
|
381
|
+
export const StyledMenuFilter = styled.div(({ theme }) => {
|
|
382
|
+
const borderRadius = `calc(${theme.components['search-input']['border-radius']} * ${theme.base['border-radius']})`;
|
|
383
|
+
return css `
|
|
384
|
+
min-height: ${theme.components.input.height};
|
|
385
|
+
height: ${theme.components.input.height};
|
|
386
|
+
|
|
387
|
+
@media (pointer: coarse) {
|
|
388
|
+
min-height: ${theme.base['hit-area']['finger-min']};
|
|
389
|
+
min-width: ${theme.base['hit-area']['finger-min']};
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
${StyledFormControl} {
|
|
393
|
+
height: 100%;
|
|
394
|
+
border-radius: ${borderRadius};
|
|
395
|
+
padding-inline-start: calc(1.5 * ${theme.components.input.padding});
|
|
396
|
+
padding-inline-end: calc(4 * ${theme.components.input.padding});
|
|
397
|
+
|
|
398
|
+
&::-webkit-search-cancel-button {
|
|
399
|
+
display: none;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
::-webkit-search-decoration {
|
|
403
|
+
-webkit-appearance: none;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
&:focus:not([disabled]) {
|
|
407
|
+
box-shadow: ${theme.base.shadow['focus-inset']};
|
|
408
|
+
border-color: ${theme.components['form-control']['border-color']};
|
|
409
|
+
|
|
410
|
+
:hover {
|
|
411
|
+
border-color: ${theme.components['form-control'][':hover']['border-color']};
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
`;
|
|
416
|
+
});
|
|
417
|
+
StyledMenuFilter.defaultProps = defaultThemeProp;
|
|
418
|
+
export const StyledFilterIcon = styled(Icon)(({ theme }) => {
|
|
419
|
+
const iconColor = tryCatch(() => transparentize(0.3, theme.base.palette['foreground-color']));
|
|
420
|
+
return css `
|
|
421
|
+
position: absolute;
|
|
422
|
+
color: ${iconColor};
|
|
423
|
+
/* stylelint-disable-next-line unit-allowed-list */
|
|
424
|
+
inset-block-start: calc((${theme.components.input.height} - max(1.125rem, 14px)));
|
|
425
|
+
inset-inline-end: calc(2.5 * ${theme.components.input.padding});
|
|
426
|
+
|
|
427
|
+
@media (pointer: coarse) {
|
|
428
|
+
/* stylelint-disable unit-allowed-list */
|
|
429
|
+
inset-block-start: calc(
|
|
430
|
+
(${theme.base['hit-area']['finger-min']} - max(1.125rem, 14px)) * 0.75
|
|
431
|
+
);
|
|
432
|
+
/* stylelint-enable unit-allowed-list */
|
|
433
|
+
}
|
|
434
|
+
`;
|
|
435
|
+
});
|
|
436
|
+
StyledFilterIcon.defaultProps = defaultThemeProp;
|
|
380
437
|
//# sourceMappingURL=Menu.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.styles.js","sourceRoot":"","sources":["../../../src/components/Menu/Menu.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,UAAU,CAA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,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,uBAAuB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAExD,MAAM,CAAC,MAAM,6BAA6B,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAA;;CAE3E,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,EAAE,CAAA;;;;CAIzC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAC7C,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,GAAG,CAAA;;;yBAGK,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI;;;;;;;;;;;;;;;;MAgBjF,cAAc,IAAI,kBAAkB;;;;;GAKvC,CACF,CAAC;AAEF,qBAAqB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEtD,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACjD,MAAM,WAAW,GAAG,mBAAmB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;IAE3E,OAAO,GAAG,CAAA;;;;;MAKN,qBAAqB;;;;;oBAKP,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK;;;;;;;;;;;;;;;oBAevB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;;;MAG9C,wBAAwB;UACpB,qBAAqB;;;;;;;;iBAQd,KAAK,CAAC,IAAI,CAAC,OAAO;;;;uBAIZ,WAAW;;;;oBAId,WAAW;;GAE5B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,UAAU,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import { hideVisually, mix, rgba } from 'polished';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { StyledEmptyState } from '../EmptyState';\nimport Icon, { StyledIcon } from '../Icon';\nimport { StyledGrid } from '../Grid';\nimport { tryCatch } from '../../utils';\nimport { StyledText } from '../Text';\nimport { StyledVisuallyHiddenText } from '../VisuallyHiddenText/VisuallyHiddenText';\nimport { StyledMetaList, StyledMetaListItem } from '../MetaList/MetaList';\nimport Button from '../Button';\nimport { readableColor } from '../../styles';\nimport {\n StyledPrimary,\n StyledSecondary,\n StyledSummaryItem,\n StyledSummaryItemActions,\n StyledVisual\n} from '../SummaryItem';\nimport { ellipsisOverflow } from '../../styles/mixins';\nimport { StyledFlex } from '../Flex';\n\nimport type { MenuProps } from './Menu.types';\n\nexport const StyledExpandButton = styled(Button)`\n align-self: center;\n`;\n\nexport const StyledCheckMarkIcon = styled(Icon)``;\n\nexport const StyledMenuItem = styled.li<{\n isParentItem: boolean;\n mode?: MenuProps['mode'];\n itemLayout?: MenuProps['itemLayout'];\n isChecked?: boolean;\n selectableParent?: boolean;\n}>(\n ({\n theme: { base, components },\n isParentItem,\n itemLayout,\n mode = 'action',\n 'aria-selected': isChecked = false,\n selectableParent = false\n }) => {\n const activeColor = tryCatch(() =>\n mix(0.85, base.palette['primary-background'], base.palette.interactive)\n );\n const hoverColor = tryCatch(() =>\n mix(0.95, base.palette['primary-background'], base.palette.interactive)\n );\n const hoverCheckColor = tryCatch(() =>\n rgba(\n components['radio-check'][':checked']['background-color'],\n base.transparency['transparent-5']\n )\n );\n\n const checkedBackground = components['radio-check'][':checked']['background-color'];\n const checkedForeground = tryCatch(() => readableColor(checkedBackground));\n\n return css`\n min-height: ${base['hit-area']['mouse-min']};\n padding-block: calc(0.75 * ${base.spacing});\n padding-inline: ${base.spacing};\n cursor: pointer;\n\n ${itemLayout === 'inline' &&\n css`\n justify-content: flex-start;\n\n ${StyledSummaryItem} {\n /* Sets grid columns based on SummaryItem content combinations */\n\n &:has(${StyledVisual}):has(${StyledSecondary}):has(${StyledSummaryItemActions}) {\n grid-template-areas: 'visual primary secondary actions';\n grid-template-columns: auto auto 1fr auto;\n }\n\n &:has(${StyledVisual}):has(${StyledSecondary}):not(:has(${StyledSummaryItemActions})) {\n grid-template-areas: 'visual primary secondary';\n grid-template-columns: auto auto 1fr;\n }\n\n &:has(${StyledVisual}):not(:has(${StyledSecondary})):has(${StyledSummaryItemActions}) {\n grid-template-areas: 'visual primary actions';\n grid-template-columns: auto 1fr auto;\n }\n\n &:has(${StyledVisual}):not(:has(${StyledSecondary})):not(\n :has(${StyledSummaryItemActions})\n ) {\n grid-template-areas: 'visual primary';\n grid-template-columns: auto 1fr;\n }\n\n &:not(:has(${StyledVisual})):has(${StyledSecondary}):has(${StyledSummaryItemActions}) {\n grid-template-areas: 'primary secondary actions';\n grid-template-columns: auto 1fr auto;\n }\n\n &:not(:has(${StyledVisual})):has(${StyledSecondary}):not(\n :has(${StyledSummaryItemActions})\n ) {\n grid-template-areas: 'primary secondary';\n grid-template-columns: auto 1fr;\n }\n\n &:not(:has(${StyledVisual})):not(:has(${StyledSecondary})):has(\n ${StyledSummaryItemActions}\n ) {\n grid-template-areas: 'primary actions';\n grid-template-columns: auto 1fr;\n }\n\n &:not(:has(${StyledVisual})):not(:has(${StyledSecondary})):not(\n :has(${StyledSummaryItemActions})\n ) {\n grid-template-areas: 'primary';\n grid-template-columns: 1fr;\n flex-grow: 0;\n }\n\n & > ${StyledPrimary} {\n ${ellipsisOverflow};\n }\n\n & > ${StyledSecondary} {\n ${ellipsisOverflow};\n\n ul {\n li {\n ${ellipsisOverflow};\n }\n justify-content: end;\n }\n }\n\n & > ${StyledSummaryItemActions} > ${StyledFlex} {\n justify-content: end;\n }\n }\n `}\n\n @media (pointer: coarse) {\n min-height: ${base['hit-area']['finger-min']};\n }\n\n &:focus-within {\n background-color: ${activeColor};\n }\n\n &:hover {\n ${StyledCheckMarkIcon} {\n visibility: visible;\n ${mode === 'single-select' &&\n css`\n color: ${isChecked ? checkedBackground : hoverCheckColor};\n `}\n ${mode === 'multi-select' &&\n css`\n ${!isChecked &&\n css`\n border-color: ${components['form-control'][':hover']['border-color']};\n `}\n `}\n }\n }\n\n &:hover:not([aria-disabled='true']) {\n background-color: ${hoverColor};\n }\n\n a:first-of-type {\n display: block;\n width: 100%;\n text-decoration: none;\n color: inherit;\n }\n\n ${isParentItem &&\n !selectableParent &&\n (mode === 'multi-select' || mode === 'single-select') &&\n css`\n padding-inline-start: calc(1.125rem + 2 * ${base.spacing});\n `}\n\n ${StyledGrid} {\n flex-grow: 1;\n }\n\n ${StyledCheckMarkIcon} {\n margin-inline-start: 0;\n ${mode === 'single-select' &&\n css`\n ${isChecked\n ? css`\n color: ${checkedBackground};\n `\n : css`\n visibility: hidden;\n `}\n `}\n ${mode === 'multi-select' &&\n css`\n ${isChecked\n ? css`\n color: ${checkedForeground};\n background-color: ${checkedBackground};\n border: 0.0625rem solid ${components['radio-check'][':checked']['border-color']};\n `\n : css`\n color: transparent;\n border: 0.0625rem solid ${components['radio-check']['border-color']};\n `}\n border-radius: min(\n calc(${base['border-radius']} * ${components.checkbox['border-radius']}),\n 0.25rem\n );\n `}\n }\n\n &[aria-disabled='true'] {\n background-color: ${components['form-control'][':disabled']['background-color']};\n opacity: ${base['disabled-opacity']};\n }\n `;\n }\n);\n\nStyledMenuItem.defaultProps = defaultThemeProp;\n\nexport const StyledAncestors = styled.div`\n ${StyledIcon} {\n width: 1em;\n height: 1em;\n }\n\n & > ${StyledText} {\n ${ellipsisOverflow};\n }\n`;\n\nexport const StyledVisibilityHidden = styled.p`\n ${hideVisually}\n`;\n\nexport const StyledSeparator = styled.li(({ theme }) => {\n return css`\n height: 0.0625rem;\n background-color: ${theme.base.palette['border-line']};\n margin: ${theme.base.spacing} 0;\n `;\n});\n\nStyledSeparator.defaultProps = defaultThemeProp;\n\nexport const StyledMenuGroupHeader = styled.div(({ theme }) => {\n return css`\n min-height: ${theme.base['hit-area']['mouse-min']};\n font-weight: ${theme.base['font-weight']['semi-bold']};\n background-color: ${theme.base.palette['secondary-background']};\n\n @media (pointer: coarse) {\n min-height: ${theme.base['hit-area']['finger-min']};\n }\n `;\n});\n\nStyledMenuGroupHeader.defaultProps = defaultThemeProp;\n\nexport const StyledMenuListHeader = styled.legend(({ theme: { base } }) => {\n const hoverColor = tryCatch(() =>\n mix(0.95, base.palette['primary-background'], base.palette.interactive)\n );\n const activeColor = tryCatch(() =>\n mix(0.85, base.palette['primary-background'], base.palette.interactive)\n );\n\n return css`\n cursor: pointer;\n width: 100%;\n background-color: ${base.palette['primary-background']};\n\n &:first-child {\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n }\n\n &:last-child {\n border-bottom-left-radius: inherit;\n border-bottom-right-radius: inherit;\n }\n\n &:focus-within {\n box-shadow: ${base.shadow['focus-inset']};\n background-color: ${activeColor};\n }\n\n &:hover:not([aria-disabled='true']):not([data-current='true']) {\n background-color: ${hoverColor};\n }\n color: ${base.palette['foreground-color']};\n padding: calc(0.5 * ${base.spacing}) ${base.spacing};\n text-align: start;\n border-radius: inherit;\n\n > ${StyledGrid} {\n grid-column-gap: ${base.spacing};\n }\n\n ${StyledIcon} {\n /* Fixes vertical align issue increasing box size beyond square */\n display: block;\n }\n `;\n});\n\nStyledMenuListHeader.defaultProps = defaultThemeProp;\n\nexport const StyledMenuList = styled.ul(\n ({ theme }) => css`\n overflow-x: hidden;\n overflow-y: auto;\n list-style: none;\n height: 100%;\n border-radius: inherit;\n\n ${StyledEmptyState} {\n padding: ${theme.base.spacing};\n height: auto;\n }\n\n li:not(:first-child):not([role='presentation']) > ${StyledMenuGroupHeader} {\n margin-block-start: ${theme.base.spacing};\n }\n `\n);\n\nStyledMenuList.defaultProps = defaultThemeProp;\n\nexport const StyledMenuListContainer = styled.fieldset(({ theme }) => {\n return css`\n background-color: ${theme.base.palette['primary-background']};\n border: 0;\n border-radius: inherit;\n `;\n});\n\nStyledMenuListContainer.defaultProps = defaultThemeProp;\n\nexport const StyledFlyoutMenuListContainer = styled(StyledMenuListContainer)`\n min-width: 10rem;\n`;\n\nexport const StyledLoadingItem = styled.li`\n display: block;\n position: relative;\n height: 2.8rem;\n`;\n\nexport const StyledMenuListWrapper = styled.div(\n ({ theme }) => css`\n position: relative;\n overflow: hidden;\n transition: height ${theme.base.animation.speed} ${theme.base.animation.timing.ease};\n\n & > fieldset:first-child {\n position: relative;\n }\n\n &:first-child {\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n }\n\n &:last-child {\n border-bottom-left-radius: inherit;\n border-bottom-right-radius: inherit;\n }\n\n ${StyledMetaList} ${StyledMetaListItem} * {\n display: inline;\n vertical-align: baseline;\n margin: 0;\n }\n `\n);\n\nStyledMenuListWrapper.defaultProps = defaultThemeProp;\n\nexport const StyledMenu = styled.div(({ theme }) => {\n const borderStyle = `0.0625rem solid ${theme.base.palette['border-line']}`;\n\n return css`\n display: flex;\n flex-direction: column;\n\n &,\n ${StyledMenuListWrapper} {\n max-height: inherit;\n }\n\n &:focus {\n box-shadow: ${theme.base.shadow.focus};\n outline: none;\n }\n\n &:first-child {\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n }\n\n &:last-child {\n border-bottom-left-radius: inherit;\n border-bottom-right-radius: inherit;\n }\n\n &[data-active-scope='true'] [data-current='true'] {\n box-shadow: ${theme.base.shadow['focus-inset']};\n }\n\n ${StyledVisuallyHiddenText}:first-child {\n + ${StyledMenuListWrapper}, + header {\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n }\n }\n\n > header,\n > footer {\n padding: ${theme.base.spacing};\n }\n\n > header {\n border-bottom: ${borderStyle};\n }\n\n > footer {\n border-top: ${borderStyle};\n }\n `;\n});\n\nStyledMenu.defaultProps = defaultThemeProp;\n"]}
|
|
1
|
+
{"version":3,"file":"Menu.styles.js","sourceRoot":"","sources":["../../../src/components/Menu/Menu.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,MAAM,EAAE,E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AAK,CAAC,OAAO;;;;;WAKtD,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,YAAY,CAAC;;;;GAI5C,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import { hideVisually, mix, rgba, transparentize } from 'polished';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { StyledEmptyState } from '../EmptyState';\nimport Icon, { StyledIcon } from '../Icon';\nimport { StyledGrid } from '../Grid';\nimport { tryCatch } from '../../utils';\nimport { StyledText } from '../Text';\nimport { StyledVisuallyHiddenText } from '../VisuallyHiddenText/VisuallyHiddenText';\nimport { StyledMetaList, StyledMetaListItem } from '../MetaList/MetaList';\nimport Button from '../Button';\nimport { readableColor } from '../../styles';\nimport {\n StyledPrimary,\n StyledSecondary,\n StyledSummaryItem,\n StyledSummaryItemActions,\n StyledVisual\n} from '../SummaryItem';\nimport { ellipsisOverflow } from '../../styles/mixins';\nimport { StyledFlex } from '../Flex';\nimport { StyledFormControl } from '../FormControl';\n\nimport type { MenuProps } from './Menu.types';\n\nexport const StyledExpandButton = styled(Button)`\n align-self: center;\n`;\n\nexport const StyledCheckMarkIcon = styled(Icon)``;\n\nexport const StyledMenuItem = styled.li<{\n isParentItem: boolean;\n mode?: MenuProps['mode'];\n itemLayout?: MenuProps['itemLayout'];\n isChecked?: boolean;\n selectableParent?: boolean;\n}>(\n ({\n theme: { base, components },\n isParentItem,\n itemLayout,\n mode = 'action',\n 'aria-selected': isChecked = false,\n selectableParent = false\n }) => {\n const activeColor = tryCatch(() =>\n mix(0.85, base.palette['primary-background'], base.palette.interactive)\n );\n const hoverColor = tryCatch(() =>\n mix(0.95, base.palette['primary-background'], base.palette.interactive)\n );\n const hoverCheckColor = tryCatch(() =>\n rgba(\n components['radio-check'][':checked']['background-color'],\n base.transparency['transparent-5']\n )\n );\n\n const checkedBackground = components['radio-check'][':checked']['background-color'];\n const checkedForeground = tryCatch(() => readableColor(checkedBackground));\n\n return css`\n min-height: ${base['hit-area']['mouse-min']};\n padding-block: calc(0.75 * ${base.spacing});\n padding-inline: ${base.spacing};\n cursor: pointer;\n\n ${itemLayout === 'inline' &&\n css`\n justify-content: flex-start;\n\n ${StyledSummaryItem} {\n /* Sets grid columns based on SummaryItem content combinations */\n\n &:has(${StyledVisual}):has(${StyledSecondary}):has(${StyledSummaryItemActions}) {\n grid-template-areas: 'visual primary secondary actions';\n grid-template-columns: auto auto 1fr auto;\n }\n\n &:has(${StyledVisual}):has(${StyledSecondary}):not(:has(${StyledSummaryItemActions})) {\n grid-template-areas: 'visual primary secondary';\n grid-template-columns: auto auto 1fr;\n }\n\n &:has(${StyledVisual}):not(:has(${StyledSecondary})):has(${StyledSummaryItemActions}) {\n grid-template-areas: 'visual primary actions';\n grid-template-columns: auto 1fr auto;\n }\n\n &:has(${StyledVisual}):not(:has(${StyledSecondary})):not(\n :has(${StyledSummaryItemActions})\n ) {\n grid-template-areas: 'visual primary';\n grid-template-columns: auto 1fr;\n }\n\n &:not(:has(${StyledVisual})):has(${StyledSecondary}):has(${StyledSummaryItemActions}) {\n grid-template-areas: 'primary secondary actions';\n grid-template-columns: auto 1fr auto;\n }\n\n &:not(:has(${StyledVisual})):has(${StyledSecondary}):not(\n :has(${StyledSummaryItemActions})\n ) {\n grid-template-areas: 'primary secondary';\n grid-template-columns: auto 1fr;\n }\n\n &:not(:has(${StyledVisual})):not(:has(${StyledSecondary})):has(\n ${StyledSummaryItemActions}\n ) {\n grid-template-areas: 'primary actions';\n grid-template-columns: auto 1fr;\n }\n\n &:not(:has(${StyledVisual})):not(:has(${StyledSecondary})):not(\n :has(${StyledSummaryItemActions})\n ) {\n grid-template-areas: 'primary';\n grid-template-columns: 1fr;\n flex-grow: 0;\n }\n\n & > ${StyledPrimary} {\n ${ellipsisOverflow};\n }\n\n & > ${StyledSecondary} {\n ${ellipsisOverflow};\n\n ul {\n li {\n ${ellipsisOverflow};\n }\n justify-content: end;\n }\n }\n\n & > ${StyledSummaryItemActions} > ${StyledFlex} {\n justify-content: end;\n }\n }\n `}\n\n @media (pointer: coarse) {\n min-height: ${base['hit-area']['finger-min']};\n }\n\n &:focus-within {\n background-color: ${activeColor};\n }\n\n &:hover {\n ${StyledCheckMarkIcon} {\n visibility: visible;\n ${mode === 'single-select' &&\n css`\n color: ${isChecked ? checkedBackground : hoverCheckColor};\n `}\n ${mode === 'multi-select' &&\n css`\n ${!isChecked &&\n css`\n border-color: ${components['form-control'][':hover']['border-color']};\n `}\n `}\n }\n }\n\n &:hover:not([aria-disabled='true']) {\n background-color: ${hoverColor};\n }\n\n a:first-of-type {\n display: block;\n width: 100%;\n text-decoration: none;\n color: inherit;\n }\n\n ${isParentItem &&\n !selectableParent &&\n (mode === 'multi-select' || mode === 'single-select') &&\n css`\n padding-inline-start: calc(1.125rem + 2 * ${base.spacing});\n `}\n\n ${StyledGrid} {\n flex-grow: 1;\n }\n\n ${StyledCheckMarkIcon} {\n margin-inline-start: 0;\n ${mode === 'single-select' &&\n css`\n ${isChecked\n ? css`\n color: ${checkedBackground};\n `\n : css`\n visibility: hidden;\n `}\n `}\n ${mode === 'multi-select' &&\n css`\n ${isChecked\n ? css`\n color: ${checkedForeground};\n background-color: ${checkedBackground};\n border: 0.0625rem solid ${components['radio-check'][':checked']['border-color']};\n `\n : css`\n color: transparent;\n border: 0.0625rem solid ${components['radio-check']['border-color']};\n `}\n border-radius: min(\n calc(${base['border-radius']} * ${components.checkbox['border-radius']}),\n 0.25rem\n );\n `}\n }\n\n &[aria-disabled='true'] {\n background-color: ${components['form-control'][':disabled']['background-color']};\n opacity: ${base['disabled-opacity']};\n }\n `;\n }\n);\n\nStyledMenuItem.defaultProps = defaultThemeProp;\n\nexport const StyledAncestors = styled.div`\n ${StyledIcon} {\n width: 1em;\n height: 1em;\n }\n\n & > ${StyledText} {\n ${ellipsisOverflow};\n }\n`;\n\nexport const StyledVisibilityHidden = styled.p`\n ${hideVisually}\n`;\n\nexport const StyledSeparator = styled.li(({ theme }) => {\n return css`\n height: 0.0625rem;\n background-color: ${theme.base.palette['border-line']};\n margin: ${theme.base.spacing} 0;\n `;\n});\n\nStyledSeparator.defaultProps = defaultThemeProp;\n\nexport const StyledMenuGroupHeader = styled.div(({ theme }) => {\n return css`\n min-height: ${theme.base['hit-area']['mouse-min']};\n font-weight: ${theme.base['font-weight']['semi-bold']};\n background-color: ${theme.base.palette['secondary-background']};\n\n @media (pointer: coarse) {\n min-height: ${theme.base['hit-area']['finger-min']};\n }\n `;\n});\n\nStyledMenuGroupHeader.defaultProps = defaultThemeProp;\n\nexport const StyledMenuListHeader = styled.legend(({ theme: { base } }) => {\n const hoverColor = tryCatch(() =>\n mix(0.95, base.palette['primary-background'], base.palette.interactive)\n );\n const activeColor = tryCatch(() =>\n mix(0.85, base.palette['primary-background'], base.palette.interactive)\n );\n\n return css`\n cursor: pointer;\n width: 100%;\n background-color: ${base.palette['primary-background']};\n\n &:first-child {\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n }\n\n &:last-child {\n border-bottom-left-radius: inherit;\n border-bottom-right-radius: inherit;\n }\n\n &:focus-within {\n box-shadow: ${base.shadow['focus-inset']};\n background-color: ${activeColor};\n }\n\n &:hover:not([aria-disabled='true']):not([data-current='true']) {\n background-color: ${hoverColor};\n }\n color: ${base.palette['foreground-color']};\n padding: calc(0.5 * ${base.spacing}) ${base.spacing};\n text-align: start;\n border-radius: inherit;\n\n > ${StyledGrid} {\n grid-column-gap: ${base.spacing};\n }\n\n ${StyledIcon} {\n /* Fixes vertical align issue increasing box size beyond square */\n display: block;\n }\n `;\n});\n\nStyledMenuListHeader.defaultProps = defaultThemeProp;\n\nexport const StyledMenuList = styled.ul(\n ({ theme }) => css`\n overflow-x: hidden;\n overflow-y: auto;\n list-style: none;\n height: 100%;\n border-radius: inherit;\n\n ${StyledEmptyState} {\n padding: ${theme.base.spacing};\n height: auto;\n }\n\n li:not(:first-child):not([role='presentation']) > ${StyledMenuGroupHeader} {\n margin-block-start: ${theme.base.spacing};\n }\n `\n);\n\nStyledMenuList.defaultProps = defaultThemeProp;\n\nexport const StyledMenuListContainer = styled.fieldset(({ theme }) => {\n return css`\n background-color: ${theme.base.palette['primary-background']};\n border: 0;\n border-radius: inherit;\n `;\n});\n\nStyledMenuListContainer.defaultProps = defaultThemeProp;\n\nexport const StyledFlyoutMenuListContainer = styled(StyledMenuListContainer)`\n min-width: 10rem;\n`;\n\nexport const StyledLoadingItem = styled.li`\n display: block;\n position: relative;\n height: 2.8rem;\n`;\n\nexport const StyledMenuListWrapper = styled.div(\n ({ theme }) => css`\n position: relative;\n overflow: hidden;\n transition: height ${theme.base.animation.speed} ${theme.base.animation.timing.ease};\n\n & > fieldset:first-child {\n position: relative;\n }\n\n &:first-child {\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n }\n\n &:last-child {\n border-bottom-left-radius: inherit;\n border-bottom-right-radius: inherit;\n }\n\n ${StyledMetaList} ${StyledMetaListItem} * {\n display: inline;\n vertical-align: baseline;\n margin: 0;\n }\n `\n);\n\nStyledMenuListWrapper.defaultProps = defaultThemeProp;\n\nexport const StyledMenu = styled.div(({ theme }) => {\n const borderStyle = `0.0625rem solid ${theme.base.palette['border-line']}`;\n\n return css`\n display: flex;\n flex-direction: column;\n\n &,\n ${StyledMenuListWrapper} {\n max-height: inherit;\n }\n\n &:focus {\n box-shadow: ${theme.base.shadow.focus};\n outline: none;\n }\n\n &:first-child {\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n }\n\n &:last-child {\n border-bottom-left-radius: inherit;\n border-bottom-right-radius: inherit;\n }\n\n &[data-active-scope='true'] [data-current='true'] {\n box-shadow: ${theme.base.shadow['focus-inset']};\n }\n\n ${StyledVisuallyHiddenText}:first-child {\n + ${StyledMenuListWrapper}, + header {\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n }\n }\n\n > header,\n > footer {\n padding: ${theme.base.spacing};\n }\n\n > header {\n border-bottom: ${borderStyle};\n }\n\n > footer {\n border-top: ${borderStyle};\n }\n `;\n});\n\nStyledMenu.defaultProps = defaultThemeProp;\n\nexport const StyledMenuFilter = styled.div(({ theme }) => {\n const borderRadius = `calc(${theme.components['search-input']['border-radius']} * ${theme.base['border-radius']})`;\n\n return css`\n min-height: ${theme.components.input.height};\n height: ${theme.components.input.height};\n\n @media (pointer: coarse) {\n min-height: ${theme.base['hit-area']['finger-min']};\n min-width: ${theme.base['hit-area']['finger-min']};\n }\n\n ${StyledFormControl} {\n height: 100%;\n border-radius: ${borderRadius};\n padding-inline-start: calc(1.5 * ${theme.components.input.padding});\n padding-inline-end: calc(4 * ${theme.components.input.padding});\n\n &::-webkit-search-cancel-button {\n display: none;\n }\n\n ::-webkit-search-decoration {\n -webkit-appearance: none;\n }\n\n &:focus:not([disabled]) {\n box-shadow: ${theme.base.shadow['focus-inset']};\n border-color: ${theme.components['form-control']['border-color']};\n\n :hover {\n border-color: ${theme.components['form-control'][':hover']['border-color']};\n }\n }\n }\n `;\n});\n\nStyledMenuFilter.defaultProps = defaultThemeProp;\n\nexport const StyledFilterIcon = styled(Icon)(({ theme }) => {\n const iconColor = tryCatch(() => transparentize(0.3, theme.base.palette['foreground-color']));\n\n return css`\n position: absolute;\n color: ${iconColor};\n /* stylelint-disable-next-line unit-allowed-list */\n inset-block-start: calc((${theme.components.input.height} - max(1.125rem, 14px)));\n inset-inline-end: calc(2.5 * ${theme.components.input.padding});\n\n @media (pointer: coarse) {\n /* stylelint-disable unit-allowed-list */\n inset-block-start: calc(\n (${theme.base['hit-area']['finger-min']} - max(1.125rem, 14px)) * 0.75\n );\n /* stylelint-enable unit-allowed-list */\n }\n `;\n});\n\nStyledFilterIcon.defaultProps = defaultThemeProp;\n"]}
|
|
@@ -4,6 +4,7 @@ import type { MetaListProps } from '../MetaList';
|
|
|
4
4
|
import type { UseActiveDescendantConfig } from '../../hooks';
|
|
5
5
|
import type { TooltipProps } from '../Tooltip';
|
|
6
6
|
import type { SummaryItemProps } from '../SummaryItem';
|
|
7
|
+
import type { InputProps } from '../Input';
|
|
7
8
|
export type AcceptedMouseEventElement = HTMLButtonElement | HTMLAnchorElement | HTMLInputElement;
|
|
8
9
|
export interface MenuItemProps extends MenuObjectProps {
|
|
9
10
|
/** The primary piece of item information as a string. */
|
|
@@ -88,6 +89,8 @@ export interface MenuProps extends TestIdProp, BaseProps, NoChildrenProp {
|
|
|
88
89
|
* @default 'stacked'
|
|
89
90
|
*/
|
|
90
91
|
itemLayout?: SummaryItemProps['layout'];
|
|
92
|
+
/** Renders an input to filter items in the menu */
|
|
93
|
+
filterInputProps?: OmitStrict<InputProps, 'type'>;
|
|
91
94
|
/** Renders a create new action below the menu. */
|
|
92
95
|
onCreateNew?: () => void;
|
|
93
96
|
/** ID placed on the menu's list element. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.types.d.ts","sourceRoot":"","sources":["../../../src/components/Menu/Menu.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE7F,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Menu.types.d.ts","sourceRoot":"","sources":["../../../src/components/Menu/Menu.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,cAAc,EAAE,UA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,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,YAAY,EAAE,WAAW,GAAG,IAAI,CAAC;IACjC,uBAAuB,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IACzE,kBAAkB,EAAE,QAAQ,CAAC,cAAc,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC;IACjE,gBAAgB,EAAE,QAAQ,CAAC,cAAc,CAAC,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC;IAC3E,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IAC5C,2BAA2B,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;IACjE,QAAQ,CAAC,EAAE;QACT,YAAY,EAAE,aAAa,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;QAC9C,UAAU,EAAE,MAAM,IAAI,CAAC;KACxB,CAAC;CACH;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,SAAS,CAAC,gBAAgB,CAAC,CAAC;IACrC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.types.js","sourceRoot":"","sources":["../../../src/components/Menu/Menu.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Dispatch, ReactNode, Ref, RefObject, SetStateAction, MouseEvent } from 'react';\n\nimport type {\n BaseProps,\n NoChildrenProp,\n OmitStrict,\n PropsWithDefaults,\n TestIdProp\n} from '../../types';\nimport type { MetaListProps } from '../MetaList';\nimport type { UseActiveDescendantConfig } from '../../hooks';\nimport type { TooltipProps } from '../Tooltip';\nimport type { SummaryItemProps } from '../SummaryItem';\n\nexport type AcceptedMouseEventElement = HTMLButtonElement | HTMLAnchorElement | HTMLInputElement;\n\nexport interface MenuItemProps extends MenuObjectProps {\n /** The primary piece of item information as a string. */\n primary: string;\n /** Secondary info about an item. Useful for additional metadata or context. Will be overridden when ancestors are passed as a prop. */\n secondary?: MetaListProps['items'];\n /** A visual to assist identifying an item. e.g. Avatar or Icon. */\n visual?: ReactNode;\n /** A count to assist with number of associated items. */\n count?: number;\n /** An array of MenuItemProps to identify an item's ancestors by their primary value. Useful for flattened tree search results. */\n ancestors?: (MenuItemProps | MenuGroupProps)[];\n /** An array of either MenuItemProps or MenuGroupProps children. */\n items?: (MenuItemProps | MenuGroupProps)[];\n /**\n * For single or multi select menus, selected must be set true|false to render an item's radiobutton or checkbox.\n * May be set on parent or leaf items.\n */\n selected?: boolean;\n /** FUTURE SUPPORT: Use to indicate an item has a partial selection, some but not all of its descendants are selected. */\n partial?: boolean;\n /** Will render the action item as link. Only use for leaf items. */\n href?: string;\n /**\n * Provide a description for an item that will render in a Tooltip when hovering that item.\n * This should be used only for VERY SPECIFIC UX scenarios.\n */\n tooltip?: TooltipProps['children'];\n /** Use this function to identify and set item selections. Recommend leveraging top level Menu onItemClick handler. */\n onClick?: (id: MenuItemProps['id'], e: MouseEvent<AcceptedMouseEventElement>) => void;\n onExpand?: MenuItemProps['onClick'];\n /** Determines if the MenuItem will be disabled. */\n disabled?: boolean;\n role?: 'menuitem' | 'option';\n}\n\nexport interface MenuGroupProps extends MenuObjectProps {\n /** Label of the group. */\n label: string;\n /** An array of MenuItemProps children. */\n items: MenuItemProps[];\n /** List-like role to apply to group items. */\n itemRole?: MenuItemProps['role'];\n}\n\nexport type ParentMenuItemProps = MenuItemProps & { items: NonNullable<MenuItemProps['items']> };\n\nexport interface MenuListHeaderProps {\n /** Text used to indicate an expanded parent item. */\n text: string;\n /** Internal handler. */\n onClick: () => void;\n}\n\nexport interface MenuObjectProps extends TestIdProp {\n /** A unique id within the entire tree of menu items. */\n id: string;\n}\n\nexport interface MenuListProps {\n items: ParentMenuItemProps['items'];\n id?: string;\n ref?: Ref<HTMLFieldSetElement>;\n parent?: {\n el: HTMLFieldSetElement;\n item: ParentMenuItemProps;\n siblingItems: ParentMenuItemProps['items'];\n setExpandedItem: Dispatch<SetStateAction<ParentMenuItemProps | undefined>>;\n returnFocusRef: RefObject<HTMLButtonElement>;\n };\n menuRole?: 'menu' | 'listbox';\n}\n\nexport type MenuHandleValue = {\n /**\n * Sets current menu depth to that of the given id.\n * Only applies to drill-down variant.\n */\n expandTo: (parentItemId: MenuItemProps['id']) => void;\n};\n\nexport interface MenuProps extends TestIdProp, BaseProps, NoChildrenProp {\n /** An array of MenuItemProps. */\n items: (MenuItemProps | MenuGroupProps)[];\n /**\n * Determines menu item content layout structure.\n * @default 'stacked'\n */\n itemLayout?: SummaryItemProps['layout'];\n /** Renders a create new action below the menu. */\n onCreateNew?: () => void;\n /** ID placed on the menu's list element. */\n listId?: string;\n /**\n * Indicates intent for the menu.\n * As of now item types can not be mixed.\n * @default 'action'\n */\n mode?: 'action' | 'multi-select' | 'single-select';\n role?: 'menu' | 'listbox';\n /**\n * Always recommended to go for default drill-down variant for better accessibility.\n * When flyout variant is selected, its recommended not to have more than 1 nested level\n * @default 'drill-down'\n */\n variant?: 'drill-down' | 'flyout';\n /**\n * Use to accent(make bold) portions of the primary text.\n * Useful for filter/search results.\n * If passed a function, that function will be passed each items primary text.\n */\n accent?: RegExp | ((primary: string) => RegExp);\n /**\n * Item height will grow or shrink based on item count.\n * Use this indicate at which item the menu should begin its scroll.\n * @default 7\n */\n scrollAt?: number;\n /** A simple message to display when there are no items. */\n emptyText?: string;\n /**\n * A top level handler for all item clicks.\n * This is convenient way to detect which item was clicked to react by updating state or performing an action.\n * Both an item's onClick and this will be called if both are passed.\n */\n onItemClick?: MenuItemProps['onClick'];\n /**\n * A top level handler for all item pseudo focus events.\n * This is convenient way to detect which item is active to react by updating state or performing an action.\n */\n onItemActive?: (id: MenuItemProps['id']) => void;\n /**\n * A top level handler for clicks on parent items to expand their child items.\n * This is convenient way to detect when an item is expanded.\n * For lazy loading this would be a good time to set an item's items.\n * Both an item's onExpand and this will be called if both are passed.\n */\n onItemExpand?: MenuProps['onItemClick'];\n /** A top level handler for capturing when nested items have been collapsed / \"back\" button clicks. */\n onItemCollapse?: (id: MenuItemProps['id']) => void;\n /**\n * Show a Progress indicator at the end of a list where newly loaded items will be appended.\n * @default false\n */\n loading?: boolean;\n /** Callback to fetch more items */\n loadMore?: (id?: MenuItemProps['id']) => void;\n /** Ref placed on the root menu element. */\n ref?: Ref<HTMLDivElement>;\n /** HTML ID. */\n id?: string;\n /**\n * Currently highlighted item.\n * Setting currentItemId assumes synthetic focus is being controlled entirely by the containing component,\n * and unbinds menu useActiveDescendant keydown controls.\n * @deprecated\n */\n currentItemId?: string;\n /** Override for default active-descendant focus control element in menu */\n focusControlEl?: HTMLElement | undefined;\n /** Header region. */\n header?: ReactNode;\n /** Footer region. */\n footer?: ReactNode;\n /** Pauses evaluation of menu active descendants while true */\n pauseDescendantEvaluation?: UseActiveDescendantConfig['pauseDescendantEvaluation'];\n /**\n * Flag to indicate that Right/Left arrow navigation for expand/collapse parent items is not available.\n * Will accept enter if not selectable parent, otherwise falls back to shift + space.\n */\n arrowNavigationUnsupported?: boolean;\n /** Additional information to announce to screen reader users. Read before menu navigation instructions. */\n 'aria-describedby'?: string;\n /** Label for menu or listbox element */\n 'aria-label'?: string;\n /**\n * Custom menu list rendering\n * @internal\n */\n menuList?: ReactNode;\n handleRef?: Ref<MenuHandleValue>;\n}\n\ntype MenuPropsWithDefaults = PropsWithDefaults<\n MenuProps,\n 'mode' | 'variant' | 'scrollAt' | 'loading' | 'itemLayout'\n>;\n\nexport interface MenuContextProps\n extends OmitStrict<MenuPropsWithDefaults, 'ref' | 'items' | 'handleRef'> {\n radioName?: string;\n componentId: string;\n pushFlyoutId: (id: string) => void;\n flyOutActiveIdStack: string[];\n focusControl: HTMLElement | null;\n updateActiveDescendants: (options?: { preventScroll?: boolean }) => void;\n setFocusDescendant: Dispatch<SetStateAction<HTMLElement | null>>;\n setFocusReturnEl: Dispatch<SetStateAction<HTMLElement | null | undefined>>;\n getScopedItemId: (itemId: string) => string;\n updateParentDescendantStack?: (item: HTMLElement | null) => void;\n expandTo?: {\n parentItemId: MenuItemProps['id'] | undefined;\n onComplete: () => void;\n };\n}\n\nexport interface NavItemsListProps {\n listRef: RefObject<HTMLUListElement>;\n cycle?: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Menu.types.js","sourceRoot":"","sources":["../../../src/components/Menu/Menu.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Dispatch, ReactNode, Ref, RefObject, SetStateAction, MouseEvent } from 'react';\n\nimport type {\n BaseProps,\n NoChildrenProp,\n OmitStrict,\n PropsWithDefaults,\n TestIdProp\n} from '../../types';\nimport type { MetaListProps } from '../MetaList';\nimport type { UseActiveDescendantConfig } from '../../hooks';\nimport type { TooltipProps } from '../Tooltip';\nimport type { SummaryItemProps } from '../SummaryItem';\nimport type { InputProps } from '../Input';\n\nexport type AcceptedMouseEventElement = HTMLButtonElement | HTMLAnchorElement | HTMLInputElement;\n\nexport interface MenuItemProps extends MenuObjectProps {\n /** The primary piece of item information as a string. */\n primary: string;\n /** Secondary info about an item. Useful for additional metadata or context. Will be overridden when ancestors are passed as a prop. */\n secondary?: MetaListProps['items'];\n /** A visual to assist identifying an item. e.g. Avatar or Icon. */\n visual?: ReactNode;\n /** A count to assist with number of associated items. */\n count?: number;\n /** An array of MenuItemProps to identify an item's ancestors by their primary value. Useful for flattened tree search results. */\n ancestors?: (MenuItemProps | MenuGroupProps)[];\n /** An array of either MenuItemProps or MenuGroupProps children. */\n items?: (MenuItemProps | MenuGroupProps)[];\n /**\n * For single or multi select menus, selected must be set true|false to render an item's radiobutton or checkbox.\n * May be set on parent or leaf items.\n */\n selected?: boolean;\n /** FUTURE SUPPORT: Use to indicate an item has a partial selection, some but not all of its descendants are selected. */\n partial?: boolean;\n /** Will render the action item as link. Only use for leaf items. */\n href?: string;\n /**\n * Provide a description for an item that will render in a Tooltip when hovering that item.\n * This should be used only for VERY SPECIFIC UX scenarios.\n */\n tooltip?: TooltipProps['children'];\n /** Use this function to identify and set item selections. Recommend leveraging top level Menu onItemClick handler. */\n onClick?: (id: MenuItemProps['id'], e: MouseEvent<AcceptedMouseEventElement>) => void;\n onExpand?: MenuItemProps['onClick'];\n /** Determines if the MenuItem will be disabled. */\n disabled?: boolean;\n role?: 'menuitem' | 'option';\n}\n\nexport interface MenuGroupProps extends MenuObjectProps {\n /** Label of the group. */\n label: string;\n /** An array of MenuItemProps children. */\n items: MenuItemProps[];\n /** List-like role to apply to group items. */\n itemRole?: MenuItemProps['role'];\n}\n\nexport type ParentMenuItemProps = MenuItemProps & { items: NonNullable<MenuItemProps['items']> };\n\nexport interface MenuListHeaderProps {\n /** Text used to indicate an expanded parent item. */\n text: string;\n /** Internal handler. */\n onClick: () => void;\n}\n\nexport interface MenuObjectProps extends TestIdProp {\n /** A unique id within the entire tree of menu items. */\n id: string;\n}\n\nexport interface MenuListProps {\n items: ParentMenuItemProps['items'];\n id?: string;\n ref?: Ref<HTMLFieldSetElement>;\n parent?: {\n el: HTMLFieldSetElement;\n item: ParentMenuItemProps;\n siblingItems: ParentMenuItemProps['items'];\n setExpandedItem: Dispatch<SetStateAction<ParentMenuItemProps | undefined>>;\n returnFocusRef: RefObject<HTMLButtonElement>;\n };\n menuRole?: 'menu' | 'listbox';\n}\n\nexport type MenuHandleValue = {\n /**\n * Sets current menu depth to that of the given id.\n * Only applies to drill-down variant.\n */\n expandTo: (parentItemId: MenuItemProps['id']) => void;\n};\n\nexport interface MenuProps extends TestIdProp, BaseProps, NoChildrenProp {\n /** An array of MenuItemProps. */\n items: (MenuItemProps | MenuGroupProps)[];\n /**\n * Determines menu item content layout structure.\n * @default 'stacked'\n */\n itemLayout?: SummaryItemProps['layout'];\n /** Renders an input to filter items in the menu */\n filterInputProps?: OmitStrict<InputProps, 'type'>;\n /** Renders a create new action below the menu. */\n onCreateNew?: () => void;\n /** ID placed on the menu's list element. */\n listId?: string;\n /**\n * Indicates intent for the menu.\n * As of now item types can not be mixed.\n * @default 'action'\n */\n mode?: 'action' | 'multi-select' | 'single-select';\n role?: 'menu' | 'listbox';\n /**\n * Always recommended to go for default drill-down variant for better accessibility.\n * When flyout variant is selected, its recommended not to have more than 1 nested level\n * @default 'drill-down'\n */\n variant?: 'drill-down' | 'flyout';\n /**\n * Use to accent(make bold) portions of the primary text.\n * Useful for filter/search results.\n * If passed a function, that function will be passed each items primary text.\n */\n accent?: RegExp | ((primary: string) => RegExp);\n /**\n * Item height will grow or shrink based on item count.\n * Use this indicate at which item the menu should begin its scroll.\n * @default 7\n */\n scrollAt?: number;\n /** A simple message to display when there are no items. */\n emptyText?: string;\n /**\n * A top level handler for all item clicks.\n * This is convenient way to detect which item was clicked to react by updating state or performing an action.\n * Both an item's onClick and this will be called if both are passed.\n */\n onItemClick?: MenuItemProps['onClick'];\n /**\n * A top level handler for all item pseudo focus events.\n * This is convenient way to detect which item is active to react by updating state or performing an action.\n */\n onItemActive?: (id: MenuItemProps['id']) => void;\n /**\n * A top level handler for clicks on parent items to expand their child items.\n * This is convenient way to detect when an item is expanded.\n * For lazy loading this would be a good time to set an item's items.\n * Both an item's onExpand and this will be called if both are passed.\n */\n onItemExpand?: MenuProps['onItemClick'];\n /** A top level handler for capturing when nested items have been collapsed / \"back\" button clicks. */\n onItemCollapse?: (id: MenuItemProps['id']) => void;\n /**\n * Show a Progress indicator at the end of a list where newly loaded items will be appended.\n * @default false\n */\n loading?: boolean;\n /** Callback to fetch more items */\n loadMore?: (id?: MenuItemProps['id']) => void;\n /** Ref placed on the root menu element. */\n ref?: Ref<HTMLDivElement>;\n /** HTML ID. */\n id?: string;\n /**\n * Currently highlighted item.\n * Setting currentItemId assumes synthetic focus is being controlled entirely by the containing component,\n * and unbinds menu useActiveDescendant keydown controls.\n * @deprecated\n */\n currentItemId?: string;\n /** Override for default active-descendant focus control element in menu */\n focusControlEl?: HTMLElement | undefined;\n /** Header region. */\n header?: ReactNode;\n /** Footer region. */\n footer?: ReactNode;\n /** Pauses evaluation of menu active descendants while true */\n pauseDescendantEvaluation?: UseActiveDescendantConfig['pauseDescendantEvaluation'];\n /**\n * Flag to indicate that Right/Left arrow navigation for expand/collapse parent items is not available.\n * Will accept enter if not selectable parent, otherwise falls back to shift + space.\n */\n arrowNavigationUnsupported?: boolean;\n /** Additional information to announce to screen reader users. Read before menu navigation instructions. */\n 'aria-describedby'?: string;\n /** Label for menu or listbox element */\n 'aria-label'?: string;\n /**\n * Custom menu list rendering\n * @internal\n */\n menuList?: ReactNode;\n handleRef?: Ref<MenuHandleValue>;\n}\n\ntype MenuPropsWithDefaults = PropsWithDefaults<\n MenuProps,\n 'mode' | 'variant' | 'scrollAt' | 'loading' | 'itemLayout'\n>;\n\nexport interface MenuContextProps\n extends OmitStrict<MenuPropsWithDefaults, 'ref' | 'items' | 'handleRef'> {\n radioName?: string;\n componentId: string;\n pushFlyoutId: (id: string) => void;\n flyOutActiveIdStack: string[];\n focusControl: HTMLElement | null;\n updateActiveDescendants: (options?: { preventScroll?: boolean }) => void;\n setFocusDescendant: Dispatch<SetStateAction<HTMLElement | null>>;\n setFocusReturnEl: Dispatch<SetStateAction<HTMLElement | null | undefined>>;\n getScopedItemId: (itemId: string) => string;\n updateParentDescendantStack?: (item: HTMLElement | null) => void;\n expandTo?: {\n parentItemId: MenuItemProps['id'] | undefined;\n onComplete: () => void;\n };\n}\n\nexport interface NavItemsListProps {\n listRef: RefObject<HTMLUListElement>;\n cycle?: boolean;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuButton.d.ts","sourceRoot":"","sources":["../../../src/components/MenuButton/MenuButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,iBAAiB,EAIjB,oBAAoB,EACrB,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EACV,SAAS,EACT,+BAA+B,EAC/B,cAAc,EACd,UAAU,EACV,UAAU,EACX,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"MenuButton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IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,gBAAgB,4GAiB5B,CAAC;;;;AA0LF,wBAA6D"}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { forwardRef, useState, useCallback } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
4
|
import { defaultThemeProp } from '../../theme';
|
|
5
|
-
import { useConsolidatedRef, useUID, useFocusWithin, useDirection, useTestIds, useEscape } from '../../hooks';
|
|
5
|
+
import { useConsolidatedRef, useUID, useFocusWithin, useDirection, useTestIds, useEscape, useElement } from '../../hooks';
|
|
6
6
|
import Button, { StyledButton } from '../Button';
|
|
7
7
|
import Popover, { StyledPopover } from '../Popover';
|
|
8
8
|
import Menu from '../Menu';
|
|
@@ -61,7 +61,10 @@ const MenuButton = forwardRef(function MenuButton(props, ref) {
|
|
|
61
61
|
const testIds = useTestIds(testId, getMenuButtonTestIds);
|
|
62
62
|
const [isOpen, setIsOpen] = useState(false);
|
|
63
63
|
const buttonRef = useConsolidatedRef(ref);
|
|
64
|
-
|
|
64
|
+
// Force re-render when popoverRef is set, so useFocusWithin has a non-null ref to read
|
|
65
|
+
const [, forceRerender] = useElement(null);
|
|
66
|
+
const popoverRef = useConsolidatedRef(popover?.ref, forceRerender);
|
|
67
|
+
const filterInputRef = useConsolidatedRef(menu?.filterInputProps?.ref);
|
|
65
68
|
const menuRef = useConsolidatedRef(menu?.ref);
|
|
66
69
|
// FIXME: Type assertion required for issue in useFocusWithin generic
|
|
67
70
|
useFocusWithin([popoverRef, buttonRef], useCallback((isFocused) => {
|
|
@@ -81,6 +84,13 @@ const MenuButton = forwardRef(function MenuButton(props, ref) {
|
|
|
81
84
|
buttonRef.current?.focus();
|
|
82
85
|
}
|
|
83
86
|
}, menu?.focusControlEl);
|
|
87
|
+
useEscape(e => {
|
|
88
|
+
if (isOpen) {
|
|
89
|
+
setIsOpen(false);
|
|
90
|
+
e.stopPropagation();
|
|
91
|
+
buttonRef.current?.focus();
|
|
92
|
+
}
|
|
93
|
+
}, filterInputRef);
|
|
84
94
|
const { rtl } = useDirection();
|
|
85
95
|
return (_jsxs(_Fragment, { children: [_jsx(Button, { "data-testid": testIds.root, as: StyledMenuButton, "aria-label": text, ...restProps, id: id, ref: buttonRef, "aria-expanded": isOpen, "aria-haspopup": 'menu', "aria-controls": isOpen ? `${id}-popover` : undefined, label: iconOnly && !isOpen ? text : undefined, onClick: (e) => {
|
|
86
96
|
// e.detail is 0 when triggered by keyboard.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuButton.js","sourceRoot":"","sources":["../../../src/components/MenuButton/MenuButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAQ1D,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAShD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,cAAc,EACd,YAAY,EACZ,UAAU,EACV,SAAS,EACV,MAAM,aAAa,CAAC;AACrB,OAAO,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEjD,OAAO,OAAO,EAAE,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,kBAAkB,MAAM,qCAAqC,CAAC;AAC1E,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,WAAW,EA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IAAC,IAAI,EAAC,kBAAkB,GAAG,IACxD,GACA,EAET,KAAC,uBAAuB,IACtB,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,cAAc,EAC9C,kBAAkB,WACd,OAAO,EACX,EAAE,EAAE,GAAG,EAAE,UAAU,EACnB,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,MAAM,EACtB,MAAM,EAAE,SAAS,CAAC,OAAO,EACzB,GAAG,EAAE,UAAU,YAEd,IAAI,IAAI,CACP,KAAC,IAAI,IACH,MAAM,EAAE,OAAO,CAAC,IAAI,KAChB,IAAI,EACR,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,WAAW,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;wBACzB,iGAAiG;wBACjG,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;4BACjC,SAAS,CAAC,KAAK,CAAC,CAAC;wBACnB,CAAC;wBACD,IAAI,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;oBAChC,CAAC,EACD,cAAc,EAAE,IAAI,CAAC,cAAc,IAAI,SAAS,CAAC,OAAO,IAAI,SAAS,GACrE,CACH,GACuB,IACzB,CACJ,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["import { forwardRef, useState, useCallback } from 'react';\nimport type {\n MouseEventHandler,\n MouseEvent,\n UIEvent,\n PropsWithoutRef,\n KeyboardEventHandler\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport type {\n BaseProps,\n ForwardRefForwardPropsComponent,\n NoChildrenProp,\n OmitStrict,\n TestIdProp\n} from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport {\n useConsolidatedRef,\n useUID,\n useFocusWithin,\n useDirection,\n useTestIds,\n useEscape\n} from '../../hooks';\nimport Button, { StyledButton } from '../Button';\nimport type { ButtonProps } from '../Button';\nimport Popover, { StyledPopover } from '../Popover';\nimport type { PopoverProps } from '../Popover';\nimport Menu from '../Menu';\nimport type { MenuProps } from '../Menu/Menu.types';\nimport Icon, { registerIcon, StyledIcon } from '../Icon';\nimport * as arrowMicroDownIcon from '../Icon/icons/arrow-micro-down.icon';\nimport Text, { StyledText } from '../Text';\nimport Flex from '../Flex';\nimport { Count } from '../Badges';\nimport type { CountProps } from '../Badges/Count';\nimport { withTestIds } from '../../utils';\n\nimport { getMenuButtonTestIds } from './MenuButton.test-ids';\n\nregisterIcon(arrowMicroDownIcon);\n\nexport interface MenuButtonProps extends BaseProps, NoChildrenProp, TestIdProp {\n /** The text for the MenuButton also used to set the aria-label. */\n text: string;\n /**\n * Determines the Button variant for the MenuButton.\n * @default 'secondary'\n */\n variant?: ButtonProps['variant'];\n /** The name of the icon for the MenuButton. */\n icon?: string;\n /** Only display the icon. The text prop will be forwarded to a tooltip. */\n iconOnly?: ButtonProps['icon'];\n /** The total count representing the list data which was selected. */\n count?: CountProps['children'];\n /** The click handler for the MenuButton. */\n onClick?: MouseEventHandler;\n /** Menu related props. */\n menu?: MenuProps;\n /** Popover related props. */\n popover?: OmitStrict<PopoverProps, 'show' | 'target' | 'children'>;\n /** DOM id for the button element. */\n id?: string;\n /** Ref for the button element. */\n ref?: ButtonProps['ref'];\n /** The keydown handler for the MenuButton. */\n onKeyDown?: KeyboardEventHandler;\n /**\n * Whether to display an arrow when only the icon is displayed.\n * Only applies when `iconOnly` is true.\n * @default false\n */\n showArrow?: boolean;\n}\n\nexport const StyledMenuButton = styled.button(\n ({\n theme: {\n base: { spacing }\n }\n }) => {\n return css`\n gap: ${spacing};\n flex-shrink: 0;\n white-space: nowrap;\n max-width: 100%;\n\n & + ${StyledPopover} + ${StyledButton} {\n margin-inline-start: ${spacing};\n }\n `;\n }\n);\n\nStyledMenuButton.defaultProps = defaultThemeProp;\n\nconst StyledMenuButtonChildren = styled.span<{ padIcon?: boolean }>(({ theme, padIcon }) => {\n const {\n base: {\n 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger }\n },\n components: {\n icon: {\n size: { s: iconSize }\n }\n }\n } = theme;\n\n return css`\n max-width: 100%;\n\n ${padIcon &&\n css`\n padding-inline-start: calc((${hitAreaMouse} - ${iconSize}) / 2);\n\n @media (pointer: coarse) {\n padding-inline-start: calc(${hitAreaFinger} - ${iconSize} * 2);\n }\n `}\n\n ${StyledText} {\n text-overflow: ellipsis;\n overflow: hidden;\n }\n\n ${StyledIcon}:last-child:not(:first-child) {\n /* Offsets the flex gap to make the down arrow appear to trail the text. */\n margin-inline-start: -${theme.base.spacing};\n }\n `;\n});\n\nconst StyledMenuButtonPopover = styled(Popover)`\n min-width: 20ch;\n`;\n\nconst MenuButton: ForwardRefForwardPropsComponent<MenuButtonProps> = forwardRef(function MenuButton(\n props: PropsWithoutRef<MenuButtonProps>,\n ref: MenuButtonProps['ref']\n) {\n const uid = useUID();\n const {\n testId,\n id = uid,\n text,\n menu,\n popover,\n onClick,\n icon,\n count,\n iconOnly = false,\n showArrow = false,\n ...restProps\n } = props;\n const testIds = useTestIds(testId, getMenuButtonTestIds);\n const [isOpen, setIsOpen] = useState(false);\n\n const buttonRef = useConsolidatedRef(ref);\n const popoverRef = useConsolidatedRef<HTMLDivElement>(popover?.ref);\n const menuRef = useConsolidatedRef<HTMLDivElement>(menu?.ref);\n\n // FIXME: Type assertion required for issue in useFocusWithin generic\n useFocusWithin<HTMLElement>(\n [popoverRef, buttonRef],\n useCallback((isFocused: boolean) => {\n if (!isFocused) setIsOpen(false);\n }, [])\n );\n\n useEscape(e => {\n if (isOpen) {\n setIsOpen(false);\n e.stopPropagation();\n }\n }, buttonRef);\n\n useEscape(e => {\n if (isOpen) {\n setIsOpen(false);\n e.stopPropagation();\n buttonRef.current?.focus();\n }\n }, menu?.focusControlEl);\n\n const { rtl } = useDirection();\n\n return (\n <>\n <Button\n data-testid={testIds.root}\n as={StyledMenuButton}\n aria-label={text}\n {...restProps}\n id={id}\n ref={buttonRef}\n aria-expanded={isOpen}\n aria-haspopup='menu'\n aria-controls={isOpen ? `${id}-popover` : undefined}\n label={iconOnly && !isOpen ? text : undefined}\n onClick={(e: MouseEvent<HTMLButtonElement> & UIEvent<HTMLButtonElement>) => {\n // e.detail is 0 when triggered by keyboard.\n const mouseClick = e.detail > 0;\n\n if (isOpen) {\n if (mouseClick) {\n // Close the menu if it is open and it is a *mouse* click on the button.\n setIsOpen(false);\n }\n } else {\n // Open the menu if it's closed, for mouse or keyboard click.\n setIsOpen(true);\n }\n\n // If the menu is closed or the user mouse clicks.\n // This avoids Enter key firing onClick when selecting a menu item.\n if (!isOpen || mouseClick) {\n onClick?.(e);\n }\n }}\n icon={iconOnly}\n >\n <Flex\n as={StyledMenuButtonChildren}\n container={{ alignItems: 'center', gap: 1 }}\n padIcon={iconOnly && showArrow}\n >\n {icon && <Icon name={icon} />}\n {!iconOnly && (\n <>\n <Text>{text}</Text>\n {typeof count === 'number' && <Count>{count}</Count>}\n </>\n )}\n {(!iconOnly || showArrow) && <Icon name='arrow-micro-down' />}\n </Flex>\n </Button>\n\n <StyledMenuButtonPopover\n placement={rtl ? 'bottom-end' : 'bottom-start'}\n hideOnTargetHidden\n {...popover}\n id={`${id}-popover`}\n show={!!menu && isOpen}\n target={buttonRef.current}\n ref={popoverRef}\n >\n {menu && (\n <Menu\n testId={testIds.root}\n {...menu}\n ref={menuRef}\n items={menu.items}\n onItemClick={(itemId, e) => {\n // When clicking an item (by mouse or keyboard) and the menu is not multi-select, close the menu.\n if (menu.mode !== 'multi-select') {\n setIsOpen(false);\n }\n menu.onItemClick?.(itemId, e);\n }}\n focusControlEl={menu.focusControlEl || buttonRef.current || undefined}\n />\n )}\n </StyledMenuButtonPopover>\n </>\n );\n});\n\nexport default withTestIds(MenuButton, getMenuButtonTestIds);\n"]}
|
|
1
|
+
{"version":3,"file":"MenuButton.js","sourceRoot":"","sources":["../../../src/components/MenuButton/Menu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,IACxD,GACA,EAET,KAAC,uBAAuB,IACtB,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,cAAc,EAC9C,kBAAkB,WACd,OAAO,EACX,EAAE,EAAE,GAAG,EAAE,UAAU,EACnB,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,MAAM,EACtB,MAAM,EAAE,SAAS,CAAC,OAAO,EACzB,GAAG,EAAE,UAAU,YAEd,IAAI,IAAI,CACP,KAAC,IAAI,IACH,MAAM,EAAE,OAAO,CAAC,IAAI,KAChB,IAAI,EACR,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,WAAW,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;wBACzB,iGAAiG;wBACjG,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;4BACjC,SAAS,CAAC,KAAK,CAAC,CAAC;wBACnB,CAAC;wBACD,IAAI,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;oBAChC,CAAC,EACD,cAAc,EAAE,IAAI,CAAC,cAAc,IAAI,SAAS,CAAC,OAAO,IAAI,SAAS,GACrE,CACH,GACuB,IACzB,CACJ,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["import { forwardRef, useState, useCallback } from 'react';\nimport type {\n MouseEventHandler,\n MouseEvent,\n UIEvent,\n PropsWithoutRef,\n KeyboardEventHandler\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport type {\n BaseProps,\n ForwardRefForwardPropsComponent,\n NoChildrenProp,\n OmitStrict,\n TestIdProp\n} from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport {\n useConsolidatedRef,\n useUID,\n useFocusWithin,\n useDirection,\n useTestIds,\n useEscape,\n useElement\n} from '../../hooks';\nimport Button, { StyledButton } from '../Button';\nimport type { ButtonProps } from '../Button';\nimport Popover, { StyledPopover } from '../Popover';\nimport type { PopoverProps } from '../Popover';\nimport Menu from '../Menu';\nimport type { MenuProps } from '../Menu/Menu.types';\nimport Icon, { registerIcon, StyledIcon } from '../Icon';\nimport * as arrowMicroDownIcon from '../Icon/icons/arrow-micro-down.icon';\nimport Text, { StyledText } from '../Text';\nimport Flex from '../Flex';\nimport { Count } from '../Badges';\nimport type { CountProps } from '../Badges/Count';\nimport { withTestIds } from '../../utils';\n\nimport { getMenuButtonTestIds } from './MenuButton.test-ids';\n\nregisterIcon(arrowMicroDownIcon);\n\nexport interface MenuButtonProps extends BaseProps, NoChildrenProp, TestIdProp {\n /** The text for the MenuButton also used to set the aria-label. */\n text: string;\n /**\n * Determines the Button variant for the MenuButton.\n * @default 'secondary'\n */\n variant?: ButtonProps['variant'];\n /** The name of the icon for the MenuButton. */\n icon?: string;\n /** Only display the icon. The text prop will be forwarded to a tooltip. */\n iconOnly?: ButtonProps['icon'];\n /** The total count representing the list data which was selected. */\n count?: CountProps['children'];\n /** The click handler for the MenuButton. */\n onClick?: MouseEventHandler;\n /** Menu related props. */\n menu?: MenuProps;\n /** Popover related props. */\n popover?: OmitStrict<PopoverProps, 'show' | 'target' | 'children'>;\n /** DOM id for the button element. */\n id?: string;\n /** Ref for the button element. */\n ref?: ButtonProps['ref'];\n /** The keydown handler for the MenuButton. */\n onKeyDown?: KeyboardEventHandler;\n /**\n * Whether to display an arrow when only the icon is displayed.\n * Only applies when `iconOnly` is true.\n * @default false\n */\n showArrow?: boolean;\n}\n\nexport const StyledMenuButton = styled.button(\n ({\n theme: {\n base: { spacing }\n }\n }) => {\n return css`\n gap: ${spacing};\n flex-shrink: 0;\n white-space: nowrap;\n max-width: 100%;\n\n & + ${StyledPopover} + ${StyledButton} {\n margin-inline-start: ${spacing};\n }\n `;\n }\n);\n\nStyledMenuButton.defaultProps = defaultThemeProp;\n\nconst StyledMenuButtonChildren = styled.span<{ padIcon?: boolean }>(({ theme, padIcon }) => {\n const {\n base: {\n 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger }\n },\n components: {\n icon: {\n size: { s: iconSize }\n }\n }\n } = theme;\n\n return css`\n max-width: 100%;\n\n ${padIcon &&\n css`\n padding-inline-start: calc((${hitAreaMouse} - ${iconSize}) / 2);\n\n @media (pointer: coarse) {\n padding-inline-start: calc(${hitAreaFinger} - ${iconSize} * 2);\n }\n `}\n\n ${StyledText} {\n text-overflow: ellipsis;\n overflow: hidden;\n }\n\n ${StyledIcon}:last-child:not(:first-child) {\n /* Offsets the flex gap to make the down arrow appear to trail the text. */\n margin-inline-start: -${theme.base.spacing};\n }\n `;\n});\n\nconst StyledMenuButtonPopover = styled(Popover)`\n min-width: 20ch;\n`;\n\nconst MenuButton: ForwardRefForwardPropsComponent<MenuButtonProps> = forwardRef(function MenuButton(\n props: PropsWithoutRef<MenuButtonProps>,\n ref: MenuButtonProps['ref']\n) {\n const uid = useUID();\n const {\n testId,\n id = uid,\n text,\n menu,\n popover,\n onClick,\n icon,\n count,\n iconOnly = false,\n showArrow = false,\n ...restProps\n } = props;\n const testIds = useTestIds(testId, getMenuButtonTestIds);\n const [isOpen, setIsOpen] = useState(false);\n\n const buttonRef = useConsolidatedRef(ref);\n // Force re-render when popoverRef is set, so useFocusWithin has a non-null ref to read\n const [, forceRerender] = useElement(null);\n const popoverRef = useConsolidatedRef<HTMLDivElement>(popover?.ref, forceRerender);\n const filterInputRef = useConsolidatedRef<HTMLInputElement>(menu?.filterInputProps?.ref);\n const menuRef = useConsolidatedRef<HTMLDivElement>(menu?.ref);\n\n // FIXME: Type assertion required for issue in useFocusWithin generic\n useFocusWithin<HTMLElement>(\n [popoverRef, buttonRef],\n useCallback((isFocused: boolean) => {\n if (!isFocused) setIsOpen(false);\n }, [])\n );\n\n useEscape(e => {\n if (isOpen) {\n setIsOpen(false);\n e.stopPropagation();\n }\n }, buttonRef);\n\n useEscape(e => {\n if (isOpen) {\n setIsOpen(false);\n e.stopPropagation();\n buttonRef.current?.focus();\n }\n }, menu?.focusControlEl);\n\n useEscape(e => {\n if (isOpen) {\n setIsOpen(false);\n e.stopPropagation();\n buttonRef.current?.focus();\n }\n }, filterInputRef);\n\n const { rtl } = useDirection();\n\n return (\n <>\n <Button\n data-testid={testIds.root}\n as={StyledMenuButton}\n aria-label={text}\n {...restProps}\n id={id}\n ref={buttonRef}\n aria-expanded={isOpen}\n aria-haspopup='menu'\n aria-controls={isOpen ? `${id}-popover` : undefined}\n label={iconOnly && !isOpen ? text : undefined}\n onClick={(e: MouseEvent<HTMLButtonElement> & UIEvent<HTMLButtonElement>) => {\n // e.detail is 0 when triggered by keyboard.\n const mouseClick = e.detail > 0;\n\n if (isOpen) {\n if (mouseClick) {\n // Close the menu if it is open and it is a *mouse* click on the button.\n setIsOpen(false);\n }\n } else {\n // Open the menu if it's closed, for mouse or keyboard click.\n setIsOpen(true);\n }\n\n // If the menu is closed or the user mouse clicks.\n // This avoids Enter key firing onClick when selecting a menu item.\n if (!isOpen || mouseClick) {\n onClick?.(e);\n }\n }}\n icon={iconOnly}\n >\n <Flex\n as={StyledMenuButtonChildren}\n container={{ alignItems: 'center', gap: 1 }}\n padIcon={iconOnly && showArrow}\n >\n {icon && <Icon name={icon} />}\n {!iconOnly && (\n <>\n <Text>{text}</Text>\n {typeof count === 'number' && <Count>{count}</Count>}\n </>\n )}\n {(!iconOnly || showArrow) && <Icon name='arrow-micro-down' />}\n </Flex>\n </Button>\n\n <StyledMenuButtonPopover\n placement={rtl ? 'bottom-end' : 'bottom-start'}\n hideOnTargetHidden\n {...popover}\n id={`${id}-popover`}\n show={!!menu && isOpen}\n target={buttonRef.current}\n ref={popoverRef}\n >\n {menu && (\n <Menu\n testId={testIds.root}\n {...menu}\n ref={menuRef}\n items={menu.items}\n onItemClick={(itemId, e) => {\n // When clicking an item (by mouse or keyboard) and the menu is not multi-select, close the menu.\n if (menu.mode !== 'multi-select') {\n setIsOpen(false);\n }\n menu.onItemClick?.(itemId, e);\n }}\n focusControlEl={menu.focusControlEl || buttonRef.current || undefined}\n />\n )}\n </StyledMenuButtonPopover>\n </>\n );\n});\n\nexport default withTestIds(MenuButton, getMenuButtonTestIds);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../src/components/TextArea/TextArea.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAqC,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAEvF,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AASvD,MAAM,WAAW,aAAc,SAAQ,gBAAgB,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU;IAC5F,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;CACpD;;;;
|
|
1
|
+
{"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../src/components/TextArea/TextArea.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAqC,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAEvF,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AASvD,MAAM,WAAW,aAAc,SAAQ,gBAAgB,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU;IAC5F,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;CACpD;;;;AAuID,wBAAyD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useCallback, useState, useEffect
|
|
2
|
+
import { forwardRef, useCallback, useState, useEffect } from 'react';
|
|
3
3
|
import FormField from '../FormField';
|
|
4
4
|
import { StyledFormControl } from '../FormControl';
|
|
5
5
|
import { hasProp, withTestIds } from '../../utils';
|
|
@@ -30,16 +30,6 @@ const TextArea = forwardRef(function TextArea(props, ref) {
|
|
|
30
30
|
setCharCount(e.target.value.length);
|
|
31
31
|
}
|
|
32
32
|
}, [onChangeProp, hardStop, maxLength]);
|
|
33
|
-
const ariaDescribedBy = useMemo(() => {
|
|
34
|
-
const idString = [];
|
|
35
|
-
if (info) {
|
|
36
|
-
idString.push(`${id}-info`);
|
|
37
|
-
}
|
|
38
|
-
if (displayCharCount && typeof maxLength === 'number') {
|
|
39
|
-
idString.push(`${id}-charCount`);
|
|
40
|
-
}
|
|
41
|
-
return idString.length ? idString.join(' ') : undefined;
|
|
42
|
-
}, [info, id, displayCharCount, maxLength]);
|
|
43
33
|
useEffect(() => {
|
|
44
34
|
if (!textAreaRef.current)
|
|
45
35
|
return;
|
|
@@ -57,7 +47,7 @@ const TextArea = forwardRef(function TextArea(props, ref) {
|
|
|
57
47
|
textAreaRef.current.style.removeProperty('--textarea-height');
|
|
58
48
|
}
|
|
59
49
|
}, [value, autoResize]);
|
|
60
|
-
const TextAreaControl = (_jsx(StyledFormControl, { "data-testid": testIds.control, ref: consolidatedRef, id: id, "aria-describedby":
|
|
50
|
+
const TextAreaControl = (_jsx(StyledFormControl, { "data-testid": testIds.control, ref: consolidatedRef, id: id, "aria-describedby": displayCharCount && typeof maxLength === 'number' ? `${id}-charCount` : undefined, required: required, disabled: disabled, status: status, readOnly: readOnly, autoResize: autoResize, resizable: autoResize ? false : resizable, maxLength: hardStop ? maxLength : undefined, hasSuggestion: status === 'pending' && !!onResolveSuggestion, ...controlProp, ...restProps, onChange: onChange, as: StyledTextArea }));
|
|
61
51
|
return label || displayCharCount ? (_jsx(FormField, { testId: testIds, additionalInfo: additionalInfo, label: label, labelHidden: labelHidden, id: id, readOnly: readOnly, info: info, status: status, charLimitDisplay: displayCharCount && typeof maxLength === 'number' ? (_jsxs(Text, { id: `${id}-charCount`, readOnly: readOnly, variant: 'secondary', "aria-live": maxLength >= 0 && maxLength - charCount <= 20 ? 'polite' : 'off', children: [maxLength >= 0 ? t('x_of_y', [charCount || '0', maxLength]) : charCount, ' ', _jsx(VisuallyHiddenText, { children: t('characters_typed') })] })) : undefined, required: required, disabled: disabled, onResolveSuggestion: onResolveSuggestion, children: TextAreaControl })) : (TextAreaControl);
|
|
62
52
|
});
|
|
63
53
|
export default withTestIds(TextArea, getTextAreaTestIds);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextArea.js","sourceRoot":"","sources":["../../../src/components/TextArea/TextArea.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAI9E,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC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AQ,EAAE,QAAQ,EAClB,EAAE,EAAE,cAAc,GAClB,CACH,CAAC;IAEF,OAAO,KAAK,IAAI,gBAAgB,CAAC,CAAC,CAAC,CACjC,KAAC,SAAS,IACR,MAAM,EAAE,OAAO,EACf,cAAc,EAAE,cAAc,EAC9B,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,EAAE,EAAE,EAAE,EACN,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,gBAAgB,EACd,gBAAgB,IAAI,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,CAClD,MAAC,IAAI,IACH,EAAE,EAAE,GAAG,EAAE,YAAY,EACrB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAC,WAAW,eACR,SAAS,IAAI,CAAC,IAAI,SAAS,GAAG,SAAS,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,aAE1E,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,SAAS,IAAI,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,GAAG,EAC7E,KAAC,kBAAkB,cAAE,CAAC,CAAC,kBAAkB,CAAC,GAAsB,IAC3D,CACR,CAAC,CAAC,CAAC,SAAS,EAEf,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,mBAAmB,EAAE,mBAAmB,YAEvC,eAAe,GACN,CACb,CAAC,CAAC,CAAC,CACF,eAAe,CAChB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import { forwardRef, useCallback, useState, useEffect, useMemo } from 'react';\nimport type { FC, Ref, PropsWithoutRef, ChangeEvent, ChangeEventHandler } from 'react';\n\nimport type { BaseProps, ForwardProps, NoChildrenProp, TestIdProp } from '../../types';\nimport FormField from '../FormField';\nimport { StyledFormControl } from '../FormControl';\nimport type { FormControlProps } from '../FormControl';\nimport { hasProp, withTestIds } from '../../utils';\nimport { useConsolidatedRef, useI18n, useTestIds, useUID } from '../../hooks';\nimport Text from '../Text';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\n\nimport StyledTextArea from './TextArea.styles';\nimport { getTextAreaTestIds } from './TextArea.test-ids';\n\nexport interface TextAreaProps extends FormControlProps, BaseProps, NoChildrenProp, TestIdProp {\n /** Minimum length of characters that can be input. */\n minLength?: number;\n /** Maximum length of characters that can be input. */\n maxLength?: number;\n /**\n * Allows the user to resize the Text Area. This prop is ignored if autoResize is true.\n * @default false\n */\n resizable?: boolean;\n /**\n * Enables the Text Area to resize itself automatically.\n * @default true\n */\n autoResize?: boolean;\n /**\n * Display a live character count in relation to the maxLength.\n * @default false\n */\n displayCharCount?: boolean;\n /**\n * Allow or disallow a value beyond the maxLength.\n * @default true\n */\n hardStop?: boolean;\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n}\n\nconst TextArea: FC<TextAreaProps & ForwardProps> = forwardRef(function TextArea(\n props: PropsWithoutRef<TextAreaProps>,\n ref: Ref<HTMLTextAreaElement>\n) {\n const uid = useUID();\n const {\n testId,\n additionalInfo,\n id = uid,\n value,\n defaultValue,\n required = false,\n disabled = false,\n readOnly = false,\n label,\n labelHidden,\n info,\n status,\n resizable = false,\n autoResize = true,\n maxLength,\n displayCharCount = false,\n hardStop = true,\n onChange: onChangeProp,\n onResolveSuggestion,\n ...restProps\n } = props;\n const t = useI18n();\n\n const testIds = useTestIds(testId, getTextAreaTestIds);\n const [charCount, setCharCount] = useState(0);\n const textAreaRef = useConsolidatedRef(ref);\n const consolidatedRef = useConsolidatedRef(ref, textAreaRef);\n\n const controlProp: {\n value?: string;\n defaultValue?: string;\n } = {};\n\n // Conditionally render component as controlled/uncontrolled\n if (hasProp(props, 'value')) {\n controlProp.value = value ?? '';\n } else if (hasProp(props, 'defaultValue')) {\n controlProp.defaultValue = defaultValue ?? '';\n }\n\n const onChange = useCallback(\n (e: ChangeEvent<HTMLTextAreaElement>) => {\n if (!hardStop || maxLength === undefined || e.target.value.length <= maxLength) {\n onChangeProp?.(e);\n setCharCount(e.target.value.length);\n }\n },\n [onChangeProp, hardStop, maxLength]\n );\n\n const ariaDescribedBy = useMemo(() => {\n const idString = [];\n\n if (info) {\n idString.push(`${id}-info`);\n }\n if (displayCharCount && typeof maxLength === 'number') {\n idString.push(`${id}-charCount`);\n }\n\n return idString.length ? idString.join(' ') : undefined;\n }, [info, id, displayCharCount, maxLength]);\n\n useEffect(() => {\n if (!textAreaRef.current) return;\n\n if (autoResize) {\n textAreaRef.current.style.setProperty('--textarea-height', 'auto');\n\n // Remove scrollbar width to avoid interference with calculation.\n textAreaRef.current.style.setProperty('scrollbar-width', 'none');\n\n const scrollHeight = textAreaRef.current.scrollHeight;\n const borderWidth = textAreaRef.current.offsetHeight - textAreaRef.current.clientHeight;\n // Set height to auto then scrollHeight + borderWidth to resize TextArea to content\n textAreaRef.current.style.setProperty('--textarea-height', `${scrollHeight + borderWidth}px`);\n\n textAreaRef.current.style.removeProperty('scrollbar-width');\n } else {\n textAreaRef.current.style.removeProperty('--textarea-height');\n }\n }, [value, autoResize]);\n\n const TextAreaControl = (\n <StyledFormControl\n data-testid={testIds.control}\n ref={consolidatedRef}\n id={id}\n aria-describedby={ariaDescribedBy}\n required={required}\n disabled={disabled}\n status={status}\n readOnly={readOnly}\n autoResize={autoResize}\n resizable={autoResize ? false : resizable}\n maxLength={hardStop ? maxLength : undefined}\n hasSuggestion={status === 'pending' && !!onResolveSuggestion}\n {...controlProp}\n {...restProps}\n onChange={onChange}\n as={StyledTextArea}\n />\n );\n\n return label || displayCharCount ? (\n <FormField\n testId={testIds}\n additionalInfo={additionalInfo}\n label={label}\n labelHidden={labelHidden}\n id={id}\n readOnly={readOnly}\n info={info}\n status={status}\n charLimitDisplay={\n displayCharCount && typeof maxLength === 'number' ? (\n <Text\n id={`${id}-charCount`}\n readOnly={readOnly}\n variant='secondary'\n aria-live={maxLength >= 0 && maxLength - charCount <= 20 ? 'polite' : 'off'}\n >\n {maxLength >= 0 ? t('x_of_y', [charCount || '0', maxLength]) : charCount}{' '}\n <VisuallyHiddenText>{t('characters_typed')}</VisuallyHiddenText>\n </Text>\n ) : undefined\n }\n required={required}\n disabled={disabled}\n onResolveSuggestion={onResolveSuggestion}\n >\n {TextAreaControl}\n </FormField>\n ) : (\n TextAreaControl\n );\n});\n\nexport default withTestIds(TextArea, getTextAreaTestIds);\n"]}
|
|
1
|
+
{"version":3,"file":"TextArea.js","sourceRoot":"","sources":["../../../src/components/TextArea/TextArea.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIrE,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AAEvD,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AA8BzD,MAAM,QAAQ,GAAqC,UAAU,CAAC,SAAS,QAAQ,CAC7E,KAAqC,EACrC,GAA6B;IAE7B,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IACrB,MAAM,EACJ,MAAM,EACN,cAAc,EACd,EAAE,GAAG,GAAG,EACR,KAAK,EACL,YAAY,EACZ,QAAQ,GAAG,KAAK,EAChB,QAAQ,GAAG,KAAK,EAChB,QAAQ,GAAG,KAAK,EAChB,KA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CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import { forwardRef, useCallback, useState, useEffect } from 'react';\nimport type { FC, Ref, PropsWithoutRef, ChangeEvent, ChangeEventHandler } from 'react';\n\nimport type { BaseProps, ForwardProps, NoChildrenProp, TestIdProp } from '../../types';\nimport FormField from '../FormField';\nimport { StyledFormControl } from '../FormControl';\nimport type { FormControlProps } from '../FormControl';\nimport { hasProp, withTestIds } from '../../utils';\nimport { useConsolidatedRef, useI18n, useTestIds, useUID } from '../../hooks';\nimport Text from '../Text';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\n\nimport StyledTextArea from './TextArea.styles';\nimport { getTextAreaTestIds } from './TextArea.test-ids';\n\nexport interface TextAreaProps extends FormControlProps, BaseProps, NoChildrenProp, TestIdProp {\n /** Minimum length of characters that can be input. */\n minLength?: number;\n /** Maximum length of characters that can be input. */\n maxLength?: number;\n /**\n * Allows the user to resize the Text Area. This prop is ignored if autoResize is true.\n * @default false\n */\n resizable?: boolean;\n /**\n * Enables the Text Area to resize itself automatically.\n * @default true\n */\n autoResize?: boolean;\n /**\n * Display a live character count in relation to the maxLength.\n * @default false\n */\n displayCharCount?: boolean;\n /**\n * Allow or disallow a value beyond the maxLength.\n * @default true\n */\n hardStop?: boolean;\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n}\n\nconst TextArea: FC<TextAreaProps & ForwardProps> = forwardRef(function TextArea(\n props: PropsWithoutRef<TextAreaProps>,\n ref: Ref<HTMLTextAreaElement>\n) {\n const uid = useUID();\n const {\n testId,\n additionalInfo,\n id = uid,\n value,\n defaultValue,\n required = false,\n disabled = false,\n readOnly = false,\n label,\n labelHidden,\n info,\n status,\n resizable = false,\n autoResize = true,\n maxLength,\n displayCharCount = false,\n hardStop = true,\n onChange: onChangeProp,\n onResolveSuggestion,\n ...restProps\n } = props;\n const t = useI18n();\n\n const testIds = useTestIds(testId, getTextAreaTestIds);\n const [charCount, setCharCount] = useState(0);\n const textAreaRef = useConsolidatedRef(ref);\n const consolidatedRef = useConsolidatedRef(ref, textAreaRef);\n\n const controlProp: {\n value?: string;\n defaultValue?: string;\n } = {};\n\n // Conditionally render component as controlled/uncontrolled\n if (hasProp(props, 'value')) {\n controlProp.value = value ?? '';\n } else if (hasProp(props, 'defaultValue')) {\n controlProp.defaultValue = defaultValue ?? '';\n }\n\n const onChange = useCallback(\n (e: ChangeEvent<HTMLTextAreaElement>) => {\n if (!hardStop || maxLength === undefined || e.target.value.length <= maxLength) {\n onChangeProp?.(e);\n setCharCount(e.target.value.length);\n }\n },\n [onChangeProp, hardStop, maxLength]\n );\n\n useEffect(() => {\n if (!textAreaRef.current) return;\n\n if (autoResize) {\n textAreaRef.current.style.setProperty('--textarea-height', 'auto');\n\n // Remove scrollbar width to avoid interference with calculation.\n textAreaRef.current.style.setProperty('scrollbar-width', 'none');\n\n const scrollHeight = textAreaRef.current.scrollHeight;\n const borderWidth = textAreaRef.current.offsetHeight - textAreaRef.current.clientHeight;\n // Set height to auto then scrollHeight + borderWidth to resize TextArea to content\n textAreaRef.current.style.setProperty('--textarea-height', `${scrollHeight + borderWidth}px`);\n\n textAreaRef.current.style.removeProperty('scrollbar-width');\n } else {\n textAreaRef.current.style.removeProperty('--textarea-height');\n }\n }, [value, autoResize]);\n\n const TextAreaControl = (\n <StyledFormControl\n data-testid={testIds.control}\n ref={consolidatedRef}\n id={id}\n aria-describedby={\n displayCharCount && typeof maxLength === 'number' ? `${id}-charCount` : undefined\n }\n required={required}\n disabled={disabled}\n status={status}\n readOnly={readOnly}\n autoResize={autoResize}\n resizable={autoResize ? false : resizable}\n maxLength={hardStop ? maxLength : undefined}\n hasSuggestion={status === 'pending' && !!onResolveSuggestion}\n {...controlProp}\n {...restProps}\n onChange={onChange}\n as={StyledTextArea}\n />\n );\n\n return label || displayCharCount ? (\n <FormField\n testId={testIds}\n additionalInfo={additionalInfo}\n label={label}\n labelHidden={labelHidden}\n id={id}\n readOnly={readOnly}\n info={info}\n status={status}\n charLimitDisplay={\n displayCharCount && typeof maxLength === 'number' ? (\n <Text\n id={`${id}-charCount`}\n readOnly={readOnly}\n variant='secondary'\n aria-live={maxLength >= 0 && maxLength - charCount <= 20 ? 'polite' : 'off'}\n >\n {maxLength >= 0 ? t('x_of_y', [charCount || '0', maxLength]) : charCount}{' '}\n <VisuallyHiddenText>{t('characters_typed')}</VisuallyHiddenText>\n </Text>\n ) : undefined\n }\n required={required}\n disabled={disabled}\n onResolveSuggestion={onResolveSuggestion}\n >\n {TextAreaControl}\n </FormField>\n ) : (\n TextAreaControl\n );\n});\n\nexport default withTestIds(TextArea, getTextAreaTestIds);\n"]}
|
package/lib/hooks/useI18n.d.ts
CHANGED
|
@@ -284,6 +284,7 @@ declare const useI18n: () => import("../i18n/translate").TranslationFunction<Rea
|
|
|
284
284
|
composite_input_open_button_a11y: string;
|
|
285
285
|
composite_input_close_button_a11y: string;
|
|
286
286
|
menu_selection_instructions: string;
|
|
287
|
+
menu_filter_instructions: string;
|
|
287
288
|
menu_item_expand_arrow: string;
|
|
288
289
|
menu_item_collapse_arrow: string;
|
|
289
290
|
menu_item_collapse_shift_space: string;
|
|
@@ -919,6 +920,14 @@ declare const useI18n: () => import("../i18n/translate").TranslationFunction<Rea
|
|
|
919
920
|
many: string;
|
|
920
921
|
other: string;
|
|
921
922
|
};
|
|
923
|
+
detected_entities_label: {
|
|
924
|
+
zero: string;
|
|
925
|
+
one: string;
|
|
926
|
+
two: string;
|
|
927
|
+
few: string;
|
|
928
|
+
many: string;
|
|
929
|
+
other: string;
|
|
930
|
+
};
|
|
922
931
|
show_detected_entities: string;
|
|
923
932
|
nothing_detected_yet: string;
|
|
924
933
|
ai_detected_entities: string;
|
|
@@ -937,7 +946,6 @@ declare const useI18n: () => import("../i18n/translate").TranslationFunction<Rea
|
|
|
937
946
|
follow_up_tasks: string;
|
|
938
947
|
add_follow_up_task: string;
|
|
939
948
|
agents_utterance: string;
|
|
940
|
-
detected_entities: string;
|
|
941
949
|
task_deleted: string;
|
|
942
950
|
no_analytics_collected: string;
|
|
943
951
|
feedback_not_available: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useI18n.d.ts","sourceRoot":"","sources":["../../src/hooks/useI18n.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,QAAA,MAAM,OAAO
|
|
1
|
+
{"version":3,"file":"useI18n.d.ts","sourceRoot":"","sources":["../../src/hooks/useI18n.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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11y: string;
|
|
281
281
|
composite_input_close_button_a11y: string;
|
|
282
282
|
menu_selection_instructions: string;
|
|
283
|
+
menu_filter_instructions: string;
|
|
283
284
|
menu_item_expand_arrow: string;
|
|
284
285
|
menu_item_collapse_arrow: string;
|
|
285
286
|
menu_item_collapse_shift_space: string;
|
|
@@ -915,6 +916,14 @@ declare const _default: {
|
|
|
915
916
|
many: string;
|
|
916
917
|
other: string;
|
|
917
918
|
};
|
|
919
|
+
detected_entities_label: {
|
|
920
|
+
zero: string;
|
|
921
|
+
one: string;
|
|
922
|
+
two: string;
|
|
923
|
+
few: string;
|
|
924
|
+
many: string;
|
|
925
|
+
other: string;
|
|
926
|
+
};
|
|
918
927
|
show_detected_entities: string;
|
|
919
928
|
nothing_detected_yet: string;
|
|
920
929
|
ai_detected_entities: string;
|
|
@@ -933,7 +942,6 @@ declare const _default: {
|
|
|
933
942
|
follow_up_tasks: string;
|
|
934
943
|
add_follow_up_task: string;
|
|
935
944
|
agents_utterance: string;
|
|
936
|
-
detected_entities: string;
|
|
937
945
|
task_deleted: string;
|
|
938
946
|
no_analytics_collected: string;
|
|
939
947
|
feedback_not_available: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../src/i18n/default.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../src/i18n/default.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAiiDE,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAqMxB,6CAA6C;;;;IAK7C,4CAA4C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2F5C,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2C/B,uCAAuC;;;;;;;;;;;IAavC,6CAA6C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA93D/C,wBAm7DE"}
|
package/lib/i18n/default.js
CHANGED
|
@@ -305,6 +305,7 @@ export default {
|
|
|
305
305
|
composite_input_close_button_a11y: 'Close configuration dialog',
|
|
306
306
|
/* core:Menu */
|
|
307
307
|
menu_selection_instructions: 'Press enter to select items.',
|
|
308
|
+
menu_filter_instructions: 'Start typing to filter.',
|
|
308
309
|
menu_item_expand_arrow: '{0}. Arrow right to expand.',
|
|
309
310
|
menu_item_collapse_arrow: 'Arrow left to collapse.',
|
|
310
311
|
menu_item_collapse_shift_space: 'Press shift space to collapse.',
|
|
@@ -988,6 +989,14 @@ export default {
|
|
|
988
989
|
many: 'Add {0} new items',
|
|
989
990
|
other: 'Add {0} new items'
|
|
990
991
|
},
|
|
992
|
+
detected_entities_label: {
|
|
993
|
+
zero: 'No detected entities',
|
|
994
|
+
one: '{0} detected entity',
|
|
995
|
+
two: '{0} detected entities',
|
|
996
|
+
few: '{0} detected entities',
|
|
997
|
+
many: '{0} detected entities',
|
|
998
|
+
other: '{0} detected entities'
|
|
999
|
+
},
|
|
991
1000
|
show_detected_entities: 'Show detected entities',
|
|
992
1001
|
nothing_detected_yet: 'Nothing detected yet',
|
|
993
1002
|
ai_detected_entities: 'AI detected entities',
|
|
@@ -1006,7 +1015,6 @@ export default {
|
|
|
1006
1015
|
follow_up_tasks: 'Follow-up tasks',
|
|
1007
1016
|
add_follow_up_task: 'Add follow-up task',
|
|
1008
1017
|
agents_utterance: "Agent's commitment in context",
|
|
1009
|
-
detected_entities: 'Detected entities',
|
|
1010
1018
|
task_deleted: 'Deleted',
|
|
1011
1019
|
/* cs:FeedbackMetrics */
|
|
1012
1020
|
no_analytics_collected: 'No analytics were collected during this interaction',
|