@carbon/ibm-products
Version:
Carbon for IBM Products
50 lines (48 loc) • 2.59 kB
JavaScript
/**
* Copyright IBM Corp. 2020, 2026
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import { __toESM } from "../../_virtual/_rolldown/runtime.js";
import { require_classnames } from "../../node_modules/classnames/index.js";
import package_settings_default from "../../global/js/package-settings.js";
import React from "react";
import PropTypes from "prop-types";
import { CodeSnippet } from "@carbon/react";
//#region src/components/_Canary/Canary.jsx
/**
* Copyright IBM Corp. 2020, 2021
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
var import_classnames = /* @__PURE__ */ __toESM(require_classnames());
const blockClass = `${package_settings_default.prefix}--canary`;
/**
* Canary component used when the component requested is not yet production
*
* @deprecated The component feature flag (canary) mechanism is deprecated in
* favour of PDLC-prefixed exports (e.g. `preview__`, `previewCandidate__`) and
* will be removed in a future release. See
* https://carbondesignsystem.com/contributing/product-development-lifecycle/
*/
const Canary = ({ className, componentName, ...rest }) => {
const instructions = `
import { pkg } from '@carbon/ibm-products';
// NOTE: must happen before component is first used
pkg.component.${componentName} = true;
`;
return /* @__PURE__ */ React.createElement("div", {
...rest,
className: (0, import_classnames.default)(blockClass, className)
}, /* @__PURE__ */ React.createElement("h2", null, "This component ", /* @__PURE__ */ React.createElement("strong", null, componentName), " is not ready yet."), /* @__PURE__ */ React.createElement("p", null, "To enable it, initialize package flags before the component is first used."), /* @__PURE__ */ React.createElement("br", null), /* @__PURE__ */ React.createElement("p", null, "e.g. in main.js"), /* @__PURE__ */ React.createElement(CodeSnippet, { type: "multi" }, instructions), /* @__PURE__ */ React.createElement("br", null), /* @__PURE__ */ React.createElement("p", null, "View a live example on", " ", /* @__PURE__ */ React.createElement("a", { href: "https://codesandbox.io/s/example-component-olif5?file=/src/config.js" }, "codesandbox"), "."));
};
Canary.propTypes = {
/** Provide an optional class to be applied to the containing node */
className: PropTypes.string,
/** Name of the component that is not ready yet */
componentName: PropTypes.string.isRequired
};
//#endregion
export { Canary };