UNPKG

@cerberus-design/react

Version:

The Cerberus Design React component library.

79 lines (76 loc) 2.82 kB
"use strict"; "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/components/field/status-indicator.tsx var status_indicator_exports = {}; __export(status_indicator_exports, { FieldStatusIndicator: () => FieldStatusIndicator }); module.exports = __toCommonJS(status_indicator_exports); var import_react2 = require("@ark-ui/react"); var import_css = require("styled-system/css"); var import_recipes = require("styled-system/recipes"); // src/context/cerberus.tsx var import_react = require("react"); var import_jsx_runtime = require("react/jsx-runtime"); var CerberusContext = (0, import_react.createContext)(null); function useCerberusContext() { const context = (0, import_react.useContext)(CerberusContext); if (!context) { throw new Error("useCerberus must be used within a CerberusProvider"); } return context; } // src/components/field/status-indicator.tsx var import_jsx_runtime2 = require("react/jsx-runtime"); function FieldStatusIndicator(props) { const { fallback, ...nativeProps } = props; const fieldContext = (0, import_react2.useFieldContext)(); const styles = (0, import_recipes.field)(); const { icons } = useCerberusContext(); const { invalid: InvalidIcon } = icons; if (!fieldContext) return null; if (fieldContext.invalid) { return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( "span", { ...nativeProps, "aria-hidden": "true", "data-invalid": true, className: (0, import_css.cx)(nativeProps.className, styles.statusIndicator), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(InvalidIcon, {}) } ); } return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( "span", { ...nativeProps, "aria-hidden": "true", "data-part": "end-indicator", className: (0, import_css.cx)(nativeProps.className, styles.endIndicator), children: fallback } ); } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { FieldStatusIndicator }); //# sourceMappingURL=status-indicator.cjs.map