@pega/cosmos-react-core 10.0.0-build.4.2 → 10.0.0-build.4.21
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/AppShell/AppHeader.d.ts.map +1 -1
- package/lib/components/AppShell/AppHeader.js +44 -7
- package/lib/components/AppShell/AppHeader.js.map +1 -1
- package/lib/components/AppShell/AppHeader.styles.d.ts +6 -2
- package/lib/components/AppShell/AppHeader.styles.d.ts.map +1 -1
- package/lib/components/AppShell/AppHeader.styles.js +36 -18
- package/lib/components/AppShell/AppHeader.styles.js.map +1 -1
- package/lib/components/AppShell/AppNavigationPanel.js +1 -1
- package/lib/components/AppShell/AppNavigationPanel.js.map +1 -1
- package/lib/components/AppShell/AppShell.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.js +27 -9
- package/lib/components/AppShell/AppShell.js.map +1 -1
- package/lib/components/AppShell/AppShellContext.d.ts +1 -0
- package/lib/components/AppShell/AppShellContext.d.ts.map +1 -1
- package/lib/components/AppShell/AppShellContext.js +1 -0
- package/lib/components/AppShell/AppShellContext.js.map +1 -1
- package/lib/components/AppShell/AppShellList.js +1 -1
- package/lib/components/AppShell/AppShellList.js.map +1 -1
- package/lib/components/AppShell/NavigationList.d.ts.map +1 -1
- package/lib/components/AppShell/NavigationList.js +3 -2
- package/lib/components/AppShell/NavigationList.js.map +1 -1
- package/lib/components/AppShell/NavigationListItemWrapper.d.ts.map +1 -1
- package/lib/components/AppShell/NavigationListItemWrapper.js +87 -48
- package/lib/components/AppShell/NavigationListItemWrapper.js.map +1 -1
- package/lib/components/Avatar/Avatar.d.ts +1 -1
- package/lib/components/Avatar/Avatar.d.ts.map +1 -1
- package/lib/components/Avatar/Avatar.js.map +1 -1
- package/lib/components/Badges/Selection.js +1 -1
- package/lib/components/Badges/Selection.js.map +1 -1
- package/lib/components/ComboBox/ComboBox.d.ts.map +1 -1
- package/lib/components/ComboBox/ComboBox.js +3 -6
- package/lib/components/ComboBox/ComboBox.js.map +1 -1
- package/lib/components/ComboBox/ComboBox.styles.d.ts.map +1 -1
- package/lib/components/ComboBox/ComboBox.styles.js +9 -1
- package/lib/components/ComboBox/ComboBox.styles.js.map +1 -1
- package/lib/components/ComboBox/ComboBoxInput.d.ts +0 -2
- package/lib/components/ComboBox/ComboBoxInput.d.ts.map +1 -1
- package/lib/components/ComboBox/ComboBoxInput.js +2 -2
- package/lib/components/ComboBox/ComboBoxInput.js.map +1 -1
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.d.ts +4 -6
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.d.ts.map +1 -1
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js +96 -189
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js.map +1 -1
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.styles.d.ts +190 -0
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.styles.d.ts.map +1 -0
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.styles.js +72 -0
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.styles.js.map +1 -0
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.types.d.ts +0 -2
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.types.d.ts.map +1 -1
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.types.js.map +1 -1
- package/lib/components/Configuration/Configuration.d.ts.map +1 -1
- package/lib/components/Configuration/Configuration.js +3 -1
- package/lib/components/Configuration/Configuration.js.map +1 -1
- package/lib/components/Currency/CurrencyInput.d.ts.map +1 -1
- package/lib/components/Currency/CurrencyInput.js +19 -12
- package/lib/components/Currency/CurrencyInput.js.map +1 -1
- package/lib/components/Currency/utils.d.ts +8 -0
- package/lib/components/Currency/utils.d.ts.map +1 -1
- package/lib/components/Currency/utils.js +34 -4
- package/lib/components/Currency/utils.js.map +1 -1
- package/lib/components/DateTime/DateTimeDisplay.d.ts +2 -2
- package/lib/components/DateTime/DateTimeDisplay.d.ts.map +1 -1
- package/lib/components/DateTime/DateTimeDisplay.js +29 -4
- package/lib/components/DateTime/DateTimeDisplay.js.map +1 -1
- package/lib/components/DateTime/Input/DateInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/DateInput.js +7 -7
- package/lib/components/DateTime/Input/DateInput.js.map +1 -1
- package/lib/components/DateTime/Input/DateRangeInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/DateRangeInput.js +8 -2
- package/lib/components/DateTime/Input/DateRangeInput.js.map +1 -1
- package/lib/components/DateTime/Input/DateTimeInput.d.ts +1 -1
- package/lib/components/DateTime/Input/DateTimeInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/DateTimeInput.js +8 -8
- package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
- package/lib/components/DateTime/Input/MonthInput.js +2 -2
- package/lib/components/DateTime/Input/MonthInput.js.map +1 -1
- package/lib/components/DateTime/Input/QuarterInput.js +2 -2
- package/lib/components/DateTime/Input/QuarterInput.js.map +1 -1
- package/lib/components/DateTime/Input/TimeInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/TimeInput.js +3 -3
- package/lib/components/DateTime/Input/TimeInput.js.map +1 -1
- package/lib/components/DateTime/Input/TimeRangeInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/TimeRangeInput.js +12 -4
- package/lib/components/DateTime/Input/TimeRangeInput.js.map +1 -1
- package/lib/components/DateTime/Input/WeekInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/WeekInput.js +2 -2
- package/lib/components/DateTime/Input/WeekInput.js.map +1 -1
- package/lib/components/DateTime/Input/utils.d.ts +6 -0
- package/lib/components/DateTime/Input/utils.d.ts.map +1 -1
- package/lib/components/DateTime/Input/utils.js +47 -0
- package/lib/components/DateTime/Input/utils.js.map +1 -1
- package/lib/components/DateTime/utils.d.ts +15 -4
- package/lib/components/DateTime/utils.d.ts.map +1 -1
- package/lib/components/DateTime/utils.js +24 -3
- package/lib/components/DateTime/utils.js.map +1 -1
- package/lib/components/Dialog/InfoDialogWrapper.d.ts +4 -0
- package/lib/components/Dialog/InfoDialogWrapper.d.ts.map +1 -0
- package/lib/components/Dialog/InfoDialogWrapper.js +13 -0
- package/lib/components/Dialog/InfoDialogWrapper.js.map +1 -0
- package/lib/components/Dialog/TouchDialog.d.ts +5 -0
- package/lib/components/Dialog/TouchDialog.d.ts.map +1 -0
- package/lib/components/Dialog/TouchDialog.js +85 -0
- package/lib/components/Dialog/TouchDialog.js.map +1 -0
- package/lib/components/Dialog/TouchDialog.styles.d.ts +7 -0
- package/lib/components/Dialog/TouchDialog.styles.d.ts.map +1 -0
- package/lib/components/Dialog/TouchDialog.styles.js +62 -0
- package/lib/components/Dialog/TouchDialog.styles.js.map +1 -0
- package/lib/components/Dialog/TouchDialog.test-ids.d.ts +2 -0
- package/lib/components/Dialog/TouchDialog.test-ids.d.ts.map +1 -0
- package/lib/components/Dialog/TouchDialog.test-ids.js +3 -0
- package/lib/components/Dialog/TouchDialog.test-ids.js.map +1 -0
- package/lib/components/Dialog/TouchDialog.types.d.ts +42 -0
- package/lib/components/Dialog/TouchDialog.types.d.ts.map +1 -0
- package/lib/components/Dialog/TouchDialog.types.js +2 -0
- package/lib/components/Dialog/TouchDialog.types.js.map +1 -0
- package/lib/components/Dialog/TouchInfoDialog.d.ts +4 -0
- package/lib/components/Dialog/TouchInfoDialog.d.ts.map +1 -0
- package/lib/components/Dialog/TouchInfoDialog.js +14 -0
- package/lib/components/Dialog/TouchInfoDialog.js.map +1 -0
- package/lib/components/Dialog/index.d.ts +4 -1
- package/lib/components/Dialog/index.d.ts.map +1 -1
- package/lib/components/Dialog/index.js +3 -1
- package/lib/components/Dialog/index.js.map +1 -1
- package/lib/components/FieldGroup/FieldGroup.d.ts +12 -7
- package/lib/components/FieldGroup/FieldGroup.d.ts.map +1 -1
- package/lib/components/FieldGroup/FieldGroup.js +28 -25
- package/lib/components/FieldGroup/FieldGroup.js.map +1 -1
- package/lib/components/FieldGroup/FieldGroupList.js +1 -1
- package/lib/components/FieldGroup/FieldGroupList.js.map +1 -1
- package/lib/components/FieldValueList/FieldValueList.d.ts +3 -1
- package/lib/components/FieldValueList/FieldValueList.d.ts.map +1 -1
- package/lib/components/FieldValueList/FieldValueList.js +15 -6
- package/lib/components/FieldValueList/FieldValueList.js.map +1 -1
- package/lib/components/File/CompactList.js +1 -1
- package/lib/components/File/CompactList.js.map +1 -1
- package/lib/components/File/FileItem.d.ts +38 -0
- package/lib/components/File/FileItem.d.ts.map +1 -1
- package/lib/components/File/FileItem.js +167 -23
- package/lib/components/File/FileItem.js.map +1 -1
- package/lib/components/File/FileList.d.ts.map +1 -1
- package/lib/components/File/FileList.js +6 -2
- package/lib/components/File/FileList.js.map +1 -1
- package/lib/components/File/index.d.ts +1 -1
- package/lib/components/File/index.d.ts.map +1 -1
- package/lib/components/File/index.js.map +1 -1
- package/lib/components/File/mimeTypes.json +1 -0
- package/lib/components/FormField/FormField.d.ts +9 -1
- package/lib/components/FormField/FormField.d.ts.map +1 -1
- package/lib/components/FormField/FormField.js +26 -10
- package/lib/components/FormField/FormField.js.map +1 -1
- package/lib/components/Icon/Icon.d.ts +5 -0
- package/lib/components/Icon/Icon.d.ts.map +1 -1
- package/lib/components/Icon/Icon.js +44 -4
- package/lib/components/Icon/Icon.js.map +1 -1
- package/lib/components/Icon/iconNames.d.ts +1 -0
- package/lib/components/Icon/iconNames.d.ts.map +1 -1
- package/lib/components/Icon/iconNames.js +1 -0
- package/lib/components/Icon/iconNames.js.map +1 -1
- package/lib/components/Icon/icons/search-solid.icon.d.ts +1 -1
- package/lib/components/Icon/icons/search-solid.icon.js +3 -3
- package/lib/components/Icon/icons/search-solid.icon.js.map +1 -1
- package/lib/components/Icon/streamlineIconNames.d.ts +1 -0
- package/lib/components/Icon/streamlineIconNames.d.ts.map +1 -1
- package/lib/components/Icon/streamlineIconNames.js +1 -0
- package/lib/components/Icon/streamlineIconNames.js.map +1 -1
- package/lib/components/Link/Link.d.ts +6 -13
- package/lib/components/Link/Link.d.ts.map +1 -1
- package/lib/components/Link/Link.js.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.d.ts.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.js +1 -1
- package/lib/components/ListToolbar/ListToolbar.js.map +1 -1
- package/lib/components/ListToolbar/PresetMenuPopover.d.ts.map +1 -1
- package/lib/components/ListToolbar/PresetMenuPopover.js +16 -5
- package/lib/components/ListToolbar/PresetMenuPopover.js.map +1 -1
- package/lib/components/MenuButton/MenuButton.d.ts.map +1 -1
- package/lib/components/MenuButton/MenuButton.js +33 -7
- package/lib/components/MenuButton/MenuButton.js.map +1 -1
- package/lib/components/MultiStepForm/FormProgress.styles.d.ts +25 -1
- package/lib/components/MultiStepForm/FormProgress.styles.d.ts.map +1 -1
- package/lib/components/MultiStepForm/FormProgress.styles.js +168 -5
- package/lib/components/MultiStepForm/FormProgress.styles.js.map +1 -1
- package/lib/components/MultiStepForm/HorizontalFormProgress.d.ts +2 -2
- package/lib/components/MultiStepForm/HorizontalFormProgress.d.ts.map +1 -1
- package/lib/components/MultiStepForm/HorizontalFormProgress.js +48 -22
- package/lib/components/MultiStepForm/HorizontalFormProgress.js.map +1 -1
- package/lib/components/MultiStepForm/MultiStepForm.d.ts.map +1 -1
- package/lib/components/MultiStepForm/MultiStepForm.js +2 -2
- package/lib/components/MultiStepForm/MultiStepForm.js.map +1 -1
- package/lib/components/MultiStepForm/MultiStepForm.types.d.ts +5 -0
- package/lib/components/MultiStepForm/MultiStepForm.types.d.ts.map +1 -1
- package/lib/components/MultiStepForm/MultiStepForm.types.js.map +1 -1
- package/lib/components/MultiStepForm/VerticalFormProgress.d.ts +2 -2
- package/lib/components/MultiStepForm/VerticalFormProgress.d.ts.map +1 -1
- package/lib/components/MultiStepForm/VerticalFormProgress.js +45 -20
- package/lib/components/MultiStepForm/VerticalFormProgress.js.map +1 -1
- package/lib/components/MultiStepForm/useFormProgressOverflow.d.ts +1 -1
- package/lib/components/MultiStepForm/useFormProgressOverflow.d.ts.map +1 -1
- package/lib/components/MultiStepForm/useFormProgressOverflow.js +17 -9
- package/lib/components/MultiStepForm/useFormProgressOverflow.js.map +1 -1
- package/lib/components/Number/utils.js +1 -1
- package/lib/components/Number/utils.js.map +1 -1
- package/lib/components/PageTemplates/PageTemplates.js +1 -1
- package/lib/components/PageTemplates/PageTemplates.js.map +1 -1
- package/lib/components/RadioCheckGroup/RadioCheckGroup.d.ts.map +1 -1
- package/lib/components/RadioCheckGroup/RadioCheckGroup.js +1 -1
- package/lib/components/RadioCheckGroup/RadioCheckGroup.js.map +1 -1
- package/lib/components/SelectionCard/SelectionCard.d.ts +1 -1
- package/lib/components/SelectionCard/SelectionCard.d.ts.map +1 -1
- package/lib/components/SelectionCard/SelectionCard.js +3 -3
- package/lib/components/SelectionCard/SelectionCard.js.map +1 -1
- package/lib/components/SelectionCard/SelectionCardDisplay.d.ts +5 -0
- package/lib/components/SelectionCard/SelectionCardDisplay.d.ts.map +1 -1
- package/lib/components/SelectionCard/SelectionCardDisplay.js +4 -2
- package/lib/components/SelectionCard/SelectionCardDisplay.js.map +1 -1
- package/lib/components/SpeechToTextButton/SpeechToTextButton.js +1 -1
- package/lib/components/SpeechToTextButton/SpeechToTextButton.js.map +1 -1
- package/lib/components/SummaryList/SummaryList.d.ts.map +1 -1
- package/lib/components/SummaryList/SummaryList.js +8 -4
- package/lib/components/SummaryList/SummaryList.js.map +1 -1
- package/lib/components/TextArea/TextArea.d.ts.map +1 -1
- package/lib/components/TextArea/TextArea.js +7 -21
- package/lib/components/TextArea/TextArea.js.map +1 -1
- package/lib/components/TextArea/TextArea.styles.d.ts +0 -1
- package/lib/components/TextArea/TextArea.styles.d.ts.map +1 -1
- package/lib/components/TextArea/TextArea.styles.js +1 -2
- package/lib/components/TextArea/TextArea.styles.js.map +1 -1
- package/lib/hooks/useI18n.d.ts +13 -9
- package/lib/hooks/useI18n.d.ts.map +1 -1
- package/lib/i18n/default.d.ts +13 -10
- package/lib/i18n/default.d.ts.map +1 -1
- package/lib/i18n/default.js +16 -12
- package/lib/i18n/default.js.map +1 -1
- package/lib/i18n/i18n.d.ts +13 -9
- package/lib/i18n/i18n.d.ts.map +1 -1
- package/lib/styles/GlobalStyle.d.ts.map +1 -1
- package/lib/styles/GlobalStyle.js +3 -3
- package/lib/styles/GlobalStyle.js.map +1 -1
- package/lib/theme/theme.d.ts +48 -0
- package/lib/theme/theme.d.ts.map +1 -1
- package/lib/theme/themeDefinition.json +26 -0
- package/lib/theme/themeOverrides.schema.json +36 -0
- package/lib/theme/themes/aurigaDarkTheme.json +54 -61
- package/lib/theme/themes/aurigaTheme.json +49 -56
- package/lib/theme/themes/virgoTheme.json +3 -3
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +1 -0
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/isTouchDevice.d.ts +3 -0
- package/lib/utils/isTouchDevice.d.ts.map +1 -0
- package/lib/utils/isTouchDevice.js +4 -0
- package/lib/utils/isTouchDevice.js.map +1 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBox.styles.d.ts","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.styles.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,oBAAoB;;2JA+B/B,CAAC;AAIH,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"ComboBox.styles.d.ts","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.styles.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,oBAAoB;;2JA+B/B,CAAC;AAIH,eAAO,MAAM,iBAAiB,6NA4D5B,CAAC;AAIH,eAAO,MAAM,cAAc;;;;mBAkBzB,CAAC"}
|
|
@@ -40,8 +40,16 @@ export const StyledDropdownButton = styled(Button)(({ theme }) => {
|
|
|
40
40
|
StyledDropdownButton.defaultProps = defaultThemeProp;
|
|
41
41
|
export const StyledSelectInput = styled.div(({ theme: { base, components } }) => {
|
|
42
42
|
return css `
|
|
43
|
+
height: ${components.input.height};
|
|
44
|
+
max-height: ${components.input.height};
|
|
45
|
+
|
|
46
|
+
/* Clip overflowing content, but leave room for a focus ring. */
|
|
47
|
+
overflow: clip;
|
|
48
|
+
overflow-clip-margin: 0.3rem;
|
|
49
|
+
|
|
43
50
|
@media (pointer: coarse) {
|
|
44
|
-
|
|
51
|
+
height: ${base['hit-area']['finger-min']};
|
|
52
|
+
max-height: ${base['hit-area']['finger-min']};
|
|
45
53
|
}
|
|
46
54
|
|
|
47
55
|
/*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBox.styles.js","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC/D,MAAM,gBAAgB,GAAG,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACrD,MAAM,uBAAuB,GAAG,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,eAAe,CAAC,CAAC;IAElF,OAAO,GAAG,CAAA;;;;;;oCAMwB,g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,CAAC,QAAQ,CAAC,CAAC,cAAc,CAAC;oBACtD,UAAU,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC;;;;;;;;;;qBAUjD,UAAU,CAAC,KAAK,CAAC,MAAM,UAAU,UAAU,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC;eACjF,UAAU,CAAC,cAAc,CAAC,CAAC,kBAAkB,CAAC;;wBAErC,IAAI,CAAC,OAAO;;;;;;;;;;;;;;GAcjC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,iBAAiB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAElD,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC,GAAG,EAAE;IAC3D,OAAO,GAAG,CAAA;;;;;;;MAON,aAAa;;;;QAIX,UAAU;QACV,qBAAqB;;;;GAI1B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport Button from '../Button';\nimport { StyledFormControl } from '../FormControl';\nimport { StyledPopover } from '../Popover';\nimport { StyledMenu, StyledMenuListWrapper } from '../Menu/Menu.styles';\nimport { StyledBackdrop } from '../Backdrop';\nimport { StyledProgressRing } from '../Progress';\n\nexport const StyledDropdownButton = styled(Button)(({ theme }) => {\n const baseBorderRadius = theme.base['border-radius'];\n const formControlBorderRadius = theme.components['form-control']['border-radius'];\n\n return css`\n align-self: stretch;\n height: auto;\n margin-block: -0.0625rem;\n margin-inline-end: -0.0625rem;\n border-start-start-radius: 0;\n border-start-end-radius: calc(${baseBorderRadius} * ${formControlBorderRadius});\n border-end-start-radius: 0;\n border-end-end-radius: calc(${baseBorderRadius} * ${formControlBorderRadius});\n\n &::after {\n content: '';\n pointer-events: none;\n position: absolute;\n z-index: 1;\n inset-inline-start: calc(${theme.components['form-control']['border-width']} * -1);\n inset-block: 0;\n width: ${theme.components['form-control']['border-width']};\n background-color: ${theme.components['form-control']['border-color']};\n transform: scaleY(0.5);\n transition: transform ${theme.base.animation.speed} ${theme.base.animation.timing.ease};\n }\n\n &:hover::after {\n transform: scaleY(1);\n }\n `;\n});\n\nStyledDropdownButton.defaultProps = defaultThemeProp;\n\nexport const StyledSelectInput = styled.div(({ theme: { base, components } }) => {\n return css`\n height: ${components.input.height};\n max-height: ${components.input.height};\n\n /* Clip overflowing content, but leave room for a focus ring. */\n overflow: clip;\n overflow-clip-margin: 0.3rem;\n\n @media (pointer: coarse) {\n height: ${base['hit-area']['finger-min']};\n max-height: ${base['hit-area']['finger-min']};\n }\n\n /*\n FIXME\n :not selectors needed to prevent greedy div selector affecting Progress styles.\n Best if div could be more targeted to specific classes.\n */\n div:not(${StyledBackdrop}, ${StyledBackdrop} div) {\n min-height: calc(\n ${components.input.height} - 2 * ${components['form-control']['border-width']}\n );\n }\n\n ${StyledProgressRing} svg {\n width: calc(${components.input.height} - 0.5rem);\n height: calc(${components.input.height} - 0.5rem);\n }\n\n &:focus-within {\n border-color: ${components['form-control'][':focus']['border-color']};\n box-shadow: ${components['form-control'][':focus']['box-shadow']};\n }\n\n &:hover:not([readonly]):not([disabled]):focus-within {\n border-color: transparent;\n }\n\n input {\n min-width: 0;\n width: 100%;\n height: calc(${components.input.height} - 2 * ${components['form-control']['border-width']});\n color: ${components['form-control']['foreground-color']};\n text-overflow: ellipsis;\n padding-inline: ${base.spacing};\n }\n\n input,\n input:focus {\n border: none;\n outline: none;\n flex-grow: 1;\n background-color: transparent;\n\n &:read-only {\n cursor: default;\n }\n }\n `;\n});\n\nStyledSelectInput.defaultProps = defaultThemeProp;\n\nexport const StyledComboBox = styled(StyledFormControl)(() => {\n return css`\n border: 0;\n\n &:focus {\n z-index: 1;\n }\n\n ${StyledPopover} {\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n\n ${StyledMenu},\n ${StyledMenuListWrapper} {\n max-height: inherit;\n }\n }\n `;\n});\n\nStyledComboBox.defaultProps = defaultThemeProp;\n"]}
|
|
@@ -15,8 +15,6 @@ interface ComboBoxInputProps extends BaseProps {
|
|
|
15
15
|
onSelectedFocus?: MultiSelectInputProps['onSelectedFocus'];
|
|
16
16
|
/** Callback on selected item pseudo blur */
|
|
17
17
|
onSelectedBlur?: MultiSelectInputProps['onSelectedBlur'];
|
|
18
|
-
/** Pause evaluation of selected item descendants */
|
|
19
|
-
pauseDescendantEvaluation?: MultiSelectInputProps['pauseDescendantEvaluation'];
|
|
20
18
|
}
|
|
21
19
|
declare const ComboBoxInput: FunctionComponent<ComboBoxInputProps & ForwardProps>;
|
|
22
20
|
export default ComboBoxInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBoxInput.d.ts","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBoxInput.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAwB,MAAM,OAAO,CAAC;AAErE,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAIxD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,UAAU,kBAAmB,SAAQ,SAAS;IAC5C,IAAI,CAAC,EAAE,cAAc,GAAG,eAAe,CAAC;IACxC,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE,CAAC;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/B,MAAM,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IACjC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,aAAa,CAAC,IAA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E,iBAAiB,CAAC,kBAAkB,GAAG,YAAY,CAiCvE,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -3,8 +3,8 @@ import { forwardRef } from 'react';
|
|
|
3
3
|
import SingleSelectInput from './SingleSelectInput/SingleSelectInput';
|
|
4
4
|
import MultiSelectInput from './MultiSelectInput/MultiSelectInput';
|
|
5
5
|
const ComboBoxInput = forwardRef(function ComboBoxInput(props, ref) {
|
|
6
|
-
const { value, mode, selected, visual, onRemove, onSelectedFocus, onSelectedBlur,
|
|
7
|
-
return mode === 'multi-select' ? (_jsx(MultiSelectInput, { selected: selected, value: value, ref: ref, onRemove: onRemove, onSelectedBlur: onSelectedBlur, onSelectedFocus: onSelectedFocus,
|
|
6
|
+
const { value, mode, selected, visual, onRemove, onSelectedFocus, onSelectedBlur, ...restProps } = props;
|
|
7
|
+
return mode === 'multi-select' ? (_jsx(MultiSelectInput, { selected: selected, value: value, ref: ref, onRemove: onRemove, onSelectedBlur: onSelectedBlur, onSelectedFocus: onSelectedFocus, ...restProps })) : (_jsx(SingleSelectInput, { ref: ref, selected: selected, value: value, visual: visual, ...restProps }));
|
|
8
8
|
});
|
|
9
9
|
export default ComboBoxInput;
|
|
10
10
|
//# sourceMappingURL=ComboBoxInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBoxInput.js","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBoxInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAMnC,OAAO,iBAAiB,MAAM,uCAAuC,CAAC;AACtE,OAAO,gBAAgB,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"ComboBoxInput.js","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBoxInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAMnC,OAAO,iBAAiB,MAAM,uCAAuC,CAAC;AACtE,OAAO,gBAAgB,MAAM,qCAAqC,CAAC;AAkBnE,MAAM,aAAa,GAAyD,UAAU,CACpF,SAAS,aAAa,CAAC,KAA0C,EAAE,GAA0B;IAC3F,MAAM,EACJ,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,eAAe,EACf,cAAc,EACd,GAAG,SAAS,EACb,GAAG,KAAK,CAAC;IAEV,OAAO,IAAI,KAAK,cAAc,CAAC,CAAC,CAAC,CAC/B,KAAC,gBAAgB,IACf,QAAQ,EAAE,QAAsB,EAChC,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,KAC5B,SAAS,GACb,CACH,CAAC,CAAC,CAAC,CACF,KAAC,iBAAiB,IAChB,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,QAAoB,EAC9B,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,KACV,SAAS,GACb,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { FunctionComponent, Ref, PropsWithoutRef } from 'react';\n\nimport type { BaseProps, ForwardProps } from '../../types';\nimport type { MenuItemProps } from '../Menu/Menu.types';\n\nimport SingleSelectInput from './SingleSelectInput/SingleSelectInput';\nimport MultiSelectInput from './MultiSelectInput/MultiSelectInput';\nimport type { MultiSelectInputProps } from './MultiSelectInput/MultiSelectInput.types';\nimport type ComboBoxProps from './ComboBox.types';\nimport type { Selected } from './ComboBox.types';\n\ninterface ComboBoxInputProps extends BaseProps {\n mode?: 'multi-select' | 'single-select';\n selected?: Selected | Selected[];\n loading?: boolean;\n value?: ComboBoxProps['value'];\n visual?: ComboBoxProps['visual'];\n onRemove?: (id: MenuItemProps['id'], index: number) => void;\n /** Callback on selected item pseudo focus */\n onSelectedFocus?: MultiSelectInputProps['onSelectedFocus'];\n /** Callback on selected item pseudo blur */\n onSelectedBlur?: MultiSelectInputProps['onSelectedBlur'];\n}\n\nconst ComboBoxInput: FunctionComponent<ComboBoxInputProps & ForwardProps> = forwardRef(\n function ComboBoxInput(props: PropsWithoutRef<ComboBoxInputProps>, ref: Ref<HTMLInputElement>) {\n const {\n value,\n mode,\n selected,\n visual,\n onRemove,\n onSelectedFocus,\n onSelectedBlur,\n ...restProps\n } = props;\n\n return mode === 'multi-select' ? (\n <MultiSelectInput\n selected={selected as Selected[]}\n value={value}\n ref={ref}\n onRemove={onRemove}\n onSelectedBlur={onSelectedBlur}\n onSelectedFocus={onSelectedFocus}\n {...restProps}\n />\n ) : (\n <SingleSelectInput\n ref={ref}\n selected={selected as Selected}\n value={value}\n visual={visual}\n {...restProps}\n />\n );\n }\n);\n\nexport default ComboBoxInput;\n"]}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
1
|
+
import type { WithAttributes } from '../../../types';
|
|
2
|
+
import StyledMultiSelectInput from './MultiSelectInput.styles';
|
|
3
3
|
import type { MultiSelectInputProps } from './MultiSelectInput.types';
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
}, never>> & string;
|
|
7
|
-
declare const MultiSelectInput: FunctionComponent<MultiSelectInputProps & ForwardProps>;
|
|
4
|
+
export { StyledMultiSelectInput };
|
|
5
|
+
declare const MultiSelectInput: import("react").ForwardRefExoticComponent<Omit<WithAttributes<"input", MultiSelectInputProps>, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
8
6
|
export default MultiSelectInput;
|
|
9
7
|
//# sourceMappingURL=MultiSelectInput.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelectInput.d.ts","sourceRoot":"","sources":["../../../../src/components/ComboBox/MultiSelectInput/MultiSelectInput.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MultiSelectInput.d.ts","sourceRoot":"","sources":["../../../../src/components/ComboBox/MultiSelectInput/MultiSelectInput.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAgBrD,OAAO,sBAA8C,MAAM,2BAA2B,CAAC;AACvF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEtE,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAKlC,QAAA,MAAM,gBAAgB,0JA2NpB,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,202 +1,115 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useRef, useCallback, useMemo,
|
|
3
|
-
import styled from 'styled-components';
|
|
2
|
+
import { forwardRef, useRef, useCallback, useMemo, useEffect, useState } from 'react';
|
|
4
3
|
import Progress from '../../Progress';
|
|
5
|
-
import { defaultThemeProp } from '../../../theme';
|
|
6
4
|
import Selectable from '../../Badges/Selection';
|
|
7
5
|
import { StyledFormControl } from '../../FormControl';
|
|
8
6
|
import Flex from '../../Flex';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
7
|
+
import { useArrows, useConsolidatedRef, useDirection, useFocusWithin, useI18n, useUID } from '../../../hooks';
|
|
8
|
+
import { isInstance, getActiveElement } from '../../../utils';
|
|
11
9
|
import VisuallyHiddenText from '../../VisuallyHiddenText';
|
|
12
|
-
import {
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
ul {
|
|
17
|
-
list-style: none;
|
|
18
|
-
display: contents;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
input {
|
|
22
|
-
width: 8ch;
|
|
23
|
-
height: 1.125rem;
|
|
24
|
-
}
|
|
25
|
-
`;
|
|
26
|
-
StyledMultiSelectInput.defaultProps = defaultThemeProp;
|
|
27
|
-
const StyledInputWrapper = styled(Flex) `
|
|
28
|
-
position: relative;
|
|
29
|
-
`;
|
|
10
|
+
import StyledMultiSelectInput, { StyledSelectionRow } from './MultiSelectInput.styles';
|
|
11
|
+
export { StyledMultiSelectInput };
|
|
12
|
+
const scrollIntoViewOptions = { block: 'nearest', inline: 'nearest' };
|
|
13
|
+
const selectionFocusSelector = '[data-selection-focus]';
|
|
30
14
|
const MultiSelectInput = forwardRef(function MultiSelectInput(props, ref) {
|
|
31
|
-
const { selected = [], loading, value, onRemove, onChange, onKeyDown, suggestion, actions, readOnly, disabled, status, placeholder, autoFocus,
|
|
15
|
+
const { selected = [], loading, value, onRemove, onChange, onKeyDown, suggestion, actions, readOnly, disabled, status, placeholder, autoFocus, onSelectedFocus, onSelectedBlur, 'aria-controls': ariaControls, required, ...restProps } = props;
|
|
32
16
|
const t = useI18n();
|
|
17
|
+
const { start } = useDirection();
|
|
33
18
|
const id = useUID();
|
|
34
19
|
const inputRef = useConsolidatedRef(ref);
|
|
35
20
|
const listRef = useRef(null);
|
|
36
|
-
const
|
|
37
|
-
const [
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
21
|
+
const isSelectionFocusedRef = useRef(false);
|
|
22
|
+
const [lastFocusedId, setLastFocusedId] = useState();
|
|
23
|
+
const selectionDescriptionId = `${id}-selectionDescription`;
|
|
24
|
+
// Pin the newest selection to the divider
|
|
25
|
+
const revealNewestSelection = useCallback(() => {
|
|
26
|
+
const el = listRef.current;
|
|
27
|
+
if (el && !isSelectionFocusedRef.current)
|
|
28
|
+
el.scrollLeft = el.scrollWidth;
|
|
29
|
+
}, []);
|
|
30
|
+
// On blur, re-pin the newest selection
|
|
31
|
+
const onSelectionFocusChange = useCallback((isFocused) => {
|
|
32
|
+
isSelectionFocusedRef.current = isFocused;
|
|
33
|
+
if (isFocused)
|
|
34
|
+
onSelectedFocus?.();
|
|
35
|
+
else {
|
|
36
|
+
onSelectedBlur?.();
|
|
37
|
+
revealNewestSelection();
|
|
52
38
|
}
|
|
53
|
-
}
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (idx === selected.length - 1) {
|
|
58
|
-
// If removing last selected item
|
|
59
|
-
if (selected.length > 1) {
|
|
60
|
-
// If other selected items, focus previous
|
|
61
|
-
setFocusDescendant(listRef.current?.querySelectorAll(uadConfig.selector)[idx - 1] ||
|
|
62
|
-
null);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
// Blur selected if final only item removed
|
|
66
|
-
onSelectedBlur?.();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
else if (selected.length > 1) {
|
|
70
|
-
// If not last item removed and other selected items, focus next
|
|
71
|
-
setFocusDescendant(listRef.current?.querySelectorAll(uadConfig.selector)[idx + 1] ||
|
|
72
|
-
null);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
onRemove?.(selectionId, idx);
|
|
76
|
-
inputRef.current?.focus();
|
|
77
|
-
}, [selected, onRemove, onSelectedBlur, uadConfig]);
|
|
39
|
+
}, [onSelectedFocus, onSelectedBlur, revealNewestSelection]);
|
|
40
|
+
const isSelectionFocused = useFocusWithin([listRef], onSelectionFocusChange);
|
|
41
|
+
useArrows(listRef, { selector: selectionFocusSelector, dir: 'left-right', cycle: false, updateTabIndex: false }, [selected.length]);
|
|
42
|
+
// Re-pin the newest selection on selection change (add/remove) and on resize.
|
|
78
43
|
useEffect(() => {
|
|
79
|
-
|
|
80
|
-
if (
|
|
81
|
-
setActiveItemId(activeDescendant.id);
|
|
82
|
-
}
|
|
83
|
-
}, [activeDescendant]);
|
|
84
|
-
const onListArrowKeyDown = useCallback((e) => {
|
|
85
|
-
// Tab (forward) from within the list: move focus to the input
|
|
86
|
-
if (e.key === 'Tab' && !e.shiftKey) {
|
|
87
|
-
e.preventDefault();
|
|
88
|
-
inputRef.current?.focus();
|
|
44
|
+
const el = listRef.current;
|
|
45
|
+
if (!el)
|
|
89
46
|
return;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
tabindex: el.getAttribute('tabindex')
|
|
100
|
-
}));
|
|
101
|
-
elementsToRestore.forEach(el => el.setAttribute('tabindex', '-1'));
|
|
102
|
-
requestAnimationFrame(() => {
|
|
103
|
-
previousTabIndexes.forEach(({ el, tabindex }) => {
|
|
104
|
-
if (tabindex === null) {
|
|
105
|
-
el.removeAttribute('tabindex');
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
el.setAttribute('tabindex', tabindex);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
if (e.key !== `Arrow${cap(start)}` && e.key !== `Arrow${cap(end)}`)
|
|
115
|
-
return;
|
|
116
|
-
const items = Array.from(listRef.current?.querySelectorAll(uadConfig.selector) ?? []);
|
|
117
|
-
const currentIndex = items.findIndex(item => item === getActiveElement() || item.contains(getActiveElement()));
|
|
118
|
-
if (currentIndex === -1)
|
|
47
|
+
revealNewestSelection();
|
|
48
|
+
const observer = new ResizeObserver(revealNewestSelection);
|
|
49
|
+
observer.observe(el);
|
|
50
|
+
return () => observer.disconnect();
|
|
51
|
+
}, [selected.length, revealNewestSelection]);
|
|
52
|
+
// Keep a focused selection visible
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
const el = listRef.current;
|
|
55
|
+
if (!el)
|
|
119
56
|
return;
|
|
120
|
-
e
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const prev = items[currentIndex - 1];
|
|
124
|
-
const prevLink = prev.querySelector('a');
|
|
125
|
-
const focusTarget = isInstance(prevLink, HTMLElement) ? prevLink : prev;
|
|
126
|
-
focusTarget.focus();
|
|
127
|
-
}
|
|
128
|
-
else if (e.key === `Arrow${cap(end)}`) {
|
|
129
|
-
if (currentIndex < items.length - 1) {
|
|
130
|
-
const next = items[currentIndex + 1];
|
|
131
|
-
const nextLink = next.querySelector('a');
|
|
132
|
-
const focusTarget = isInstance(nextLink, HTMLElement) ? nextLink : next;
|
|
133
|
-
focusTarget.focus();
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
inputRef.current?.focus();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}, [start, end, uadConfig.selector]);
|
|
140
|
-
const onInputKeyDown = useCallback((e) => {
|
|
141
|
-
// Shift+Tab: Focus the last selected item's link
|
|
142
|
-
if (e.key === 'Tab' && e.shiftKey && selected.length) {
|
|
143
|
-
const items = Array.from(listRef.current?.querySelectorAll(uadConfig.selector) ?? []);
|
|
144
|
-
const lastItem = items[items.length - 1];
|
|
145
|
-
const link = lastItem?.querySelector('a');
|
|
146
|
-
if (isInstance(link, HTMLElement)) {
|
|
147
|
-
e.preventDefault();
|
|
148
|
-
e.stopPropagation();
|
|
149
|
-
link.focus();
|
|
57
|
+
const handleFocusIn = (e) => {
|
|
58
|
+
const target = e.target;
|
|
59
|
+
if (!isInstance(target, HTMLElement))
|
|
150
60
|
return;
|
|
61
|
+
const selection = target.closest('[data-selection]');
|
|
62
|
+
if (!selection)
|
|
63
|
+
return;
|
|
64
|
+
setLastFocusedId(selection.dataset.selection);
|
|
65
|
+
selection.scrollIntoView(scrollIntoViewOptions);
|
|
66
|
+
};
|
|
67
|
+
el.addEventListener('focusin', handleFocusIn);
|
|
68
|
+
return () => el.removeEventListener('focusin', handleFocusIn);
|
|
69
|
+
}, [selected.length]);
|
|
70
|
+
// The selection that owns tab stop: the last focused one if still present, else the newest
|
|
71
|
+
const tabStopId = useMemo(() => {
|
|
72
|
+
if (!Array.isArray(selected))
|
|
73
|
+
return undefined;
|
|
74
|
+
const ids = selected.map(item => item.id.toString());
|
|
75
|
+
return lastFocusedId && ids.includes(lastFocusedId) ? lastFocusedId : ids[ids.length - 1];
|
|
76
|
+
}, [lastFocusedId, selected]);
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
listRef.current?.querySelectorAll('[data-selection]').forEach(selection => {
|
|
79
|
+
const link = selection.querySelector('a[href]');
|
|
80
|
+
const target = link ?? selection;
|
|
81
|
+
const isTabStop = !isSelectionFocused && selection.dataset.selection === tabStopId;
|
|
82
|
+
if (link) {
|
|
83
|
+
selection.removeAttribute('data-selection-focus');
|
|
84
|
+
selection.removeAttribute('tabindex');
|
|
85
|
+
const existingTokens = link.getAttribute('aria-describedby')?.split(/\s+/) ?? [];
|
|
86
|
+
if (!existingTokens.includes(selectionDescriptionId)) {
|
|
87
|
+
link.setAttribute('aria-describedby', [...existingTokens, selectionDescriptionId].join(' '));
|
|
88
|
+
}
|
|
151
89
|
}
|
|
90
|
+
target.setAttribute('data-selection-focus', '');
|
|
91
|
+
target.tabIndex = isTabStop ? 0 : -1;
|
|
92
|
+
});
|
|
93
|
+
}, [selected, isSelectionFocused, tabStopId, selectionDescriptionId]);
|
|
94
|
+
const handleSelectedRemoval = useCallback((selectionId, idx) => {
|
|
95
|
+
const activeEl = getActiveElement();
|
|
96
|
+
const isInSelectionList = listRef.current?.contains(activeEl) ?? false;
|
|
97
|
+
if (isInSelectionList) {
|
|
98
|
+
// Move focus to an adjacent selection before unmount
|
|
99
|
+
const targetIdx = idx > 0 ? idx - 1 : 1;
|
|
100
|
+
const child = listRef.current?.children[targetIdx];
|
|
101
|
+
const focusTarget = isInstance(child, HTMLElement)
|
|
102
|
+
? child.querySelector('a[href]') ?? child
|
|
103
|
+
: undefined;
|
|
104
|
+
if (focusTarget)
|
|
105
|
+
focusTarget.focus();
|
|
106
|
+
else
|
|
107
|
+
inputRef.current?.focus();
|
|
152
108
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if (pauseDescendantEvaluation && e.key === `Arrow${cap(start)}`) {
|
|
158
|
-
setFocusDescendant(listRef.current?.querySelectorAll(uadConfig.selector)[lastIndex] ||
|
|
159
|
-
null);
|
|
160
|
-
onSelectedFocus?.();
|
|
161
|
-
}
|
|
162
|
-
const lastSelectableId = listRef.current?.querySelectorAll(uadConfig.selector)[lastIndex]
|
|
163
|
-
?.id;
|
|
164
|
-
const onLastItem = activeItemId === lastSelectableId;
|
|
165
|
-
if (!pauseDescendantEvaluation &&
|
|
166
|
-
((onLastItem && e.key === `Arrow${cap(end)}`) || e.key === 'ArrowDown')) {
|
|
167
|
-
onSelectedBlur?.();
|
|
168
|
-
}
|
|
169
|
-
if (['Backspace', 'Delete'].includes(e.key) && !(readOnly || disabled)) {
|
|
170
|
-
handleSelectedRemoval(selected[lastIndex].id, lastIndex);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
onKeyDown?.(e);
|
|
174
|
-
}, [
|
|
175
|
-
pauseDescendantEvaluation,
|
|
176
|
-
activeItemId,
|
|
177
|
-
onKeyDown,
|
|
178
|
-
handleSelectedRemoval,
|
|
179
|
-
selected,
|
|
180
|
-
readOnly,
|
|
181
|
-
disabled,
|
|
182
|
-
start,
|
|
183
|
-
uadConfig.selector,
|
|
184
|
-
onSelectedFocus,
|
|
185
|
-
onSelectedBlur
|
|
186
|
-
]);
|
|
187
|
-
const ariaDescribedBy = useMemo(() => {
|
|
188
|
-
return onChange
|
|
189
|
-
? `${id}-inputDescription ${id}-searchDescription`
|
|
190
|
-
: `${id}-inputDescription`;
|
|
191
|
-
}, [id]);
|
|
192
|
-
const ariaControlsValue = useMemo(() => {
|
|
193
|
-
if (!pauseDescendantEvaluation) {
|
|
194
|
-
return selected.length > 0 ? id : undefined;
|
|
195
|
-
}
|
|
196
|
-
return ariaControls;
|
|
197
|
-
}, [pauseDescendantEvaluation, selected.length]);
|
|
198
|
-
return (_jsxs(Flex, { as: StyledMultiSelectInput, forwardedAs: StyledFormControl, hasSuggestion: status === 'pending' && !!suggestion, container: { alignItems: 'center', justify: 'between' }, readOnly: readOnly, disabled: disabled, status: status, children: [_jsxs(StyledInputWrapper, { container: { alignContent: 'center', wrap: 'wrap', rowGap: 0.5, colGap: 0.25, pad: 0.25 }, item: { grow: 1 }, onClick: (e) => {
|
|
199
|
-
// Ignore clicks on selection items
|
|
109
|
+
onRemove?.(selectionId, idx);
|
|
110
|
+
}, [onRemove]);
|
|
111
|
+
return (_jsxs(Flex, { as: StyledMultiSelectInput, forwardedAs: StyledFormControl, hasSuggestion: status === 'pending' && !!suggestion, container: { alignItems: 'center', justify: 'between' }, readOnly: readOnly, disabled: disabled, status: status, children: [_jsxs(Flex, { as: StyledSelectionRow, container: { alignItems: 'center', colGap: 0.25, pad: [0, 0.25, 0, 0] }, item: { grow: 1 }, onClick: (e) => {
|
|
112
|
+
// Ignore clicks on selection items.
|
|
200
113
|
if (isInstance(e.target, HTMLElement) &&
|
|
201
114
|
!isInstance(e.target, HTMLInputElement) &&
|
|
202
115
|
!e.currentTarget.contains(e.target.closest('li'))) {
|
|
@@ -206,15 +119,9 @@ const MultiSelectInput = forwardRef(function MultiSelectInput(props, ref) {
|
|
|
206
119
|
}
|
|
207
120
|
}, children: [loading && (_jsx(Progress, { placement: 'local', "aria-label": t('combobox_loading_selected_items'), liveConfig: {
|
|
208
121
|
contextualLabel: t('combobox_loading_selected_items')
|
|
209
|
-
} })), selected.length > 0 && (_jsx("ul", { ref: listRef, id: id, "aria-label": t('selected_items'),
|
|
210
|
-
return (_jsx(Selectable, { as: 'li', id: element.id.toString(), status: status, contextualLabel: element.text, onRemove: !readOnly && !disabled
|
|
211
|
-
? () => {
|
|
212
|
-
handleSelectedRemoval(element.id, idx);
|
|
213
|
-
}
|
|
214
|
-
: undefined, tabIndex: -1, "aria-label": `${t('remove')} ${element.text}`, "aria-describedby": ariaDescribedBy, children: element.primary ?? element.text }, element.id));
|
|
215
|
-
}) })), _jsx(Flex, { item: { grow: 1 }, as: 'input', size: 1, ref: inputRef, value: value,
|
|
122
|
+
} })), selected.length > 0 && (_jsx("ul", { ref: listRef, id: id, "aria-label": t('selected_items'), tabIndex: -1, children: selected.map((element, idx) => (_jsx(Selectable, { as: 'li', "data-selection": element.id.toString(), status: status, contextualLabel: element.text, onRemove: !readOnly && !disabled ? () => handleSelectedRemoval(element.id, idx) : undefined, "aria-label": `${t('remove')} ${element.text}`, "aria-describedby": selectionDescriptionId, children: element.primary ?? element.text }, element.id))) })), !readOnly && (_jsx(Flex, { item: { grow: 1 }, as: 'input', size: 1, ref: inputRef, value: value,
|
|
216
123
|
// no-op avoids react uncontrolled warning
|
|
217
|
-
onChange: onChange || (() => { }), onKeyDown:
|
|
124
|
+
onChange: onChange || (() => { }), onKeyDown: onKeyDown, readOnly: !onChange, disabled: disabled, placeholder: selected.length ? undefined : placeholder, autoComplete: '_off', autoFocus: autoFocus, "aria-controls": ariaControls ?? (selected.length > 0 ? id : undefined), "aria-required": !!required, ...restProps }))] }), actions, _jsx(VisuallyHiddenText, { id: selectionDescriptionId, children: `${t('multiselect_instructions', [start])}${!readOnly ? ` ${t('multiselect_tab_to_input')}` : ''}` })] }));
|
|
218
125
|
});
|
|
219
126
|
export default MultiSelectInput;
|
|
220
127
|
//# sourceMappingURL=MultiSelectInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelectInput.js","sourceRoot":"","sources":["../../../../src/components/ComboBox/MultiSelectInput/MultiSelectInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtF,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,E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kBAAkB,IAAC,EAAE,EAAE,GAAG,EAAE,oBAAoB,YAC9C,CAAC,CAAC,8BAA8B,CAAC,GACf,IAChB,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import { forwardRef, useRef, useCallback, useMemo, useState, useEffect } from 'react';\nimport type { FunctionComponent, Ref, PropsWithoutRef, KeyboardEvent, MouseEvent } from 'react';\nimport styled from 'styled-components';\n\nimport Progress from '../../Progress';\nimport type { ForwardProps } from '../../../types';\nimport { defaultThemeProp } from '../../../theme';\nimport Selectable from '../../Badges/Selection';\nimport { StyledFormControl } from '../../FormControl';\nimport Flex from '../../Flex';\nimport {\n useConsolidatedRef,\n useActiveDescendant,\n useDirection,\n useI18n,\n useUID\n} from '../../../hooks';\nimport { cap, isInstance, getActiveElement } from '../../../utils';\nimport VisuallyHiddenText from '../../VisuallyHiddenText';\nimport { StyledSelectInput } from '../ComboBox.styles';\nimport type { Selected } from '../ComboBox.types';\n\nimport type { MultiSelectInputProps } from './MultiSelectInput.types';\n\nexport const StyledMultiSelectInput = styled(StyledSelectInput)`\n cursor: text;\n\n ul {\n list-style: none;\n display: contents;\n }\n\n input {\n width: 8ch;\n height: 1.125rem;\n }\n`;\n\nStyledMultiSelectInput.defaultProps = defaultThemeProp;\n\nconst StyledInputWrapper = styled(Flex)`\n position: relative;\n`;\n\nconst MultiSelectInput: FunctionComponent<MultiSelectInputProps & ForwardProps> = forwardRef(\n function MultiSelectInput(\n props: PropsWithoutRef<MultiSelectInputProps>,\n ref: Ref<HTMLInputElement>\n ) {\n const {\n selected = [],\n loading,\n value,\n onRemove,\n onChange,\n onKeyDown,\n suggestion,\n actions,\n readOnly,\n disabled,\n status,\n placeholder,\n autoFocus,\n pauseDescendantEvaluation,\n onSelectedFocus,\n onSelectedBlur,\n 'aria-controls': ariaControls,\n required,\n ...restProps\n } = props;\n const t = useI18n();\n const id = useUID();\n\n const inputRef = useConsolidatedRef<HTMLInputElement>(ref);\n const listRef = useRef<HTMLUListElement>(null);\n const [focusDescendant, setFocusDescendant] = useState<HTMLElement | null>(null);\n const [activeItemId, setActiveItemId] = useState<string | null>(null);\n const { start, end } = useDirection();\n\n const uadConfig = useMemo(\n () => ({\n focusEl: inputRef.current,\n scope: listRef.current,\n selector: ':scope > li',\n orientation: 'horizontal' as const,\n focusReturnEl: focusDescendant,\n clearFocusReturn: () => {\n setFocusDescendant(null);\n },\n pauseDescendantEvaluation,\n preventInitialScroll: true,\n onClick: (el: HTMLElement) => {\n el.click();\n }\n }),\n [pauseDescendantEvaluation, selected, focusDescendant]\n );\n\n const { activeDescendant } = useActiveDescendant(uadConfig, [selected]);\n\n const handleSelectedRemoval = useCallback(\n (selectionId: Selected['id'], idx: number) => {\n if (!pauseDescendantEvaluation) {\n if (idx === selected.length - 1) {\n // If removing last selected item\n if (selected.length > 1) {\n // If other selected items, focus previous\n setFocusDescendant(\n (listRef.current?.querySelectorAll(uadConfig.selector)[idx - 1] as HTMLElement) ||\n null\n );\n } else {\n // Blur selected if final only item removed\n onSelectedBlur?.();\n }\n } else if (selected.length > 1) {\n // If not last item removed and other selected items, focus next\n setFocusDescendant(\n (listRef.current?.querySelectorAll(uadConfig.selector)[idx + 1] as HTMLElement) ||\n null\n );\n }\n }\n onRemove?.(selectionId, idx);\n inputRef.current?.focus();\n },\n [selected, onRemove, onSelectedBlur, uadConfig]\n );\n\n useEffect(() => {\n // Maintain active item & prev. val only as it changes.\n if (activeDescendant?.id && activeDescendant.id !== activeItemId) {\n setActiveItemId(activeDescendant.id);\n }\n }, [activeDescendant]);\n\n const onListArrowKeyDown = useCallback(\n (e: KeyboardEvent<HTMLUListElement>) => {\n // Tab (forward) from within the list: move focus to the input\n if (e.key === 'Tab' && !e.shiftKey) {\n e.preventDefault();\n inputRef.current?.focus();\n return;\n }\n\n // Shift+Tab from within the list: exit the combobox entirely\n if (e.key === 'Tab' && e.shiftKey) {\n const focusables = Array.from(listRef.current?.querySelectorAll('a, button') ?? []);\n const elementsToRestore = inputRef.current\n ? [...focusables, inputRef.current]\n : focusables;\n const previousTabIndexes = elementsToRestore.map(el => ({\n el,\n tabindex: el.getAttribute('tabindex')\n }));\n elementsToRestore.forEach(el => el.setAttribute('tabindex', '-1'));\n requestAnimationFrame(() => {\n previousTabIndexes.forEach(({ el, tabindex }) => {\n if (tabindex === null) {\n el.removeAttribute('tabindex');\n } else {\n el.setAttribute('tabindex', tabindex);\n }\n });\n });\n return;\n }\n\n if (e.key !== `Arrow${cap(start)}` && e.key !== `Arrow${cap(end)}`) return;\n\n const items = Array.from(\n listRef.current?.querySelectorAll<HTMLLIElement>(uadConfig.selector) ?? []\n );\n const currentIndex = items.findIndex(\n item => item === getActiveElement() || item.contains(getActiveElement())\n );\n if (currentIndex === -1) return;\n\n e.preventDefault();\n e.stopPropagation();\n\n if (e.key === `Arrow${cap(start)}` && currentIndex > 0) {\n const prev = items[currentIndex - 1];\n const prevLink = prev.querySelector('a');\n const focusTarget = isInstance(prevLink, HTMLElement) ? prevLink : prev;\n focusTarget.focus();\n } else if (e.key === `Arrow${cap(end)}`) {\n if (currentIndex < items.length - 1) {\n const next = items[currentIndex + 1];\n const nextLink = next.querySelector('a');\n const focusTarget = isInstance(nextLink, HTMLElement) ? nextLink : next;\n focusTarget.focus();\n } else {\n inputRef.current?.focus();\n }\n }\n },\n [start, end, uadConfig.selector]\n );\n\n const onInputKeyDown = useCallback(\n (e: KeyboardEvent<HTMLInputElement>) => {\n // Shift+Tab: Focus the last selected item's link\n if (e.key === 'Tab' && e.shiftKey && selected.length) {\n const items = Array.from(\n listRef.current?.querySelectorAll<HTMLLIElement>(uadConfig.selector) ?? []\n );\n const lastItem = items[items.length - 1];\n const link = lastItem?.querySelector('a');\n\n if (isInstance(link, HTMLElement)) {\n e.preventDefault();\n e.stopPropagation();\n link.focus();\n return;\n }\n }\n\n if (\n selected.length &&\n inputRef.current?.selectionStart === 0 &&\n inputRef.current?.selectionEnd === 0\n ) {\n const lastIndex = selected.length - 1;\n if (pauseDescendantEvaluation && e.key === `Arrow${cap(start)}`) {\n setFocusDescendant(\n (listRef.current?.querySelectorAll(uadConfig.selector)[lastIndex] as HTMLElement) ||\n null\n );\n onSelectedFocus?.();\n }\n\n const lastSelectableId = listRef.current?.querySelectorAll(uadConfig.selector)[lastIndex]\n ?.id;\n const onLastItem = activeItemId === lastSelectableId;\n\n if (\n !pauseDescendantEvaluation &&\n ((onLastItem && e.key === `Arrow${cap(end)}`) || e.key === 'ArrowDown')\n ) {\n onSelectedBlur?.();\n }\n\n if (['Backspace', 'Delete'].includes(e.key) && !(readOnly || disabled)) {\n handleSelectedRemoval(selected[lastIndex].id, lastIndex);\n }\n }\n onKeyDown?.(e);\n },\n [\n pauseDescendantEvaluation,\n activeItemId,\n onKeyDown,\n handleSelectedRemoval,\n selected,\n readOnly,\n disabled,\n start,\n uadConfig.selector,\n onSelectedFocus,\n onSelectedBlur\n ]\n );\n\n const ariaDescribedBy = useMemo(() => {\n return onChange\n ? `${id}-inputDescription ${id}-searchDescription`\n : `${id}-inputDescription`;\n }, [id]);\n\n const ariaControlsValue = useMemo(() => {\n if (!pauseDescendantEvaluation) {\n return selected.length > 0 ? id : undefined;\n }\n return ariaControls;\n }, [pauseDescendantEvaluation, selected.length]);\n\n return (\n <Flex\n as={StyledMultiSelectInput}\n forwardedAs={StyledFormControl}\n hasSuggestion={status === 'pending' && !!suggestion}\n container={{ alignItems: 'center', justify: 'between' }}\n readOnly={readOnly}\n disabled={disabled}\n status={status}\n >\n <StyledInputWrapper\n container={{ alignContent: 'center', wrap: 'wrap', rowGap: 0.5, colGap: 0.25, pad: 0.25 }}\n item={{ grow: 1 }}\n onClick={(e: MouseEvent<HTMLDivElement>) => {\n // Ignore clicks on selection items\n if (\n isInstance(e.target, HTMLElement) &&\n !isInstance(e.target, HTMLInputElement) &&\n !e.currentTarget.contains(e.target.closest('li'))\n ) {\n e.stopPropagation();\n inputRef.current?.focus();\n inputRef.current?.click();\n }\n }}\n >\n {loading && (\n <Progress\n placement='local'\n aria-label={t('combobox_loading_selected_items')}\n liveConfig={{\n contextualLabel: t('combobox_loading_selected_items')\n }}\n />\n )}\n {selected.length > 0 && (\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n <ul\n ref={listRef}\n id={id}\n aria-label={t('selected_items')}\n onKeyDown={onListArrowKeyDown}\n >\n {selected.map((element, idx) => {\n return (\n <Selectable\n as='li'\n key={element.id}\n id={element.id.toString()}\n status={status}\n contextualLabel={element.text}\n onRemove={\n !readOnly && !disabled\n ? () => {\n handleSelectedRemoval(element.id, idx);\n }\n : undefined\n }\n tabIndex={-1}\n aria-label={`${t('remove')} ${element.text}`}\n aria-describedby={ariaDescribedBy}\n >\n {element.primary ?? element.text}\n </Selectable>\n );\n })}\n </ul>\n )}\n <Flex\n item={{ grow: 1 }}\n as='input'\n size={1}\n ref={inputRef}\n value={value}\n // no-op avoids react uncontrolled warning\n onChange={onChange || (() => {})}\n onKeyDown={onInputKeyDown}\n readOnly={readOnly || !onChange}\n disabled={disabled}\n placeholder={selected?.length ? undefined : placeholder}\n autoComplete='_off'\n autoFocus={autoFocus}\n aria-controls={ariaControlsValue}\n aria-required={!!required}\n {...restProps}\n />\n </StyledInputWrapper>\n {actions}\n <VisuallyHiddenText id={`${id}-inputDescription`}>\n {`${t('combobox_open_close')} `}\n </VisuallyHiddenText>\n <VisuallyHiddenText id={`${id}-searchDescription`}>\n {t('combobox_search_instructions')}\n </VisuallyHiddenText>\n </Flex>\n );\n }\n);\n\nexport default MultiSelectInput;\n"]}
|
|
1
|
+
{"version":3,"file":"MultiSelectInput.js","sourceRoot":"","sources":["../../../../src/components/ComboBox/MultiSelectInput/MultiSelectInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGtF,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,OA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Callback, useMemo, useEffect, useState } from 'react';\nimport type { MouseEvent } from 'react';\n\nimport Progress from '../../Progress';\nimport type { WithAttributes } from '../../../types';\nimport Selectable from '../../Badges/Selection';\nimport { StyledFormControl } from '../../FormControl';\nimport Flex from '../../Flex';\nimport {\n useArrows,\n useConsolidatedRef,\n useDirection,\n useFocusWithin,\n useI18n,\n useUID\n} from '../../../hooks';\nimport { isInstance, getActiveElement } from '../../../utils';\nimport VisuallyHiddenText from '../../VisuallyHiddenText';\nimport type { Selected } from '../ComboBox.types';\n\nimport StyledMultiSelectInput, { StyledSelectionRow } from './MultiSelectInput.styles';\nimport type { MultiSelectInputProps } from './MultiSelectInput.types';\n\nexport { StyledMultiSelectInput };\n\nconst scrollIntoViewOptions: ScrollIntoViewOptions = { block: 'nearest', inline: 'nearest' };\nconst selectionFocusSelector = '[data-selection-focus]';\n\nconst MultiSelectInput = forwardRef<\n HTMLInputElement,\n WithAttributes<'input', MultiSelectInputProps>\n>(function MultiSelectInput(props, ref) {\n const {\n selected = [],\n loading,\n value,\n onRemove,\n onChange,\n onKeyDown,\n suggestion,\n actions,\n readOnly,\n disabled,\n status,\n placeholder,\n autoFocus,\n onSelectedFocus,\n onSelectedBlur,\n 'aria-controls': ariaControls,\n required,\n ...restProps\n } = props;\n const t = useI18n();\n const { start } = useDirection();\n const id = useUID();\n\n const inputRef = useConsolidatedRef<HTMLInputElement>(ref);\n const listRef = useRef<HTMLUListElement>(null);\n const isSelectionFocusedRef = useRef(false);\n const [lastFocusedId, setLastFocusedId] = useState<string>();\n const selectionDescriptionId = `${id}-selectionDescription`;\n\n // Pin the newest selection to the divider\n const revealNewestSelection = useCallback(() => {\n const el = listRef.current;\n if (el && !isSelectionFocusedRef.current) el.scrollLeft = el.scrollWidth;\n }, []);\n\n // On blur, re-pin the newest selection\n const onSelectionFocusChange = useCallback(\n (isFocused: boolean) => {\n isSelectionFocusedRef.current = isFocused;\n if (isFocused) onSelectedFocus?.();\n else {\n onSelectedBlur?.();\n revealNewestSelection();\n }\n },\n [onSelectedFocus, onSelectedBlur, revealNewestSelection]\n );\n const isSelectionFocused = useFocusWithin([listRef], onSelectionFocusChange);\n\n useArrows(\n listRef,\n { selector: selectionFocusSelector, dir: 'left-right', cycle: false, updateTabIndex: false },\n [selected.length]\n );\n\n // Re-pin the newest selection on selection change (add/remove) and on resize.\n useEffect(() => {\n const el = listRef.current;\n if (!el) return;\n revealNewestSelection();\n const observer = new ResizeObserver(revealNewestSelection);\n observer.observe(el);\n return () => observer.disconnect();\n }, [selected.length, revealNewestSelection]);\n\n // Keep a focused selection visible\n useEffect(() => {\n const el = listRef.current;\n if (!el) return;\n const handleFocusIn = (e: FocusEvent) => {\n const target = e.target;\n if (!isInstance(target, HTMLElement)) return;\n const selection = target.closest<HTMLElement>('[data-selection]');\n if (!selection) return;\n setLastFocusedId(selection.dataset.selection);\n selection.scrollIntoView(scrollIntoViewOptions);\n };\n el.addEventListener('focusin', handleFocusIn);\n return () => el.removeEventListener('focusin', handleFocusIn);\n }, [selected.length]);\n\n // The selection that owns tab stop: the last focused one if still present, else the newest\n const tabStopId = useMemo(() => {\n if (!Array.isArray(selected)) return undefined;\n const ids = selected.map(item => item.id.toString());\n return lastFocusedId && ids.includes(lastFocusedId) ? lastFocusedId : ids[ids.length - 1];\n }, [lastFocusedId, selected]);\n\n useEffect(() => {\n listRef.current?.querySelectorAll<HTMLElement>('[data-selection]').forEach(selection => {\n const link = selection.querySelector<HTMLElement>('a[href]');\n const target = link ?? selection;\n const isTabStop = !isSelectionFocused && selection.dataset.selection === tabStopId;\n if (link) {\n selection.removeAttribute('data-selection-focus');\n selection.removeAttribute('tabindex');\n const existingTokens = link.getAttribute('aria-describedby')?.split(/\\s+/) ?? [];\n if (!existingTokens.includes(selectionDescriptionId)) {\n link.setAttribute(\n 'aria-describedby',\n [...existingTokens, selectionDescriptionId].join(' ')\n );\n }\n }\n target.setAttribute('data-selection-focus', '');\n target.tabIndex = isTabStop ? 0 : -1;\n });\n }, [selected, isSelectionFocused, tabStopId, selectionDescriptionId]);\n\n const handleSelectedRemoval = useCallback(\n (selectionId: Selected['id'], idx: number) => {\n const activeEl = getActiveElement();\n const isInSelectionList = listRef.current?.contains(activeEl) ?? false;\n\n if (isInSelectionList) {\n // Move focus to an adjacent selection before unmount\n const targetIdx = idx > 0 ? idx - 1 : 1;\n const child = listRef.current?.children[targetIdx];\n const focusTarget = isInstance(child, HTMLElement)\n ? child.querySelector<HTMLElement>('a[href]') ?? child\n : undefined;\n if (focusTarget) focusTarget.focus();\n else inputRef.current?.focus();\n }\n\n onRemove?.(selectionId, idx);\n },\n [onRemove]\n );\n\n return (\n <Flex\n as={StyledMultiSelectInput}\n forwardedAs={StyledFormControl}\n hasSuggestion={status === 'pending' && !!suggestion}\n container={{ alignItems: 'center', justify: 'between' }}\n readOnly={readOnly}\n disabled={disabled}\n status={status}\n >\n <Flex\n as={StyledSelectionRow}\n container={{ alignItems: 'center', colGap: 0.25, pad: [0, 0.25, 0, 0] }}\n item={{ grow: 1 }}\n onClick={(e: MouseEvent<HTMLDivElement>) => {\n // Ignore clicks on selection items.\n if (\n isInstance(e.target, HTMLElement) &&\n !isInstance(e.target, HTMLInputElement) &&\n !e.currentTarget.contains(e.target.closest('li'))\n ) {\n e.stopPropagation();\n inputRef.current?.focus();\n inputRef.current?.click();\n }\n }}\n >\n {loading && (\n <Progress\n placement='local'\n aria-label={t('combobox_loading_selected_items')}\n liveConfig={{\n contextualLabel: t('combobox_loading_selected_items')\n }}\n />\n )}\n {selected.length > 0 && (\n <ul ref={listRef} id={id} aria-label={t('selected_items')} tabIndex={-1}>\n {selected.map((element, idx) => (\n <Selectable\n as='li'\n key={element.id}\n data-selection={element.id.toString()}\n status={status}\n contextualLabel={element.text}\n onRemove={\n !readOnly && !disabled ? () => handleSelectedRemoval(element.id, idx) : undefined\n }\n aria-label={`${t('remove')} ${element.text}`}\n aria-describedby={selectionDescriptionId}\n >\n {element.primary ?? element.text}\n </Selectable>\n ))}\n </ul>\n )}\n {!readOnly && (\n <Flex\n item={{ grow: 1 }}\n as='input'\n size={1}\n ref={inputRef}\n value={value}\n // no-op avoids react uncontrolled warning\n onChange={onChange || (() => {})}\n onKeyDown={onKeyDown}\n readOnly={!onChange}\n disabled={disabled}\n placeholder={selected.length ? undefined : placeholder}\n autoComplete='_off'\n autoFocus={autoFocus}\n aria-controls={ariaControls ?? (selected.length > 0 ? id : undefined)}\n aria-required={!!required}\n {...restProps}\n />\n )}\n </Flex>\n {actions}\n\n <VisuallyHiddenText id={selectionDescriptionId}>\n {`${t('multiselect_instructions', [start])}${!readOnly ? ` ${t('multiselect_tab_to_input')}` : ''}`}\n </VisuallyHiddenText>\n </Flex>\n );\n});\n\nexport default MultiSelectInput;\n"]}
|