You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.2 KiB
52 lines
1.2 KiB
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = _default;
|
|
|
|
function _react() {
|
|
const data = _interopRequireDefault(require("react"));
|
|
|
|
_react = function _react() {
|
|
return data;
|
|
};
|
|
|
|
return data;
|
|
}
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _default() {
|
|
return `\
|
|
import React, { useContext } from 'react';
|
|
import AccessContext, { AccessInstance as AccessInstanceType } from './context';
|
|
|
|
export type AccessInstance = AccessInstanceType;
|
|
|
|
export const useAccess = () => {
|
|
const access = useContext(AccessContext);
|
|
|
|
return access;
|
|
};
|
|
|
|
export interface AccessProps {
|
|
accessible: boolean;
|
|
fallback?: React.ReactNode;
|
|
}
|
|
|
|
export const Access: React.FC<AccessProps> = props => {
|
|
const { accessible, fallback, children } = props;
|
|
|
|
if (process.env.NODE_ENV === 'development' && typeof accessible === 'function') {
|
|
console.warn(
|
|
'[plugin-access]: provided "accessible" prop is a function named "' +
|
|
(accessible as Function).name +
|
|
'" instead of a boolean, maybe you need check it.',
|
|
);
|
|
}
|
|
|
|
return <>{accessible ? children : fallback}</>;
|
|
};
|
|
`;
|
|
} |