This commit is contained in:
Iliyan Angelov
2025-09-14 23:24:25 +03:00
commit c67067a2a4
71311 changed files with 6800714 additions and 0 deletions

View File

@@ -0,0 +1 @@
exports.shouldForwardProp=function(o){return function(r){for(let e in r)o(e)||delete r[e]}};

View File

@@ -0,0 +1 @@
function e(e){return function(n){for(let t in n)e(t)||delete n[t]}}export{e as shouldForwardProp};

View File

@@ -0,0 +1 @@
function e(e){return function(n){for(let t in n)e(t)||delete n[t]}}export{e as shouldForwardProp};

View File

@@ -0,0 +1 @@
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define(["exports"],o):o((e||self).gooberForwardProp={})}(this,function(e){e.shouldForwardProp=function(e){return function(o){for(let n in o)e(n)||delete o[n]}}});

View File

@@ -0,0 +1,41 @@
{
"name": "goober-should-forward-prop",
"amdName": "gooberForwardProp",
"version": "0.0.1",
"description": "The shouldForwardProp addon function for goober",
"sideEffects": false,
"main": "./dist/goober-should-forward-prop.cjs",
"module": "./dist/goober-should-forward-prop.esm.js",
"umd:main": "./dist/goober-should-forward-prop.umd.js",
"source": "./src/index.js",
"unpkg": "./dist/goober-should-forward-prop.umd.js",
"types": "./should-forward-prop.d.ts",
"type": "module",
"scripts": {
"build": "rm -rf dist && microbundle --entry src/index.js --name gooberForwardProp --no-sourcemap --generateTypes false",
"test": "jest --setupFiles ./jest.setup.js"
},
"repository": {
"type": "git",
"url": "https://github.com/cristianbote/goober.git",
"directory": "should-forward-prop"
},
"author": "Jonas De Vrient <devrient.jonas@gmail.com>",
"keywords": [
"goober",
"styled",
"should-forward-prop"
],
"license": "MIT",
"peerDependencies": {
"goober": "^2.0.18"
},
"devDependencies": {
"microbundle": "^0.14.2",
"jest": "^24.1.0",
"preact": "^10.5.6",
"@babel/plugin-transform-react-jsx": "^7.7.0",
"@babel/preset-env": "^7.3.1",
"babel-jest": "^24.1.0"
}
}

View File

@@ -0,0 +1,9 @@
export = gooberShouldForwardProp;
export as namespace shouldForwardProp;
declare namespace gooberShouldForwardProp {
type ForwardPropFunction = (prop: string) => boolean;
function shouldForwardProp(fwdProp: ForwardPropFunction): (props: object) => undefined;
}

View File

@@ -0,0 +1,25 @@
import { css } from 'goober';
import { shouldForwardProp } from '../index';
describe('shouldForwardProp', () => {
it('type', () => {
expect(typeof shouldForwardProp).toEqual('function');
});
it('shouldForwardProp', () => {
const fn = shouldForwardProp((prop) => {
// Filter out props prefixed with '$'
return prop[0] !== '$';
});
const props = {
color: 'red',
$shouldAnimate: true
};
// 'render'
fn(props);
expect(props).toEqual({ color: 'red' });
});
});

View File

@@ -0,0 +1,19 @@
/**
* Should forward prop utility function
* @param {Function} filterPropFunction The flter function
*/
export function shouldForwardProp(filterPropFunction) {
/**
* The forward props function passed to `setup`
* @param {object} props
*/
function forwardProp(props) {
for (let p in props) {
if (!filterPropFunction(p)) {
delete props[p];
}
}
}
return forwardProp;
}