Socket
Socket
Sign inDemoInstall

@pap-it/system-react

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pap-it/system-react - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

68

dist/src/HOC.js

@@ -1,67 +0,1 @@

import { jsx as _jsx } from "react/jsx-runtime";
import React from "react";
export function papHOC(WebComponent) {
const InternalComponent = React.forwardRef((props, forwardedRef) => {
const internalRef = React.useRef(null);
const eventsAdded = React.useRef(new Set());
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [_loaded, setLoaded] = React.useState(false);
React.useEffect(() => {
if (typeof forwardedRef === "function") {
forwardedRef(internalRef.current);
}
else if (forwardedRef) {
forwardedRef.current = internalRef.current;
}
if (internalRef.current)
setLoaded(true);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [internalRef.current]);
const attributes = {
class: props.className,
};
// TODO use this to get property info later
// const propertyConfig = internalRef.current.getProperties();
if (internalRef.current) {
for (let name in props) {
if (typeof props[name] === "function") {
// check if its event
if (name.startsWith('on')) // NOTE it would suck for functions that do in fact start with on..
{
if (eventsAdded.current.has(name)) {
// we already added it !
continue;
}
const eventname = extractEventName(name);
if (eventname) {
internalRef.current.addEventListener(eventname, props[name]);
eventsAdded.current.add(name);
continue;
}
}
// else we add this function directly to ref
internalRef.current[name] = props[name];
}
else if (typeof props[name] === "object") {
internalRef.current[name] = props[name];
}
else {
// primitive
// we should check if its available in the properties and if attribute is not false
// internalRef.current[name as keyof TElement] = props[name as keyof Props];
attributes[name] = props[name];
}
}
}
return (_jsx(WebComponent, { ref: internalRef, ...attributes, children: props.children }));
});
return React.memo(InternalComponent);
}
function extractEventName(name) {
if (name.startsWith('on')) {
return name
.replace(/^on/, '')
.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
}
return null;
}
"use strict";import{jsx as l}from"react/jsx-runtime";import r from"react";export function papHOC(c){const s=r.forwardRef((t,u)=>{const n=r.useRef(null),i=r.useRef(new Set),[d,o]=r.useState(!1);r.useEffect(()=>{typeof u=="function"?u(n.current):u&&(u.current=n.current),n.current&&o(!0)},[n.current]);const a={class:t.className};if(n.current)for(let e in t)if(typeof t[e]=="function"){if(e.startsWith("on")){if(i.current.has(e))continue;const f=m(e);if(f){n.current.addEventListener(f,t[e]),i.current.add(e);continue}}n.current[e]=t[e]}else typeof t[e]=="object"?n.current[e]=t[e]:a[e]=t[e];return l(c,{ref:n,...a,children:t.children})});return r.memo(s)}function m(c){return c.startsWith("on")?c.replace(/^on/,"").replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase():null}

4

dist/src/index.js

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

export * from './HOC';
export * from './types';
// * <-- This is an asshole
"use strict";export*from"./HOC";export*from"./types";

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

export {};
"use strict";export{};
{
"name": "@pap-it/system-react",
"version": "0.0.5",
"version": "0.0.6",
"scripts": {

@@ -5,0 +5,0 @@ "test": ".scripts/test.sh",

@@ -5,5 +5,6 @@ # ReactSystem

Version: Version: 0.0.5
Version: Version: Version: 0.0.6
## Development

@@ -10,0 +11,0 @@

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