UNPKG

@wener/console

Version:

Base console UI toolkit

33 lines (32 loc) 1.13 kB
import React from "react"; import { useDebounce } from "@wener/reaction"; import { cn } from "../tw/index.js"; import { ErrorPlaceholder } from "./ErrorPlaceholder.js"; export const NotReadyPlaceholder = ({ loading, refetch, empty, children, error, className, content = children, ...props }) => { // 200-500ms const _loading = useDebounce(loading, 250); if (_loading) { return /*#__PURE__*/ React.createElement("div", { "data-state": "loading", className: cn("loading loading-spinner h-4 w-4 opacity-75", className), ...props }); } if (error) { return /*#__PURE__*/ React.createElement(ErrorPlaceholder, { "data-state": "error", error: error, className: className, ...props }); } if (empty !== undefined && !empty) { return /*#__PURE__*/ React.createElement("div", { "data-state": "empty", className: cn(className), ...props }, "\u6CA1\u6709\u6570\u636E"); } return content; }; //# sourceMappingURL=NotReadyPlaceholder.js.map