@rocket.chat/styled 0.34.1 → 0.34.2

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/README.md CHANGED
@@ -1,91 +1,122 @@
1
- <!--header-->
1
+ # `@rocket.chat/styled`
2
2
 
3
- <p align="center">
4
- <a href="https://rocket.chat" title="Rocket.Chat">
5
- <img src="https://github.com/RocketChat/Rocket.Chat.Artwork/raw/master/Logos/2020/png/logo-horizontal-red.png" alt="Rocket.Chat" />
6
- </a>
7
- </p>
3
+ > Minimal `styled` API to create React components from HTML elements and tagged CSS templates.
8
4
 
9
- # `@rocket.chat/styled`
5
+ [![npm](https://img.shields.io/npm/v/@rocket.chat/styled?style=flat-square)](https://www.npmjs.com/package/@rocket.chat/styled) [![downloads](https://img.shields.io/npm/dw/@rocket.chat/styled?style=flat-square)](https://www.npmjs.com/package/@rocket.chat/styled)
10
6
 
11
- > A simple styled API for React components
7
+ `styled` turns an intrinsic element (`div`, `button`, `span`...) and a CSS template into a React function component. Each distinct set of evaluated styles gets a hashed class name. The rules are transpiled and attached to the document by [`@rocket.chat/css-in-js`](https://www.npmjs.com/package/@rocket.chat/css-in-js), so you get vendor prefixes and fallbacks for CSS logical properties for free.
12
8
 
13
- ---
9
+ It is intentionally small: it only styles intrinsic elements, and has no theming, `as` prop or `attrs`.
14
10
 
15
- [![npm@latest](https://img.shields.io/npm/v/@rocket.chat/styled/latest?style=flat-square)](https://www.npmjs.com/package/@rocket.chat/styled/v/latest) [![npm@next](https://img.shields.io/npm/v/@rocket.chat/styled/next?style=flat-square)](https://www.npmjs.com/package/@rocket.chat/styled/v/next) ![npm downloads](https://img.shields.io/npm/dw/@rocket.chat/styled?style=flat-square) ![License: MIT](https://img.shields.io/npm/l/@rocket.chat/styled?style=flat-square)
11
+ ## Installation
16
12
 
17
- ![deps](https://img.shields.io/librariesio/release/npm/@rocket.chat/styled?style=flat-square) ![npm bundle size](https://img.shields.io/bundlephobia/min/@rocket.chat/styled?style=flat-square)
13
+ ```sh
14
+ npm install @rocket.chat/styled react
15
+ ```
18
16
 
19
- <!--/header-->
17
+ `react` is a peer dependency. The components use `useInsertionEffect`, so React 18 or later is required.
20
18
 
21
- ## Install
19
+ ## Usage
22
20
 
23
- <!--install-->
21
+ ### Style an element
24
22
 
25
- Add `@rocket.chat/styled` as a dependency:
23
+ ```tsx
24
+ import styled from '@rocket.chat/styled';
26
25
 
27
- ```sh
28
- npm i @rocket.chat/styled
26
+ const Card = styled('div')`
27
+ padding-block: 8px;
28
+ padding-inline: 16px;
29
+ border-radius: 4px;
30
+ background-color: white;
29
31
 
30
- # or, if you are using yarn:
32
+ &:hover {
33
+ background-color: whitesmoke;
34
+ }
35
+ `;
31
36
 
32
- yarn add @rocket.chat/styled
37
+ const App = () => <Card role='region'>Hello</Card>;
33
38
  ```
34
39
 
35
- <!--/install-->
40
+ The component accepts every prop of the underlying element. A `className` you pass is kept and the generated class name is appended to it.
36
41
 
37
- ## Contributing
42
+ ### Style from props
38
43
 
39
- <!--contributing(msg)-->
44
+ Function interpolations receive the component props. Use the second argument of `styled` to remove custom props before they reach the DOM element.
40
45
 
41
- Contributions, issues, and feature requests are welcome!<br />
42
- Feel free to check the [issues](https://github.com/RocketChat/fuselage/issues).
46
+ ```tsx
47
+ import styled from '@rocket.chat/styled';
43
48
 
44
- <!--/contributing(msg)-->
49
+ type BadgeProps = { tone: 'info' | 'danger' };
45
50
 
46
- ### Building
51
+ const Badge = styled<'span', BadgeProps>('span', ({ tone: _tone, ...props }) => props)`
52
+ padding: 2px 6px;
53
+ color: white;
54
+ background-color: ${(p) => (p.tone === 'danger' ? 'crimson' : 'steelblue')};
55
+ `;
47
56
 
48
- As this package dependends on others in this monorepo, before anything run the following at the root directory:
57
+ const App = () => <Badge tone='danger'>3</Badge>;
58
+ ```
49
59
 
50
- <!--yarn(build)-->
60
+ ### Render into another document
51
61
 
52
- ```sh
53
- yarn build
54
- ```
62
+ Styles are attached to `window.document` by default. When rendering into an iframe or a popup window, provide its document through `OwnerDocument`:
55
63
 
56
- <!--/yarn(build)-->
64
+ ```tsx
65
+ import { OwnerDocument } from '@rocket.chat/styled';
66
+ import type { ReactNode } from 'react';
67
+ import { createPortal } from 'react-dom';
57
68
 
58
- ### Linting
69
+ const PopupContent = ({ popup, children }: { popup: Window; children: ReactNode }) => (
70
+ <OwnerDocument.Provider value={{ document: popup.document }}>{createPortal(children, popup.document.body)}</OwnerDocument.Provider>
71
+ );
72
+ ```
59
73
 
60
- To ensure the source is matching our coding style, we perform [linting](<https://en.wikipedia.org/wiki/Lint_(software)>).
61
- Before commiting, check if your code fits our style by running:
74
+ ## API
62
75
 
63
- <!--yarn(lint)-->
76
+ ### `styled` (default export)
64
77
 
65
- ```sh
66
- yarn lint
78
+ ```ts
79
+ styled<K extends keyof JSX.IntrinsicElements, P>(
80
+ type: K,
81
+ filter?: (props: JSX.IntrinsicElements[K] & P) => JSX.IntrinsicElements[K],
82
+ ): (
83
+ slices: TemplateStringsArray,
84
+ ...values: readonly (string | ((props: P) => string))[]
85
+ ) => FunctionComponent<JSX.IntrinsicElements[K] & P>;
67
86
  ```
68
87
 
69
- <!--/yarn(lint)-->
88
+ - `type`: the intrinsic element to render.
89
+ - `filter`: optional function that receives the props (with the generated `className` already merged) and returns the props passed to the element.
70
90
 
71
- Some linter warnings and errors can be automatically fixed:
91
+ The returned component has `displayName` set to `StyledComponent(<type>)`. Its rules are attached in an insertion effect and detached about one second after the component unmounts or its styles change.
72
92
 
73
- <!--yarn(lint-and-fix)-->
93
+ ### `OwnerDocument`
74
94
 
75
- ```sh
76
- yarn lint-and-fix
95
+ ```ts
96
+ const OwnerDocument: React.Context<{ document: Document }>;
77
97
  ```
78
98
 
79
- <!--/yarn(lint-and-fix)-->
99
+ React context that sets the document where styles are attached. Defaults to `window.document`.
80
100
 
81
- ### Running tests
101
+ ### `useOwnerDocument`
82
102
 
83
- Whenever possible, add tests to describe exactly what your code do. You can run them by yourself:
103
+ ```ts
104
+ const useOwnerDocument: () => { document: Document };
105
+ ```
84
106
 
85
- <!--yarn(test)-->
107
+ Reads the current `OwnerDocument` value.
108
+
109
+ ## Development
110
+
111
+ This package lives in the [Rocket.Chat monorepo](https://github.com/RocketChat/Rocket.Chat/tree/develop/packages/styled). From the repository root:
86
112
 
87
113
  ```sh
88
- yarn test
114
+ yarn workspace @rocket.chat/styled build
115
+ yarn workspace @rocket.chat/styled testunit
116
+ yarn workspace @rocket.chat/styled lint
117
+ yarn workspace @rocket.chat/styled typecheck
89
118
  ```
90
119
 
91
- <!--/yarn(test)-->
120
+ ## License
121
+
122
+ MIT — see [LICENSE](https://github.com/RocketChat/Rocket.Chat/blob/develop/LICENSE).
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OwnerDocument.d.ts","sourceRoot":"","sources":["../src/OwnerDocument.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa;cACf,QAAQ;EACc,CAAC;AAElC,eAAO,MAAM,gBAAgB;cAHlB,QAAQ;CAKlB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@rocket.chat/css-in-js"),t=require("react");const s=t.createContext({document:window.document}),n=()=>t.useContext(s),a=(e,t)=>Object.assign(Object.assign({},e),{className:e.className?`${e.className} ${t}`:t});exports.OwnerDocument=s,exports.default=(s,c)=>(r,...o)=>{const u=e.css(r,...o),m="undefined"==typeof window?n=>{const r=u(n),o=e.createClassName(r),m=e.escapeName(o),l=e.transpile(`.${m}`,r),i=a(n,o);return t.createElement(t.Fragment,{},t.createElement("style",{},l),t.createElement(s,c?c(i):i))}:r=>{const o=u(r),m=e.createClassName(o);t.useDebugValue(m);const{document:l}=n();t.useInsertionEffect(()=>{const t=e.escapeName(m),s=e.transpile(`.${t}`,o),n=e.attachRules(s,{document:l});return()=>{setTimeout(n,1e3)}},[m,o,l]);const i=a(r,m);return t.createElement(s,c?c(i):i)};return m.displayName=`StyledComponent(${s})`,m},exports.useOwnerDocument=n;
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/OwnerDocument.ts","../src/styled.ts"],"sourcesContent":[null,null],"names":["OwnerDocument","createContext","document","window","useOwnerDocument","useContext","attachClassName","props","additionalClassName","Object","assign","className","type","filter","slices","values","cssFn","css","StyledComponent","content","computedClassName","createClassName","escapedClassName","escapeName","transpiledContent","transpile","newProps","createElement","Fragment","useDebugValue","useInsertionEffect","detach","attachRules","setTimeout","displayName"],"mappings":"+HAEO,MAAMA,EAAgBC,EAAAA,cAE1B,CAAEC,SAAUC,OAAOD,WAETE,EAAmB,IACxBC,EAAAA,WAAWL,GCDNM,EAAkB,CAAmCC,EAAUC,IAAmCC,OAAAC,OAAAD,OAAAC,OAAA,GAC3GH,GAAK,CACRI,UAAWJ,EAAMI,UAAY,GAAGJ,EAAMI,aAAaH,IAAwBA,4CAI3E,CAA2CI,EAASC,IACpD,CACCC,KACGC,KAEH,MAAMC,EAAQC,EAAAA,IAAIH,KAAWC,GAEvBG,EACa,oBAAXf,OACHI,IACD,MAAMY,EAAUH,EAAMT,GAChBa,EAAoBC,EAAAA,gBAAgBF,GACpCG,EAAmBC,EAAAA,WAAWH,GAC9BI,EAAoBC,EAAAA,UAAU,IAAIH,IAAoBH,GAEtDO,EAAWpB,EAAgBC,EAAOa,GAExC,OAAOO,EAAAA,cACNC,EAAAA,SACA,CAAA,EACAD,EAAAA,cAAc,QAAS,CAAA,EAAIH,GAC3BG,EAAAA,cAAcf,EAAMC,EAASA,EAAOa,GAAYA,KAGhDnB,IACD,MAAMY,EAAUH,EAAMT,GAChBa,EAAoBC,EAAAA,gBAAgBF,GAE1CU,EAAAA,cAAcT,GAEd,MAAMlB,SAAEA,GAAaE,IACrB0B,EAAAA,mBAAmB,KAClB,MAAMR,EAAmBC,EAAAA,WAAWH,GAC9BI,EAAoBC,EAAAA,UAAU,IAAIH,IAAoBH,GACtDY,EAASC,EAAAA,YAAYR,EAAmB,CAAEtB,aAEhD,MAAO,KACN+B,WAAWF,EAAQ,OAElB,CAACX,EAAmBD,EAASjB,IAEhC,MAAMwB,EAAWpB,EAAgBC,EAAOa,GACxC,OAAOO,EAAAA,cAAcf,EAAMC,EAASA,EAAOa,GAAYA,IAK3D,OAFAR,EAAgBgB,YAAc,mBAAmBtB,KAE1CM"}
@@ -0,0 +1,2 @@
1
+ import{css as t,createClassName as e,escapeName as n,transpile as s,attachRules as o}from"@rocket.chat/css-in-js";import{createContext as c,useContext as r,createElement as a,Fragment as m,useDebugValue as d,useInsertionEffect as u}from"react";const i=c({document:window.document}),l=()=>r(i),p=(t,e)=>Object.assign(Object.assign({},t),{className:t.className?`${t.className} ${e}`:e}),f=(c,r)=>(i,...f)=>{const $=t(i,...f),w="undefined"==typeof window?t=>{const o=$(t),d=e(o),u=n(d),i=s(`.${u}`,o),l=p(t,d);return a(m,{},a("style",{},i),a(c,r?r(l):l))}:t=>{const m=$(t),i=e(m);d(i);const{document:f}=l();u(()=>{const t=n(i),e=s(`.${t}`,m),c=o(e,{document:f});return()=>{setTimeout(c,1e3)}},[i,m,f]);const w=p(t,i);return a(c,r?r(w):w)};return w.displayName=`StyledComponent(${c})`,w};export{i as OwnerDocument,f as default,l as useOwnerDocument};
2
+ //# sourceMappingURL=index.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.module.js","sources":["../src/OwnerDocument.ts","../src/styled.ts"],"sourcesContent":[null,null],"names":["OwnerDocument","createContext","document","window","useOwnerDocument","useContext","attachClassName","props","additionalClassName","Object","assign","className","styled","type","filter","slices","values","cssFn","css","StyledComponent","content","computedClassName","createClassName","escapedClassName","escapeName","transpiledContent","transpile","newProps","createElement","Fragment","useDebugValue","useInsertionEffect","detach","attachRules","setTimeout","displayName"],"mappings":"oPAEO,MAAMA,EAAgBC,EAE1B,CAAEC,SAAUC,OAAOD,WAETE,EAAmB,IACxBC,EAAWL,GCDNM,EAAkB,CAAmCC,EAAUC,IAAmCC,OAAAC,OAAAD,OAAAC,OAAA,GAC3GH,GAAK,CACRI,UAAWJ,EAAMI,UAAY,GAAGJ,EAAMI,aAAaH,IAAwBA,IAGtEI,EACL,CAA2CC,EAASC,IACpD,CACCC,KACGC,KAEH,MAAMC,EAAQC,EAAIH,KAAWC,GAEvBG,EACa,oBAAXhB,OACHI,IACD,MAAMa,EAAUH,EAAMV,GAChBc,EAAoBC,EAAgBF,GACpCG,EAAmBC,EAAWH,GAC9BI,EAAoBC,EAAU,IAAIH,IAAoBH,GAEtDO,EAAWrB,EAAgBC,EAAOc,GAExC,OAAOO,EACNC,EACA,CAAA,EACAD,EAAc,QAAS,CAAA,EAAIH,GAC3BG,EAAcf,EAAMC,EAASA,EAAOa,GAAYA,KAGhDpB,IACD,MAAMa,EAAUH,EAAMV,GAChBc,EAAoBC,EAAgBF,GAE1CU,EAAcT,GAEd,MAAMnB,SAAEA,GAAaE,IACrB2B,EAAmB,KAClB,MAAMR,EAAmBC,EAAWH,GAC9BI,EAAoBC,EAAU,IAAIH,IAAoBH,GACtDY,EAASC,EAAYR,EAAmB,CAAEvB,aAEhD,MAAO,KACNgC,WAAWF,EAAQ,OAElB,CAACX,EAAmBD,EAASlB,IAEhC,MAAMyB,EAAWrB,EAAgBC,EAAOc,GACxC,OAAOO,EAAcf,EAAMC,EAASA,EAAOa,GAAYA,IAK3D,OAFAR,EAAgBgB,YAAc,mBAAmBtB,KAE1CM"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../src/styled.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAKpD,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,OAAO,CAAC,EAAE,qBAAqB,MAAM,KAAG,CAGxG,CAAC;AAEH,QAAA,MAAM,MAAM,GACV,CAAC,SAAS,MAAM,GAAG,CAAC,iBAAiB,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAEzH,QAAQ,oBAAoB,EAC5B,GAAG,QAAQ,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC,CAAC,EAAE,KACrD,iBAAiB,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,CA4ChD,CAAC;AAEH,eAAe,MAAM,CAAC"}
package/package.json CHANGED
@@ -1,14 +1,20 @@
1
1
  {
2
2
  "name": "@rocket.chat/styled",
3
- "version": "0.34.1",
3
+ "version": "0.34.2",
4
4
  "description": "A simple styled API for React components",
5
- "homepage": "https://github.com/RocketChat/fuselage#readme",
5
+ "keywords": [
6
+ "react",
7
+ "styled",
8
+ "css-in-js",
9
+ "rocket.chat"
10
+ ],
11
+ "homepage": "https://github.com/RocketChat/Rocket.Chat#readme",
6
12
  "bugs": {
7
- "url": "https://github.com/RocketChat/fuselage/issues"
13
+ "url": "https://github.com/RocketChat/Rocket.Chat/issues"
8
14
  },
9
15
  "repository": {
10
16
  "type": "git",
11
- "url": "git+https://github.com/RocketChat/fuselage.git",
17
+ "url": "git+https://github.com/RocketChat/Rocket.Chat.git",
12
18
  "directory": "packages/styled"
13
19
  },
14
20
  "license": "MIT",
@@ -16,44 +22,48 @@
16
22
  "name": "Rocket.Chat",
17
23
  "url": "https://rocket.chat/"
18
24
  },
19
- "main": "dist/cjs/index.js",
20
- "module": "dist/esm/index.js",
21
- "types": "dist/esm/index.d.ts",
25
+ "main": "dist/index.js",
26
+ "module": "dist/index.module.js",
27
+ "source": "src/index.ts",
28
+ "types": "dist/index.d.ts",
22
29
  "files": [
23
30
  "/dist"
24
31
  ],
25
32
  "scripts": {
26
- "build": "run .:build:clean && run .:build:esm && run .:build:cjs && run .:build:api",
27
- ".:build:clean": "rimraf dist",
28
- ".:build:esm": "tsc -p tsconfig.esm.json",
29
- ".:build:cjs": "tsc -p tsconfig.cjs.json",
30
- ".:build:api": "api-extractor run --local",
31
- "lint": "lint",
32
- "lint-and-fix": "lint-and-fix",
33
- "test": "jest --runInBand",
34
- "docs": "typedoc"
33
+ "build": "rm -rf dist && rollup -c",
34
+ "lint": "yarn run -T oxlint",
35
+ "lint:fix": "yarn run -T oxlint --fix",
36
+ "test": "jest",
37
+ "testunit": "jest",
38
+ "typecheck": "tsc --noEmit"
35
39
  },
36
40
  "dependencies": {
37
- "@rocket.chat/css-in-js": "^0.33.0"
41
+ "@rocket.chat/css-in-js": "~0.33.3"
38
42
  },
39
43
  "devDependencies": {
40
- "@microsoft/api-extractor": "~7.58.7",
41
- "@testing-library/dom": "~10.4.1",
42
- "@testing-library/react": "~16.3.2",
43
- "@types/react": "~19.2.17",
44
- "@types/react-dom": "~19.2.3",
45
- "eslint": "~9.39.4",
46
- "jest": "~30.4.2",
47
- "jest-environment-jsdom": "~30.4.1",
48
- "lint-all": "^0.31.25",
49
- "prettier": "~3.6.2",
50
- "react": "~19.2.7",
51
- "react-dom": "~19.2.7",
52
- "rimraf": "~6.1.3",
53
- "ts-jest": "~29.4.11",
54
- "typedoc": "~0.28.19",
44
+ "@rocket.chat/jest-presets": "~0.0.4",
45
+ "@rocket.chat/tsconfig": "~0.0.0",
46
+ "@rollup/plugin-commonjs": "~29.0.3",
47
+ "@rollup/plugin-json": "~6.1.0",
48
+ "@rollup/plugin-node-resolve": "~16.0.3",
49
+ "@rollup/plugin-terser": "~1.0.0",
50
+ "@rollup/plugin-typescript": "~12.3.0",
51
+ "@testing-library/dom": "~10.4.2",
52
+ "@testing-library/react": "~16.3.3",
53
+ "@types/react": "~19.2.18",
54
+ "@types/react-dom": "~19.2.7",
55
+ "jest": "~30.5.2",
56
+ "react": "~19.2.8",
57
+ "react-dom": "~19.2.8",
58
+ "rollup": "~4.62.5",
55
59
  "typescript": "~5.9.3"
56
60
  },
61
+ "peerDependencies": {
62
+ "react": "*"
63
+ },
64
+ "volta": {
65
+ "extends": "../../package.json"
66
+ },
57
67
  "publishConfig": {
58
68
  "access": "public"
59
69
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"OwnerDocument.d.ts","sourceRoot":"","sources":["../../src/OwnerDocument.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa;cACd,QAAQ;EACa,CAAC;AAElC,eAAO,MAAM,gBAAgB;cAHjB,QAAQ;CAKnB,CAAC"}
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useOwnerDocument = exports.OwnerDocument = void 0;
4
- const react_1 = require("react");
5
- exports.OwnerDocument = (0, react_1.createContext)({ document: window.document });
6
- const useOwnerDocument = () => {
7
- return (0, react_1.useContext)(exports.OwnerDocument);
8
- };
9
- exports.useOwnerDocument = useOwnerDocument;
10
- //# sourceMappingURL=OwnerDocument.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OwnerDocument.js","sourceRoot":"","sources":["../../src/OwnerDocument.ts"],"names":[],"mappings":";;;AAAA,iCAAkD;AAErC,QAAA,aAAa,GAAG,IAAA,qBAAa,EAEvC,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;AAE3B,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,OAAO,IAAA,kBAAU,EAAC,qBAAa,CAAC,CAAC;AACnC,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
package/dist/cjs/index.js DELETED
@@ -1,21 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.default = void 0;
18
- var styled_1 = require("./styled");
19
- Object.defineProperty(exports, "default", { enumerable: true, get: function () { return styled_1.default; } });
20
- __exportStar(require("./OwnerDocument"), exports);
21
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAAmC;AAA1B,iGAAA,OAAO,OAAA;AAChB,kDAAgC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../../src/styled.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAUpD,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,EAC9D,OAAO,CAAC,EACR,qBAAqB,MAAM,KAC1B,CAKD,CAAC;AAEH,QAAA,MAAM,MAAM,GACT,CAAC,SAAS,MAAM,GAAG,CAAC,iBAAiB,EAAE,CAAC,EACvC,MAAM,CAAC,EACP,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAGtE,QAAQ,oBAAoB,EAC5B,GAAG,QAAQ,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC,CAAC,EAAE,KACtD,iBAAiB,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,CAkDhD,CAAC;AAEJ,eAAe,MAAM,CAAC"}
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.attachClassName = void 0;
4
- const css_in_js_1 = require("@rocket.chat/css-in-js");
5
- const react_1 = require("react");
6
- const OwnerDocument_1 = require("./OwnerDocument");
7
- const attachClassName = (props, additionalClassName) => ({
8
- ...props,
9
- className: props.className
10
- ? `${props.className} ${additionalClassName}`
11
- : additionalClassName,
12
- });
13
- exports.attachClassName = attachClassName;
14
- const styled = (type, filter) => (slices, ...values) => {
15
- const cssFn = (0, css_in_js_1.css)(slices, ...values);
16
- const StyledComponent = typeof window === 'undefined'
17
- ? (props) => {
18
- const content = cssFn(props);
19
- const computedClassName = (0, css_in_js_1.createClassName)(content);
20
- const escapedClassName = (0, css_in_js_1.escapeName)(computedClassName);
21
- const transpiledContent = (0, css_in_js_1.transpile)(`.${escapedClassName}`, content);
22
- const newProps = (0, exports.attachClassName)(props, computedClassName);
23
- return (0, react_1.createElement)(react_1.Fragment, {}, (0, react_1.createElement)('style', {}, transpiledContent), (0, react_1.createElement)(type, filter ? filter(newProps) : newProps));
24
- }
25
- : (props) => {
26
- const content = cssFn(props);
27
- const computedClassName = (0, css_in_js_1.createClassName)(content);
28
- (0, react_1.useDebugValue)(computedClassName);
29
- const { document } = (0, OwnerDocument_1.useOwnerDocument)();
30
- (0, react_1.useInsertionEffect)(() => {
31
- const escapedClassName = (0, css_in_js_1.escapeName)(computedClassName);
32
- const transpiledContent = (0, css_in_js_1.transpile)(`.${escapedClassName}`, content);
33
- const detach = (0, css_in_js_1.attachRules)(transpiledContent, { document });
34
- return () => {
35
- setTimeout(detach, 1000);
36
- };
37
- }, [computedClassName, content, document]);
38
- const newProps = (0, exports.attachClassName)(props, computedClassName);
39
- return (0, react_1.createElement)(type, filter ? filter(newProps) : newProps);
40
- };
41
- StyledComponent.displayName = `StyledComponent(${type})`;
42
- return StyledComponent;
43
- };
44
- exports.default = styled;
45
- //# sourceMappingURL=styled.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"styled.js","sourceRoot":"","sources":["../../src/styled.ts"],"names":[],"mappings":";;;AAAA,sDAMgC;AAEhC,iCAKe;AAEf,mDAAmD;AAE5C,MAAM,eAAe,GAAG,CAC7B,KAAQ,EACR,mBAA2B,EACxB,EAAE,CAAC,CAAC;IACP,GAAG,KAAK;IACR,SAAS,EAAE,KAAK,CAAC,SAAS;QACxB,CAAC,CAAC,GAAG,KAAK,CAAC,SAAS,IAAI,mBAAmB,EAAE;QAC7C,CAAC,CAAC,mBAAmB;CACxB,CAAC,CAAC;AARU,QAAA,eAAe,mBAQzB;AAEH,MAAM,MAAM,GACV,CACE,IAAO,EACP,MAAsE,EACtE,EAAE,CACJ,CACE,MAA4B,EAC5B,GAAG,MAAoD,EACN,EAAE;IACnD,MAAM,KAAK,GAAG,IAAA,eAAG,EAAC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC;IAErC,MAAM,eAAe,GACnB,OAAO,MAAM,KAAK,WAAW;QAC3B,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE;YACR,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;YAC7B,MAAM,iBAAiB,GAAG,IAAA,2BAAe,EAAC,OAAO,CAAC,CAAC;YACnD,MAAM,gBAAgB,GAAG,IAAA,sBAAU,EAAC,iBAAiB,CAAC,CAAC;YACv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,OAAO,IAAA,qBAAa,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QACnE,CAAC,CAAC;IAER,eAAe,CAAC,WAAW,GAAG,mBAAmB,IAAI,GAAG,CAAC;IAEzD,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AAEJ,kBAAe,MAAM,CAAC"}
@@ -1,7 +0,0 @@
1
- export declare const OwnerDocument: import("react").Context<{
2
- document: Document;
3
- }>;
4
- export declare const useOwnerDocument: () => {
5
- document: Document;
6
- };
7
- //# sourceMappingURL=OwnerDocument.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OwnerDocument.d.ts","sourceRoot":"","sources":["../../src/OwnerDocument.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa;cACd,QAAQ;EACa,CAAC;AAElC,eAAO,MAAM,gBAAgB;cAHjB,QAAQ;CAKnB,CAAC"}
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useOwnerDocument = exports.OwnerDocument = void 0;
4
- const react_1 = require("react");
5
- exports.OwnerDocument = (0, react_1.createContext)({ document: window.document });
6
- const useOwnerDocument = () => {
7
- return (0, react_1.useContext)(exports.OwnerDocument);
8
- };
9
- exports.useOwnerDocument = useOwnerDocument;
10
- //# sourceMappingURL=OwnerDocument.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OwnerDocument.js","sourceRoot":"","sources":["../../src/OwnerDocument.ts"],"names":[],"mappings":";;;AAAA,iCAAkD;AAErC,QAAA,aAAa,GAAG,IAAA,qBAAa,EAEvC,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;AAE3B,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,OAAO,IAAA,kBAAU,EAAC,qBAAa,CAAC,CAAC;AACnC,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B"}
@@ -1,3 +0,0 @@
1
- export { default } from './styled';
2
- export * from './OwnerDocument';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
package/dist/esm/index.js DELETED
@@ -1,24 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.default = void 0;
21
- var styled_1 = require("./styled");
22
- Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(styled_1).default; } });
23
- __exportStar(require("./OwnerDocument"), exports);
24
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,mCAAmC;AAA1B,kHAAA,OAAO,OAAA;AAChB,kDAAgC"}
@@ -1,7 +0,0 @@
1
- import type { JSX, FunctionComponent } from 'react';
2
- export declare const attachClassName: <P extends {
3
- className?: string;
4
- }>(props: P, additionalClassName: string) => P;
5
- declare const styled: <K extends keyof JSX.IntrinsicElements, P>(type: K, filter?: (p: JSX.IntrinsicElements[K] & P) => JSX.IntrinsicElements[K]) => (slices: TemplateStringsArray, ...values: readonly (string | ((props: P) => string))[]) => FunctionComponent<JSX.IntrinsicElements[K] & P>;
6
- export default styled;
7
- //# sourceMappingURL=styled.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../../src/styled.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAUpD,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,EAC9D,OAAO,CAAC,EACR,qBAAqB,MAAM,KAC1B,CAKD,CAAC;AAEH,QAAA,MAAM,MAAM,GACT,CAAC,SAAS,MAAM,GAAG,CAAC,iBAAiB,EAAE,CAAC,EACvC,MAAM,CAAC,EACP,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAGtE,QAAQ,oBAAoB,EAC5B,GAAG,QAAQ,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC,CAAC,EAAE,KACtD,iBAAiB,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,CAkDhD,CAAC;AAEJ,eAAe,MAAM,CAAC"}
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.attachClassName = void 0;
4
- const css_in_js_1 = require("@rocket.chat/css-in-js");
5
- const react_1 = require("react");
6
- const OwnerDocument_1 = require("./OwnerDocument");
7
- const attachClassName = (props, additionalClassName) => ({
8
- ...props,
9
- className: props.className
10
- ? `${props.className} ${additionalClassName}`
11
- : additionalClassName,
12
- });
13
- exports.attachClassName = attachClassName;
14
- const styled = (type, filter) => (slices, ...values) => {
15
- const cssFn = (0, css_in_js_1.css)(slices, ...values);
16
- const StyledComponent = typeof window === 'undefined'
17
- ? (props) => {
18
- const content = cssFn(props);
19
- const computedClassName = (0, css_in_js_1.createClassName)(content);
20
- const escapedClassName = (0, css_in_js_1.escapeName)(computedClassName);
21
- const transpiledContent = (0, css_in_js_1.transpile)(`.${escapedClassName}`, content);
22
- const newProps = (0, exports.attachClassName)(props, computedClassName);
23
- return (0, react_1.createElement)(react_1.Fragment, {}, (0, react_1.createElement)('style', {}, transpiledContent), (0, react_1.createElement)(type, filter ? filter(newProps) : newProps));
24
- }
25
- : (props) => {
26
- const content = cssFn(props);
27
- const computedClassName = (0, css_in_js_1.createClassName)(content);
28
- (0, react_1.useDebugValue)(computedClassName);
29
- const { document } = (0, OwnerDocument_1.useOwnerDocument)();
30
- (0, react_1.useInsertionEffect)(() => {
31
- const escapedClassName = (0, css_in_js_1.escapeName)(computedClassName);
32
- const transpiledContent = (0, css_in_js_1.transpile)(`.${escapedClassName}`, content);
33
- const detach = (0, css_in_js_1.attachRules)(transpiledContent, { document });
34
- return () => {
35
- setTimeout(detach, 1000);
36
- };
37
- }, [computedClassName, content, document]);
38
- const newProps = (0, exports.attachClassName)(props, computedClassName);
39
- return (0, react_1.createElement)(type, filter ? filter(newProps) : newProps);
40
- };
41
- StyledComponent.displayName = `StyledComponent(${type})`;
42
- return StyledComponent;
43
- };
44
- exports.default = styled;
45
- //# sourceMappingURL=styled.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"styled.js","sourceRoot":"","sources":["../../src/styled.ts"],"names":[],"mappings":";;;AAAA,sDAMgC;AAEhC,iCAKe;AAEf,mDAAmD;AAE5C,MAAM,eAAe,GAAG,CAC7B,KAAQ,EACR,mBAA2B,EACxB,EAAE,CAAC,CAAC;IACP,GAAG,KAAK;IACR,SAAS,EAAE,KAAK,CAAC,SAAS;QACxB,CAAC,CAAC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,EAAE,GAAG,IAAA,gCAAgB,GAAE,CAAC;YACxC,IAAA,0BAAkB,EAAC,GAAG,EAAE;gBACtB,MAAM,gBAAgB,GAAG,IAAA,sBAAU,EAAC,iBAAiB,CAAC,CAAC;gBACvD,MAAM,iBAAiB,GAAG,IAAA,qBAAS,EACjC,IAAI,gBAAgB,EAAE,EACtB,OAAO,CACR,CAAC;gBACF,MAAM,MAAM,GAAG,IAAA,uBAAW,EAAC,iBAAiB,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;gBAE5D,OAAO,GAAG,EAAE;oBACV,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;gBAC3B,CAAC,CAAC;YACJ,CAAC,EAAE,CAAC,iBAAiB,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;YAE3C,MAAM,QAAQ,GAAG,IAAA,uBAAe,EAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;YAC3D,OAAO,IAAA,qBAAa,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QACnE,CAAC,CAAC;IAER,eAAe,CAAC,WAAW,GAAG,mBAAmB,IAAI,GAAG,CAAC;IAEzD,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AAEJ,kBAAe,MAAM,CAAC"}
@@ -1,11 +0,0 @@
1
- // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
- // It should be published with your NPM package. It should not be tracked by Git.
3
- {
4
- "tsdocVersion": "0.12",
5
- "toolPackages": [
6
- {
7
- "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.58.7"
9
- }
10
- ]
11
- }
File without changes
File without changes