@ark-ui/vue
Version:
A collection of unstyled, accessible UI components for Vue, utilizing state machines for seamless interaction.
35 lines (32 loc) • 1.24 kB
JavaScript
import { defineComponent, computed, renderSlot, normalizeProps as normalizeProps$1, guardReactiveProps } 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 { useForwardExpose } from '../../utils/use-forward-expose.js';
import { ToastProvider } from './use-toast-context.js';
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "toaster-item",
props: {
value: {},
index: {},
parent: {}
},
setup(__props) {
const props = __props;
const env = useEnvironmentContext(DEFAULT_ENVIRONMENT);
const machineProps = computed(() => ({
...props.value,
index: props.index,
parent: props.parent,
getRootNode: env?.value.getRootNode
}));
const service = useMachine(toast.machine, machineProps);
const api = computed(() => toast.connect(service, normalizeProps));
ToastProvider(api);
useForwardExpose();
return (_ctx, _cache) => {
return renderSlot(_ctx.$slots, "default", normalizeProps$1(guardReactiveProps(props.value)));
};
}
});
export { _sfc_main as default };