@purpur/library 9.1.1 → 9.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ "use strict";const e=require("react/jsx-runtime"),f=require("react"),S=require("./listbox-COBHLRtB.js"),A=require("./use-autocomplete.es-BHDgQLae.js"),j=require("./bind-DeUYJ6m9.js"),R=require("./search.es-Cg2amJSR.js"),B=require("./text-field-BwxGMWds.js"),F=require("./button-Dqxdc3nC.js"),C={"purpur-search-field":"_purpur-search-field_6ot57_1","purpur-search-field--has-clear-button":"_purpur-search-field--has-clear-button_6ot57_4","purpur-search-field--no-gap":"_purpur-search-field--no-gap_6ot57_13","purpur-search-field__wrapper":"_purpur-search-field__wrapper_6ot57_17","purpur-search-field__wrapper--gap":"_purpur-search-field__wrapper--gap_6ot57_20","purpur-search-field__search-icon":"_purpur-search-field__search-icon_6ot57_24","purpur-search-field__close-icon":"_purpur-search-field__close-icon_6ot57_24","purpur-search-field__autocomplete-root":"_purpur-search-field__autocomplete-root_6ot57_27","purpur-search-field__listbox":"_purpur-search-field__listbox_6ot57_31"},L={"purpur-search-field-button":"_purpur-search-field-button_c16yo_1","purpur-search-field-button--icon-only":"_purpur-search-field-button--icon-only_c16yo_1"},z=j.c.bind(L),w="purpur-search-field-button",V=({["data-testid"]:t,disabled:a,iconOnly:u,label:o})=>{const i={className:z(w,{[`${w}--icon-only`]:u}),disabled:a,"data-testid":t};return u?e.jsx(F.Button,{...i,"aria-label":o,iconOnly:!0,size:"sm",type:"submit",variant:"primary",children:e.jsx(R.s,{size:"xs"})}):e.jsx(F.Button,{...i,size:"sm",type:"submit",variant:"primary",children:o})},k=["button-attached","no-button"],y=j.c.bind(C),d="purpur-search-field",$=f.forwardRef(({["data-testid"]:t,className:a,clearButtonAriaLabel:u,disabled:o,iconOnlySearchButton:i,onClear:c,onSearch:l,searchButtonLabel:b,variant:p,formRef:r,wrapperStyle:m,...n},s)=>{const _=h=>t?`${t}-${h}`:void 0,x=(typeof n.value=="number"?n.value!==void 0:n.value?.length)&&!o&&!n.readOnly&&!n.loading,O=y(a,d,{[`${d}--no-gap`]:p==="button-attached",[`${d}--has-clear-button`]:x});return e.jsx("form",{ref:r,className:y(`${d}__wrapper`),"data-testid":t,style:m,onSubmit:h=>{h.preventDefault(),l?.(h)},children:e.jsx(B.TextField,{ref:s,className:O,clearButtonAriaLabel:u,disabled:o,onClear:c,startAdornment:i?null:e.jsx(R.s,{size:"xs",className:y(`${d}__search-icon`)},"1"),afterField:p!=="no-button"?e.jsx(V,{disabled:o,iconOnly:i,label:b,"data-testid":_("button")}):null,"data-testid":_("text-field"),type:"search",...n})})});$.displayName="SearchFieldBase";const q=j.c.bind(C),v="purpur-search-field",g=f.forwardRef(({suggestions:t,suggestionsLabel:a,onSelectSuggestion:u,openSuggestionsOnFocus:o,suggestionsMaxHeight:i,...c},l)=>{const b=f.useId(),p=c.id??b,r=A.ee({id:p,options:t,listboxLabel:a,disabled:c.disabled,readOnly:c.readOnly,openOnFocus:o,listboxMaxHeight:i,onSelect:u,"data-testid":c["data-testid"]}),m=s=>{r.inputRef.current=s,typeof l=="function"?l(s):l&&(l.current=s)},n=s=>{c.onChange?.(s),r.isOpen||r.openListbox()};return e.jsxs("div",{ref:r.rootRef,className:q(`${v}__autocomplete-root`),children:[e.jsx($,{ref:m,...c,onChange:n,id:p,wrapperStyle:r.anchorStyle,...r.inputProps}),r.isOpen&&e.jsx(S.Listbox,{...r.listboxProps,className:q(`${v}__listbox`),children:t.map((s,_)=>{const{key:N,...x}=r.getListboxItemProps(s,_);return e.jsx(S.Listbox.Item,{...x,children:s.label},N)})})]})});g.displayName="SearchFieldAutocomplete";const I=f.forwardRef((t,a)=>t.suggestions?e.jsx(g,{ref:a,...t}):e.jsx($,{ref:a,...t}));I.displayName="SearchField";exports.SearchField=I;exports.SearchFieldAutocomplete=g;exports.searchFieldVariants=k;
2
+ //# sourceMappingURL=search-field-Bst9d-wX.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"search-field-DAktzYb0.js","sources":["../../../components/search-field/src/search-field-button.tsx","../../../components/search-field/src/search-field-base.tsx","../../../components/search-field/src/search-field-autocomplete.tsx","../../../components/search-field/src/search-field.tsx"],"sourcesContent":["import React from \"react\";\nimport { Button } from \"@purpur/button\";\nimport { IconSearch } from \"@purpur/icon/search\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./search-field-button.module.scss\";\n\ntype Props = {\n [\"data-testid\"]?: string;\n disabled?: boolean;\n iconOnly?: boolean;\n label: string;\n};\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-search-field-button\";\n\nexport const SearchFieldButton = ({\n [\"data-testid\"]: dataTestid,\n disabled,\n iconOnly,\n label,\n}: Props) => {\n const props = {\n className: cx(rootClassName, {\n [`${rootClassName}--icon-only`]: iconOnly,\n }),\n disabled,\n [\"data-testid\"]: dataTestid,\n };\n\n if (iconOnly) {\n return (\n <Button {...props} aria-label={label} iconOnly size=\"sm\" type=\"submit\" variant=\"primary\">\n <IconSearch size=\"xs\" />\n </Button>\n );\n }\n\n return (\n <Button {...props} size=\"sm\" type=\"submit\" variant=\"primary\">\n {label}\n </Button>\n );\n};\n","import React, {\n type ChangeEvent,\n type CSSProperties,\n type FormEvent,\n forwardRef,\n type RefObject,\n} from \"react\";\nimport { IconSearch } from \"@purpur/icon/search\";\nimport { TextField, type TextFieldProps } from \"@purpur/text-field\";\nimport { type AutocompleteOption } from \"@purpur/use-autocomplete\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./search-field.module.scss\";\nimport { SearchFieldButton } from \"./search-field-button\";\n\nexport const searchFieldVariants = [\"button-attached\", \"no-button\"] as const;\n\ntype Variant = (typeof searchFieldVariants)[number];\n\ntype DefaultProps = {\n [\"data-testid\"]?: string;\n /**\n * An accessible label for the clear button.\n * */\n clearButtonAriaLabel: string;\n /**\n * Disables both the input field and submit button if `true`.\n * */\n disabled?: boolean;\n /**\n * Will display only a search icon in the search button if `true`.\n * */\n iconOnlySearchButton?: boolean;\n /**\n * Event handler called when the value of the search field changes.\n * */\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n /**\n * Event handler called when the clear button is clicked.\n * */\n onClear: () => void;\n /**\n * Event handler called when the search form is submitted.\n * */\n onSearch?: (e: FormEvent<HTMLFormElement>) => void;\n /**\n * The label text (or `aria-label` if `iconOnlySearchButton` is `true`) of the search button.\n * */\n searchButtonLabel?: string;\n variant: Variant;\n formRef?: RefObject<HTMLFormElement>;\n};\n\ntype TextSearchButton = {\n iconOnlySearchButton?: false;\n searchButtonLabel: string;\n variant: \"button-attached\";\n};\n\ntype IconOnlySearchButton = {\n iconOnlySearchButton: true;\n searchButtonLabel: string;\n variant: \"button-attached\";\n};\n\ntype NoButton = {\n searchButtonLabel?: never;\n variant: \"no-button\";\n};\n\nexport type SearchFieldBaseProps = DefaultProps &\n (TextSearchButton | IconOnlySearchButton | NoButton) &\n Omit<TextFieldProps, \"startAdornment\" | \"endAdornment\" | \"afterField\" | \"onChange\" | \"variant\">;\n\ntype SearchFieldBaseInternalProps = SearchFieldBaseProps & {\n wrapperStyle?: CSSProperties;\n};\n\ntype SearchFieldAutocompleteSharedProps = {\n /**\n * Called when the user selects a suggestion.\n */\n onSelectSuggestion?: (option: AutocompleteOption) => void;\n /**\n * Open the suggestions listbox when the input receives focus.\n */\n openSuggestionsOnFocus?: boolean;\n /**\n * Maximum height of the suggestions listbox. A number is interpreted as px.\n */\n suggestionsMaxHeight?: string | number;\n};\n\ntype SearchFieldWithoutAutocomplete = SearchFieldAutocompleteSharedProps & {\n suggestions?: never;\n suggestionsLabel?: never;\n};\n\ntype SearchFieldWithAutocomplete = SearchFieldAutocompleteSharedProps & {\n /**\n * The list of suggestions to display in a listbox below the field.\n * No filtering is applied — pass the already-correct (pre-filtered) list.\n * If autocomplete should stay enabled while there are temporarily no matches,\n * pass an empty array instead of `undefined` or `null`. Changing this prop\n * from an absent value to an array switches between the regular and\n * autocomplete variants, which causes a re-render, drops input focus, and\n * hides the listbox.\n */\n suggestions: AutocompleteOption[];\n /**\n * Accessible label for the suggestions listbox.\n */\n suggestionsLabel: string;\n};\n\nexport type SearchFieldAutocompleteEnhancements =\n | SearchFieldWithoutAutocomplete\n | SearchFieldWithAutocomplete;\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-search-field\";\n\nexport const SearchFieldBase = forwardRef<HTMLInputElement, SearchFieldBaseInternalProps>(\n (\n {\n [\"data-testid\"]: dataTestId,\n className,\n clearButtonAriaLabel,\n disabled,\n iconOnlySearchButton,\n onClear,\n onSearch,\n searchButtonLabel,\n variant,\n formRef,\n wrapperStyle,\n ...props\n },\n ref\n ) => {\n const getTestId = (name: string) => (dataTestId ? `${dataTestId}-${name}` : undefined);\n const hasValue =\n typeof props.value === \"number\" ? props.value !== undefined : props.value?.length;\n const hasClearButton = hasValue && !disabled && !props.readOnly && !props.loading;\n\n const classes = cx(className, rootClassName, {\n [`${rootClassName}--no-gap`]: variant === \"button-attached\",\n [`${rootClassName}--has-clear-button`]: hasClearButton,\n });\n\n return (\n <form\n ref={formRef}\n className={cx(`${rootClassName}__wrapper`)}\n data-testid={dataTestId}\n style={wrapperStyle}\n onSubmit={(e: FormEvent<HTMLFormElement>) => {\n e.preventDefault();\n onSearch?.(e);\n }}\n >\n <TextField\n ref={ref}\n className={classes}\n clearButtonAriaLabel={clearButtonAriaLabel}\n disabled={disabled}\n onClear={onClear}\n startAdornment={\n !iconOnlySearchButton ? (\n <IconSearch size=\"xs\" className={cx(`${rootClassName}__search-icon`)} key=\"1\" />\n ) : null\n }\n afterField={\n variant !== \"no-button\" ? (\n <SearchFieldButton\n disabled={disabled}\n iconOnly={iconOnlySearchButton}\n label={searchButtonLabel}\n data-testid={getTestId(\"button\")}\n />\n ) : null\n }\n data-testid={getTestId(\"text-field\")}\n type=\"search\"\n {...props}\n />\n </form>\n );\n }\n);\n\nSearchFieldBase.displayName = \"SearchFieldBase\";\n","import React, { forwardRef, useId } from \"react\";\nimport { Listbox } from \"@purpur/listbox\";\nimport { type AutocompleteOption, useAutocomplete } from \"@purpur/use-autocomplete\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./search-field.module.scss\";\nimport {\n type SearchFieldAutocompleteEnhancements,\n SearchFieldBase,\n type SearchFieldBaseProps,\n} from \"./search-field-base\";\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-search-field\";\n\nexport type SearchFieldAutocompleteProps = SearchFieldBaseProps &\n Extract<SearchFieldAutocompleteEnhancements, { suggestions: AutocompleteOption[] }>;\n\nexport const SearchFieldAutocomplete = forwardRef<HTMLInputElement, SearchFieldAutocompleteProps>(\n (\n {\n suggestions,\n suggestionsLabel,\n onSelectSuggestion,\n openSuggestionsOnFocus,\n suggestionsMaxHeight,\n ...searchFieldProps\n },\n ref\n ) => {\n const randomId = useId();\n const inputId = (searchFieldProps.id as string | undefined) ?? randomId;\n\n const autocomplete = useAutocomplete({\n id: inputId,\n options: suggestions,\n listboxLabel: suggestionsLabel,\n disabled: searchFieldProps.disabled,\n readOnly: searchFieldProps.readOnly,\n openOnFocus: openSuggestionsOnFocus,\n listboxMaxHeight: suggestionsMaxHeight,\n onSelect: onSelectSuggestion,\n [\"data-testid\"]: searchFieldProps[\"data-testid\"],\n });\n\n const setInputRef = (node: HTMLInputElement | null) => {\n (autocomplete.inputRef as React.MutableRefObject<HTMLInputElement | null>).current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLInputElement | null>).current = node;\n };\n\n const handleInputChange: React.ChangeEventHandler<HTMLInputElement> = (event) => {\n searchFieldProps.onChange?.(event);\n if (!autocomplete.isOpen) {\n autocomplete.openListbox();\n }\n };\n\n return (\n <div\n ref={autocomplete.rootRef as React.RefObject<HTMLDivElement>}\n className={cx(`${rootClassName}__autocomplete-root`)}\n >\n <SearchFieldBase\n ref={setInputRef}\n {...searchFieldProps}\n onChange={handleInputChange}\n id={inputId}\n wrapperStyle={autocomplete.anchorStyle}\n {...autocomplete.inputProps}\n />\n {autocomplete.isOpen && (\n <Listbox {...autocomplete.listboxProps} className={cx(`${rootClassName}__listbox`)}>\n {suggestions.map((option, index) => {\n const { key, ...listboxItemProps } = autocomplete.getListboxItemProps(option, index);\n\n return (\n <Listbox.Item key={key} {...listboxItemProps}>\n {option.label}\n </Listbox.Item>\n );\n })}\n </Listbox>\n )}\n </div>\n );\n }\n);\n\nSearchFieldAutocomplete.displayName = \"SearchFieldAutocomplete\";\n","import React, { forwardRef } from \"react\";\n\nimport { SearchFieldAutocomplete } from \"./search-field-autocomplete\";\nimport {\n type SearchFieldAutocompleteEnhancements,\n SearchFieldBase,\n type SearchFieldBaseProps,\n searchFieldVariants,\n} from \"./search-field-base\";\n\nexport { searchFieldVariants };\n\nexport type SearchFieldProps = SearchFieldBaseProps & SearchFieldAutocompleteEnhancements;\n\nexport const SearchField = forwardRef<HTMLInputElement, SearchFieldProps>((props, ref) => {\n if (props.suggestions) {\n return <SearchFieldAutocomplete ref={ref} {...props} />;\n }\n\n return <SearchFieldBase ref={ref} {...props} />;\n});\n\nSearchField.displayName = \"SearchField\";\n\nexport {\n SearchFieldAutocomplete,\n type SearchFieldAutocompleteProps,\n} from \"./search-field-autocomplete\";\n"],"names":["cx","c","styles","rootClassName","SearchFieldButton","dataTestid","disabled","iconOnly","label","props","Button","IconSearch","jsx","searchFieldVariants","SearchFieldBase","forwardRef","dataTestId","className","clearButtonAriaLabel","iconOnlySearchButton","onClear","onSearch","searchButtonLabel","variant","formRef","wrapperStyle","ref","getTestId","name","hasClearButton","classes","e","TextField","SearchFieldAutocomplete","suggestions","suggestionsLabel","onSelectSuggestion","openSuggestionsOnFocus","suggestionsMaxHeight","searchFieldProps","randomId","useId","inputId","autocomplete","useAutocomplete","setInputRef","node","handleInputChange","event","jsxs","Listbox","option","index","key","listboxItemProps","SearchField"],"mappings":"wnCAcMA,EAAKC,EAAAA,EAAE,KAAKC,CAAM,EAClBC,EAAgB,6BAETC,EAAoB,CAAC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,EAAG,GAAGG,CAAa,qBAAqB,EAEnD,SAAA,CAAAS,EAAAA,IAACE,EAAA,CACC,IAAK+B,EACJ,GAAGN,EACJ,SAAUQ,EACV,GAAIL,EACJ,aAAcC,EAAa,YAC1B,GAAGA,EAAa,UAAA,CAAA,EAElBA,EAAa,QACZ/B,EAAAA,IAACsC,EAAAA,QAAA,CAAS,GAAGP,EAAa,aAAc,UAAW3C,EAAG,GAAGG,CAAa,WAAW,EAC9E,WAAY,IAAI,CAACgD,EAAQC,IAAU,CAClC,KAAM,CAAE,IAAAC,EAAK,GAAGC,CAAA,EAAqBX,EAAa,oBAAoBQ,EAAQC,CAAK,EAEnF,OACExC,EAAAA,IAACsC,UAAQ,KAAR,CAAwB,GAAGI,EACzB,SAAAH,EAAO,OADSE,CAEnB,CAEJ,CAAC,CAAA,CACH,CAAA,CAAA,CAAA,CAIR,CACF,EAEApB,EAAwB,YAAc,0BC3E/B,MAAMsB,EAAcxC,EAAAA,WAA+C,CAACN,EAAOiB,IAC5EjB,EAAM,YACDG,EAAAA,IAACqB,EAAA,CAAwB,IAAAP,EAAW,GAAGjB,CAAA,CAAO,EAGhDG,EAAAA,IAACE,EAAA,CAAgB,IAAAY,EAAW,GAAGjB,CAAA,CAAO,CAC9C,EAED8C,EAAY,YAAc"}
1
+ {"version":3,"file":"search-field-Bst9d-wX.js","sources":["../../../components/search-field/src/search-field-button.tsx","../../../components/search-field/src/search-field-base.tsx","../../../components/search-field/src/search-field-autocomplete.tsx","../../../components/search-field/src/search-field.tsx"],"sourcesContent":["import React from \"react\";\nimport { Button } from \"@purpur/button\";\nimport { IconSearch } from \"@purpur/icon/search\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./search-field-button.module.scss\";\n\ntype Props = {\n [\"data-testid\"]?: string;\n disabled?: boolean;\n iconOnly?: boolean;\n label: string;\n};\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-search-field-button\";\n\nexport const SearchFieldButton = ({\n [\"data-testid\"]: dataTestid,\n disabled,\n iconOnly,\n label,\n}: Props) => {\n const props = {\n className: cx(rootClassName, {\n [`${rootClassName}--icon-only`]: iconOnly,\n }),\n disabled,\n [\"data-testid\"]: dataTestid,\n };\n\n if (iconOnly) {\n return (\n <Button {...props} aria-label={label} iconOnly size=\"sm\" type=\"submit\" variant=\"primary\">\n <IconSearch size=\"xs\" />\n </Button>\n );\n }\n\n return (\n <Button {...props} size=\"sm\" type=\"submit\" variant=\"primary\">\n {label}\n </Button>\n );\n};\n","import React, {\n type ChangeEvent,\n type CSSProperties,\n type FormEvent,\n forwardRef,\n type RefObject,\n} from \"react\";\nimport { IconSearch } from \"@purpur/icon/search\";\nimport { TextField, type TextFieldProps } from \"@purpur/text-field\";\nimport { type AutocompleteOption } from \"@purpur/use-autocomplete\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./search-field.module.scss\";\nimport { SearchFieldButton } from \"./search-field-button\";\n\nexport const searchFieldVariants = [\"button-attached\", \"no-button\"] as const;\n\ntype Variant = (typeof searchFieldVariants)[number];\n\ntype DefaultProps = {\n [\"data-testid\"]?: string;\n /**\n * An accessible label for the clear button.\n * */\n clearButtonAriaLabel: string;\n /**\n * Disables both the input field and submit button if `true`.\n * */\n disabled?: boolean;\n /**\n * Will display only a search icon in the search button if `true`.\n * */\n iconOnlySearchButton?: boolean;\n /**\n * Event handler called when the value of the search field changes.\n * */\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n /**\n * Event handler called when the clear button is clicked.\n * */\n onClear: () => void;\n /**\n * Event handler called when the search form is submitted.\n * */\n onSearch?: (e: FormEvent<HTMLFormElement>) => void;\n /**\n * The label text (or `aria-label` if `iconOnlySearchButton` is `true`) of the search button.\n * */\n searchButtonLabel?: string;\n variant: Variant;\n formRef?: RefObject<HTMLFormElement>;\n};\n\ntype TextSearchButton = {\n iconOnlySearchButton?: false;\n searchButtonLabel: string;\n variant: \"button-attached\";\n};\n\ntype IconOnlySearchButton = {\n iconOnlySearchButton: true;\n searchButtonLabel: string;\n variant: \"button-attached\";\n};\n\ntype NoButton = {\n searchButtonLabel?: never;\n variant: \"no-button\";\n};\n\nexport type SearchFieldBaseProps = DefaultProps &\n (TextSearchButton | IconOnlySearchButton | NoButton) &\n Omit<TextFieldProps, \"startAdornment\" | \"endAdornment\" | \"afterField\" | \"onChange\" | \"variant\">;\n\ntype SearchFieldBaseInternalProps = SearchFieldBaseProps & {\n wrapperStyle?: CSSProperties;\n};\n\ntype SearchFieldAutocompleteSharedProps = {\n /**\n * Called when the user selects a suggestion.\n */\n onSelectSuggestion?: (option: AutocompleteOption) => void;\n /**\n * Open the suggestions listbox when the input receives focus.\n */\n openSuggestionsOnFocus?: boolean;\n /**\n * Maximum height of the suggestions listbox. A number is interpreted as px.\n */\n suggestionsMaxHeight?: string | number;\n};\n\ntype SearchFieldWithoutAutocomplete = SearchFieldAutocompleteSharedProps & {\n suggestions?: never;\n suggestionsLabel?: never;\n};\n\ntype SearchFieldWithAutocomplete = SearchFieldAutocompleteSharedProps & {\n /**\n * The list of suggestions to display in a listbox below the field.\n * No filtering is applied — pass the already-correct (pre-filtered) list.\n * If autocomplete should stay enabled while there are temporarily no matches,\n * pass an empty array instead of `undefined` or `null`. Changing this prop\n * from an absent value to an array switches between the regular and\n * autocomplete variants, which causes a re-render, drops input focus, and\n * hides the listbox.\n */\n suggestions: AutocompleteOption[];\n /**\n * Accessible label for the suggestions listbox.\n */\n suggestionsLabel: string;\n};\n\nexport type SearchFieldAutocompleteEnhancements =\n | SearchFieldWithoutAutocomplete\n | SearchFieldWithAutocomplete;\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-search-field\";\n\nexport const SearchFieldBase = forwardRef<HTMLInputElement, SearchFieldBaseInternalProps>(\n (\n {\n [\"data-testid\"]: dataTestId,\n className,\n clearButtonAriaLabel,\n disabled,\n iconOnlySearchButton,\n onClear,\n onSearch,\n searchButtonLabel,\n variant,\n formRef,\n wrapperStyle,\n ...props\n },\n ref\n ) => {\n const getTestId = (name: string) => (dataTestId ? `${dataTestId}-${name}` : undefined);\n const hasValue =\n typeof props.value === \"number\" ? props.value !== undefined : props.value?.length;\n const hasClearButton = hasValue && !disabled && !props.readOnly && !props.loading;\n\n const classes = cx(className, rootClassName, {\n [`${rootClassName}--no-gap`]: variant === \"button-attached\",\n [`${rootClassName}--has-clear-button`]: hasClearButton,\n });\n\n return (\n <form\n ref={formRef}\n className={cx(`${rootClassName}__wrapper`)}\n data-testid={dataTestId}\n style={wrapperStyle}\n onSubmit={(e: FormEvent<HTMLFormElement>) => {\n e.preventDefault();\n onSearch?.(e);\n }}\n >\n <TextField\n ref={ref}\n className={classes}\n clearButtonAriaLabel={clearButtonAriaLabel}\n disabled={disabled}\n onClear={onClear}\n startAdornment={\n !iconOnlySearchButton ? (\n <IconSearch size=\"xs\" className={cx(`${rootClassName}__search-icon`)} key=\"1\" />\n ) : null\n }\n afterField={\n variant !== \"no-button\" ? (\n <SearchFieldButton\n disabled={disabled}\n iconOnly={iconOnlySearchButton}\n label={searchButtonLabel}\n data-testid={getTestId(\"button\")}\n />\n ) : null\n }\n data-testid={getTestId(\"text-field\")}\n type=\"search\"\n {...props}\n />\n </form>\n );\n }\n);\n\nSearchFieldBase.displayName = \"SearchFieldBase\";\n","import React, { forwardRef, useId } from \"react\";\nimport { Listbox } from \"@purpur/listbox\";\nimport { type AutocompleteOption, useAutocomplete } from \"@purpur/use-autocomplete\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./search-field.module.scss\";\nimport {\n type SearchFieldAutocompleteEnhancements,\n SearchFieldBase,\n type SearchFieldBaseProps,\n} from \"./search-field-base\";\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-search-field\";\n\nexport type SearchFieldAutocompleteProps = SearchFieldBaseProps &\n Extract<SearchFieldAutocompleteEnhancements, { suggestions: AutocompleteOption[] }>;\n\nexport const SearchFieldAutocomplete = forwardRef<HTMLInputElement, SearchFieldAutocompleteProps>(\n (\n {\n suggestions,\n suggestionsLabel,\n onSelectSuggestion,\n openSuggestionsOnFocus,\n suggestionsMaxHeight,\n ...searchFieldProps\n },\n ref\n ) => {\n const randomId = useId();\n const inputId = (searchFieldProps.id as string | undefined) ?? randomId;\n\n const autocomplete = useAutocomplete({\n id: inputId,\n options: suggestions,\n listboxLabel: suggestionsLabel,\n disabled: searchFieldProps.disabled,\n readOnly: searchFieldProps.readOnly,\n openOnFocus: openSuggestionsOnFocus,\n listboxMaxHeight: suggestionsMaxHeight,\n onSelect: onSelectSuggestion,\n [\"data-testid\"]: searchFieldProps[\"data-testid\"],\n });\n\n const setInputRef = (node: HTMLInputElement | null) => {\n (autocomplete.inputRef as React.MutableRefObject<HTMLInputElement | null>).current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLInputElement | null>).current = node;\n };\n\n const handleInputChange: React.ChangeEventHandler<HTMLInputElement> = (event) => {\n searchFieldProps.onChange?.(event);\n if (!autocomplete.isOpen) {\n autocomplete.openListbox();\n }\n };\n\n return (\n <div\n ref={autocomplete.rootRef as React.RefObject<HTMLDivElement>}\n className={cx(`${rootClassName}__autocomplete-root`)}\n >\n <SearchFieldBase\n ref={setInputRef}\n {...searchFieldProps}\n onChange={handleInputChange}\n id={inputId}\n wrapperStyle={autocomplete.anchorStyle}\n {...autocomplete.inputProps}\n />\n {autocomplete.isOpen && (\n <Listbox {...autocomplete.listboxProps} className={cx(`${rootClassName}__listbox`)}>\n {suggestions.map((option, index) => {\n const { key, ...listboxItemProps } = autocomplete.getListboxItemProps(option, index);\n\n return (\n <Listbox.Item key={key} {...listboxItemProps}>\n {option.label}\n </Listbox.Item>\n );\n })}\n </Listbox>\n )}\n </div>\n );\n }\n);\n\nSearchFieldAutocomplete.displayName = \"SearchFieldAutocomplete\";\n","import React, { forwardRef } from \"react\";\n\nimport { SearchFieldAutocomplete } from \"./search-field-autocomplete\";\nimport {\n type SearchFieldAutocompleteEnhancements,\n SearchFieldBase,\n type SearchFieldBaseProps,\n searchFieldVariants,\n} from \"./search-field-base\";\n\nexport { searchFieldVariants };\n\nexport type SearchFieldProps = SearchFieldBaseProps & SearchFieldAutocompleteEnhancements;\n\nexport const SearchField = forwardRef<HTMLInputElement, SearchFieldProps>((props, ref) => {\n if (props.suggestions) {\n return <SearchFieldAutocomplete ref={ref} {...props} />;\n }\n\n return <SearchFieldBase ref={ref} {...props} />;\n});\n\nSearchField.displayName = \"SearchField\";\n\nexport {\n SearchFieldAutocomplete,\n type SearchFieldAutocompleteProps,\n} from \"./search-field-autocomplete\";\n"],"names":["cx","c","styles","rootClassName","SearchFieldButton","dataTestid","disabled","iconOnly","label","props","Button","IconSearch","jsx","searchFieldVariants","SearchFieldBase","forwardRef","dataTestId","className","clearButtonAriaLabel","iconOnlySearchButton","onClear","onSearch","searchButtonLabel","variant","formRef","wrapperStyle","ref","getTestId","name","hasClearButton","classes","e","TextField","SearchFieldAutocomplete","suggestions","suggestionsLabel","onSelectSuggestion","openSuggestionsOnFocus","suggestionsMaxHeight","searchFieldProps","randomId","useId","inputId","autocomplete","useAutocomplete","setInputRef","node","handleInputChange","event","jsxs","Listbox","option","index","key","listboxItemProps","SearchField"],"mappings":"wnCAcMA,EAAKC,EAAAA,EAAE,KAAKC,CAAM,EAClBC,EAAgB,6BAETC,EAAoB,CAAC,CAChC,CAAC,eAAgBC,EACjB,SAAAC,EACA,SAAAC,EACA,MAAAC,CACF,IAAa,CACX,MAAMC,EAAQ,CACZ,UAAWT,EAAGG,EAAe,CAC3B,CAAC,GAAGA,CAAa,aAAa,EAAGI,CAAA,CAClC,EACD,SAAAD,EACC,cAAgBD,CAAA,EAGnB,OAAIE,QAECG,SAAA,CAAQ,GAAGD,EAAO,aAAYD,EAAO,SAAQ,GAAC,KAAK,KAAK,KAAK,SAAS,QAAQ,UAC7E,eAACG,EAAAA,EAAA,CAAW,KAAK,KAAK,EACxB,EAKFC,EAAAA,IAACF,EAAAA,OAAA,CAAQ,GAAGD,EAAO,KAAK,KAAK,KAAK,SAAS,QAAQ,UAChD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,CAAwB,GAAGI,EACzB,SAAAH,EAAO,OADSE,CAEnB,CAEJ,CAAC,CAAA,CACH,CAAA,CAAA,CAAA,CAIR,CACF,EAEApB,EAAwB,YAAc,0BC3E/B,MAAMsB,EAAcxC,EAAAA,WAA+C,CAACN,EAAOiB,IAC5EjB,EAAM,YACDG,EAAAA,IAACqB,EAAA,CAAwB,IAAAP,EAAW,GAAGjB,CAAA,CAAO,EAGhDG,EAAAA,IAACE,EAAA,CAAgB,IAAAY,EAAW,GAAGjB,CAAA,CAAO,CAC9C,EAED8C,EAAY,YAAc"}
@@ -1,80 +1,80 @@
1
- import { jsx as r, jsxs as B } from "react/jsx-runtime";
1
+ import { jsx as t, jsxs as B } from "react/jsx-runtime";
2
2
  import { forwardRef as x, useId as R } from "react";
3
- import { L as N } from "./listbox-DG4KmQP_.mjs";
3
+ import { L as S } from "./listbox-DG4KmQP_.mjs";
4
4
  import { e as A } from "./use-autocomplete.es-CVv3z8t6.mjs";
5
5
  import { c as $ } from "./bind-CU-R61T-.mjs";
6
- import { s as I } from "./search.es-DoFKg2Hr.mjs";
6
+ import { s as F } from "./search.es-DoFKg2Hr.mjs";
7
7
  import { T as V } from "./text-field-BQYzwIrG.mjs";
8
- import { b as S } from "./button-Cv7NlYbv.mjs";
9
- const F = {
10
- "purpur-search-field": "_purpur-search-field_18zr1_1",
11
- "purpur-search-field--has-clear-button": "_purpur-search-field--has-clear-button_18zr1_4",
12
- "purpur-search-field--no-gap": "_purpur-search-field--no-gap_18zr1_13",
13
- "purpur-search-field__wrapper": "_purpur-search-field__wrapper_18zr1_17",
14
- "purpur-search-field__wrapper--gap": "_purpur-search-field__wrapper--gap_18zr1_20",
15
- "purpur-search-field__search-icon": "_purpur-search-field__search-icon_18zr1_24",
16
- "purpur-search-field__close-icon": "_purpur-search-field__close-icon_18zr1_24",
17
- "purpur-search-field__autocomplete-root": "_purpur-search-field__autocomplete-root_18zr1_27",
18
- "purpur-search-field__listbox": "_purpur-search-field__listbox_18zr1_31"
8
+ import { b as v } from "./button-Cv7NlYbv.mjs";
9
+ const O = {
10
+ "purpur-search-field": "_purpur-search-field_6ot57_1",
11
+ "purpur-search-field--has-clear-button": "_purpur-search-field--has-clear-button_6ot57_4",
12
+ "purpur-search-field--no-gap": "_purpur-search-field--no-gap_6ot57_13",
13
+ "purpur-search-field__wrapper": "_purpur-search-field__wrapper_6ot57_17",
14
+ "purpur-search-field__wrapper--gap": "_purpur-search-field__wrapper--gap_6ot57_20",
15
+ "purpur-search-field__search-icon": "_purpur-search-field__search-icon_6ot57_24",
16
+ "purpur-search-field__close-icon": "_purpur-search-field__close-icon_6ot57_24",
17
+ "purpur-search-field__autocomplete-root": "_purpur-search-field__autocomplete-root_6ot57_27",
18
+ "purpur-search-field__listbox": "_purpur-search-field__listbox_6ot57_31"
19
19
  }, j = {
20
20
  "purpur-search-field-button": "_purpur-search-field-button_c16yo_1",
21
21
  "purpur-search-field-button--icon-only": "_purpur-search-field-button--icon-only_c16yo_1"
22
- }, k = $.bind(j), v = "purpur-search-field-button", D = ({
22
+ }, k = $.bind(j), w = "purpur-search-field-button", D = ({
23
23
  ["data-testid"]: e,
24
- disabled: s,
24
+ disabled: o,
25
25
  iconOnly: u,
26
- label: o
26
+ label: s
27
27
  }) => {
28
28
  const c = {
29
- className: k(v, {
30
- [`${v}--icon-only`]: u
29
+ className: k(w, {
30
+ [`${w}--icon-only`]: u
31
31
  }),
32
- disabled: s,
32
+ disabled: o,
33
33
  "data-testid": e
34
34
  };
35
- return u ? /* @__PURE__ */ r(S, { ...c, "aria-label": o, iconOnly: !0, size: "sm", type: "submit", variant: "primary", children: /* @__PURE__ */ r(I, { size: "xs" }) }) : /* @__PURE__ */ r(S, { ...c, size: "sm", type: "submit", variant: "primary", children: o });
36
- }, U = ["button-attached", "no-button"], y = $.bind(F), d = "purpur-search-field", g = x(
35
+ return u ? /* @__PURE__ */ t(v, { ...c, "aria-label": s, iconOnly: !0, size: "sm", type: "submit", variant: "primary", children: /* @__PURE__ */ t(F, { size: "xs" }) }) : /* @__PURE__ */ t(v, { ...c, size: "sm", type: "submit", variant: "primary", children: s });
36
+ }, U = ["button-attached", "no-button"], y = $.bind(O), d = "purpur-search-field", g = x(
37
37
  ({
38
38
  ["data-testid"]: e,
39
- className: s,
39
+ className: o,
40
40
  clearButtonAriaLabel: u,
41
- disabled: o,
41
+ disabled: s,
42
42
  iconOnlySearchButton: c,
43
43
  onClear: i,
44
44
  onSearch: l,
45
45
  searchButtonLabel: f,
46
46
  variant: p,
47
- formRef: t,
47
+ formRef: r,
48
48
  wrapperStyle: m,
49
49
  ...n
50
50
  }, a) => {
51
- const _ = (h) => e ? `${e}-${h}` : void 0, b = (typeof n.value == "number" ? n.value !== void 0 : n.value?.length) && !o && !n.readOnly && !n.loading, L = y(s, d, {
51
+ const _ = (h) => e ? `${e}-${h}` : void 0, b = (typeof n.value == "number" ? n.value !== void 0 : n.value?.length) && !s && !n.readOnly && !n.loading, z = y(o, d, {
52
52
  [`${d}--no-gap`]: p === "button-attached",
53
53
  [`${d}--has-clear-button`]: b
54
54
  });
55
- return /* @__PURE__ */ r(
55
+ return /* @__PURE__ */ t(
56
56
  "form",
57
57
  {
58
- ref: t,
58
+ ref: r,
59
59
  className: y(`${d}__wrapper`),
60
60
  "data-testid": e,
61
61
  style: m,
62
62
  onSubmit: (h) => {
63
63
  h.preventDefault(), l?.(h);
64
64
  },
65
- children: /* @__PURE__ */ r(
65
+ children: /* @__PURE__ */ t(
66
66
  V,
67
67
  {
68
68
  ref: a,
69
- className: L,
69
+ className: z,
70
70
  clearButtonAriaLabel: u,
71
- disabled: o,
71
+ disabled: s,
72
72
  onClear: i,
73
- startAdornment: c ? null : /* @__PURE__ */ r(I, { size: "xs", className: y(`${d}__search-icon`) }, "1"),
74
- afterField: p !== "no-button" ? /* @__PURE__ */ r(
73
+ startAdornment: c ? null : /* @__PURE__ */ t(F, { size: "xs", className: y(`${d}__search-icon`) }, "1"),
74
+ afterField: p !== "no-button" ? /* @__PURE__ */ t(
75
75
  D,
76
76
  {
77
- disabled: o,
77
+ disabled: s,
78
78
  iconOnly: c,
79
79
  label: f,
80
80
  "data-testid": _("button")
@@ -90,62 +90,62 @@ const F = {
90
90
  }
91
91
  );
92
92
  g.displayName = "SearchFieldBase";
93
- const w = $.bind(F), C = "purpur-search-field", O = x(
93
+ const C = $.bind(O), I = "purpur-search-field", L = x(
94
94
  ({
95
95
  suggestions: e,
96
- suggestionsLabel: s,
96
+ suggestionsLabel: o,
97
97
  onSelectSuggestion: u,
98
- openSuggestionsOnFocus: o,
98
+ openSuggestionsOnFocus: s,
99
99
  suggestionsMaxHeight: c,
100
100
  ...i
101
101
  }, l) => {
102
- const f = R(), p = i.id ?? f, t = A({
102
+ const f = R(), p = i.id ?? f, r = A({
103
103
  id: p,
104
104
  options: e,
105
- listboxLabel: s,
105
+ listboxLabel: o,
106
106
  disabled: i.disabled,
107
107
  readOnly: i.readOnly,
108
- openOnFocus: o,
108
+ openOnFocus: s,
109
109
  listboxMaxHeight: c,
110
110
  onSelect: u,
111
111
  "data-testid": i["data-testid"]
112
112
  }), m = (a) => {
113
- t.inputRef.current = a, typeof l == "function" ? l(a) : l && (l.current = a);
113
+ r.inputRef.current = a, typeof l == "function" ? l(a) : l && (l.current = a);
114
114
  }, n = (a) => {
115
- i.onChange?.(a), t.isOpen || t.openListbox();
115
+ i.onChange?.(a), r.isOpen || r.openListbox();
116
116
  };
117
117
  return /* @__PURE__ */ B(
118
118
  "div",
119
119
  {
120
- ref: t.rootRef,
121
- className: w(`${C}__autocomplete-root`),
120
+ ref: r.rootRef,
121
+ className: C(`${I}__autocomplete-root`),
122
122
  children: [
123
- /* @__PURE__ */ r(
123
+ /* @__PURE__ */ t(
124
124
  g,
125
125
  {
126
126
  ref: m,
127
127
  ...i,
128
128
  onChange: n,
129
129
  id: p,
130
- wrapperStyle: t.anchorStyle,
131
- ...t.inputProps
130
+ wrapperStyle: r.anchorStyle,
131
+ ...r.inputProps
132
132
  }
133
133
  ),
134
- t.isOpen && /* @__PURE__ */ r(N, { ...t.listboxProps, className: w(`${C}__listbox`), children: e.map((a, _) => {
135
- const { key: z, ...b } = t.getListboxItemProps(a, _);
136
- return /* @__PURE__ */ r(N.Item, { ...b, children: a.label }, z);
134
+ r.isOpen && /* @__PURE__ */ t(S, { ...r.listboxProps, className: C(`${I}__listbox`), children: e.map((a, _) => {
135
+ const { key: N, ...b } = r.getListboxItemProps(a, _);
136
+ return /* @__PURE__ */ t(S.Item, { ...b, children: a.label }, N);
137
137
  }) })
138
138
  ]
139
139
  }
140
140
  );
141
141
  }
142
142
  );
143
- O.displayName = "SearchFieldAutocomplete";
144
- const H = x((e, s) => e.suggestions ? /* @__PURE__ */ r(O, { ref: s, ...e }) : /* @__PURE__ */ r(g, { ref: s, ...e }));
143
+ L.displayName = "SearchFieldAutocomplete";
144
+ const H = x((e, o) => e.suggestions ? /* @__PURE__ */ t(L, { ref: o, ...e }) : /* @__PURE__ */ t(g, { ref: o, ...e }));
145
145
  H.displayName = "SearchField";
146
146
  export {
147
147
  H as S,
148
- O as a,
148
+ L as a,
149
149
  U as s
150
150
  };
151
- //# sourceMappingURL=search-field-Caj2dKLn.mjs.map
151
+ //# sourceMappingURL=search-field-DTuEiK-M.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"search-field-Caj2dKLn.mjs","sources":["../../../components/search-field/src/search-field-button.tsx","../../../components/search-field/src/search-field-base.tsx","../../../components/search-field/src/search-field-autocomplete.tsx","../../../components/search-field/src/search-field.tsx"],"sourcesContent":["import React from \"react\";\nimport { Button } from \"@purpur/button\";\nimport { IconSearch } from \"@purpur/icon/search\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./search-field-button.module.scss\";\n\ntype Props = {\n [\"data-testid\"]?: string;\n disabled?: boolean;\n iconOnly?: boolean;\n label: string;\n};\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-search-field-button\";\n\nexport const SearchFieldButton = ({\n [\"data-testid\"]: dataTestid,\n disabled,\n iconOnly,\n label,\n}: Props) => {\n const props = {\n className: cx(rootClassName, {\n [`${rootClassName}--icon-only`]: iconOnly,\n }),\n disabled,\n [\"data-testid\"]: dataTestid,\n };\n\n if (iconOnly) {\n return (\n <Button {...props} aria-label={label} iconOnly size=\"sm\" type=\"submit\" variant=\"primary\">\n <IconSearch size=\"xs\" />\n </Button>\n );\n }\n\n return (\n <Button {...props} size=\"sm\" type=\"submit\" variant=\"primary\">\n {label}\n </Button>\n );\n};\n","import React, {\n type ChangeEvent,\n type CSSProperties,\n type FormEvent,\n forwardRef,\n type RefObject,\n} from \"react\";\nimport { IconSearch } from \"@purpur/icon/search\";\nimport { TextField, type TextFieldProps } from \"@purpur/text-field\";\nimport { type AutocompleteOption } from \"@purpur/use-autocomplete\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./search-field.module.scss\";\nimport { SearchFieldButton } from \"./search-field-button\";\n\nexport const searchFieldVariants = [\"button-attached\", \"no-button\"] as const;\n\ntype Variant = (typeof searchFieldVariants)[number];\n\ntype DefaultProps = {\n [\"data-testid\"]?: string;\n /**\n * An accessible label for the clear button.\n * */\n clearButtonAriaLabel: string;\n /**\n * Disables both the input field and submit button if `true`.\n * */\n disabled?: boolean;\n /**\n * Will display only a search icon in the search button if `true`.\n * */\n iconOnlySearchButton?: boolean;\n /**\n * Event handler called when the value of the search field changes.\n * */\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n /**\n * Event handler called when the clear button is clicked.\n * */\n onClear: () => void;\n /**\n * Event handler called when the search form is submitted.\n * */\n onSearch?: (e: FormEvent<HTMLFormElement>) => void;\n /**\n * The label text (or `aria-label` if `iconOnlySearchButton` is `true`) of the search button.\n * */\n searchButtonLabel?: string;\n variant: Variant;\n formRef?: RefObject<HTMLFormElement>;\n};\n\ntype TextSearchButton = {\n iconOnlySearchButton?: false;\n searchButtonLabel: string;\n variant: \"button-attached\";\n};\n\ntype IconOnlySearchButton = {\n iconOnlySearchButton: true;\n searchButtonLabel: string;\n variant: \"button-attached\";\n};\n\ntype NoButton = {\n searchButtonLabel?: never;\n variant: \"no-button\";\n};\n\nexport type SearchFieldBaseProps = DefaultProps &\n (TextSearchButton | IconOnlySearchButton | NoButton) &\n Omit<TextFieldProps, \"startAdornment\" | \"endAdornment\" | \"afterField\" | \"onChange\" | \"variant\">;\n\ntype SearchFieldBaseInternalProps = SearchFieldBaseProps & {\n wrapperStyle?: CSSProperties;\n};\n\ntype SearchFieldAutocompleteSharedProps = {\n /**\n * Called when the user selects a suggestion.\n */\n onSelectSuggestion?: (option: AutocompleteOption) => void;\n /**\n * Open the suggestions listbox when the input receives focus.\n */\n openSuggestionsOnFocus?: boolean;\n /**\n * Maximum height of the suggestions listbox. A number is interpreted as px.\n */\n suggestionsMaxHeight?: string | number;\n};\n\ntype SearchFieldWithoutAutocomplete = SearchFieldAutocompleteSharedProps & {\n suggestions?: never;\n suggestionsLabel?: never;\n};\n\ntype SearchFieldWithAutocomplete = SearchFieldAutocompleteSharedProps & {\n /**\n * The list of suggestions to display in a listbox below the field.\n * No filtering is applied — pass the already-correct (pre-filtered) list.\n * If autocomplete should stay enabled while there are temporarily no matches,\n * pass an empty array instead of `undefined` or `null`. Changing this prop\n * from an absent value to an array switches between the regular and\n * autocomplete variants, which causes a re-render, drops input focus, and\n * hides the listbox.\n */\n suggestions: AutocompleteOption[];\n /**\n * Accessible label for the suggestions listbox.\n */\n suggestionsLabel: string;\n};\n\nexport type SearchFieldAutocompleteEnhancements =\n | SearchFieldWithoutAutocomplete\n | SearchFieldWithAutocomplete;\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-search-field\";\n\nexport const SearchFieldBase = forwardRef<HTMLInputElement, SearchFieldBaseInternalProps>(\n (\n {\n [\"data-testid\"]: dataTestId,\n className,\n clearButtonAriaLabel,\n disabled,\n iconOnlySearchButton,\n onClear,\n onSearch,\n searchButtonLabel,\n variant,\n formRef,\n wrapperStyle,\n ...props\n },\n ref\n ) => {\n const getTestId = (name: string) => (dataTestId ? `${dataTestId}-${name}` : undefined);\n const hasValue =\n typeof props.value === \"number\" ? props.value !== undefined : props.value?.length;\n const hasClearButton = hasValue && !disabled && !props.readOnly && !props.loading;\n\n const classes = cx(className, rootClassName, {\n [`${rootClassName}--no-gap`]: variant === \"button-attached\",\n [`${rootClassName}--has-clear-button`]: hasClearButton,\n });\n\n return (\n <form\n ref={formRef}\n className={cx(`${rootClassName}__wrapper`)}\n data-testid={dataTestId}\n style={wrapperStyle}\n onSubmit={(e: FormEvent<HTMLFormElement>) => {\n e.preventDefault();\n onSearch?.(e);\n }}\n >\n <TextField\n ref={ref}\n className={classes}\n clearButtonAriaLabel={clearButtonAriaLabel}\n disabled={disabled}\n onClear={onClear}\n startAdornment={\n !iconOnlySearchButton ? (\n <IconSearch size=\"xs\" className={cx(`${rootClassName}__search-icon`)} key=\"1\" />\n ) : null\n }\n afterField={\n variant !== \"no-button\" ? (\n <SearchFieldButton\n disabled={disabled}\n iconOnly={iconOnlySearchButton}\n label={searchButtonLabel}\n data-testid={getTestId(\"button\")}\n />\n ) : null\n }\n data-testid={getTestId(\"text-field\")}\n type=\"search\"\n {...props}\n />\n </form>\n );\n }\n);\n\nSearchFieldBase.displayName = \"SearchFieldBase\";\n","import React, { forwardRef, useId } from \"react\";\nimport { Listbox } from \"@purpur/listbox\";\nimport { type AutocompleteOption, useAutocomplete } from \"@purpur/use-autocomplete\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./search-field.module.scss\";\nimport {\n type SearchFieldAutocompleteEnhancements,\n SearchFieldBase,\n type SearchFieldBaseProps,\n} from \"./search-field-base\";\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-search-field\";\n\nexport type SearchFieldAutocompleteProps = SearchFieldBaseProps &\n Extract<SearchFieldAutocompleteEnhancements, { suggestions: AutocompleteOption[] }>;\n\nexport const SearchFieldAutocomplete = forwardRef<HTMLInputElement, SearchFieldAutocompleteProps>(\n (\n {\n suggestions,\n suggestionsLabel,\n onSelectSuggestion,\n openSuggestionsOnFocus,\n suggestionsMaxHeight,\n ...searchFieldProps\n },\n ref\n ) => {\n const randomId = useId();\n const inputId = (searchFieldProps.id as string | undefined) ?? randomId;\n\n const autocomplete = useAutocomplete({\n id: inputId,\n options: suggestions,\n listboxLabel: suggestionsLabel,\n disabled: searchFieldProps.disabled,\n readOnly: searchFieldProps.readOnly,\n openOnFocus: openSuggestionsOnFocus,\n listboxMaxHeight: suggestionsMaxHeight,\n onSelect: onSelectSuggestion,\n [\"data-testid\"]: searchFieldProps[\"data-testid\"],\n });\n\n const setInputRef = (node: HTMLInputElement | null) => {\n (autocomplete.inputRef as React.MutableRefObject<HTMLInputElement | null>).current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLInputElement | null>).current = node;\n };\n\n const handleInputChange: React.ChangeEventHandler<HTMLInputElement> = (event) => {\n searchFieldProps.onChange?.(event);\n if (!autocomplete.isOpen) {\n autocomplete.openListbox();\n }\n };\n\n return (\n <div\n ref={autocomplete.rootRef as React.RefObject<HTMLDivElement>}\n className={cx(`${rootClassName}__autocomplete-root`)}\n >\n <SearchFieldBase\n ref={setInputRef}\n {...searchFieldProps}\n onChange={handleInputChange}\n id={inputId}\n wrapperStyle={autocomplete.anchorStyle}\n {...autocomplete.inputProps}\n />\n {autocomplete.isOpen && (\n <Listbox {...autocomplete.listboxProps} className={cx(`${rootClassName}__listbox`)}>\n {suggestions.map((option, index) => {\n const { key, ...listboxItemProps } = autocomplete.getListboxItemProps(option, index);\n\n return (\n <Listbox.Item key={key} {...listboxItemProps}>\n {option.label}\n </Listbox.Item>\n );\n })}\n </Listbox>\n )}\n </div>\n );\n }\n);\n\nSearchFieldAutocomplete.displayName = \"SearchFieldAutocomplete\";\n","import React, { forwardRef } from \"react\";\n\nimport { SearchFieldAutocomplete } from \"./search-field-autocomplete\";\nimport {\n type SearchFieldAutocompleteEnhancements,\n SearchFieldBase,\n type SearchFieldBaseProps,\n searchFieldVariants,\n} from \"./search-field-base\";\n\nexport { searchFieldVariants };\n\nexport type SearchFieldProps = SearchFieldBaseProps & SearchFieldAutocompleteEnhancements;\n\nexport const SearchField = forwardRef<HTMLInputElement, SearchFieldProps>((props, ref) => {\n if (props.suggestions) {\n return <SearchFieldAutocomplete ref={ref} {...props} />;\n }\n\n return <SearchFieldBase ref={ref} {...props} />;\n});\n\nSearchField.displayName = \"SearchField\";\n\nexport {\n SearchFieldAutocomplete,\n type SearchFieldAutocompleteProps,\n} from \"./search-field-autocomplete\";\n"],"names":["cx","c","styles","rootClassName","SearchFieldButton","dataTestid","disabled","iconOnly","label","props","Button","IconSearch","jsx","searchFieldVariants","SearchFieldBase","forwardRef","dataTestId","className","clearButtonAriaLabel","iconOnlySearchButton","onClear","onSearch","searchButtonLabel","variant","formRef","wrapperStyle","ref","getTestId","name","hasClearButton","classes","e","TextField","SearchFieldAutocomplete","suggestions","suggestionsLabel","onSelectSuggestion","openSuggestionsOnFocus","suggestionsMaxHeight","searchFieldProps","randomId","useId","inputId","autocomplete","useAutocomplete","setInputRef","node","handleInputChange","event","jsxs","Listbox","option","index","key","listboxItemProps","SearchField"],"mappings":";;;;;;;;;;;;;;;;;;;;;GAcMA,IAAKC,EAAE,KAAKC,CAAM,GAClBC,IAAgB,8BAETC,IAAoB,CAAC;AAAA,EAChC,CAAC,gBAAgBC;AAAA,EACjB,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC;AACF,MAAa;AACX,QAAMC,IAAQ;AAAA,IACZ,WAAWT,EAAGG,GAAe;AAAA,MAC3B,CAAC,GAAGA,CAAa,aAAa,GAAGI;AAAA,IAAA,CAClC;AAAA,IACD,UAAAD;AAAA,IACC,eAAgBD;AAAA,EAAA;AAGnB,SAAIE,sBAECG,GAAA,EAAQ,GAAGD,GAAO,cAAYD,GAAO,UAAQ,IAAC,MAAK,MAAK,MAAK,UAAS,SAAQ,WAC7E,4BAACG,GAAA,EAAW,MAAK,MAAK,GACxB,IAKF,gBAAAC,EAACF,GAAA,E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AA;AAAA,QACC,KAAKN,EAAa;AAAA,QAClB,WAAW3C,EAAG,GAAGG,CAAa,qBAAqB;AAAA,QAEnD,UAAA;AAAA,UAAA,gBAAAS;AAAA,YAACE;AAAA,YAAA;AAAA,cACC,KAAK+B;AAAA,cACJ,GAAGN;AAAA,cACJ,UAAUQ;AAAA,cACV,IAAIL;AAAA,cACJ,cAAcC,EAAa;AAAA,cAC1B,GAAGA,EAAa;AAAA,YAAA;AAAA,UAAA;AAAA,UAElBA,EAAa,UACZ,gBAAA/B,EAACsC,GAAA,EAAS,GAAGP,EAAa,cAAc,WAAW3C,EAAG,GAAGG,CAAa,WAAW,GAC9E,YAAY,IAAI,CAACgD,GAAQC,MAAU;AAClC,kBAAM,EAAE,KAAAC,GAAK,GAAGC,EAAA,IAAqBX,EAAa,oBAAoBQ,GAAQC,CAAK;AAEnF,mBACE,gBAAAxC,EAACsC,EAAQ,MAAR,EAAwB,GAAGI,GACzB,UAAAH,EAAO,SADSE,CAEnB;AAAA,UAEJ,CAAC,EAAA,CACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEApB,EAAwB,cAAc;AC3E/B,MAAMsB,IAAcxC,EAA+C,CAACN,GAAOiB,MAC5EjB,EAAM,cACD,gBAAAG,EAACqB,GAAA,EAAwB,KAAAP,GAAW,GAAGjB,EAAA,CAAO,IAGhD,gBAAAG,EAACE,GAAA,EAAgB,KAAAY,GAAW,GAAGjB,EAAA,CAAO,CAC9C;AAED8C,EAAY,cAAc;"}
1
+ {"version":3,"file":"search-field-DTuEiK-M.mjs","sources":["../../../components/search-field/src/search-field-button.tsx","../../../components/search-field/src/search-field-base.tsx","../../../components/search-field/src/search-field-autocomplete.tsx","../../../components/search-field/src/search-field.tsx"],"sourcesContent":["import React from \"react\";\nimport { Button } from \"@purpur/button\";\nimport { IconSearch } from \"@purpur/icon/search\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./search-field-button.module.scss\";\n\ntype Props = {\n [\"data-testid\"]?: string;\n disabled?: boolean;\n iconOnly?: boolean;\n label: string;\n};\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-search-field-button\";\n\nexport const SearchFieldButton = ({\n [\"data-testid\"]: dataTestid,\n disabled,\n iconOnly,\n label,\n}: Props) => {\n const props = {\n className: cx(rootClassName, {\n [`${rootClassName}--icon-only`]: iconOnly,\n }),\n disabled,\n [\"data-testid\"]: dataTestid,\n };\n\n if (iconOnly) {\n return (\n <Button {...props} aria-label={label} iconOnly size=\"sm\" type=\"submit\" variant=\"primary\">\n <IconSearch size=\"xs\" />\n </Button>\n );\n }\n\n return (\n <Button {...props} size=\"sm\" type=\"submit\" variant=\"primary\">\n {label}\n </Button>\n );\n};\n","import React, {\n type ChangeEvent,\n type CSSProperties,\n type FormEvent,\n forwardRef,\n type RefObject,\n} from \"react\";\nimport { IconSearch } from \"@purpur/icon/search\";\nimport { TextField, type TextFieldProps } from \"@purpur/text-field\";\nimport { type AutocompleteOption } from \"@purpur/use-autocomplete\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./search-field.module.scss\";\nimport { SearchFieldButton } from \"./search-field-button\";\n\nexport const searchFieldVariants = [\"button-attached\", \"no-button\"] as const;\n\ntype Variant = (typeof searchFieldVariants)[number];\n\ntype DefaultProps = {\n [\"data-testid\"]?: string;\n /**\n * An accessible label for the clear button.\n * */\n clearButtonAriaLabel: string;\n /**\n * Disables both the input field and submit button if `true`.\n * */\n disabled?: boolean;\n /**\n * Will display only a search icon in the search button if `true`.\n * */\n iconOnlySearchButton?: boolean;\n /**\n * Event handler called when the value of the search field changes.\n * */\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n /**\n * Event handler called when the clear button is clicked.\n * */\n onClear: () => void;\n /**\n * Event handler called when the search form is submitted.\n * */\n onSearch?: (e: FormEvent<HTMLFormElement>) => void;\n /**\n * The label text (or `aria-label` if `iconOnlySearchButton` is `true`) of the search button.\n * */\n searchButtonLabel?: string;\n variant: Variant;\n formRef?: RefObject<HTMLFormElement>;\n};\n\ntype TextSearchButton = {\n iconOnlySearchButton?: false;\n searchButtonLabel: string;\n variant: \"button-attached\";\n};\n\ntype IconOnlySearchButton = {\n iconOnlySearchButton: true;\n searchButtonLabel: string;\n variant: \"button-attached\";\n};\n\ntype NoButton = {\n searchButtonLabel?: never;\n variant: \"no-button\";\n};\n\nexport type SearchFieldBaseProps = DefaultProps &\n (TextSearchButton | IconOnlySearchButton | NoButton) &\n Omit<TextFieldProps, \"startAdornment\" | \"endAdornment\" | \"afterField\" | \"onChange\" | \"variant\">;\n\ntype SearchFieldBaseInternalProps = SearchFieldBaseProps & {\n wrapperStyle?: CSSProperties;\n};\n\ntype SearchFieldAutocompleteSharedProps = {\n /**\n * Called when the user selects a suggestion.\n */\n onSelectSuggestion?: (option: AutocompleteOption) => void;\n /**\n * Open the suggestions listbox when the input receives focus.\n */\n openSuggestionsOnFocus?: boolean;\n /**\n * Maximum height of the suggestions listbox. A number is interpreted as px.\n */\n suggestionsMaxHeight?: string | number;\n};\n\ntype SearchFieldWithoutAutocomplete = SearchFieldAutocompleteSharedProps & {\n suggestions?: never;\n suggestionsLabel?: never;\n};\n\ntype SearchFieldWithAutocomplete = SearchFieldAutocompleteSharedProps & {\n /**\n * The list of suggestions to display in a listbox below the field.\n * No filtering is applied — pass the already-correct (pre-filtered) list.\n * If autocomplete should stay enabled while there are temporarily no matches,\n * pass an empty array instead of `undefined` or `null`. Changing this prop\n * from an absent value to an array switches between the regular and\n * autocomplete variants, which causes a re-render, drops input focus, and\n * hides the listbox.\n */\n suggestions: AutocompleteOption[];\n /**\n * Accessible label for the suggestions listbox.\n */\n suggestionsLabel: string;\n};\n\nexport type SearchFieldAutocompleteEnhancements =\n | SearchFieldWithoutAutocomplete\n | SearchFieldWithAutocomplete;\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-search-field\";\n\nexport const SearchFieldBase = forwardRef<HTMLInputElement, SearchFieldBaseInternalProps>(\n (\n {\n [\"data-testid\"]: dataTestId,\n className,\n clearButtonAriaLabel,\n disabled,\n iconOnlySearchButton,\n onClear,\n onSearch,\n searchButtonLabel,\n variant,\n formRef,\n wrapperStyle,\n ...props\n },\n ref\n ) => {\n const getTestId = (name: string) => (dataTestId ? `${dataTestId}-${name}` : undefined);\n const hasValue =\n typeof props.value === \"number\" ? props.value !== undefined : props.value?.length;\n const hasClearButton = hasValue && !disabled && !props.readOnly && !props.loading;\n\n const classes = cx(className, rootClassName, {\n [`${rootClassName}--no-gap`]: variant === \"button-attached\",\n [`${rootClassName}--has-clear-button`]: hasClearButton,\n });\n\n return (\n <form\n ref={formRef}\n className={cx(`${rootClassName}__wrapper`)}\n data-testid={dataTestId}\n style={wrapperStyle}\n onSubmit={(e: FormEvent<HTMLFormElement>) => {\n e.preventDefault();\n onSearch?.(e);\n }}\n >\n <TextField\n ref={ref}\n className={classes}\n clearButtonAriaLabel={clearButtonAriaLabel}\n disabled={disabled}\n onClear={onClear}\n startAdornment={\n !iconOnlySearchButton ? (\n <IconSearch size=\"xs\" className={cx(`${rootClassName}__search-icon`)} key=\"1\" />\n ) : null\n }\n afterField={\n variant !== \"no-button\" ? (\n <SearchFieldButton\n disabled={disabled}\n iconOnly={iconOnlySearchButton}\n label={searchButtonLabel}\n data-testid={getTestId(\"button\")}\n />\n ) : null\n }\n data-testid={getTestId(\"text-field\")}\n type=\"search\"\n {...props}\n />\n </form>\n );\n }\n);\n\nSearchFieldBase.displayName = \"SearchFieldBase\";\n","import React, { forwardRef, useId } from \"react\";\nimport { Listbox } from \"@purpur/listbox\";\nimport { type AutocompleteOption, useAutocomplete } from \"@purpur/use-autocomplete\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./search-field.module.scss\";\nimport {\n type SearchFieldAutocompleteEnhancements,\n SearchFieldBase,\n type SearchFieldBaseProps,\n} from \"./search-field-base\";\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-search-field\";\n\nexport type SearchFieldAutocompleteProps = SearchFieldBaseProps &\n Extract<SearchFieldAutocompleteEnhancements, { suggestions: AutocompleteOption[] }>;\n\nexport const SearchFieldAutocomplete = forwardRef<HTMLInputElement, SearchFieldAutocompleteProps>(\n (\n {\n suggestions,\n suggestionsLabel,\n onSelectSuggestion,\n openSuggestionsOnFocus,\n suggestionsMaxHeight,\n ...searchFieldProps\n },\n ref\n ) => {\n const randomId = useId();\n const inputId = (searchFieldProps.id as string | undefined) ?? randomId;\n\n const autocomplete = useAutocomplete({\n id: inputId,\n options: suggestions,\n listboxLabel: suggestionsLabel,\n disabled: searchFieldProps.disabled,\n readOnly: searchFieldProps.readOnly,\n openOnFocus: openSuggestionsOnFocus,\n listboxMaxHeight: suggestionsMaxHeight,\n onSelect: onSelectSuggestion,\n [\"data-testid\"]: searchFieldProps[\"data-testid\"],\n });\n\n const setInputRef = (node: HTMLInputElement | null) => {\n (autocomplete.inputRef as React.MutableRefObject<HTMLInputElement | null>).current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLInputElement | null>).current = node;\n };\n\n const handleInputChange: React.ChangeEventHandler<HTMLInputElement> = (event) => {\n searchFieldProps.onChange?.(event);\n if (!autocomplete.isOpen) {\n autocomplete.openListbox();\n }\n };\n\n return (\n <div\n ref={autocomplete.rootRef as React.RefObject<HTMLDivElement>}\n className={cx(`${rootClassName}__autocomplete-root`)}\n >\n <SearchFieldBase\n ref={setInputRef}\n {...searchFieldProps}\n onChange={handleInputChange}\n id={inputId}\n wrapperStyle={autocomplete.anchorStyle}\n {...autocomplete.inputProps}\n />\n {autocomplete.isOpen && (\n <Listbox {...autocomplete.listboxProps} className={cx(`${rootClassName}__listbox`)}>\n {suggestions.map((option, index) => {\n const { key, ...listboxItemProps } = autocomplete.getListboxItemProps(option, index);\n\n return (\n <Listbox.Item key={key} {...listboxItemProps}>\n {option.label}\n </Listbox.Item>\n );\n })}\n </Listbox>\n )}\n </div>\n );\n }\n);\n\nSearchFieldAutocomplete.displayName = \"SearchFieldAutocomplete\";\n","import React, { forwardRef } from \"react\";\n\nimport { SearchFieldAutocomplete } from \"./search-field-autocomplete\";\nimport {\n type SearchFieldAutocompleteEnhancements,\n SearchFieldBase,\n type SearchFieldBaseProps,\n searchFieldVariants,\n} from \"./search-field-base\";\n\nexport { searchFieldVariants };\n\nexport type SearchFieldProps = SearchFieldBaseProps & SearchFieldAutocompleteEnhancements;\n\nexport const SearchField = forwardRef<HTMLInputElement, SearchFieldProps>((props, ref) => {\n if (props.suggestions) {\n return <SearchFieldAutocomplete ref={ref} {...props} />;\n }\n\n return <SearchFieldBase ref={ref} {...props} />;\n});\n\nSearchField.displayName = \"SearchField\";\n\nexport {\n SearchFieldAutocomplete,\n type SearchFieldAutocompleteProps,\n} from \"./search-field-autocomplete\";\n"],"names":["cx","c","styles","rootClassName","SearchFieldButton","dataTestid","disabled","iconOnly","label","props","Button","IconSearch","jsx","searchFieldVariants","SearchFieldBase","forwardRef","dataTestId","className","clearButtonAriaLabel","iconOnlySearchButton","onClear","onSearch","searchButtonLabel","variant","formRef","wrapperStyle","ref","getTestId","name","hasClearButton","classes","e","TextField","SearchFieldAutocomplete","suggestions","suggestionsLabel","onSelectSuggestion","openSuggestionsOnFocus","suggestionsMaxHeight","searchFieldProps","randomId","useId","inputId","autocomplete","useAutocomplete","setInputRef","node","handleInputChange","event","jsxs","Listbox","option","index","key","listboxItemProps","SearchField"],"mappings":";;;;;;;;;;;;;;;;;;;;;GAcMA,IAAKC,EAAE,KAAKC,CAAM,GAClBC,IAAgB,8BAETC,IAAoB,CAAC;AAAA,EAChC,CAAC,gBAAgBC;AAAA,EACjB,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC;AACF,MAAa;AACX,QAAMC,IAAQ;AAAA,IACZ,WAAWT,EAAGG,GAAe;AAAA,MAC3B,CAAC,GAAGA,CAAa,aAAa,GAAGI;AAAA,IAAA,CAClC;AAAA,IACD,UAAAD;AAAA,IACC,eAAgBD;AAAA,EAAA;AAGnB,SAAIE,sBAECG,G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,IACnF,GAEMC,IAAgE,CAACC,MAAU;AAC/E,MAAAT,EAAiB,WAAWS,CAAK,GAC5BL,EAAa,UAChBA,EAAa,YAAA;AAAA,IAEjB;AAEA,WACE,gBAAAM;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAKN,EAAa;AAAA,QAClB,WAAW3C,EAAG,GAAGG,CAAa,qBAAqB;AAAA,QAEnD,UAAA;AAAA,UAAA,gBAAAS;AAAA,YAACE;AAAA,YAAA;AAAA,cACC,KAAK+B;AAAA,cACJ,GAAGN;AAAA,cACJ,UAAUQ;AAAA,cACV,IAAIL;AAAA,cACJ,cAAcC,EAAa;AAAA,cAC1B,GAAGA,EAAa;AAAA,YAAA;AAAA,UAAA;AAAA,UAElBA,EAAa,UACZ,gBAAA/B,EAACsC,GAAA,EAAS,GAAGP,EAAa,cAAc,WAAW3C,EAAG,GAAGG,CAAa,WAAW,GAC9E,YAAY,IAAI,CAACgD,GAAQC,MAAU;AAClC,kBAAM,EAAE,KAAAC,GAAK,GAAGC,EAAA,IAAqBX,EAAa,oBAAoBQ,GAAQC,CAAK;AAEnF,mBACE,gBAAAxC,EAACsC,EAAQ,MAAR,EAAwB,GAAGI,GACzB,UAAAH,EAAO,SADSE,CAEnB;AAAA,UAEJ,CAAC,EAAA,CACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEApB,EAAwB,cAAc;AC3E/B,MAAMsB,IAAcxC,EAA+C,CAACN,GAAOiB,MAC5EjB,EAAM,cACD,gBAAAG,EAACqB,GAAA,EAAwB,KAAAP,GAAW,GAAGjB,EAAA,CAAO,IAGhD,gBAAAG,EAACE,GAAA,EAAgB,KAAAY,GAAW,GAAGjB,EAAA,CAAO,CAC9C;AAED8C,EAAY,cAAc;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./search-field-DAktzYb0.js");exports.SearchField=e.SearchField;exports.SearchFieldAutocomplete=e.SearchFieldAutocomplete;exports.searchFieldVariants=e.searchFieldVariants;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./search-field-Bst9d-wX.js");exports.SearchField=e.SearchField;exports.SearchFieldAutocomplete=e.SearchFieldAutocomplete;exports.searchFieldVariants=e.searchFieldVariants;
2
2
  //# sourceMappingURL=search-field.cjs.js.map
@@ -1,4 +1,4 @@
1
- import { S as r, a as s, s as c } from "./search-field-Caj2dKLn.mjs";
1
+ import { S as r, a as s, s as c } from "./search-field-DTuEiK-M.mjs";
2
2
  export {
3
3
  r as SearchField,
4
4
  s as SearchFieldAutocomplete,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpur/library",
3
- "version": "9.1.1",
3
+ "version": "9.1.2",
4
4
  "license": "AGPL-3.0-only",
5
5
  "sideEffects": [
6
6
  "*.css",
@@ -107,72 +107,72 @@
107
107
  "vite": "^7.2.2",
108
108
  "shx": "~0.4.0",
109
109
  "@purpur/accordion": "8.21.0",
110
- "@purpur/alert-badge": "8.21.0",
111
- "@purpur/badge": "8.21.0",
112
110
  "@purpur/action": "8.21.0",
113
- "@purpur/breadcrumbs": "8.21.0",
114
- "@purpur/button": "8.21.0",
111
+ "@purpur/badge": "8.21.0",
115
112
  "@purpur/autocomplete": "8.21.0",
116
- "@purpur/calendar": "8.21.0",
113
+ "@purpur/alert-badge": "8.21.0",
114
+ "@purpur/button": "8.21.0",
115
+ "@purpur/breadcrumbs": "8.21.0",
117
116
  "@purpur/card": "8.21.0",
118
117
  "@purpur/checkbox": "8.21.0",
119
118
  "@purpur/color-dot": "8.21.0",
119
+ "@purpur/calendar": "8.21.0",
120
120
  "@purpur/common-types": "8.21.0",
121
121
  "@purpur/chip-group": "8.21.0",
122
122
  "@purpur/component-rig": "1.0.0",
123
123
  "@purpur/container": "8.21.0",
124
124
  "@purpur/content-block": "8.21.0",
125
- "@purpur/countdown": "8.21.0",
126
125
  "@purpur/counter-badge": "8.21.0",
126
+ "@purpur/countdown": "8.21.0",
127
+ "@purpur/cta-link": "8.21.0",
127
128
  "@purpur/date-field": "8.21.0",
128
129
  "@purpur/date-picker": "8.21.0",
129
130
  "@purpur/dismissable-chip-group": "8.21.0",
130
- "@purpur/drawer": "8.21.0",
131
- "@purpur/cta-link": "8.21.0",
132
131
  "@purpur/field-error-text": "8.21.0",
133
- "@purpur/footer": "8.21.0",
134
- "@purpur/field-helper-text": "8.21.0",
132
+ "@purpur/drawer": "8.21.0",
135
133
  "@purpur/grid": "8.21.0",
136
- "@purpur/heading": "8.21.0",
137
- "@purpur/icon": "8.21.0",
134
+ "@purpur/field-helper-text": "8.21.0",
138
135
  "@purpur/hero-banner": "8.21.0",
139
- "@purpur/illustrative-icon": "8.21.0",
136
+ "@purpur/icon": "8.21.0",
137
+ "@purpur/heading": "8.21.0",
138
+ "@purpur/footer": "8.21.0",
139
+ "@purpur/link": "8.21.0",
140
140
  "@purpur/label": "8.21.0",
141
+ "@purpur/illustrative-icon": "8.21.0",
141
142
  "@purpur/listbox": "8.21.0",
142
- "@purpur/link": "8.21.0",
143
- "@purpur/logo": "8.21.0",
144
143
  "@purpur/modal": "8.21.0",
144
+ "@purpur/logo": "8.21.0",
145
+ "@purpur/notification-banner": "8.21.0",
145
146
  "@purpur/notification": "8.21.0",
147
+ "@purpur/paragraph": "8.21.0",
146
148
  "@purpur/pagination": "8.21.0",
147
- "@purpur/notification-banner": "8.21.0",
148
149
  "@purpur/password-field": "8.21.0",
149
- "@purpur/popover": "8.21.0",
150
- "@purpur/paragraph": "8.21.0",
150
+ "@purpur/promotion-card": "8.21.0",
151
151
  "@purpur/product-card": "8.21.0",
152
- "@purpur/quantity-selector": "8.21.0",
152
+ "@purpur/popover": "8.21.0",
153
153
  "@purpur/radio-button-group": "8.21.0",
154
154
  "@purpur/radio-card-group": "8.21.0",
155
+ "@purpur/quantity-selector": "8.21.0",
155
156
  "@purpur/rich-text": "8.21.0",
156
- "@purpur/promotion-card": "8.21.0",
157
157
  "@purpur/search-field": "8.21.0",
158
- "@purpur/select": "8.21.0",
159
158
  "@purpur/skeleton": "8.21.0",
160
- "@purpur/spacer": "8.21.0",
159
+ "@purpur/select": "8.21.0",
161
160
  "@purpur/slider": "8.21.0",
162
- "@purpur/spinner": "8.21.0",
163
161
  "@purpur/stepper": "8.21.0",
162
+ "@purpur/spacer": "8.21.0",
164
163
  "@purpur/table": "8.21.0",
164
+ "@purpur/spinner": "8.21.0",
165
165
  "@purpur/text-area": "8.21.0",
166
166
  "@purpur/tabs": "8.21.0",
167
167
  "@purpur/text-field": "8.21.0",
168
- "@purpur/text-spacing": "8.21.0",
169
168
  "@purpur/theme": "8.21.0",
170
- "@purpur/toggle": "8.21.0",
169
+ "@purpur/text-spacing": "8.21.0",
171
170
  "@purpur/tokens": "8.21.0",
171
+ "@purpur/toggle": "8.21.0",
172
+ "@purpur/visually-hidden": "8.21.0",
173
+ "@purpur/chat-field": "9.1.2",
172
174
  "@purpur/tooltip": "8.21.0",
173
- "@purpur/chat-field": "9.1.1",
174
- "@purpur/dropdown": "0.1.0",
175
- "@purpur/visually-hidden": "8.21.0"
175
+ "@purpur/dropdown": "0.1.0"
176
176
  },
177
177
  "peerDependencies": {
178
178
  "@types/react": "^18 || ^19",
@@ -1,2 +0,0 @@
1
- "use strict";const e=require("react/jsx-runtime"),f=require("react"),N=require("./listbox-COBHLRtB.js"),O=require("./use-autocomplete.es-BHDgQLae.js"),j=require("./bind-DeUYJ6m9.js"),v=require("./search.es-Cg2amJSR.js"),A=require("./text-field-BwxGMWds.js"),S=require("./button-Dqxdc3nC.js"),R={"purpur-search-field":"_purpur-search-field_18zr1_1","purpur-search-field--has-clear-button":"_purpur-search-field--has-clear-button_18zr1_4","purpur-search-field--no-gap":"_purpur-search-field--no-gap_18zr1_13","purpur-search-field__wrapper":"_purpur-search-field__wrapper_18zr1_17","purpur-search-field__wrapper--gap":"_purpur-search-field__wrapper--gap_18zr1_20","purpur-search-field__search-icon":"_purpur-search-field__search-icon_18zr1_24","purpur-search-field__close-icon":"_purpur-search-field__close-icon_18zr1_24","purpur-search-field__autocomplete-root":"_purpur-search-field__autocomplete-root_18zr1_27","purpur-search-field__listbox":"_purpur-search-field__listbox_18zr1_31"},B={"purpur-search-field-button":"_purpur-search-field-button_c16yo_1","purpur-search-field-button--icon-only":"_purpur-search-field-button--icon-only_c16yo_1"},L=j.c.bind(B),F="purpur-search-field-button",V=({["data-testid"]:t,disabled:a,iconOnly:u,label:o})=>{const i={className:L(F,{[`${F}--icon-only`]:u}),disabled:a,"data-testid":t};return u?e.jsx(S.Button,{...i,"aria-label":o,iconOnly:!0,size:"sm",type:"submit",variant:"primary",children:e.jsx(v.s,{size:"xs"})}):e.jsx(S.Button,{...i,size:"sm",type:"submit",variant:"primary",children:o})},k=["button-attached","no-button"],y=j.c.bind(R),d="purpur-search-field",$=f.forwardRef(({["data-testid"]:t,className:a,clearButtonAriaLabel:u,disabled:o,iconOnlySearchButton:i,onClear:c,onSearch:l,searchButtonLabel:b,variant:p,formRef:r,wrapperStyle:m,...n},s)=>{const _=h=>t?`${t}-${h}`:void 0,x=(typeof n.value=="number"?n.value!==void 0:n.value?.length)&&!o&&!n.readOnly&&!n.loading,I=y(a,d,{[`${d}--no-gap`]:p==="button-attached",[`${d}--has-clear-button`]:x});return e.jsx("form",{ref:r,className:y(`${d}__wrapper`),"data-testid":t,style:m,onSubmit:h=>{h.preventDefault(),l?.(h)},children:e.jsx(A.TextField,{ref:s,className:I,clearButtonAriaLabel:u,disabled:o,onClear:c,startAdornment:i?null:e.jsx(v.s,{size:"xs",className:y(`${d}__search-icon`)},"1"),afterField:p!=="no-button"?e.jsx(V,{disabled:o,iconOnly:i,label:b,"data-testid":_("button")}):null,"data-testid":_("text-field"),type:"search",...n})})});$.displayName="SearchFieldBase";const w=j.c.bind(R),q="purpur-search-field",g=f.forwardRef(({suggestions:t,suggestionsLabel:a,onSelectSuggestion:u,openSuggestionsOnFocus:o,suggestionsMaxHeight:i,...c},l)=>{const b=f.useId(),p=c.id??b,r=O.ee({id:p,options:t,listboxLabel:a,disabled:c.disabled,readOnly:c.readOnly,openOnFocus:o,listboxMaxHeight:i,onSelect:u,"data-testid":c["data-testid"]}),m=s=>{r.inputRef.current=s,typeof l=="function"?l(s):l&&(l.current=s)},n=s=>{c.onChange?.(s),r.isOpen||r.openListbox()};return e.jsxs("div",{ref:r.rootRef,className:w(`${q}__autocomplete-root`),children:[e.jsx($,{ref:m,...c,onChange:n,id:p,wrapperStyle:r.anchorStyle,...r.inputProps}),r.isOpen&&e.jsx(N.Listbox,{...r.listboxProps,className:w(`${q}__listbox`),children:t.map((s,_)=>{const{key:z,...x}=r.getListboxItemProps(s,_);return e.jsx(N.Listbox.Item,{...x,children:s.label},z)})})]})});g.displayName="SearchFieldAutocomplete";const C=f.forwardRef((t,a)=>t.suggestions?e.jsx(g,{ref:a,...t}):e.jsx($,{ref:a,...t}));C.displayName="SearchField";exports.SearchField=C;exports.SearchFieldAutocomplete=g;exports.searchFieldVariants=k;
2
- //# sourceMappingURL=search-field-DAktzYb0.js.map