Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default (props: Props) => {
// Number.isInteger will be provided by @babel/runtime-corejs2
invariant(
Number.isInteger(props.index),
'Draggable requires an integer index prop',
);
invariant(props.draggableId, 'Draggable requires a draggableId');
invariant(
typeof props.isDragDisabled === 'boolean',
'isDragDisabled must be a boolean',
);
};
(windowScroll: Position, options: ScrollOptions) => {
invariant(
!whileDraggingRef.current,
'Cannot collect a droppable while a drag is occurring',
);
const previous: Props = previousRef.current;
const ref: ?HTMLElement = previous.getDroppableRef();
invariant(ref, 'Cannot collect without a droppable ref');
const env: Env = getEnv(ref);
const dragging: WhileDragging = {
ref,
descriptor,
env,
scrollOptions: options,
};
// side effect
whileDraggingRef.current = dragging;
const MarkPlugin = (options = {}) => {
const missingRequiredOptions = validate(options);
invariant(
missingRequiredOptions.length >= 0,
`ui-kit/rich-text-input/Mark: missing required options: ${missingRequiredOptions.join(
','
)}`
);
const isHotKey = memoizedIsHotkey(options.hotkey);
return [
{
// eslint-disable-next-line consistent-return
onKeyDown(event, editor, next) {
if (!isHotKey(event)) {
return next();
}
if (!frame) {
const subject: DroppableSubject = getSubject({
page: droppable.subject.page,
axis: droppable.axis,
frame: null,
// cleared
withPlaceholder: null,
});
return {
...droppable,
subject,
};
}
const oldMaxScroll: ?Position = added.oldFrameMaxScroll;
invariant(
oldMaxScroll,
'Expected droppable with frame to have old max frame scroll when removing placeholder',
);
const newFrame: Scrollable = withMaxScroll(frame, oldMaxScroll);
const subject: DroppableSubject = getSubject({
page: droppable.subject.page,
axis: droppable.axis,
frame: newFrame,
// cleared
withPlaceholder: null,
});
return {
...droppable,
subject,
export function assert(value, spec) {
// getSpec allows us to pass it strings to retrive previously defined specs.
invariant(
typeof spec === 'string' || spec instanceof Spec,
'Invalid spec '.concat(spec, ' passed to perusal.assert.')
);
var specification = getSpec(spec); // If the value was previous asserted with this specification, simply return the
// previous result.
if (value.specs && value.specs[specification.name]) return value.specs[specification.name];
return specification.assert(value);
}
/**
const throwIfSVG = (el: mixed) => {
invariant(
!isSvgElement(el),
`A drag handle cannot be an SVGElement: it has inconsistent focus support.
More information: https://github.com/atlassian/react-beautiful-dnd/blob/master/docs/guides/dragging-svgs.md`,
);
};
function useParams() {
if (process.env.NODE_ENV !== "production") {
!(typeof useContext === "function") ? process.env.NODE_ENV !== "production" ? invariant(false, "You must use React >= 16.8 in order to use useParams()") : invariant(false) : void 0;
}
var match = useContext(context).match;
return match ? match.params : {};
}
function useRouteMatch(path) {
export function and(name) {
invariant(typeof name === 'string', 'perusal-immutable.and was called with an invalid name.');
for (
var _len = arguments.length, specs = new Array(_len > 1 ? _len - 1 : 0), _key = 1;
_key < _len;
_key++
) {
specs[_key - 1] = arguments[_key];
}
invariant(specs.length > 0, 'perusal-immutable.and was called without specs.');
for (var _i = 0, _specs = specs; _i < _specs.length; _i++) {
var spec = _specs[_i];
invariant(spec instanceof Spec, 'perusal-immutable.and was called with invalid specs.');
}
return new And(name, specs);
}
export function getSpec(maybeSpec: string | Spec) {
if (maybeSpec instanceof Spec) return maybeSpec;
invariant(defs[maybeSpec], `Specification for ${maybeSpec} does not exist!`);
return defs[maybeSpec];
}
export const pred = (name: string, fn: (value: any) => boolean) => {
invariant(
fn && typeof fn === 'function',
'perusal-immutable.pred was called with an invalid predicate.'
);
invariant(
name && typeof name === 'string',
'perusal-immutable.pred was called with an invalid string.'
);
return new Pred(name, fn);
};