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,CAAA,GAAA,mDAAW,GAAG;QACzC,yBAAyB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAW,GAAG;QAClD,SAAS;QACT,UAAU;QACV,iBAAiB;QACjB,YAAY;QACZ,YAAY;QACZ,kBAAA;QAED,6BACC,oIACE,0DAAC,CAAA,GAAA,oCAAS;QAAE,WAAU;QAAK,SAAS;QAAU,GAAG,cAAc;sBAC/D,0DAAC,CAAA,GAAA,oCAAS;QAAE,WAAU;QAAO,SAAS;QAAU,GAAG,cAAc;SAGpE,sBACC,0DAAC;QACC,MAAK;QACL,MAAM;QACN,MAAM,MAAM,IAAI;QAChB,OAAO,MAAM,MAAM,WAAW,IAAI,KAAK,MAAM,WAAW;;AAMpE","sources":["packages/@adobe/react-spectrum/src/numberfield/NumberField.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 {AriaButtonProps} from 'react-aria/useButton';\n\nimport {AriaNumberFieldProps, useNumberField} from 'react-aria/useNumberField';\nimport {classNames} from '../utils/classNames';\nimport {Field} from '../label/Field';\nimport {\n  FocusableRef,\n  InputDOMProps,\n  RefObject,\n  SpectrumFieldValidation,\n  SpectrumLabelableProps,\n  StyleProps\n} from '@react-types/shared';\nimport {FocusRing} from 'react-aria/FocusRing';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {NumberFieldState, useNumberFieldState} from 'react-stately/useNumberFieldState';\nimport React, {HTMLAttributes, InputHTMLAttributes, Ref, useRef} from 'react';\nimport {StepButton} from './StepButton';\nimport stepperStyle from '@adobe/spectrum-css-temp/components/stepper/vars.css';\nimport {TextFieldBase} from '../textfield/TextFieldBase';\nimport {useFocusableRef} from '../utils/useDOMRef';\nimport {useFormProps} from '../form/Form';\nimport {useHover} from 'react-aria/useHover';\nimport {useLocale} from 'react-aria/I18nProvider';\nimport {useProvider, useProviderProps} from '../provider/Provider';\nimport {useStyleProps} from '../utils/styleProps';\n\nexport interface SpectrumNumberFieldProps\n  extends\n    Omit<AriaNumberFieldProps, 'placeholder' | 'isInvalid' | 'validationState'>,\n    SpectrumFieldValidation<number>,\n    InputDOMProps,\n    StyleProps,\n    SpectrumLabelableProps {\n  /** Whether the numberfield should be displayed with a quiet style. */\n  isQuiet?: boolean;\n  /**\n   * Whether to hide the increment and decrement buttons.\n   *\n   * @default false\n   */\n  hideStepper?: boolean;\n}\n\n/**\n * NumberFields allow users to enter a number, and increment or decrement the value using stepper\n * buttons.\n */\nexport const NumberField = React.forwardRef(function NumberField(\n  props: SpectrumNumberFieldProps,\n  ref: FocusableRef<HTMLElement>\n) {\n  props = useProviderProps(props);\n  props = useFormProps(props);\n  let provider = useProvider();\n  let {isQuiet, isReadOnly, isDisabled, hideStepper} = props;\n\n  let {styleProps: style} = useStyleProps(props);\n\n  let {locale} = useLocale();\n  let state = useNumberFieldState({...props, locale});\n  let inputRef = useRef<HTMLInputElement>(null);\n  let domRef = useFocusableRef<HTMLElement>(ref, inputRef);\n  let {\n    groupProps,\n    labelProps,\n    inputProps,\n    incrementButtonProps,\n    decrementButtonProps,\n    descriptionProps,\n    errorMessageProps,\n    isInvalid,\n    validationErrors,\n    validationDetails\n  } = useNumberField(props, state, inputRef);\n  let isMobile = provider.scale === 'large';\n  let showStepper = !hideStepper;\n\n  let {isHovered, hoverProps} = useHover({isDisabled});\n\n  let validationState = props.validationState || (isInvalid ? 'invalid' : undefined);\n  let className = classNames(\n    stepperStyle,\n    'spectrum-Stepper',\n    // because FocusRing won't pass along the className from Field, we have to handle that ourselves\n    !props.label && style.className ? style.className : '',\n    {\n      'spectrum-Stepper--isQuiet': isQuiet,\n      'is-disabled': isDisabled,\n      'spectrum-Stepper--readonly': isReadOnly,\n      'is-invalid': validationState === 'invalid' && !isDisabled,\n      'spectrum-Stepper--showStepper': showStepper,\n      'spectrum-Stepper--isMobile': isMobile,\n      'is-hovered': isHovered\n    }\n  );\n\n  return (\n    <Field\n      {...(props as Omit<SpectrumNumberFieldProps, 'onChange'>)}\n      descriptionProps={descriptionProps}\n      errorMessageProps={errorMessageProps}\n      isInvalid={isInvalid}\n      validationErrors={validationErrors}\n      validationDetails={validationDetails}\n      labelProps={labelProps}\n      ref={domRef}\n      wrapperClassName={classNames(stepperStyle, 'spectrum-Stepper-container', {\n        'spectrum-Stepper-container--isMobile': isMobile\n      })}>\n      <NumberFieldInput\n        {...props}\n        groupProps={mergeProps(groupProps, hoverProps)}\n        inputProps={inputProps}\n        inputRef={inputRef}\n        incrementProps={incrementButtonProps}\n        decrementProps={decrementButtonProps}\n        className={className}\n        style={style}\n        state={state}\n        validationState={validationState}\n      />\n    </Field>\n  );\n});\n\ninterface NumberFieldInputProps extends SpectrumNumberFieldProps {\n  groupProps: HTMLAttributes<HTMLDivElement>;\n  inputProps: InputHTMLAttributes<HTMLInputElement>;\n  inputRef: RefObject<HTMLInputElement | HTMLTextAreaElement | null>;\n  incrementProps: AriaButtonProps;\n  decrementProps: AriaButtonProps;\n  className?: string;\n  style?: React.CSSProperties;\n  state: NumberFieldState;\n}\n\nconst NumberFieldInput = React.forwardRef(function NumberFieldInput(\n  props: NumberFieldInputProps,\n  ref: Ref<HTMLDivElement>\n) {\n  let {\n    groupProps,\n    inputProps,\n    inputRef,\n    incrementProps,\n    decrementProps,\n    className,\n    style,\n    autoFocus,\n    isQuiet,\n    isDisabled,\n    hideStepper,\n    validationState,\n    name,\n    state\n  } = props;\n  let showStepper = !hideStepper;\n\n  return (\n    <FocusRing\n      within\n      isTextInput\n      focusClass={classNames(stepperStyle, 'is-focused')}\n      focusRingClass={classNames(stepperStyle, 'focus-ring')}\n      autoFocus={autoFocus}>\n      <div {...groupProps} ref={ref} style={style} className={className}>\n        <TextFieldBase\n          UNSAFE_className={classNames(stepperStyle, 'spectrum-Stepper-field')}\n          inputClassName={classNames(stepperStyle, 'spectrum-Stepper-input')}\n          validationIconClassName={classNames(stepperStyle, 'spectrum-Stepper-icon')}\n          isQuiet={isQuiet}\n          inputRef={inputRef}\n          validationState={validationState}\n          inputProps={inputProps}\n          isDisabled={isDisabled}\n          disableFocusRing\n        />\n        {showStepper && (\n          <>\n            <StepButton direction=\"up\" isQuiet={isQuiet} {...incrementProps} />\n            <StepButton direction=\"down\" isQuiet={isQuiet} {...decrementProps} />\n          </>\n        )}\n        {name && (\n          <input\n            type=\"hidden\"\n            name={name}\n            form={props.form}\n            value={isNaN(state.numberValue) ? '' : state.numberValue}\n          />\n        )}\n      </div>\n    </FocusRing>\n  );\n});\n"],"names":[],"version":3,"file":"NumberField.cjs.map"}