@griffel/react 1.0.3 → 1.1.0
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 +135 -0
- package/RendererContext.cjs.js +1 -1
- package/RendererContext.cjs.js.map +1 -1
- package/RendererContext.d.ts +1 -1
- package/RendererContext.esm.js +1 -1
- package/RendererContext.esm.js.map +1 -1
- package/index.cjs.js +1 -0
- package/index.cjs.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.esm.js +1 -1
- package/makeStyles.cjs.js +12 -2
- package/makeStyles.cjs.js.map +1 -1
- package/makeStyles.esm.js +12 -2
- package/makeStyles.esm.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -70,6 +70,140 @@ function Component() {
|
|
|
70
70
|
}
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
+
## `shorthands`
|
|
74
|
+
|
|
75
|
+
`shorthands` provides a set of functions to mimic [CSS shorthands](https://developer.mozilla.org/en-US/docs/Web/CSS/Shorthand_properties) and improve developer experience as [CSS shorthands are not supported](https://griffel.js.org/react/guides/limitations#css-shorthands-are-not-supported) by Griffel.
|
|
76
|
+
|
|
77
|
+
### `shorthands.border`
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
import { makeStyles, shorthands } from '@griffel/react';
|
|
81
|
+
|
|
82
|
+
const useClasses = makeStyles({
|
|
83
|
+
root: {
|
|
84
|
+
...shorthands.border('2px'),
|
|
85
|
+
...shorthands.border('2px', 'solid'),
|
|
86
|
+
...shorthands.border('2px', 'solid', 'red'),
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### `shorthands.borderBottom`, `shorthands.borderTop`, `shorthands.borderLeft`, `shorthands.borderRight`
|
|
92
|
+
|
|
93
|
+
```js
|
|
94
|
+
import { makeStyles, shorthands } from '@griffel/react';
|
|
95
|
+
|
|
96
|
+
const useClasses = makeStyles({
|
|
97
|
+
root: {
|
|
98
|
+
// The same is true for "borderTop", "borderLeft" & "borderRight"
|
|
99
|
+
...shorthands.borderBottom('2px'),
|
|
100
|
+
...shorthands.borderBottom('2px', 'solid'),
|
|
101
|
+
...shorthands.borderBottom('2px', 'solid', 'red'),
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### `shorthands.borderColor`
|
|
107
|
+
|
|
108
|
+
```js
|
|
109
|
+
import { makeStyles, shorthands } from '@griffel/react';
|
|
110
|
+
|
|
111
|
+
const useClasses = makeStyles({
|
|
112
|
+
root: {
|
|
113
|
+
...shorthands.borderColor('red'),
|
|
114
|
+
...shorthands.borderColor('red', 'blue'),
|
|
115
|
+
...shorthands.borderColor('red', 'blue', 'green'),
|
|
116
|
+
...shorthands.borderColor('red', 'blue', 'green', 'yellow'),
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### `shorthands.borderStyle`
|
|
122
|
+
|
|
123
|
+
```js
|
|
124
|
+
import { makeStyles, shorthands } from '@griffel/react';
|
|
125
|
+
|
|
126
|
+
const useClasses = makeStyles({
|
|
127
|
+
root: {
|
|
128
|
+
...shorthands.borderStyle('solid'),
|
|
129
|
+
...shorthands.borderStyle('solid', 'dashed'),
|
|
130
|
+
...shorthands.borderStyle('solid', 'dashed', 'dotted'),
|
|
131
|
+
...shorthands.borderStyle('solid', 'dashed', 'dotted', 'double'),
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### `shorthands.borderWidth`
|
|
137
|
+
|
|
138
|
+
```js
|
|
139
|
+
import { makeStyles, shorthands } from '@griffel/react';
|
|
140
|
+
|
|
141
|
+
const useClasses = makeStyles({
|
|
142
|
+
root: {
|
|
143
|
+
...shorthands.borderWidth('12px'),
|
|
144
|
+
...shorthands.borderWidth('12px', '24px'),
|
|
145
|
+
...shorthands.borderWidth('12px', '24px', '36px'),
|
|
146
|
+
...shorthands.borderWidth('12px', '24px', '36px', '48px'),
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### `shorthands.gap`
|
|
152
|
+
|
|
153
|
+
```js
|
|
154
|
+
import { makeStyles, shorthands } from '@griffel/react';
|
|
155
|
+
|
|
156
|
+
const useClasses = makeStyles({
|
|
157
|
+
root: {
|
|
158
|
+
...shorthands.gap('12px'),
|
|
159
|
+
...shorthands.gap('12px', '24px'),
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### `shorthands.margin`
|
|
165
|
+
|
|
166
|
+
```js
|
|
167
|
+
import { makeStyles, shorthands } from '@griffel/react';
|
|
168
|
+
|
|
169
|
+
const useClasses = makeStyles({
|
|
170
|
+
root: {
|
|
171
|
+
...shorthands.margin('12px'),
|
|
172
|
+
...shorthands.margin('12px', '24px'),
|
|
173
|
+
...shorthands.margin('12px', '24px', '36px'),
|
|
174
|
+
...shorthands.margin('12px', '24px', '36px', '48px'),
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### `shorthands.overflow`
|
|
180
|
+
|
|
181
|
+
```js
|
|
182
|
+
import { makeStyles, shorthands } from '@griffel/react';
|
|
183
|
+
|
|
184
|
+
const useClasses = makeStyles({
|
|
185
|
+
root: {
|
|
186
|
+
...shorthands.overflow('visible'),
|
|
187
|
+
...shorthands.overflow('visible', 'hidden'),
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### `shorthands.padding`
|
|
193
|
+
|
|
194
|
+
```js
|
|
195
|
+
import { makeStyles, shorthands } from '@griffel/react';
|
|
196
|
+
|
|
197
|
+
const useClasses = makeStyles({
|
|
198
|
+
root: {
|
|
199
|
+
...shorthands.padding('12px'),
|
|
200
|
+
...shorthands.padding('12px', '24px'),
|
|
201
|
+
...shorthands.padding('12px', '24px', '36px'),
|
|
202
|
+
...shorthands.padding('12px', '24px', '36px', '48px'),
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
```
|
|
206
|
+
|
|
73
207
|
## `makeStaticStyles()`
|
|
74
208
|
|
|
75
209
|
Creates styles attached to a global selector. Styles can be defined via objects:
|
|
@@ -187,6 +321,7 @@ const useClasses = makeStyles({
|
|
|
187
321
|
|
|
188
322
|
'@media screen and (max-width: 992px)': { color: 'orange' },
|
|
189
323
|
'@supports (display: grid)': { color: 'red' },
|
|
324
|
+
'@layer utility': { marginBottom: '1em' }
|
|
190
325
|
},
|
|
191
326
|
});
|
|
192
327
|
```
|
package/RendererContext.cjs.js
CHANGED
|
@@ -65,7 +65,7 @@ const RendererProvider = ({
|
|
|
65
65
|
/**
|
|
66
66
|
* Returns an instance of current makeStyles() renderer.
|
|
67
67
|
*
|
|
68
|
-
* @private
|
|
68
|
+
* @private Exported as "useRenderer_unstable" use it on own risk. Can be changed or removed without a notice.
|
|
69
69
|
*/
|
|
70
70
|
|
|
71
71
|
function useRenderer() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RendererContext.cjs.js","sources":["../../../packages/react/src/RendererContext.tsx"],"sourcesContent":["import { createDOMRenderer, rehydrateRendererCache } from '@griffel/core';\nimport * as React from 'react';\nimport type { GriffelRenderer } from '@griffel/core';\n\nexport interface RendererProviderProps {\n /** An instance of Griffel renderer. */\n renderer: GriffelRenderer;\n\n /**\n * Document used to insert CSS variables to head\n */\n targetDocument?: Document;\n}\n\n/**\n * Verifies if an application can use DOM.\n */\nfunction canUseDOM(): boolean {\n return typeof window !== 'undefined' && !!(window.document && window.document.createElement);\n}\n\n/**\n * @private\n */\nconst RendererContext = React.createContext<GriffelRenderer>(createDOMRenderer());\n\n/**\n * @public\n */\nexport const RendererProvider: React.FC<RendererProviderProps> = ({ children, renderer, targetDocument }) => {\n if (canUseDOM()) {\n // This if statement technically breaks the rules of hooks, but is safe because the condition never changes after\n // mounting.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useMemo(() => {\n // \"rehydrateCache()\" can't be called in effects as it needs to be called before any component will be rendered to\n // avoid double insertion of classes\n rehydrateRendererCache(renderer, targetDocument);\n }, [renderer, targetDocument]);\n }\n\n return <RendererContext.Provider value={renderer}>{children}</RendererContext.Provider>;\n};\n\n/**\n * Returns an instance of current makeStyles() renderer.\n *\n * @private\n */\nexport function useRenderer(): GriffelRenderer {\n return React.useContext(RendererContext);\n}\n"],"names":["canUseDOM","window","document","createElement","RendererContext","React","createContext","createDOMRenderer","RendererProvider","children","renderer","targetDocument","useMemo","rehydrateRendererCache","Provider","value","useRenderer","useContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA;;;;AAGA,SAASA,SAAT;AACE,SAAO,OAAOC,MAAP,KAAkB,WAAlB,IAAiC,CAAC,EAAEA,MAAM,CAACC,QAAP,IAAmBD,MAAM,CAACC,QAAP,CAAgBC,aAArC,CAAzC;AACD;AAED;;;;;AAGA,MAAMC,eAAe,gBAAGC,gBAAK,CAACC,aAAN,eAAqCC,sBAAiB,EAAtD,CAAxB;AAEA;;;;MAGaC,gBAAgB,GAAoC,CAAC;AAAEC,EAAAA,QAAF;AAAYC,EAAAA,QAAZ;AAAsBC,EAAAA;AAAtB,CAAD;AAC/D,MAAIX,SAAS,EAAb,EAAiB;AACf;AACA;AACA;AACAK,IAAAA,gBAAK,CAACO,OAAN,CAAc;AACZ;AACA;AACAC,MAAAA,2BAAsB,CAACH,QAAD,EAAWC,cAAX,CAAtB;AACD,KAJD,EAIG,CAACD,QAAD,EAAWC,cAAX,CAJH;AAKD;;AAED,sBAAON,8BAAA,CAACD,eAAe,CAACU,QAAjB;AAA0BC,IAAAA,KAAK,EAAEL;GAAjC,EAA4CD,QAA5C,CAAP;AACD;AAED;;;;;;SAKgBO;AACd,SAAOX,gBAAK,CAACY,UAAN,CAAiBb,eAAjB,CAAP;AACD;;;;;"}
|
|
1
|
+
{"version":3,"file":"RendererContext.cjs.js","sources":["../../../packages/react/src/RendererContext.tsx"],"sourcesContent":["import { createDOMRenderer, rehydrateRendererCache } from '@griffel/core';\nimport * as React from 'react';\nimport type { GriffelRenderer } from '@griffel/core';\n\nexport interface RendererProviderProps {\n /** An instance of Griffel renderer. */\n renderer: GriffelRenderer;\n\n /**\n * Document used to insert CSS variables to head\n */\n targetDocument?: Document;\n}\n\n/**\n * Verifies if an application can use DOM.\n */\nfunction canUseDOM(): boolean {\n return typeof window !== 'undefined' && !!(window.document && window.document.createElement);\n}\n\n/**\n * @private\n */\nconst RendererContext = React.createContext<GriffelRenderer>(createDOMRenderer());\n\n/**\n * @public\n */\nexport const RendererProvider: React.FC<RendererProviderProps> = ({ children, renderer, targetDocument }) => {\n if (canUseDOM()) {\n // This if statement technically breaks the rules of hooks, but is safe because the condition never changes after\n // mounting.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useMemo(() => {\n // \"rehydrateCache()\" can't be called in effects as it needs to be called before any component will be rendered to\n // avoid double insertion of classes\n rehydrateRendererCache(renderer, targetDocument);\n }, [renderer, targetDocument]);\n }\n\n return <RendererContext.Provider value={renderer}>{children}</RendererContext.Provider>;\n};\n\n/**\n * Returns an instance of current makeStyles() renderer.\n *\n * @private Exported as \"useRenderer_unstable\" use it on own risk. Can be changed or removed without a notice.\n */\nexport function useRenderer(): GriffelRenderer {\n return React.useContext(RendererContext);\n}\n"],"names":["canUseDOM","window","document","createElement","RendererContext","React","createContext","createDOMRenderer","RendererProvider","children","renderer","targetDocument","useMemo","rehydrateRendererCache","Provider","value","useRenderer","useContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA;;;;AAGA,SAASA,SAAT;AACE,SAAO,OAAOC,MAAP,KAAkB,WAAlB,IAAiC,CAAC,EAAEA,MAAM,CAACC,QAAP,IAAmBD,MAAM,CAACC,QAAP,CAAgBC,aAArC,CAAzC;AACD;AAED;;;;;AAGA,MAAMC,eAAe,gBAAGC,gBAAK,CAACC,aAAN,eAAqCC,sBAAiB,EAAtD,CAAxB;AAEA;;;;MAGaC,gBAAgB,GAAoC,CAAC;AAAEC,EAAAA,QAAF;AAAYC,EAAAA,QAAZ;AAAsBC,EAAAA;AAAtB,CAAD;AAC/D,MAAIX,SAAS,EAAb,EAAiB;AACf;AACA;AACA;AACAK,IAAAA,gBAAK,CAACO,OAAN,CAAc;AACZ;AACA;AACAC,MAAAA,2BAAsB,CAACH,QAAD,EAAWC,cAAX,CAAtB;AACD,KAJD,EAIG,CAACD,QAAD,EAAWC,cAAX,CAJH;AAKD;;AAED,sBAAON,8BAAA,CAACD,eAAe,CAACU,QAAjB;AAA0BC,IAAAA,KAAK,EAAEL;GAAjC,EAA4CD,QAA5C,CAAP;AACD;AAED;;;;;;SAKgBO;AACd,SAAOX,gBAAK,CAACY,UAAN,CAAiBb,eAAjB,CAAP;AACD;;;;;"}
|
package/RendererContext.d.ts
CHANGED
|
@@ -15,6 +15,6 @@ export declare const RendererProvider: React.FC<RendererProviderProps>;
|
|
|
15
15
|
/**
|
|
16
16
|
* Returns an instance of current makeStyles() renderer.
|
|
17
17
|
*
|
|
18
|
-
* @private
|
|
18
|
+
* @private Exported as "useRenderer_unstable" use it on own risk. Can be changed or removed without a notice.
|
|
19
19
|
*/
|
|
20
20
|
export declare function useRenderer(): GriffelRenderer;
|
package/RendererContext.esm.js
CHANGED
|
@@ -41,7 +41,7 @@ const RendererProvider = ({
|
|
|
41
41
|
/**
|
|
42
42
|
* Returns an instance of current makeStyles() renderer.
|
|
43
43
|
*
|
|
44
|
-
* @private
|
|
44
|
+
* @private Exported as "useRenderer_unstable" use it on own risk. Can be changed or removed without a notice.
|
|
45
45
|
*/
|
|
46
46
|
|
|
47
47
|
function useRenderer() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RendererContext.esm.js","sources":["../../../packages/react/src/RendererContext.tsx"],"sourcesContent":["import { createDOMRenderer, rehydrateRendererCache } from '@griffel/core';\nimport * as React from 'react';\nimport type { GriffelRenderer } from '@griffel/core';\n\nexport interface RendererProviderProps {\n /** An instance of Griffel renderer. */\n renderer: GriffelRenderer;\n\n /**\n * Document used to insert CSS variables to head\n */\n targetDocument?: Document;\n}\n\n/**\n * Verifies if an application can use DOM.\n */\nfunction canUseDOM(): boolean {\n return typeof window !== 'undefined' && !!(window.document && window.document.createElement);\n}\n\n/**\n * @private\n */\nconst RendererContext = React.createContext<GriffelRenderer>(createDOMRenderer());\n\n/**\n * @public\n */\nexport const RendererProvider: React.FC<RendererProviderProps> = ({ children, renderer, targetDocument }) => {\n if (canUseDOM()) {\n // This if statement technically breaks the rules of hooks, but is safe because the condition never changes after\n // mounting.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useMemo(() => {\n // \"rehydrateCache()\" can't be called in effects as it needs to be called before any component will be rendered to\n // avoid double insertion of classes\n rehydrateRendererCache(renderer, targetDocument);\n }, [renderer, targetDocument]);\n }\n\n return <RendererContext.Provider value={renderer}>{children}</RendererContext.Provider>;\n};\n\n/**\n * Returns an instance of current makeStyles() renderer.\n *\n * @private\n */\nexport function useRenderer(): GriffelRenderer {\n return React.useContext(RendererContext);\n}\n"],"names":["canUseDOM","window","document","createElement","RendererContext","React","createContext","createDOMRenderer","RendererProvider","children","renderer","targetDocument","useMemo","rehydrateRendererCache","Provider","value","useRenderer","useContext"],"mappings":";;;AAcA;;;;AAGA,SAASA,SAAT;AACE,SAAO,OAAOC,MAAP,KAAkB,WAAlB,IAAiC,CAAC,EAAEA,MAAM,CAACC,QAAP,IAAmBD,MAAM,CAACC,QAAP,CAAgBC,aAArC,CAAzC;AACD;AAED;;;;;AAGA,MAAMC,eAAe,gBAAGC,KAAK,CAACC,aAAN,eAAqCC,iBAAiB,EAAtD,CAAxB;AAEA;;;;MAGaC,gBAAgB,GAAoC,CAAC;AAAEC,EAAAA,QAAF;AAAYC,EAAAA,QAAZ;AAAsBC,EAAAA;AAAtB,CAAD;AAC/D,MAAIX,SAAS,EAAb,EAAiB;AACf;AACA;AACA;AACAK,IAAAA,KAAK,CAACO,OAAN,CAAc;AACZ;AACA;AACAC,MAAAA,sBAAsB,CAACH,QAAD,EAAWC,cAAX,CAAtB;AACD,KAJD,EAIG,CAACD,QAAD,EAAWC,cAAX,CAJH;AAKD;;AAED,sBAAON,mBAAA,CAACD,eAAe,CAACU,QAAjB;AAA0BC,IAAAA,KAAK,EAAEL;GAAjC,EAA4CD,QAA5C,CAAP;AACD;AAED;;;;;;SAKgBO;AACd,SAAOX,KAAK,CAACY,UAAN,CAAiBb,eAAjB,CAAP;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"RendererContext.esm.js","sources":["../../../packages/react/src/RendererContext.tsx"],"sourcesContent":["import { createDOMRenderer, rehydrateRendererCache } from '@griffel/core';\nimport * as React from 'react';\nimport type { GriffelRenderer } from '@griffel/core';\n\nexport interface RendererProviderProps {\n /** An instance of Griffel renderer. */\n renderer: GriffelRenderer;\n\n /**\n * Document used to insert CSS variables to head\n */\n targetDocument?: Document;\n}\n\n/**\n * Verifies if an application can use DOM.\n */\nfunction canUseDOM(): boolean {\n return typeof window !== 'undefined' && !!(window.document && window.document.createElement);\n}\n\n/**\n * @private\n */\nconst RendererContext = React.createContext<GriffelRenderer>(createDOMRenderer());\n\n/**\n * @public\n */\nexport const RendererProvider: React.FC<RendererProviderProps> = ({ children, renderer, targetDocument }) => {\n if (canUseDOM()) {\n // This if statement technically breaks the rules of hooks, but is safe because the condition never changes after\n // mounting.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useMemo(() => {\n // \"rehydrateCache()\" can't be called in effects as it needs to be called before any component will be rendered to\n // avoid double insertion of classes\n rehydrateRendererCache(renderer, targetDocument);\n }, [renderer, targetDocument]);\n }\n\n return <RendererContext.Provider value={renderer}>{children}</RendererContext.Provider>;\n};\n\n/**\n * Returns an instance of current makeStyles() renderer.\n *\n * @private Exported as \"useRenderer_unstable\" use it on own risk. Can be changed or removed without a notice.\n */\nexport function useRenderer(): GriffelRenderer {\n return React.useContext(RendererContext);\n}\n"],"names":["canUseDOM","window","document","createElement","RendererContext","React","createContext","createDOMRenderer","RendererProvider","children","renderer","targetDocument","useMemo","rehydrateRendererCache","Provider","value","useRenderer","useContext"],"mappings":";;;AAcA;;;;AAGA,SAASA,SAAT;AACE,SAAO,OAAOC,MAAP,KAAkB,WAAlB,IAAiC,CAAC,EAAEA,MAAM,CAACC,QAAP,IAAmBD,MAAM,CAACC,QAAP,CAAgBC,aAArC,CAAzC;AACD;AAED;;;;;AAGA,MAAMC,eAAe,gBAAGC,KAAK,CAACC,aAAN,eAAqCC,iBAAiB,EAAtD,CAAxB;AAEA;;;;MAGaC,gBAAgB,GAAoC,CAAC;AAAEC,EAAAA,QAAF;AAAYC,EAAAA,QAAZ;AAAsBC,EAAAA;AAAtB,CAAD;AAC/D,MAAIX,SAAS,EAAb,EAAiB;AACf;AACA;AACA;AACAK,IAAAA,KAAK,CAACO,OAAN,CAAc;AACZ;AACA;AACAC,MAAAA,sBAAsB,CAACH,QAAD,EAAWC,cAAX,CAAtB;AACD,KAJD,EAIG,CAACD,QAAD,EAAWC,cAAX,CAJH;AAKD;;AAED,sBAAON,mBAAA,CAACD,eAAe,CAACU,QAAjB;AAA0BC,IAAAA,KAAK,EAAEL;GAAjC,EAA4CD,QAA5C,CAAP;AACD;AAED;;;;;;SAKgBO;AACd,SAAOX,KAAK,CAACY,UAAN,CAAiBb,eAAjB,CAAP;AACD;;;;"}
|
package/index.cjs.js
CHANGED
|
@@ -28,6 +28,7 @@ exports.makeStyles = makeStyles.makeStyles;
|
|
|
28
28
|
exports.makeStaticStyles = makeStaticStyles.makeStaticStyles;
|
|
29
29
|
exports.renderToStyleElements = renderToStyleElements.renderToStyleElements;
|
|
30
30
|
exports.RendererProvider = RendererContext.RendererProvider;
|
|
31
|
+
exports.useRenderer_unstable = RendererContext.useRenderer;
|
|
31
32
|
exports.TextDirectionProvider = TextDirectionContext.TextDirectionProvider;
|
|
32
33
|
exports.__styles = __styles.__styles;
|
|
33
34
|
//# sourceMappingURL=index.cjs.js.map
|
package/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ export type { GriffelStyle } from '@griffel/core';
|
|
|
3
3
|
export { makeStyles } from './makeStyles';
|
|
4
4
|
export { makeStaticStyles } from './makeStaticStyles';
|
|
5
5
|
export { renderToStyleElements } from './renderToStyleElements';
|
|
6
|
-
export { RendererProvider } from './RendererContext';
|
|
6
|
+
export { RendererProvider, useRenderer as useRenderer_unstable } from './RendererContext';
|
|
7
7
|
export { TextDirectionProvider } from './TextDirectionContext';
|
|
8
8
|
export { __styles } from './__styles';
|
package/index.esm.js
CHANGED
|
@@ -2,7 +2,7 @@ export { createDOMRenderer, mergeClasses, shorthands } from '@griffel/core';
|
|
|
2
2
|
export { makeStyles } from './makeStyles.esm.js';
|
|
3
3
|
export { makeStaticStyles } from './makeStaticStyles.esm.js';
|
|
4
4
|
export { renderToStyleElements } from './renderToStyleElements.esm.js';
|
|
5
|
-
export { RendererProvider } from './RendererContext.esm.js';
|
|
5
|
+
export { RendererProvider, useRenderer as useRenderer_unstable } from './RendererContext.esm.js';
|
|
6
6
|
export { TextDirectionProvider } from './TextDirectionContext.esm.js';
|
|
7
7
|
export { __styles } from './__styles.esm.js';
|
|
8
8
|
//# sourceMappingURL=index.esm.js.map
|
package/makeStyles.cjs.js
CHANGED
|
@@ -28,9 +28,19 @@ function _interopNamespace(e) {
|
|
|
28
28
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
29
29
|
|
|
30
30
|
function isInsideComponent() {
|
|
31
|
+
// React 18 always logs errors if a dispatcher is not present:
|
|
32
|
+
// https://github.com/facebook/react/blob/42f15b324f50d0fd98322c21646ac3013e30344a/packages/react/src/ReactHooks.js#L26-L36
|
|
31
33
|
try {
|
|
32
|
-
//
|
|
33
|
-
React__namespace.
|
|
34
|
+
// @ts-expect-error "SECRET_INTERNALS" are not typed
|
|
35
|
+
const dispatcher = React__namespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher.current; // Before any React component was rendered "dispatcher" will be "null"
|
|
36
|
+
|
|
37
|
+
if (dispatcher === null || dispatcher === undefined) {
|
|
38
|
+
return false;
|
|
39
|
+
} // A check with hooks call (i.e. call "React.useContext()" outside a component) will always produce errors, but
|
|
40
|
+
// a call on the dispatcher don't
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
dispatcher.useContext({});
|
|
34
44
|
return true;
|
|
35
45
|
} catch (e) {
|
|
36
46
|
return false;
|
package/makeStyles.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makeStyles.cjs.js","sources":["../../../packages/react/src/makeStyles.ts"],"sourcesContent":["import { makeStyles as vanillaMakeStyles } from '@griffel/core';\nimport * as React from 'react';\nimport type { GriffelStyle } from '@griffel/core';\n\nimport { useRenderer } from './RendererContext';\nimport { useTextDirection } from './TextDirectionContext';\n\nfunction isInsideComponent() {\n try {\n //
|
|
1
|
+
{"version":3,"file":"makeStyles.cjs.js","sources":["../../../packages/react/src/makeStyles.ts"],"sourcesContent":["import { makeStyles as vanillaMakeStyles } from '@griffel/core';\nimport * as React from 'react';\nimport type { GriffelStyle } from '@griffel/core';\n\nimport { useRenderer } from './RendererContext';\nimport { useTextDirection } from './TextDirectionContext';\n\nfunction isInsideComponent() {\n // React 18 always logs errors if a dispatcher is not present:\n // https://github.com/facebook/react/blob/42f15b324f50d0fd98322c21646ac3013e30344a/packages/react/src/ReactHooks.js#L26-L36\n try {\n // @ts-expect-error \"SECRET_INTERNALS\" are not typed\n const dispatcher = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher.current;\n\n // Before any React component was rendered \"dispatcher\" will be \"null\"\n if (dispatcher === null || dispatcher === undefined) {\n return false;\n }\n\n // A check with hooks call (i.e. call \"React.useContext()\" outside a component) will always produce errors, but\n // a call on the dispatcher don't\n dispatcher.useContext({});\n return true;\n } catch (e) {\n return false;\n }\n}\n\nexport function makeStyles<Slots extends string | number>(stylesBySlots: Record<Slots, GriffelStyle>) {\n const getStyles = vanillaMakeStyles(stylesBySlots);\n\n if (process.env.NODE_ENV !== 'production') {\n if (isInsideComponent()) {\n throw new Error(\n [\n \"makeStyles(): this function cannot be called in component's scope.\",\n 'All makeStyles() calls should be top level i.e. in a root scope of a file.',\n ].join(' '),\n );\n }\n }\n\n return function useClasses(): Record<Slots, string> {\n const dir = useTextDirection();\n const renderer = useRenderer();\n\n return getStyles({ dir, renderer });\n };\n}\n"],"names":["isInsideComponent","dispatcher","React","__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED","ReactCurrentDispatcher","current","undefined","useContext","e","makeStyles","stylesBySlots","getStyles","vanillaMakeStyles","process","env","NODE_ENV","Error","join","useClasses","dir","useTextDirection","renderer","useRenderer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,SAASA,iBAAT;AACE;AACA;AACA,MAAI;AACF;AACA,UAAMC,UAAU,GAAGC,gBAAK,CAACC,kDAAN,CAAyDC,sBAAzD,CAAgFC,OAAnG,CAFE;;AAKF,QAAIJ,UAAU,KAAK,IAAf,IAAuBA,UAAU,KAAKK,SAA1C,EAAqD;AACnD,aAAO,KAAP;AACD,KAPC;AAUF;;;AACAL,IAAAA,UAAU,CAACM,UAAX,CAAsB,EAAtB;AACA,WAAO,IAAP;AACD,GAbD,CAaE,OAAOC,CAAP,EAAU;AACV,WAAO,KAAP;AACD;AACF;;SAEeC,WAA0CC;AACxD,QAAMC,SAAS,GAAGC,eAAiB,CAACF,aAAD,CAAnC;;AAEA,MAAIG,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;AACzC,QAAIf,iBAAiB,EAArB,EAAyB;AACvB,YAAM,IAAIgB,KAAJ,CACJ,CACE,oEADF,EAEE,4EAFF,EAGEC,IAHF,CAGO,GAHP,CADI,CAAN;AAMD;AACF;;AAED,SAAO,SAASC,UAAT;AACL,UAAMC,GAAG,GAAGC,qCAAgB,EAA5B;AACA,UAAMC,QAAQ,GAAGC,2BAAW,EAA5B;AAEA,WAAOX,SAAS,CAAC;AAAEQ,MAAAA,GAAF;AAAOE,MAAAA;AAAP,KAAD,CAAhB;AACD,GALD;AAMD;;;;"}
|
package/makeStyles.esm.js
CHANGED
|
@@ -4,9 +4,19 @@ import { useRenderer } from './RendererContext.esm.js';
|
|
|
4
4
|
import { useTextDirection } from './TextDirectionContext.esm.js';
|
|
5
5
|
|
|
6
6
|
function isInsideComponent() {
|
|
7
|
+
// React 18 always logs errors if a dispatcher is not present:
|
|
8
|
+
// https://github.com/facebook/react/blob/42f15b324f50d0fd98322c21646ac3013e30344a/packages/react/src/ReactHooks.js#L26-L36
|
|
7
9
|
try {
|
|
8
|
-
//
|
|
9
|
-
React.
|
|
10
|
+
// @ts-expect-error "SECRET_INTERNALS" are not typed
|
|
11
|
+
const dispatcher = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher.current; // Before any React component was rendered "dispatcher" will be "null"
|
|
12
|
+
|
|
13
|
+
if (dispatcher === null || dispatcher === undefined) {
|
|
14
|
+
return false;
|
|
15
|
+
} // A check with hooks call (i.e. call "React.useContext()" outside a component) will always produce errors, but
|
|
16
|
+
// a call on the dispatcher don't
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
dispatcher.useContext({});
|
|
10
20
|
return true;
|
|
11
21
|
} catch (e) {
|
|
12
22
|
return false;
|
package/makeStyles.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makeStyles.esm.js","sources":["../../../packages/react/src/makeStyles.ts"],"sourcesContent":["import { makeStyles as vanillaMakeStyles } from '@griffel/core';\nimport * as React from 'react';\nimport type { GriffelStyle } from '@griffel/core';\n\nimport { useRenderer } from './RendererContext';\nimport { useTextDirection } from './TextDirectionContext';\n\nfunction isInsideComponent() {\n try {\n //
|
|
1
|
+
{"version":3,"file":"makeStyles.esm.js","sources":["../../../packages/react/src/makeStyles.ts"],"sourcesContent":["import { makeStyles as vanillaMakeStyles } from '@griffel/core';\nimport * as React from 'react';\nimport type { GriffelStyle } from '@griffel/core';\n\nimport { useRenderer } from './RendererContext';\nimport { useTextDirection } from './TextDirectionContext';\n\nfunction isInsideComponent() {\n // React 18 always logs errors if a dispatcher is not present:\n // https://github.com/facebook/react/blob/42f15b324f50d0fd98322c21646ac3013e30344a/packages/react/src/ReactHooks.js#L26-L36\n try {\n // @ts-expect-error \"SECRET_INTERNALS\" are not typed\n const dispatcher = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher.current;\n\n // Before any React component was rendered \"dispatcher\" will be \"null\"\n if (dispatcher === null || dispatcher === undefined) {\n return false;\n }\n\n // A check with hooks call (i.e. call \"React.useContext()\" outside a component) will always produce errors, but\n // a call on the dispatcher don't\n dispatcher.useContext({});\n return true;\n } catch (e) {\n return false;\n }\n}\n\nexport function makeStyles<Slots extends string | number>(stylesBySlots: Record<Slots, GriffelStyle>) {\n const getStyles = vanillaMakeStyles(stylesBySlots);\n\n if (process.env.NODE_ENV !== 'production') {\n if (isInsideComponent()) {\n throw new Error(\n [\n \"makeStyles(): this function cannot be called in component's scope.\",\n 'All makeStyles() calls should be top level i.e. in a root scope of a file.',\n ].join(' '),\n );\n }\n }\n\n return function useClasses(): Record<Slots, string> {\n const dir = useTextDirection();\n const renderer = useRenderer();\n\n return getStyles({ dir, renderer });\n };\n}\n"],"names":["isInsideComponent","dispatcher","React","__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED","ReactCurrentDispatcher","current","undefined","useContext","e","makeStyles","stylesBySlots","getStyles","vanillaMakeStyles","process","env","NODE_ENV","Error","join","useClasses","dir","useTextDirection","renderer","useRenderer"],"mappings":";;;;;AAOA,SAASA,iBAAT;AACE;AACA;AACA,MAAI;AACF;AACA,UAAMC,UAAU,GAAGC,KAAK,CAACC,kDAAN,CAAyDC,sBAAzD,CAAgFC,OAAnG,CAFE;;AAKF,QAAIJ,UAAU,KAAK,IAAf,IAAuBA,UAAU,KAAKK,SAA1C,EAAqD;AACnD,aAAO,KAAP;AACD,KAPC;AAUF;;;AACAL,IAAAA,UAAU,CAACM,UAAX,CAAsB,EAAtB;AACA,WAAO,IAAP;AACD,GAbD,CAaE,OAAOC,CAAP,EAAU;AACV,WAAO,KAAP;AACD;AACF;;SAEeC,WAA0CC;AACxD,QAAMC,SAAS,GAAGC,YAAiB,CAACF,aAAD,CAAnC;;AAEA,MAAIG,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;AACzC,QAAIf,iBAAiB,EAArB,EAAyB;AACvB,YAAM,IAAIgB,KAAJ,CACJ,CACE,oEADF,EAEE,4EAFF,EAGEC,IAHF,CAGO,GAHP,CADI,CAAN;AAMD;AACF;;AAED,SAAO,SAASC,UAAT;AACL,UAAMC,GAAG,GAAGC,gBAAgB,EAA5B;AACA,UAAMC,QAAQ,GAAGC,WAAW,EAA5B;AAEA,WAAOX,SAAS,CAAC;AAAEQ,MAAAA,GAAF;AAAOE,MAAAA;AAAP,KAAD,CAAhB;AACD,GALD;AAMD;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griffel/react",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "React implementation of Atomic CSS-in-JS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"sideEffects": false,
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@griffel/core": "^1.
|
|
12
|
+
"@griffel/core": "^1.3.1",
|
|
13
13
|
"tslib": "^2.1.0"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|