@redsift/pickers 11.5.0 → 11.6.0-muiv5-alpha.0
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/_virtual/_rollupPluginBabelHelpers.js +93 -0
- package/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
- package/components/combobox/Combobox.d.ts +29 -0
- package/components/combobox/Combobox.js +151 -0
- package/components/combobox/Combobox.js.map +1 -0
- package/components/combobox/context.js +6 -0
- package/components/combobox/context.js.map +1 -0
- package/components/combobox/intl/en-US.json.js +13 -0
- package/components/combobox/intl/en-US.json.js.map +1 -0
- package/components/combobox/intl/fr-FR.json.js +13 -0
- package/components/combobox/intl/fr-FR.json.js.map +1 -0
- package/components/combobox/intl/index.js +10 -0
- package/components/combobox/intl/index.js.map +1 -0
- package/components/combobox/types.d.ts +107 -0
- package/components/combobox/types.js +22 -0
- package/components/combobox/types.js.map +1 -0
- package/components/combobox-content/ComboboxContent.d.ts +17 -0
- package/components/combobox-content/ComboboxContent.js +70 -0
- package/components/combobox-content/ComboboxContent.js.map +1 -0
- package/components/combobox-content/types.d.ts +11 -0
- package/components/combobox-content-footer/ComboboxContentFooter.d.ts +9 -0
- package/components/combobox-content-footer/ComboboxContentFooter.js +28 -0
- package/components/combobox-content-footer/ComboboxContentFooter.js.map +1 -0
- package/components/combobox-content-footer/styles.js +12 -0
- package/components/combobox-content-footer/styles.js.map +1 -0
- package/components/combobox-content-footer/types.d.ts +11 -0
- package/components/combobox-content-header/ComboboxContentHeader.d.ts +9 -0
- package/components/combobox-content-header/ComboboxContentHeader.js +28 -0
- package/components/combobox-content-header/ComboboxContentHeader.js.map +1 -0
- package/components/combobox-content-header/styles.js +12 -0
- package/components/combobox-content-header/styles.js.map +1 -0
- package/components/combobox-content-header/types.d.ts +11 -0
- package/components/combobox-content-listbox/ComboboxContentListbox.d.ts +9 -0
- package/components/combobox-content-listbox/ComboboxContentListbox.js +124 -0
- package/components/combobox-content-listbox/ComboboxContentListbox.js.map +1 -0
- package/components/combobox-content-listbox/types.d.ts +12 -0
- package/components/combobox-trigger/ComboboxTrigger.d.ts +9 -0
- package/components/combobox-trigger/ComboboxTrigger.js +352 -0
- package/components/combobox-trigger/ComboboxTrigger.js.map +1 -0
- package/components/combobox-trigger/types.d.ts +27 -0
- package/components/item/Item.d.ts +8 -0
- package/components/item/Item.js +137 -0
- package/components/item/Item.js.map +1 -0
- package/components/item/useMenuItem.js +69 -0
- package/components/item/useMenuItem.js.map +1 -0
- package/components/menu-button/MenuButton.d.ts +29 -0
- package/components/menu-button/MenuButton.js +76 -0
- package/components/menu-button/MenuButton.js.map +1 -0
- package/components/menu-button/context.js +6 -0
- package/components/menu-button/context.js.map +1 -0
- package/components/menu-button/types.d.ts +45 -0
- package/components/menu-button-content/MenuButtonContent.d.ts +17 -0
- package/components/menu-button-content/MenuButtonContent.js +68 -0
- package/components/menu-button-content/MenuButtonContent.js.map +1 -0
- package/components/menu-button-content/types.d.ts +9 -0
- package/components/menu-button-content-footer/MenuButtonContentFooter.d.ts +9 -0
- package/components/menu-button-content-footer/MenuButtonContentFooter.js +28 -0
- package/components/menu-button-content-footer/MenuButtonContentFooter.js.map +1 -0
- package/components/menu-button-content-footer/styles.js +12 -0
- package/components/menu-button-content-footer/styles.js.map +1 -0
- package/components/menu-button-content-footer/types.d.ts +11 -0
- package/components/menu-button-content-header/MenuButtonContentHeader.d.ts +9 -0
- package/components/menu-button-content-header/MenuButtonContentHeader.js +28 -0
- package/components/menu-button-content-header/MenuButtonContentHeader.js.map +1 -0
- package/components/menu-button-content-header/styles.js +12 -0
- package/components/menu-button-content-header/styles.js.map +1 -0
- package/components/menu-button-content-header/types.d.ts +11 -0
- package/components/menu-button-content-menu/MenuButtonContentMenu.d.ts +9 -0
- package/components/menu-button-content-menu/MenuButtonContentMenu.js +41 -0
- package/components/menu-button-content-menu/MenuButtonContentMenu.js.map +1 -0
- package/components/menu-button-content-menu/types.d.ts +9 -0
- package/components/menu-button-trigger/MenuButtonTrigger.d.ts +9 -0
- package/components/menu-button-trigger/MenuButtonTrigger.js +167 -0
- package/components/menu-button-trigger/MenuButtonTrigger.js.map +1 -0
- package/components/menu-button-trigger/types.d.ts +15 -0
- package/components/select/Select.d.ts +22 -0
- package/components/select/Select.js +116 -0
- package/components/select/Select.js.map +1 -0
- package/components/select/context.js +6 -0
- package/components/select/context.js.map +1 -0
- package/components/select/types.d.ts +61 -0
- package/components/select-content/SelectContent.d.ts +9 -0
- package/components/select-content/SelectContent.js +62 -0
- package/components/select-content/SelectContent.js.map +1 -0
- package/components/select-content/types.d.ts +9 -0
- package/components/select-trigger/SelectTrigger.d.ts +9 -0
- package/components/select-trigger/SelectTrigger.js +249 -0
- package/components/select-trigger/SelectTrigger.js.map +1 -0
- package/components/select-trigger/types.d.ts +17 -0
- package/index.d.ts +31 -438
- package/index.js +17 -1822
- package/index.js.map +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { StyledComboboxContentFooter } from './styles.js';
|
|
5
|
+
|
|
6
|
+
const _excluded = ["children", "className"];
|
|
7
|
+
const COMPONENT_NAME = 'ComboboxContentFooter';
|
|
8
|
+
const CLASSNAME = 'redsift-combobox-content-footer';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The ComboboxContentFooter component.
|
|
12
|
+
*/
|
|
13
|
+
const ComboboxContentFooter = /*#__PURE__*/forwardRef((props, ref) => {
|
|
14
|
+
const {
|
|
15
|
+
children,
|
|
16
|
+
className
|
|
17
|
+
} = props,
|
|
18
|
+
forwardedProps = _objectWithoutProperties(props, _excluded);
|
|
19
|
+
return /*#__PURE__*/React.createElement(StyledComboboxContentFooter, _extends({}, forwardedProps, {
|
|
20
|
+
className: classNames(ComboboxContentFooter.className, className),
|
|
21
|
+
ref: ref
|
|
22
|
+
}), children);
|
|
23
|
+
});
|
|
24
|
+
ComboboxContentFooter.className = CLASSNAME;
|
|
25
|
+
ComboboxContentFooter.displayName = COMPONENT_NAME;
|
|
26
|
+
|
|
27
|
+
export { ComboboxContentFooter };
|
|
28
|
+
//# sourceMappingURL=ComboboxContentFooter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComboboxContentFooter.js","sources":["../../../src/components/combobox-content-footer/ComboboxContentFooter.tsx"],"sourcesContent":["import React, { forwardRef, RefObject } from 'react';\nimport classNames from 'classnames';\n\nimport { StyledComboboxContentFooter } from './styles';\nimport { ComboboxContentFooterProps } from './types';\nimport { Comp } from '@redsift/design-system';\n\nconst COMPONENT_NAME = 'ComboboxContentFooter';\nconst CLASSNAME = 'redsift-combobox-content-footer';\n\n/**\n * The ComboboxContentFooter component.\n */\nexport const ComboboxContentFooter: Comp<ComboboxContentFooterProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { children, className, ...forwardedProps } = props;\n\n return (\n <StyledComboboxContentFooter\n {...forwardedProps}\n className={classNames(ComboboxContentFooter.className, className)}\n ref={ref as RefObject<HTMLDivElement>}\n >\n {children}\n </StyledComboboxContentFooter>\n );\n});\nComboboxContentFooter.className = CLASSNAME;\nComboboxContentFooter.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","ComboboxContentFooter","forwardRef","props","ref","children","className","forwardedProps","_objectWithoutProperties","_excluded","React","createElement","StyledComboboxContentFooter","_extends","classNames","displayName"],"mappings":";;;;;;AAOA,MAAMA,cAAc,GAAG,uBAAuB,CAAA;AAC9C,MAAMC,SAAS,GAAG,iCAAiC,CAAA;;AAEnD;AACA;AACA;AACO,MAAMC,qBAAuE,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EAChH,MAAM;MAAEC,QAAQ;AAAEC,MAAAA,SAAAA;AAA6B,KAAC,GAAGH,KAAK;AAAxBI,IAAAA,cAAc,GAAAC,wBAAA,CAAKL,KAAK,EAAAM,SAAA,CAAA,CAAA;EAExD,oBACEC,KAAA,CAAAC,aAAA,CAACC,2BAA2B,EAAAC,QAAA,KACtBN,cAAc,EAAA;IAClBD,SAAS,EAAEQ,UAAU,CAACb,qBAAqB,CAACK,SAAS,EAAEA,SAAS,CAAE;AAClEF,IAAAA,GAAG,EAAEA,GAAAA;AAAiC,GAAA,CAAA,EAErCC,QAC0B,CAAC,CAAA;AAElC,CAAC,EAAC;AACFJ,qBAAqB,CAACK,SAAS,GAAGN,SAAS,CAAA;AAC3CC,qBAAqB,CAACc,WAAW,GAAGhB,cAAc;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { baseContainer } from '@redsift/design-system';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Component style.
|
|
6
|
+
*/
|
|
7
|
+
const StyledComboboxContentFooter = styled.div`
|
|
8
|
+
${baseContainer}
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
export { StyledComboboxContentFooter };
|
|
12
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sources":["../../../src/components/combobox-content-footer/styles.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { StyledComboboxContentFooterProps } from './types';\nimport { baseContainer } from '@redsift/design-system';\n\n/**\n * Component style.\n */\nexport const StyledComboboxContentFooter = styled.div<StyledComboboxContentFooterProps>`\n ${baseContainer}\n`;\n"],"names":["StyledComboboxContentFooter","styled","div","baseContainer"],"mappings":";;;AAIA;AACA;AACA;AACaA,MAAAA,2BAA2B,GAAGC,MAAM,CAACC,GAAsC,CAAA;AACxF,EAAA,EAAIC,aAAc,CAAA;AAClB;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ContainerProps } from '@redsift/design-system';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Component props.
|
|
6
|
+
*/
|
|
7
|
+
interface ComboboxContentFooterProps extends ComponentProps<'div'>, ContainerProps {
|
|
8
|
+
}
|
|
9
|
+
type StyledComboboxContentFooterProps = ComboboxContentFooterProps & {};
|
|
10
|
+
|
|
11
|
+
export { ComboboxContentFooterProps, StyledComboboxContentFooterProps };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ComboboxContentHeaderProps } from './types.js';
|
|
2
|
+
import { Comp } from '@redsift/design-system';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The ComboboxContentHeader component.
|
|
6
|
+
*/
|
|
7
|
+
declare const ComboboxContentHeader: Comp<ComboboxContentHeaderProps, HTMLDivElement>;
|
|
8
|
+
|
|
9
|
+
export { ComboboxContentHeader };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { StyledComboboxContentHeader } from './styles.js';
|
|
5
|
+
|
|
6
|
+
const _excluded = ["children", "className"];
|
|
7
|
+
const COMPONENT_NAME = 'ComboboxContentHeader';
|
|
8
|
+
const CLASSNAME = 'redsift-combobox-content-header';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The ComboboxContentHeader component.
|
|
12
|
+
*/
|
|
13
|
+
const ComboboxContentHeader = /*#__PURE__*/forwardRef((props, ref) => {
|
|
14
|
+
const {
|
|
15
|
+
children,
|
|
16
|
+
className
|
|
17
|
+
} = props,
|
|
18
|
+
forwardedProps = _objectWithoutProperties(props, _excluded);
|
|
19
|
+
return /*#__PURE__*/React.createElement(StyledComboboxContentHeader, _extends({}, forwardedProps, {
|
|
20
|
+
className: classNames(ComboboxContentHeader.className, className),
|
|
21
|
+
ref: ref
|
|
22
|
+
}), children);
|
|
23
|
+
});
|
|
24
|
+
ComboboxContentHeader.className = CLASSNAME;
|
|
25
|
+
ComboboxContentHeader.displayName = COMPONENT_NAME;
|
|
26
|
+
|
|
27
|
+
export { ComboboxContentHeader };
|
|
28
|
+
//# sourceMappingURL=ComboboxContentHeader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComboboxContentHeader.js","sources":["../../../src/components/combobox-content-header/ComboboxContentHeader.tsx"],"sourcesContent":["import React, { forwardRef, RefObject } from 'react';\nimport classNames from 'classnames';\n\nimport { StyledComboboxContentHeader } from './styles';\nimport { ComboboxContentHeaderProps } from './types';\nimport { Comp } from '@redsift/design-system';\n\nconst COMPONENT_NAME = 'ComboboxContentHeader';\nconst CLASSNAME = 'redsift-combobox-content-header';\n\n/**\n * The ComboboxContentHeader component.\n */\nexport const ComboboxContentHeader: Comp<ComboboxContentHeaderProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { children, className, ...forwardedProps } = props;\n\n return (\n <StyledComboboxContentHeader\n {...forwardedProps}\n className={classNames(ComboboxContentHeader.className, className)}\n ref={ref as RefObject<HTMLDivElement>}\n >\n {children}\n </StyledComboboxContentHeader>\n );\n});\nComboboxContentHeader.className = CLASSNAME;\nComboboxContentHeader.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","ComboboxContentHeader","forwardRef","props","ref","children","className","forwardedProps","_objectWithoutProperties","_excluded","React","createElement","StyledComboboxContentHeader","_extends","classNames","displayName"],"mappings":";;;;;;AAOA,MAAMA,cAAc,GAAG,uBAAuB,CAAA;AAC9C,MAAMC,SAAS,GAAG,iCAAiC,CAAA;;AAEnD;AACA;AACA;AACO,MAAMC,qBAAuE,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EAChH,MAAM;MAAEC,QAAQ;AAAEC,MAAAA,SAAAA;AAA6B,KAAC,GAAGH,KAAK;AAAxBI,IAAAA,cAAc,GAAAC,wBAAA,CAAKL,KAAK,EAAAM,SAAA,CAAA,CAAA;EAExD,oBACEC,KAAA,CAAAC,aAAA,CAACC,2BAA2B,EAAAC,QAAA,KACtBN,cAAc,EAAA;IAClBD,SAAS,EAAEQ,UAAU,CAACb,qBAAqB,CAACK,SAAS,EAAEA,SAAS,CAAE;AAClEF,IAAAA,GAAG,EAAEA,GAAAA;AAAiC,GAAA,CAAA,EAErCC,QAC0B,CAAC,CAAA;AAElC,CAAC,EAAC;AACFJ,qBAAqB,CAACK,SAAS,GAAGN,SAAS,CAAA;AAC3CC,qBAAqB,CAACc,WAAW,GAAGhB,cAAc;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { baseContainer } from '@redsift/design-system';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Component style.
|
|
6
|
+
*/
|
|
7
|
+
const StyledComboboxContentHeader = styled.div`
|
|
8
|
+
${baseContainer}
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
export { StyledComboboxContentHeader };
|
|
12
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sources":["../../../src/components/combobox-content-header/styles.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { StyledComboboxContentHeaderProps } from './types';\nimport { baseContainer } from '@redsift/design-system';\n\n/**\n * Component style.\n */\nexport const StyledComboboxContentHeader = styled.div<StyledComboboxContentHeaderProps>`\n ${baseContainer}\n`;\n"],"names":["StyledComboboxContentHeader","styled","div","baseContainer"],"mappings":";;;AAIA;AACA;AACA;AACaA,MAAAA,2BAA2B,GAAGC,MAAM,CAACC,GAAsC,CAAA;AACxF,EAAA,EAAIC,aAAc,CAAA;AAClB;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ContainerProps } from '@redsift/design-system';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Component props.
|
|
6
|
+
*/
|
|
7
|
+
interface ComboboxContentHeaderProps extends ComponentProps<'div'>, ContainerProps {
|
|
8
|
+
}
|
|
9
|
+
type StyledComboboxContentHeaderProps = ComboboxContentHeaderProps & {};
|
|
10
|
+
|
|
11
|
+
export { ComboboxContentHeaderProps, StyledComboboxContentHeaderProps };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Comp } from '@redsift/design-system';
|
|
2
|
+
import { ComboboxContentListboxProps } from './types.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The ComboboxContentListbox component.
|
|
6
|
+
*/
|
|
7
|
+
declare const ComboboxContentListbox: Comp<ComboboxContentListboxProps, HTMLDivElement>;
|
|
8
|
+
|
|
9
|
+
export { ComboboxContentListbox };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import React, { forwardRef, useContext, useEffect } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { FocusWithinGroupContext, ListboxContext, isComponent, Item, useListboxItem, useTheme, Flexbox, StyledItem } from '@redsift/design-system';
|
|
5
|
+
import { ComboboxContext } from '../combobox/context.js';
|
|
6
|
+
import { ComboboxSelectionMode, ComboboxVariant } from '../combobox/types.js';
|
|
7
|
+
|
|
8
|
+
const _excluded = ["children", "className", "renderFreeTextItem"];
|
|
9
|
+
const COMPONENT_NAME = 'ComboboxContentListbox';
|
|
10
|
+
const CLASSNAME = 'redsift-combobox-content-listbox';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The ComboboxContentListbox component.
|
|
14
|
+
*/
|
|
15
|
+
const ComboboxContentListbox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
16
|
+
const {
|
|
17
|
+
children,
|
|
18
|
+
className,
|
|
19
|
+
renderFreeTextItem
|
|
20
|
+
} = props,
|
|
21
|
+
forwardedProps = _objectWithoutProperties(props, _excluded);
|
|
22
|
+
const focusContext = useContext(FocusWithinGroupContext);
|
|
23
|
+
const listboxState = useContext(ListboxContext);
|
|
24
|
+
const comboboxState = useContext(ComboboxContext);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (focusContext && focusContext.state.delayedAction && focusContext.state.tabStops.length) {
|
|
27
|
+
focusContext.dispatch(focusContext.state.delayedAction);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const canHaveMultipleSelections = (comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.selectionMode) === ComboboxSelectionMode.multiple;
|
|
31
|
+
const canHaveFreeText = (comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.variant) === ComboboxVariant.suggestions;
|
|
32
|
+
const cloneChildAndPush = (child, array) => {
|
|
33
|
+
if (!canHaveMultipleSelections || !canHaveFreeText || canHaveMultipleSelections && canHaveFreeText && !comboboxState.value.includes(child.props.value)) {
|
|
34
|
+
array.push( /*#__PURE__*/React.cloneElement(child, {
|
|
35
|
+
key: child.props.value,
|
|
36
|
+
hasCheckbox: canHaveMultipleSelections && !canHaveFreeText
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const renderedChildren = [];
|
|
41
|
+
if (Array.isArray(children)) {
|
|
42
|
+
for (const child of children) {
|
|
43
|
+
if (isComponent(Item)(child)) {
|
|
44
|
+
if (focusContext.state.maxOptionsLength) {
|
|
45
|
+
if (renderedChildren.length < focusContext.state.maxOptionsLength) {
|
|
46
|
+
if (!focusContext.state.filter) {
|
|
47
|
+
cloneChildAndPush(child, renderedChildren);
|
|
48
|
+
} else {
|
|
49
|
+
const {
|
|
50
|
+
value: filterValue,
|
|
51
|
+
type,
|
|
52
|
+
caseSensitive
|
|
53
|
+
} = focusContext.state.filter;
|
|
54
|
+
if (!filterValue) {
|
|
55
|
+
cloneChildAndPush(child, renderedChildren);
|
|
56
|
+
} else if (caseSensitive && (type === 'startsWith' && child.props.value.startsWith(filterValue) || type === 'contains' && child.props.value.includes(filterValue) || type === 'endsWith' && child.props.value.endsWith(filterValue))) {
|
|
57
|
+
cloneChildAndPush(child, renderedChildren);
|
|
58
|
+
} else if (!caseSensitive && (type === 'startsWith' && child.props.value.toLowerCase().startsWith(filterValue.toLowerCase()) || type === 'contains' && child.props.value.toLowerCase().includes(filterValue.toLowerCase()) || type === 'endsWith' && child.props.value.toLowerCase().endsWith(filterValue.toLowerCase()))) {
|
|
59
|
+
cloneChildAndPush(child, renderedChildren);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
cloneChildAndPush(child, renderedChildren);
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
renderedChildren.push(child);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const {
|
|
72
|
+
tabIndex,
|
|
73
|
+
isFocused,
|
|
74
|
+
isSelected,
|
|
75
|
+
isDisabled,
|
|
76
|
+
handleKeyDown,
|
|
77
|
+
handleClick
|
|
78
|
+
} = useListboxItem({
|
|
79
|
+
domElementRef: comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.freeTextItemRef,
|
|
80
|
+
value: (comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.inputValue) || '',
|
|
81
|
+
id: comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.freeTextItemId
|
|
82
|
+
});
|
|
83
|
+
const theme = useTheme();
|
|
84
|
+
const renderedFreeTextItem = comboboxState !== null && comboboxState !== void 0 && comboboxState.inputValue ? renderFreeTextItem && typeof renderFreeTextItem === 'function' ? renderFreeTextItem(comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.inputValue, comboboxState, listboxState) : comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.inputValue : null;
|
|
85
|
+
return /*#__PURE__*/React.createElement(Flexbox, _extends({
|
|
86
|
+
className: classNames(ComboboxContentListbox.className, className)
|
|
87
|
+
}, forwardedProps, {
|
|
88
|
+
ref: ref,
|
|
89
|
+
flexDirection: "column",
|
|
90
|
+
gap: "0px",
|
|
91
|
+
margin: "8px 0px",
|
|
92
|
+
style: {
|
|
93
|
+
outline: 'none'
|
|
94
|
+
},
|
|
95
|
+
width: "100%"
|
|
96
|
+
}), canHaveMultipleSelections && canHaveFreeText ? /*#__PURE__*/React.createElement(StyledItem, {
|
|
97
|
+
role: "option",
|
|
98
|
+
id: comboboxState.freeTextItemId,
|
|
99
|
+
$color: "primary",
|
|
100
|
+
$isActive: isSelected,
|
|
101
|
+
$isDisabled: isDisabled,
|
|
102
|
+
$isGradient: false,
|
|
103
|
+
$isHovered: isFocused,
|
|
104
|
+
$hasBorder: false,
|
|
105
|
+
$hasCheckbox: false,
|
|
106
|
+
$theme: theme,
|
|
107
|
+
"aria-selected": isSelected,
|
|
108
|
+
className: classNames(Item.className, className),
|
|
109
|
+
onClick: handleClick,
|
|
110
|
+
ref: comboboxState.freeTextItemRef,
|
|
111
|
+
onKeyDown: handleKeyDown,
|
|
112
|
+
tabIndex: tabIndex,
|
|
113
|
+
style: !comboboxState.inputValue ? {
|
|
114
|
+
height: '0',
|
|
115
|
+
visibility: 'hidden',
|
|
116
|
+
padding: '0'
|
|
117
|
+
} : undefined
|
|
118
|
+
}, renderedFreeTextItem) : null, Array.isArray(children) ? renderedChildren : children);
|
|
119
|
+
});
|
|
120
|
+
ComboboxContentListbox.className = CLASSNAME;
|
|
121
|
+
ComboboxContentListbox.displayName = COMPONENT_NAME;
|
|
122
|
+
|
|
123
|
+
export { ComboboxContentListbox };
|
|
124
|
+
//# sourceMappingURL=ComboboxContentListbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComboboxContentListbox.js","sources":["../../../src/components/combobox-content-listbox/ComboboxContentListbox.tsx"],"sourcesContent":["import React, { ReactNode, forwardRef, useContext, useEffect, RefObject, ReactElement } from 'react';\nimport classNames from 'classnames';\n\nimport {\n Comp,\n Flexbox,\n FocusWithinGroupContext,\n Item,\n ListboxContext,\n StyledItem,\n isComponent,\n useListboxItem,\n useTheme,\n} from '@redsift/design-system';\nimport { ComboboxContentListboxProps } from './types';\nimport { ComboboxContext } from '../combobox/context';\nimport { ComboboxSelectionMode, ComboboxVariant } from '../combobox/types';\n\nconst COMPONENT_NAME = 'ComboboxContentListbox';\nconst CLASSNAME = 'redsift-combobox-content-listbox';\n\n/**\n * The ComboboxContentListbox component.\n */\nexport const ComboboxContentListbox: Comp<ComboboxContentListboxProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { children, className, renderFreeTextItem, ...forwardedProps } = props;\n\n const focusContext = useContext(FocusWithinGroupContext);\n const listboxState = useContext(ListboxContext);\n const comboboxState = useContext(ComboboxContext);\n\n useEffect(() => {\n if (focusContext && focusContext.state.delayedAction && focusContext.state.tabStops.length) {\n focusContext.dispatch(focusContext.state.delayedAction);\n }\n });\n\n const canHaveMultipleSelections = comboboxState?.selectionMode === ComboboxSelectionMode.multiple;\n const canHaveFreeText = comboboxState?.variant === ComboboxVariant.suggestions;\n\n const cloneChildAndPush = (child: ReactElement, array: Array<ReactNode>) => {\n if (\n !canHaveMultipleSelections ||\n !canHaveFreeText ||\n (canHaveMultipleSelections && canHaveFreeText && !(comboboxState.value as string[]).includes(child.props.value))\n ) {\n array.push(\n React.cloneElement(child, {\n key: child.props.value,\n hasCheckbox: canHaveMultipleSelections && !canHaveFreeText,\n })\n );\n }\n };\n const renderedChildren: Array<ReactNode> = [];\n if (Array.isArray(children)) {\n for (const child of children) {\n if (isComponent(Item)(child)) {\n if (focusContext.state.maxOptionsLength) {\n if (renderedChildren.length < focusContext.state.maxOptionsLength) {\n if (!focusContext.state.filter) {\n cloneChildAndPush(child, renderedChildren);\n } else {\n const { value: filterValue, type, caseSensitive } = focusContext.state.filter;\n\n if (!filterValue) {\n cloneChildAndPush(child, renderedChildren);\n } else if (\n caseSensitive &&\n ((type === 'startsWith' && child.props.value!.startsWith(filterValue)) ||\n (type === 'contains' && child.props.value!.includes(filterValue)) ||\n (type === 'endsWith' && child.props.value!.endsWith(filterValue)))\n ) {\n cloneChildAndPush(child, renderedChildren);\n } else if (\n !caseSensitive &&\n ((type === 'startsWith' && child.props.value!.toLowerCase().startsWith(filterValue.toLowerCase())) ||\n (type === 'contains' && child.props.value!.toLowerCase().includes(filterValue.toLowerCase())) ||\n (type === 'endsWith' && child.props.value!.toLowerCase().endsWith(filterValue.toLowerCase())))\n ) {\n cloneChildAndPush(child, renderedChildren);\n }\n }\n }\n } else {\n cloneChildAndPush(child, renderedChildren);\n }\n } else {\n renderedChildren.push(child);\n }\n }\n }\n\n const { tabIndex, isFocused, isSelected, isDisabled, handleKeyDown, handleClick } = useListboxItem({\n domElementRef: comboboxState?.freeTextItemRef as RefObject<Element>,\n value: comboboxState?.inputValue || '',\n id: comboboxState?.freeTextItemId,\n });\n const theme = useTheme();\n\n const renderedFreeTextItem = comboboxState?.inputValue\n ? renderFreeTextItem && typeof renderFreeTextItem === 'function'\n ? renderFreeTextItem(comboboxState?.inputValue, comboboxState, listboxState)\n : comboboxState?.inputValue\n : null;\n\n return (\n <Flexbox\n className={classNames(ComboboxContentListbox.className, className)}\n {...forwardedProps}\n ref={ref}\n flexDirection=\"column\"\n gap=\"0px\"\n margin=\"8px 0px\"\n style={{ outline: 'none' }}\n width=\"100%\"\n >\n {canHaveMultipleSelections && canHaveFreeText ? (\n <StyledItem\n role=\"option\"\n id={comboboxState.freeTextItemId}\n $color=\"primary\"\n $isActive={isSelected}\n $isDisabled={isDisabled}\n $isGradient={false}\n $isHovered={isFocused}\n $hasBorder={false}\n $hasCheckbox={false}\n $theme={theme}\n aria-selected={isSelected}\n className={classNames(Item.className, className)}\n onClick={handleClick}\n ref={comboboxState.freeTextItemRef as RefObject<HTMLDivElement>}\n onKeyDown={handleKeyDown}\n tabIndex={tabIndex}\n style={\n !comboboxState.inputValue\n ? {\n height: '0',\n visibility: 'hidden',\n padding: '0',\n }\n : undefined\n }\n >\n {renderedFreeTextItem}\n </StyledItem>\n ) : null}\n {Array.isArray(children) ? renderedChildren : children}\n </Flexbox>\n );\n});\nComboboxContentListbox.className = CLASSNAME;\nComboboxContentListbox.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","ComboboxContentListbox","forwardRef","props","ref","children","className","renderFreeTextItem","forwardedProps","_objectWithoutProperties","_excluded","focusContext","useContext","FocusWithinGroupContext","listboxState","ListboxContext","comboboxState","ComboboxContext","useEffect","state","delayedAction","tabStops","length","dispatch","canHaveMultipleSelections","selectionMode","ComboboxSelectionMode","multiple","canHaveFreeText","variant","ComboboxVariant","suggestions","cloneChildAndPush","child","array","value","includes","push","React","cloneElement","key","hasCheckbox","renderedChildren","Array","isArray","isComponent","Item","maxOptionsLength","filter","filterValue","type","caseSensitive","startsWith","endsWith","toLowerCase","tabIndex","isFocused","isSelected","isDisabled","handleKeyDown","handleClick","useListboxItem","domElementRef","freeTextItemRef","inputValue","id","freeTextItemId","theme","useTheme","renderedFreeTextItem","createElement","Flexbox","_extends","classNames","flexDirection","gap","margin","style","outline","width","StyledItem","role","$color","$isActive","$isDisabled","$isGradient","$isHovered","$hasBorder","$hasCheckbox","$theme","onClick","onKeyDown","height","visibility","padding","undefined","displayName"],"mappings":";;;;;;;;AAkBA,MAAMA,cAAc,GAAG,wBAAwB,CAAA;AAC/C,MAAMC,SAAS,GAAG,kCAAkC,CAAA;;AAEpD;AACA;AACA;AACO,MAAMC,sBAAyE,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EAClH,MAAM;MAAEC,QAAQ;MAAEC,SAAS;AAAEC,MAAAA,kBAAAA;AAAsC,KAAC,GAAGJ,KAAK;AAAxBK,IAAAA,cAAc,GAAAC,wBAAA,CAAKN,KAAK,EAAAO,SAAA,CAAA,CAAA;AAE5E,EAAA,MAAMC,YAAY,GAAGC,UAAU,CAACC,uBAAuB,CAAC,CAAA;AACxD,EAAA,MAAMC,YAAY,GAAGF,UAAU,CAACG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;IAC1BnD,SAAS,EAAEmE,UAAU,CAAC3B,IAAI,CAACxC,SAAS,EAAEA,SAAS,CAAE;AACjDoF,IAAAA,OAAO,EAAE9B,WAAY;IACrBxD,GAAG,EAAEY,aAAa,CAAC+C,eAA6C;AAChE4B,IAAAA,SAAS,EAAEhC,aAAc;AACzBJ,IAAAA,QAAQ,EAAEA,QAAS;AACnBsB,IAAAA,KAAK,EACH,CAAC7D,aAAa,CAACgD,UAAU,GACrB;AACE4B,MAAAA,MAAM,EAAE,GAAG;AACXC,MAAAA,UAAU,EAAE,QAAQ;AACpBC,MAAAA,OAAO,EAAE,GAAA;AACX,KAAC,GACDC,SAAAA;AACL,GAAA,EAEA1B,oBACS,CAAC,GACX,IAAI,EACP1B,KAAK,CAACC,OAAO,CAACvC,QAAQ,CAAC,GAAGqC,gBAAgB,GAAGrC,QACvC,CAAC,CAAA;AAEd,CAAC,EAAC;AACFJ,sBAAsB,CAACK,SAAS,GAAGN,SAAS,CAAA;AAC5CC,sBAAsB,CAAC+F,WAAW,GAAGjG,cAAc;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { FlexboxProps, ListboxContextProps } from '@redsift/design-system';
|
|
3
|
+
import { ComboboxState } from '../combobox/types.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Component props.
|
|
7
|
+
*/
|
|
8
|
+
interface ComboboxContentListboxProps extends FlexboxProps {
|
|
9
|
+
renderFreeTextItem?: ReactNode | ((value?: string, comboboxState?: ComboboxState | null, listboxState?: ListboxContextProps) => ReactNode);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { ComboboxContentListboxProps };
|