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AAkB;IACpB;IAEA,IAAI,WAAW,CAAA,GAAA,6CAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAClD,OAAO,SAAS,EAAE;IAElB,qBACE,0DAAC,CAAA,GAAA,kCAAO;QACN,QAAQ;YACN;gBAAC;gBAAyB;aAAM;YAChC;gBAAC,CAAA,GAAA,sCAAW;gBAAG;aAAW;YAC1B;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;gBACE,CAAA,GAAA,uCAAY;gBACZ;oBACE,OAAO;wBACL,WAAW;wBACX,WAAW;oBACb;gBACF;aACD;YACD;gBACE,CAAA,GAAA,qCAAU;gBACV;oBACE,OAAO;wBACL,aAAa;wBACb,cAAc;oBAChB;gBACF;aACD;YACD;gBAAC,CAAA,GAAA,2CAAgB;gBAAG;aAAW;SAChC;qBACD,0DAAC,CAAA,GAAA,6BAAE,EAAE,GAAG;QACL,GAAG,QAAQ;QACX,GAAG,WAAW;QACf,KAAK;QACL,MAAM,MAAM,IAAI,IAAI;QACpB,iBAAe,MAAM,UAAU,IAAI;QACnC,iBAAe,MAAM,UAAU,IAAI;QACnC,iBAAe,MAAM,UAAU,IAAI;QACnC,gBAAc,WAAW,SAAS,IAAI;QAEvC,MAAM,IAAI,kBACT,0DAAC;QACC,MAAK;QACL,MAAM,MAAM,IAAI;QAChB,MAAM,MAAM,IAAI;QAChB,OAAO,MAAM,MAAM,WAAW,IAAI,KAAK,MAAM,WAAW;QACxD,UAAU,MAAM,UAAU,IAAI;;AAKxC","sources":["packages/react-aria-components/src/NumberField.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 {AriaNumberFieldProps, useNumberField} from 'react-aria/useNumberField';\n\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 {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {forwardRefType, GlobalDOMAttributes, InputDOMProps} from '@react-types/shared';\nimport {GroupContext} from './Group';\nimport {InputContext} from './Input';\nimport {LabelContext} from './Label';\nimport {NumberFieldState, useNumberFieldState} from 'react-stately/useNumberFieldState';\nimport React, {createContext, ForwardedRef, forwardRef, useRef} from 'react';\nimport {TextContext} from './Text';\nimport {useLocale} from 'react-aria/I18nProvider';\n\nexport interface NumberFieldRenderProps {\n  /**\n   * Whether the number field is disabled.\n   *\n   * @selector [data-disabled]\n   */\n  isDisabled: boolean;\n  /**\n   * Whether the number field is invalid.\n   *\n   * @selector [data-invalid]\n   */\n  isInvalid: boolean;\n  /**\n   * Whether the number field is read only.\n   *\n   * @selector [data-readonly]\n   */\n  isReadOnly: boolean;\n  /**\n   * Whether the number field is required.\n   *\n   * @selector [data-required]\n   */\n  isRequired: boolean;\n  /**\n   * State of the number field.\n   */\n  state: NumberFieldState;\n}\n\nexport interface NumberFieldProps\n  extends\n    Omit<\n      AriaNumberFieldProps,\n      | 'label'\n      | 'placeholder'\n      | 'description'\n      | 'errorMessage'\n      | 'validationState'\n      | 'validationBehavior'\n    >,\n    RACValidation,\n    InputDOMProps,\n    RenderProps<NumberFieldRenderProps>,\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-NumberField'\n   */\n  className?: ClassNameOrFunction<NumberFieldRenderProps>;\n}\n\nexport const NumberFieldContext =\n  createContext<ContextValue<NumberFieldProps, HTMLDivElement>>(null);\nexport const NumberFieldStateContext = createContext<NumberFieldState | null>(null);\n\n/**\n * A number field allows a user to enter a number, and increment or decrement the value using\n * stepper buttons.\n */\nexport const NumberField = /*#__PURE__*/ (forwardRef as forwardRefType)(function NumberField(\n  props: NumberFieldProps,\n  ref: ForwardedRef<HTMLDivElement>\n) {\n  [props, ref] = useContextProps(props, ref, NumberFieldContext);\n  let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n  let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n  let {locale} = useLocale();\n  let state = useNumberFieldState({\n    ...props,\n    locale,\n    validationBehavior\n  });\n\n  let inputRef = useRef<HTMLInputElement>(null);\n  let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n  let {\n    labelProps,\n    groupProps,\n    inputProps,\n    incrementButtonProps,\n    decrementButtonProps,\n    descriptionProps,\n    errorMessageProps,\n    ...validation\n  } = useNumberField(\n    {\n      ...removeDataAttributes(props),\n      label,\n      validationBehavior\n    },\n    state,\n    inputRef\n  );\n\n  let renderProps = useRenderProps({\n    ...props,\n    values: {\n      state,\n      isDisabled: props.isDisabled || false,\n      isInvalid: validation.isInvalid || false,\n      isRequired: props.isRequired || false,\n      isReadOnly: props.isReadOnly || false\n    },\n    defaultClassName: 'react-aria-NumberField'\n  });\n\n  let DOMProps = filterDOMProps(props, {global: true});\n  delete DOMProps.id;\n\n  return (\n    <Provider\n      values={[\n        [NumberFieldStateContext, state],\n        [GroupContext, groupProps],\n        [InputContext, {...inputProps, ref: inputRef}],\n        [LabelContext, {...labelProps, ref: labelRef}],\n        [\n          ButtonContext,\n          {\n            slots: {\n              increment: incrementButtonProps,\n              decrement: decrementButtonProps\n            }\n          }\n        ],\n        [\n          TextContext,\n          {\n            slots: {\n              description: descriptionProps,\n              errorMessage: errorMessageProps\n            }\n          }\n        ],\n        [FieldErrorContext, validation]\n      ]}>\n      <dom.div\n        {...DOMProps}\n        {...renderProps}\n        ref={ref}\n        slot={props.slot || undefined}\n        data-disabled={props.isDisabled || undefined}\n        data-readonly={props.isReadOnly || undefined}\n        data-required={props.isRequired || undefined}\n        data-invalid={validation.isInvalid || undefined}\n      />\n      {props.name && (\n        <input\n          type=\"hidden\"\n          name={props.name}\n          form={props.form}\n          value={isNaN(state.numberValue) ? '' : state.numberValue}\n          disabled={props.isDisabled || undefined}\n        />\n      )}\n    </Provider>\n  );\n});\n"],"names":[],"version":3,"file":"NumberField.cjs.map"}