Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@react-md/utils

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-md/utils - npm Package Compare versions

Comparing version 2.0.0-alpha.1 to 2.0.0-alpha.3

CHANGELOG.md

10

es/index.js
export * from "./delegateEvent";
export * from "./touches";
import * as PassiveEvents from "./passiveEvents";
export { PassiveEvents };
export * from "./omit";

@@ -8,2 +10,10 @@ export * from "./positioning";

export { default as useToggle } from "./useToggle";
export { default as useInterval } from "./useInterval";
export { default as useTimeout } from "./useTimeout";
export { default as useTempValue } from "./useTempValue";
export { default as useScrollListener } from "./useScrollListener";
export { default as useRefCache } from "./useRefCache";
export { default as usePrevious } from "./usePrevious";
export { default as ScrollListener } from "./ScrollListener";
export * from "./ScrollListener";
//# sourceMappingURL=index.js.map

6

es/positioning/findSizingContainer.js

@@ -32,6 +32,4 @@ /**

}
else if (process.env.NODE_ENV === "development") {
/* tslint:disable no-console */
console.error("Unable to find a child element for sizing using the `data-query-selector`");
console.error(new Error().stack);
else if (process.env.NODE_ENV !== "production") {
throw new Error("Unable to find a child element using the `data-sizing-selector`");
}

@@ -38,0 +36,0 @@ }

@@ -1,4 +0,6 @@

export { default as getViewportBounds } from "./getViewportBounds";
export { default as findSizingContainer } from "./findSizingContainer";
export { default as getViewportSize } from "./getViewportSize";
export { default as positionRelativeTo } from "./positionRelativeTo";
export { default as getElementRect } from "./getElementRect";
export { default as getFixedPosition } from "./getFixedPosition";
export * from "./getFixedPosition";
//# sourceMappingURL=index.js.map

@@ -12,3 +12,3 @@ var __assign = (this && this.__assign) || function () {

};
import isPassiveEventsSupported from "./isPassiveEventsSupported";
import { isSupported } from "./passiveEvents";
/**

@@ -47,3 +47,3 @@ * A helper function for manually setting touch events on elements when they cannot be directly

// @ts-ignore
el[(add ? "add" : "remove") + "EventListener"]("touch" + eventType, callback, isPassiveEventsSupported ? __assign({ passive: true, capture: capture }, options) : capture);
el[(add ? "add" : "remove") + "EventListener"]("touch" + eventType, callback, isSupported ? __assign({ passive: true, capture: capture }, options) : capture);
}

@@ -50,0 +50,0 @@ /**

@@ -1,2 +0,3 @@

import { useState, useRef, useCallback, useEffect } from "react";
import { useCallback, useState } from "react";
import useRefCache from "./useRefCache";
/**

@@ -13,8 +14,5 @@ * This hooks provides an easy way to toggle a boolean flag for React components.

var _a = useState(defaultToggled), toggled = _a[0], setToggled = _a[1];
var toggledRef = useRef(toggled);
useEffect(function () {
toggledRef.current = toggled;
});
var previous = useRefCache(toggled);
var enable = useCallback(function () {
if (!toggledRef.current) {
if (!previous.current) {
setToggled(true);

@@ -24,3 +22,3 @@ }

var disable = useCallback(function () {
if (toggledRef.current) {
if (previous.current) {
setToggled(false);

@@ -27,0 +25,0 @@ }

@@ -5,5 +5,14 @@ "use strict";

}
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./delegateEvent"));
__export(require("./touches"));
var PassiveEvents = __importStar(require("./passiveEvents"));
exports.PassiveEvents = PassiveEvents;
__export(require("./omit"));

@@ -17,2 +26,17 @@ __export(require("./positioning"));

exports.useToggle = useToggle_1.default;
var useInterval_1 = require("./useInterval");
exports.useInterval = useInterval_1.default;
var useTimeout_1 = require("./useTimeout");
exports.useTimeout = useTimeout_1.default;
var useTempValue_1 = require("./useTempValue");
exports.useTempValue = useTempValue_1.default;
var useScrollListener_1 = require("./useScrollListener");
exports.useScrollListener = useScrollListener_1.default;
var useRefCache_1 = require("./useRefCache");
exports.useRefCache = useRefCache_1.default;
var usePrevious_1 = require("./usePrevious");
exports.usePrevious = usePrevious_1.default;
var ScrollListener_1 = require("./ScrollListener");
exports.ScrollListener = ScrollListener_1.default;
__export(require("./ScrollListener"));
//# sourceMappingURL=index.js.map

@@ -34,6 +34,4 @@ "use strict";

}
else if (process.env.NODE_ENV === "development") {
/* tslint:disable no-console */
console.error("Unable to find a child element for sizing using the `data-query-selector`");
console.error(new Error().stack);
else if (process.env.NODE_ENV !== "production") {
throw new Error("Unable to find a child element using the `data-sizing-selector`");
}

@@ -40,0 +38,0 @@ }

"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
var getViewportBounds_1 = require("./getViewportBounds");
exports.getViewportBounds = getViewportBounds_1.default;
var findSizingContainer_1 = require("./findSizingContainer");
exports.findSizingContainer = findSizingContainer_1.default;
var getViewportSize_1 = require("./getViewportSize");
exports.getViewportSize = getViewportSize_1.default;
var positionRelativeTo_1 = require("./positionRelativeTo");
exports.positionRelativeTo = positionRelativeTo_1.default;
var getElementRect_1 = require("./getElementRect");
exports.getElementRect = getElementRect_1.default;
var getFixedPosition_1 = require("./getFixedPosition");
exports.getFixedPosition = getFixedPosition_1.default;
__export(require("./getFixedPosition"));
//# sourceMappingURL=index.js.map

@@ -13,7 +13,4 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var isPassiveEventsSupported_1 = __importDefault(require("./isPassiveEventsSupported"));
var passiveEvents_1 = require("./passiveEvents");
/**

@@ -52,3 +49,3 @@ * A helper function for manually setting touch events on elements when they cannot be directly

// @ts-ignore
el[(add ? "add" : "remove") + "EventListener"]("touch" + eventType, callback, isPassiveEventsSupported_1.default ? __assign({ passive: true, capture: capture }, options) : capture);
el[(add ? "add" : "remove") + "EventListener"]("touch" + eventType, callback, passiveEvents_1.isSupported ? __assign({ passive: true, capture: capture }, options) : capture);
}

@@ -55,0 +52,0 @@ exports.setTouchEvent = setTouchEvent;

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = require("react");
var useRefCache_1 = __importDefault(require("./useRefCache"));
/**

@@ -15,8 +19,5 @@ * This hooks provides an easy way to toggle a boolean flag for React components.

var _a = react_1.useState(defaultToggled), toggled = _a[0], setToggled = _a[1];
var toggledRef = react_1.useRef(toggled);
react_1.useEffect(function () {
toggledRef.current = toggled;
});
var previous = useRefCache_1.default(toggled);
var enable = react_1.useCallback(function () {
if (!toggledRef.current) {
if (!previous.current) {
setToggled(true);

@@ -26,3 +27,3 @@ }

var disable = react_1.useCallback(function () {
if (toggledRef.current) {
if (previous.current) {
setToggled(false);

@@ -29,0 +30,0 @@ }

{
"name": "@react-md/utils",
"version": "2.0.0-alpha.1",
"version": "2.0.0-alpha.3",
"description": "General utils for react-md.",
"scripts": {
"build": "dev-utils build",
"clean": "dev-utils clean",
"test": "dev-utils test"
"clean": "dev-utils clean"
},

@@ -36,3 +35,3 @@ "main": "./lib/index.js",

},
"gitHead": "9197bcdf38df3cff304499431696dc8e950b4b17"
"gitHead": "ff38fa4bd502c527ffb8847eae71b471456e0355"
}

@@ -1,5 +0,5 @@

import { renderHook, cleanup, act } from "react-hooks-testing-library";
import { act, renderHook } from "react-hooks-testing-library";
import useToggle from "../useToggle";
afterEach(cleanup);
describe("useToggle", () => {

@@ -6,0 +6,0 @@ it("should default to setting toggled to false", () => {

export * from "./delegateEvent";
export * from "./touches";
import * as PassiveEvents from "./passiveEvents";
export { PassiveEvents };
export * from "./omit";

@@ -11,3 +14,11 @@

export { default as useToggle } from "./useToggle";
export { default as useInterval } from "./useInterval";
export { default as useTimeout } from "./useTimeout";
export { default as useTempValue } from "./useTempValue";
export { default as useScrollListener } from "./useScrollListener";
export { default as useRefCache } from "./useRefCache";
export { default as usePrevious } from "./usePrevious";
export { default as ScrollListener } from "./ScrollListener";
export * from "./ScrollListener";
export * from "./types.d";

@@ -1,2 +0,2 @@

import { Omit } from "./types.d";
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;

@@ -3,0 +3,0 @@ /**

@@ -33,8 +33,6 @@ /**

return content;
} else if (process.env.NODE_ENV === "development") {
/* tslint:disable no-console */
console.error(
"Unable to find a child element for sizing using the `data-query-selector`"
} else if (process.env.NODE_ENV !== "production") {
throw new Error(
"Unable to find a child element using the `data-sizing-selector`"
);
console.error(new Error().stack);
}

@@ -41,0 +39,0 @@ }

@@ -1,5 +0,5 @@

export { default as getViewportBounds } from "./getViewportBounds";
export { default as findSizingContainer } from "./findSizingContainer";
export { default as getViewportSize } from "./getViewportSize";
export { default as positionRelativeTo } from "./positionRelativeTo";
export * from "./types.d";
export { default as getElementRect } from "./getElementRect";
export { default as getFixedPosition } from "./getFixedPosition";
export * from "./getFixedPosition";

@@ -1,2 +0,2 @@

import isPassiveEventsSupported from "./isPassiveEventsSupported";
import { isSupported } from "./passiveEvents";

@@ -41,3 +41,3 @@ export type TouchTypes = "start" | "end" | "cancel" | "move";

callback,
isPassiveEventsSupported ? { passive: true, capture, ...options } : capture
isSupported ? { passive: true, capture, ...options } : capture
);

@@ -44,0 +44,0 @@ }

@@ -12,3 +12,2 @@ import { Ref } from "react";

export type Maybe<T, NotFound = null> = T | NotFound;
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;

@@ -24,1 +23,8 @@ /**

{ [K in Keys]-?: Required<Pick<T, K>> }[Keys];
interface LabelA11y {
"aria-label"?: string;
"aria-labelledby"?: string;
}
export type LabelRequiredForA11y<T extends LabelA11y> = T &
RequireAtLeastOne<T, "aria-label" | "aria-labelledby">;

@@ -1,2 +0,3 @@

import { useState, useRef, useCallback, useEffect } from "react";
import { useCallback, useState } from "react";
import useRefCache from "./useRefCache";

@@ -13,9 +14,6 @@ /**

const [toggled, setToggled] = useState(defaultToggled);
const toggledRef = useRef(toggled);
useEffect(() => {
toggledRef.current = toggled;
});
const previous = useRefCache(toggled);
const enable = useCallback(() => {
if (!toggledRef.current) {
if (!previous.current) {
setToggled(true);

@@ -25,3 +23,3 @@ }

const disable = useCallback(() => {
if (toggledRef.current) {
if (previous.current) {
setToggled(false);

@@ -28,0 +26,0 @@ }

export * from "./delegateEvent";
export * from "./touches";
import * as PassiveEvents from "./passiveEvents";
export { PassiveEvents };
export * from "./omit";

@@ -8,2 +10,10 @@ export * from "./positioning";

export { default as useToggle } from "./useToggle";
export { default as useInterval } from "./useInterval";
export { default as useTimeout } from "./useTimeout";
export { default as useTempValue } from "./useTempValue";
export { default as useScrollListener } from "./useScrollListener";
export { default as useRefCache } from "./useRefCache";
export { default as usePrevious } from "./usePrevious";
export { default as ScrollListener } from "./ScrollListener";
export * from "./ScrollListener";
export * from "./types.d";

@@ -1,2 +0,2 @@

import { Omit } from "./types.d";
export declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
/**

@@ -3,0 +3,0 @@ * I really don't know how to typedef this. It just creates

@@ -16,2 +16,2 @@ /**

*/
export default function findSizingContainer(el: HTMLElement | null): import("..").Maybe<HTMLElement, null>;
export default function findSizingContainer(el: HTMLElement | null): HTMLElement | null;

@@ -1,4 +0,5 @@

export { default as getViewportBounds } from "./getViewportBounds";
export { default as findSizingContainer } from "./findSizingContainer";
export { default as getViewportSize } from "./getViewportSize";
export { default as positionRelativeTo } from "./positionRelativeTo";
export * from "./types.d";
export { default as getElementRect } from "./getElementRect";
export { default as getFixedPosition } from "./getFixedPosition";
export * from "./getFixedPosition";

@@ -12,3 +12,2 @@ import { Ref } from "react";

export type Maybe<T, NotFound = null> = T | NotFound;
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;

@@ -24,1 +23,8 @@ /**

{ [K in Keys]-?: Required<Pick<T, K>> }[Keys];
interface LabelA11y {
"aria-label"?: string;
"aria-labelledby"?: string;
}
export type LabelRequiredForA11y<T extends LabelA11y> = T &
RequireAtLeastOne<T, "aria-label" | "aria-labelledby">;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc