@griffel/react 1.7.3 → 1.7.4

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.
Files changed (112) hide show
  1. package/LICENSE.md +21 -0
  2. package/lib/RendererContext.cjs +46 -0
  3. package/lib/TextDirectionContext.cjs +33 -0
  4. package/lib/__css.cjs +22 -0
  5. package/lib/__resetCSS.cjs +22 -0
  6. package/lib/__resetStyles.cjs +26 -0
  7. package/lib/__staticCSS.cjs +18 -0
  8. package/lib/__staticStyles.cjs +23 -0
  9. package/lib/__styles.cjs +26 -0
  10. package/lib/index.cjs +78 -0
  11. package/lib/insertionFactory.cjs +33 -0
  12. package/lib/makeResetStyles.cjs +35 -0
  13. package/lib/makeStaticStyles.cjs +28 -0
  14. package/lib/makeStyles.cjs +35 -0
  15. package/lib/renderToStyleElements.cjs +50 -0
  16. package/lib/useInsertionEffect.cjs +20 -0
  17. package/lib/utils/canUseDOM.cjs +17 -0
  18. package/lib/utils/isInsideComponent.cjs +46 -0
  19. package/package.json +3 -3
  20. package/src/RendererContext.d.ts +24 -0
  21. package/src/RendererContext.js +32 -0
  22. package/src/RendererContext.js.map +1 -0
  23. package/src/TextDirectionContext.d.ts +19 -0
  24. package/src/TextDirectionContext.js +22 -0
  25. package/src/TextDirectionContext.js.map +1 -0
  26. package/src/__css.d.ts +7 -0
  27. package/src/__css.js +16 -0
  28. package/src/__css.js.map +1 -0
  29. package/src/__resetCSS.d.ts +6 -0
  30. package/src/{__resetCSS.ts → __resetCSS.js} +7 -10
  31. package/src/__resetCSS.js.map +1 -0
  32. package/src/__resetStyles.d.ts +7 -0
  33. package/src/__resetStyles.js +19 -0
  34. package/src/__resetStyles.js.map +1 -0
  35. package/src/__staticCSS.d.ts +6 -0
  36. package/src/{__staticCSS.ts → __staticCSS.js} +5 -7
  37. package/src/__staticCSS.js.map +1 -0
  38. package/src/__staticStyles.d.ts +7 -0
  39. package/src/{__staticStyles.ts → __staticStyles.js} +7 -12
  40. package/src/__staticStyles.js.map +1 -0
  41. package/src/__styles.d.ts +7 -0
  42. package/src/__styles.js +19 -0
  43. package/src/__styles.js.map +1 -0
  44. package/src/{index.ts → index.d.ts} +0 -6
  45. package/src/index.js +16 -0
  46. package/src/index.js.map +1 -0
  47. package/src/insertionFactory.d.ts +2 -0
  48. package/src/insertionFactory.js +21 -0
  49. package/src/insertionFactory.js.map +1 -0
  50. package/src/makeResetStyles.d.ts +2 -0
  51. package/src/makeResetStyles.js +23 -0
  52. package/src/makeResetStyles.js.map +1 -0
  53. package/src/makeStaticStyles.d.ts +2 -0
  54. package/src/makeStaticStyles.js +17 -0
  55. package/src/makeStaticStyles.js.map +1 -0
  56. package/src/makeStyles.d.ts +2 -0
  57. package/src/makeStyles.js +23 -0
  58. package/src/makeStyles.js.map +1 -0
  59. package/src/renderToStyleElements.d.ts +8 -0
  60. package/src/renderToStyleElements.js +51 -0
  61. package/src/renderToStyleElements.js.map +1 -0
  62. package/src/useInsertionEffect.d.ts +1 -0
  63. package/src/useInsertionEffect.js +10 -0
  64. package/src/useInsertionEffect.js.map +1 -0
  65. package/src/utils/canUseDOM.d.ts +1 -0
  66. package/src/utils/canUseDOM.js +9 -0
  67. package/src/utils/canUseDOM.js.map +1 -0
  68. package/src/utils/isInsideComponent.d.ts +1 -0
  69. package/src/utils/isInsideComponent.js +39 -0
  70. package/src/utils/isInsideComponent.js.map +1 -0
  71. package/.storybook/main.js +0 -20
  72. package/.storybook/preview.js +0 -1
  73. package/CHANGELOG.json +0 -1281
  74. package/CHANGELOG.md +0 -501
  75. package/bundle-size/__css.fixture.js +0 -7
  76. package/bundle-size/__styles.fixture.js +0 -7
  77. package/bundle-size/makeResetStyles.fixture.js +0 -7
  78. package/bundle-size/makeStaticStyles.fixture.js +0 -7
  79. package/bundle-size/makeStyles.fixture.js +0 -7
  80. package/eslint.config.mjs +0 -31
  81. package/project.json +0 -96
  82. package/src/RendererContext.tsx +0 -52
  83. package/src/TextDirectionContext.tsx +0 -34
  84. package/src/__css.ts +0 -21
  85. package/src/__resetStyles.ts +0 -28
  86. package/src/__styles.ts +0 -27
  87. package/src/createDOMRenderer.test.tsx +0 -133
  88. package/src/insertionFactory-node.test.ts +0 -31
  89. package/src/insertionFactory.test.ts +0 -29
  90. package/src/insertionFactory.ts +0 -27
  91. package/src/makeResetStyles.test.tsx +0 -27
  92. package/src/makeResetStyles.ts +0 -31
  93. package/src/makeStaticStyles.ts +0 -23
  94. package/src/makeStyles.test.tsx +0 -27
  95. package/src/makeStyles.ts +0 -31
  96. package/src/renderToStyleElements-node.test.tsx +0 -418
  97. package/src/renderToStyleElements.test.tsx +0 -103
  98. package/src/renderToStyleElements.ts +0 -61
  99. package/src/stories/ComponentStyles.stories.tsx +0 -55
  100. package/src/stories/DOMRendererFilter.stories.tsx +0 -76
  101. package/src/stories/FallbackValues.stories.tsx +0 -50
  102. package/src/stories/makeStyles.stories.tsx +0 -17
  103. package/src/useInsertionEffect.ts +0 -11
  104. package/src/utils/canUseDOM-node.test.ts +0 -14
  105. package/src/utils/canUseDOM.test.tsx +0 -8
  106. package/src/utils/canUseDOM.ts +0 -8
  107. package/src/utils/isInsideComponent.ts +0 -41
  108. package/tsconfig.json +0 -20
  109. package/tsconfig.lib.json +0 -28
  110. package/tsconfig.spec.json +0 -21
  111. package/tsconfig.storybook.json +0 -12
  112. package/vitest.config.ts +0 -21
@@ -1,34 +0,0 @@
1
- 'use client';
2
-
3
- import { createContext, useContext, type FC, type ReactNode } from 'react';
4
-
5
- export interface TextDirectionProviderProps {
6
- /** Indicates the directionality of the element's text. */
7
- dir: 'ltr' | 'rtl';
8
-
9
- /**
10
- * Content wrapped by the TextDirectionProvider.
11
- */
12
- children: ReactNode;
13
- }
14
-
15
- /**
16
- * @private
17
- */
18
- const TextDirectionContext = /*#__PURE__*/ createContext<'ltr' | 'rtl'>('ltr');
19
-
20
- /**
21
- * @public
22
- */
23
- export const TextDirectionProvider: FC<TextDirectionProviderProps> = ({ children, dir }) => {
24
- return <TextDirectionContext.Provider value={dir}>{children}</TextDirectionContext.Provider>;
25
- };
26
-
27
- /**
28
- * Returns current directionality of the element's text.
29
- *
30
- * @private
31
- */
32
- export function useTextDirection() {
33
- return useContext(TextDirectionContext);
34
- }
package/src/__css.ts DELETED
@@ -1,21 +0,0 @@
1
- 'use client';
2
-
3
- import { __css as vanillaCSS } from '@griffel/core';
4
- import type { CSSClassesMapBySlot } from '@griffel/core';
5
-
6
- import { useTextDirection } from './TextDirectionContext.js';
7
-
8
- /**
9
- * A version of makeStyles() that accepts build output as an input and skips all runtime transforms & DOM insertion.
10
- *
11
- * @private
12
- */
13
- export function __css<Slots extends string>(classesMapBySlot: CSSClassesMapBySlot<Slots>) {
14
- const getStyles = vanillaCSS(classesMapBySlot);
15
-
16
- return function useClasses(): Record<Slots, string> {
17
- const dir = useTextDirection();
18
-
19
- return getStyles({ dir });
20
- };
21
- }
@@ -1,28 +0,0 @@
1
- 'use client';
2
-
3
- import { __resetStyles as vanillaResetStyles } from '@griffel/core';
4
- import type { CSSRulesByBucket } from '@griffel/core';
5
-
6
- import { insertionFactory } from './insertionFactory.js';
7
- import { useRenderer } from './RendererContext.js';
8
- import { useTextDirection } from './TextDirectionContext.js';
9
-
10
- /**
11
- * A version of makeResetStyles() that accepts build output as an input and skips all runtime transforms.
12
- *
13
- * @private
14
- */
15
- export function __resetStyles(
16
- ltrClassName: string,
17
- rtlClassName: string | null,
18
- cssRules: CSSRulesByBucket | string[],
19
- ) {
20
- const getStyles = vanillaResetStyles(ltrClassName, rtlClassName, cssRules, insertionFactory);
21
-
22
- return function useClasses(): string {
23
- const dir = useTextDirection();
24
- const renderer = useRenderer();
25
-
26
- return getStyles({ dir, renderer });
27
- };
28
- }
package/src/__styles.ts DELETED
@@ -1,27 +0,0 @@
1
- 'use client';
2
-
3
- import { __styles as vanillaStyles } from '@griffel/core';
4
- import type { CSSClassesMapBySlot, CSSRulesByBucket } from '@griffel/core';
5
-
6
- import { insertionFactory } from './insertionFactory.js';
7
- import { useRenderer } from './RendererContext.js';
8
- import { useTextDirection } from './TextDirectionContext.js';
9
-
10
- /**
11
- * A version of makeStyles() that accepts build output as an input and skips all runtime transforms.
12
- *
13
- * @private
14
- */
15
- export function __styles<Slots extends string>(
16
- classesMapBySlot: CSSClassesMapBySlot<Slots>,
17
- cssRules: CSSRulesByBucket,
18
- ) {
19
- const getStyles = vanillaStyles(classesMapBySlot, cssRules, insertionFactory);
20
-
21
- return function useClasses(): Record<Slots, string> {
22
- const dir = useTextDirection();
23
- const renderer = useRenderer();
24
-
25
- return getStyles({ dir, renderer });
26
- };
27
- }
@@ -1,133 +0,0 @@
1
- import { describe, it, expect, vi } from 'vitest';
2
- import type { Mock } from 'vitest';
3
- import { createDOMRenderer, mergeClasses } from '@griffel/core';
4
- import * as React from 'react';
5
- import { hydrateRoot } from 'react-dom/client';
6
- import { renderToStaticMarkup } from 'react-dom/server';
7
-
8
- import { makeStyles } from './makeStyles.js';
9
- import { makeResetStyles } from './makeResetStyles.js';
10
- import { RendererProvider } from './RendererContext.js';
11
- import { renderToStyleElements } from './renderToStyleElements.js';
12
- import { useInsertionEffect as _useInsertionEffect } from './useInsertionEffect.js';
13
-
14
- vi.mock('./useInsertionEffect', () => ({
15
- useInsertionEffect: vi.fn(),
16
- }));
17
-
18
- const useInsertionEffect = _useInsertionEffect as Mock<typeof React.useInsertionEffect>;
19
-
20
- describe('createDOMRenderer', () => {
21
- it('rehydrateCache() avoids double insertion', () => {
22
- // This test validates a scenario for Server-Side rendering
23
-
24
- const clientRenderer = createDOMRenderer(document);
25
- const serverRenderer = createDOMRenderer(
26
- // we should use "null" as "undefined" will fall back to "document" which is present in this environment
27
- null as unknown as undefined,
28
- );
29
-
30
- const useExampleClasses = makeStyles({
31
- root: {
32
- animationName: {
33
- from: { height: '10px' },
34
- to: { height: '20px' },
35
- },
36
-
37
- color: 'red',
38
- '@media screen and (max-width: 992px)': { ':hover': { color: 'blue' } },
39
- },
40
- });
41
- const useExampleClass = makeResetStyles({
42
- color: 'red',
43
- ':hover': { color: 'blue' },
44
- });
45
- const ExampleComponent: React.FC = () => {
46
- const classes = useExampleClasses();
47
- const className = useExampleClass();
48
-
49
- return <div className={mergeClasses(className, classes.root)} />;
50
- };
51
-
52
- //
53
- // Server
54
- // A "server" renders components to static HTML that will be transferred to a client
55
- //
56
-
57
- // Heads up!
58
- // Mock there is need as this test is executed in DOM environment and uses "useInsertionEffect".
59
- // However, "useInsertionEffect" will not be called in "renderToStaticMarkup()".
60
- useInsertionEffect.mockImplementation(fn => fn());
61
-
62
- const componentHTML = renderToStaticMarkup(
63
- <RendererProvider renderer={serverRenderer}>
64
- <ExampleComponent />
65
- </RendererProvider>,
66
- );
67
- const stylesHTML = renderToStaticMarkup(<>{renderToStyleElements(serverRenderer)}</>);
68
-
69
- useInsertionEffect.mockImplementation(React.useInsertionEffect);
70
-
71
- // Ensure that all styles are inserted into the cache
72
- expect(serverRenderer.insertionCache).toMatchInlineSnapshot(`
73
- {
74
- ".f1p9cr64{animation-name:f1kgwxhb;}": "d",
75
- ".fe3e8s9{color:red;}": "d",
76
- ".rp2atum:hover{color:blue;}": "r",
77
- ".rp2atum{color:red;}": "r",
78
- "@keyframes f1kgwxhb{from{height:10px;}to{height:20px;}}": "k",
79
- "@media screen and (max-width: 992px){.fzd6x39:hover{color:blue;}}": "m",
80
- }
81
- `);
82
- // There is no DOM on a server, style nodes should not be present
83
- expect(document.querySelector('style')).toBe(null);
84
-
85
- //
86
- // Client
87
- // Creates an element to render components and inserts HTML rendered from a server
88
- //
89
-
90
- const container = document.createElement('div');
91
-
92
- document.body.appendChild(container);
93
-
94
- container.innerHTML = componentHTML;
95
- document.head.innerHTML = stylesHTML;
96
-
97
- // As all style came from a server, we should not insert any CSS on a client
98
- // (this tests internal implementation, but there is no other way?)
99
- const styleElementsBeforeHydration = document.querySelectorAll<HTMLStyleElement>('style');
100
- const insertRules = [...(styleElementsBeforeHydration as unknown as HTMLStyleElement[])].map(styleEl =>
101
- vi.spyOn(styleEl.sheet!, 'insertRule'),
102
- );
103
-
104
- React.act(() => {
105
- hydrateRoot(
106
- container,
107
- // "RendererProvider" is not required there, we need it only for Jest spies
108
- <RendererProvider renderer={clientRenderer}>
109
- <ExampleComponent />
110
- </RendererProvider>,
111
- );
112
- });
113
-
114
- const styleElementsAfterHydration = document.querySelectorAll<HTMLStyleElement>('style');
115
-
116
- // We also would to ensure that new elements have not been inserted
117
- expect(styleElementsBeforeHydration.length).toBe(styleElementsAfterHydration.length);
118
-
119
- // Following rules are present in cache:
120
- // - makeResetStyles
121
- // - color
122
- // - :hover + color
123
- // - makeStyles
124
- // - "animationName"
125
- // - "color"
126
- // - @keyframes
127
- // - @media
128
- expect(Object.keys(clientRenderer.insertionCache)).toHaveLength(6);
129
- insertRules.forEach(insertRule => {
130
- expect(insertRule).not.toHaveBeenCalled();
131
- });
132
- });
133
- });
@@ -1,31 +0,0 @@
1
- /*
2
- * @vitest-environment node
3
- */
4
-
5
- // 👆 this is intentionally to test in SSR like environment
6
-
7
- import { describe, it, expect, vi } from 'vitest';
8
- import type { GriffelRenderer } from '@griffel/core';
9
-
10
- const { useInsertionEffect } = vi.hoisted(() => ({
11
- useInsertionEffect: vi.fn(),
12
- }));
13
-
14
- vi.mock('react', async importOriginal => {
15
- const actual = await importOriginal<typeof import('react')>();
16
- return { ...actual, useInsertionEffect };
17
- });
18
-
19
- import { insertionFactory } from './insertionFactory.js';
20
-
21
- describe('insertionFactory (node)', () => {
22
- it('does not use insertionEffect', () => {
23
- const renderer: Partial<GriffelRenderer> = { id: 'a', insertCSSRules: vi.fn() };
24
- const insertStyles = insertionFactory();
25
-
26
- insertStyles(renderer as GriffelRenderer, { d: ['a'] });
27
-
28
- expect(useInsertionEffect).not.toHaveBeenCalled();
29
- expect(renderer.insertCSSRules).toHaveBeenCalledTimes(1);
30
- });
31
- });
@@ -1,29 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import type { Mock } from 'vitest';
3
- import type { GriffelRenderer } from '@griffel/core';
4
-
5
- import { insertionFactory } from './insertionFactory.js';
6
- import { useInsertionEffect as _useInsertionEffect } from './useInsertionEffect.js';
7
- import type * as React from 'react';
8
-
9
- vi.mock('./useInsertionEffect', () => ({
10
- useInsertionEffect: vi.fn().mockImplementation(fn => fn()),
11
- }));
12
-
13
- const useInsertionEffect = _useInsertionEffect as Mock<typeof React.useInsertionEffect>;
14
-
15
- describe('canUseDOM', () => {
16
- beforeEach(() => {
17
- vi.clearAllMocks();
18
- });
19
-
20
- it('uses "useInsertionEffect" when available', () => {
21
- const renderer: Partial<GriffelRenderer> = { insertCSSRules: vi.fn() };
22
- const insertStyles = insertionFactory();
23
-
24
- insertStyles(renderer as GriffelRenderer, { d: ['a'] });
25
-
26
- expect(useInsertionEffect).toHaveBeenCalledTimes(1);
27
- expect(renderer.insertCSSRules).toHaveBeenCalledTimes(1);
28
- });
29
- });
@@ -1,27 +0,0 @@
1
- 'use client';
2
-
3
- import type { CSSRulesByBucket, GriffelInsertionFactory, GriffelRenderer } from '@griffel/core';
4
-
5
- import { canUseDOM } from './utils/canUseDOM.js';
6
- import { useInsertionEffect } from './useInsertionEffect.js';
7
-
8
- export const insertionFactory: GriffelInsertionFactory = () => {
9
- const insertionCache: Record<string, boolean> = {};
10
-
11
- return function insert(renderer: GriffelRenderer, cssRules: CSSRulesByBucket) {
12
- // Even if `useInsertionEffect` is available, we can use it on a client only as it will not be executed in SSR
13
- if (useInsertionEffect && canUseDOM()) {
14
- // eslint-disable-next-line react-x/rules-of-hooks
15
- useInsertionEffect(() => {
16
- renderer.insertCSSRules(cssRules!);
17
- }, [renderer, cssRules]);
18
-
19
- return;
20
- }
21
-
22
- if (insertionCache[renderer.id] === undefined) {
23
- renderer.insertCSSRules(cssRules!);
24
- insertionCache[renderer.id] = true;
25
- }
26
- };
27
- };
@@ -1,27 +0,0 @@
1
- import { describe, it, expect, vi } from 'vitest';
2
- import type * as React from 'react';
3
- import { createRoot } from 'react-dom/client';
4
- import { act } from 'react-dom/test-utils';
5
-
6
- import { makeResetStyles } from './makeResetStyles.js';
7
-
8
- describe('makeResetStyles', () => {
9
- it('works outside of React components', () => {
10
- expect(() => makeResetStyles({ root: { color: 'red' } })).not.toThrow();
11
- });
12
-
13
- it('throws inside React components', () => {
14
- vi.spyOn(console, 'error').mockImplementation(() => {});
15
-
16
- const Example: React.FC = () => {
17
- makeResetStyles({ color: 'red' });
18
- return null;
19
- };
20
- const root = createRoot(document.createElement('div'));
21
-
22
- expect(() => act(() => root.render(<Example />))).toThrow(/All makeResetStyles\(\) calls should be top level/);
23
-
24
- // Should not throw outside React components after rendering
25
- expect(() => makeResetStyles({ color: 'red' })).not.toThrow();
26
- });
27
- });
@@ -1,31 +0,0 @@
1
- 'use client';
2
-
3
- import { makeResetStyles as vanillaMakeResetStyles } from '@griffel/core';
4
- import type { GriffelResetStyle } from '@griffel/core';
5
-
6
- import { insertionFactory } from './insertionFactory.js';
7
- import { useRenderer } from './RendererContext.js';
8
- import { useTextDirection } from './TextDirectionContext.js';
9
- import { isInsideComponent } from './utils/isInsideComponent.js';
10
-
11
- export function makeResetStyles(styles: GriffelResetStyle) {
12
- const getStyles = vanillaMakeResetStyles(styles, insertionFactory);
13
-
14
- if (process.env.NODE_ENV !== 'production') {
15
- if (isInsideComponent()) {
16
- throw new Error(
17
- [
18
- "makeResetStyles(): this function cannot be called in component's scope.",
19
- 'All makeResetStyles() calls should be top level i.e. in a root scope of a file.',
20
- ].join(' '),
21
- );
22
- }
23
- }
24
-
25
- return function useClassName(): string {
26
- const dir = useTextDirection();
27
- const renderer = useRenderer();
28
-
29
- return getStyles({ dir, renderer });
30
- };
31
- }
@@ -1,23 +0,0 @@
1
- 'use client';
2
-
3
- import { makeStaticStyles as vanillaMakeStaticStyles } from '@griffel/core';
4
- import type { GriffelStaticStyles, MakeStaticStylesOptions } from '@griffel/core';
5
-
6
- import { insertionFactory } from './insertionFactory.js';
7
- import { useRenderer } from './RendererContext.js';
8
-
9
- export function makeStaticStyles(styles: GriffelStaticStyles | GriffelStaticStyles[]) {
10
- const getStyles = vanillaMakeStaticStyles(styles, insertionFactory);
11
-
12
- if (process.env.NODE_ENV === 'test') {
13
- // eslint-disable-next-line @typescript-eslint/no-empty-function
14
- return () => {};
15
- }
16
-
17
- return function useStaticStyles(): void {
18
- const renderer = useRenderer();
19
- const options: MakeStaticStylesOptions = { renderer };
20
-
21
- return getStyles(options);
22
- };
23
- }
@@ -1,27 +0,0 @@
1
- import { describe, it, expect, vi } from 'vitest';
2
- import type * as React from 'react';
3
- import { createRoot } from 'react-dom/client';
4
- import { act } from 'react-dom/test-utils';
5
-
6
- import { makeStyles } from './makeStyles.js';
7
-
8
- describe('makeStyles', () => {
9
- it('works outside of React components', () => {
10
- expect(() => makeStyles({ root: { color: 'red' } })).not.toThrow();
11
- });
12
-
13
- it('throws inside React components', () => {
14
- vi.spyOn(console, 'error').mockImplementation(() => {});
15
-
16
- const Example: React.FC = () => {
17
- makeStyles({ root: { color: 'red' } });
18
- return null;
19
- };
20
- const root = createRoot(document.createElement('div'));
21
-
22
- expect(() => act(() => root.render(<Example />))).toThrow(/All makeStyles\(\) calls should be top level/);
23
-
24
- // Should not throw outside React components after rendering
25
- expect(() => makeStyles({ root: { color: 'red' } })).not.toThrow();
26
- });
27
- });
package/src/makeStyles.ts DELETED
@@ -1,31 +0,0 @@
1
- 'use client';
2
-
3
- import { makeStyles as vanillaMakeStyles } from '@griffel/core';
4
- import type { GriffelStyle } from '@griffel/core';
5
-
6
- import { insertionFactory } from './insertionFactory.js';
7
- import { useRenderer } from './RendererContext.js';
8
- import { useTextDirection } from './TextDirectionContext.js';
9
- import { isInsideComponent } from './utils/isInsideComponent.js';
10
-
11
- export function makeStyles<Slots extends string | number>(stylesBySlots: Record<Slots, GriffelStyle>) {
12
- const getStyles = vanillaMakeStyles(stylesBySlots, insertionFactory);
13
-
14
- if (process.env.NODE_ENV !== 'production') {
15
- if (isInsideComponent()) {
16
- throw new Error(
17
- [
18
- "makeStyles(): this function cannot be called in component's scope.",
19
- 'All makeStyles() calls should be top level i.e. in a root scope of a file.',
20
- ].join(' '),
21
- );
22
- }
23
- }
24
-
25
- return function useClasses(): Record<Slots, string> {
26
- const dir = useTextDirection();
27
- const renderer = useRenderer();
28
-
29
- return getStyles({ dir, renderer });
30
- };
31
- }