UNPKG

@ark-ui/vue

Version:

A collection of unstyled, accessible UI components for Vue, utilizing state machines for seamless interaction.

52 lines (49 loc) 2.11 kB
import { defineComponent, useId, computed, createBlock, openBlock, unref, normalizeProps as normalizeProps$1, guardReactiveProps, withCtx, createElementBlock, Fragment, renderList, renderSlot, mergeProps } from 'vue'; import * as toast from '@zag-js/toast'; import { useMachine, normalizeProps } from '@zag-js/vue'; import { useEnvironmentContext, DEFAULT_ENVIRONMENT } from '../../providers/environment/use-environment-context.js'; import { useLocaleContext, DEFAULT_LOCALE } from '../../providers/locale/use-locale-context.js'; import { useForwardExpose } from '../../utils/use-forward-expose.js'; import { ark } from '../factory.js'; import _sfc_main$1 from './toaster-item.vue.js'; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "toaster", props: { toaster: {}, asChild: { type: Boolean } }, setup(__props) { const props = __props; const locale = useLocaleContext(DEFAULT_LOCALE); const env = useEnvironmentContext(DEFAULT_ENVIRONMENT); const service = useMachine(toast.group.machine, { store: props.toaster, id: useId(), dir: locale?.value.dir, getRootNode: env?.value.getRootNode }); const api = computed(() => toast.group.connect(service, normalizeProps)); useForwardExpose(); return (_ctx, _cache) => { return openBlock(), createBlock(unref(ark).div, normalizeProps$1(guardReactiveProps(api.value.getGroupProps())), { default: withCtx(() => [ (openBlock(true), createElementBlock(Fragment, null, renderList(api.value.getToasts(), (toastItem, index) => { return openBlock(), createBlock(_sfc_main$1, { key: toastItem.id, value: toastItem, parent: unref(service), index }, { default: withCtx((slotProps) => [ renderSlot(_ctx.$slots, "default", mergeProps({ ref_for: true }, slotProps)) ]), _: 3 }, 8, ["value", "parent", "index"]); }), 128)) ]), _: 3 }, 16); }; } }); export { _sfc_main as default };