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WAAW,CAAA,GAAA,6CAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAClD,OAAO,SAAS,EAAE;IAElB,qBACE,0DAAC,CAAA,GAAA,6BAAE,EAAE,GAAG;QACL,GAAG,QAAQ;QACX,GAAG,WAAW;QACf,KAAK;QACL,MAAM,MAAM,IAAI,IAAI;QACpB,cAAY,MAAM,KAAK,KAAK,MAAM;QAClC,iBAAe,MAAM,UAAU,IAAI;QACnC,gBAAc,WAAW,SAAS,IAAI;QACtC,iBAAe,MAAM,UAAU,IAAI;QACnC,iBAAe,MAAM,UAAU,IAAI;qBACnC,0DAAC,CAAA,GAAA,kCAAO;QACN,QAAQ;YACN;gBAAC,CAAA,GAAA,sCAAW;gBAAG;oBAAC,GAAG,UAAU;oBAAE,KAAK;gBAAQ;aAAE;YAC9C;gBAAC,CAAA,GAAA,sCAAW;gBAAG;oBAAC,GAAG,UAAU;oBAAE,KAAK;gBAAQ;aAAE;YAC9C;gBAAC,CAAA,GAAA,uCAAY;gBAAG;aAAiB;YACjC;gBACE,CAAA,GAAA,qCAAU;gBACV;oBACE,OAAO;wBACL,aAAa;wBACb,cAAc;oBAChB;gBACF;aACD;YACD;gBAAC,CAAA,GAAA,sCAAW;gBAAG;oBAAC,WAAW,WAAW,SAAS;oBAAE,YAAY,MAAM,UAAU,IAAI;gBAAK;aAAE;YACxF;gBAAC,CAAA,GAAA,2CAAgB;gBAAG;aAAW;SAChC;OACA,YAAY,QAAQ;AAI7B","sources":["packages/react-aria-components/src/SearchField.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaSearchFieldProps, useSearchField} from 'react-aria/useSearchField';\nimport {ButtonContext} from './Button';\nimport {\n  ClassNameOrFunction,\n  ContextValue,\n  dom,\n  Provider,\n  RACValidation,\n  removeDataAttributes,\n  RenderProps,\n  SlotProps,\n  useContextProps,\n  useRenderProps,\n  useSlot,\n  useSlottedContext\n} from './utils';\nimport {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {FieldInputContext} from './Autocomplete';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes} from '@react-types/shared';\nimport {GroupContext} from './Group';\nimport {InputContext} from './Input';\nimport {LabelContext} from './Label';\nimport React, {createContext, ForwardedRef, useRef} from 'react';\nimport {SearchFieldState, useSearchFieldState} from 'react-stately/useSearchFieldState';\nimport {TextContext} from './Text';\n\nexport interface SearchFieldRenderProps {\n  /**\n   * Whether the search field is empty.\n   *\n   * @selector [data-empty]\n   */\n  isEmpty: boolean;\n  /**\n   * Whether the search field is disabled.\n   *\n   * @selector [data-disabled]\n   */\n  isDisabled: boolean;\n  /**\n   * Whether the search field is invalid.\n   *\n   * @selector [data-invalid]\n   */\n  isInvalid: boolean;\n  /**\n   * Whether the search field is read only.\n   *\n   * @selector [data-readonly]\n   */\n  isReadOnly: boolean;\n  /**\n   * Whether the search field is required.\n   *\n   * @selector [data-required]\n   */\n  isRequired: boolean;\n  /**\n   * State of the search field.\n   */\n  state: SearchFieldState;\n}\n\nexport interface SearchFieldProps\n  extends\n    Omit<\n      AriaSearchFieldProps,\n      | 'label'\n      | 'placeholder'\n      | 'description'\n      | 'errorMessage'\n      | 'validationState'\n      | 'validationBehavior'\n    >,\n    RACValidation,\n    RenderProps<SearchFieldRenderProps>,\n    SlotProps,\n    GlobalDOMAttributes<HTMLDivElement> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n   * element. A function may be provided to compute the class based on component state.\n   *\n   * @default 'react-aria-SearchField'\n   */\n  className?: ClassNameOrFunction<SearchFieldRenderProps>;\n}\n\nexport const SearchFieldContext =\n  createContext<ContextValue<SearchFieldProps, HTMLDivElement>>(null);\n\n/**\n * A search field allows a user to enter and clear a search query.\n */\nexport const SearchField = /*#__PURE__*/ createHideableComponent(function SearchField(\n  props: SearchFieldProps,\n  ref: ForwardedRef<HTMLDivElement>\n) {\n  [props, ref] = useContextProps(props, ref, SearchFieldContext);\n  let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n  let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n  let inputRef = useRef<HTMLInputElement>(null);\n  [props, inputRef as unknown] = useContextProps(props, inputRef, FieldInputContext);\n  let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n  let state = useSearchFieldState({\n    ...props,\n    validationBehavior\n  });\n\n  let {\n    labelProps,\n    inputProps,\n    clearButtonProps,\n    descriptionProps,\n    errorMessageProps,\n    ...validation\n  } = useSearchField(\n    {\n      ...removeDataAttributes(props),\n      label,\n      validationBehavior\n    },\n    state,\n    inputRef\n  );\n\n  let renderProps = useRenderProps({\n    ...props,\n    values: {\n      isEmpty: state.value === '',\n      isDisabled: props.isDisabled || false,\n      isInvalid: validation.isInvalid || false,\n      isReadOnly: props.isReadOnly || false,\n      isRequired: props.isRequired || false,\n      state\n    },\n    defaultClassName: 'react-aria-SearchField'\n  });\n\n  let DOMProps = filterDOMProps(props, {global: true});\n  delete DOMProps.id;\n\n  return (\n    <dom.div\n      {...DOMProps}\n      {...renderProps}\n      ref={ref}\n      slot={props.slot || undefined}\n      data-empty={state.value === '' || undefined}\n      data-disabled={props.isDisabled || undefined}\n      data-invalid={validation.isInvalid || undefined}\n      data-readonly={props.isReadOnly || undefined}\n      data-required={props.isRequired || undefined}>\n      <Provider\n        values={[\n          [LabelContext, {...labelProps, ref: labelRef}],\n          [InputContext, {...inputProps, ref: inputRef}],\n          [ButtonContext, clearButtonProps],\n          [\n            TextContext,\n            {\n              slots: {\n                description: descriptionProps,\n                errorMessage: errorMessageProps\n              }\n            }\n          ],\n          [GroupContext, {isInvalid: validation.isInvalid, isDisabled: props.isDisabled || false}],\n          [FieldErrorContext, validation]\n        ]}>\n        {renderProps.children}\n      </Provider>\n    </dom.div>\n  );\n});\n"],"names":[],"version":3,"file":"SearchField.cjs.map"}