@os-design/omit-emotion-props 1.0.18 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts.map +1 -0
- package/dist/{esm/index.js → index.js} +1 -2
- package/package.json +8 -9
- package/src/index.mdx +47 -0
- package/dist/cjs/index.js +0 -19
- package/dist/cjs/index.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- /package/dist/{types/index.d.ts → index.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,UAAU,mBAAmB;IAC3B,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CAC9C;AAED,QAAA,MAAM,gBAAgB,aAAc,MAAM,EAAE,KAAG,mBAE7C,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@os-design/omit-emotion-props",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.20",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"repository": "git@gitlab.com:os-team/libs/os-design.git",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"types": "dist/
|
|
9
|
-
"react-native": "src/index.ts",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"react-native": "./src/index.ts",
|
|
10
10
|
"files": [
|
|
11
11
|
"dist",
|
|
12
12
|
"src",
|
|
@@ -21,9 +21,8 @@
|
|
|
21
21
|
"sideEffects": false,
|
|
22
22
|
"scripts": {
|
|
23
23
|
"clean": "rimraf dist",
|
|
24
|
-
"build:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts,.tsx --out-dir dist
|
|
25
|
-
"build:
|
|
26
|
-
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types",
|
|
24
|
+
"build:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts,.tsx --out-dir dist",
|
|
25
|
+
"build:types": "tsc -p tsconfig.build.json --emitDeclarationOnly --declaration --declarationDir dist",
|
|
27
26
|
"build": "yarn clean && npm-run-all 'build:*'",
|
|
28
27
|
"ncu": "ncu -u"
|
|
29
28
|
},
|
|
@@ -33,5 +32,5 @@
|
|
|
33
32
|
"devDependencies": {
|
|
34
33
|
"react": ">=18"
|
|
35
34
|
},
|
|
36
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "86a83e87297a07afe132782ca2c95023b7139276"
|
|
37
36
|
}
|
package/src/index.mdx
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Meta } from '@storybook/blocks';
|
|
2
|
+
import { Square, SquareWithoutProps } from './index.example';
|
|
3
|
+
|
|
4
|
+
<Meta title='Utils/omitEmotionProps' />
|
|
5
|
+
|
|
6
|
+
# omitEmotionProps
|
|
7
|
+
|
|
8
|
+
Disables forwarding the specified properties to the element.
|
|
9
|
+
See more in the [emotion docs](https://emotion.sh/docs/styled#customizing-prop-forwarding).
|
|
10
|
+
|
|
11
|
+
## Example of usage
|
|
12
|
+
|
|
13
|
+
Pass `omitEmotionProps('prop1', 'prop2')` as a second argument of the `styled` function.
|
|
14
|
+
You can specify as many properties as you want.
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import styled from '@emotion/styled';
|
|
18
|
+
import { omitEmotionProps } from '@os-design/styles';
|
|
19
|
+
|
|
20
|
+
interface SquareProps {
|
|
21
|
+
size: number;
|
|
22
|
+
color: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const Square = styled.div<SquareProps>`
|
|
26
|
+
width: ${(p) => p.size}em;
|
|
27
|
+
height: ${(p) => p.size}em;
|
|
28
|
+
background-color: ${(p) => p.color};
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
export const SquareWithoutProps = styled(
|
|
32
|
+
'div',
|
|
33
|
+
omitEmotionProps('size', 'color')
|
|
34
|
+
)<SquareProps>`
|
|
35
|
+
width: ${(p) => p.size}em;
|
|
36
|
+
height: ${(p) => p.size}em;
|
|
37
|
+
background-color: ${(p) => p.color};
|
|
38
|
+
`;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
As a result, the `size` and `color` properties will not be passed to the HTML element (see the HTML code).
|
|
42
|
+
|
|
43
|
+
<SquareWithoutProps size={10} color='gray' />
|
|
44
|
+
|
|
45
|
+
If you did not use the `omitEmotionProps` function, the properties will be passed to the HTML element (see the HTML code).
|
|
46
|
+
|
|
47
|
+
<Square size={10} color='gray' />
|
package/dist/cjs/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var omitEmotionProps = function omitEmotionProps() {
|
|
8
|
-
for (var _len = arguments.length, props = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
9
|
-
props[_key] = arguments[_key];
|
|
10
|
-
}
|
|
11
|
-
return {
|
|
12
|
-
shouldForwardProp: function shouldForwardProp(p) {
|
|
13
|
-
return !props.includes(p);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
var _default = omitEmotionProps;
|
|
18
|
-
exports["default"] = _default;
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["omitEmotionProps","_len","arguments","length","props","Array","_key","shouldForwardProp","p","includes","_default","exports"],"sources":["../../src/index.ts"],"sourcesContent":["interface OmitEmotionPropsRes {\n shouldForwardProp: (prop: string) => boolean;\n}\n\nconst omitEmotionProps = (...props: string[]): OmitEmotionPropsRes => ({\n shouldForwardProp: (p) => !props.includes(p),\n});\n\nexport default omitEmotionProps;\n"],"mappings":";;;;;;AAIA,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAA;EAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAOC,KAAK,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;IAALF,KAAK,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;EAAA;EAAA,OAAqC;IACrEC,iBAAiB,EAAE,SAAAA,kBAACC,CAAC;MAAA,OAAK,CAACJ,KAAK,CAACK,QAAQ,CAACD,CAAC,CAAC;IAAA;EAC9C,CAAC;AAAA,CAAC;AAAC,IAAAE,QAAA,GAEYV,gBAAgB;AAAAW,OAAA,cAAAD,QAAA"}
|
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["omitEmotionProps","props","shouldForwardProp","p","includes"],"sources":["../../src/index.ts"],"sourcesContent":["interface OmitEmotionPropsRes {\n shouldForwardProp: (prop: string) => boolean;\n}\n\nconst omitEmotionProps = (...props: string[]): OmitEmotionPropsRes => ({\n shouldForwardProp: (p) => !props.includes(p),\n});\n\nexport default omitEmotionProps;\n"],"mappings":"AAIA,MAAMA,gBAAgB,GAAGA,CAAC,GAAGC,KAAe,MAA2B;EACrEC,iBAAiB,EAAGC,CAAC,IAAK,CAACF,KAAK,CAACG,QAAQ,CAACD,CAAC;AAC7C,CAAC,CAAC;AAEF,eAAeH,gBAAgB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,UAAU,mBAAmB;IAC3B,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CAC9C;AAED,QAAA,MAAM,gBAAgB,aAAc,MAAM,EAAE,KAAG,mBAE7C,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
|
|
File without changes
|