@contentful/f36-autocomplete 4.10.2 → 4.10.5
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/CHANGELOG.md +44 -0
- package/README.mdx +10 -0
- package/dist/main.js +2 -1
- package/dist/main.js.map +1 -1
- package/dist/module.js +2 -1
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.10.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`32cac8e8`](https://github.com/contentful/forma-36/commit/32cac8e8bdeedfe29b36bc6025eec11607c93da8)]:
|
|
8
|
+
- @contentful/f36-icons@4.10.5
|
|
9
|
+
- @contentful/f36-popover@4.10.5
|
|
10
|
+
- @contentful/f36-button@4.10.5
|
|
11
|
+
- @contentful/f36-forms@4.10.5
|
|
12
|
+
- @contentful/f36-skeleton@4.10.5
|
|
13
|
+
- @contentful/f36-typography@4.10.5
|
|
14
|
+
- @contentful/f36-utils@4.10.5
|
|
15
|
+
- @contentful/f36-core@4.10.5
|
|
16
|
+
|
|
17
|
+
## 4.10.4
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- [#2093](https://github.com/contentful/forma-36/pull/2093) [`52cce145`](https://github.com/contentful/forma-36/commit/52cce145fa2d7d2a4d9a7ff9591beca862317799) Thanks [@Lelith](https://github.com/Lelith)! - Enable controlling the dropdown menu open and close state after select with new property "closeAfterSelect"
|
|
22
|
+
|
|
23
|
+
- Updated dependencies []:
|
|
24
|
+
- @contentful/f36-button@4.10.4
|
|
25
|
+
- @contentful/f36-forms@4.10.4
|
|
26
|
+
- @contentful/f36-icons@4.10.4
|
|
27
|
+
- @contentful/f36-popover@4.10.4
|
|
28
|
+
- @contentful/f36-skeleton@4.10.4
|
|
29
|
+
- @contentful/f36-typography@4.10.4
|
|
30
|
+
- @contentful/f36-utils@4.10.4
|
|
31
|
+
- @contentful/f36-core@4.10.4
|
|
32
|
+
|
|
33
|
+
## 4.10.3
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Updated dependencies [[`1bc834c6`](https://github.com/contentful/forma-36/commit/1bc834c65097e5b253b7bc69a96a16121b4e7cc4)]:
|
|
38
|
+
- @contentful/f36-popover@4.10.3
|
|
39
|
+
- @contentful/f36-button@4.10.3
|
|
40
|
+
- @contentful/f36-forms@4.10.3
|
|
41
|
+
- @contentful/f36-icons@4.10.3
|
|
42
|
+
- @contentful/f36-skeleton@4.10.3
|
|
43
|
+
- @contentful/f36-typography@4.10.3
|
|
44
|
+
- @contentful/f36-utils@4.10.3
|
|
45
|
+
- @contentful/f36-core@4.10.3
|
|
46
|
+
|
|
3
47
|
## 4.10.2
|
|
4
48
|
|
|
5
49
|
### Patch Changes
|
package/README.mdx
CHANGED
|
@@ -59,6 +59,8 @@ This is possible by using the `renderItem` prop and the `getStringMatch` utility
|
|
|
59
59
|
|
|
60
60
|
### Selecting multiple items
|
|
61
61
|
|
|
62
|
+
It is also possible to use the Autocomplete as multiselect. To improve the user experience, you can keep the dropdown open after selection by setting the "closeAfterSelect" property to false.
|
|
63
|
+
|
|
62
64
|
```jsx file=./examples/AutocompleteMultiSelectionExample.tsx
|
|
63
65
|
|
|
64
66
|
```
|
|
@@ -74,6 +76,14 @@ Besides the correct shape of the object the Autocomplete component needs to rece
|
|
|
74
76
|
|
|
75
77
|
```
|
|
76
78
|
|
|
79
|
+
### Fully controlled selection from outside
|
|
80
|
+
|
|
81
|
+
In order to use proper form validation you need to be able to control the actual input field from the autocomplete, because the search query value is not the actual selection. This is done via the selectedItem property.
|
|
82
|
+
|
|
83
|
+
```jsx file=./examples/ControlledAutocomplete.tsx
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
|
|
77
87
|
### Error validation with FormControl
|
|
78
88
|
|
|
79
89
|
```jsx file=./examples/AutocompleteWithErrorValidationExample.tsx
|
package/dist/main.js
CHANGED
|
@@ -136,7 +136,7 @@ $26b30f0765231b47$var$HighlightedItem.displayName = 'HighlightedItem';
|
|
|
136
136
|
|
|
137
137
|
|
|
138
138
|
function $56e6e764f18116b7$var$_Autocomplete(props, ref) {
|
|
139
|
-
const { id: id , className: className , clearAfterSelect: clearAfterSelect = false , defaultValue: defaultValue = '' , selectedItem: selectedItem1 , items: items , onInputValueChange: onInputValueChange , onSelectItem: onSelectItem , renderItem: renderItem , itemToString: itemToString = (item)=>item
|
|
139
|
+
const { id: id , className: className , clearAfterSelect: clearAfterSelect = false , closeAfterSelect: closeAfterSelect = true , defaultValue: defaultValue = '' , selectedItem: selectedItem1 , items: items , onInputValueChange: onInputValueChange , onSelectItem: onSelectItem , renderItem: renderItem , itemToString: itemToString = (item)=>item
|
|
140
140
|
, isInvalid: isInvalid , isDisabled: isDisabled , isRequired: isRequired , isReadOnly: isReadOnly , noMatchesMessage: noMatchesMessage = 'No matches found' , placeholder: placeholder = 'Search' , inputRef: inputRef , toggleRef: toggleRef , listRef: listRef , listWidth: listWidth = 'auto' , listMaxHeight: listMaxHeight = 180 , isGrouped: isGrouped = false , isLoading: isLoading = false , usePortal: usePortal = false , testId: testId = 'cf-autocomplete' } = props;
|
|
141
141
|
const styles = $e938248654439d1d$export$71b73d9f7d678746(listMaxHeight);
|
|
142
142
|
const [inputValue1, setInputValue] = $hVoOH$react.useState(defaultValue);
|
|
@@ -173,6 +173,7 @@ function $56e6e764f18116b7$var$_Autocomplete(props, ref) {
|
|
|
173
173
|
case $hVoOH$downshift.useCombobox.stateChangeTypes.ItemClick:
|
|
174
174
|
if (selectedItem) onSelectItem(selectedItem);
|
|
175
175
|
if (clearAfterSelect) handleInputValueChange('');
|
|
176
|
+
if (!closeAfterSelect) toggleMenu();
|
|
176
177
|
break;
|
|
177
178
|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IvB,KAAK,CAACrD,OAAN,CAAcwD,MAAnC,CAAAoB;QACA,OAAOa,MAAP,CAAA;KAzBF,CAFF,EA8BC,CAAC/D,SAAD,IACC,CAACwB,mCAAa,CAAC9C,SAAD,EAAYD,KAAZ,CADf,IAECA,KAAK,CAACqD,MAAN,GAAe,CAFhB,kBAGG,qDAAC,yCAAiB;QAChB,KAAA,EAAOrD,KAAD;QACN,iBAAA,EAAmByE,iBAAD;QAClB,gBAAA,EAAkBd,gBAAD;QACjB,YAAA,EAAcH,YAAD;QACb,UAAA,EAAYjD,UAAD;QACX,UAAA,EAAYC,WAAD;MATjB,CAYV,CACA,CAlIE,CAmIF;CAEC;AAED,MAAM+E,0CAAoB,GAAG,IAAM;IACjC,qBACE,qDAAC,8CAAD;QAAmB,SAAA,EAAW,EAAD;qBAC3B,qDAAC,6CAAD;QAAkB,aAAA,EAAe,CAAD;MAAtC,CAFE,CAGF;CAJA,A,EAQA,kFAFC;AAGD,SAASxC,mCAAa,CACpB9C,SADF,EAEED,KAFF,EAGyC;IACvC,OAAOC,SAAP,CAAA;CACD;AAOM,MAAM3B,yCAAY,iBAAGE,sCAAK,CAACgH,UAAN,CAAiB/D,mCAAjB,CAAA,AAArB,AACsC;;AD1Y7C","sources":["packages/components/autocomplete/src/index.ts","packages/components/autocomplete/src/Autocomplete.tsx","packages/components/autocomplete/src/AutocompleteItems.tsx","packages/components/autocomplete/src/Autocomplete.styles.ts"],"sourcesContent":["export { Autocomplete } from './Autocomplete';\nexport type { AutocompleteProps } from './Autocomplete';\n","import React, { useCallback, useState } from 'react';\nimport { cx } from 'emotion';\nimport { useCombobox } from 'downshift';\n\nimport { mergeRefs } from '@contentful/f36-core';\nimport type { CommonProps, ExpandProps } from '@contentful/f36-core';\nimport { IconButton } from '@contentful/f36-button';\nimport { TextInput } from '@contentful/f36-forms';\nimport type { TextInputProps } from '@contentful/f36-forms';\nimport { CloseIcon, ChevronDownIcon } from '@contentful/f36-icons';\nimport { SkeletonContainer, SkeletonBodyText } from '@contentful/f36-skeleton';\nimport { Popover } from '@contentful/f36-popover';\nimport { Subheading, SectionHeading } from '@contentful/f36-typography';\n\nimport { AutocompleteItems } from './AutocompleteItems';\nimport { getAutocompleteStyles } from './Autocomplete.styles';\n\nexport interface GenericGroupType<ItemType> {\n groupTitle: string;\n options: ItemType[];\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface AutocompleteProps<ItemType>\n extends CommonProps,\n Pick<\n TextInputProps,\n | 'isDisabled'\n | 'isInvalid'\n | 'isReadOnly'\n | 'isRequired'\n | 'id'\n | 'defaultValue'\n > {\n /**\n * It’s an array of data to be used as \"options\" by the autocomplete component.\n * This can either be a plain list of items or a list of groups of items.\n */\n items: ItemType[] | GenericGroupType<ItemType>[];\n\n /**\n * Tells if the item is a object with groups\n */\n isGrouped?: boolean;\n\n /**\n * Function called whenever the input value changes\n */\n onInputValueChange?: (value: string) => void;\n /**\n * This is the function that will be called when the user selects one of the \"options\" in the list.\n * The component will pass the selected \"item\" as an argument to the function..\n */\n onSelectItem: (item: ItemType) => void;\n\n /**\n * Applying the selectedItem property turns autocomplete into a controlled component.\n * Can be used to display e.g. previously selected element. If it is an object the itemToString function will apply to it.\n */\n selectedItem?: ItemType;\n\n /**\n * This is the function that will be called for each \"item\" passed in the `items` prop.\n * It receives the \"item\" and \"inputValue\" as arguments and returns a ReactNode.\n * The inputValue is passed in case you want to highlight the match on the render.\n */\n renderItem?: (item: ItemType, inputValue: string) => React.ReactNode;\n /**\n * When using objects as `items`, we recommend passing a function that tells Downshift how to extract a string\n * from those objetcs to be used as inputValue\n */\n itemToString?: (item: ItemType) => string;\n /**\n * If this is set to `true` the text input will be cleared after an item is selected\n * @default false\n */\n clearAfterSelect?: boolean;\n /**\n * This is the value will be passed to the `placeholder` prop of the input.\n * @default \"Search\"\n */\n placeholder?: string;\n /**\n * A message that will be shown when it is not possible to find any option that matches the input value\n * @default \"No matches\"\n */\n noMatchesMessage?: string;\n /**\n * Use this prop to get a ref to the input element of the component\n */\n inputRef?: React.Ref<HTMLInputElement>;\n /**\n * Use this prop to get a ref to the toggle button of the component\n */\n toggleRef?: React.Ref<HTMLButtonElement>;\n /**\n * Use this prop to get a ref to the list of items of the component\n */\n listRef?: React.Ref<HTMLUListElement>;\n /**\n * It sets the width of the list\n * @default \"auto\"\n */\n listWidth?: 'auto' | 'full';\n /**\n * It sets the max-height, in pixels, of the list\n * The default value is the height of 5 single line items\n * @default 180\n */\n listMaxHeight?: number;\n /**\n * Sets the list to show its loading state\n * @default false\n */\n isLoading?: boolean;\n /**\n * Boolean to control whether or not to render the suggestions box in a React Portal.\n * Rendering content inside a Portal allows the suggestions box to escape the bounds\n * of its parent while still being positioned correctly.\n * Defaults to `false`\n */\n usePortal?: boolean;\n}\n\nfunction _Autocomplete<ItemType>(\n props: AutocompleteProps<ItemType>,\n ref: React.Ref<HTMLDivElement>,\n) {\n const {\n id,\n className,\n clearAfterSelect = false,\n defaultValue = '',\n selectedItem,\n items,\n onInputValueChange,\n onSelectItem,\n renderItem,\n itemToString = (item: ItemType) => (item as unknown) as string,\n isInvalid,\n isDisabled,\n isRequired,\n isReadOnly,\n noMatchesMessage = 'No matches found',\n placeholder = 'Search',\n inputRef,\n toggleRef,\n listRef,\n listWidth = 'auto',\n listMaxHeight = 180,\n isGrouped = false,\n isLoading = false,\n usePortal = false,\n testId = 'cf-autocomplete',\n } = props;\n\n type GroupType = GenericGroupType<ItemType>;\n\n const styles = getAutocompleteStyles(listMaxHeight);\n\n const [inputValue, setInputValue] = useState(defaultValue);\n\n const handleInputValueChange = useCallback(\n (value: string) => {\n setInputValue(value);\n\n onInputValueChange?.(value);\n },\n [onInputValueChange],\n );\n\n // Handle manually to avoid a jumping cursor, see https://github.com/downshift-js/downshift/issues/1108#issuecomment-842407759\n const handleNativeChangeEvent = useCallback(\n (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n const value = event.target.value;\n handleInputValueChange(value);\n },\n [handleInputValueChange],\n );\n\n const flattenItems = isUsingGroups(isGrouped, items)\n ? items.reduce(\n (acc: ItemType[], group: GroupType) => [...acc, ...group.options],\n [],\n )\n : items;\n\n const isShowingNoMatches = isUsingGroups(isGrouped, items)\n ? items.every((group: GroupType) => group.options.length === 0)\n : items.length === 0;\n\n const {\n getComboboxProps,\n getInputProps,\n getItemProps,\n getMenuProps,\n getToggleButtonProps,\n highlightedIndex,\n isOpen,\n toggleMenu,\n } = useCombobox({\n items: flattenItems,\n selectedItem,\n inputValue,\n itemToString,\n onInputValueChange: ({ type, inputValue }) => {\n if (type !== '__input_change__') {\n handleInputValueChange(inputValue);\n }\n },\n onStateChange: ({ type, selectedItem }) => {\n switch (type) {\n case useCombobox.stateChangeTypes.InputKeyDownEnter:\n case useCombobox.stateChangeTypes.ItemClick:\n if (selectedItem) {\n onSelectItem(selectedItem);\n }\n if (clearAfterSelect) {\n handleInputValueChange('');\n }\n break;\n default:\n break;\n }\n },\n });\n\n const {\n 'aria-labelledby': _labelledby,\n id: _inputId,\n ...inputProps\n } = getInputProps();\n const comboboxProps = getComboboxProps();\n const toggleProps = getToggleButtonProps();\n const menuProps = getMenuProps();\n let elementStartIndex = 0;\n\n return (\n <div\n data-test-id={testId}\n className={cx(styles.autocomplete, className)}\n ref={ref}\n >\n <Popover\n usePortal={usePortal}\n isOpen={isOpen}\n isFullWidth={listWidth === 'full'}\n renderOnlyWhenOpen={false}\n // This is necessary, otherwise the focus will change from the input to the Popover\n // and the user won't be able to type in the input\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={false}\n id={menuProps.id}\n >\n <Popover.Trigger>\n <div {...comboboxProps} className={styles.combobox}>\n <TextInput\n className={styles.inputField}\n {...inputProps}\n onFocus={() => {\n if (!isOpen) {\n toggleMenu();\n }\n }}\n id={id}\n isInvalid={isInvalid}\n isDisabled={isDisabled}\n isRequired={isRequired}\n isReadOnly={isReadOnly}\n ref={mergeRefs(inputProps.ref, inputRef)}\n testId=\"cf-autocomplete-input\"\n placeholder={placeholder}\n onChange={(event) => {\n inputProps.onChange(event);\n handleNativeChangeEvent(event);\n }}\n />\n <IconButton\n {...toggleProps}\n ref={mergeRefs(toggleProps.ref, toggleRef)}\n aria-label=\"toggle menu\"\n className={styles.toggleButton}\n variant=\"transparent\"\n icon={\n inputValue ? (\n <CloseIcon aria-label=\"Clear\" variant=\"muted\" />\n ) : (\n <ChevronDownIcon aria-label=\"Show list\" variant=\"muted\" />\n )\n }\n onClick={() => {\n if (inputValue) {\n handleInputValueChange('');\n } else {\n toggleMenu();\n }\n }}\n isDisabled={isDisabled}\n size=\"small\"\n />\n </div>\n </Popover.Trigger>\n\n <Popover.Content\n {...menuProps}\n ref={mergeRefs(menuProps.ref, listRef)}\n className={styles.content}\n testId=\"cf-autocomplete-container\"\n >\n {isLoading &&\n [...Array(3)].map((_, index) => (\n <div key={index} className={cx(styles.item, styles.disabled)}>\n <ListItemLoadingState />\n </div>\n ))}\n\n {!isLoading && isShowingNoMatches && (\n <div className={styles.item}>\n <Subheading className={styles.noMatchesTitle}>\n {noMatchesMessage}\n </Subheading>\n </div>\n )}\n\n {!isLoading &&\n isUsingGroups(isGrouped, items) &&\n items.map((group: GroupType, index: number) => {\n if (group.options.length < 1) {\n return;\n }\n const render = (\n <div key={index}>\n <SectionHeading\n key={index}\n data-test-id=\"cf-autocomplete-grouptitle\"\n marginBottom=\"none\"\n className={styles.groupTitle}\n >\n {group.groupTitle}\n </SectionHeading>\n <AutocompleteItems<ItemType>\n items={group.options}\n highlightedIndex={highlightedIndex}\n getItemProps={getItemProps}\n renderItem={renderItem}\n inputValue={inputValue}\n elementStartIndex={elementStartIndex}\n />\n </div>\n );\n elementStartIndex += group.options.length;\n return render;\n })}\n\n {!isLoading &&\n !isUsingGroups(isGrouped, items) &&\n items.length > 0 && (\n <AutocompleteItems<ItemType>\n items={items}\n elementStartIndex={elementStartIndex}\n highlightedIndex={highlightedIndex}\n getItemProps={getItemProps}\n renderItem={renderItem}\n inputValue={inputValue}\n />\n )}\n </Popover.Content>\n </Popover>\n </div>\n );\n}\n\nconst ListItemLoadingState = () => {\n return (\n <SkeletonContainer svgHeight={16}>\n <SkeletonBodyText numberOfLines={1} />\n </SkeletonContainer>\n );\n};\n\n// This is required to infer correct typings when differentiating groups and items\nfunction isUsingGroups<ItemType>(\n isGrouped: boolean,\n items: ItemType[] | GenericGroupType<ItemType>[],\n): items is GenericGroupType<ItemType>[] {\n return isGrouped;\n}\n\n/**\n * The Autocomplete is a component that will show a `TextInput` where a user can type any word which will be used\n * to filter a list of items. That list of filtered items will be shown to the user as possible options for the input.\n * Once one of the options is selected, that option becomes the value of the `TextInput`.\n */\nexport const Autocomplete = React.forwardRef(_Autocomplete) as <T>(\n props: ExpandProps<AutocompleteProps<T>> & {\n ref?: React.Ref<HTMLDivElement>;\n },\n) => ReturnType<typeof _Autocomplete>;\n","import React, { HTMLAttributes } from 'react';\nimport { cx } from 'emotion';\n\nimport { getStringMatch } from '@contentful/f36-utils';\nimport { Text } from '@contentful/f36-typography';\nimport { getAutocompleteStyles } from './Autocomplete.styles';\nimport type { UseComboboxGetItemPropsOptions } from 'downshift';\n\ninterface AutocompleteItemsProps<ItemType> {\n items: ItemType[];\n elementStartIndex: number;\n highlightedIndex: number;\n getItemProps: (\n options: UseComboboxGetItemPropsOptions<ItemType>,\n ) => HTMLAttributes<HTMLLIElement>;\n renderItem: (item: ItemType, inputValue: string) => React.ReactNode;\n inputValue: string;\n listMaxHeight?: number;\n}\n\nexport const AutocompleteItems = <ItemType,>(\n props: AutocompleteItemsProps<ItemType>,\n) => {\n const {\n items,\n elementStartIndex,\n highlightedIndex,\n getItemProps,\n renderItem,\n inputValue,\n listMaxHeight = 180,\n } = props;\n\n const styles = getAutocompleteStyles(listMaxHeight);\n\n return (\n <ul className={styles.list} data-test-id=\"cf-autocomplete-list\">\n {items.map((item: ItemType, index: number) => {\n const itemIndex = elementStartIndex + index;\n const itemProps = getItemProps({ item, index: itemIndex });\n return (\n <Text\n {...itemProps}\n as=\"li\"\n key={itemIndex}\n className={cx([\n styles.item,\n highlightedIndex === itemIndex && styles.highlighted,\n ])}\n data-test-id={`cf-autocomplete-list-item-${itemIndex}`}\n >\n {renderItem ? (\n renderItem(item, inputValue)\n ) : typeof item === 'string' ? (\n <HighlightedItem item={item} inputValue={inputValue} />\n ) : (\n item\n )}\n </Text>\n );\n })}\n </ul>\n );\n};\n\nAutocompleteItems.displayName = 'AutocompleteItems';\n\nfunction HighlightedItem({\n item,\n inputValue,\n}: {\n item: string;\n inputValue: string;\n}) {\n const { before, match, after } = getStringMatch(item, inputValue);\n\n return (\n <>\n {before}\n <b>{match}</b>\n {after}\n </>\n );\n}\n\nHighlightedItem.displayName = 'HighlightedItem';\n","import { css } from 'emotion';\nimport tokens from '@contentful/f36-tokens';\n\nexport const getAutocompleteStyles = (listMaxHeight: number) => ({\n autocomplete: css({\n position: 'relative',\n width: '100%',\n }),\n combobox: css({\n position: 'relative',\n }),\n inputField: css({\n paddingRight: tokens.spacingXl,\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n }),\n toggleButton: css({\n position: 'absolute',\n top: '1px',\n right: '1px',\n zIndex: 1,\n padding: tokens.spacing2Xs,\n height: '38px',\n }),\n content: css({\n overflow: 'auto',\n maxHeight: `${listMaxHeight}px`,\n }),\n list: css({\n listStyle: 'none',\n padding: `${tokens.spacingXs} 0`,\n margin: 0,\n }),\n groupTitle: css({\n padding: `${tokens.spacingXs} ${tokens.spacingM}`,\n lineHeight: tokens.lineHeightM,\n }),\n noMatchesTitle: css({\n color: tokens.gray500,\n margin: `${tokens.spacingM} 0 ${tokens.spacingM} 0`,\n }),\n item: css({\n display: 'block',\n padding: `${tokens.spacingXs} ${tokens.spacingM}`,\n wordBreak: 'break-word',\n whiteSpace: 'break-spaces',\n cursor: 'pointer',\n hyphens: 'auto',\n\n '&:focus, &:hover': {\n backgroundColor: tokens.gray100,\n },\n '&:active': {\n backgroundColor: tokens.gray200,\n },\n }),\n disabled: css({\n opacity: 0.5,\n pointerEvents: 'none',\n }),\n highlighted: css({\n backgroundColor: tokens.gray100,\n }),\n});\n"],"names":["Autocomplete","AutocompleteProps","React","useCallback","useState","useCombobox","mergeRefs","CommonProps","ExpandProps","IconButton","TextInput","TextInputProps","CloseIcon","ChevronDownIcon","SkeletonContainer","SkeletonBodyText","Popover","Subheading","SectionHeading","AutocompleteItems","getAutocompleteStyles","GenericGroupType","groupTitle","options","ItemType","Pick","items","isGrouped","onInputValueChange","value","onSelectItem","item","selectedItem","renderItem","inputValue","ReactNode","itemToString","clearAfterSelect","placeholder","noMatchesMessage","inputRef","Ref","HTMLInputElement","toggleRef","HTMLButtonElement","listRef","HTMLUListElement","listWidth","listMaxHeight","isLoading","usePortal","_Autocomplete","props","ref","HTMLDivElement","id","className","defaultValue","isInvalid","isDisabled","isRequired","isReadOnly","testId","GroupType","styles","setInputValue","handleInputValueChange","handleNativeChangeEvent","event","ChangeEvent","HTMLTextAreaElement","target","flattenItems","isUsingGroups","reduce","acc","group","isShowingNoMatches","every","length","getComboboxProps","getInputProps","getItemProps","getMenuProps","getToggleButtonProps","highlightedIndex","isOpen","toggleMenu","type","onStateChange","stateChangeTypes","InputKeyDownEnter","ItemClick","_labelledby","_inputId","inputProps","comboboxProps","toggleProps","menuProps","elementStartIndex","autocomplete","combobox","inputField","onChange","toggleButton","content","Array","map","_","index","disabled","noMatchesTitle","render","ListItemLoadingState","forwardRef","T","ReturnType","HTMLAttributes","getStringMatch","Text","UseComboboxGetItemPropsOptions","AutocompleteItemsProps","HTMLLIElement","list","itemIndex","itemProps","highlighted","displayName","HighlightedItem","before","match","after","tokens","paddingRight","spacingXl","textOverflow","whiteSpace","position","top","right","zIndex","padding","spacing2Xs","height","overflow","maxHeight","listStyle","spacingXs","margin","spacingM","lineHeight","lineHeightM","color","gray500","display","wordBreak","cursor","hyphens","backgroundColor","gray100","gray200"],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;A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D,OAAN,CAAcyD,MAAnC,CAAAoB;QACA,OAAOa,MAAP,CAAA;KAzBF,CAFF,EA8BC,CAAC/D,SAAD,IACC,CAACwB,mCAAa,CAAC/C,SAAD,EAAYD,KAAZ,CADf,IAECA,KAAK,CAACsD,MAAN,GAAe,CAFhB,kBAGG,qDAAC,yCAAiB;QAChB,KAAA,EAAOtD,KAAD;QACN,iBAAA,EAAmB0E,iBAAD;QAClB,gBAAA,EAAkBd,gBAAD;QACjB,YAAA,EAAcH,YAAD;QACb,UAAA,EAAYlD,UAAD;QACX,UAAA,EAAYC,WAAD;MATjB,CAYV,CACA,CAlIE,CAmIF;CAEC;AAED,MAAMgF,0CAAoB,GAAG,IAAM;IACjC,qBACE,qDAAC,8CAAD;QAAmB,SAAA,EAAW,EAAD;qBAC3B,qDAAC,6CAAD;QAAkB,aAAA,EAAe,CAAD;MAAtC,CAFE,CAGF;CAJA,A,EAQA,kFAFC;AAGD,SAASxC,mCAAa,CACpB/C,SADF,EAEED,KAFF,EAGyC;IACvC,OAAOC,SAAP,CAAA;CACD;AAOM,MAAM3B,yCAAY,iBAAGE,sCAAK,CAACiH,UAAN,CAAiB/D,mCAAjB,CAAA,AAArB,AACsC;;ADnZ7C","sources":["packages/components/autocomplete/src/index.ts","packages/components/autocomplete/src/Autocomplete.tsx","packages/components/autocomplete/src/AutocompleteItems.tsx","packages/components/autocomplete/src/Autocomplete.styles.ts"],"sourcesContent":["export { Autocomplete } from './Autocomplete';\nexport type { AutocompleteProps } from './Autocomplete';\n","import React, { useCallback, useState } from 'react';\nimport { cx } from 'emotion';\nimport { useCombobox } from 'downshift';\n\nimport { mergeRefs } from '@contentful/f36-core';\nimport type { CommonProps, ExpandProps } from '@contentful/f36-core';\nimport { IconButton } from '@contentful/f36-button';\nimport { TextInput } from '@contentful/f36-forms';\nimport type { TextInputProps } from '@contentful/f36-forms';\nimport { CloseIcon, ChevronDownIcon } from '@contentful/f36-icons';\nimport { SkeletonContainer, SkeletonBodyText } from '@contentful/f36-skeleton';\nimport { Popover } from '@contentful/f36-popover';\nimport { Subheading, SectionHeading } from '@contentful/f36-typography';\n\nimport { AutocompleteItems } from './AutocompleteItems';\nimport { getAutocompleteStyles } from './Autocomplete.styles';\n\nexport interface GenericGroupType<ItemType> {\n groupTitle: string;\n options: ItemType[];\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface AutocompleteProps<ItemType>\n extends CommonProps,\n Pick<\n TextInputProps,\n | 'isDisabled'\n | 'isInvalid'\n | 'isReadOnly'\n | 'isRequired'\n | 'id'\n | 'defaultValue'\n > {\n /**\n * It’s an array of data to be used as \"options\" by the autocomplete component.\n * This can either be a plain list of items or a list of groups of items.\n */\n items: ItemType[] | GenericGroupType<ItemType>[];\n\n /**\n * Tells if the item is a object with groups\n */\n isGrouped?: boolean;\n\n /**\n * Function called whenever the input value changes\n */\n onInputValueChange?: (value: string) => void;\n /**\n * This is the function that will be called when the user selects one of the \"options\" in the list.\n * The component will pass the selected \"item\" as an argument to the function..\n */\n onSelectItem: (item: ItemType) => void;\n\n /**\n * Applying the selectedItem property turns autocomplete into a controlled component.\n * Can be used to display e.g. previously selected element. If it is an object the itemToString function will apply to it.\n */\n selectedItem?: ItemType;\n\n /**\n * This is the function that will be called for each \"item\" passed in the `items` prop.\n * It receives the \"item\" and \"inputValue\" as arguments and returns a ReactNode.\n * The inputValue is passed in case you want to highlight the match on the render.\n */\n renderItem?: (item: ItemType, inputValue: string) => React.ReactNode;\n /**\n * When using objects as `items`, we recommend passing a function that tells Downshift how to extract a string\n * from those objetcs to be used as inputValue\n */\n itemToString?: (item: ItemType) => string;\n /**\n * If this is set to `true` the text input will be cleared after an item is selected\n * @default false\n */\n clearAfterSelect?: boolean;\n /**\n * If this is set to `false` the dropdown menu will stay open after selecting an item\n * @default true\n */\n closeAfterSelect?: boolean;\n /**\n * This is the value will be passed to the `placeholder` prop of the input.\n * @default \"Search\"\n */\n placeholder?: string;\n /**\n * A message that will be shown when it is not possible to find any option that matches the input value\n * @default \"No matches\"\n */\n noMatchesMessage?: string;\n /**\n * Use this prop to get a ref to the input element of the component\n */\n inputRef?: React.Ref<HTMLInputElement>;\n /**\n * Use this prop to get a ref to the toggle button of the component\n */\n toggleRef?: React.Ref<HTMLButtonElement>;\n /**\n * Use this prop to get a ref to the list of items of the component\n */\n listRef?: React.Ref<HTMLUListElement>;\n /**\n * It sets the width of the list\n * @default \"auto\"\n */\n listWidth?: 'auto' | 'full';\n /**\n * It sets the max-height, in pixels, of the list\n * The default value is the height of 5 single line items\n * @default 180\n */\n listMaxHeight?: number;\n /**\n * Sets the list to show its loading state\n * @default false\n */\n isLoading?: boolean;\n /**\n * Boolean to control whether or not to render the suggestions box in a React Portal.\n * Rendering content inside a Portal allows the suggestions box to escape the bounds\n * of its parent while still being positioned correctly.\n * Defaults to `false`\n */\n usePortal?: boolean;\n}\n\nfunction _Autocomplete<ItemType>(\n props: AutocompleteProps<ItemType>,\n ref: React.Ref<HTMLDivElement>,\n) {\n const {\n id,\n className,\n clearAfterSelect = false,\n closeAfterSelect = true,\n defaultValue = '',\n selectedItem,\n items,\n onInputValueChange,\n onSelectItem,\n renderItem,\n itemToString = (item: ItemType) => (item as unknown) as string,\n isInvalid,\n isDisabled,\n isRequired,\n isReadOnly,\n noMatchesMessage = 'No matches found',\n placeholder = 'Search',\n inputRef,\n toggleRef,\n listRef,\n listWidth = 'auto',\n listMaxHeight = 180,\n isGrouped = false,\n isLoading = false,\n usePortal = false,\n testId = 'cf-autocomplete',\n } = props;\n\n type GroupType = GenericGroupType<ItemType>;\n\n const styles = getAutocompleteStyles(listMaxHeight);\n\n const [inputValue, setInputValue] = useState(defaultValue);\n\n const handleInputValueChange = useCallback(\n (value: string) => {\n setInputValue(value);\n\n onInputValueChange?.(value);\n },\n [onInputValueChange],\n );\n\n // Handle manually to avoid a jumping cursor, see https://github.com/downshift-js/downshift/issues/1108#issuecomment-842407759\n const handleNativeChangeEvent = useCallback(\n (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n const value = event.target.value;\n handleInputValueChange(value);\n },\n [handleInputValueChange],\n );\n\n const flattenItems = isUsingGroups(isGrouped, items)\n ? items.reduce(\n (acc: ItemType[], group: GroupType) => [...acc, ...group.options],\n [],\n )\n : items;\n\n const isShowingNoMatches = isUsingGroups(isGrouped, items)\n ? items.every((group: GroupType) => group.options.length === 0)\n : items.length === 0;\n\n const {\n getComboboxProps,\n getInputProps,\n getItemProps,\n getMenuProps,\n getToggleButtonProps,\n highlightedIndex,\n isOpen,\n toggleMenu,\n } = useCombobox({\n items: flattenItems,\n selectedItem,\n inputValue,\n itemToString,\n onInputValueChange: ({ type, inputValue }) => {\n if (type !== '__input_change__') {\n handleInputValueChange(inputValue);\n }\n },\n onStateChange: ({ type, selectedItem }) => {\n switch (type) {\n case useCombobox.stateChangeTypes.InputKeyDownEnter:\n case useCombobox.stateChangeTypes.ItemClick:\n if (selectedItem) {\n onSelectItem(selectedItem);\n }\n if (clearAfterSelect) {\n handleInputValueChange('');\n }\n if (!closeAfterSelect) {\n toggleMenu();\n }\n break;\n default:\n break;\n }\n },\n });\n\n const {\n 'aria-labelledby': _labelledby,\n id: _inputId,\n ...inputProps\n } = getInputProps();\n const comboboxProps = getComboboxProps();\n const toggleProps = getToggleButtonProps();\n const menuProps = getMenuProps();\n let elementStartIndex = 0;\n\n return (\n <div\n data-test-id={testId}\n className={cx(styles.autocomplete, className)}\n ref={ref}\n >\n <Popover\n usePortal={usePortal}\n isOpen={isOpen}\n isFullWidth={listWidth === 'full'}\n renderOnlyWhenOpen={false}\n // This is necessary, otherwise the focus will change from the input to the Popover\n // and the user won't be able to type in the input\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={false}\n id={menuProps.id}\n >\n <Popover.Trigger>\n <div {...comboboxProps} className={styles.combobox}>\n <TextInput\n className={styles.inputField}\n {...inputProps}\n onFocus={() => {\n if (!isOpen) {\n toggleMenu();\n }\n }}\n id={id}\n isInvalid={isInvalid}\n isDisabled={isDisabled}\n isRequired={isRequired}\n isReadOnly={isReadOnly}\n ref={mergeRefs(inputProps.ref, inputRef)}\n testId=\"cf-autocomplete-input\"\n placeholder={placeholder}\n onChange={(event) => {\n inputProps.onChange(event);\n handleNativeChangeEvent(event);\n }}\n />\n <IconButton\n {...toggleProps}\n ref={mergeRefs(toggleProps.ref, toggleRef)}\n aria-label=\"toggle menu\"\n className={styles.toggleButton}\n variant=\"transparent\"\n icon={\n inputValue ? (\n <CloseIcon aria-label=\"Clear\" variant=\"muted\" />\n ) : (\n <ChevronDownIcon aria-label=\"Show list\" variant=\"muted\" />\n )\n }\n onClick={() => {\n if (inputValue) {\n handleInputValueChange('');\n } else {\n toggleMenu();\n }\n }}\n isDisabled={isDisabled}\n size=\"small\"\n />\n </div>\n </Popover.Trigger>\n\n <Popover.Content\n {...menuProps}\n ref={mergeRefs(menuProps.ref, listRef)}\n className={styles.content}\n testId=\"cf-autocomplete-container\"\n >\n {isLoading &&\n [...Array(3)].map((_, index) => (\n <div key={index} className={cx(styles.item, styles.disabled)}>\n <ListItemLoadingState />\n </div>\n ))}\n\n {!isLoading && isShowingNoMatches && (\n <div className={styles.item}>\n <Subheading className={styles.noMatchesTitle}>\n {noMatchesMessage}\n </Subheading>\n </div>\n )}\n\n {!isLoading &&\n isUsingGroups(isGrouped, items) &&\n items.map((group: GroupType, index: number) => {\n if (group.options.length < 1) {\n return;\n }\n const render = (\n <div key={index}>\n <SectionHeading\n key={index}\n data-test-id=\"cf-autocomplete-grouptitle\"\n marginBottom=\"none\"\n className={styles.groupTitle}\n >\n {group.groupTitle}\n </SectionHeading>\n <AutocompleteItems<ItemType>\n items={group.options}\n highlightedIndex={highlightedIndex}\n getItemProps={getItemProps}\n renderItem={renderItem}\n inputValue={inputValue}\n elementStartIndex={elementStartIndex}\n />\n </div>\n );\n elementStartIndex += group.options.length;\n return render;\n })}\n\n {!isLoading &&\n !isUsingGroups(isGrouped, items) &&\n items.length > 0 && (\n <AutocompleteItems<ItemType>\n items={items}\n elementStartIndex={elementStartIndex}\n highlightedIndex={highlightedIndex}\n getItemProps={getItemProps}\n renderItem={renderItem}\n inputValue={inputValue}\n />\n )}\n </Popover.Content>\n </Popover>\n </div>\n );\n}\n\nconst ListItemLoadingState = () => {\n return (\n <SkeletonContainer svgHeight={16}>\n <SkeletonBodyText numberOfLines={1} />\n </SkeletonContainer>\n );\n};\n\n// This is required to infer correct typings when differentiating groups and items\nfunction isUsingGroups<ItemType>(\n isGrouped: boolean,\n items: ItemType[] | GenericGroupType<ItemType>[],\n): items is GenericGroupType<ItemType>[] {\n return isGrouped;\n}\n\n/**\n * The Autocomplete is a component that will show a `TextInput` where a user can type any word which will be used\n * to filter a list of items. That list of filtered items will be shown to the user as possible options for the input.\n * Once one of the options is selected, that option becomes the value of the `TextInput`.\n */\nexport const Autocomplete = React.forwardRef(_Autocomplete) as <T>(\n props: ExpandProps<AutocompleteProps<T>> & {\n ref?: React.Ref<HTMLDivElement>;\n },\n) => ReturnType<typeof _Autocomplete>;\n","import React, { HTMLAttributes } from 'react';\nimport { cx } from 'emotion';\n\nimport { getStringMatch } from '@contentful/f36-utils';\nimport { Text } from '@contentful/f36-typography';\nimport { getAutocompleteStyles } from './Autocomplete.styles';\nimport type { UseComboboxGetItemPropsOptions } from 'downshift';\n\ninterface AutocompleteItemsProps<ItemType> {\n items: ItemType[];\n elementStartIndex: number;\n highlightedIndex: number;\n getItemProps: (\n options: UseComboboxGetItemPropsOptions<ItemType>,\n ) => HTMLAttributes<HTMLLIElement>;\n renderItem: (item: ItemType, inputValue: string) => React.ReactNode;\n inputValue: string;\n listMaxHeight?: number;\n}\n\nexport const AutocompleteItems = <ItemType,>(\n props: AutocompleteItemsProps<ItemType>,\n) => {\n const {\n items,\n elementStartIndex,\n highlightedIndex,\n getItemProps,\n renderItem,\n inputValue,\n listMaxHeight = 180,\n } = props;\n\n const styles = getAutocompleteStyles(listMaxHeight);\n\n return (\n <ul className={styles.list} data-test-id=\"cf-autocomplete-list\">\n {items.map((item: ItemType, index: number) => {\n const itemIndex = elementStartIndex + index;\n const itemProps = getItemProps({ item, index: itemIndex });\n return (\n <Text\n {...itemProps}\n as=\"li\"\n key={itemIndex}\n className={cx([\n styles.item,\n highlightedIndex === itemIndex && styles.highlighted,\n ])}\n data-test-id={`cf-autocomplete-list-item-${itemIndex}`}\n >\n {renderItem ? (\n renderItem(item, inputValue)\n ) : typeof item === 'string' ? (\n <HighlightedItem item={item} inputValue={inputValue} />\n ) : (\n item\n )}\n </Text>\n );\n })}\n </ul>\n );\n};\n\nAutocompleteItems.displayName = 'AutocompleteItems';\n\nfunction HighlightedItem({\n item,\n inputValue,\n}: {\n item: string;\n inputValue: string;\n}) {\n const { before, match, after } = getStringMatch(item, inputValue);\n\n return (\n <>\n {before}\n <b>{match}</b>\n {after}\n </>\n );\n}\n\nHighlightedItem.displayName = 'HighlightedItem';\n","import { css } from 'emotion';\nimport tokens from '@contentful/f36-tokens';\n\nexport const getAutocompleteStyles = (listMaxHeight: number) => ({\n autocomplete: css({\n position: 'relative',\n width: '100%',\n }),\n combobox: css({\n position: 'relative',\n }),\n inputField: css({\n paddingRight: tokens.spacingXl,\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n }),\n toggleButton: css({\n position: 'absolute',\n top: '1px',\n right: '1px',\n zIndex: 1,\n padding: tokens.spacing2Xs,\n height: '38px',\n }),\n content: css({\n overflow: 'auto',\n maxHeight: `${listMaxHeight}px`,\n }),\n list: css({\n listStyle: 'none',\n padding: `${tokens.spacingXs} 0`,\n margin: 0,\n }),\n groupTitle: css({\n padding: `${tokens.spacingXs} ${tokens.spacingM}`,\n lineHeight: tokens.lineHeightM,\n }),\n noMatchesTitle: css({\n color: tokens.gray500,\n margin: `${tokens.spacingM} 0 ${tokens.spacingM} 0`,\n }),\n item: css({\n display: 'block',\n padding: `${tokens.spacingXs} ${tokens.spacingM}`,\n wordBreak: 'break-word',\n whiteSpace: 'break-spaces',\n cursor: 'pointer',\n hyphens: 'auto',\n\n '&:focus, &:hover': {\n backgroundColor: tokens.gray100,\n },\n '&:active': {\n backgroundColor: tokens.gray200,\n },\n }),\n disabled: css({\n opacity: 0.5,\n pointerEvents: 'none',\n }),\n highlighted: css({\n backgroundColor: tokens.gray100,\n }),\n});\n"],"names":["Autocomplete","AutocompleteProps","React","useCallback","useState","useCombobox","mergeRefs","CommonProps","ExpandProps","IconButton","TextInput","TextInputProps","CloseIcon","ChevronDownIcon","SkeletonContainer","SkeletonBodyText","Popover","Subheading","SectionHeading","AutocompleteItems","getAutocompleteStyles","GenericGroupType","groupTitle","options","ItemType","Pick","items","isGrouped","onInputValueChange","value","onSelectItem","item","selectedItem","renderItem","inputValue","ReactNode","itemToString","clearAfterSelect","closeAfterSelect","placeholder","noMatchesMessage","inputRef","Ref","HTMLInputElement","toggleRef","HTMLButtonElement","listRef","HTMLUListElement","listWidth","listMaxHeight","isLoading","usePortal","_Autocomplete","props","ref","HTMLDivElement","id","className","defaultValue","isInvalid","isDisabled","isRequired","isReadOnly","testId","GroupType","styles","setInputValue","handleInputValueChange","handleNativeChangeEvent","event","ChangeEvent","HTMLTextAreaElement","target","flattenItems","isUsingGroups","reduce","acc","group","isShowingNoMatches","every","length","getComboboxProps","getInputProps","getItemProps","getMenuProps","getToggleButtonProps","highlightedIndex","isOpen","toggleMenu","type","onStateChange","stateChangeTypes","InputKeyDownEnter","ItemClick","_labelledby","_inputId","inputProps","comboboxProps","toggleProps","menuProps","elementStartIndex","autocomplete","combobox","inputField","onChange","toggleButton","content","Array","map","_","index","disabled","noMatchesTitle","render","ListItemLoadingState","forwardRef","T","ReturnType","HTMLAttributes","getStringMatch","Text","UseComboboxGetItemPropsOptions","AutocompleteItemsProps","HTMLLIElement","list","itemIndex","itemProps","highlighted","displayName","HighlightedItem","before","match","after","tokens","paddingRight","spacingXl","textOverflow","whiteSpace","position","top","right","zIndex","padding","spacing2Xs","height","overflow","maxHeight","listStyle","spacingXs","margin","spacingM","lineHeight","lineHeightM","color","gray500","display","wordBreak","cursor","hyphens","backgroundColor","gray100","gray200"],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -128,7 +128,7 @@ $641c6dc49f14cfd8$var$HighlightedItem.displayName = 'HighlightedItem';
|
|
|
128
128
|
|
|
129
129
|
|
|
130
130
|
function $7cd5ba9838c72bf9$var$_Autocomplete(props, ref) {
|
|
131
|
-
const { id: id , className: className , clearAfterSelect: clearAfterSelect = false , defaultValue: defaultValue = '' , selectedItem: selectedItem1 , items: items , onInputValueChange: onInputValueChange , onSelectItem: onSelectItem , renderItem: renderItem , itemToString: itemToString = (item)=>item
|
|
131
|
+
const { id: id , className: className , clearAfterSelect: clearAfterSelect = false , closeAfterSelect: closeAfterSelect = true , defaultValue: defaultValue = '' , selectedItem: selectedItem1 , items: items , onInputValueChange: onInputValueChange , onSelectItem: onSelectItem , renderItem: renderItem , itemToString: itemToString = (item)=>item
|
|
132
132
|
, isInvalid: isInvalid , isDisabled: isDisabled , isRequired: isRequired , isReadOnly: isReadOnly , noMatchesMessage: noMatchesMessage = 'No matches found' , placeholder: placeholder = 'Search' , inputRef: inputRef , toggleRef: toggleRef , listRef: listRef , listWidth: listWidth = 'auto' , listMaxHeight: listMaxHeight = 180 , isGrouped: isGrouped = false , isLoading: isLoading = false , usePortal: usePortal = false , testId: testId = 'cf-autocomplete' } = props;
|
|
133
133
|
const styles = $b76be67e84921f58$export$71b73d9f7d678746(listMaxHeight);
|
|
134
134
|
const [inputValue1, setInputValue] = $7oe8x$useState(defaultValue);
|
|
@@ -165,6 +165,7 @@ function $7cd5ba9838c72bf9$var$_Autocomplete(props, ref) {
|
|
|
165
165
|
case $7oe8x$useCombobox.stateChangeTypes.ItemClick:
|
|
166
166
|
if (selectedItem) onSelectItem(selectedItem);
|
|
167
167
|
if (clearAfterSelect) handleInputValueChange('');
|
|
168
|
+
if (!closeAfterSelect) toggleMenu();
|
|
168
169
|
break;
|
|
169
170
|
default:
|
|
170
171
|
break;
|
package/d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,MAAP,CAAA;KAzBF,CAFF,EA8BC,CAAC/D,SAAD,IACC,CAACwB,mCAAa,CAAC9C,SAAD,EAAYD,KAAZ,CADf,IAECA,KAAK,CAACqD,MAAN,GAAe,CAFhB,kBAGG,2BAAC,yCAAiB;QAChB,KAAA,EAAOrD,KAAD;QACN,iBAAA,EAAmByE,iBAAD;QAClB,gBAAA,EAAkBd,gBAAD;QACjB,YAAA,EAAcH,YAAD;QACb,UAAA,EAAYjD,UAAD;QACX,UAAA,EAAYC,WAAD;MATjB,CAYV,CACA,CAlIE,CAmIF;CAEC;AAED,MAAM+E,0CAAoB,GAAG,IAAM;IACjC,qBACE,2BAAC,wBAAD;QAAmB,SAAA,EAAW,EAAD;qBAC3B,2BAAC,uBAAD;QAAkB,aAAA,EAAe,CAAD;MAAtC,CAFE,CAGF;CAJA,A,EAQA,kFAFC;AAGD,SAASxC,mCAAa,CACpB9C,SADF,EAEED,KAFF,EAGyC;IACvC,OAAOC,SAAP,CAAA;CACD;AAOM,MAAM3B,yCAAY,iBAAGE,YAAK,CAACgH,UAAN,CAAiB/D,mCAAjB,CAAA,AAArB,AACsC;;AD1Y7C","sources":["packages/components/autocomplete/src/index.ts","packages/components/autocomplete/src/Autocomplete.tsx","packages/components/autocomplete/src/AutocompleteItems.tsx","packages/components/autocomplete/src/Autocomplete.styles.ts"],"sourcesContent":["export { Autocomplete } from './Autocomplete';\nexport type { AutocompleteProps } from './Autocomplete';\n","import React, { useCallback, useState } from 'react';\nimport { cx } from 'emotion';\nimport { useCombobox } from 'downshift';\n\nimport { mergeRefs } from '@contentful/f36-core';\nimport type { CommonProps, ExpandProps } from '@contentful/f36-core';\nimport { IconButton } from '@contentful/f36-button';\nimport { TextInput } from '@contentful/f36-forms';\nimport type { TextInputProps } from '@contentful/f36-forms';\nimport { CloseIcon, ChevronDownIcon } from '@contentful/f36-icons';\nimport { SkeletonContainer, SkeletonBodyText } from '@contentful/f36-skeleton';\nimport { Popover } from '@contentful/f36-popover';\nimport { Subheading, SectionHeading } from '@contentful/f36-typography';\n\nimport { AutocompleteItems } from './AutocompleteItems';\nimport { getAutocompleteStyles } from './Autocomplete.styles';\n\nexport interface GenericGroupType<ItemType> {\n groupTitle: string;\n options: ItemType[];\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface AutocompleteProps<ItemType>\n extends CommonProps,\n Pick<\n TextInputProps,\n | 'isDisabled'\n | 'isInvalid'\n | 'isReadOnly'\n | 'isRequired'\n | 'id'\n | 'defaultValue'\n > {\n /**\n * It’s an array of data to be used as \"options\" by the autocomplete component.\n * This can either be a plain list of items or a list of groups of items.\n */\n items: ItemType[] | GenericGroupType<ItemType>[];\n\n /**\n * Tells if the item is a object with groups\n */\n isGrouped?: boolean;\n\n /**\n * Function called whenever the input value changes\n */\n onInputValueChange?: (value: string) => void;\n /**\n * This is the function that will be called when the user selects one of the \"options\" in the list.\n * The component will pass the selected \"item\" as an argument to the function..\n */\n onSelectItem: (item: ItemType) => void;\n\n /**\n * Applying the selectedItem property turns autocomplete into a controlled component.\n * Can be used to display e.g. previously selected element. If it is an object the itemToString function will apply to it.\n */\n selectedItem?: ItemType;\n\n /**\n * This is the function that will be called for each \"item\" passed in the `items` prop.\n * It receives the \"item\" and \"inputValue\" as arguments and returns a ReactNode.\n * The inputValue is passed in case you want to highlight the match on the render.\n */\n renderItem?: (item: ItemType, inputValue: string) => React.ReactNode;\n /**\n * When using objects as `items`, we recommend passing a function that tells Downshift how to extract a string\n * from those objetcs to be used as inputValue\n */\n itemToString?: (item: ItemType) => string;\n /**\n * If this is set to `true` the text input will be cleared after an item is selected\n * @default false\n */\n clearAfterSelect?: boolean;\n /**\n * This is the value will be passed to the `placeholder` prop of the input.\n * @default \"Search\"\n */\n placeholder?: string;\n /**\n * A message that will be shown when it is not possible to find any option that matches the input value\n * @default \"No matches\"\n */\n noMatchesMessage?: string;\n /**\n * Use this prop to get a ref to the input element of the component\n */\n inputRef?: React.Ref<HTMLInputElement>;\n /**\n * Use this prop to get a ref to the toggle button of the component\n */\n toggleRef?: React.Ref<HTMLButtonElement>;\n /**\n * Use this prop to get a ref to the list of items of the component\n */\n listRef?: React.Ref<HTMLUListElement>;\n /**\n * It sets the width of the list\n * @default \"auto\"\n */\n listWidth?: 'auto' | 'full';\n /**\n * It sets the max-height, in pixels, of the list\n * The default value is the height of 5 single line items\n * @default 180\n */\n listMaxHeight?: number;\n /**\n * Sets the list to show its loading state\n * @default false\n */\n isLoading?: boolean;\n /**\n * Boolean to control whether or not to render the suggestions box in a React Portal.\n * Rendering content inside a Portal allows the suggestions box to escape the bounds\n * of its parent while still being positioned correctly.\n * Defaults to `false`\n */\n usePortal?: boolean;\n}\n\nfunction _Autocomplete<ItemType>(\n props: AutocompleteProps<ItemType>,\n ref: React.Ref<HTMLDivElement>,\n) {\n const {\n id,\n className,\n clearAfterSelect = false,\n defaultValue = '',\n selectedItem,\n items,\n onInputValueChange,\n onSelectItem,\n renderItem,\n itemToString = (item: ItemType) => (item as unknown) as string,\n isInvalid,\n isDisabled,\n isRequired,\n isReadOnly,\n noMatchesMessage = 'No matches found',\n placeholder = 'Search',\n inputRef,\n toggleRef,\n listRef,\n listWidth = 'auto',\n listMaxHeight = 180,\n isGrouped = false,\n isLoading = false,\n usePortal = false,\n testId = 'cf-autocomplete',\n } = props;\n\n type GroupType = GenericGroupType<ItemType>;\n\n const styles = getAutocompleteStyles(listMaxHeight);\n\n const [inputValue, setInputValue] = useState(defaultValue);\n\n const handleInputValueChange = useCallback(\n (value: string) => {\n setInputValue(value);\n\n onInputValueChange?.(value);\n },\n [onInputValueChange],\n );\n\n // Handle manually to avoid a jumping cursor, see https://github.com/downshift-js/downshift/issues/1108#issuecomment-842407759\n const handleNativeChangeEvent = useCallback(\n (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n const value = event.target.value;\n handleInputValueChange(value);\n },\n [handleInputValueChange],\n );\n\n const flattenItems = isUsingGroups(isGrouped, items)\n ? items.reduce(\n (acc: ItemType[], group: GroupType) => [...acc, ...group.options],\n [],\n )\n : items;\n\n const isShowingNoMatches = isUsingGroups(isGrouped, items)\n ? items.every((group: GroupType) => group.options.length === 0)\n : items.length === 0;\n\n const {\n getComboboxProps,\n getInputProps,\n getItemProps,\n getMenuProps,\n getToggleButtonProps,\n highlightedIndex,\n isOpen,\n toggleMenu,\n } = useCombobox({\n items: flattenItems,\n selectedItem,\n inputValue,\n itemToString,\n onInputValueChange: ({ type, inputValue }) => {\n if (type !== '__input_change__') {\n handleInputValueChange(inputValue);\n }\n },\n onStateChange: ({ type, selectedItem }) => {\n switch (type) {\n case useCombobox.stateChangeTypes.InputKeyDownEnter:\n case useCombobox.stateChangeTypes.ItemClick:\n if (selectedItem) {\n onSelectItem(selectedItem);\n }\n if (clearAfterSelect) {\n handleInputValueChange('');\n }\n break;\n default:\n break;\n }\n },\n });\n\n const {\n 'aria-labelledby': _labelledby,\n id: _inputId,\n ...inputProps\n } = getInputProps();\n const comboboxProps = getComboboxProps();\n const toggleProps = getToggleButtonProps();\n const menuProps = getMenuProps();\n let elementStartIndex = 0;\n\n return (\n <div\n data-test-id={testId}\n className={cx(styles.autocomplete, className)}\n ref={ref}\n >\n <Popover\n usePortal={usePortal}\n isOpen={isOpen}\n isFullWidth={listWidth === 'full'}\n renderOnlyWhenOpen={false}\n // This is necessary, otherwise the focus will change from the input to the Popover\n // and the user won't be able to type in the input\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={false}\n id={menuProps.id}\n >\n <Popover.Trigger>\n <div {...comboboxProps} className={styles.combobox}>\n <TextInput\n className={styles.inputField}\n {...inputProps}\n onFocus={() => {\n if (!isOpen) {\n toggleMenu();\n }\n }}\n id={id}\n isInvalid={isInvalid}\n isDisabled={isDisabled}\n isRequired={isRequired}\n isReadOnly={isReadOnly}\n ref={mergeRefs(inputProps.ref, inputRef)}\n testId=\"cf-autocomplete-input\"\n placeholder={placeholder}\n onChange={(event) => {\n inputProps.onChange(event);\n handleNativeChangeEvent(event);\n }}\n />\n <IconButton\n {...toggleProps}\n ref={mergeRefs(toggleProps.ref, toggleRef)}\n aria-label=\"toggle menu\"\n className={styles.toggleButton}\n variant=\"transparent\"\n icon={\n inputValue ? (\n <CloseIcon aria-label=\"Clear\" variant=\"muted\" />\n ) : (\n <ChevronDownIcon aria-label=\"Show list\" variant=\"muted\" />\n )\n }\n onClick={() => {\n if (inputValue) {\n handleInputValueChange('');\n } else {\n toggleMenu();\n }\n }}\n isDisabled={isDisabled}\n size=\"small\"\n />\n </div>\n </Popover.Trigger>\n\n <Popover.Content\n {...menuProps}\n ref={mergeRefs(menuProps.ref, listRef)}\n className={styles.content}\n testId=\"cf-autocomplete-container\"\n >\n {isLoading &&\n [...Array(3)].map((_, index) => (\n <div key={index} className={cx(styles.item, styles.disabled)}>\n <ListItemLoadingState />\n </div>\n ))}\n\n {!isLoading && isShowingNoMatches && (\n <div className={styles.item}>\n <Subheading className={styles.noMatchesTitle}>\n {noMatchesMessage}\n </Subheading>\n </div>\n )}\n\n {!isLoading &&\n isUsingGroups(isGrouped, items) &&\n items.map((group: GroupType, index: number) => {\n if (group.options.length < 1) {\n return;\n }\n const render = (\n <div key={index}>\n <SectionHeading\n key={index}\n data-test-id=\"cf-autocomplete-grouptitle\"\n marginBottom=\"none\"\n className={styles.groupTitle}\n >\n {group.groupTitle}\n </SectionHeading>\n <AutocompleteItems<ItemType>\n items={group.options}\n highlightedIndex={highlightedIndex}\n getItemProps={getItemProps}\n renderItem={renderItem}\n inputValue={inputValue}\n elementStartIndex={elementStartIndex}\n />\n </div>\n );\n elementStartIndex += group.options.length;\n return render;\n })}\n\n {!isLoading &&\n !isUsingGroups(isGrouped, items) &&\n items.length > 0 && (\n <AutocompleteItems<ItemType>\n items={items}\n elementStartIndex={elementStartIndex}\n highlightedIndex={highlightedIndex}\n getItemProps={getItemProps}\n renderItem={renderItem}\n inputValue={inputValue}\n />\n )}\n </Popover.Content>\n </Popover>\n </div>\n );\n}\n\nconst ListItemLoadingState = () => {\n return (\n <SkeletonContainer svgHeight={16}>\n <SkeletonBodyText numberOfLines={1} />\n </SkeletonContainer>\n );\n};\n\n// This is required to infer correct typings when differentiating groups and items\nfunction isUsingGroups<ItemType>(\n isGrouped: boolean,\n items: ItemType[] | GenericGroupType<ItemType>[],\n): items is GenericGroupType<ItemType>[] {\n return isGrouped;\n}\n\n/**\n * The Autocomplete is a component that will show a `TextInput` where a user can type any word which will be used\n * to filter a list of items. That list of filtered items will be shown to the user as possible options for the input.\n * Once one of the options is selected, that option becomes the value of the `TextInput`.\n */\nexport const Autocomplete = React.forwardRef(_Autocomplete) as <T>(\n props: ExpandProps<AutocompleteProps<T>> & {\n ref?: React.Ref<HTMLDivElement>;\n },\n) => ReturnType<typeof _Autocomplete>;\n","import React, { HTMLAttributes } from 'react';\nimport { cx } from 'emotion';\n\nimport { getStringMatch } from '@contentful/f36-utils';\nimport { Text } from '@contentful/f36-typography';\nimport { getAutocompleteStyles } from './Autocomplete.styles';\nimport type { UseComboboxGetItemPropsOptions } from 'downshift';\n\ninterface AutocompleteItemsProps<ItemType> {\n items: ItemType[];\n elementStartIndex: number;\n highlightedIndex: number;\n getItemProps: (\n options: UseComboboxGetItemPropsOptions<ItemType>,\n ) => HTMLAttributes<HTMLLIElement>;\n renderItem: (item: ItemType, inputValue: string) => React.ReactNode;\n inputValue: string;\n listMaxHeight?: number;\n}\n\nexport const AutocompleteItems = <ItemType,>(\n props: AutocompleteItemsProps<ItemType>,\n) => {\n const {\n items,\n elementStartIndex,\n highlightedIndex,\n getItemProps,\n renderItem,\n inputValue,\n listMaxHeight = 180,\n } = props;\n\n const styles = getAutocompleteStyles(listMaxHeight);\n\n return (\n <ul className={styles.list} data-test-id=\"cf-autocomplete-list\">\n {items.map((item: ItemType, index: number) => {\n const itemIndex = elementStartIndex + index;\n const itemProps = getItemProps({ item, index: itemIndex });\n return (\n <Text\n {...itemProps}\n as=\"li\"\n key={itemIndex}\n className={cx([\n styles.item,\n highlightedIndex === itemIndex && styles.highlighted,\n ])}\n data-test-id={`cf-autocomplete-list-item-${itemIndex}`}\n >\n {renderItem ? (\n renderItem(item, inputValue)\n ) : typeof item === 'string' ? (\n <HighlightedItem item={item} inputValue={inputValue} />\n ) : (\n item\n )}\n </Text>\n );\n })}\n </ul>\n );\n};\n\nAutocompleteItems.displayName = 'AutocompleteItems';\n\nfunction HighlightedItem({\n item,\n inputValue,\n}: {\n item: string;\n inputValue: string;\n}) {\n const { before, match, after } = getStringMatch(item, inputValue);\n\n return (\n <>\n {before}\n <b>{match}</b>\n {after}\n </>\n );\n}\n\nHighlightedItem.displayName = 'HighlightedItem';\n","import { css } from 'emotion';\nimport tokens from '@contentful/f36-tokens';\n\nexport const getAutocompleteStyles = (listMaxHeight: number) => ({\n autocomplete: css({\n position: 'relative',\n width: '100%',\n }),\n combobox: css({\n position: 'relative',\n }),\n inputField: css({\n paddingRight: tokens.spacingXl,\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n }),\n toggleButton: css({\n position: 'absolute',\n top: '1px',\n right: '1px',\n zIndex: 1,\n padding: tokens.spacing2Xs,\n height: '38px',\n }),\n content: css({\n overflow: 'auto',\n maxHeight: `${listMaxHeight}px`,\n }),\n list: css({\n listStyle: 'none',\n padding: `${tokens.spacingXs} 0`,\n margin: 0,\n }),\n groupTitle: css({\n padding: `${tokens.spacingXs} ${tokens.spacingM}`,\n lineHeight: tokens.lineHeightM,\n }),\n noMatchesTitle: css({\n color: tokens.gray500,\n margin: `${tokens.spacingM} 0 ${tokens.spacingM} 0`,\n }),\n item: css({\n display: 'block',\n padding: `${tokens.spacingXs} ${tokens.spacingM}`,\n wordBreak: 'break-word',\n whiteSpace: 'break-spaces',\n cursor: 'pointer',\n hyphens: 'auto',\n\n '&:focus, &:hover': {\n backgroundColor: tokens.gray100,\n },\n '&:active': {\n backgroundColor: tokens.gray200,\n },\n }),\n disabled: css({\n opacity: 0.5,\n pointerEvents: 'none',\n }),\n highlighted: css({\n backgroundColor: tokens.gray100,\n }),\n});\n"],"names":["Autocomplete","AutocompleteProps","React","useCallback","useState","useCombobox","mergeRefs","CommonProps","ExpandProps","IconButton","TextInput","TextInputProps","CloseIcon","ChevronDownIcon","SkeletonContainer","SkeletonBodyText","Popover","Subheading","SectionHeading","AutocompleteItems","getAutocompleteStyles","GenericGroupType","groupTitle","options","ItemType","Pick","items","isGrouped","onInputValueChange","value","onSelectItem","item","selectedItem","renderItem","inputValue","ReactNode","itemToString","clearAfterSelect","placeholder","noMatchesMessage","inputRef","Ref","HTMLInputElement","toggleRef","HTMLButtonElement","listRef","HTMLUListElement","listWidth","listMaxHeight","isLoading","usePortal","_Autocomplete","props","ref","HTMLDivElement","id","className","defaultValue","isInvalid","isDisabled","isRequired","isReadOnly","testId","GroupType","styles","setInputValue","handleInputValueChange","handleNativeChangeEvent","event","ChangeEvent","HTMLTextAreaElement","target","flattenItems","isUsingGroups","reduce","acc","group","isShowingNoMatches","every","length","getComboboxProps","getInputProps","getItemProps","getMenuProps","getToggleButtonProps","highlightedIndex","isOpen","toggleMenu","type","onStateChange","stateChangeTypes","InputKeyDownEnter","ItemClick","_labelledby","_inputId","inputProps","comboboxProps","toggleProps","menuProps","elementStartIndex","autocomplete","combobox","inputField","onChange","toggleButton","content","Array","map","_","index","disabled","noMatchesTitle","render","ListItemLoadingState","forwardRef","T","ReturnType","HTMLAttributes","getStringMatch","Text","UseComboboxGetItemPropsOptions","AutocompleteItemsProps","HTMLLIElement","list","itemIndex","itemProps","highlighted","displayName","HighlightedItem","before","match","after","tokens","paddingRight","spacingXl","textOverflow","whiteSpace","position","top","right","zIndex","padding","spacing2Xs","height","overflow","maxHeight","listStyle","spacingXs","margin","spacingM","lineHeight","lineHeightM","color","gray500","display","wordBreak","cursor","hyphens","backgroundColor","gray100","gray200"],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;A;;;;;;;;;;A;;;;A;;AGGO,MAAMoB,yCAAqB,GAAG,CAAC6B,aAAD,GAA4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ACC,CAACwB,mCAAa,CAAC/C,SAAD,EAAYD,KAAZ,CADf,IAECA,KAAK,CAACsD,MAAN,GAAe,CAFhB,kBAGG,2BAAC,yCAAiB;QAChB,KAAA,EAAOtD,KAAD;QACN,iBAAA,EAAmB0E,iBAAD;QAClB,gBAAA,EAAkBd,gBAAD;QACjB,YAAA,EAAcH,YAAD;QACb,UAAA,EAAYlD,UAAD;QACX,UAAA,EAAYC,WAAD;MATjB,CAYV,CACA,CAlIE,CAmIF;CAEC;AAED,MAAMgF,0CAAoB,GAAG,IAAM;IACjC,qBACE,2BAAC,wBAAD;QAAmB,SAAA,EAAW,EAAD;qBAC3B,2BAAC,uBAAD;QAAkB,aAAA,EAAe,CAAD;MAAtC,CAFE,CAGF;CAJA,A,EAQA,kFAFC;AAGD,SAASxC,mCAAa,CACpB/C,SADF,EAEED,KAFF,EAGyC;IACvC,OAAOC,SAAP,CAAA;CACD;AAOM,MAAM3B,yCAAY,iBAAGE,YAAK,CAACiH,UAAN,CAAiB/D,mCAAjB,CAAA,AAArB,AACsC;;ADnZ7C","sources":["packages/components/autocomplete/src/index.ts","packages/components/autocomplete/src/Autocomplete.tsx","packages/components/autocomplete/src/AutocompleteItems.tsx","packages/components/autocomplete/src/Autocomplete.styles.ts"],"sourcesContent":["export { Autocomplete } from './Autocomplete';\nexport type { AutocompleteProps } from './Autocomplete';\n","import React, { useCallback, useState } from 'react';\nimport { cx } from 'emotion';\nimport { useCombobox } from 'downshift';\n\nimport { mergeRefs } from '@contentful/f36-core';\nimport type { CommonProps, ExpandProps } from '@contentful/f36-core';\nimport { IconButton } from '@contentful/f36-button';\nimport { TextInput } from '@contentful/f36-forms';\nimport type { TextInputProps } from '@contentful/f36-forms';\nimport { CloseIcon, ChevronDownIcon } from '@contentful/f36-icons';\nimport { SkeletonContainer, SkeletonBodyText } from '@contentful/f36-skeleton';\nimport { Popover } from '@contentful/f36-popover';\nimport { Subheading, SectionHeading } from '@contentful/f36-typography';\n\nimport { AutocompleteItems } from './AutocompleteItems';\nimport { getAutocompleteStyles } from './Autocomplete.styles';\n\nexport interface GenericGroupType<ItemType> {\n groupTitle: string;\n options: ItemType[];\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface AutocompleteProps<ItemType>\n extends CommonProps,\n Pick<\n TextInputProps,\n | 'isDisabled'\n | 'isInvalid'\n | 'isReadOnly'\n | 'isRequired'\n | 'id'\n | 'defaultValue'\n > {\n /**\n * It’s an array of data to be used as \"options\" by the autocomplete component.\n * This can either be a plain list of items or a list of groups of items.\n */\n items: ItemType[] | GenericGroupType<ItemType>[];\n\n /**\n * Tells if the item is a object with groups\n */\n isGrouped?: boolean;\n\n /**\n * Function called whenever the input value changes\n */\n onInputValueChange?: (value: string) => void;\n /**\n * This is the function that will be called when the user selects one of the \"options\" in the list.\n * The component will pass the selected \"item\" as an argument to the function..\n */\n onSelectItem: (item: ItemType) => void;\n\n /**\n * Applying the selectedItem property turns autocomplete into a controlled component.\n * Can be used to display e.g. previously selected element. If it is an object the itemToString function will apply to it.\n */\n selectedItem?: ItemType;\n\n /**\n * This is the function that will be called for each \"item\" passed in the `items` prop.\n * It receives the \"item\" and \"inputValue\" as arguments and returns a ReactNode.\n * The inputValue is passed in case you want to highlight the match on the render.\n */\n renderItem?: (item: ItemType, inputValue: string) => React.ReactNode;\n /**\n * When using objects as `items`, we recommend passing a function that tells Downshift how to extract a string\n * from those objetcs to be used as inputValue\n */\n itemToString?: (item: ItemType) => string;\n /**\n * If this is set to `true` the text input will be cleared after an item is selected\n * @default false\n */\n clearAfterSelect?: boolean;\n /**\n * If this is set to `false` the dropdown menu will stay open after selecting an item\n * @default true\n */\n closeAfterSelect?: boolean;\n /**\n * This is the value will be passed to the `placeholder` prop of the input.\n * @default \"Search\"\n */\n placeholder?: string;\n /**\n * A message that will be shown when it is not possible to find any option that matches the input value\n * @default \"No matches\"\n */\n noMatchesMessage?: string;\n /**\n * Use this prop to get a ref to the input element of the component\n */\n inputRef?: React.Ref<HTMLInputElement>;\n /**\n * Use this prop to get a ref to the toggle button of the component\n */\n toggleRef?: React.Ref<HTMLButtonElement>;\n /**\n * Use this prop to get a ref to the list of items of the component\n */\n listRef?: React.Ref<HTMLUListElement>;\n /**\n * It sets the width of the list\n * @default \"auto\"\n */\n listWidth?: 'auto' | 'full';\n /**\n * It sets the max-height, in pixels, of the list\n * The default value is the height of 5 single line items\n * @default 180\n */\n listMaxHeight?: number;\n /**\n * Sets the list to show its loading state\n * @default false\n */\n isLoading?: boolean;\n /**\n * Boolean to control whether or not to render the suggestions box in a React Portal.\n * Rendering content inside a Portal allows the suggestions box to escape the bounds\n * of its parent while still being positioned correctly.\n * Defaults to `false`\n */\n usePortal?: boolean;\n}\n\nfunction _Autocomplete<ItemType>(\n props: AutocompleteProps<ItemType>,\n ref: React.Ref<HTMLDivElement>,\n) {\n const {\n id,\n className,\n clearAfterSelect = false,\n closeAfterSelect = true,\n defaultValue = '',\n selectedItem,\n items,\n onInputValueChange,\n onSelectItem,\n renderItem,\n itemToString = (item: ItemType) => (item as unknown) as string,\n isInvalid,\n isDisabled,\n isRequired,\n isReadOnly,\n noMatchesMessage = 'No matches found',\n placeholder = 'Search',\n inputRef,\n toggleRef,\n listRef,\n listWidth = 'auto',\n listMaxHeight = 180,\n isGrouped = false,\n isLoading = false,\n usePortal = false,\n testId = 'cf-autocomplete',\n } = props;\n\n type GroupType = GenericGroupType<ItemType>;\n\n const styles = getAutocompleteStyles(listMaxHeight);\n\n const [inputValue, setInputValue] = useState(defaultValue);\n\n const handleInputValueChange = useCallback(\n (value: string) => {\n setInputValue(value);\n\n onInputValueChange?.(value);\n },\n [onInputValueChange],\n );\n\n // Handle manually to avoid a jumping cursor, see https://github.com/downshift-js/downshift/issues/1108#issuecomment-842407759\n const handleNativeChangeEvent = useCallback(\n (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n const value = event.target.value;\n handleInputValueChange(value);\n },\n [handleInputValueChange],\n );\n\n const flattenItems = isUsingGroups(isGrouped, items)\n ? items.reduce(\n (acc: ItemType[], group: GroupType) => [...acc, ...group.options],\n [],\n )\n : items;\n\n const isShowingNoMatches = isUsingGroups(isGrouped, items)\n ? items.every((group: GroupType) => group.options.length === 0)\n : items.length === 0;\n\n const {\n getComboboxProps,\n getInputProps,\n getItemProps,\n getMenuProps,\n getToggleButtonProps,\n highlightedIndex,\n isOpen,\n toggleMenu,\n } = useCombobox({\n items: flattenItems,\n selectedItem,\n inputValue,\n itemToString,\n onInputValueChange: ({ type, inputValue }) => {\n if (type !== '__input_change__') {\n handleInputValueChange(inputValue);\n }\n },\n onStateChange: ({ type, selectedItem }) => {\n switch (type) {\n case useCombobox.stateChangeTypes.InputKeyDownEnter:\n case useCombobox.stateChangeTypes.ItemClick:\n if (selectedItem) {\n onSelectItem(selectedItem);\n }\n if (clearAfterSelect) {\n handleInputValueChange('');\n }\n if (!closeAfterSelect) {\n toggleMenu();\n }\n break;\n default:\n break;\n }\n },\n });\n\n const {\n 'aria-labelledby': _labelledby,\n id: _inputId,\n ...inputProps\n } = getInputProps();\n const comboboxProps = getComboboxProps();\n const toggleProps = getToggleButtonProps();\n const menuProps = getMenuProps();\n let elementStartIndex = 0;\n\n return (\n <div\n data-test-id={testId}\n className={cx(styles.autocomplete, className)}\n ref={ref}\n >\n <Popover\n usePortal={usePortal}\n isOpen={isOpen}\n isFullWidth={listWidth === 'full'}\n renderOnlyWhenOpen={false}\n // This is necessary, otherwise the focus will change from the input to the Popover\n // and the user won't be able to type in the input\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={false}\n id={menuProps.id}\n >\n <Popover.Trigger>\n <div {...comboboxProps} className={styles.combobox}>\n <TextInput\n className={styles.inputField}\n {...inputProps}\n onFocus={() => {\n if (!isOpen) {\n toggleMenu();\n }\n }}\n id={id}\n isInvalid={isInvalid}\n isDisabled={isDisabled}\n isRequired={isRequired}\n isReadOnly={isReadOnly}\n ref={mergeRefs(inputProps.ref, inputRef)}\n testId=\"cf-autocomplete-input\"\n placeholder={placeholder}\n onChange={(event) => {\n inputProps.onChange(event);\n handleNativeChangeEvent(event);\n }}\n />\n <IconButton\n {...toggleProps}\n ref={mergeRefs(toggleProps.ref, toggleRef)}\n aria-label=\"toggle menu\"\n className={styles.toggleButton}\n variant=\"transparent\"\n icon={\n inputValue ? (\n <CloseIcon aria-label=\"Clear\" variant=\"muted\" />\n ) : (\n <ChevronDownIcon aria-label=\"Show list\" variant=\"muted\" />\n )\n }\n onClick={() => {\n if (inputValue) {\n handleInputValueChange('');\n } else {\n toggleMenu();\n }\n }}\n isDisabled={isDisabled}\n size=\"small\"\n />\n </div>\n </Popover.Trigger>\n\n <Popover.Content\n {...menuProps}\n ref={mergeRefs(menuProps.ref, listRef)}\n className={styles.content}\n testId=\"cf-autocomplete-container\"\n >\n {isLoading &&\n [...Array(3)].map((_, index) => (\n <div key={index} className={cx(styles.item, styles.disabled)}>\n <ListItemLoadingState />\n </div>\n ))}\n\n {!isLoading && isShowingNoMatches && (\n <div className={styles.item}>\n <Subheading className={styles.noMatchesTitle}>\n {noMatchesMessage}\n </Subheading>\n </div>\n )}\n\n {!isLoading &&\n isUsingGroups(isGrouped, items) &&\n items.map((group: GroupType, index: number) => {\n if (group.options.length < 1) {\n return;\n }\n const render = (\n <div key={index}>\n <SectionHeading\n key={index}\n data-test-id=\"cf-autocomplete-grouptitle\"\n marginBottom=\"none\"\n className={styles.groupTitle}\n >\n {group.groupTitle}\n </SectionHeading>\n <AutocompleteItems<ItemType>\n items={group.options}\n highlightedIndex={highlightedIndex}\n getItemProps={getItemProps}\n renderItem={renderItem}\n inputValue={inputValue}\n elementStartIndex={elementStartIndex}\n />\n </div>\n );\n elementStartIndex += group.options.length;\n return render;\n })}\n\n {!isLoading &&\n !isUsingGroups(isGrouped, items) &&\n items.length > 0 && (\n <AutocompleteItems<ItemType>\n items={items}\n elementStartIndex={elementStartIndex}\n highlightedIndex={highlightedIndex}\n getItemProps={getItemProps}\n renderItem={renderItem}\n inputValue={inputValue}\n />\n )}\n </Popover.Content>\n </Popover>\n </div>\n );\n}\n\nconst ListItemLoadingState = () => {\n return (\n <SkeletonContainer svgHeight={16}>\n <SkeletonBodyText numberOfLines={1} />\n </SkeletonContainer>\n );\n};\n\n// This is required to infer correct typings when differentiating groups and items\nfunction isUsingGroups<ItemType>(\n isGrouped: boolean,\n items: ItemType[] | GenericGroupType<ItemType>[],\n): items is GenericGroupType<ItemType>[] {\n return isGrouped;\n}\n\n/**\n * The Autocomplete is a component that will show a `TextInput` where a user can type any word which will be used\n * to filter a list of items. That list of filtered items will be shown to the user as possible options for the input.\n * Once one of the options is selected, that option becomes the value of the `TextInput`.\n */\nexport const Autocomplete = React.forwardRef(_Autocomplete) as <T>(\n props: ExpandProps<AutocompleteProps<T>> & {\n ref?: React.Ref<HTMLDivElement>;\n },\n) => ReturnType<typeof _Autocomplete>;\n","import React, { HTMLAttributes } from 'react';\nimport { cx } from 'emotion';\n\nimport { getStringMatch } from '@contentful/f36-utils';\nimport { Text } from '@contentful/f36-typography';\nimport { getAutocompleteStyles } from './Autocomplete.styles';\nimport type { UseComboboxGetItemPropsOptions } from 'downshift';\n\ninterface AutocompleteItemsProps<ItemType> {\n items: ItemType[];\n elementStartIndex: number;\n highlightedIndex: number;\n getItemProps: (\n options: UseComboboxGetItemPropsOptions<ItemType>,\n ) => HTMLAttributes<HTMLLIElement>;\n renderItem: (item: ItemType, inputValue: string) => React.ReactNode;\n inputValue: string;\n listMaxHeight?: number;\n}\n\nexport const AutocompleteItems = <ItemType,>(\n props: AutocompleteItemsProps<ItemType>,\n) => {\n const {\n items,\n elementStartIndex,\n highlightedIndex,\n getItemProps,\n renderItem,\n inputValue,\n listMaxHeight = 180,\n } = props;\n\n const styles = getAutocompleteStyles(listMaxHeight);\n\n return (\n <ul className={styles.list} data-test-id=\"cf-autocomplete-list\">\n {items.map((item: ItemType, index: number) => {\n const itemIndex = elementStartIndex + index;\n const itemProps = getItemProps({ item, index: itemIndex });\n return (\n <Text\n {...itemProps}\n as=\"li\"\n key={itemIndex}\n className={cx([\n styles.item,\n highlightedIndex === itemIndex && styles.highlighted,\n ])}\n data-test-id={`cf-autocomplete-list-item-${itemIndex}`}\n >\n {renderItem ? (\n renderItem(item, inputValue)\n ) : typeof item === 'string' ? (\n <HighlightedItem item={item} inputValue={inputValue} />\n ) : (\n item\n )}\n </Text>\n );\n })}\n </ul>\n );\n};\n\nAutocompleteItems.displayName = 'AutocompleteItems';\n\nfunction HighlightedItem({\n item,\n inputValue,\n}: {\n item: string;\n inputValue: string;\n}) {\n const { before, match, after } = getStringMatch(item, inputValue);\n\n return (\n <>\n {before}\n <b>{match}</b>\n {after}\n </>\n );\n}\n\nHighlightedItem.displayName = 'HighlightedItem';\n","import { css } from 'emotion';\nimport tokens from '@contentful/f36-tokens';\n\nexport const getAutocompleteStyles = (listMaxHeight: number) => ({\n autocomplete: css({\n position: 'relative',\n width: '100%',\n }),\n combobox: css({\n position: 'relative',\n }),\n inputField: css({\n paddingRight: tokens.spacingXl,\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n }),\n toggleButton: css({\n position: 'absolute',\n top: '1px',\n right: '1px',\n zIndex: 1,\n padding: tokens.spacing2Xs,\n height: '38px',\n }),\n content: css({\n overflow: 'auto',\n maxHeight: `${listMaxHeight}px`,\n }),\n list: css({\n listStyle: 'none',\n padding: `${tokens.spacingXs} 0`,\n margin: 0,\n }),\n groupTitle: css({\n padding: `${tokens.spacingXs} ${tokens.spacingM}`,\n lineHeight: tokens.lineHeightM,\n }),\n noMatchesTitle: css({\n color: tokens.gray500,\n margin: `${tokens.spacingM} 0 ${tokens.spacingM} 0`,\n }),\n item: css({\n display: 'block',\n padding: `${tokens.spacingXs} ${tokens.spacingM}`,\n wordBreak: 'break-word',\n whiteSpace: 'break-spaces',\n cursor: 'pointer',\n hyphens: 'auto',\n\n '&:focus, &:hover': {\n backgroundColor: tokens.gray100,\n },\n '&:active': {\n backgroundColor: tokens.gray200,\n },\n }),\n disabled: css({\n opacity: 0.5,\n pointerEvents: 'none',\n }),\n highlighted: css({\n backgroundColor: tokens.gray100,\n }),\n});\n"],"names":["Autocomplete","AutocompleteProps","React","useCallback","useState","useCombobox","mergeRefs","CommonProps","ExpandProps","IconButton","TextInput","TextInputProps","CloseIcon","ChevronDownIcon","SkeletonContainer","SkeletonBodyText","Popover","Subheading","SectionHeading","AutocompleteItems","getAutocompleteStyles","GenericGroupType","groupTitle","options","ItemType","Pick","items","isGrouped","onInputValueChange","value","onSelectItem","item","selectedItem","renderItem","inputValue","ReactNode","itemToString","clearAfterSelect","closeAfterSelect","placeholder","noMatchesMessage","inputRef","Ref","HTMLInputElement","toggleRef","HTMLButtonElement","listRef","HTMLUListElement","listWidth","listMaxHeight","isLoading","usePortal","_Autocomplete","props","ref","HTMLDivElement","id","className","defaultValue","isInvalid","isDisabled","isRequired","isReadOnly","testId","GroupType","styles","setInputValue","handleInputValueChange","handleNativeChangeEvent","event","ChangeEvent","HTMLTextAreaElement","target","flattenItems","isUsingGroups","reduce","acc","group","isShowingNoMatches","every","length","getComboboxProps","getInputProps","getItemProps","getMenuProps","getToggleButtonProps","highlightedIndex","isOpen","toggleMenu","type","onStateChange","stateChangeTypes","InputKeyDownEnter","ItemClick","_labelledby","_inputId","inputProps","comboboxProps","toggleProps","menuProps","elementStartIndex","autocomplete","combobox","inputField","onChange","toggleButton","content","Array","map","_","index","disabled","noMatchesTitle","render","ListItemLoadingState","forwardRef","T","ReturnType","HTMLAttributes","getStringMatch","Text","UseComboboxGetItemPropsOptions","AutocompleteItemsProps","HTMLLIElement","list","itemIndex","itemProps","highlighted","displayName","HighlightedItem","before","match","after","tokens","paddingRight","spacingXl","textOverflow","whiteSpace","position","top","right","zIndex","padding","spacing2Xs","height","overflow","maxHeight","listStyle","spacingXs","margin","spacingM","lineHeight","lineHeightM","color","gray500","display","wordBreak","cursor","hyphens","backgroundColor","gray100","gray200"],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -45,6 +45,11 @@ export interface AutocompleteProps<ItemType> extends CommonProps, Pick<TextInput
|
|
|
45
45
|
* @default false
|
|
46
46
|
*/
|
|
47
47
|
clearAfterSelect?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* If this is set to `false` the dropdown menu will stay open after selecting an item
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
52
|
+
closeAfterSelect?: boolean;
|
|
48
53
|
/**
|
|
49
54
|
* This is the value will be passed to the `placeholder` prop of the input.
|
|
50
55
|
* @default "Search"
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AEiBA,2BAAkC,QAAQ;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,QAAQ,EAAE,CAAC;CACrB;AAGD,mCAAmC,QAAQ,CACzC,SAAQ,WAAW,EACjB,IAAI,CACF,cAAc,EACZ,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,IAAI,GACJ,cAAc,CACjB;IACH;;;OAGG;IACH,KAAK,EAAE,QAAQ,EAAE,GAAG,iBAAiB,QAAQ,CAAC,EAAE,CAAC;IAEjD;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C;;;OAGG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IAEvC;;;OAGG;IACH,YAAY,CAAC,EAAE,QAAQ,CAAC;IAExB;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,KAAK,MAAM,SAAS,CAAC;IACrE;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,MAAM,CAAC;IAC1C;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;O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AAE,QAAQ,CAAC;IAExB;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,KAAK,MAAM,SAAS,CAAC;IACrE;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,MAAM,CAAC;IAC1C;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACvC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACzC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACtC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,+BAAuB,QAAQ,EAC7B,KAAK,EAAE,kBAAkB,QAAQ,CAAC,EAClC,GAAG,EAAE,MAAM,GAAG,CAAC,cAAc,CAAC,eAwP/B;AAkBD;;;;GAIG;AACH,OAAO,MAAM;UAEH,MAAM,GAAG,CAAC,cAAc,CAAC;MAE9B,WAAW,oBAAoB,CAAC,CAAC","sources":["packages/components/autocomplete/src/src/Autocomplete.styles.ts","packages/components/autocomplete/src/src/AutocompleteItems.tsx","packages/components/autocomplete/src/src/Autocomplete.tsx","packages/components/autocomplete/src/src/index.ts","packages/components/autocomplete/src/index.ts"],"sourcesContent":[null,null,null,null,"export { Autocomplete } from './Autocomplete';\nexport type { AutocompleteProps } from './Autocomplete';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/f36-autocomplete",
|
|
3
|
-
"version": "4.10.
|
|
3
|
+
"version": "4.10.5",
|
|
4
4
|
"description": "Forma 36: Autocomplete component",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "parcel build"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@babel/runtime": "^7.6.2",
|
|
10
|
-
"@contentful/f36-button": "^4.10.
|
|
11
|
-
"@contentful/f36-core": "^4.10.
|
|
12
|
-
"@contentful/f36-forms": "^4.10.
|
|
13
|
-
"@contentful/f36-icons": "^4.10.
|
|
14
|
-
"@contentful/f36-popover": "^4.10.
|
|
15
|
-
"@contentful/f36-skeleton": "^4.10.
|
|
10
|
+
"@contentful/f36-button": "^4.10.5",
|
|
11
|
+
"@contentful/f36-core": "^4.10.5",
|
|
12
|
+
"@contentful/f36-forms": "^4.10.5",
|
|
13
|
+
"@contentful/f36-icons": "^4.10.5",
|
|
14
|
+
"@contentful/f36-popover": "^4.10.5",
|
|
15
|
+
"@contentful/f36-skeleton": "^4.10.5",
|
|
16
16
|
"@contentful/f36-tokens": "^4.0.1",
|
|
17
|
-
"@contentful/f36-typography": "^4.10.
|
|
18
|
-
"@contentful/f36-utils": "^4.10.
|
|
17
|
+
"@contentful/f36-typography": "^4.10.5",
|
|
18
|
+
"@contentful/f36-utils": "^4.10.5",
|
|
19
19
|
"downshift": "^6.1.7",
|
|
20
20
|
"emotion": "^10.0.17"
|
|
21
21
|
},
|