@builder.io/mitosis
Version:
Write components once, run everywhere. Compiles to Vue, React, Solid, and Liquid. Import code from Figma and Builder.io
16 lines (15 loc) • 936 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getContextType = exports.hasGetContext = exports.hasSetContext = exports.hasContext = void 0;
const hasContext = (component) => (0, exports.hasSetContext)(component) || (0, exports.hasGetContext)(component);
exports.hasContext = hasContext;
const hasSetContext = (component) => Object.keys(component.context.set).length > 0;
exports.hasSetContext = hasSetContext;
const hasGetContext = (component) => Object.keys(component.context.get).length > 0;
exports.hasGetContext = hasGetContext;
const getContextType = ({ component, context, }) => {
var _a, _b;
// TO-DO: remove useMetadata check if no longer needed.
return ((_b = (_a = component.meta.useMetadata) === null || _a === void 0 ? void 0 : _a.contextTypes) === null || _b === void 0 ? void 0 : _b[context.name]) || context.type || 'normal';
};
exports.getContextType = getContextType;
;