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,OACd;YAAC,OAAO,GAAG,eAAe,EAAE,CAAC;YAAE,UAAU,GAAG,eAAe,EAAE,CAAC;QAAA,IAC9D;OAEL;IAIL,qBACE,0DAAC;QACC,KAAK;QACL,WAAW,CAAA,GAAA,oCAAS,EAClB,CAAA,GAAA,mDAAK,GACL,mBACA;YACE,gCAAgC,kBAAkB;YAClD,iCAAiC,kBAAkB;YACnD,eAAe;QACjB,GACA,SACA,WAAW,SAAS;QAEtB,OAAO;YACL,GAAG,KAAK;YACR,GAAG,WAAW,KAAK;QACrB;QACC,GAAG,UAAU;OACb,MAAM,KAAK,kBACV,0DAAC;QAAI,WAAW,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;QAAmC,MAAK;OACxE,MAAM,KAAK,IAAI,WACf,MAAM,cAAc,kBACnB,0DAAC,CAAA,GAAA,sCAAW;QACV,OAAO;YACL,cAAc;gBACZ,kBAAkB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;YACvC;QACF;OACC,MAAM,cAAc,GAGxB,kBAAkB,SAAS,kBAAkB,0BAGlD,0DAAC;QACC,WAAW,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;QAC9B,KAAK;QACJ,GAAG,UAAU;QACd,MAAK;OACJ,SAAS;kBACR;kBACA;eACA;IACF,KAED,kBAAkB,wBACjB,0DAAC;QACC,WAAW,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;QAC9B,MAAK;OACJ,kBAAkB;AAK7B","sources":["packages/@adobe/react-spectrum/src/slider/SliderBase.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 {AriaSliderProps, useSlider} from 'react-aria/useSlider';\n\nimport {classNames} from '../utils/classNames';\nimport {FocusableRef, LabelPosition, RefObject, StyleProps, ValueBase} from '@react-types/shared';\nimport React, {CSSProperties, ReactNode, useRef} from 'react';\nimport {SliderState, useSliderState} from 'react-stately/useSliderState';\nimport {SlotProvider} from '../utils/Slots';\nimport styles from '@adobe/spectrum-css-temp/components/slider/vars.css';\nimport {useFocusableRef} from '../utils/useDOMRef';\nimport {useNumberFormatter} from 'react-aria/useNumberFormatter';\nimport {useProviderProps} from '../provider/Provider';\nimport {useStyleProps} from '../utils/styleProps';\n\nexport interface SpectrumBarSliderBase<T> extends AriaSliderProps<T>, ValueBase<T>, StyleProps {\n  /**\n   * The display format of the value label.\n   */\n  formatOptions?: Intl.NumberFormatOptions;\n  /**\n   * The label's overall position relative to the element it is labeling.\n   *\n   * @default 'top'\n   */\n  labelPosition?: LabelPosition;\n  /**\n   * Whether the value's label is displayed. True by default if there's a `label`, false by default\n   * if not.\n   */\n  showValueLabel?: boolean;\n  /**\n   * A function that returns the content to display as the value's label. Overrides default\n   * formatted number.\n   */\n  getValueLabel?: (value: T) => string;\n  /**\n   * A ContextualHelp element to place next to the label.\n   */\n  contextualHelp?: ReactNode;\n}\n\nexport interface SliderBaseChildArguments {\n  inputRef: RefObject<HTMLInputElement | null>;\n  trackRef: RefObject<HTMLElement | null>;\n  state: SliderState;\n}\n\nexport interface SliderBaseProps<T = number[]> extends SpectrumBarSliderBase<T> {\n  children: (opts: SliderBaseChildArguments) => ReactNode;\n  classes?: string[] | Object;\n  style?: CSSProperties;\n}\n\nexport const SliderBase = React.forwardRef(function SliderBase(\n  props: SliderBaseProps,\n  ref: FocusableRef<HTMLDivElement>\n) {\n  props = useProviderProps(props);\n  let {\n    isDisabled,\n    children,\n    classes,\n    style,\n    labelPosition = 'top',\n    getValueLabel,\n    showValueLabel = !!props.label,\n    formatOptions,\n    minValue = 0,\n    maxValue = 100,\n    ...otherProps\n  } = props;\n\n  let {styleProps} = useStyleProps(otherProps);\n\n  // `Math.abs(Math.sign(a) - Math.sign(b)) === 2` is true if the values have a different sign.\n  let alwaysDisplaySign = Math.abs(Math.sign(minValue) - Math.sign(maxValue)) === 2;\n  if (alwaysDisplaySign) {\n    if (formatOptions != null) {\n      if (!('signDisplay' in formatOptions)) {\n        formatOptions = {\n          ...formatOptions,\n          signDisplay: 'exceptZero'\n        };\n      }\n    } else {\n      formatOptions = {signDisplay: 'exceptZero'};\n    }\n  }\n\n  const formatter = useNumberFormatter(formatOptions);\n  const state = useSliderState({\n    ...props,\n    numberFormatter: formatter,\n    minValue,\n    maxValue\n  });\n  let trackRef = useRef<HTMLDivElement | null>(null);\n  let {groupProps, trackProps, labelProps, outputProps} = useSlider(props, state, trackRef);\n\n  let inputRef = useRef<HTMLInputElement | null>(null);\n  let domRef = useFocusableRef(ref, inputRef);\n\n  let displayValue = '';\n  let maxLabelLength: number | null = null;\n\n  if (typeof getValueLabel === 'function') {\n    displayValue = getValueLabel(state.values);\n    switch (state.values.length) {\n      case 1:\n        maxLabelLength = Math.max(\n          getValueLabel([minValue]).length,\n          getValueLabel([maxValue]).length\n        );\n        break;\n      case 2:\n        // Try all possible combinations of min and max values.\n        maxLabelLength = Math.max(\n          getValueLabel([minValue, minValue]).length,\n          getValueLabel([minValue, maxValue]).length,\n          getValueLabel([maxValue, minValue]).length,\n          getValueLabel([maxValue, maxValue]).length\n        );\n        break;\n      default:\n        throw new Error('Only sliders with 1 or 2 handles are supported!');\n    }\n  } else {\n    maxLabelLength = Math.max(\n      [...formatter.format(minValue)].length,\n      [...formatter.format(maxValue)].length\n    );\n    switch (state.values.length) {\n      case 1:\n        displayValue = state.getThumbValueLabel(0);\n        break;\n      case 2:\n        // This should really use the NumberFormat#formatRange proposal...\n        // https://github.com/tc39/ecma402/issues/393\n        // https://github.com/tc39/proposal-intl-numberformat-v3#formatrange-ecma-402-393\n        displayValue = `${state.getThumbValueLabel(0)} – ${state.getThumbValueLabel(1)}`;\n        maxLabelLength =\n          3 +\n          2 *\n            Math.max(\n              maxLabelLength,\n              [...formatter.format(minValue)].length,\n              [...formatter.format(maxValue)].length\n            );\n        break;\n      default:\n        throw new Error('Only sliders with 1 or 2 handles are supported!');\n    }\n  }\n\n  let labelNode = (\n    <label className={classNames(styles, 'spectrum-Slider-label')} {...labelProps}>\n      {props.label}\n    </label>\n  );\n\n  let valueNode = (\n    <output\n      {...outputProps}\n      className={classNames(styles, 'spectrum-Slider-value')}\n      style={\n        maxLabelLength != null\n          ? {width: `${maxLabelLength}ch`, minWidth: `${maxLabelLength}ch`}\n          : undefined\n      }>\n      {displayValue}\n    </output>\n  );\n\n  return (\n    <div\n      ref={domRef}\n      className={classNames(\n        styles,\n        'spectrum-Slider',\n        {\n          'spectrum-Slider--positionTop': labelPosition === 'top',\n          'spectrum-Slider--positionSide': labelPosition === 'side',\n          'is-disabled': isDisabled\n        },\n        classes,\n        styleProps.className\n      )}\n      style={{\n        ...style,\n        ...styleProps.style\n      }}\n      {...groupProps}>\n      {props.label && (\n        <div className={classNames(styles, 'spectrum-Slider-labelContainer')} role=\"presentation\">\n          {props.label && labelNode}\n          {props.contextualHelp && (\n            <SlotProvider\n              slots={{\n                actionButton: {\n                  UNSAFE_className: classNames(styles, 'spectrum-Slider-contextualHelp')\n                }\n              }}>\n              {props.contextualHelp}\n            </SlotProvider>\n          )}\n          {labelPosition === 'top' && showValueLabel && valueNode}\n        </div>\n      )}\n      <div\n        className={classNames(styles, 'spectrum-Slider-controls')}\n        ref={trackRef}\n        {...trackProps}\n        role=\"presentation\">\n        {children({\n          trackRef,\n          inputRef,\n          state\n        })}\n      </div>\n      {labelPosition === 'side' && (\n        <div\n          className={classNames(styles, 'spectrum-Slider-valueLabelContainer')}\n          role=\"presentation\">\n          {showValueLabel && valueNode}\n        </div>\n      )}\n    </div>\n  );\n});\n"],"names":[],"version":3,"file":"SliderBase.cjs.map"}