feat: migrate Toast and Table with reviewed state focus and SSR contracts

This commit is contained in:
maoyingjie
2026-10-24 07:19:26 +08:00
parent 0cfe7b6195
commit ed41af5294
95 changed files with 9358 additions and 8 deletions
@@ -0,0 +1,49 @@
<script lang="ts">
import { defineComponent, h, inject, useAttrs, type PropType } from "vue";
import type { ToastVariants } from "@heroui-vue/styles";
import { toastContextKey } from "./context";
import {
ToastDangerIcon,
ToastInfoIcon,
ToastSuccessIcon,
ToastWarningIcon,
} from "./icons";
export default defineComponent({
name: "ToastIndicator",
inheritAttrs: false,
props: {
variant: {
type: String as PropType<ToastVariants["variant"]>,
default: "default",
},
as: { type: String, default: "div" },
},
setup(props, { slots }) {
const attrs = useAttrs();
const ctx = inject(toastContextKey, null);
function defaultIcon() {
switch (props.variant) {
case "success":
return h(ToastSuccessIcon, { "data-slot": "toast-default-icon" });
case "warning":
return h(ToastWarningIcon, { "data-slot": "toast-default-icon" });
case "danger":
return h(ToastDangerIcon, { "data-slot": "toast-default-icon" });
default:
return h(ToastInfoIcon, { "data-slot": "toast-default-icon" });
}
}
return () =>
h(
props.as,
{
...attrs,
class: [ctx?.slots.value.indicator(), attrs.class],
"data-slot": "toast-indicator",
},
slots.default?.() ?? [defaultIcon()],
);
},
});
</script>