Socket
Socket
Sign inDemoInstall

@entur/utils

Package Overview
Dependencies
Maintainers
13
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@entur/utils - npm Package Compare versions

Comparing version 0.5.0-beta.0 to 0.5.0

38

CHANGELOG.md

@@ -6,6 +6,40 @@ # Change Log

# [0.5.0-beta.0](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.5.0-alpha.0...@entur/utils@0.5.0-beta.0) (2022-11-21)
## [0.4.9](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.8...@entur/utils@0.4.9) (2023-01-19)
### Performance Improvements
- **button:** remove usage of react-polymorphic-types in favor of own implementation in button packa ([d15d852](https://bitbucket.org/enturas/design-system/commits/d15d85245d7f7273f0700fafcef3201d4fa2e0ff))
- **layout:** remove usage of react-polymorphic-types in favor of own implementation in layout packa ([b7ada6d](https://bitbucket.org/enturas/design-system/commits/b7ada6d7b9776cce86dea51f58c4b7ea0300451b))
- **packages:** remove all referenves to react-polymorphic-types npm-package ([e47a304](https://bitbucket.org/enturas/design-system/commits/e47a304d87eb77adae5dd002e89f03026c7eadce))
## [0.4.8](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.5...@entur/utils@0.4.8) (2022-12-09)
### Bug Fixes
- **style import warning:** remove ~ from import warning since it is deprecated ([c6a25fd](https://bitbucket.org/enturas/design-system/commits/c6a25fde98ec2f2821f678c6175c797ad10b7185))
## [0.4.7](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.6...@entur/utils@0.4.7) (2022-11-24)
**Note:** Version bump only for package @entur/utils
## [0.4.6](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.5...@entur/utils@0.4.6) (2022-10-31)
### Bug Fixes
- **style import warning:** remove ~ from import warning since it is deprecated ([c6a25fd](https://bitbucket.org/enturas/design-system/commits/c6a25fde98ec2f2821f678c6175c797ad10b7185))
# [0.5.0-RC.2](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.5.0-RC.1...@entur/utils@0.5.0-RC.2) (2022-11-22)
### Bug Fixes
- **useOnEscape:** commit for force updating utils-packages for publishing ([4c1082c](https://bitbucket.org/enturas/design-system/commits/4c1082c872a546c6c848aed2e2ae80e2d4599d11))
# [0.5.0-RC.1](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.5.0-RC.0...@entur/utils@0.5.0-RC.1) (2022-11-21)
**Note:** Version bump only for package @entur/utils
# [0.5.0-RC.0](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.5.0-alpha.0...@entur/utils@0.5.0-RC.0) (2022-11-21)
**Note:** Version bump only for package @entur/utils
# [0.5.0-alpha.0](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.6-alpha.0...@entur/utils@0.5.0-alpha.0) (2022-10-26)

@@ -22,3 +56,3 @@

- **locale:** wip fix for locale not working ([0ff0912](https://bitbucket.org/enturas/design-system/commits/0ff0912405e015abb50c9cb6103c5f9827d8bd7b))
- **locale:** fix for locale not working ([0ff0912](https://bitbucket.org/enturas/design-system/commits/0ff0912405e015abb50c9cb6103c5f9827d8bd7b))

@@ -25,0 +59,0 @@ ## [0.4.5](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.4...@entur/utils@0.4.5) (2022-08-31)

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

import type { PolymorphicPropsWithoutRef, PolymorphicPropsWithRef, PolymorphicForwardRefExoticComponent } from 'react-polymorphic-types';
export { PolymorphicPropsWithoutRef, PolymorphicPropsWithRef, PolymorphicForwardRefExoticComponent, };
/** These polymorphic types are derrived from Ben Ilegbodu's article available at the following link:
* https://www.benmvp.com/blog/forwarding-refs-polymorphic-react-component-typescript/
*/
import React from 'react';
export declare type PropsOf<C extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>> = JSX.LibraryManagedAttributes<C, React.ComponentPropsWithoutRef<C>>;
declare type AsProp<C extends React.ElementType> = {
/**
* An override of the default HTML tag.
* Can also be another React component.
*/
as?: C;
};
/**
* Allows for extending a set of props (`ExtendedProps`) by an overriding set of props
* (`OverrideProps`), ensuring that any duplicates are overridden by the overriding
* set of props.
*/
export declare type ExtendableProps<ExtendedProps = Record<string, unknown>, OverrideProps = Record<string, unknown>> = OverrideProps & Omit<ExtendedProps, keyof OverrideProps>;
/**
* Allows for inheriting the props from the specified element type so that
* props like children, className & style work, as well as element-specific
* attributes like aria roles. The component (`C`) must be passed in.
*/
export declare type InheritableElementProps<C extends React.ElementType, Props = Record<string, unknown>> = ExtendableProps<PropsOf<C>, Props>;
/**
* A more sophisticated version of `InheritableElementProps` where
* the passed in `as` prop will determine which props can be included
*/
export declare type PolymorphicComponentProps<C extends React.ElementType, Props = Record<string, unknown>> = InheritableElementProps<C, Props & AsProp<C>>;
/**
* Utility type to extract the `ref` prop from a polymorphic component
*/
export declare type PolymorphicRef<C extends React.ElementType> = React.ComponentPropsWithRef<C>['ref'];
/**
* A wrapper of `PolymorphicComponentProps` that also includes the `ref`
* prop for the polymorphic component
*/
export declare type PolymorphicComponentPropsWithRef<C extends React.ElementType, Props = Record<string, unknown>> = PolymorphicComponentProps<C, Props> & {
ref?: PolymorphicRef<C>;
};
export {};

2

dist/useOnEscape.d.ts
import React from 'react';
export declare const useOnEscape: (ref: React.RefObject<HTMLDivElement>, handler: () => void) => void;
export declare const useOnEscape: (ref: React.RefObject<HTMLElement>, handler: () => void) => void;

@@ -147,3 +147,2 @@ 'use strict';

var runIfKeyIsEscape = function runIfKeyIsEscape(event) {
console.log('lol');
if (event.key === 'Escape') handler();

@@ -208,3 +207,3 @@ };

warning__default["default"](missingImports.length === 0, "You are missing " + (singleMissingImport ? 'a CSS import' : missingImports.length + " CSS imports") + "!\n\nPlease add the following CSS import" + (singleMissingImport ? '' : 's') + " somewhere in your app:\n\n" + missingImports.map(function (namespace) {
return "\t@import '~@entur/" + namespace + "/dist/styles.css';";
return "\t@import '@entur/" + namespace + "/dist/styles.css';";
}).join('\n') + "\n") ;

@@ -211,0 +210,0 @@ }

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("tiny-warning");var t=n(e);function r(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function o(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return r(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?r(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u=function(){var e=window;return{width:e.innerWidth,height:e.innerHeight}};exports.ConditionalWrapper=function(e){var n=e.children;return e.condition?(0,e.wrapper)(n):t.default.createElement(t.default.Fragment,null,n)},exports.debounce=function(e,n){var t;return function(){for(var r=arguments.length,o=new Array(r),u=0;u<r;u++)o[u]=arguments[u];clearTimeout(t),t=setTimeout((function(){return e.apply(void 0,o)}),n)}},exports.mergeRefs=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return function(e){for(var t,r=o(n);!(t=r()).done;){var u=t.value;"function"==typeof u?u(e):u&&(u.current=e)}}},exports.useOnClickOutside=function(n,t){e.useEffect((function(){var e=function(e){n.some((function(n){return function(e,n){return!(!e||!(e.contains(n.target)||n.composed&&n.composedPath&&n.composedPath().find((function(n){return n!==window&&e.contains(n)}))))}(n.current,e)}))||t()};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),function(){document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}}),[n,t])},exports.useOnEscape=function(n,t){e.useEffect((function(){var e,r=function(e){console.log("lol"),"Escape"===e.key&&t()};return null==(e=n.current)||e.addEventListener("keydown",r),function(){var e;return null==(e=n.current)?void 0:e.removeEventListener("keydown",r)}}),[n,t])},exports.useOnMount=function(e){var n=t.default.useRef(!1);t.default.useEffect((function(){n.current||(n.current=!0,e())}),[e])},exports.useRandomId=function(e){return e+"-"+t.default.useRef(String(Math.random()).substring(2)).current},exports.useWindowDimensions=function(){var n=e.useState(u()),t=n[0],r=n[1];return e.useEffect((function(){function e(){r(u())}return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[]),t},exports.warnAboutMissingStyles=function(){};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("tiny-warning");var t=n(e);function r(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function o(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return r(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?r(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u=function(){var e=window;return{width:e.innerWidth,height:e.innerHeight}};exports.ConditionalWrapper=function(e){var n=e.children;return e.condition?(0,e.wrapper)(n):t.default.createElement(t.default.Fragment,null,n)},exports.debounce=function(e,n){var t;return function(){for(var r=arguments.length,o=new Array(r),u=0;u<r;u++)o[u]=arguments[u];clearTimeout(t),t=setTimeout((function(){return e.apply(void 0,o)}),n)}},exports.mergeRefs=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return function(e){for(var t,r=o(n);!(t=r()).done;){var u=t.value;"function"==typeof u?u(e):u&&(u.current=e)}}},exports.useOnClickOutside=function(n,t){e.useEffect((function(){var e=function(e){n.some((function(n){return function(e,n){return!(!e||!(e.contains(n.target)||n.composed&&n.composedPath&&n.composedPath().find((function(n){return n!==window&&e.contains(n)}))))}(n.current,e)}))||t()};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),function(){document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}}),[n,t])},exports.useOnEscape=function(n,t){e.useEffect((function(){var e,r=function(e){"Escape"===e.key&&t()};return null==(e=n.current)||e.addEventListener("keydown",r),function(){var e;return null==(e=n.current)?void 0:e.removeEventListener("keydown",r)}}),[n,t])},exports.useOnMount=function(e){var n=t.default.useRef(!1);t.default.useEffect((function(){n.current||(n.current=!0,e())}),[e])},exports.useRandomId=function(e){return e+"-"+t.default.useRef(String(Math.random()).substring(2)).current},exports.useWindowDimensions=function(){var n=e.useState(u()),t=n[0],r=n[1];return e.useEffect((function(){function e(){r(u())}return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[]),t},exports.warnAboutMissingStyles=function(){};
//# sourceMappingURL=utils.cjs.production.min.js.map

@@ -138,3 +138,2 @@ import React, { useEffect, useState } from 'react';

var runIfKeyIsEscape = function runIfKeyIsEscape(event) {
console.log('lol');
if (event.key === 'Escape') handler();

@@ -199,3 +198,3 @@ };

process.env.NODE_ENV !== "production" ? warning(missingImports.length === 0, "You are missing " + (singleMissingImport ? 'a CSS import' : missingImports.length + " CSS imports") + "!\n\nPlease add the following CSS import" + (singleMissingImport ? '' : 's') + " somewhere in your app:\n\n" + missingImports.map(function (namespace) {
return "\t@import '~@entur/" + namespace + "/dist/styles.css';";
return "\t@import '@entur/" + namespace + "/dist/styles.css';";
}).join('\n') + "\n") : void 0;

@@ -202,0 +201,0 @@ }

{
"name": "@entur/utils",
"version": "0.5.0-beta.0",
"version": "0.5.0",
"license": "EUPL-1.2",

@@ -22,3 +22,2 @@ "main": "dist/index.js",

"build": "dts build && cp src/*.scss dist",
"test": "dts test --env=jsdom",
"lint": "dts lint"

@@ -31,6 +30,5 @@ },

"dependencies": {
"react-polymorphic-types": "^1.1.0",
"tiny-warning": "^1.0.3"
},
"gitHead": "9ee9c4ee58756a1101f2cb8b3647c29e98f1e017"
"gitHead": "36772ae4f2d8375622acff19736c07d15435cb95"
}

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