{"version":3,"file":"ToggleGroupRoot.cjs","sources":["../../src/ToggleGroup/ToggleGroupRoot.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { ComputedRef, Ref } from 'vue'\nimport type { PrimitiveProps } from '@/Primitive'\nimport type { AcceptableValue, DataOrientation, Direction, FormFieldProps, SingleOrMultipleProps } from '../shared/types'\nimport { createContext, useDirection, useFormControl, useForwardExpose } from '@/shared'\nimport VisuallyHiddenInput from '@/VisuallyHidden/VisuallyHiddenInput.vue'\n\nexport interface ToggleGroupRootProps<T = AcceptableValue | AcceptableValue[]>\n  extends PrimitiveProps, FormFieldProps, SingleOrMultipleProps<T> {\n  /** When `false`, navigating through the items using arrow keys will be disabled. */\n  rovingFocus?: boolean\n  /** When `true`, prevents the user from interacting with the toggle group and all its items. */\n  disabled?: boolean\n  /** The orientation of the component, which determines how focus moves: `horizontal` for left/right arrows and `vertical` for up/down arrows. */\n  orientation?: DataOrientation\n  /** The reading direction of the combobox when applicable. <br> If omitted, inherits globally from `ConfigProvider` or assumes LTR (left-to-right) reading mode. */\n  dir?: Direction\n  /** When `loop` and `rovingFocus` is `true`, keyboard navigation will loop from last item to first, and vice versa. */\n  loop?: boolean\n}\nexport type ToggleGroupRootEmits = {\n  /** Event handler called when the value changes. */\n  'update:modelValue': [payload: AcceptableValue | AcceptableValue[]]\n}\n\ninterface ToggleGroupRootContext {\n  isSingle: ComputedRef<boolean>\n  modelValue: Ref<AcceptableValue | AcceptableValue[] | undefined>\n  changeModelValue: (value: AcceptableValue) => void\n  dir?: Ref<Direction>\n  orientation?: DataOrientation\n  loop: Ref<boolean>\n  rovingFocus: Ref<boolean>\n  disabled?: Ref<boolean>\n}\n\nexport const [injectToggleGroupRootContext, provideToggleGroupRootContext]\n  = createContext<ToggleGroupRootContext>('ToggleGroupRoot')\n</script>\n\n<script setup lang=\"ts\">\nimport { toRefs } from 'vue'\nimport { Primitive } from '@/Primitive'\nimport { useSingleOrMultipleValue } from '@/shared/useSingleOrMultipleValue'\nimport { RovingFocusGroup } from '@/RovingFocus'\n\nconst props = withDefaults(defineProps<ToggleGroupRootProps>(), {\n  loop: true,\n  rovingFocus: true,\n  disabled: false,\n})\nconst emits = defineEmits<ToggleGroupRootEmits>()\n\ndefineSlots<{\n  default: (props: {\n    /** Current toggle values */\n    modelValue: typeof modelValue.value\n  }) => any\n}>()\n\nconst { loop, rovingFocus, disabled, dir: propDir } = toRefs(props)\nconst dir = useDirection(propDir)\nconst { forwardRef, currentElement } = useForwardExpose()\n\nconst { modelValue, changeModelValue, isSingle } = useSingleOrMultipleValue(props, emits)\nconst isFormControl = useFormControl(currentElement)\n\nprovideToggleGroupRootContext({\n  isSingle,\n  modelValue,\n  changeModelValue,\n  dir,\n  orientation: props.orientation,\n  loop,\n  rovingFocus,\n  disabled,\n})\n</script>\n\n<template>\n  <component\n    :is=\"rovingFocus ? RovingFocusGroup : Primitive\"\n    as-child\n    :orientation=\"rovingFocus ? orientation : undefined\"\n    :dir=\"dir\"\n    :loop=\"rovingFocus ? loop : undefined\"\n  >\n    <Primitive\n      :ref=\"forwardRef\"\n      role=\"group\"\n      :as-child=\"asChild\"\n      :as=\"as\"\n    >\n      <slot :model-value=\"modelValue\" />\n\n      <VisuallyHiddenInput\n        v-if=\"isFormControl && name\"\n        :name=\"name\"\n        :required=\"required\"\n        :value=\"modelValue\"\n      />\n    </Primitive>\n  </component>\n</template>\n"],"names":["createContext","toRefs","useDirection","useForwardExpose","useSingleOrMultipleValue","useFormControl"],"mappings":";;;;;;;;;;;;AAoCO,MAAM,CAAC,4BAAA,EAA8B,6BAA6B,CAAA,GACrEA,mCAAsC,iBAAiB;;;;;;;;;;;;;;;;;;;AAS3D,IAAA,MAAM,KAAQ,GAAA,OAAA;AAKd,IAAA,MAAM,KAAQ,GAAA,MAAA;AASd,IAAM,MAAA,EAAE,MAAM,WAAa,EAAA,QAAA,EAAU,KAAK,OAAQ,EAAA,GAAIC,WAAO,KAAK,CAAA;AAClE,IAAM,MAAA,GAAA,GAAMC,iCAAa,OAAO,CAAA;AAChC,IAAA,MAAM,EAAE,UAAA,EAAY,cAAe,EAAA,GAAIC,wCAAiB,EAAA;AAExD,IAAA,MAAM,EAAE,UAAY,EAAA,gBAAA,EAAkB,UAAa,GAAAC,wDAAA,CAAyB,OAAO,KAAK,CAAA;AACxF,IAAM,MAAA,aAAA,GAAgBC,qCAAe,cAAc,CAAA;AAEnD,IAA8B,6BAAA,CAAA;AAAA,MAC5B,QAAA;AAAA,MACA,UAAA;AAAA,MACA,gBAAA;AAAA,MACA,GAAA;AAAA,MACA,aAAa,KAAM,CAAA,WAAA;AAAA,MACnB,IAAA;AAAA,MACA,WAAA;AAAA,MACA;AAAA,KACD,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}