@yamada-ui/status
Version:
Yamada UI status component
89 lines (88 loc) • 3.22 kB
JavaScript
"use client"
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/status.tsx
var status_exports = {};
__export(status_exports, {
Status: () => Status,
getStatusColorScheme: () => getStatusColorScheme
});
module.exports = __toCommonJS(status_exports);
var import_core = require("@yamada-ui/core");
var import_utils = require("@yamada-ui/utils");
var import_jsx_runtime = require("react/jsx-runtime");
var defaultStatuses = {
error: { colorScheme: "danger" },
info: { colorScheme: "info" },
success: { colorScheme: "success" },
warning: { colorScheme: "warning" }
};
var getStatusColorScheme = (status, statuses) => {
var _a, _b;
return (_b = (_a = statuses == null ? void 0 : statuses[status]) == null ? void 0 : _a.colorScheme) != null ? _b : defaultStatuses[status].colorScheme;
};
var Status = (0, import_core.forwardRef)(
({ colorScheme, value = "info", indicatorProps, labelProps, ...props }, ref) => {
var _a, _b, _c;
const { theme } = (0, import_core.useTheme)();
const statuses = (_c = (_b = (_a = theme.__config) == null ? void 0 : _a.status) == null ? void 0 : _b.statuses) != null ? _c : {};
colorScheme != null ? colorScheme : colorScheme = getStatusColorScheme(value, statuses);
const [styles, mergedProps] = (0, import_core.useComponentMultiStyle)("Status", {
...props,
colorScheme
});
const { className, children, ...rest } = (0, import_core.omitThemeProps)(mergedProps);
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
import_core.ui.div,
{
className: (0, import_utils.cx)("ui-status", className),
__css: { ...styles.container },
...rest,
children: [
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_core.ui.div,
{
ref,
className: "ui-status__indicator",
__css: { ...styles.indicator },
...indicatorProps
}
),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_core.ui.p,
{
className: "ui-status__label",
__css: { ...styles.label },
...labelProps,
children
}
)
]
}
);
}
);
Status.displayName = "Status";
Status.__ui__ = "Status";
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
Status,
getStatusColorScheme
});
//# sourceMappingURL=status.js.map