@contentful/f36-autocomplete 4.20.6 → 4.20.8

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/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import n, { useState, useCallback } from 'react';
1
+ import i, { useState, useCallback } from 'react';
2
2
  import { cx, css } from 'emotion';
3
3
  import { useCombobox } from 'downshift';
4
4
  import { mergeRefs } from '@contentful/f36-core';
@@ -11,7 +11,7 @@ import { Subheading, SectionHeading, Text } from '@contentful/f36-typography';
11
11
  import { getStringMatch } from '@contentful/f36-utils';
12
12
  import p from '@contentful/f36-tokens';
13
13
 
14
- var be=Object.defineProperty,xe=Object.defineProperties;var ve=Object.getOwnPropertyDescriptors;var P=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable;var X=(e,o,i)=>o in e?be(e,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[o]=i,g=(e,o)=>{for(var i in o||(o={}))U.call(o,i)&&X(e,i,o[i]);if(P)for(var i of P(o))W.call(o,i)&&X(e,i,o[i]);return e},h=(e,o)=>xe(e,ve(o));var q=(e,o)=>{var i={};for(var r in e)U.call(e,r)&&o.indexOf(r)<0&&(i[r]=e[r]);if(e!=null&&P)for(var r of P(e))o.indexOf(r)<0&&W.call(e,r)&&(i[r]=e[r]);return i};var S=e=>({autocomplete:css({position:"relative",width:"100%"}),combobox:css({position:"relative"}),inputField:css({paddingRight:p.spacingXl,textOverflow:"ellipsis",whiteSpace:"nowrap"}),toggleButton:css({position:"absolute",top:"1px",right:"1px",zIndex:1,padding:p.spacing2Xs,height:"38px"}),content:css({overflow:"auto",maxHeight:`${e}px`}),list:css({listStyle:"none",padding:`${p.spacingXs} 0`,margin:0}),groupTitle:css({padding:`${p.spacingXs} ${p.spacingM}`,lineHeight:p.lineHeightM}),noMatchesTitle:css({color:p.gray500,margin:`${p.spacingM} 0 ${p.spacingM} 0`}),item:css({display:"block",padding:`${p.spacingXs} ${p.spacingM}`,wordBreak:"break-word",whiteSpace:"break-spaces",cursor:"pointer",hyphens:"auto","&:focus, &:hover":{backgroundColor:p.gray100},"&:active":{backgroundColor:p.gray200}}),disabled:css({opacity:.5,pointerEvents:"none"}),highlighted:css({backgroundColor:p.gray100})});var M=e=>{let{items:o,elementStartIndex:i,highlightedIndex:r,getItemProps:I,renderItem:T,inputValue:b,listMaxHeight:A=180}=e,s=S(A);return n.createElement("ul",{className:s.list,"data-test-id":"cf-autocomplete-list"},o.map((m,H)=>{let c=i+H,k=I({item:m,index:c});return n.createElement(Text,h(g({},k),{as:"li",key:c,className:cx([s.item,r===c&&s.highlighted]),"data-test-id":`cf-autocomplete-list-item-${c}`}),T?T(m,b):typeof m=="string"?n.createElement(z,{item:m,inputValue:b}):m)}))};M.displayName="AutocompleteItems";function z({item:e,inputValue:o}){let{before:i,match:r,after:I}=getStringMatch(e,o);return n.createElement(n.Fragment,null,i,n.createElement("b",null,r),I)}z.displayName="HighlightedItem";function Le(e,o){let {id:i,className:r,clearAfterSelect:I=!1,closeAfterSelect:T=!0,defaultValue:b="",selectedItem:A,items:s,onInputValueChange:m,onSelectItem:H,renderItem:c,icon:k=n.createElement(ChevronDownIcon,{variant:"muted"}),itemToString:Q=t=>t,isInvalid:Y,isDisabled:R,isRequired:Z,isReadOnly:ee,noMatchesMessage:te="No matches found",placeholder:oe="Search",inputRef:ie,toggleRef:ne,listRef:se,listWidth:re="auto",listMaxHeight:pe=180,isGrouped:x=!1,isLoading:v=!1,usePortal:ae=!1,testId:le="cf-autocomplete"}=e,u=S(pe),[d,me]=useState(b),y=useCallback(t=>{me(t),m==null||m(t);},[m]),ue=useCallback(t=>{let a=t.target.value;y(a);},[y]),ce=C(x)?s.reduce((t,a)=>[...t,...a.options],[]):s,de=C(x)?s.every(t=>t.options.length===0):s.length===0,{getComboboxProps:ge,getInputProps:he,getItemProps:_,getMenuProps:fe,getToggleButtonProps:Ie,highlightedIndex:$,isOpen:B,toggleMenu:w}=useCombobox({items:ce,selectedItem:A,inputValue:d,itemToString:Q,onInputValueChange:({type:t,inputValue:a})=>{t!=="__input_change__"&&y(a);},onStateChange:({type:t,selectedItem:a})=>{switch(t){case useCombobox.stateChangeTypes.InputKeyDownEnter:case useCombobox.stateChangeTypes.ItemClick:a&&H(a),I&&y(""),T||w();break;}}}),F=he(),G=q(F,["aria-labelledby","id"]),ye=ge(),D=Ie(),N=fe(),L=0;return n.createElement("div",{"data-test-id":le,className:cx(u.autocomplete,r),ref:o},n.createElement(Popover,{usePortal:ae,isOpen:B,isFullWidth:re==="full",renderOnlyWhenOpen:!1,autoFocus:!1,id:N.id},n.createElement(Popover.Trigger,null,n.createElement("div",h(g({},ye),{className:u.combobox}),n.createElement(TextInput,h(g({className:u.inputField},G),{onFocus:()=>{B||w();},id:i,isInvalid:Y,isDisabled:R,isRequired:Z,isReadOnly:ee,ref:mergeRefs(G.ref,ie),testId:"cf-autocomplete-input",placeholder:oe,onChange:t=>{G.onChange(t),ue(t);}})),n.createElement(IconButton,h(g({},D),{ref:mergeRefs(D.ref,ne),"aria-label":d?"Clear":"Show list",className:u.toggleButton,variant:"transparent",icon:d?n.createElement(CloseIcon,{variant:"muted"}):k,onClick:()=>{d?y(""):w();},isDisabled:R,size:"small"})))),(s.length>0||d.length>0)&&n.createElement(Popover.Content,h(g({},N),{ref:mergeRefs(N.ref,se),className:u.content,testId:"cf-autocomplete-container"}),v&&[...Array(3)].map((t,a)=>n.createElement("div",{key:a,className:cx(u.item,u.disabled)},n.createElement(Ee,null))),!v&&de&&n.createElement("div",{className:u.item},n.createElement(Subheading,{className:u.noMatchesTitle},te)),!v&&C(x)&&s.map((t,a)=>{if(t.options.length<1)return;let Te=n.createElement("div",{key:a},n.createElement(SectionHeading,{key:a,"data-test-id":"cf-autocomplete-grouptitle",marginBottom:"none",className:u.groupTitle},t.groupTitle),n.createElement(M,{items:t.options,highlightedIndex:$,getItemProps:_,renderItem:c,inputValue:d,elementStartIndex:L}));return L+=t.options.length,Te}),!v&&!C(x)&&s.length>0&&n.createElement(M,{items:s,elementStartIndex:L,highlightedIndex:$,getItemProps:_,renderItem:c,inputValue:d}))))}var Ee=()=>n.createElement(Skeleton.Container,{svgHeight:16},n.createElement(Skeleton.BodyText,{numberOfLines:1}));function C(e,o){return e}var Ve=n.forwardRef(Le);
14
+ var xe=Object.defineProperty,ve=Object.defineProperties;var Pe=Object.getOwnPropertyDescriptors;var S=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var U=(e,o,n)=>o in e?xe(e,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[o]=n,c=(e,o)=>{for(var n in o||(o={}))W.call(o,n)&&U(e,n,o[n]);if(S)for(var n of S(o))q.call(o,n)&&U(e,n,o[n]);return e},d=(e,o)=>ve(e,Pe(o));var z=(e,o)=>{var n={};for(var r in e)W.call(e,r)&&o.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&S)for(var r of S(e))o.indexOf(r)<0&&q.call(e,r)&&(n[r]=e[r]);return n};var M=e=>({autocomplete:css({position:"relative",width:"100%"}),combobox:css({position:"relative"}),inputField:css({paddingRight:p.spacingXl,textOverflow:"ellipsis",whiteSpace:"nowrap"}),toggleButton:css({position:"absolute",top:"1px",right:"1px",zIndex:1,padding:p.spacing2Xs,height:"38px"}),content:css({overflow:"auto",maxHeight:`${e}px`}),list:css({listStyle:"none",padding:`${p.spacingXs} 0`,margin:0}),groupTitle:css({padding:`${p.spacingXs} ${p.spacingM}`,lineHeight:p.lineHeightM}),noMatchesTitle:css({color:p.gray500,margin:`${p.spacingM} 0 ${p.spacingM} 0`}),item:css({display:"block",padding:`${p.spacingXs} ${p.spacingM}`,wordBreak:"break-word",whiteSpace:"break-spaces",cursor:"pointer",hyphens:"auto","&:focus, &:hover":{backgroundColor:p.gray100},"&:active":{backgroundColor:p.gray200}}),disabled:css({opacity:.5,pointerEvents:"none"}),highlighted:css({backgroundColor:p.gray100}),hidden:css({display:"none"})});var C=e=>{let{items:o,elementStartIndex:n,highlightedIndex:r,getItemProps:I,renderItem:T,inputValue:b,listMaxHeight:H=180}=e,s=M(H);return i.createElement("ul",{className:s.list,"data-test-id":"cf-autocomplete-list"},o.map((u,k)=>{let g=n+k,w=I({item:u,index:g});return i.createElement(Text,d(c({},w),{as:"li",key:g,className:cx([s.item,r===g&&s.highlighted]),"data-test-id":`cf-autocomplete-list-item-${g}`}),T?T(u,b):typeof u=="string"?i.createElement(j,{item:u,inputValue:b}):u)}))};C.displayName="AutocompleteItems";function j({item:e,inputValue:o}){let{before:n,match:r,after:I}=getStringMatch(e,o);return i.createElement(i.Fragment,null,n,i.createElement("b",null,r),I)}j.displayName="HighlightedItem";function Ee(e,o){let {id:n,className:r,clearAfterSelect:I=!1,closeAfterSelect:T=!0,defaultValue:b="",selectedItem:H,items:s,onInputValueChange:u,onSelectItem:k,renderItem:g,icon:w=i.createElement(ChevronDownIcon,{variant:"muted"}),itemToString:Q=t=>t,isInvalid:Y,isDisabled:R,isRequired:Z,isReadOnly:ee,showEmptyList:te,noMatchesMessage:oe="No matches found",placeholder:ie="Search",inputRef:ne,toggleRef:se,listRef:re,listWidth:pe="auto",listMaxHeight:ae=180,isGrouped:x=!1,isLoading:v=!1,usePortal:le=!1,testId:me="cf-autocomplete"}=e,m=M(ae),[h,ue]=useState(b),y=useCallback(t=>{ue(t),u==null||u(t);},[u]),ce=useCallback(t=>{let a=t.target.value;y(a);},[y]),de=A(x)?s.reduce((t,a)=>[...t,...a.options],[]):s,ge=A(x)?s.every(t=>t.options.length===0):s.length===0,{getComboboxProps:he,getInputProps:fe,getItemProps:$,getMenuProps:Ie,getToggleButtonProps:ye,highlightedIndex:B,isOpen:D,toggleMenu:N}=useCombobox({items:de,selectedItem:H,inputValue:h,itemToString:Q,onInputValueChange:({type:t,inputValue:a})=>{t!=="__input_change__"&&y(a);},onStateChange:({type:t,selectedItem:a})=>{switch(t){case useCombobox.stateChangeTypes.InputKeyDownEnter:case useCombobox.stateChangeTypes.ItemClick:a&&k(a),I&&y(""),T||N();break;}}}),X=fe(),G=z(X,["aria-labelledby","id"]),Te=he(),F=ye(),P=Ie(),L=0;return i.createElement("div",{"data-test-id":me,className:cx(m.autocomplete,r),ref:o},i.createElement(Popover,{usePortal:le,isOpen:D,isFullWidth:pe==="full",renderOnlyWhenOpen:!1,autoFocus:!1,id:P.id},i.createElement(Popover.Trigger,null,i.createElement("div",d(c({},Te),{className:m.combobox}),i.createElement(TextInput,d(c({className:m.inputField},G),{onFocus:()=>{D||N();},id:n,isInvalid:Y,isDisabled:R,isRequired:Z,isReadOnly:ee,ref:mergeRefs(G.ref,ne),testId:"cf-autocomplete-input",placeholder:ie,onChange:t=>{G.onChange(t),ce(t);}})),i.createElement(IconButton,d(c({},F),{ref:mergeRefs(F.ref,se),"aria-label":h?"Clear":"Show list",className:m.toggleButton,variant:"transparent",icon:h?i.createElement(CloseIcon,{variant:"muted"}):w,onClick:()=>{h?y(""):N();},isDisabled:R,size:"small"})))),s.length>0||h.length>0||te?i.createElement(Popover.Content,d(c({},P),{ref:mergeRefs(P.ref,re),className:m.content,testId:"cf-autocomplete-container"}),v&&[...Array(3)].map((t,a)=>i.createElement("div",{key:a,className:cx(m.item,m.disabled)},i.createElement(Ve,null))),!v&&ge&&i.createElement("div",{className:m.item},i.createElement(Subheading,{className:m.noMatchesTitle},oe)),!v&&A(x)&&s.map((t,a)=>{if(t.options.length<1)return;let be=i.createElement("div",{key:a},i.createElement(SectionHeading,{key:a,"data-test-id":"cf-autocomplete-grouptitle",marginBottom:"none",className:m.groupTitle},t.groupTitle),i.createElement(C,{items:t.options,highlightedIndex:B,getItemProps:$,renderItem:g,inputValue:h,elementStartIndex:L}));return L+=t.options.length,be}),!v&&!A(x)&&s.length>0&&i.createElement(C,{items:s,elementStartIndex:L,highlightedIndex:B,getItemProps:$,renderItem:g,inputValue:h})):i.createElement("div",d(c({},P),{className:cx(m.hidden)}))))}var Ve=()=>i.createElement(Skeleton.Container,{svgHeight:16},i.createElement(Skeleton.BodyText,{numberOfLines:1}));function A(e,o){return e}var Oe=i.forwardRef(Ee);
15
15
 
16
- export { Ve as Autocomplete };
16
+ export { Oe as Autocomplete };
17
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Autocomplete.tsx","../../src/AutocompleteItems.tsx","../../src/Autocomplete.styles.ts"],"names":["React","useCallback","useState","cx","useCombobox","mergeRefs","IconButton","TextInput","CloseIcon","ChevronDownIcon","Skeleton","Popover","Subheading","SectionHeading","getStringMatch","Text","css","tokens","getAutocompleteStyles","listMaxHeight","AutocompleteItems","props","items","elementStartIndex","highlightedIndex","getItemProps","renderItem","inputValue","styles","item","index","itemIndex","itemProps","__spreadProps","__spreadValues","HighlightedItem","before","match","after","_Autocomplete","ref","id","className","clearAfterSelect","closeAfterSelect","defaultValue","selectedItem","onInputValueChange","onSelectItem","icon","itemToString","isInvalid","isDisabled","isRequired","isReadOnly","noMatchesMessage","placeholder","inputRef","toggleRef","listRef","listWidth","isGrouped","isLoading","usePortal","testId","setInputValue","handleInputValueChange","value","handleNativeChangeEvent","event","flattenItems","isUsingGroups","acc","group","isShowingNoMatches","getComboboxProps","getInputProps","getMenuProps","getToggleButtonProps","isOpen","toggleMenu","type","_a","_labelledby","_inputId","inputProps","__objRest","comboboxProps","toggleProps","menuProps","_","ListItemLoadingState","render","Autocomplete"],"mappings":"qlBAAA,OAAOA,GAAS,eAAAC,EAAa,YAAAC,OAAgB,QAC7C,OAAS,MAAAC,MAAU,UACnB,OAAS,eAAAC,MAAmB,YAE5B,OACE,aAAAC,MAGK,uBACP,OAAS,cAAAC,OAAkB,yBAC3B,OAAS,aAAAC,OAAsC,wBAC/C,OAAS,aAAAC,GAAW,mBAAAC,OAAuB,wBAC3C,OAAS,YAAAC,MAAgB,2BACzB,OAAS,WAAAC,MAAe,0BACxB,OAAS,cAAAC,GAAY,kBAAAC,OAAsB,6BCd3C,OAA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EACPV,EACAvC,EACuC,CACvC,OAAOuC,CACT,CAOO,IAAMgC,GAAe7F,EAAM,WAAWuC,EAAa","sourcesContent":["import React, { useCallback, useState } from 'react';\nimport { cx } from 'emotion';\nimport { useCombobox } from 'downshift';\n\nimport {\n mergeRefs,\n type CommonProps,\n type ExpandProps,\n} from '@contentful/f36-core';\nimport { IconButton } from '@contentful/f36-button';\nimport { TextInput, type TextInputProps } from '@contentful/f36-forms';\nimport { CloseIcon, ChevronDownIcon } from '@contentful/f36-icons';\nimport { Skeleton } 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 * Set a custom icon for the text input\n */\n icon?: React.ReactElement;\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 icon = <ChevronDownIcon variant=\"muted\" />,\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={inputValue ? 'Clear' : 'Show list'}\n className={styles.toggleButton}\n variant=\"transparent\"\n icon={inputValue ? <CloseIcon variant=\"muted\" /> : icon}\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 {(items.length > 0 || inputValue.length > 0) && (\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 )}\n </Popover>\n </div>\n );\n}\n\nconst ListItemLoadingState = () => {\n return (\n <Skeleton.Container svgHeight={16}>\n <Skeleton.BodyText numberOfLines={1} />\n </Skeleton.Container>\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';\nimport { getStringMatch } from '@contentful/f36-utils';\nimport type { UseComboboxGetItemPropsOptions } from 'downshift';\nimport { Text } from '@contentful/f36-typography';\n\nimport { getAutocompleteStyles } from './Autocomplete.styles';\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"]}
1
+ {"version":3,"sources":["../../src/Autocomplete.tsx","../../src/AutocompleteItems.tsx","../../src/Autocomplete.styles.ts"],"names":["React","useCallback","useState","cx","useCombobox","mergeRefs","IconButton","TextInput","CloseIcon","ChevronDownIcon","Skeleton","Popover","Subheading","SectionHeading","getStringMatch","Text","css","tokens","getAutocompleteStyles","listMaxHeight","AutocompleteItems","props","items","elementStartIndex","highlightedIndex","getItemProps","renderItem","inputValue","styles","item","index","itemIndex","itemProps","__spreadProps","__spreadValues","HighlightedItem","before","match","after","_Autocomplete","ref","id","className","clearAfterSelect","closeAfterSelect","defaultValue","selectedItem","onInputValueChange","onSelectItem","icon","itemToString","isInvalid","isDisabled","isRequired","isReadOnly","showEmptyList","noMatchesMessage","placeholder","inputRef","toggleRef","listRef","listWidth","isGrouped","isLoading","usePortal","testId","setInputValue","handleInputValueChange","value","handleNativeChangeEvent","event","flattenItems","isUsingGroups","acc","group","isShowingNoMatches","getComboboxProps","getInputProps","getMenuProps","getToggleButtonProps","isOpen","toggleMenu","type","_a","_labelledby","_inputId","inputProps","__objRest","comboboxProps","toggleProps","menuProps","_","ListItemLoadingState","render","Autocomplete"],"mappings":"qlBAAA,OAAOA,GAAS,eAAAC,EAAa,YAAAC,OAAgB,QAC7C,OAAS,MAAAC,MAAU,UACnB,OAAS,eAAAC,MAAmB,YAE5B,OACE,aAAAC,MAGK,uBACP,OAAS,cAAAC,OAAkB,yBAC3B,OAAS,aAAAC,OAAsC,wBAC/C,OAAS,aAAAC,GAAW,mBAAAC,OAAuB,wBAC3C,OAAS,YAAAC,MAAgB,2BACzB,OAAS,WAAAC,MAAe,0BACxB,OAAS,cAAAC,GAAY,kBAAAC,OAAsB,6BCd3C,OAAOb,MAA+B,QACtC,OAAS,MAAAG,OAAU,UACnB,OAAS,kBAAAW,OAAsB,wBAE/B,OAAS,QAAAC,OAAY,6BCJrB,OAAS,OAAAC,MAAW,UACpB,OAAOC,MAAY,yBAEZ,IAAMC,EAAyBC,IAA2B,CAC/D,aAAcH,EAAI,CAChB,SAAU,WACV,MAAO,MACT,CAAC,EACD,SAAUA,EAAI,CACZ,SAAU,UACZ,CAAC,EACD,WAAYA,EAAI,CACd,aAAcC,EAAO,UACrB,aAAc,WACd,WAAY,QACd,CAAC,EACD,aAAcD,EAAI,CAChB,SAAU,WACV,IAAK,MACL,MAAO,MACP,OAAQ,EACR,QAASC,EAAO,WAChB,OAAQ,MACV,CAAC,EACD,QAASD,EAAI,CACX,SAAU,OACV,UAAW,GAAGG,KAChB,CAAC,EACD,KAAMH,EAAI,CACR,UAAW,OACX,QAAS,GAAGC,EAAO,cACnB,OAAQ,CACV,CAAC,EACD,WAAYD,EAAI,CACd,QAAS,GAAGC,EAAO,aAAaA,EAAO,WACvC,WAAYA,EAAO,WACrB,CAAC,EACD,eAAgBD,EAAI,CAClB,MAAOC,EAAO,QACd,OAAQ,GAAGA,EAAO,cAAcA,EAAO,YACzC,CAAC,EACD,KAAMD,EAAI,CACR,QAAS,QACT,QAAS,GAAGC,EAAO,aAAaA,EAAO,WACvC,UAAW,aACX,WAAY,e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AYC,EACZ,WAAYC,EACZ,kBAAmBJ,EACrB,CACF,EAEF,OAAAA,GAAqBmD,EAAM,QAAQ,OAC5BmB,EACT,CAAC,EAEF,CAAC9B,GACA,CAACS,EAAcV,EAAWxC,CAAK,GAC/BA,EAAM,OAAS,GACbtB,EAAA,cAACoB,EAAA,CACC,MAAOE,EACP,kBAAmBC,EACnB,iBAAkBC,EAClB,aAAcC,EACd,WAAYC,EACZ,WAAYC,EACd,CAEN,EAIA3B,EAAA,cAAC,MAAAiC,EAAAC,EAAA,GAAQwD,GAAR,CAAmB,UAAWvF,EAAGyB,EAAO,MAAM,GAAG,CAEtD,CACF,CAEJ,CAEA,IAAMgE,GAAuB,IAEzB5F,EAAA,cAACU,EAAS,UAAT,CAAmB,UAAW,IAC7BV,EAAA,cAACU,EAAS,SAAT,CAAkB,cAAe,EAAG,CACvC,EAKJ,SAAS8D,EACPV,EACAxC,EACuC,CACvC,OAAOwC,CACT,CAOO,IAAMgC,GAAe9F,EAAM,WAAWuC,EAAa","sourcesContent":["import React, { useCallback, useState } from 'react';\nimport { cx } from 'emotion';\nimport { useCombobox } from 'downshift';\n\nimport {\n mergeRefs,\n type CommonProps,\n type ExpandProps,\n} from '@contentful/f36-core';\nimport { IconButton } from '@contentful/f36-button';\nimport { TextInput, type TextInputProps } from '@contentful/f36-forms';\nimport { CloseIcon, ChevronDownIcon } from '@contentful/f36-icons';\nimport { Skeleton } 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 * Set a custom icon for the text input\n */\n icon?: React.ReactElement;\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 * Defines if the list should be shown even if empty, when input is focused\n * @default false\n */\n showEmptyList?: boolean;\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 icon = <ChevronDownIcon variant=\"muted\" />,\n itemToString = (item: ItemType) => item as unknown as string,\n isInvalid,\n isDisabled,\n isRequired,\n isReadOnly,\n showEmptyList,\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={inputValue ? 'Clear' : 'Show list'}\n className={styles.toggleButton}\n variant=\"transparent\"\n icon={inputValue ? <CloseIcon variant=\"muted\" /> : icon}\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 {items.length > 0 || inputValue.length > 0 || showEmptyList ? (\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 ) : (\n // We need to render an empty hidden div, so we can pass the menuProps or downshift will show a warning about it\n // https://github.com/downshift-js/downshift/issues/1167#issuecomment-1088022842\n <div {...menuProps} className={cx(styles.hidden)} />\n )}\n </Popover>\n </div>\n );\n}\n\nconst ListItemLoadingState = () => {\n return (\n <Skeleton.Container svgHeight={16}>\n <Skeleton.BodyText numberOfLines={1} />\n </Skeleton.Container>\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';\nimport { getStringMatch } from '@contentful/f36-utils';\nimport type { UseComboboxGetItemPropsOptions } from 'downshift';\nimport { Text } from '@contentful/f36-typography';\n\nimport { getAutocompleteStyles } from './Autocomplete.styles';\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 hidden: css({\n display: 'none',\n }),\n});\n"]}
package/dist/index.d.ts CHANGED
@@ -60,6 +60,11 @@ interface AutocompleteProps<ItemType> extends CommonProps, Pick<TextInputProps,
60
60
  * @default "Search"
61
61
  */
62
62
  placeholder?: string;
63
+ /**
64
+ * Defines if the list should be shown even if empty, when input is focused
65
+ * @default false
66
+ */
67
+ showEmptyList?: boolean;
63
68
  /**
64
69
  * A message that will be shown when it is not possible to find any option that matches the input value
65
70
  * @default "No matches"
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var n = require('react');
5
+ var i = require('react');
6
6
  var emotion = require('emotion');
7
7
  var downshift = require('downshift');
8
8
  var f36Core = require('@contentful/f36-core');
@@ -17,10 +17,10 @@ var p = require('@contentful/f36-tokens');
17
17
 
18
18
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
19
 
20
- var n__default = /*#__PURE__*/_interopDefaultLegacy(n);
20
+ var i__default = /*#__PURE__*/_interopDefaultLegacy(i);
21
21
  var p__default = /*#__PURE__*/_interopDefaultLegacy(p);
22
22
 
23
- var be=Object.defineProperty,xe=Object.defineProperties;var ve=Object.getOwnPropertyDescriptors;var P=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable;var X=(e,o,i)=>o in e?be(e,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[o]=i,g=(e,o)=>{for(var i in o||(o={}))U.call(o,i)&&X(e,i,o[i]);if(P)for(var i of P(o))W.call(o,i)&&X(e,i,o[i]);return e},h=(e,o)=>xe(e,ve(o));var q=(e,o)=>{var i={};for(var r in e)U.call(e,r)&&o.indexOf(r)<0&&(i[r]=e[r]);if(e!=null&&P)for(var r of P(e))o.indexOf(r)<0&&W.call(e,r)&&(i[r]=e[r]);return i};var S=e=>({autocomplete:emotion.css({position:"relative",width:"100%"}),combobox:emotion.css({position:"relative"}),inputField:emotion.css({paddingRight:p__default["default"].spacingXl,textOverflow:"ellipsis",whiteSpace:"nowrap"}),toggleButton:emotion.css({position:"absolute",top:"1px",right:"1px",zIndex:1,padding:p__default["default"].spacing2Xs,height:"38px"}),content:emotion.css({overflow:"auto",maxHeight:`${e}px`}),list:emotion.css({listStyle:"none",padding:`${p__default["default"].spacingXs} 0`,margin:0}),groupTitle:emotion.css({padding:`${p__default["default"].spacingXs} ${p__default["default"].spacingM}`,lineHeight:p__default["default"].lineHeightM}),noMatchesTitle:emotion.css({color:p__default["default"].gray500,margin:`${p__default["default"].spacingM} 0 ${p__default["default"].spacingM} 0`}),item:emotion.css({display:"block",padding:`${p__default["default"].spacingXs} ${p__default["default"].spacingM}`,wordBreak:"break-word",whiteSpace:"break-spaces",cursor:"pointer",hyphens:"auto","&:focus, &:hover":{backgroundColor:p__default["default"].gray100},"&:active":{backgroundColor:p__default["default"].gray200}}),disabled:emotion.css({opacity:.5,pointerEvents:"none"}),highlighted:emotion.css({backgroundColor:p__default["default"].gray100})});var M=e=>{let{items:o,elementStartIndex:i,highlightedIndex:r,getItemProps:I,renderItem:T,inputValue:b,listMaxHeight:A=180}=e,s=S(A);return n__default["default"].createElement("ul",{className:s.list,"data-test-id":"cf-autocomplete-list"},o.map((m,H)=>{let c=i+H,k=I({item:m,index:c});return n__default["default"].createElement(f36Typography.Text,h(g({},k),{as:"li",key:c,className:emotion.cx([s.item,r===c&&s.highlighted]),"data-test-id":`cf-autocomplete-list-item-${c}`}),T?T(m,b):typeof m=="string"?n__default["default"].createElement(z,{item:m,inputValue:b}):m)}))};M.displayName="AutocompleteItems";function z({item:e,inputValue:o}){let{before:i,match:r,after:I}=f36Utils.getStringMatch(e,o);return n__default["default"].createElement(n__default["default"].Fragment,null,i,n__default["default"].createElement("b",null,r),I)}z.displayName="HighlightedItem";function Le(e,o){let {id:i,className:r,clearAfterSelect:I=!1,closeAfterSelect:T=!0,defaultValue:b="",selectedItem:A,items:s,onInputValueChange:m,onSelectItem:H,renderItem:c,icon:k=n__default["default"].createElement(f36Icons.ChevronDownIcon,{variant:"muted"}),itemToString:Q=t=>t,isInvalid:Y,isDisabled:R,isRequired:Z,isReadOnly:ee,noMatchesMessage:te="No matches found",placeholder:oe="Search",inputRef:ie,toggleRef:ne,listRef:se,listWidth:re="auto",listMaxHeight:pe=180,isGrouped:x=!1,isLoading:v=!1,usePortal:ae=!1,testId:le="cf-autocomplete"}=e,u=S(pe),[d,me]=n.useState(b),y=n.useCallback(t=>{me(t),m==null||m(t);},[m]),ue=n.useCallback(t=>{let a=t.target.value;y(a);},[y]),ce=C(x)?s.reduce((t,a)=>[...t,...a.options],[]):s,de=C(x)?s.every(t=>t.options.length===0):s.length===0,{getComboboxProps:ge,getInputProps:he,getItemProps:_,getMenuProps:fe,getToggleButtonProps:Ie,highlightedIndex:$,isOpen:B,toggleMenu:w}=downshift.useCombobox({items:ce,selectedItem:A,inputValue:d,itemToString:Q,onInputValueChange:({type:t,inputValue:a})=>{t!=="__input_change__"&&y(a);},onStateChange:({type:t,selectedItem:a})=>{switch(t){case downshift.useCombobox.stateChangeTypes.InputKeyDownEnter:case downshift.useCombobox.stateChangeTypes.ItemClick:a&&H(a),I&&y(""),T||w();break;}}}),F=he(),G=q(F,["aria-labelledby","id"]),ye=ge(),D=Ie(),N=fe(),L=0;return n__default["default"].createElement("div",{"data-test-id":le,className:emotion.cx(u.autocomplete,r),ref:o},n__default["default"].createElement(f36Popover.Popover,{usePortal:ae,isOpen:B,isFullWidth:re==="full",renderOnlyWhenOpen:!1,autoFocus:!1,id:N.id},n__default["default"].createElement(f36Popover.Popover.Trigger,null,n__default["default"].createElement("div",h(g({},ye),{className:u.combobox}),n__default["default"].createElement(f36Forms.TextInput,h(g({className:u.inputField},G),{onFocus:()=>{B||w();},id:i,isInvalid:Y,isDisabled:R,isRequired:Z,isReadOnly:ee,ref:f36Core.mergeRefs(G.ref,ie),testId:"cf-autocomplete-input",placeholder:oe,onChange:t=>{G.onChange(t),ue(t);}})),n__default["default"].createElement(f36Button.IconButton,h(g({},D),{ref:f36Core.mergeRefs(D.ref,ne),"aria-label":d?"Clear":"Show list",className:u.toggleButton,variant:"transparent",icon:d?n__default["default"].createElement(f36Icons.CloseIcon,{variant:"muted"}):k,onClick:()=>{d?y(""):w();},isDisabled:R,size:"small"})))),(s.length>0||d.length>0)&&n__default["default"].createElement(f36Popover.Popover.Content,h(g({},N),{ref:f36Core.mergeRefs(N.ref,se),className:u.content,testId:"cf-autocomplete-container"}),v&&[...Array(3)].map((t,a)=>n__default["default"].createElement("div",{key:a,className:emotion.cx(u.item,u.disabled)},n__default["default"].createElement(Ee,null))),!v&&de&&n__default["default"].createElement("div",{className:u.item},n__default["default"].createElement(f36Typography.Subheading,{className:u.noMatchesTitle},te)),!v&&C(x)&&s.map((t,a)=>{if(t.options.length<1)return;let Te=n__default["default"].createElement("div",{key:a},n__default["default"].createElement(f36Typography.SectionHeading,{key:a,"data-test-id":"cf-autocomplete-grouptitle",marginBottom:"none",className:u.groupTitle},t.groupTitle),n__default["default"].createElement(M,{items:t.options,highlightedIndex:$,getItemProps:_,renderItem:c,inputValue:d,elementStartIndex:L}));return L+=t.options.length,Te}),!v&&!C(x)&&s.length>0&&n__default["default"].createElement(M,{items:s,elementStartIndex:L,highlightedIndex:$,getItemProps:_,renderItem:c,inputValue:d}))))}var Ee=()=>n__default["default"].createElement(f36Skeleton.Skeleton.Container,{svgHeight:16},n__default["default"].createElement(f36Skeleton.Skeleton.BodyText,{numberOfLines:1}));function C(e,o){return e}var Ve=n__default["default"].forwardRef(Le);
23
+ var xe=Object.defineProperty,ve=Object.defineProperties;var Pe=Object.getOwnPropertyDescriptors;var S=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var U=(e,o,n)=>o in e?xe(e,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[o]=n,c=(e,o)=>{for(var n in o||(o={}))W.call(o,n)&&U(e,n,o[n]);if(S)for(var n of S(o))q.call(o,n)&&U(e,n,o[n]);return e},d=(e,o)=>ve(e,Pe(o));var z=(e,o)=>{var n={};for(var r in e)W.call(e,r)&&o.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&S)for(var r of S(e))o.indexOf(r)<0&&q.call(e,r)&&(n[r]=e[r]);return n};var M=e=>({autocomplete:emotion.css({position:"relative",width:"100%"}),combobox:emotion.css({position:"relative"}),inputField:emotion.css({paddingRight:p__default["default"].spacingXl,textOverflow:"ellipsis",whiteSpace:"nowrap"}),toggleButton:emotion.css({position:"absolute",top:"1px",right:"1px",zIndex:1,padding:p__default["default"].spacing2Xs,height:"38px"}),content:emotion.css({overflow:"auto",maxHeight:`${e}px`}),list:emotion.css({listStyle:"none",padding:`${p__default["default"].spacingXs} 0`,margin:0}),groupTitle:emotion.css({padding:`${p__default["default"].spacingXs} ${p__default["default"].spacingM}`,lineHeight:p__default["default"].lineHeightM}),noMatchesTitle:emotion.css({color:p__default["default"].gray500,margin:`${p__default["default"].spacingM} 0 ${p__default["default"].spacingM} 0`}),item:emotion.css({display:"block",padding:`${p__default["default"].spacingXs} ${p__default["default"].spacingM}`,wordBreak:"break-word",whiteSpace:"break-spaces",cursor:"pointer",hyphens:"auto","&:focus, &:hover":{backgroundColor:p__default["default"].gray100},"&:active":{backgroundColor:p__default["default"].gray200}}),disabled:emotion.css({opacity:.5,pointerEvents:"none"}),highlighted:emotion.css({backgroundColor:p__default["default"].gray100}),hidden:emotion.css({display:"none"})});var C=e=>{let{items:o,elementStartIndex:n,highlightedIndex:r,getItemProps:I,renderItem:T,inputValue:b,listMaxHeight:H=180}=e,s=M(H);return i__default["default"].createElement("ul",{className:s.list,"data-test-id":"cf-autocomplete-list"},o.map((u,k)=>{let g=n+k,w=I({item:u,index:g});return i__default["default"].createElement(f36Typography.Text,d(c({},w),{as:"li",key:g,className:emotion.cx([s.item,r===g&&s.highlighted]),"data-test-id":`cf-autocomplete-list-item-${g}`}),T?T(u,b):typeof u=="string"?i__default["default"].createElement(j,{item:u,inputValue:b}):u)}))};C.displayName="AutocompleteItems";function j({item:e,inputValue:o}){let{before:n,match:r,after:I}=f36Utils.getStringMatch(e,o);return i__default["default"].createElement(i__default["default"].Fragment,null,n,i__default["default"].createElement("b",null,r),I)}j.displayName="HighlightedItem";function Ee(e,o){let {id:n,className:r,clearAfterSelect:I=!1,closeAfterSelect:T=!0,defaultValue:b="",selectedItem:H,items:s,onInputValueChange:u,onSelectItem:k,renderItem:g,icon:w=i__default["default"].createElement(f36Icons.ChevronDownIcon,{variant:"muted"}),itemToString:Q=t=>t,isInvalid:Y,isDisabled:R,isRequired:Z,isReadOnly:ee,showEmptyList:te,noMatchesMessage:oe="No matches found",placeholder:ie="Search",inputRef:ne,toggleRef:se,listRef:re,listWidth:pe="auto",listMaxHeight:ae=180,isGrouped:x=!1,isLoading:v=!1,usePortal:le=!1,testId:me="cf-autocomplete"}=e,m=M(ae),[h,ue]=i.useState(b),y=i.useCallback(t=>{ue(t),u==null||u(t);},[u]),ce=i.useCallback(t=>{let a=t.target.value;y(a);},[y]),de=A(x)?s.reduce((t,a)=>[...t,...a.options],[]):s,ge=A(x)?s.every(t=>t.options.length===0):s.length===0,{getComboboxProps:he,getInputProps:fe,getItemProps:$,getMenuProps:Ie,getToggleButtonProps:ye,highlightedIndex:B,isOpen:D,toggleMenu:N}=downshift.useCombobox({items:de,selectedItem:H,inputValue:h,itemToString:Q,onInputValueChange:({type:t,inputValue:a})=>{t!=="__input_change__"&&y(a);},onStateChange:({type:t,selectedItem:a})=>{switch(t){case downshift.useCombobox.stateChangeTypes.InputKeyDownEnter:case downshift.useCombobox.stateChangeTypes.ItemClick:a&&k(a),I&&y(""),T||N();break;}}}),X=fe(),G=z(X,["aria-labelledby","id"]),Te=he(),F=ye(),P=Ie(),L=0;return i__default["default"].createElement("div",{"data-test-id":me,className:emotion.cx(m.autocomplete,r),ref:o},i__default["default"].createElement(f36Popover.Popover,{usePortal:le,isOpen:D,isFullWidth:pe==="full",renderOnlyWhenOpen:!1,autoFocus:!1,id:P.id},i__default["default"].createElement(f36Popover.Popover.Trigger,null,i__default["default"].createElement("div",d(c({},Te),{className:m.combobox}),i__default["default"].createElement(f36Forms.TextInput,d(c({className:m.inputField},G),{onFocus:()=>{D||N();},id:n,isInvalid:Y,isDisabled:R,isRequired:Z,isReadOnly:ee,ref:f36Core.mergeRefs(G.ref,ne),testId:"cf-autocomplete-input",placeholder:ie,onChange:t=>{G.onChange(t),ce(t);}})),i__default["default"].createElement(f36Button.IconButton,d(c({},F),{ref:f36Core.mergeRefs(F.ref,se),"aria-label":h?"Clear":"Show list",className:m.toggleButton,variant:"transparent",icon:h?i__default["default"].createElement(f36Icons.CloseIcon,{variant:"muted"}):w,onClick:()=>{h?y(""):N();},isDisabled:R,size:"small"})))),s.length>0||h.length>0||te?i__default["default"].createElement(f36Popover.Popover.Content,d(c({},P),{ref:f36Core.mergeRefs(P.ref,re),className:m.content,testId:"cf-autocomplete-container"}),v&&[...Array(3)].map((t,a)=>i__default["default"].createElement("div",{key:a,className:emotion.cx(m.item,m.disabled)},i__default["default"].createElement(Ve,null))),!v&&ge&&i__default["default"].createElement("div",{className:m.item},i__default["default"].createElement(f36Typography.Subheading,{className:m.noMatchesTitle},oe)),!v&&A(x)&&s.map((t,a)=>{if(t.options.length<1)return;let be=i__default["default"].createElement("div",{key:a},i__default["default"].createElement(f36Typography.SectionHeading,{key:a,"data-test-id":"cf-autocomplete-grouptitle",marginBottom:"none",className:m.groupTitle},t.groupTitle),i__default["default"].createElement(C,{items:t.options,highlightedIndex:B,getItemProps:$,renderItem:g,inputValue:h,elementStartIndex:L}));return L+=t.options.length,be}),!v&&!A(x)&&s.length>0&&i__default["default"].createElement(C,{items:s,elementStartIndex:L,highlightedIndex:B,getItemProps:$,renderItem:g,inputValue:h})):i__default["default"].createElement("div",d(c({},P),{className:emotion.cx(m.hidden)}))))}var Ve=()=>i__default["default"].createElement(f36Skeleton.Skeleton.Container,{svgHeight:16},i__default["default"].createElement(f36Skeleton.Skeleton.BodyText,{numberOfLines:1}));function A(e,o){return e}var Oe=i__default["default"].forwardRef(Ee);
24
24
 
25
- exports.Autocomplete = Ve;
25
+ exports.Autocomplete = Oe;
26
26
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/Autocomplete.tsx","../src/AutocompleteItems.tsx","../src/Autocomplete.styles.ts"],"names":["React","useCallback","useState","cx","useCombobox","mergeRefs","IconButton","TextInput","CloseIcon","ChevronDownIcon","Skeleton","Popover","Subheading","SectionHeading","getStringMatch","Text","css","tokens","getAutocompleteStyles","listMaxHeight","AutocompleteItems","props","items","elementStartIndex","highlightedIndex","getItemProps","renderItem","inputValue","styles","item","index","itemIndex","itemProps","__spreadProps","__spreadValues","HighlightedItem","before","match","after","_Autocomplete","ref","id","className","clearAfterSelect","closeAfterSelect","defaultValue","selectedItem","onInputValueChange","onSelectItem","icon","itemToString","isInvalid","isDisabled","isRequired","isReadOnly","noMatchesMessage","placeholder","inputRef","toggleRef","listRef","listWidth","isGrouped","isLoading","usePortal","testId","setInputValue","handleInputValueChange","value","handleNativeChangeEvent","event","flattenItems","isUsingGroups","acc","group","isShowingNoMatches","getComboboxProps","getInputProps","getMenuProps","getToggleButtonProps","isOpen","toggleMenu","type","_a","_labelledby","_inputId","inputProps","__objRest","comboboxProps","toggleProps","menuProps","_","ListItemLoadingState","render","Autocomplete"],"mappings":"qlBAAA,OAAOA,GAAS,eAAAC,EAAa,YAAAC,OAAgB,QAC7C,OAAS,MAAAC,MAAU,UACnB,OAAS,eAAAC,MAAmB,YAE5B,OACE,aAAAC,MAGK,uBACP,OAAS,cAAAC,OAAkB,yBAC3B,OAAS,aAAAC,OAAsC,wBAC/C,OAAS,aAAAC,GAAW,mBAAAC,OAAuB,wBAC3C,OAAS,YAAAC,M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CAAmB,UAAW,IAC7BV,EAAA,cAACU,EAAS,SAAT,CAAkB,cAAe,EAAG,CACvC,EAKJ,SAAS6D,EACPV,EACAvC,EACuC,CACvC,OAAOuC,CACT,CAOO,IAAMgC,GAAe7F,EAAM,WAAWuC,EAAa","sourcesContent":["import React, { useCallback, useState } from 'react';\nimport { cx } from 'emotion';\nimport { useCombobox } from 'downshift';\n\nimport {\n mergeRefs,\n type CommonProps,\n type ExpandProps,\n} from '@contentful/f36-core';\nimport { IconButton } from '@contentful/f36-button';\nimport { TextInput, type TextInputProps } from '@contentful/f36-forms';\nimport { CloseIcon, ChevronDownIcon } from '@contentful/f36-icons';\nimport { Skeleton } 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 * Set a custom icon for the text input\n */\n icon?: React.ReactElement;\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 icon = <ChevronDownIcon variant=\"muted\" />,\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={inputValue ? 'Clear' : 'Show list'}\n className={styles.toggleButton}\n variant=\"transparent\"\n icon={inputValue ? <CloseIcon variant=\"muted\" /> : icon}\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 {(items.length > 0 || inputValue.length > 0) && (\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 )}\n </Popover>\n </div>\n );\n}\n\nconst ListItemLoadingState = () => {\n return (\n <Skeleton.Container svgHeight={16}>\n <Skeleton.BodyText numberOfLines={1} />\n </Skeleton.Container>\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';\nimport { getStringMatch } from '@contentful/f36-utils';\nimport type { UseComboboxGetItemPropsOptions } from 'downshift';\nimport { Text } from '@contentful/f36-typography';\n\nimport { getAutocompleteStyles } from './Autocomplete.styles';\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"]}
1
+ {"version":3,"sources":["../src/Autocomplete.tsx","../src/AutocompleteItems.tsx","../src/Autocomplete.styles.ts"],"names":["React","useCallback","useState","cx","useCombobox","mergeRefs","IconButton","TextInput","CloseIcon","ChevronDownIcon","Skeleton","Popover","Subheading","SectionHeading","getStringMatch","Text","css","tokens","getAutocompleteStyles","listMaxHeight","AutocompleteItems","props","items","elementStartIndex","highlightedIndex","getItemProps","renderItem","inputValue","styles","item","index","itemIndex","itemProps","__spreadProps","__spreadValues","HighlightedItem","before","match","after","_Autocomplete","ref","id","className","clearAfterSelect","closeAfterSelect","defaultValue","selectedItem","onInputValueChange","onSelectItem","icon","itemToString","isInvalid","isDisabled","isRequired","isReadOnly","showEmptyList","noMatchesMessage","placeholder","inputRef","toggleRef","listRef","listWidth","isGrouped","isLoading","usePortal","testId","setInputValue","handleInputValueChange","value","handleNativeChangeEvent","event","flattenItems","isUsingGroups","acc","group","isShowingNoMatches","getComboboxProps","getInputProps","getMenuProps","getToggleButtonProps","isOpen","toggleMenu","type","_a","_labelledby","_inputId","inputProps","__objRest","comboboxProps","toggleProps","menuProps","_","ListItemLoadingState","render","Autocomplete"],"mappings":"qlBAAA,OAAOA,GAAS,eAAAC,EAAa,YAAAC,OAAgB,QAC7C,OAAS,MAAAC,MAAU,UACnB,OAAS,eAAAC,MAAmB,YAE5B,OACE,aAAAC,MAGK,uBACP,OAAS,cAAAC,OAAkB,yBAC3B,OAAS,aAAAC,OAAsC,wBAC/C,OAAS,aAAAC,GAAW,mBAAAC,OAAuB,wBAC3C,OAAS,YAAAC,MAAgB,2BACzB,OAAS,WAAAC,MAAe,0BACxB,OAAS,cAAAC,GAAY,kBAAAC,OAAsB,6BCd3C,OAAOb,MAA+B,QACtC,OAAS,MAAAG,OAAU,UACnB,OAAS,kBAAAW,OAAsB,wBAE/B,OAAS,QAAAC,OAAY,6BCJrB,OAAS,OAAAC,MAAW,UACpB,OAAOC,MAAY,yBAEZ,IAAMC,EAAyBC,IAA2B,CAC/D,aAAcH,EAAI,CAChB,SAAU,WACV,MAAO,MACT,CAAC,EACD,SAAUA,EAAI,CACZ,SAAU,UACZ,CAAC,EACD,WAAYA,EAAI,CACd,aAAcC,EAAO,UACrB,aAAc,WACd,WAAY,QACd,CAAC,EACD,aAAcD,EAAI,CAChB,SAAU,WACV,IAAK,MACL,MAAO,MACP,OAAQ,EACR,QAASC,EAAO,WAChB,OAAQ,MACV,CAAC,EACD,QAASD,EAAI,CACX,SAAU,OACV,UAAW,GAAGG,KAChB,CAAC,EACD,KAAMH,EAAI,CACR,UAAW,OACX,QAAS,GAAGC,EAAO,cACnB,OAAQ,CACV,CAAC,EACD,WAAYD,EAAI,CACd,QAAS,GAAGC,EAAO,aAAaA,EAAO,WACvC,WAAYA,EAAO,WACrB,CAAC,EACD,eAAgBD,EAAI,CAClB,MAAOC,EAAO,QACd,OAAQ,GAAGA,EAAO,cAAcA,EAAO,YACzC,CAAC,EACD,KA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,EACA1E,EAAA,cAACoB,EAAA,CACC,MAAOsD,EAAM,QACb,iBAAkBlD,EAClB,aAAcC,EACd,WAAYC,EACZ,WAAYC,EACZ,kBAAmBJ,EACrB,CACF,EAEF,OAAAA,GAAqBmD,EAAM,QAAQ,OAC5BmB,EACT,CAAC,EAEF,CAAC9B,GACA,CAACS,EAAcV,EAAWxC,CAAK,GAC/BA,EAAM,OAAS,GACbtB,EAAA,cAACoB,EAAA,CACC,MAAOE,EACP,kBAAmBC,EACnB,iBAAkBC,EAClB,aAAcC,EACd,WAAYC,EACZ,WAAYC,EACd,CAEN,EAIA3B,EAAA,cAAC,MAAAiC,EAAAC,EAAA,GAAQwD,GAAR,CAAmB,UAAWvF,EAAGyB,EAAO,MAAM,GAAG,CAEtD,CACF,CAEJ,CAEA,IAAMgE,GAAuB,IAEzB5F,EAAA,cAACU,EAAS,UAAT,CAAmB,UAAW,IAC7BV,EAAA,cAACU,EAAS,SAAT,CAAkB,cAAe,EAAG,CACvC,EAKJ,SAAS8D,EACPV,EACAxC,EACuC,CACvC,OAAOwC,CACT,CAOO,IAAMgC,GAAe9F,EAAM,WAAWuC,EAAa","sourcesContent":["import React, { useCallback, useState } from 'react';\nimport { cx } from 'emotion';\nimport { useCombobox } from 'downshift';\n\nimport {\n mergeRefs,\n type CommonProps,\n type ExpandProps,\n} from '@contentful/f36-core';\nimport { IconButton } from '@contentful/f36-button';\nimport { TextInput, type TextInputProps } from '@contentful/f36-forms';\nimport { CloseIcon, ChevronDownIcon } from '@contentful/f36-icons';\nimport { Skeleton } 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 * Set a custom icon for the text input\n */\n icon?: React.ReactElement;\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 * Defines if the list should be shown even if empty, when input is focused\n * @default false\n */\n showEmptyList?: boolean;\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 icon = <ChevronDownIcon variant=\"muted\" />,\n itemToString = (item: ItemType) => item as unknown as string,\n isInvalid,\n isDisabled,\n isRequired,\n isReadOnly,\n showEmptyList,\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={inputValue ? 'Clear' : 'Show list'}\n className={styles.toggleButton}\n variant=\"transparent\"\n icon={inputValue ? <CloseIcon variant=\"muted\" /> : icon}\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 {items.length > 0 || inputValue.length > 0 || showEmptyList ? (\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 ) : (\n // We need to render an empty hidden div, so we can pass the menuProps or downshift will show a warning about it\n // https://github.com/downshift-js/downshift/issues/1167#issuecomment-1088022842\n <div {...menuProps} className={cx(styles.hidden)} />\n )}\n </Popover>\n </div>\n );\n}\n\nconst ListItemLoadingState = () => {\n return (\n <Skeleton.Container svgHeight={16}>\n <Skeleton.BodyText numberOfLines={1} />\n </Skeleton.Container>\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';\nimport { getStringMatch } from '@contentful/f36-utils';\nimport type { UseComboboxGetItemPropsOptions } from 'downshift';\nimport { Text } from '@contentful/f36-typography';\n\nimport { getAutocompleteStyles } from './Autocomplete.styles';\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 hidden: css({\n display: 'none',\n }),\n});\n"]}
package/package.json CHANGED
@@ -1,22 +1,21 @@
1
1
  {
2
2
  "name": "@contentful/f36-autocomplete",
3
- "version": "4.20.6",
3
+ "version": "4.20.8",
4
4
  "description": "Forma 36: Autocomplete component",
5
5
  "scripts": {
6
6
  "build": "tsup"
7
7
  },
8
8
  "dependencies": {
9
- "@babel/runtime": "^7.6.2",
10
- "@contentful/f36-button": "^4.20.6",
11
- "@contentful/f36-core": "^4.20.6",
12
- "@contentful/f36-forms": "^4.20.6",
13
- "@contentful/f36-icons": "^4.20.6",
14
- "@contentful/f36-popover": "^4.20.6",
15
- "@contentful/f36-skeleton": "^4.20.6",
9
+ "@contentful/f36-button": "^4.20.8",
10
+ "@contentful/f36-core": "^4.20.8",
11
+ "@contentful/f36-forms": "^4.20.8",
12
+ "@contentful/f36-icons": "^4.20.8",
13
+ "@contentful/f36-popover": "^4.20.8",
14
+ "@contentful/f36-skeleton": "^4.20.8",
16
15
  "@contentful/f36-tokens": "^4.0.1",
17
- "@contentful/f36-typography": "^4.20.6",
18
- "@contentful/f36-utils": "^4.20.6",
19
- "downshift": "^6.1.7",
16
+ "@contentful/f36-typography": "^4.20.8",
17
+ "@contentful/f36-utils": "^4.20.8",
18
+ "downshift": "^6.1.12",
20
19
  "emotion": "^10.0.17"
21
20
  },
22
21
  "peerDependencies": {
package/CHANGELOG.md DELETED
@@ -1,697 +0,0 @@
1
- # Change Log
2
-
3
- ## 4.20.6
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies [[`05bdd10f`](https://github.com/contentful/forma-36/commit/05bdd10f5ea6fae41cacb0f4fd3db0bdd65422e9)]:
8
- - @contentful/f36-icons@4.20.6
9
- - @contentful/f36-button@4.20.6
10
- - @contentful/f36-forms@4.20.6
11
- - @contentful/f36-popover@4.20.6
12
- - @contentful/f36-skeleton@4.20.6
13
- - @contentful/f36-typography@4.20.6
14
- - @contentful/f36-utils@4.20.6
15
- - @contentful/f36-core@4.20.6
16
-
17
- ## 4.20.5
18
-
19
- ### Patch Changes
20
-
21
- - Updated dependencies []:
22
- - @contentful/f36-button@4.20.5
23
- - @contentful/f36-forms@4.20.5
24
- - @contentful/f36-icons@4.20.5
25
- - @contentful/f36-popover@4.20.5
26
- - @contentful/f36-skeleton@4.20.5
27
- - @contentful/f36-typography@4.20.5
28
- - @contentful/f36-utils@4.20.5
29
- - @contentful/f36-core@4.20.5
30
-
31
- ## 4.20.4
32
-
33
- ### Patch Changes
34
-
35
- - Updated dependencies []:
36
- - @contentful/f36-button@4.20.4
37
- - @contentful/f36-forms@4.20.4
38
- - @contentful/f36-icons@4.20.4
39
- - @contentful/f36-popover@4.20.4
40
- - @contentful/f36-skeleton@4.20.4
41
- - @contentful/f36-typography@4.20.4
42
- - @contentful/f36-utils@4.20.4
43
- - @contentful/f36-core@4.20.4
44
-
45
- ## 4.20.3
46
-
47
- ### Patch Changes
48
-
49
- - Updated dependencies [[`d3c27ab8`](https://github.com/contentful/forma-36/commit/d3c27ab830ec9c2cc096e8be33da496c2dc284ea)]:
50
- - @contentful/f36-core@4.20.3
51
- - @contentful/f36-button@4.20.3
52
- - @contentful/f36-forms@4.20.3
53
- - @contentful/f36-icons@4.20.3
54
- - @contentful/f36-popover@4.20.3
55
- - @contentful/f36-skeleton@4.20.3
56
- - @contentful/f36-typography@4.20.3
57
- - @contentful/f36-utils@4.20.3
58
-
59
- ## 4.20.2
60
-
61
- ### Patch Changes
62
-
63
- - Updated dependencies []:
64
- - @contentful/f36-button@4.20.2
65
- - @contentful/f36-forms@4.20.2
66
- - @contentful/f36-icons@4.20.2
67
- - @contentful/f36-popover@4.20.2
68
- - @contentful/f36-skeleton@4.20.2
69
- - @contentful/f36-typography@4.20.2
70
- - @contentful/f36-utils@4.20.2
71
- - @contentful/f36-core@4.20.2
72
-
73
- ## 4.20.1
74
-
75
- ### Patch Changes
76
-
77
- - Updated dependencies []:
78
- - @contentful/f36-button@4.20.1
79
- - @contentful/f36-forms@4.20.1
80
- - @contentful/f36-icons@4.20.1
81
- - @contentful/f36-popover@4.20.1
82
- - @contentful/f36-skeleton@4.20.1
83
- - @contentful/f36-typography@4.20.1
84
- - @contentful/f36-utils@4.20.1
85
- - @contentful/f36-core@4.20.1
86
-
87
- ## 4.20.0
88
-
89
- ### Patch Changes
90
-
91
- - Updated dependencies []:
92
- - @contentful/f36-button@4.20.0
93
- - @contentful/f36-forms@4.20.0
94
- - @contentful/f36-icons@4.20.0
95
- - @contentful/f36-popover@4.20.0
96
- - @contentful/f36-skeleton@4.20.0
97
- - @contentful/f36-typography@4.20.0
98
- - @contentful/f36-utils@4.20.0
99
- - @contentful/f36-core@4.20.0
100
-
101
- ## 4.19.2
102
-
103
- ### Patch Changes
104
-
105
- - Updated dependencies [[`9647d295`](https://github.com/contentful/forma-36/commit/9647d295763c6518fe6d381d79a53524ac104d92)]:
106
- - @contentful/f36-typography@4.19.2
107
- - @contentful/f36-button@4.19.2
108
- - @contentful/f36-forms@4.19.2
109
- - @contentful/f36-icons@4.19.2
110
- - @contentful/f36-popover@4.19.2
111
- - @contentful/f36-skeleton@4.19.2
112
- - @contentful/f36-utils@4.19.2
113
- - @contentful/f36-core@4.19.2
114
-
115
- ## 4.19.1
116
-
117
- ### Patch Changes
118
-
119
- - [#2209](https://github.com/contentful/forma-36/pull/2209) [`42f0c321`](https://github.com/contentful/forma-36/commit/42f0c3218965137191842f492fe5dbf4bd10784c) Thanks [@denkristoffer](https://github.com/denkristoffer)! - build: build ESM to JS file - legacy output
120
- fix(notification): use type imports
121
- - Updated dependencies [[`42f0c321`](https://github.com/contentful/forma-36/commit/42f0c3218965137191842f492fe5dbf4bd10784c)]:
122
- - @contentful/f36-button@4.19.1
123
- - @contentful/f36-forms@4.19.1
124
- - @contentful/f36-icons@4.19.1
125
- - @contentful/f36-popover@4.19.1
126
- - @contentful/f36-skeleton@4.19.1
127
- - @contentful/f36-typography@4.19.1
128
- - @contentful/f36-utils@4.19.1
129
- - @contentful/f36-core@4.19.1
130
-
131
- ## 4.19.0
132
-
133
- ### Patch Changes
134
-
135
- - Updated dependencies []:
136
- - @contentful/f36-button@4.19.0
137
- - @contentful/f36-forms@4.19.0
138
- - @contentful/f36-icons@4.19.0
139
- - @contentful/f36-popover@4.19.0
140
- - @contentful/f36-skeleton@4.19.0
141
- - @contentful/f36-typography@4.19.0
142
- - @contentful/f36-utils@4.19.0
143
- - @contentful/f36-core@4.19.0
144
-
145
- ## 4.18.0
146
-
147
- ### Patch Changes
148
-
149
- - Updated dependencies []:
150
- - @contentful/f36-button@4.18.0
151
- - @contentful/f36-forms@4.18.0
152
- - @contentful/f36-icons@4.18.0
153
- - @contentful/f36-popover@4.18.0
154
- - @contentful/f36-skeleton@4.18.0
155
- - @contentful/f36-typography@4.18.0
156
- - @contentful/f36-utils@4.18.0
157
- - @contentful/f36-core@4.18.0
158
-
159
- ## 4.17.0
160
-
161
- ### Patch Changes
162
-
163
- - Updated dependencies [[`71baf762`](https://github.com/contentful/forma-36/commit/71baf762bc3635730f496dab4113975984878736)]:
164
- - @contentful/f36-skeleton@4.17.0
165
- - @contentful/f36-button@4.17.0
166
- - @contentful/f36-forms@4.17.0
167
- - @contentful/f36-icons@4.17.0
168
- - @contentful/f36-popover@4.17.0
169
- - @contentful/f36-typography@4.17.0
170
- - @contentful/f36-utils@4.17.0
171
- - @contentful/f36-core@4.17.0
172
-
173
- ## 4.16.0
174
-
175
- ### Patch Changes
176
-
177
- - Updated dependencies []:
178
- - @contentful/f36-button@4.16.0
179
- - @contentful/f36-forms@4.16.0
180
- - @contentful/f36-icons@4.16.0
181
- - @contentful/f36-popover@4.16.0
182
- - @contentful/f36-skeleton@4.16.0
183
- - @contentful/f36-typography@4.16.0
184
- - @contentful/f36-utils@4.16.0
185
- - @contentful/f36-core@4.16.0
186
-
187
- ## 4.15.1
188
-
189
- ### Patch Changes
190
-
191
- - [#2165](https://github.com/contentful/forma-36/pull/2165) [`5582f33c`](https://github.com/contentful/forma-36/commit/5582f33c0674850a30cc2a1792aad72fa219f7de) Thanks [@loweisz](https://github.com/loweisz)! - fix(autocomplete): hide list component when when items and search value are empty
192
-
193
- - Updated dependencies []:
194
- - @contentful/f36-button@4.15.1
195
- - @contentful/f36-forms@4.15.1
196
- - @contentful/f36-icons@4.15.1
197
- - @contentful/f36-popover@4.15.1
198
- - @contentful/f36-skeleton@4.15.1
199
- - @contentful/f36-typography@4.15.1
200
- - @contentful/f36-utils@4.15.1
201
- - @contentful/f36-core@4.15.1
202
-
203
- ## 4.15.0
204
-
205
- ### Patch Changes
206
-
207
- - Updated dependencies []:
208
- - @contentful/f36-button@4.15.0
209
- - @contentful/f36-forms@4.15.0
210
- - @contentful/f36-icons@4.15.0
211
- - @contentful/f36-popover@4.15.0
212
- - @contentful/f36-skeleton@4.15.0
213
- - @contentful/f36-typography@4.15.0
214
- - @contentful/f36-utils@4.15.0
215
- - @contentful/f36-core@4.15.0
216
-
217
- ## 4.14.0
218
-
219
- ### Patch Changes
220
-
221
- - Updated dependencies []:
222
- - @contentful/f36-button@4.14.0
223
- - @contentful/f36-forms@4.14.0
224
- - @contentful/f36-icons@4.14.0
225
- - @contentful/f36-popover@4.14.0
226
- - @contentful/f36-skeleton@4.14.0
227
- - @contentful/f36-typography@4.14.0
228
- - @contentful/f36-utils@4.14.0
229
- - @contentful/f36-core@4.14.0
230
-
231
- ## 4.13.0
232
-
233
- ### Patch Changes
234
-
235
- - Updated dependencies []:
236
- - @contentful/f36-button@4.13.0
237
- - @contentful/f36-forms@4.13.0
238
- - @contentful/f36-icons@4.13.0
239
- - @contentful/f36-popover@4.13.0
240
- - @contentful/f36-skeleton@4.13.0
241
- - @contentful/f36-typography@4.13.0
242
- - @contentful/f36-utils@4.13.0
243
- - @contentful/f36-core@4.13.0
244
-
245
- ## 4.12.0
246
-
247
- ### Patch Changes
248
-
249
- - Updated dependencies []:
250
- - @contentful/f36-button@4.12.0
251
- - @contentful/f36-forms@4.12.0
252
- - @contentful/f36-icons@4.12.0
253
- - @contentful/f36-popover@4.12.0
254
- - @contentful/f36-skeleton@4.12.0
255
- - @contentful/f36-typography@4.12.0
256
- - @contentful/f36-utils@4.12.0
257
- - @contentful/f36-core@4.12.0
258
-
259
- ## 4.11.0
260
-
261
- ### Minor Changes
262
-
263
- - [#2116](https://github.com/contentful/forma-36/pull/2116) [`7efcc111`](https://github.com/contentful/forma-36/commit/7efcc111878fd22085f9717dc4d708b721fc20f3) Thanks [@mshaaban0](https://github.com/mshaaban0)! - feat: allow passing custom icons to autocomplete
264
-
265
- ### Patch Changes
266
-
267
- - Updated dependencies []:
268
- - @contentful/f36-button@4.11.0
269
- - @contentful/f36-forms@4.11.0
270
- - @contentful/f36-icons@4.11.0
271
- - @contentful/f36-popover@4.11.0
272
- - @contentful/f36-skeleton@4.11.0
273
- - @contentful/f36-typography@4.11.0
274
- - @contentful/f36-utils@4.11.0
275
- - @contentful/f36-core@4.11.0
276
-
277
- ## 4.11.0-beta.0
278
-
279
- ### Minor Changes
280
-
281
- - [#2116](https://github.com/contentful/forma-36/pull/2116) [`7efcc111`](https://github.com/contentful/forma-36/commit/7efcc111878fd22085f9717dc4d708b721fc20f3) Thanks [@mshaaban0](https://github.com/mshaaban0)! - feat: allow passing custom icons to autocomplete
282
-
283
- ### Patch Changes
284
-
285
- - Updated dependencies []:
286
- - @contentful/f36-button@4.11.0-beta.0
287
- - @contentful/f36-forms@4.11.0-beta.0
288
- - @contentful/f36-icons@4.11.0-beta.0
289
- - @contentful/f36-popover@4.11.0-beta.0
290
- - @contentful/f36-skeleton@4.11.0-beta.0
291
- - @contentful/f36-typography@4.11.0-beta.0
292
- - @contentful/f36-utils@4.11.0-beta.0
293
- - @contentful/f36-core@4.11.0-beta.0
294
-
295
- ## 4.10.5
296
-
297
- ### Patch Changes
298
-
299
- - Updated dependencies [[`32cac8e8`](https://github.com/contentful/forma-36/commit/32cac8e8bdeedfe29b36bc6025eec11607c93da8)]:
300
- - @contentful/f36-icons@4.10.5
301
- - @contentful/f36-popover@4.10.5
302
- - @contentful/f36-button@4.10.5
303
- - @contentful/f36-forms@4.10.5
304
- - @contentful/f36-skeleton@4.10.5
305
- - @contentful/f36-typography@4.10.5
306
- - @contentful/f36-utils@4.10.5
307
- - @contentful/f36-core@4.10.5
308
-
309
- ## 4.10.4
310
-
311
- ### Patch Changes
312
-
313
- - [#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"
314
-
315
- - Updated dependencies []:
316
- - @contentful/f36-button@4.10.4
317
- - @contentful/f36-forms@4.10.4
318
- - @contentful/f36-icons@4.10.4
319
- - @contentful/f36-popover@4.10.4
320
- - @contentful/f36-skeleton@4.10.4
321
- - @contentful/f36-typography@4.10.4
322
- - @contentful/f36-utils@4.10.4
323
- - @contentful/f36-core@4.10.4
324
-
325
- ## 4.10.3
326
-
327
- ### Patch Changes
328
-
329
- - Updated dependencies [[`1bc834c6`](https://github.com/contentful/forma-36/commit/1bc834c65097e5b253b7bc69a96a16121b4e7cc4)]:
330
- - @contentful/f36-popover@4.10.3
331
- - @contentful/f36-button@4.10.3
332
- - @contentful/f36-forms@4.10.3
333
- - @contentful/f36-icons@4.10.3
334
- - @contentful/f36-skeleton@4.10.3
335
- - @contentful/f36-typography@4.10.3
336
- - @contentful/f36-utils@4.10.3
337
- - @contentful/f36-core@4.10.3
338
-
339
- ## 4.10.2
340
-
341
- ### Patch Changes
342
-
343
- - Updated dependencies []:
344
- - @contentful/f36-button@4.10.2
345
- - @contentful/f36-forms@4.10.2
346
- - @contentful/f36-icons@4.10.2
347
- - @contentful/f36-popover@4.10.2
348
- - @contentful/f36-skeleton@4.10.2
349
- - @contentful/f36-typography@4.10.2
350
- - @contentful/f36-utils@4.10.2
351
- - @contentful/f36-core@4.10.2
352
-
353
- ## 4.10.1
354
-
355
- ### Patch Changes
356
-
357
- - Updated dependencies []:
358
- - @contentful/f36-button@4.10.1
359
- - @contentful/f36-forms@4.10.1
360
- - @contentful/f36-icons@4.10.1
361
- - @contentful/f36-popover@4.10.1
362
- - @contentful/f36-skeleton@4.10.1
363
- - @contentful/f36-typography@4.10.1
364
- - @contentful/f36-utils@4.10.1
365
- - @contentful/f36-core@4.10.1
366
-
367
- ## 4.10.0
368
-
369
- ### Patch Changes
370
-
371
- - Updated dependencies [[`20d73e7c`](https://github.com/contentful/forma-36/commit/20d73e7c8247ee789fdfde58882682808bf761ae)]:
372
- - @contentful/f36-button@4.10.0
373
- - @contentful/f36-forms@4.10.0
374
- - @contentful/f36-icons@4.10.0
375
- - @contentful/f36-popover@4.10.0
376
- - @contentful/f36-skeleton@4.10.0
377
- - @contentful/f36-typography@4.10.0
378
- - @contentful/f36-utils@4.10.0
379
- - @contentful/f36-core@4.10.0
380
-
381
- ## 4.9.0
382
-
383
- ### Minor Changes
384
-
385
- - [#2055](https://github.com/contentful/forma-36/pull/2055) [`910dafc9`](https://github.com/contentful/forma-36/commit/910dafc9ba4a1acc9133d2ee89e7a1fad879e932) Thanks [@Lelith](https://github.com/Lelith)! - Enable Autocomplete as a controlled input by using selectedItem property
386
-
387
- ### Patch Changes
388
-
389
- - Updated dependencies []:
390
- - @contentful/f36-button@4.9.0
391
- - @contentful/f36-forms@4.9.0
392
- - @contentful/f36-icons@4.9.0
393
- - @contentful/f36-popover@4.9.0
394
- - @contentful/f36-skeleton@4.9.0
395
- - @contentful/f36-typography@4.9.0
396
- - @contentful/f36-utils@4.9.0
397
- - @contentful/f36-core@4.9.0
398
-
399
- ## 4.8.2
400
-
401
- ### Patch Changes
402
-
403
- - Updated dependencies []:
404
- - @contentful/f36-button@4.8.2
405
- - @contentful/f36-forms@4.8.2
406
- - @contentful/f36-icons@4.8.2
407
- - @contentful/f36-popover@4.8.2
408
- - @contentful/f36-skeleton@4.8.2
409
- - @contentful/f36-typography@4.8.2
410
- - @contentful/f36-utils@4.8.2
411
- - @contentful/f36-core@4.8.2
412
-
413
- ## 4.8.1
414
-
415
- ### Patch Changes
416
-
417
- - Updated dependencies [[`7afca5e6`](https://github.com/contentful/forma-36/commit/7afca5e6f9d89b1f187fc48ab8e8fd39366f110b)]:
418
- - @contentful/f36-typography@4.8.1
419
- - @contentful/f36-button@4.8.1
420
- - @contentful/f36-forms@4.8.1
421
- - @contentful/f36-icons@4.8.1
422
- - @contentful/f36-popover@4.8.1
423
- - @contentful/f36-skeleton@4.8.1
424
- - @contentful/f36-utils@4.8.1
425
- - @contentful/f36-core@4.8.1
426
-
427
- ## 4.8.0
428
-
429
- ### Patch Changes
430
-
431
- - [#2008](https://github.com/contentful/forma-36/pull/2008) [`1a941fd9`](https://github.com/contentful/forma-36/commit/1a941fd99757e49bb30e0e32eab19bc680f66597) Thanks [@massao](https://github.com/massao)! - Fix issue with types being generated wrongly
432
-
433
- - Updated dependencies [[`1a941fd9`](https://github.com/contentful/forma-36/commit/1a941fd99757e49bb30e0e32eab19bc680f66597)]:
434
- - @contentful/f36-skeleton@4.8.0
435
- - @contentful/f36-button@4.8.0
436
- - @contentful/f36-forms@4.8.0
437
- - @contentful/f36-icons@4.8.0
438
- - @contentful/f36-popover@4.8.0
439
- - @contentful/f36-typography@4.8.0
440
- - @contentful/f36-utils@4.8.0
441
- - @contentful/f36-core@4.8.0
442
-
443
- ## 4.7.0
444
-
445
- ### Patch Changes
446
-
447
- - Updated dependencies [[`e50b8945`](https://github.com/contentful/forma-36/commit/e50b8945faef7323187e1bd9a2a9cbfcbae2e405)]:
448
- - @contentful/f36-core@4.7.0
449
- - @contentful/f36-button@4.7.0
450
- - @contentful/f36-forms@4.7.0
451
- - @contentful/f36-icons@4.7.0
452
- - @contentful/f36-popover@4.7.0
453
- - @contentful/f36-skeleton@4.7.0
454
- - @contentful/f36-typography@4.7.0
455
- - @contentful/f36-utils@4.7.0
456
-
457
- ## 4.6.2
458
-
459
- ### Patch Changes
460
-
461
- - Updated dependencies []:
462
- - @contentful/f36-button@4.6.2
463
- - @contentful/f36-forms@4.6.2
464
- - @contentful/f36-icons@4.6.2
465
- - @contentful/f36-popover@4.6.2
466
- - @contentful/f36-skeleton@4.6.2
467
- - @contentful/f36-typography@4.6.2
468
- - @contentful/f36-utils@4.6.2
469
- - @contentful/f36-core@4.6.2
470
-
471
- ## 4.6.1
472
-
473
- ### Patch Changes
474
-
475
- - Updated dependencies []:
476
- - @contentful/f36-button@4.6.1
477
- - @contentful/f36-forms@4.6.1
478
- - @contentful/f36-icons@4.6.1
479
- - @contentful/f36-popover@4.6.1
480
- - @contentful/f36-skeleton@4.6.1
481
- - @contentful/f36-typography@4.6.1
482
- - @contentful/f36-utils@4.6.1
483
- - @contentful/f36-core@4.6.1
484
-
485
- ## 4.6.0
486
-
487
- ### Patch Changes
488
-
489
- - Updated dependencies []:
490
- - @contentful/f36-button@4.6.0
491
- - @contentful/f36-forms@4.6.0
492
- - @contentful/f36-icons@4.6.0
493
- - @contentful/f36-popover@4.6.0
494
- - @contentful/f36-skeleton@4.6.0
495
- - @contentful/f36-typography@4.6.0
496
- - @contentful/f36-utils@4.6.0
497
- - @contentful/f36-core@4.6.0
498
-
499
- ## 4.5.0
500
-
501
- ### Patch Changes
502
-
503
- - Updated dependencies [[`d841d7cb`](https://github.com/contentful/forma-36/commit/d841d7cbf74b20192028591197bc42df3d2ebc2e)]:
504
- - @contentful/f36-utils@4.5.0
505
- - @contentful/f36-button@4.5.0
506
- - @contentful/f36-forms@4.5.0
507
- - @contentful/f36-icons@4.5.0
508
- - @contentful/f36-popover@4.5.0
509
- - @contentful/f36-skeleton@4.5.0
510
- - @contentful/f36-typography@4.5.0
511
- - @contentful/f36-core@4.5.0
512
-
513
- ## 4.4.1
514
-
515
- ### Patch Changes
516
-
517
- - Updated dependencies []:
518
- - @contentful/f36-button@4.4.1
519
- - @contentful/f36-forms@4.4.1
520
- - @contentful/f36-icons@4.4.1
521
- - @contentful/f36-popover@4.4.1
522
- - @contentful/f36-skeleton@4.4.1
523
- - @contentful/f36-typography@4.4.1
524
- - @contentful/f36-utils@4.4.1
525
- - @contentful/f36-core@4.4.1
526
-
527
- ## 4.4.0
528
-
529
- ### Patch Changes
530
-
531
- - Updated dependencies [[`a9459709`](https://github.com/contentful/forma-36/commit/a945970959bc7e9478bec822bb775a513c6aa0fe)]:
532
- - @contentful/f36-core@4.4.0
533
- - @contentful/f36-button@4.4.0
534
- - @contentful/f36-forms@4.4.0
535
- - @contentful/f36-icons@4.4.0
536
- - @contentful/f36-popover@4.4.0
537
- - @contentful/f36-skeleton@4.4.0
538
- - @contentful/f36-typography@4.4.0
539
- - @contentful/f36-utils@4.4.0
540
-
541
- ## 4.3.11
542
-
543
- ### Patch Changes
544
-
545
- - Updated dependencies [[`edd15d01`](https://github.com/contentful/forma-36/commit/edd15d016be65430e4a1ceb6c617a7b8bdb98585)]:
546
- - @contentful/f36-forms@4.3.11
547
- - @contentful/f36-button@4.3.11
548
- - @contentful/f36-icons@4.3.11
549
- - @contentful/f36-popover@4.3.11
550
- - @contentful/f36-skeleton@4.3.11
551
- - @contentful/f36-typography@4.3.11
552
- - @contentful/f36-utils@4.3.11
553
- - @contentful/f36-core@4.3.11
554
-
555
- ## 4.3.10
556
-
557
- ### Patch Changes
558
-
559
- - [#1969](https://github.com/contentful/forma-36/pull/1969) [`0c5a4b60`](https://github.com/contentful/forma-36/commit/0c5a4b60f8df76e1f75d98b7ea28dd0fd6307fc3) Thanks [@denkristoffer](https://github.com/denkristoffer)! - don't put cursor to the end on every change event
560
-
561
- - Updated dependencies [[`0c5a4b60`](https://github.com/contentful/forma-36/commit/0c5a4b60f8df76e1f75d98b7ea28dd0fd6307fc3)]:
562
- - @contentful/f36-forms@4.3.10
563
- - @contentful/f36-button@4.3.10
564
- - @contentful/f36-icons@4.3.10
565
- - @contentful/f36-popover@4.3.10
566
- - @contentful/f36-skeleton@4.3.10
567
- - @contentful/f36-typography@4.3.10
568
- - @contentful/f36-utils@4.3.10
569
- - @contentful/f36-core@4.3.10
570
-
571
- ## 4.3.9
572
-
573
- ### Patch Changes
574
-
575
- - [#1953](https://github.com/contentful/forma-36/pull/1953) [`df985087`](https://github.com/contentful/forma-36/commit/df98508780f63754e29df09d4f6239bdc84982a8) Thanks [@massao](https://github.com/massao)! - bump packages versions to have consistent versioning
576
-
577
- - Updated dependencies [[`df985087`](https://github.com/contentful/forma-36/commit/df98508780f63754e29df09d4f6239bdc84982a8)]:
578
- - @contentful/f36-button@4.3.9
579
- - @contentful/f36-forms@4.3.9
580
- - @contentful/f36-icons@4.3.9
581
- - @contentful/f36-popover@4.3.9
582
- - @contentful/f36-skeleton@4.3.9
583
- - @contentful/f36-typography@4.3.9
584
- - @contentful/f36-core@4.3.9
585
- - @contentful/f36-utils@4.3.9
586
-
587
- ## [4.2.11](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.2.10...@contentful/f36-autocomplete@4.2.11) (2022-03-14)
588
-
589
- **Note:** Version bump only for package @contentful/f36-autocomplete
590
-
591
- ## [4.2.10](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.2.9...@contentful/f36-autocomplete@4.2.10) (2022-03-10)
592
-
593
- **Note:** Version bump only for package @contentful/f36-autocomplete
594
-
595
- ## [4.2.9](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.2.8...@contentful/f36-autocomplete@4.2.9) (2022-03-09)
596
-
597
- **Note:** Version bump only for package @contentful/f36-autocomplete
598
-
599
- ## [4.2.8](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.2.7...@contentful/f36-autocomplete@4.2.8) (2022-03-09)
600
-
601
- **Note:** Version bump only for package @contentful/f36-autocomplete
602
-
603
- ## [4.2.7](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.2.6...@contentful/f36-autocomplete@4.2.7) (2022-03-03)
604
-
605
- ### Bug Fixes
606
-
607
- - migrate links from master to main ([#1923](https://github.com/contentful/forma-36/issues/1923)) ([607301d](https://github.com/contentful/forma-36/commit/607301d57a2e83190d2aa298120ddb8493e8c429))
608
-
609
- ## [4.2.6](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.2.5...@contentful/f36-autocomplete@4.2.6) (2022-03-02)
610
-
611
- **Note:** Version bump only for package @contentful/f36-autocomplete
612
-
613
- ## [4.2.5](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.2.4...@contentful/f36-autocomplete@4.2.5) (2022-03-01)
614
-
615
- ### Bug Fixes
616
-
617
- - autocomplete method documentation ([#1914](https://github.com/contentful/forma-36/issues/1914)) ([0596bd7](https://github.com/contentful/forma-36/commit/0596bd7e86398f4a15cac7e8e5a5943ca6c61fe0))
618
-
619
- ## [4.2.4](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.2.3...@contentful/f36-autocomplete@4.2.4) (2022-02-22)
620
-
621
- **Note:** Version bump only for package @contentful/f36-autocomplete
622
-
623
- ## [4.2.3](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.2.2...@contentful/f36-autocomplete@4.2.3) (2022-02-22)
624
-
625
- **Note:** Version bump only for package @contentful/f36-autocomplete
626
-
627
- ## [4.2.2](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.2.1...@contentful/f36-autocomplete@4.2.2) (2022-02-17)
628
-
629
- **Note:** Version bump only for package @contentful/f36-autocomplete
630
-
631
- ## [4.2.1](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.2.0...@contentful/f36-autocomplete@4.2.1) (2022-02-09)
632
-
633
- **Note:** Version bump only for package @contentful/f36-autocomplete
634
-
635
- # [4.2.0](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.11...@contentful/f36-autocomplete@4.2.0) (2022-02-09)
636
-
637
- ### Features
638
-
639
- - by default render Popover only when it's open ([#1873](https://github.com/contentful/forma-36/issues/1873)) ([48a511b](https://github.com/contentful/forma-36/commit/48a511bc48c17d3e4bf0cbfb8d16da8c3cbc29b2))
640
-
641
- ## [4.1.11](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.10...@contentful/f36-autocomplete@4.1.11) (2022-02-07)
642
-
643
- **Note:** Version bump only for package @contentful/f36-autocomplete
644
-
645
- ## [4.1.10](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.9...@contentful/f36-autocomplete@4.1.10) (2022-02-07)
646
-
647
- **Note:** Version bump only for package @contentful/f36-autocomplete
648
-
649
- ## [4.1.9](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.8...@contentful/f36-autocomplete@4.1.9) (2022-02-07)
650
-
651
- **Note:** Version bump only for package @contentful/f36-autocomplete
652
-
653
- ## [4.1.8](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.7...@contentful/f36-autocomplete@4.1.8) (2022-02-02)
654
-
655
- **Note:** Version bump only for package @contentful/f36-autocomplete
656
-
657
- ## [4.1.7](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.6...@contentful/f36-autocomplete@4.1.7) (2022-01-31)
658
-
659
- **Note:** Version bump only for package @contentful/f36-autocomplete
660
-
661
- ## [4.1.6](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.5...@contentful/f36-autocomplete@4.1.6) (2022-01-31)
662
-
663
- **Note:** Version bump only for package @contentful/f36-autocomplete
664
-
665
- ## [4.1.5](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.4...@contentful/f36-autocomplete@4.1.5) (2022-01-28)
666
-
667
- **Note:** Version bump only for package @contentful/f36-autocomplete
668
-
669
- ## [4.1.4](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.3...@contentful/f36-autocomplete@4.1.4) (2022-01-26)
670
-
671
- **Note:** Version bump only for package @contentful/f36-autocomplete
672
-
673
- ## [4.1.3](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.2...@contentful/f36-autocomplete@4.1.3) (2022-01-25)
674
-
675
- **Note:** Version bump only for package @contentful/f36-autocomplete
676
-
677
- ## [4.1.2](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.1...@contentful/f36-autocomplete@4.1.2) (2022-01-19)
678
-
679
- **Note:** Version bump only for package @contentful/f36-autocomplete
680
-
681
- ## [4.1.1](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.0...@contentful/f36-autocomplete@4.1.1) (2022-01-19)
682
-
683
- **Note:** Version bump only for package @contentful/f36-autocomplete
684
-
685
- # [4.1.0](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.0.2...@contentful/f36-autocomplete@4.1.0) (2022-01-13)
686
-
687
- ### Features
688
-
689
- - implement props list redesign [BAU-535](<[#1756](https://github.com/contentful/forma-36/issues/1756)>) ([21c57e7](https://github.com/contentful/forma-36/commit/21c57e72008b75990d03af4e7500edc1c7f3d26d))
690
-
691
- ## [4.0.2](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.0.1...@contentful/f36-autocomplete@4.0.2) (2022-01-12)
692
-
693
- **Note:** Version bump only for package @contentful/f36-autocomplete
694
-
695
- ## [4.0.1](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.0.0...@contentful/f36-autocomplete@4.0.1) (2022-01-11)
696
-
697
- **Note:** Version bump only for package @contentful/f36-autocomplete