@pega/cosmos-react-core 3.0.0-dev.17.0 → 3.0.0-dev.18.2
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/Badges/Keyboard.d.ts.map +1 -1
- package/lib/components/Badges/Keyboard.js +2 -0
- package/lib/components/Badges/Keyboard.js.map +1 -1
- package/lib/components/Badges/Selection.d.ts +1 -1
- package/lib/components/Badges/Selection.d.ts.map +1 -1
- package/lib/components/Badges/Selection.js +4 -2
- package/lib/components/Badges/Selection.js.map +1 -1
- package/lib/components/Breadcrumbs/Breadcrumbs.d.ts +2 -1
- package/lib/components/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
- package/lib/components/Breadcrumbs/Breadcrumbs.js +27 -7
- package/lib/components/Breadcrumbs/Breadcrumbs.js.map +1 -1
- package/lib/components/ComboBox/ComboBox.d.ts.map +1 -1
- package/lib/components/ComboBox/ComboBox.js +55 -23
- package/lib/components/ComboBox/ComboBox.js.map +1 -1
- package/lib/components/ComboBox/ComboBox.types.d.ts +3 -1
- package/lib/components/ComboBox/ComboBox.types.d.ts.map +1 -1
- package/lib/components/ComboBox/ComboBox.types.js.map +1 -1
- package/lib/components/ComboBox/ComboBoxInput.d.ts +7 -0
- package/lib/components/ComboBox/ComboBoxInput.d.ts.map +1 -1
- package/lib/components/ComboBox/ComboBoxInput.js +5 -2
- package/lib/components/ComboBox/ComboBoxInput.js.map +1 -1
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.d.ts.map +1 -1
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js +113 -36
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js.map +1 -1
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.types.d.ts +8 -0
- 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/CompositeInput/CompositeInput.d.ts.map +1 -1
- package/lib/components/CompositeInput/CompositeInput.js +2 -2
- package/lib/components/CompositeInput/CompositeInput.js.map +1 -1
- package/lib/components/CompositeInput/CompositeInput.styles.d.ts.map +1 -1
- package/lib/components/CompositeInput/CompositeInput.styles.js +20 -17
- package/lib/components/CompositeInput/CompositeInput.styles.js.map +1 -1
- package/lib/components/Currency/utils.d.ts.map +1 -1
- package/lib/components/Currency/utils.js +3 -2
- package/lib/components/Currency/utils.js.map +1 -1
- package/lib/components/DateTime/Picker/Calendar.d.ts.map +1 -1
- package/lib/components/DateTime/Picker/Calendar.js +6 -12
- package/lib/components/DateTime/Picker/Calendar.js.map +1 -1
- package/lib/components/DateTime/Picker/Calendar.styles.d.ts +2 -4
- package/lib/components/DateTime/Picker/Calendar.styles.d.ts.map +1 -1
- package/lib/components/DateTime/Picker/Calendar.styles.js +12 -54
- package/lib/components/DateTime/Picker/Calendar.styles.js.map +1 -1
- package/lib/components/DateTime/Picker/DatePicker.d.ts.map +1 -1
- package/lib/components/DateTime/Picker/DatePicker.js +2 -1
- package/lib/components/DateTime/Picker/DatePicker.js.map +1 -1
- package/lib/components/DateTime/Picker/DatePicker.styles.d.ts +3 -0
- package/lib/components/DateTime/Picker/DatePicker.styles.d.ts.map +1 -0
- package/lib/components/DateTime/Picker/DatePicker.styles.js +39 -0
- package/lib/components/DateTime/Picker/DatePicker.styles.js.map +1 -0
- package/lib/components/DateTime/Picker/DateRangePicker.js +1 -1
- package/lib/components/DateTime/Picker/DateRangePicker.js.map +1 -1
- package/lib/components/DateTime/index.d.ts +2 -0
- package/lib/components/DateTime/index.d.ts.map +1 -1
- package/lib/components/DateTime/index.js +2 -0
- package/lib/components/DateTime/index.js.map +1 -1
- package/lib/components/Dialog/Dialog.d.ts.map +1 -1
- package/lib/components/Dialog/Dialog.js +3 -2
- package/lib/components/Dialog/Dialog.js.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.d.ts.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.js +64 -9
- package/lib/components/ListToolbar/ListToolbar.js.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.types.d.ts +2 -0
- package/lib/components/ListToolbar/ListToolbar.types.d.ts.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.types.js.map +1 -1
- package/lib/components/ListToolbar/PresetMenuPopover.d.ts +12 -0
- package/lib/components/ListToolbar/PresetMenuPopover.d.ts.map +1 -0
- package/lib/components/ListToolbar/PresetMenuPopover.js +36 -0
- package/lib/components/ListToolbar/PresetMenuPopover.js.map +1 -0
- package/lib/components/ListToolbar/QueryOptionPopover.d.ts.map +1 -1
- package/lib/components/ListToolbar/QueryOptionPopover.js +14 -44
- package/lib/components/ListToolbar/QueryOptionPopover.js.map +1 -1
- package/lib/components/Menu/Menu.d.ts.map +1 -1
- package/lib/components/Menu/Menu.js +8 -5
- package/lib/components/Menu/Menu.js.map +1 -1
- package/lib/components/Menu/Menu.styles.js +1 -1
- package/lib/components/Menu/Menu.styles.js.map +1 -1
- package/lib/components/Menu/Menu.types.d.ts +13 -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/Menu/MenuGroup.d.ts.map +1 -1
- package/lib/components/Menu/MenuGroup.js +3 -3
- package/lib/components/Menu/MenuGroup.js.map +1 -1
- package/lib/components/Menu/MenuItem.d.ts.map +1 -1
- package/lib/components/Menu/MenuItem.js +3 -5
- package/lib/components/Menu/MenuItem.js.map +1 -1
- package/lib/components/Menu/MenuList.d.ts.map +1 -1
- package/lib/components/Menu/MenuList.js +14 -14
- package/lib/components/Menu/MenuList.js.map +1 -1
- package/lib/components/PageTemplates/DashboardPage.d.ts.map +1 -1
- package/lib/components/PageTemplates/DashboardPage.js +1 -4
- package/lib/components/PageTemplates/DashboardPage.js.map +1 -1
- package/lib/components/Skeleton/ParagraphSkeleton.d.ts.map +1 -1
- package/lib/components/Skeleton/ParagraphSkeleton.js +2 -2
- package/lib/components/Skeleton/ParagraphSkeleton.js.map +1 -1
- package/lib/hooks/useActiveDescendant.d.ts +5 -1
- package/lib/hooks/useActiveDescendant.d.ts.map +1 -1
- package/lib/hooks/useActiveDescendant.js +162 -94
- package/lib/hooks/useActiveDescendant.js.map +1 -1
- package/lib/hooks/useI18n.d.ts +26 -0
- package/lib/hooks/useI18n.d.ts.map +1 -1
- package/lib/hooks/useI18n.js +2 -1
- package/lib/hooks/useI18n.js.map +1 -1
- package/lib/i18n/default.d.ts +26 -0
- package/lib/i18n/default.d.ts.map +1 -1
- package/lib/i18n/default.js +39 -13
- package/lib/i18n/default.js.map +1 -1
- package/lib/i18n/i18n.d.ts +52 -0
- package/lib/i18n/i18n.d.ts.map +1 -1
- package/lib/i18n/translate.d.ts +3 -0
- package/lib/i18n/translate.d.ts.map +1 -1
- package/lib/i18n/translate.js.map +1 -1
- package/lib/init.js +1 -1
- package/lib/init.js.map +1 -1
- package/lib/theme/themes/darkTheme.json +3 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Keyboard.d.ts","sourceRoot":"","sources":["../../../src/components/Badges/Keyboard.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Keyboard.d.ts","sourceRoot":"","sources":["../../../src/components/Badges/Keyboard.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAK1C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAsB3C,eAAO,MAAM,cAAc,yGA+B1B,CAAC;AAGF,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,QAAA,MAAM,QAAQ,EAAE,iBAAiB,CAAC,aAAa,GAAG,YAAY,CAU7D,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
|
+
import { defaultThemeProp } from '../../theme';
|
|
3
4
|
import useOS from '../../hooks/useOS';
|
|
4
5
|
const osxKeyMapper = {
|
|
5
6
|
Command: '⌘',
|
|
@@ -40,6 +41,7 @@ export const StyledKeyboard = styled.kbd(({ theme: { base, components: { text: {
|
|
|
40
41
|
inset-block-start: calc(1.25rem / 4 - 0.125rem);
|
|
41
42
|
`;
|
|
42
43
|
});
|
|
44
|
+
StyledKeyboard.defaultProps = defaultThemeProp;
|
|
43
45
|
const Keyboard = ({ keyName, ...restProps }) => {
|
|
44
46
|
const { windows: isWindows } = useOS();
|
|
45
47
|
return (_jsx(StyledKeyboard, { ...restProps, "aria-label": keyName, children: (isWindows && windowsKeyMapper[keyName]) ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Keyboard.js","sourceRoot":"","sources":["../../../src/components/Badges/Keyboard.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,MAAM,mBAAmB,CAAC;AAGtC,MAAM,YAAY,GAA8B;IAC9C,OAAO,EAAE,GAAG;IACZ,MAAM,EAAE,GAAG;IACX,OAAO,EAAE,GAAG;IACZ,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,KAAK;CACd,CAAC;AAEF,MAAM,gBAAgB,GAA8B;IAClD,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,GAAG;IACZ,SAAS,EAAE,WAAW;CACvB,CAAC;AAEF,MAAM,gBAAgB,GAA8B;IAClD,SAAS,EAAE,OAAO;IAClB,WAAW,EAAE,OAAO;IACpB,GAAG,EAAE,QAAQ;CACd,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CACtC,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EACJ,UAAU,EAAE,EACV,IAAI,EAAE,EAAE,OAAO,EAAE,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AAC;eACvC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC;;;qBAG1B,IAAI,CAAC,aAAa,CAAC;qBACnB,OAAO,CAAC,aAAa,CAAC;;;;gCAIX,QAAQ,CAAC,cAAc,CAAC;4BAC5B,IAAI,CAAC,eAAe,CAAC;;;;;;;;KAQ5C,CAAC;AACJ,CAAC,CACF,CAAC;AACF,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAM/C,MAAM,QAAQ,GAAoD,CAAC,EAAE,OAAO,EAAE,GAAG,SAAS,EAAE,EAAE,EAAE;IAC9F,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,CAAC;IACvC,OAAO,CACL,KAAC,cAAc,OAAK,SAAS,gBAAc,OAAO,YAC/C,CAAC,SAAS,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAC;YACvC,YAAY,CAAC,OAAO,CAAC;YACrB,gBAAgB,CAAC,OAAO,CAAC;YACzB,OAAO,GACM,CAClB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import { FunctionComponent } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport useOS from '../../hooks/useOS';\nimport { ForwardProps } from '../../types';\n\nconst osxKeyMapper: { [key: string]: string } = {\n Command: '⌘',\n Option: '⌥',\n Control: '⌃',\n Return: '↵',\n Delete: 'Del'\n};\n\nconst windowsKeyMapper: { [key: string]: string } = {\n Control: 'Ctrl',\n Windows: '⊞',\n Backspace: 'Backspace'\n};\n\nconst generalKeyMapper: { [key: string]: string } = {\n 'Page up': 'Pg up',\n 'Page down': 'Pg dn',\n Ins: 'Insert'\n};\n\nexport const StyledKeyboard = styled.kbd(\n ({\n theme: {\n base,\n components: {\n text: { primary },\n badges: { keyboard }\n }\n }\n }) => {\n return css`\n background-color: ${keyboard['background-color']};\n color: ${base.palette['foreground-color']};\n display: inline-block;\n position: relative;\n font-family: ${base['font-family']};\n font-weight: ${primary['font-weight']};\n overflow: hidden;\n white-space: nowrap;\n padding: 0.125rem;\n border: 0.0125rem solid ${keyboard['border-color']};\n border-radius: calc(${base['border-radius']} / 4);\n text-transform: capitalize;\n text-align: center;\n min-width: 1.25rem;\n height: 1.25rem;\n text-overflow: ellipsis;\n line-height: 1rem;\n inset-block-start: calc(1.25rem / 4 - 0.125rem);\n `;\n }\n);\nStyledKeyboard.defaultProps = defaultThemeProp;\n\nexport interface KeyboardProps {\n keyName: string;\n}\n\nconst Keyboard: FunctionComponent<KeyboardProps & ForwardProps> = ({ keyName, ...restProps }) => {\n const { windows: isWindows } = useOS();\n return (\n <StyledKeyboard {...restProps} aria-label={keyName}>\n {(isWindows && windowsKeyMapper[keyName]) ||\n osxKeyMapper[keyName] ||\n generalKeyMapper[keyName] ||\n keyName}\n </StyledKeyboard>\n );\n};\n\nexport default Keyboard;\n"]}
|
|
@@ -14,7 +14,7 @@ export interface SelectableProps {
|
|
|
14
14
|
/** Event handler fired on every keyup event. */
|
|
15
15
|
onKeyUp?: (event: KeyboardEvent) => void;
|
|
16
16
|
}
|
|
17
|
-
export declare const StyledSelectable: import("styled-components").StyledComponent<"
|
|
17
|
+
export declare const StyledSelectable: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {}, never>;
|
|
18
18
|
declare const Selectable: FC<SelectableProps & ForwardProps>;
|
|
19
19
|
export default Selectable;
|
|
20
20
|
//# sourceMappingURL=Selection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Selection.d.ts","sourceRoot":"","sources":["../../../src/components/Badges/Selection.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,UAAU,EAAoC,aAAa,EAAE,MAAM,OAAO,CAAC;AAIxF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"Selection.d.ts","sourceRoot":"","sources":["../../../src/components/Badges/Selection.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,UAAU,EAAoC,aAAa,EAAE,MAAM,OAAO,CAAC;AAIxF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAU3C,MAAM,WAAW,eAAe;IAC9B,sFAAsF;IACtF,EAAE,EAAE,MAAM,CAAC;IACX,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,gGAAgG;IAChG,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,iHAAiH;IACjH,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,sDAAsD;IACtD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC,gDAAgD;IAChD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;CAC1C;AAED,eAAO,MAAM,gBAAgB,4GAsD3B,CAAC;AAGH,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,GAAG,YAAY,CAsDlD,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -7,8 +7,9 @@ import BareButton, { StyledBareButton } from '../Button/BareButton';
|
|
|
7
7
|
import Icon, { registerIcon, StyledIcon } from '../Icon';
|
|
8
8
|
import * as timesIcon from '../Icon/icons/times.icon';
|
|
9
9
|
import { useConsolidatedRef, useI18n } from '../../hooks';
|
|
10
|
+
import { defaultThemeProp } from '../../theme';
|
|
10
11
|
registerIcon(timesIcon);
|
|
11
|
-
export const StyledSelectable = styled.
|
|
12
|
+
export const StyledSelectable = styled.button(props => {
|
|
12
13
|
const { foreground, background } = props.theme.components.badges.selectable.base;
|
|
13
14
|
const { dark } = props.theme.base.palette;
|
|
14
15
|
const borderRadius = props.theme.base['border-radius'];
|
|
@@ -61,6 +62,7 @@ export const StyledSelectable = styled.div(props => {
|
|
|
61
62
|
}
|
|
62
63
|
`;
|
|
63
64
|
});
|
|
65
|
+
StyledSelectable.defaultProps = defaultThemeProp;
|
|
64
66
|
const Selectable = forwardRef(({ id, children, onSelect, onRemove, onClick, onKeyUp, ...restProps }, ref) => {
|
|
65
67
|
const consolidatedRef = useConsolidatedRef(ref);
|
|
66
68
|
const t = useI18n();
|
|
@@ -82,7 +84,7 @@ const Selectable = forwardRef(({ id, children, onSelect, onRemove, onClick, onKe
|
|
|
82
84
|
onRemove?.(id);
|
|
83
85
|
}
|
|
84
86
|
};
|
|
85
|
-
return (_jsxs(
|
|
87
|
+
return (_jsxs(StyledSelectable, { ref: consolidatedRef, onClick: handleClick, onKeyUp: handleKeyUp, ...restProps, children: [children, onRemove && (_jsx(BareButton, { tabIndex: '-1', onClick: handleCloseClick, "aria-label": `${t('remove')}`, children: _jsx(Icon, { name: 'times' }) }))] }));
|
|
86
88
|
});
|
|
87
89
|
export default Selectable;
|
|
88
90
|
//# sourceMappingURL=Selection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Selection.js","sourceRoot":"","sources":["../../../src/components/Badges/Selection.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,UAAU,EAAuC,MAAM,OAAO,CAAC;AACxF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,UAAU,EAAE,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,SAAS,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"Selection.js","sourceRoot":"","sources":["../../../src/components/Badges/Selection.tsx"],"names":[],"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,EAAE,CAAC;QACpB,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,CAAC,CAAgB,EAAE,EAAE;QACvC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;QACb,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,EAAE;YACrB,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;SAChB;QAED,IAAI,CAAC,CAAC,GAAG,KAAK,WAAW,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ,EAAE;YAC/C,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;SAChB;IACH,CAAC,CAAC;IAEF,OAAO,CACL,MAAC,gBAAgB,IACf,GAAG,EAAE,eAAe,EACpB,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,WAAW,KAChB,SAAS,aAEZ,QAAQ,EACR,QAAQ,IAAI,CACX,KAAC,UAAU,IAAC,QAAQ,EAAC,IAAI,EAAC,OAAO,EAAE,gBAAgB,gBAAc,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,YAC/E,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,GAAG,GACV,CACd,IACgB,CACpB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { FC, MouseEvent, forwardRef, PropsWithoutRef, Ref, KeyboardEvent } from 'react';\nimport styled, { css } from 'styled-components';\nimport { mix, transparentize } from 'polished';\n\nimport { ForwardProps } from '../../types';\nimport { tryCatch } from '../../utils/utils';\nimport BareButton, { StyledBareButton } from '../Button/BareButton';\nimport Icon, { registerIcon, StyledIcon } from '../Icon';\nimport * as timesIcon from '../Icon/icons/times.icon';\nimport { useConsolidatedRef, useI18n } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\n\nregisterIcon(timesIcon);\n\nexport interface SelectableProps {\n /** An id that is used by the onSelect and onRemove functions if they are provided. */\n id: string;\n /** The content of the Badge. */\n children: string;\n /** Takes an ID that represents the Badge. This function is called when the Badge is clicked. */\n onSelect?: (id: string) => void;\n /** Takes an ID that represents the Badge. This function is called when the Badge is closed by clicking the X. */\n onRemove?: (id: string) => void;\n /** Event handler called when the Badge is clicked. */\n onClick?: (event: MouseEvent) => void;\n /** Event handler fired on every keyup event. */\n onKeyUp?: (event: KeyboardEvent) => void;\n}\n\nexport const StyledSelectable = styled.button(props => {\n const { foreground, background } = props.theme.components.badges.selectable.base;\n const { dark } = props.theme.base.palette;\n const borderRadius = props.theme.base['border-radius'];\n const { spacing } = props.theme.base;\n\n const displayBackground = tryCatch(() => mix(0.15, background, '#ffffff'));\n const hoverBorder = tryCatch(() => mix(0.3, background, '#ffffff'));\n const boxShadowColor = tryCatch(() => transparentize(0.45, dark));\n\n const height = 1.125;\n return css`\n background: ${displayBackground};\n border: 0 solid transparent;\n border-radius: calc(${height} * ${borderRadius});\n color: ${foreground};\n cursor: default;\n display: inline-flex;\n align-items: center;\n font-size: 0.75rem;\n height: ${height}rem;\n padding: 0 ${spacing};\n min-width: max-content;\n line-height: 1;\n\n &:hover {\n color: ${props.theme.base.palette.interactive};\n box-shadow: inset 0 0 0 0.0625rem ${hoverBorder};\n\n ${StyledBareButton} {\n color: ${props.theme.base.palette.interactive};\n }\n }\n\n &:active {\n box-shadow: inset 0 0 0 0.0625rem ${background};\n }\n\n &:focus {\n color: ${props.theme.base.palette.interactive};\n box-shadow: 0 0 0.5rem -0.125rem ${boxShadowColor}, inset 0 0 0 0.125rem ${background};\n outline: none;\n\n ${StyledBareButton} {\n color: ${props.theme.base.palette.interactive};\n }\n }\n\n ${StyledIcon} {\n margin-inline-start: ${spacing};\n height: 1em;\n width: 1em;\n }\n `;\n});\nStyledSelectable.defaultProps = defaultThemeProp;\n\nconst Selectable: FC<SelectableProps & ForwardProps> = forwardRef(\n (\n {\n id,\n children,\n onSelect,\n onRemove,\n onClick,\n onKeyUp,\n ...restProps\n }: PropsWithoutRef<SelectableProps>,\n ref: Ref<HTMLButtonElement>\n ) => {\n const consolidatedRef = useConsolidatedRef(ref);\n const t = useI18n();\n\n const handleClick = (e: MouseEvent<HTMLButtonElement>) => {\n onClick?.(e);\n onSelect?.(id);\n };\n\n const handleCloseClick = (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n onRemove?.(id);\n };\n\n const handleKeyUp = (e: KeyboardEvent) => {\n onKeyUp?.(e);\n if (e.key === 'Enter') {\n onSelect?.(id);\n }\n\n if (e.key === 'Backspace' || e.key === 'Delete') {\n onRemove?.(id);\n }\n };\n\n return (\n <StyledSelectable\n ref={consolidatedRef}\n onClick={handleClick}\n onKeyUp={handleKeyUp}\n {...restProps}\n >\n {children}\n {onRemove && (\n <BareButton tabIndex='-1' onClick={handleCloseClick} aria-label={`${t('remove')}`}>\n <Icon name='times' />\n </BareButton>\n )}\n </StyledSelectable>\n );\n }\n);\n\nexport default Selectable;\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FunctionComponent, Ref } from 'react';
|
|
2
|
+
import { DefaultTheme } from 'styled-components';
|
|
2
3
|
import { BaseProps, ForwardProps, NoChildrenProp } from '../../types';
|
|
3
4
|
import { MenuItemProps } from '../Menu';
|
|
4
5
|
export interface BreadcrumbsProps extends BaseProps, NoChildrenProp {
|
|
@@ -7,7 +8,7 @@ export interface BreadcrumbsProps extends BaseProps, NoChildrenProp {
|
|
|
7
8
|
/** Ref forwarded to the wrapping element. */
|
|
8
9
|
ref?: Ref<HTMLDivElement>;
|
|
9
10
|
}
|
|
10
|
-
export declare const StyledBreadcrumbs: import("styled-components").StyledComponent<"div",
|
|
11
|
+
export declare const StyledBreadcrumbs: import("styled-components").StyledComponent<"div", DefaultTheme, {
|
|
11
12
|
oneItemRemaining: boolean;
|
|
12
13
|
}, never>;
|
|
13
14
|
declare const Breadcrumbs: FunctionComponent<BreadcrumbsProps & ForwardProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Breadcrumbs.d.ts","sourceRoot":"","sources":["../../../src/components/Breadcrumbs/Breadcrumbs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAEjB,GAAG,EAKJ,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Breadcrumbs.d.ts","sourceRoot":"","sources":["../../../src/components/Breadcrumbs/Breadcrumbs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAEjB,GAAG,EAKJ,MAAM,OAAO,CAAC;AACf,OAAe,EAAO,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAK9D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAUtE,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxC,MAAM,WAAW,gBAAiB,SAAQ,SAAS,EAAE,cAAc;IACjE,mHAAmH;IACnH,IAAI,EAAE,aAAa,EAAE,CAAC;IACtB,6CAA6C;IAC7C,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAYD,eAAO,MAAM,iBAAiB;sBAAkC,OAAO;SA0BtE,CAAC;AAyBF,QAAA,MAAM,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,GAAG,YAAY,CAwHnE,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -5,14 +5,14 @@ import { rgba } from 'polished';
|
|
|
5
5
|
import { useElement, useConsolidatedRef, useDirection } from '../../hooks';
|
|
6
6
|
import { defaultThemeProp } from '../../theme';
|
|
7
7
|
import { debounce, tryCatch } from '../../utils';
|
|
8
|
-
import Button from '../Button';
|
|
8
|
+
import Button, { StyledButton } from '../Button';
|
|
9
9
|
import Flex from '../Flex';
|
|
10
|
-
import Link from '../Link';
|
|
10
|
+
import Link, { StyledLink } from '../Link';
|
|
11
11
|
import Icon, { StyledIcon, registerIcon } from '../Icon';
|
|
12
12
|
import * as caretLeftIcon from '../Icon/icons/caret-left.icon';
|
|
13
13
|
import * as caretRightIcon from '../Icon/icons/caret-right.icon';
|
|
14
14
|
import MenuButton from '../MenuButton';
|
|
15
|
-
import Text from '../Text';
|
|
15
|
+
import Text, { StyledText } from '../Text';
|
|
16
16
|
registerIcon(caretLeftIcon, caretRightIcon);
|
|
17
17
|
const StyledSeparator = styled(Icon)(({ theme }) => {
|
|
18
18
|
const color = tryCatch(() => rgba(theme.base.palette['foreground-color'], theme.base.transparency['transparent-2']));
|
|
@@ -20,7 +20,7 @@ const StyledSeparator = styled(Icon)(({ theme }) => {
|
|
|
20
20
|
color: ${color};
|
|
21
21
|
`;
|
|
22
22
|
});
|
|
23
|
-
export const StyledBreadcrumbs = styled.div(({ oneItemRemaining }) => css `
|
|
23
|
+
export const StyledBreadcrumbs = styled.div(({ theme, oneItemRemaining }) => css `
|
|
24
24
|
white-space: nowrap;
|
|
25
25
|
overflow: visible;
|
|
26
26
|
visibility: hidden;
|
|
@@ -31,6 +31,12 @@ export const StyledBreadcrumbs = styled.div(({ oneItemRemaining }) => css `
|
|
|
31
31
|
flex-shrink: 0;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
${StyledLink},
|
|
35
|
+
${StyledButton},
|
|
36
|
+
${StyledText} {
|
|
37
|
+
max-width: ${theme.base['content-width'].md};
|
|
38
|
+
}
|
|
39
|
+
|
|
34
40
|
${oneItemRemaining &&
|
|
35
41
|
css `
|
|
36
42
|
& > :last-child {
|
|
@@ -40,6 +46,20 @@ export const StyledBreadcrumbs = styled.div(({ oneItemRemaining }) => css `
|
|
|
40
46
|
`}
|
|
41
47
|
`);
|
|
42
48
|
StyledBreadcrumbs.defaultProps = defaultThemeProp;
|
|
49
|
+
const getEllipsisStyles = ({ theme }) => {
|
|
50
|
+
return css `
|
|
51
|
+
min-width: ${theme.base['content-width'].xs};
|
|
52
|
+
white-space: nowrap;
|
|
53
|
+
overflow: hidden;
|
|
54
|
+
text-overflow: ellipsis;
|
|
55
|
+
`;
|
|
56
|
+
};
|
|
57
|
+
const StyledEllipsizedLink = styled(Link)(getEllipsisStyles);
|
|
58
|
+
StyledEllipsizedLink.defaultProps = defaultThemeProp;
|
|
59
|
+
const StyledEllipsizedButton = styled(Button)(getEllipsisStyles);
|
|
60
|
+
StyledEllipsizedButton.defaultProps = defaultThemeProp;
|
|
61
|
+
const StyledEllipsizedText = styled(Text)(getEllipsisStyles);
|
|
62
|
+
StyledEllipsizedText.defaultProps = defaultThemeProp;
|
|
43
63
|
const Breadcrumbs = forwardRef(({ path, ...restProps }, ref) => {
|
|
44
64
|
const [breadcrumbsEl, setBreadcrumbsEl] = useElement();
|
|
45
65
|
const [numMenuItems, setNumMenuItems] = useState(0);
|
|
@@ -83,15 +103,15 @@ const Breadcrumbs = forwardRef(({ path, ...restProps }, ref) => {
|
|
|
83
103
|
const { id, primary, visual, href, onClick, ...restCrumbProps } = crumb;
|
|
84
104
|
let Comp;
|
|
85
105
|
if (href)
|
|
86
|
-
Comp = (_jsxs(Link, { href: href, onClick: (e) => {
|
|
106
|
+
Comp = (_jsxs(Link, { href: href, as: primary.length > 60 ? StyledEllipsizedLink : undefined, onClick: (e) => {
|
|
87
107
|
onClick?.(id, e);
|
|
88
108
|
}, ...restCrumbProps, children: [visual, " ", primary] }, id));
|
|
89
109
|
else if (onClick)
|
|
90
|
-
Comp = (_jsxs(Button, { variant: 'link', onClick: (e) => {
|
|
110
|
+
Comp = (_jsxs(Button, { variant: 'link', as: primary.length > 60 ? StyledEllipsizedButton : undefined, onClick: (e) => {
|
|
91
111
|
onClick(id, e);
|
|
92
112
|
}, ...restCrumbProps, children: [visual, " ", primary] }, id));
|
|
93
113
|
else
|
|
94
|
-
Comp = (_jsxs(Text, { ...restCrumbProps, children: [visual, " ", primary] }, id));
|
|
114
|
+
Comp = (_jsxs(Text, { as: primary.length > 60 ? StyledEllipsizedText : undefined, ...restCrumbProps, children: [visual, " ", primary] }, id));
|
|
95
115
|
if (index === path.slice(numMenuItems).length - 1)
|
|
96
116
|
return Comp;
|
|
97
117
|
return (_jsxs(Fragment, { children: [Comp, _j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E,OAAO,IAAI,CAAC;gBAE/D,OAAO,CACL,MAAC,QAAQ,eACN,IAAI,EACL,KAAC,eAAe,IAAC,IAAI,EAAE,SAAS,GAAG,EAAE,GAAI,KAF5B,EAAE,CAGN,CACZ,CAAC;YACJ,CAAC,CAAC,IACG,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import {\n forwardRef,\n Fragment,\n FunctionComponent,\n PropsWithoutRef,\n Ref,\n useEffect,\n useRef,\n useState,\n MouseEvent\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { rgba } from 'polished';\n\nimport { useElement, useConsolidatedRef, useDirection } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport { BaseProps, ForwardProps, NoChildrenProp } from '../../types';\nimport { debounce, tryCatch } from '../../utils';\nimport Button from '../Button';\nimport Flex from '../Flex';\nimport Link from '../Link';\nimport Icon, { StyledIcon, registerIcon } from '../Icon';\nimport * as caretLeftIcon from '../Icon/icons/caret-left.icon';\nimport * as caretRightIcon from '../Icon/icons/caret-right.icon';\nimport MenuButton from '../MenuButton';\nimport Text from '../Text';\nimport { MenuItemProps } from '../Menu';\n\nregisterIcon(caretLeftIcon, caretRightIcon);\n\nexport interface BreadcrumbsProps extends BaseProps, NoChildrenProp {\n /** A set of actions representing the chronological hierarchy of pages or locations leading to the current view. */\n path: MenuItemProps[];\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nconst StyledSeparator: typeof Icon = styled(Icon)(({ theme }) => {\n const color = tryCatch(() =>\n rgba(theme.base.palette['foreground-color'], theme.base.transparency['transparent-2'])\n );\n\n return css`\n color: ${color};\n `;\n});\n\nexport const StyledBreadcrumbs = styled.div<{ oneItemRemaining: boolean }>(\n ({ oneItemRemaining }) => css`\n white-space: nowrap;\n overflow: visible;\n visibility: hidden;\n\n ${StyledIcon} {\n width: 1em;\n height: 1em;\n flex-shrink: 0;\n }\n\n ${oneItemRemaining &&\n css`\n & > :last-child {\n text-overflow: ellipsis;\n overflow: hidden;\n }\n `}\n `\n);\n\nStyledBreadcrumbs.defaultProps = defaultThemeProp;\n\nconst Breadcrumbs: FunctionComponent<BreadcrumbsProps & ForwardProps> = forwardRef(\n ({ path, ...restProps }: PropsWithoutRef<BreadcrumbsProps>, ref: BreadcrumbsProps['ref']) => {\n const [breadcrumbsEl, setBreadcrumbsEl] = useElement<HTMLDivElement>();\n const [numMenuItems, setNumMenuItems] = useState(0);\n const minInlineWidth = useRef(0);\n\n const breadcrumbRef = useConsolidatedRef(setBreadcrumbsEl, ref);\n\n const debouncedResize = debounce((entries: ResizeObserverEntry[]) => {\n if (entries[0].contentRect.width > minInlineWidth.current) {\n setNumMenuItems(curr => {\n if (curr === 0) return curr;\n return curr - 1;\n });\n }\n }, 100);\n\n const resizeObserver = new ResizeObserver(debouncedResize);\n\n const intersectionObserver = new IntersectionObserver(\n entries => {\n if (entries[0].intersectionRatio < 1 && numMenuItems < path.length - 1) {\n if (entries[0].rootBounds) minInlineWidth.current = entries[0].rootBounds.width + 1;\n setNumMenuItems(curr => {\n if (curr === path.length - 1) return curr;\n return curr + 1;\n });\n } else if (breadcrumbsEl) breadcrumbsEl.style.visibility = 'visible';\n },\n { root: breadcrumbsEl, threshold: 1 }\n );\n\n useEffect(() => {\n if (breadcrumbsEl && breadcrumbsEl.lastChild) {\n intersectionObserver.observe(breadcrumbsEl.lastChild as Element);\n resizeObserver.observe(breadcrumbsEl);\n\n return () => {\n intersectionObserver.disconnect();\n resizeObserver.disconnect();\n };\n }\n }, [breadcrumbsEl, numMenuItems]);\n\n const { end } = useDirection();\n\n return (\n <Flex\n {...restProps}\n container={{ gap: 0.5, alignItems: 'center' }}\n as={StyledBreadcrumbs}\n oneItemRemaining={numMenuItems === path.length - 1}\n ref={breadcrumbRef}\n >\n {numMenuItems > 0 && (\n <>\n <MenuButton\n text='Links'\n iconOnly\n variant='link'\n icon='folder-hierarchy-solid'\n menu={{ items: path.slice(0, numMenuItems).reverse() }}\n />\n <StyledSeparator name={`caret-${end}`} />\n </>\n )}\n {path.slice(numMenuItems).map((crumb, index) => {\n const { id, primary, visual, href, onClick, ...restCrumbProps } = crumb;\n let Comp;\n if (href)\n Comp = (\n <Link\n key={id}\n href={href}\n onClick={(e: MouseEvent<HTMLAnchorElement>) => {\n onClick?.(id, e);\n }}\n {...restCrumbProps}\n >\n {visual} {primary}\n </Link>\n );\n else if (onClick)\n Comp = (\n <Button\n key={id}\n variant='link'\n onClick={(e: MouseEvent<HTMLButtonElement>) => {\n onClick(id, e);\n }}\n {...restCrumbProps}\n >\n {visual} {primary}\n </Button>\n );\n else\n Comp = (\n <Text key={id} {...restCrumbProps}>\n {visual} {primary}\n </Text>\n );\n\n if (index === path.slice(numMenuItems).length - 1) return Comp;\n\n return (\n <Fragment key={id}>\n {Comp}\n <StyledSeparator name={`caret-${end}`} />\n </Fragment>\n );\n })}\n </Flex>\n );\n }\n);\n\nexport default Breadcrumbs;\n"]}
|
|
1
|
+
{"version":3,"file":"Breadcrumbs.js","sourceRoot":"","sources":["../../../src/components/Breadcrumbs/Breadcrumbs.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,QAAQ,EAIR,SAAS,EACT,MAAM,EACN,QAAQ,EAET,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAgB,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,EAAE,E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Ac,aAEjB,MAAM,OAAG,OAAO,KARZ,EAAE,CASA,CACV,CAAC;;oBAEF,IAAI,GAAG,CACL,MAAC,IAAI,IAEH,EAAE,EAAE,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS,KACtD,cAAc,aAEjB,MAAM,OAAG,OAAO,KAJZ,EAAE,CAKF,CACR,CAAC;gBAEJ,IAAI,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC;oBAAE,OAAO,IAAI,CAAC;gBAE/D,OAAO,CACL,MAAC,QAAQ,eACN,IAAI,EACL,KAAC,eAAe,IAAC,IAAI,EAAE,SAAS,GAAG,EAAE,GAAI,KAF5B,EAAE,CAGN,CACZ,CAAC;YACJ,CAAC,CAAC,IACG,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import {\n forwardRef,\n Fragment,\n FunctionComponent,\n PropsWithoutRef,\n Ref,\n useEffect,\n useRef,\n useState,\n MouseEvent\n} from 'react';\nimport styled, { css, DefaultTheme } from 'styled-components';\nimport { rgba } from 'polished';\n\nimport { useElement, useConsolidatedRef, useDirection } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport { BaseProps, ForwardProps, NoChildrenProp } from '../../types';\nimport { debounce, tryCatch } from '../../utils';\nimport Button, { StyledButton } from '../Button';\nimport Flex from '../Flex';\nimport Link, { StyledLink } from '../Link';\nimport Icon, { StyledIcon, registerIcon } from '../Icon';\nimport * as caretLeftIcon from '../Icon/icons/caret-left.icon';\nimport * as caretRightIcon from '../Icon/icons/caret-right.icon';\nimport MenuButton from '../MenuButton';\nimport Text, { StyledText } from '../Text';\nimport { MenuItemProps } from '../Menu';\n\nregisterIcon(caretLeftIcon, caretRightIcon);\n\nexport interface BreadcrumbsProps extends BaseProps, NoChildrenProp {\n /** A set of actions representing the chronological hierarchy of pages or locations leading to the current view. */\n path: MenuItemProps[];\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nconst StyledSeparator: typeof Icon = styled(Icon)(({ theme }) => {\n const color = tryCatch(() =>\n rgba(theme.base.palette['foreground-color'], theme.base.transparency['transparent-2'])\n );\n\n return css`\n color: ${color};\n `;\n});\n\nexport const StyledBreadcrumbs = styled.div<{ oneItemRemaining: boolean }>(\n ({ theme, oneItemRemaining }) => css`\n white-space: nowrap;\n overflow: visible;\n visibility: hidden;\n\n ${StyledIcon} {\n width: 1em;\n height: 1em;\n flex-shrink: 0;\n }\n\n ${StyledLink},\n ${StyledButton},\n ${StyledText} {\n max-width: ${theme.base['content-width'].md};\n }\n\n ${oneItemRemaining &&\n css`\n & > :last-child {\n text-overflow: ellipsis;\n overflow: hidden;\n }\n `}\n `\n);\n\nStyledBreadcrumbs.defaultProps = defaultThemeProp;\n\nconst getEllipsisStyles = ({ theme }: { theme: DefaultTheme }) => {\n return css`\n min-width: ${theme.base['content-width'].xs};\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n `;\n};\n\nconst StyledEllipsizedLink = styled(Link)(getEllipsisStyles);\n\nStyledEllipsizedLink.defaultProps = defaultThemeProp;\n\nconst StyledEllipsizedButton = styled(Button)(getEllipsisStyles);\n\nStyledEllipsizedButton.defaultProps = defaultThemeProp;\n\nconst StyledEllipsizedText = styled(Text)(getEllipsisStyles);\n\nStyledEllipsizedText.defaultProps = defaultThemeProp;\n\nconst Breadcrumbs: FunctionComponent<BreadcrumbsProps & ForwardProps> = forwardRef(\n ({ path, ...restProps }: PropsWithoutRef<BreadcrumbsProps>, ref: BreadcrumbsProps['ref']) => {\n const [breadcrumbsEl, setBreadcrumbsEl] = useElement<HTMLDivElement>();\n const [numMenuItems, setNumMenuItems] = useState(0);\n const minInlineWidth = useRef(0);\n\n const breadcrumbRef = useConsolidatedRef(setBreadcrumbsEl, ref);\n\n const debouncedResize = debounce((entries: ResizeObserverEntry[]) => {\n if (entries[0].contentRect.width > minInlineWidth.current) {\n setNumMenuItems(curr => {\n if (curr === 0) return curr;\n return curr - 1;\n });\n }\n }, 100);\n\n const resizeObserver = new ResizeObserver(debouncedResize);\n\n const intersectionObserver = new IntersectionObserver(\n entries => {\n if (entries[0].intersectionRatio < 1 && numMenuItems < path.length - 1) {\n if (entries[0].rootBounds) minInlineWidth.current = entries[0].rootBounds.width + 1;\n setNumMenuItems(curr => {\n if (curr === path.length - 1) return curr;\n return curr + 1;\n });\n } else if (breadcrumbsEl) breadcrumbsEl.style.visibility = 'visible';\n },\n { root: breadcrumbsEl, threshold: 1 }\n );\n\n useEffect(() => {\n if (breadcrumbsEl && breadcrumbsEl.lastChild) {\n intersectionObserver.observe(breadcrumbsEl.lastChild as Element);\n resizeObserver.observe(breadcrumbsEl);\n\n return () => {\n intersectionObserver.disconnect();\n resizeObserver.disconnect();\n };\n }\n }, [breadcrumbsEl, numMenuItems]);\n\n const { end } = useDirection();\n\n return (\n <Flex\n {...restProps}\n container={{ gap: 0.5, alignItems: 'center' }}\n as={StyledBreadcrumbs}\n oneItemRemaining={numMenuItems === path.length - 1}\n ref={breadcrumbRef}\n >\n {numMenuItems > 0 && (\n <>\n <MenuButton\n text='Links'\n iconOnly\n variant='link'\n icon='folder-hierarchy-solid'\n menu={{ items: path.slice(0, numMenuItems).reverse() }}\n />\n <StyledSeparator name={`caret-${end}`} />\n </>\n )}\n {path.slice(numMenuItems).map((crumb, index) => {\n const { id, primary, visual, href, onClick, ...restCrumbProps } = crumb;\n let Comp;\n if (href)\n Comp = (\n <Link\n key={id}\n href={href}\n as={primary.length > 60 ? StyledEllipsizedLink : undefined}\n onClick={(e: MouseEvent<HTMLAnchorElement>) => {\n onClick?.(id, e);\n }}\n {...restCrumbProps}\n >\n {visual} {primary}\n </Link>\n );\n else if (onClick)\n Comp = (\n <Button\n key={id}\n variant='link'\n as={primary.length > 60 ? StyledEllipsizedButton : undefined}\n onClick={(e: MouseEvent<HTMLButtonElement>) => {\n onClick(id, e);\n }}\n {...restCrumbProps}\n >\n {visual} {primary}\n </Button>\n );\n else\n Comp = (\n <Text\n key={id}\n as={primary.length > 60 ? StyledEllipsizedText : undefined}\n {...restCrumbProps}\n >\n {visual} {primary}\n </Text>\n );\n\n if (index === path.slice(numMenuItems).length - 1) return Comp;\n\n return (\n <Fragment key={id}>\n {Comp}\n <StyledSeparator name={`caret-${end}`} />\n </Fragment>\n );\n })}\n </Flex>\n );\n }\n);\n\nexport default Breadcrumbs;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBox.d.ts","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EASlB,MAAM,OAAO,CAAC;AAKf,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ComboBox.d.ts","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EASlB,MAAM,OAAO,CAAC;AAKf,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAoB3C,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAO7C,QAAA,MAAM,QAAQ,EAAE,iBAAiB,CAAC,aAAa,GAAG,YAAY,CA6R7D,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'r
|
|
|
3
3
|
import Icon, { registerIcon } from '../Icon';
|
|
4
4
|
import * as caretDownIcon from '../Icon/icons/caret-down.icon';
|
|
5
5
|
import * as caretUpIcon from '../Icon/icons/caret-up.icon';
|
|
6
|
-
import { useConsolidatedRef, useFocusWithin, useI18n, useUID, useElement } from '../../hooks';
|
|
6
|
+
import { useConsolidatedRef, useFocusWithin, useI18n, useUID, useElement, useDirection } from '../../hooks';
|
|
7
7
|
import Popover from '../Popover';
|
|
8
8
|
import FormField from '../FormField';
|
|
9
9
|
import { StyledFormControl } from '../FormControl';
|
|
@@ -12,6 +12,7 @@ import Button from '../Button';
|
|
|
12
12
|
import { navigatorIsAvailable } from '../../utils';
|
|
13
13
|
import menuHelpers from '../Menu/helpers';
|
|
14
14
|
import { sameWidth } from '../Popover/modifiers';
|
|
15
|
+
import VisuallyHiddenText from '../VisuallyHiddenText';
|
|
15
16
|
import ComboBoxInput from './ComboBoxInput';
|
|
16
17
|
import { StyledComboBox } from './ComboBox.styles';
|
|
17
18
|
registerIcon(caretDownIcon, caretUpIcon);
|
|
@@ -19,17 +20,30 @@ const isMobile = navigatorIsAvailable && navigator.userAgent.includes('Mobile');
|
|
|
19
20
|
const ComboBox = forwardRef((props, ref) => {
|
|
20
21
|
const uid = useUID();
|
|
21
22
|
const { value, required, id = uid, label, labelHidden, info, status, readOnly, disabled, mode = 'single-select', selected, onChange, actions, onFocus, onBlur, onResolveSuggestion, onDropdownButtonClick: onDropdownButtonClickProp, onClick, menu, ...restProps } = props;
|
|
23
|
+
const [pauseMenuDescendantEvaluation, setPauseMenuDescendantEvaluation] = useState(true);
|
|
24
|
+
const [pauseSelectedDescendantEvaluation, setPauseSelectedDescendantEvaluation] = useState(false);
|
|
22
25
|
const t = useI18n();
|
|
26
|
+
const listId = `${id}-list`;
|
|
23
27
|
const inputRef = useRef(null);
|
|
24
28
|
const [open, setOpen] = useState(false);
|
|
25
29
|
const menuRef = useRef(null);
|
|
26
30
|
const menuComponentId = `${id}-listbox`;
|
|
31
|
+
const { start } = useDirection();
|
|
27
32
|
// Force a re-render to make sure useFocusWithin has valid elements to set listeners on.
|
|
28
33
|
const [, setContainerEl] = useElement();
|
|
29
34
|
const containerRef = useConsolidatedRef(ref, setContainerEl);
|
|
35
|
+
const toggleMenuDescendantsActive = useCallback((bool) => {
|
|
36
|
+
setPauseMenuDescendantEvaluation(!bool);
|
|
37
|
+
setPauseSelectedDescendantEvaluation(bool);
|
|
38
|
+
}, []);
|
|
39
|
+
const toggleSelectedDescendantsActive = useCallback((bool) => {
|
|
40
|
+
setPauseSelectedDescendantEvaluation(!bool);
|
|
41
|
+
setPauseMenuDescendantEvaluation(bool);
|
|
42
|
+
}, []);
|
|
30
43
|
const focus = useFocusWithin([containerRef], focused => {
|
|
31
44
|
if (!focused) {
|
|
32
45
|
setOpen(false);
|
|
46
|
+
toggleMenuDescendantsActive(false);
|
|
33
47
|
onBlur?.(selected?.items);
|
|
34
48
|
}
|
|
35
49
|
else {
|
|
@@ -48,20 +62,28 @@ const ComboBox = forwardRef((props, ref) => {
|
|
|
48
62
|
case 'ArrowUp':
|
|
49
63
|
if (e.altKey) {
|
|
50
64
|
e.preventDefault();
|
|
51
|
-
if (open)
|
|
65
|
+
if (open) {
|
|
52
66
|
setOpen(false);
|
|
67
|
+
toggleMenuDescendantsActive(false);
|
|
68
|
+
}
|
|
53
69
|
}
|
|
54
70
|
break;
|
|
55
71
|
case 'ArrowDown':
|
|
56
72
|
e.preventDefault();
|
|
57
|
-
if (!open)
|
|
73
|
+
if (!open) {
|
|
58
74
|
setOpen(true);
|
|
75
|
+
toggleMenuDescendantsActive(true);
|
|
76
|
+
}
|
|
59
77
|
break;
|
|
60
78
|
case 'Escape':
|
|
61
|
-
|
|
62
|
-
if (
|
|
63
|
-
e.
|
|
79
|
+
case 'Tab':
|
|
80
|
+
if (e.key === 'Escape') {
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
if (open)
|
|
83
|
+
e.stopPropagation();
|
|
84
|
+
}
|
|
64
85
|
setOpen(false);
|
|
86
|
+
toggleMenuDescendantsActive(false);
|
|
65
87
|
break;
|
|
66
88
|
default:
|
|
67
89
|
}
|
|
@@ -71,27 +93,41 @@ const ComboBox = forwardRef((props, ref) => {
|
|
|
71
93
|
setOpen(!open);
|
|
72
94
|
}, [open, onDropdownButtonClickProp]);
|
|
73
95
|
const dropdownButton = useMemo(() => {
|
|
74
|
-
return (menu?.items?.length || onDropdownButtonClickProp || !onChange
|
|
75
|
-
!readOnly ? (_jsx(Button, { "aria-label": t(open ? 'combobox_close_list_button_a11y' : 'combobox_open_list_button_a11y'), icon: true, variant: 'simple', onClick: onDropdownButtonClick, onMouseDown: (e) => {
|
|
96
|
+
return (menu?.items?.length || onDropdownButtonClickProp || !onChange) && !readOnly ? (_jsx(Button, { "aria-label": t(open ? 'combobox_close_list_button_a11y' : 'combobox_open_list_button_a11y'), icon: true, variant: 'simple', onClick: onDropdownButtonClick, onMouseDown: (e) => {
|
|
76
97
|
e.preventDefault();
|
|
77
98
|
inputRef.current?.focus();
|
|
78
99
|
}, disabled: disabled, tabIndex: '-1', children: _jsx(Icon, { name: open ? 'caret-up' : 'caret-down' }) })) : null;
|
|
79
|
-
}, [onDropdownButtonClick, onChange, readOnly, open, disabled
|
|
100
|
+
}, [onDropdownButtonClick, onChange, readOnly, open, disabled]);
|
|
101
|
+
const ariaDescribedBy = useMemo(() => {
|
|
102
|
+
let idString = `${id}-inputDescription`;
|
|
103
|
+
if (info) {
|
|
104
|
+
idString = idString.concat(` ${id}-info`);
|
|
105
|
+
}
|
|
106
|
+
if (onChange) {
|
|
107
|
+
idString = idString.concat(` ${id}-searchDescription`);
|
|
108
|
+
}
|
|
109
|
+
if (mode === 'multi-select') {
|
|
110
|
+
idString = idString.concat(` ${id}-multiselectDescription`);
|
|
111
|
+
}
|
|
112
|
+
return idString;
|
|
113
|
+
}, [info, id, mode, onChange]);
|
|
80
114
|
const onInputClick = useCallback((e) => {
|
|
81
115
|
if (readOnly)
|
|
82
116
|
return;
|
|
83
117
|
setOpen(true);
|
|
118
|
+
toggleMenuDescendantsActive(true);
|
|
84
119
|
onClick?.(e);
|
|
85
120
|
}, [readOnly, onClick]);
|
|
86
121
|
useEffect(() => {
|
|
87
122
|
if (focus && menu && value && value.length > 0) {
|
|
88
123
|
setOpen(true);
|
|
124
|
+
toggleMenuDescendantsActive(true);
|
|
89
125
|
}
|
|
90
126
|
}, [menu, value, focus]);
|
|
91
127
|
// Workaround for the following error from jsx-ast-utils, fixed in version 3.5.0.
|
|
92
128
|
// The prop value with an expression type of JSXFragment could not be resolved. Please file issue to get this fixed immediately.
|
|
93
129
|
const inputActions = (_jsxs(_Fragment, { children: [dropdownButton, actions] }));
|
|
94
|
-
const Comp = (_jsxs(StyledComboBox, { ref: containerRef, as: StyledFormControl, id: `${id}-combobox`,
|
|
130
|
+
const Comp = (_jsxs(StyledComboBox, { ref: containerRef, as: StyledFormControl, id: `${id}-combobox`, role: 'combobox', "aria-haspopup": 'listbox', "aria-expanded": !readOnly && !disabled && open, "aria-owns": open && menu !== undefined && !pauseMenuDescendantEvaluation ? listId : undefined, children: [_jsx(ComboBoxInput, { ref: inputRef, role: 'searchbox', "aria-autocomplete": 'list', "aria-controls": open && menu !== undefined && !pauseMenuDescendantEvaluation ? listId : undefined, "aria-describedby": ariaDescribedBy, selected: selected?.items, spellCheck: false, ...{
|
|
95
131
|
id,
|
|
96
132
|
readOnly,
|
|
97
133
|
disabled,
|
|
@@ -99,7 +135,11 @@ const ComboBox = forwardRef((props, ref) => {
|
|
|
99
135
|
value,
|
|
100
136
|
mode,
|
|
101
137
|
status
|
|
102
|
-
}, actions: inputActions, onRemove: selected?.onRemove, onClick: onInputClick, onKeyDown: onInputKeyDown, required: required,
|
|
138
|
+
}, actions: inputActions, onRemove: selected?.onRemove, onClick: onInputClick, onKeyDown: onInputKeyDown, required: required, pauseDescendantEvaluation: pauseSelectedDescendantEvaluation, onSelectedFocus: () => {
|
|
139
|
+
toggleSelectedDescendantsActive(true);
|
|
140
|
+
}, onSelectedBlur: () => {
|
|
141
|
+
toggleSelectedDescendantsActive(false);
|
|
142
|
+
}, ...restProps }), _jsx(Popover, { show: open && menu !== undefined, target: containerRef.current, placement: 'bottom-start', modifiers: [
|
|
103
143
|
{
|
|
104
144
|
name: 'flip',
|
|
105
145
|
options: {
|
|
@@ -107,26 +147,18 @@ const ComboBox = forwardRef((props, ref) => {
|
|
|
107
147
|
}
|
|
108
148
|
},
|
|
109
149
|
sameWidth
|
|
110
|
-
], strategy: isMobile ? 'absolute' : 'fixed', onMouseDown: (e) => e.preventDefault(), children: menu && (_jsx(Menu, { ref: menuRef, id: menuComponentId, role: 'listbox', mode: mode, ...menu, items: menu.items, focusControlEl: inputRef.current || undefined, onItemClick: (itemId, e) => {
|
|
150
|
+
], strategy: isMobile ? 'absolute' : 'fixed', onMouseDown: (e) => e.preventDefault(), children: menu && (_jsx(Menu, { ref: menuRef, listId: listId, id: menuComponentId, role: 'listbox', mode: mode, ...menu, items: menu.items, focusControlEl: inputRef.current || undefined, onItemClick: (itemId, e) => {
|
|
111
151
|
if (mode === 'single-select') {
|
|
112
152
|
setOpen(false);
|
|
153
|
+
toggleMenuDescendantsActive(true);
|
|
113
154
|
}
|
|
114
155
|
menu.onItemClick?.(itemId, e);
|
|
115
156
|
const clickedItem = menuHelpers.getItem(menu.items, itemId);
|
|
116
157
|
if (clickedItem?.primary && !clickedItem?.selected) {
|
|
117
158
|
selected?.onNew?.(clickedItem?.primary);
|
|
118
159
|
}
|
|
119
|
-
}, arrowNavigationUnsupported: true })) })] }));
|
|
120
|
-
return label ? (_jsx(FormField, { ...{
|
|
121
|
-
label,
|
|
122
|
-
labelHidden,
|
|
123
|
-
id,
|
|
124
|
-
info,
|
|
125
|
-
status,
|
|
126
|
-
required,
|
|
127
|
-
disabled,
|
|
128
|
-
onResolveSuggestion
|
|
129
|
-
}, children: Comp })) : (Comp);
|
|
160
|
+
}, "aria-label": t('menu_option_list'), pauseDescendantEvaluation: pauseMenuDescendantEvaluation, arrowNavigationUnsupported: true })) })] }));
|
|
161
|
+
return (_jsxs(_Fragment, { children: [label ? (_jsx(FormField, { ...{ label, labelHidden, id, info, status, required, disabled, onResolveSuggestion }, children: Comp })) : (Comp), _jsx(VisuallyHiddenText, { id: `${id}-inputDescription`, "aria-hidden": true, children: `${t('combobox_open_close')} ` }), _jsx(VisuallyHiddenText, { id: `${id}-searchDescription`, "aria-hidden": true, children: t('combobox_search_instructions') }), _jsx(VisuallyHiddenText, { id: `${id}-multiselectDescription`, "aria-hidden": true, children: t('multiselect_instructions', [start]) })] }));
|
|
130
162
|
});
|
|
131
163
|
export default ComboBox;
|
|
132
164
|
//# sourceMappingURL=ComboBox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBox.js","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAKV,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AAEf,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,WAAW,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9F,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,IAAmB,MAAM,SAAS,CAAC;AAC1C,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,YAAY,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;AAEzC,MAAM,QAAQ,GAAG,oBAAoB,IAAI,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAEhF,MAAM,QAAQ,GAAoD,UAA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c,EAAE,YAEjD,IAAI,IAAI,CACP,KAAC,IAAI,IACH,GAAG,EAAE,OAAO,EACZ,EAAE,EAAE,eAAe,EACnB,IAAI,EAAC,SAAS,EACd,IAAI,EAAE,IAAI,KACN,IAAI,EACR,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,cAAc,EAAE,QAAQ,CAAC,OAAO,IAAI,SAAS,EAC7C,WAAW,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;wBACzB,IAAI,IAAI,KAAK,eAAe,EAAE;4BAC5B,OAAO,CAAC,KAAK,CAAC,CAAC;yBAChB;wBACD,IAAI,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;wBAE9B,MAAM,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;wBAE5D,IAAI,WAAW,EAAE,OAAO,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE;4BAClD,QAAQ,EAAE,KAAK,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;yBACzC;oBACH,CAAC,EACD,0BAA0B,SAC1B,CACH,GACO,IACK,CAClB,CAAC;IAEF,OAAO,KAAK,CAAC,CAAC,CAAC,CACb,KAAC,SAAS,OACJ;YACF,KAAK;YACL,WAAW;YACX,EAAE;YACF,IAAI;YACJ,MAAM;YACN,QAAQ;YACR,QAAQ;YACR,mBAAmB;SACpB,YAEA,IAAI,GACK,CACb,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n KeyboardEvent as ReactKeyboardEvent,\n PropsWithoutRef,\n Ref,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState\n} from 'react';\n\nimport Icon, { registerIcon } from '../Icon';\nimport * as caretDownIcon from '../Icon/icons/caret-down.icon';\nimport * as caretUpIcon from '../Icon/icons/caret-up.icon';\nimport { ForwardProps } from '../../types';\nimport { useConsolidatedRef, useFocusWithin, useI18n, useUID, useElement } from '../../hooks';\nimport Popover from '../Popover';\nimport FormField from '../FormField';\nimport { StyledFormControl } from '../FormControl';\nimport Menu, { MenuProps } from '../Menu';\nimport Button from '../Button';\nimport { navigatorIsAvailable } from '../../utils';\nimport menuHelpers from '../Menu/helpers';\nimport { sameWidth } from '../Popover/modifiers';\n\nimport ComboBoxInput from './ComboBoxInput';\nimport ComboBoxProps from './ComboBox.types';\nimport { StyledComboBox } from './ComboBox.styles';\n\nregisterIcon(caretDownIcon, caretUpIcon);\n\nconst isMobile = navigatorIsAvailable && navigator.userAgent.includes('Mobile');\n\nconst ComboBox: FunctionComponent<ComboBoxProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ComboBoxProps>, ref: Ref<HTMLDivElement>) => {\n const uid = useUID();\n const {\n value,\n required,\n id = uid,\n label,\n labelHidden,\n info,\n status,\n readOnly,\n disabled,\n mode = 'single-select',\n selected,\n onChange,\n actions,\n onFocus,\n onBlur,\n onResolveSuggestion,\n onDropdownButtonClick: onDropdownButtonClickProp,\n onClick,\n menu,\n ...restProps\n } = props;\n\n const t = useI18n();\n const inputRef = useRef<HTMLInputElement>(null);\n const [open, setOpen] = useState(false);\n const menuRef: MenuProps['ref'] = useRef(null);\n const menuComponentId = `${id}-listbox`;\n\n // Force a re-render to make sure useFocusWithin has valid elements to set listeners on.\n const [, setContainerEl] = useElement();\n const containerRef = useConsolidatedRef<HTMLDivElement>(ref, setContainerEl);\n\n const focus = useFocusWithin([containerRef], focused => {\n if (!focused) {\n setOpen(false);\n onBlur?.(selected?.items);\n } else {\n onFocus?.(selected?.items);\n if (isMobile) {\n setTimeout(() => {\n containerRef.current?.scrollIntoView({ behavior: 'smooth', block: 'start' });\n }, 150); // delay it to let keyboard expand first\n }\n }\n });\n\n const onInputKeyDown = useCallback(\n (e: ReactKeyboardEvent<HTMLInputElement>) => {\n if (!menu || readOnly) return;\n switch (e.key) {\n case 'ArrowUp':\n if (e.altKey) {\n e.preventDefault();\n if (open) setOpen(false);\n }\n break;\n case 'ArrowDown':\n e.preventDefault();\n if (!open) setOpen(true);\n break;\n case 'Escape':\n e.preventDefault();\n if (open) e.stopPropagation();\n setOpen(false);\n break;\n default:\n }\n },\n [open, readOnly, menu, value]\n );\n\n const onDropdownButtonClick = useCallback(() => {\n onDropdownButtonClickProp?.(!open);\n setOpen(!open);\n }, [open, onDropdownButtonClickProp]);\n\n const dropdownButton = useMemo(() => {\n return (menu?.items?.length || onDropdownButtonClickProp || !onChange || menu?.loading) &&\n !readOnly ? (\n <Button\n aria-label={t(\n open ? 'combobox_close_list_button_a11y' : 'combobox_open_list_button_a11y'\n )}\n icon\n variant='simple'\n onClick={onDropdownButtonClick}\n onMouseDown={(e: MouseEvent) => {\n e.preventDefault();\n inputRef.current?.focus();\n }}\n disabled={disabled}\n tabIndex='-1'\n >\n <Icon name={open ? 'caret-up' : 'caret-down'} />\n </Button>\n ) : null;\n }, [onDropdownButtonClick, onChange, readOnly, open, disabled, menu?.loading]);\n\n const onInputClick = useCallback(\n (e: MouseEvent) => {\n if (readOnly) return;\n setOpen(true);\n onClick?.(e);\n },\n [readOnly, onClick]\n );\n\n useEffect(() => {\n if (focus && menu && value && value.length > 0) {\n setOpen(true);\n }\n }, [menu, value, focus]);\n\n // Workaround for the following error from jsx-ast-utils, fixed in version 3.5.0.\n // The prop value with an expression type of JSXFragment could not be resolved. Please file issue to get this fixed immediately.\n const inputActions = (\n <>\n {dropdownButton}\n {actions}\n </>\n );\n\n const Comp = (\n <StyledComboBox ref={containerRef} as={StyledFormControl} id={`${id}-combobox`}>\n <ComboBoxInput\n ref={inputRef}\n role='combobox'\n aria-haspopup='listbox'\n aria-expanded={!readOnly && !disabled && open}\n aria-autocomplete='list'\n aria-describedby={info ? `${id}-inputDescription ${id}-info` : `${id}-inputDescription`}\n selected={selected?.items}\n spellCheck={false}\n {...{\n id,\n readOnly,\n disabled,\n onChange,\n value,\n mode,\n status\n }}\n actions={inputActions}\n onRemove={selected?.onRemove}\n onClick={onInputClick}\n onKeyDown={onInputKeyDown}\n required={required}\n {...restProps}\n />\n\n <span id={`${id}-inputDescription`} hidden>\n {`${t('combobox_open_close')} ` && onChange ? t('combobox_search_instructions') : ''}\n </span>\n\n <Popover\n show={open && menu !== undefined}\n target={containerRef.current}\n placement='bottom-start'\n modifiers={[\n {\n name: 'flip',\n options: {\n fallbackPlacements: ['top-start']\n }\n },\n sameWidth\n ]}\n strategy={isMobile ? 'absolute' : 'fixed'}\n onMouseDown={(e: MouseEvent) => e.preventDefault()}\n >\n {menu && (\n <Menu\n ref={menuRef}\n id={menuComponentId}\n role='listbox'\n mode={mode}\n {...menu}\n items={menu.items}\n focusControlEl={inputRef.current || undefined}\n onItemClick={(itemId, e) => {\n if (mode === 'single-select') {\n setOpen(false);\n }\n menu.onItemClick?.(itemId, e);\n\n const clickedItem = menuHelpers.getItem(menu.items, itemId);\n\n if (clickedItem?.primary && !clickedItem?.selected) {\n selected?.onNew?.(clickedItem?.primary);\n }\n }}\n arrowNavigationUnsupported\n />\n )}\n </Popover>\n </StyledComboBox>\n );\n\n return label ? (\n <FormField\n {...{\n label,\n labelHidden,\n id,\n info,\n status,\n required,\n disabled,\n onResolveSuggestion\n }}\n >\n {Comp}\n </FormField>\n ) : (\n Comp\n );\n }\n);\n\nexport default ComboBox;\n"]}
|
|
1
|
+
{"version":3,"file":"ComboBox.js","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAKV,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AAEf,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,WAAW,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EACL,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AAG,EAAE,yBAAyB,iCACnD,CAAC,CAAC,0BAA0B,EAAE,CAAC,KAAK,CAAC,CAAC,GACpB,IACpB,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n KeyboardEvent as ReactKeyboardEvent,\n PropsWithoutRef,\n Ref,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState\n} from 'react';\n\nimport Icon, { registerIcon } from '../Icon';\nimport * as caretDownIcon from '../Icon/icons/caret-down.icon';\nimport * as caretUpIcon from '../Icon/icons/caret-up.icon';\nimport { ForwardProps } from '../../types';\nimport {\n useConsolidatedRef,\n useFocusWithin,\n useI18n,\n useUID,\n useElement,\n useDirection\n} from '../../hooks';\nimport Popover from '../Popover';\nimport FormField from '../FormField';\nimport { StyledFormControl } from '../FormControl';\nimport Menu, { MenuProps } from '../Menu';\nimport Button from '../Button';\nimport { navigatorIsAvailable } from '../../utils';\nimport menuHelpers from '../Menu/helpers';\nimport { sameWidth } from '../Popover/modifiers';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\n\nimport ComboBoxInput from './ComboBoxInput';\nimport ComboBoxProps from './ComboBox.types';\nimport { StyledComboBox } from './ComboBox.styles';\n\nregisterIcon(caretDownIcon, caretUpIcon);\n\nconst isMobile = navigatorIsAvailable && navigator.userAgent.includes('Mobile');\n\nconst ComboBox: FunctionComponent<ComboBoxProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ComboBoxProps>, ref: Ref<HTMLDivElement>) => {\n const uid = useUID();\n const {\n value,\n required,\n id = uid,\n label,\n labelHidden,\n info,\n status,\n readOnly,\n disabled,\n mode = 'single-select',\n selected,\n onChange,\n actions,\n onFocus,\n onBlur,\n onResolveSuggestion,\n onDropdownButtonClick: onDropdownButtonClickProp,\n onClick,\n menu,\n ...restProps\n } = props;\n const [pauseMenuDescendantEvaluation, setPauseMenuDescendantEvaluation] = useState(true);\n const [pauseSelectedDescendantEvaluation, setPauseSelectedDescendantEvaluation] =\n useState(false);\n const t = useI18n();\n const listId = `${id}-list`;\n const inputRef = useRef<HTMLInputElement>(null);\n const [open, setOpen] = useState(false);\n const menuRef: MenuProps['ref'] = useRef(null);\n const menuComponentId = `${id}-listbox`;\n const { start } = useDirection();\n\n // Force a re-render to make sure useFocusWithin has valid elements to set listeners on.\n const [, setContainerEl] = useElement();\n const containerRef = useConsolidatedRef<HTMLDivElement>(ref, setContainerEl);\n\n const toggleMenuDescendantsActive = useCallback((bool: boolean) => {\n setPauseMenuDescendantEvaluation(!bool);\n setPauseSelectedDescendantEvaluation(bool);\n }, []);\n\n const toggleSelectedDescendantsActive = useCallback((bool: boolean) => {\n setPauseSelectedDescendantEvaluation(!bool);\n setPauseMenuDescendantEvaluation(bool);\n }, []);\n\n const focus = useFocusWithin([containerRef], focused => {\n if (!focused) {\n setOpen(false);\n toggleMenuDescendantsActive(false);\n onBlur?.(selected?.items);\n } else {\n onFocus?.(selected?.items);\n if (isMobile) {\n setTimeout(() => {\n containerRef.current?.scrollIntoView({ behavior: 'smooth', block: 'start' });\n }, 150); // delay it to let keyboard expand first\n }\n }\n });\n\n const onInputKeyDown = useCallback(\n (e: ReactKeyboardEvent<HTMLInputElement>) => {\n if (!menu || readOnly) return;\n switch (e.key) {\n case 'ArrowUp':\n if (e.altKey) {\n e.preventDefault();\n if (open) {\n setOpen(false);\n toggleMenuDescendantsActive(false);\n }\n }\n break;\n case 'ArrowDown':\n e.preventDefault();\n if (!open) {\n setOpen(true);\n toggleMenuDescendantsActive(true);\n }\n break;\n case 'Escape':\n case 'Tab':\n if (e.key === 'Escape') {\n e.preventDefault();\n if (open) e.stopPropagation();\n }\n setOpen(false);\n toggleMenuDescendantsActive(false);\n break;\n default:\n }\n },\n [open, readOnly, menu, value]\n );\n\n const onDropdownButtonClick = useCallback(() => {\n onDropdownButtonClickProp?.(!open);\n setOpen(!open);\n }, [open, onDropdownButtonClickProp]);\n\n const dropdownButton = useMemo(() => {\n return (menu?.items?.length || onDropdownButtonClickProp || !onChange) && !readOnly ? (\n <Button\n aria-label={t(\n open ? 'combobox_close_list_button_a11y' : 'combobox_open_list_button_a11y'\n )}\n icon\n variant='simple'\n onClick={onDropdownButtonClick}\n onMouseDown={(e: MouseEvent) => {\n e.preventDefault();\n inputRef.current?.focus();\n }}\n disabled={disabled}\n tabIndex='-1'\n >\n <Icon name={open ? 'caret-up' : 'caret-down'} />\n </Button>\n ) : null;\n }, [onDropdownButtonClick, onChange, readOnly, open, disabled]);\n\n const ariaDescribedBy = useMemo(() => {\n let idString = `${id}-inputDescription`;\n\n if (info) {\n idString = idString.concat(` ${id}-info`);\n }\n if (onChange) {\n idString = idString.concat(` ${id}-searchDescription`);\n }\n if (mode === 'multi-select') {\n idString = idString.concat(` ${id}-multiselectDescription`);\n }\n\n return idString;\n }, [info, id, mode, onChange]);\n\n const onInputClick = useCallback(\n (e: MouseEvent) => {\n if (readOnly) return;\n setOpen(true);\n toggleMenuDescendantsActive(true);\n onClick?.(e);\n },\n [readOnly, onClick]\n );\n\n useEffect(() => {\n if (focus && menu && value && value.length > 0) {\n setOpen(true);\n toggleMenuDescendantsActive(true);\n }\n }, [menu, value, focus]);\n\n // Workaround for the following error from jsx-ast-utils, fixed in version 3.5.0.\n // The prop value with an expression type of JSXFragment could not be resolved. Please file issue to get this fixed immediately.\n const inputActions = (\n <>\n {dropdownButton}\n {actions}\n </>\n );\n\n const Comp = (\n <StyledComboBox\n ref={containerRef}\n as={StyledFormControl}\n id={`${id}-combobox`}\n role='combobox'\n aria-haspopup='listbox'\n aria-expanded={!readOnly && !disabled && open}\n aria-owns={\n open && menu !== undefined && !pauseMenuDescendantEvaluation ? listId : undefined\n }\n >\n <ComboBoxInput\n ref={inputRef}\n role='searchbox'\n aria-autocomplete='list'\n aria-controls={\n open && menu !== undefined && !pauseMenuDescendantEvaluation ? listId : undefined\n }\n aria-describedby={ariaDescribedBy}\n selected={selected?.items}\n spellCheck={false}\n {...{\n id,\n readOnly,\n disabled,\n onChange,\n value,\n mode,\n status\n }}\n actions={inputActions}\n onRemove={selected?.onRemove}\n onClick={onInputClick}\n onKeyDown={onInputKeyDown}\n required={required}\n pauseDescendantEvaluation={pauseSelectedDescendantEvaluation}\n onSelectedFocus={() => {\n toggleSelectedDescendantsActive(true);\n }}\n onSelectedBlur={() => {\n toggleSelectedDescendantsActive(false);\n }}\n {...restProps}\n />\n\n <Popover\n show={open && menu !== undefined}\n target={containerRef.current}\n placement='bottom-start'\n modifiers={[\n {\n name: 'flip',\n options: {\n fallbackPlacements: ['top-start']\n }\n },\n sameWidth\n ]}\n strategy={isMobile ? 'absolute' : 'fixed'}\n onMouseDown={(e: MouseEvent) => e.preventDefault()}\n >\n {menu && (\n <Menu\n ref={menuRef}\n listId={listId}\n id={menuComponentId}\n role='listbox'\n mode={mode}\n {...menu}\n items={menu.items}\n focusControlEl={inputRef.current || undefined}\n onItemClick={(itemId, e) => {\n if (mode === 'single-select') {\n setOpen(false);\n toggleMenuDescendantsActive(true);\n }\n menu.onItemClick?.(itemId, e);\n\n const clickedItem = menuHelpers.getItem(menu.items, itemId);\n\n if (clickedItem?.primary && !clickedItem?.selected) {\n selected?.onNew?.(clickedItem?.primary);\n }\n }}\n aria-label={t('menu_option_list')}\n pauseDescendantEvaluation={pauseMenuDescendantEvaluation}\n arrowNavigationUnsupported\n />\n )}\n </Popover>\n </StyledComboBox>\n );\n\n return (\n <>\n {label ? (\n <FormField\n {...{ label, labelHidden, id, info, status, required, disabled, onResolveSuggestion }}\n >\n {Comp}\n </FormField>\n ) : (\n Comp\n )}\n <VisuallyHiddenText id={`${id}-inputDescription`} aria-hidden>\n {`${t('combobox_open_close')} `}\n </VisuallyHiddenText>\n <VisuallyHiddenText id={`${id}-searchDescription`} aria-hidden>\n {t('combobox_search_instructions')}\n </VisuallyHiddenText>\n <VisuallyHiddenText id={`${id}-multiselectDescription`} aria-hidden>\n {t('multiselect_instructions', [start])}\n </VisuallyHiddenText>\n </>\n );\n }\n);\n\nexport default ComboBox;\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChangeEvent, ReactNode } from 'react';
|
|
1
|
+
import { ChangeEvent, ReactNode, Ref } from 'react';
|
|
2
2
|
import type { NoChildrenProp } from '../../types';
|
|
3
3
|
import { FormControlProps } from '../FormControl';
|
|
4
4
|
import { MenuItemProps, MenuProps } from '../Menu/Menu.types';
|
|
@@ -74,5 +74,7 @@ export default interface ComboBoxProps extends NoChildrenProp {
|
|
|
74
74
|
menu?: MenuProps;
|
|
75
75
|
/** A visual which represents the selected item. */
|
|
76
76
|
visual?: ReactNode;
|
|
77
|
+
/** Reference to the element. */
|
|
78
|
+
ref?: Ref<HTMLDivElement>;
|
|
77
79
|
}
|
|
78
80
|
//# sourceMappingURL=ComboBox.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBox.types.d.ts","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ComboBox.types.d.ts","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE9D,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,CAAC,OAAO,WAAW,aAAc,SAAQ,cAAc;IAC3D;;;OAGG;IACH,EAAE,CAAC,EAAE,gBAAgB,CAAC,IAAI,CA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Q,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE,KAAK,IAAI,CAAC;IACrD;;;;OAIG;IACH,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE,KAAK,IAAI,CAAC;IACpD,6DAA6D;IAC7D,mBAAmB,CAAC,EAAE,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;IAC9D,iDAAiD;IACjD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;;;OAOG;IACH,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAChD,oDAAoD;IACpD,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IAClC,wDAAwD;IACxD,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,yCAAyC;IACzC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,mDAAmD;IACnD,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,gCAAgC;IAChC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBox.types.js","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ChangeEvent, ReactNode } from 'react';\n\nimport type { NoChildrenProp } from '../../types';\nimport { FormControlProps } from '../FormControl';\nimport { MenuItemProps, MenuProps } from '../Menu/Menu.types';\n\nexport interface Selected {\n id: string;\n text: string;\n}\n\nexport default interface ComboBoxProps extends NoChildrenProp {\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /** Pass a string or a fragment with an Icon and string. */\n label?: FormControlProps['label'];\n /** Visually hides the label region. */\n labelHidden?: FormControlProps['labelHidden'];\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Makes the component non editable and non clickable. The browser defaults to false. */\n readOnly?: FormControlProps['readOnly'];\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: FormControlProps['info'];\n /** Placeholder text */\n placeholder?: FormControlProps['placeholder'];\n /**\n * Whether it is single selection or multi selection combobox.\n * @default 'single-select'\n */\n mode?: 'single-select' | 'multi-select';\n /** Currently selected option, single for single-select, an array for multi-select. */\n selected?: {\n items?: Selected | Selected[];\n onRemove?: (id: MenuItemProps['id'], index: number) => void;\n onNew?: (text: string) => void;\n };\n /** Value of the combobox filtering input. */\n value?: FormControlProps['value'];\n /** Callback fired when the filtering input value changes. */\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n /** Callback fired when the ComboBox input gains focus. */\n onFocus?: (selected?: Selected | Selected[]) => void;\n /**\n * Callback fired when the ComboBox looses focus within its containing element.\n * This is not specific to the input element.\n * Note, behavior will be enhanced in an upcoming release and the input will be the only focusable element.\n */\n onBlur?: (selected?: Selected | Selected[]) => void;\n /** Callback fired when AI suggestion is accepted/rejected */\n onResolveSuggestion?: FormControlProps['onResolveSuggestion'];\n /** Automatically focuses the input on render. */\n autoFocus?: boolean;\n /**\n * Fired when the user clicks on the dropdown icon to initiate opening the menu.\n * If you want to offer default menu items without an input value, pass this function.\n * This function can be an appropriate time to fetch menu item data.\n * Remember to set the loading prop to true when when fetching data for an empty list.\n *\n * @param open value defining whether the click opens or closes the menu\n */\n onDropdownButtonClick?: (open: boolean) => void;\n /** Fired when user clicks on the Combobox input. */\n onClick?: (e: MouseEvent) => void;\n /** Action Buttons that will render within the input. */\n actions?: ReactNode;\n /** Menu related props. @see MenuProps */\n menu?: MenuProps;\n /** A visual which represents the selected item. */\n visual?: ReactNode;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ComboBox.types.js","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ChangeEvent, ReactNode, Ref } from 'react';\n\nimport type { NoChildrenProp } from '../../types';\nimport { FormControlProps } from '../FormControl';\nimport { MenuItemProps, MenuProps } from '../Menu/Menu.types';\n\nexport interface Selected {\n id: string;\n text: string;\n}\n\nexport default interface ComboBoxProps extends NoChildrenProp {\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /** Pass a string or a fragment with an Icon and string. */\n label?: FormControlProps['label'];\n /** Visually hides the label region. */\n labelHidden?: FormControlProps['labelHidden'];\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Makes the component non editable and non clickable. The browser defaults to false. */\n readOnly?: FormControlProps['readOnly'];\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: FormControlProps['info'];\n /** Placeholder text */\n placeholder?: FormControlProps['placeholder'];\n /**\n * Whether it is single selection or multi selection combobox.\n * @default 'single-select'\n */\n mode?: 'single-select' | 'multi-select';\n /** Currently selected option, single for single-select, an array for multi-select. */\n selected?: {\n items?: Selected | Selected[];\n onRemove?: (id: MenuItemProps['id'], index: number) => void;\n onNew?: (text: string) => void;\n };\n /** Value of the combobox filtering input. */\n value?: FormControlProps['value'];\n /** Callback fired when the filtering input value changes. */\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n /** Callback fired when the ComboBox input gains focus. */\n onFocus?: (selected?: Selected | Selected[]) => void;\n /**\n * Callback fired when the ComboBox looses focus within its containing element.\n * This is not specific to the input element.\n * Note, behavior will be enhanced in an upcoming release and the input will be the only focusable element.\n */\n onBlur?: (selected?: Selected | Selected[]) => void;\n /** Callback fired when AI suggestion is accepted/rejected */\n onResolveSuggestion?: FormControlProps['onResolveSuggestion'];\n /** Automatically focuses the input on render. */\n autoFocus?: boolean;\n /**\n * Fired when the user clicks on the dropdown icon to initiate opening the menu.\n * If you want to offer default menu items without an input value, pass this function.\n * This function can be an appropriate time to fetch menu item data.\n * Remember to set the loading prop to true when when fetching data for an empty list.\n *\n * @param open value defining whether the click opens or closes the menu\n */\n onDropdownButtonClick?: (open: boolean) => void;\n /** Fired when user clicks on the Combobox input. */\n onClick?: (e: MouseEvent) => void;\n /** Action Buttons that will render within the input. */\n actions?: ReactNode;\n /** Menu related props. @see MenuProps */\n menu?: MenuProps;\n /** A visual which represents the selected item. */\n visual?: ReactNode;\n /** Reference to the element. */\n ref?: Ref<HTMLDivElement>;\n}\n"]}
|