@carbon/ibm-products
Version:
Carbon for IBM Products
52 lines (50 loc) • 2.84 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.
*/
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_index = require("../../node_modules/classnames/index.js");
const require_package_settings = require("../../global/js/package-settings.js");
let react = require("react");
react = require_runtime.__toESM(react);
let prop_types = require("prop-types");
prop_types = require_runtime.__toESM(prop_types);
let _carbon_react = require("@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__ */ require_runtime.__toESM(require_index.default);
const blockClass = `${require_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.default.createElement("div", {
...rest,
className: (0, import_classnames.default)(blockClass, className)
}, /* @__PURE__ */ react.default.createElement("h2", null, "This component ", /* @__PURE__ */ react.default.createElement("strong", null, componentName), " is not ready yet."), /* @__PURE__ */ react.default.createElement("p", null, "To enable it, initialize package flags before the component is first used."), /* @__PURE__ */ react.default.createElement("br", null), /* @__PURE__ */ react.default.createElement("p", null, "e.g. in main.js"), /* @__PURE__ */ react.default.createElement(_carbon_react.CodeSnippet, { type: "multi" }, instructions), /* @__PURE__ */ react.default.createElement("br", null), /* @__PURE__ */ react.default.createElement("p", null, "View a live example on", " ", /* @__PURE__ */ react.default.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: prop_types.default.string,
/** Name of the component that is not ready yet */
componentName: prop_types.default.string.isRequired
};
//#endregion
exports.Canary = Canary;