{"mappings":"ACkFoC;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;;EAAA;;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAwBf;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;AAxBe;EAAA;;;;;AAAA;EAAA;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA","sources":["229a9af52db930e6","packages/@react-spectrum/s2/src/CheckboxGroup.tsx"],"sourcesContent":["@import \"99c19d559a913dfe\";\n@import \"3a372fd4efad6d81\";\n","/*\n * Copyright 2024 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 {\n  CheckboxGroup as AriaCheckboxGroup,\n  CheckboxGroupProps as AriaCheckboxGroupProps,\n  ContextValue\n} from 'react-aria-components';\nimport {CheckboxContext} from './Checkbox';\nimport {createContext, forwardRef, ReactNode, useContext} from 'react';\nimport {DOMRef, DOMRefValue, HelpTextProps, Orientation, SpectrumLabelableProps} from '@react-types/shared';\nimport {field, getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};\nimport {FieldLabel, HelpText} from './Field';\nimport {FormContext, useFormProps} from './Form';\nimport {style} from '../style' with {type: 'macro'};\nimport {useDOMRef} from '@react-spectrum/utils';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\nexport interface CheckboxGroupProps extends Omit<AriaCheckboxGroupProps, 'className' | 'style' | 'children'>, StyleProps, SpectrumLabelableProps, HelpTextProps {\n  /**\n   * The size of the Checkboxes in the CheckboxGroup.\n   *\n   * @default 'M'\n   */\n  size?: 'S' | 'M' | 'L' | 'XL',\n  /**\n   * The axis the checkboxes should align with.\n   *\n   * @default 'vertical'\n   */\n  orientation?: Orientation,\n  /**\n   * The Checkboxes contained within the CheckboxGroup.\n   */\n  children: ReactNode,\n  /**\n   * By default, checkboxes are not emphasized (gray).\n   * The emphasized (blue) version provides visual prominence.\n   */\n  isEmphasized?: boolean\n}\n\nexport const CheckboxGroupContext = createContext<ContextValue<Partial<CheckboxGroupProps>, DOMRefValue<HTMLDivElement>>>(null);\n\n/**\n * A CheckboxGroup allows users to select one or more items from a list of choices.\n */\nexport const CheckboxGroup = forwardRef(function CheckboxGroup(props: CheckboxGroupProps, ref: DOMRef<HTMLDivElement>) {\n  [props, ref] = useSpectrumContextProps(props, ref, CheckboxGroupContext);\n  let formContext = useContext(FormContext);\n  props = useFormProps(props);\n  let {\n    label,\n    description,\n    errorMessage,\n    children,\n    labelPosition = 'top',\n    labelAlign = 'start',\n    necessityIndicator = 'icon',\n    size = 'M',\n    orientation = 'vertical',\n    UNSAFE_className = '',\n    UNSAFE_style,\n    isEmphasized,\n    ...groupProps\n  } = props;\n  let domRef = useDOMRef(ref);\n\n  return (\n    <AriaCheckboxGroup\n      {...groupProps}\n      ref={domRef}\n      style={UNSAFE_style}\n      className={UNSAFE_className + style({\n        ...field(),\n        // Double the usual gap because of the internal padding within checkbox that spectrum has.\n        '--field-gap': {\n          type: 'rowGap',\n          value: 'calc(var(--field-height) - 1lh)'\n        }\n      }, getAllowedOverrides())({\n        size: props.size,\n        labelPosition,\n        isInForm: !!formContext\n      }, props.styles)}>\n      {({isDisabled, isInvalid}) => (<>\n        <FieldLabel\n          isDisabled={isDisabled}\n          isRequired={props.isRequired}\n          size={size}\n          labelPosition={labelPosition}\n          labelAlign={labelAlign}\n          necessityIndicator={necessityIndicator}\n          contextualHelp={props.contextualHelp}>\n          {label}\n        </FieldLabel>\n        <div\n          className={style({\n            gridArea: 'input',\n            display: 'flex',\n            flexDirection: {\n              orientation: {\n                vertical: 'column',\n                horizontal: 'row'\n              }\n            },\n            lineHeight: 'ui',\n            rowGap: '--field-gap',\n            // Spectrum uses a fixed spacing value for horizontal,\n            // but the gap changes depending on t-shirt size in vertical.\n            columnGap: 16,\n            flexWrap: 'wrap'\n          })({orientation})}>\n          <FormContext.Provider value={{...formContext, size, isRequired: undefined}}>\n            <CheckboxContext.Provider value={{isEmphasized}}>\n              {children}\n            </CheckboxContext.Provider>\n          </FormContext.Provider>\n        </div>\n        <HelpText\n          size={size}\n          isDisabled={isDisabled}\n          isInvalid={isInvalid}\n          description={description}\n          showErrorIcon>\n          {errorMessage}\n        </HelpText>\n      </>)}\n    </AriaCheckboxGroup>\n  );\n});\n"],"names":[],"version":3,"file":"CheckboxGroup.css.map"}