@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.
- package/LICENSE.md +21 -0
- package/lib/RendererContext.cjs +46 -0
- package/lib/TextDirectionContext.cjs +33 -0
- package/lib/__css.cjs +22 -0
- package/lib/__resetCSS.cjs +22 -0
- package/lib/__resetStyles.cjs +26 -0
- package/lib/__staticCSS.cjs +18 -0
- package/lib/__staticStyles.cjs +23 -0
- package/lib/__styles.cjs +26 -0
- package/lib/index.cjs +78 -0
- package/lib/insertionFactory.cjs +33 -0
- package/lib/makeResetStyles.cjs +35 -0
- package/lib/makeStaticStyles.cjs +28 -0
- package/lib/makeStyles.cjs +35 -0
- package/lib/renderToStyleElements.cjs +50 -0
- package/lib/useInsertionEffect.cjs +20 -0
- package/lib/utils/canUseDOM.cjs +17 -0
- package/lib/utils/isInsideComponent.cjs +46 -0
- package/package.json +3 -3
- package/src/RendererContext.d.ts +24 -0
- package/src/RendererContext.js +32 -0
- package/src/RendererContext.js.map +1 -0
- package/src/TextDirectionContext.d.ts +19 -0
- package/src/TextDirectionContext.js +22 -0
- package/src/TextDirectionContext.js.map +1 -0
- package/src/__css.d.ts +7 -0
- package/src/__css.js +16 -0
- package/src/__css.js.map +1 -0
- package/src/__resetCSS.d.ts +6 -0
- package/src/{__resetCSS.ts → __resetCSS.js} +7 -10
- package/src/__resetCSS.js.map +1 -0
- package/src/__resetStyles.d.ts +7 -0
- package/src/__resetStyles.js +19 -0
- package/src/__resetStyles.js.map +1 -0
- package/src/__staticCSS.d.ts +6 -0
- package/src/{__staticCSS.ts → __staticCSS.js} +5 -7
- package/src/__staticCSS.js.map +1 -0
- package/src/__staticStyles.d.ts +7 -0
- package/src/{__staticStyles.ts → __staticStyles.js} +7 -12
- package/src/__staticStyles.js.map +1 -0
- package/src/__styles.d.ts +7 -0
- package/src/__styles.js +19 -0
- package/src/__styles.js.map +1 -0
- package/src/{index.ts → index.d.ts} +0 -6
- package/src/index.js +16 -0
- package/src/index.js.map +1 -0
- package/src/insertionFactory.d.ts +2 -0
- package/src/insertionFactory.js +21 -0
- package/src/insertionFactory.js.map +1 -0
- package/src/makeResetStyles.d.ts +2 -0
- package/src/makeResetStyles.js +23 -0
- package/src/makeResetStyles.js.map +1 -0
- package/src/makeStaticStyles.d.ts +2 -0
- package/src/makeStaticStyles.js +17 -0
- package/src/makeStaticStyles.js.map +1 -0
- package/src/makeStyles.d.ts +2 -0
- package/src/makeStyles.js +23 -0
- package/src/makeStyles.js.map +1 -0
- package/src/renderToStyleElements.d.ts +8 -0
- package/src/renderToStyleElements.js +51 -0
- package/src/renderToStyleElements.js.map +1 -0
- package/src/useInsertionEffect.d.ts +1 -0
- package/src/useInsertionEffect.js +10 -0
- package/src/useInsertionEffect.js.map +1 -0
- package/src/utils/canUseDOM.d.ts +1 -0
- package/src/utils/canUseDOM.js +9 -0
- package/src/utils/canUseDOM.js.map +1 -0
- package/src/utils/isInsideComponent.d.ts +1 -0
- package/src/utils/isInsideComponent.js +39 -0
- package/src/utils/isInsideComponent.js.map +1 -0
- package/.storybook/main.js +0 -20
- package/.storybook/preview.js +0 -1
- package/CHANGELOG.json +0 -1281
- package/CHANGELOG.md +0 -501
- package/bundle-size/__css.fixture.js +0 -7
- package/bundle-size/__styles.fixture.js +0 -7
- package/bundle-size/makeResetStyles.fixture.js +0 -7
- package/bundle-size/makeStaticStyles.fixture.js +0 -7
- package/bundle-size/makeStyles.fixture.js +0 -7
- package/eslint.config.mjs +0 -31
- package/project.json +0 -96
- package/src/RendererContext.tsx +0 -52
- package/src/TextDirectionContext.tsx +0 -34
- package/src/__css.ts +0 -21
- package/src/__resetStyles.ts +0 -28
- package/src/__styles.ts +0 -27
- package/src/createDOMRenderer.test.tsx +0 -133
- package/src/insertionFactory-node.test.ts +0 -31
- package/src/insertionFactory.test.ts +0 -29
- package/src/insertionFactory.ts +0 -27
- package/src/makeResetStyles.test.tsx +0 -27
- package/src/makeResetStyles.ts +0 -31
- package/src/makeStaticStyles.ts +0 -23
- package/src/makeStyles.test.tsx +0 -27
- package/src/makeStyles.ts +0 -31
- package/src/renderToStyleElements-node.test.tsx +0 -418
- package/src/renderToStyleElements.test.tsx +0 -103
- package/src/renderToStyleElements.ts +0 -61
- package/src/stories/ComponentStyles.stories.tsx +0 -55
- package/src/stories/DOMRendererFilter.stories.tsx +0 -76
- package/src/stories/FallbackValues.stories.tsx +0 -50
- package/src/stories/makeStyles.stories.tsx +0 -17
- package/src/useInsertionEffect.ts +0 -11
- package/src/utils/canUseDOM-node.test.ts +0 -14
- package/src/utils/canUseDOM.test.tsx +0 -8
- package/src/utils/canUseDOM.ts +0 -8
- package/src/utils/isInsideComponent.ts +0 -41
- package/tsconfig.json +0 -20
- package/tsconfig.lib.json +0 -28
- package/tsconfig.spec.json +0 -21
- package/tsconfig.storybook.json +0 -12
- package/vitest.config.ts +0 -21
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { StoryFn } from '@storybook/react-vite';
|
|
2
|
-
|
|
3
|
-
import { makeStyles, shorthands, TextDirectionProvider } from '../';
|
|
4
|
-
|
|
5
|
-
const useStyles = makeStyles({
|
|
6
|
-
shouldFallbackToRed: {
|
|
7
|
-
color: ['red', 'invalid'],
|
|
8
|
-
...shorthands.border(['1px'], 'solid', ['red', 'invalid']),
|
|
9
|
-
...shorthands.borderRight('40px', 'solid', ['green', 'invalid']),
|
|
10
|
-
borderTopStyle: ['hidden', 'dashed'],
|
|
11
|
-
},
|
|
12
|
-
shouldBeBlue: {
|
|
13
|
-
color: ['red', 'blue'],
|
|
14
|
-
...shorthands.border('1px', 'solid', ['red', 'blue']),
|
|
15
|
-
...shorthands.borderRight('40px', 'solid', ['green', 'grey']),
|
|
16
|
-
borderRightWidth: '100px',
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
const FallbackTest = ({ isRtl = false }: { isRtl?: boolean }) => {
|
|
21
|
-
const classes = useStyles();
|
|
22
|
-
return (
|
|
23
|
-
<>
|
|
24
|
-
<p className={classes.shouldBeBlue}>
|
|
25
|
-
Colour and border should be blue, {isRtl ? 'left' : 'right'} wide border grey.
|
|
26
|
-
</p>
|
|
27
|
-
<p className={classes.shouldFallbackToRed}>
|
|
28
|
-
Colour and border should fallback to red, {isRtl ? 'left' : 'right'} wide border to green.
|
|
29
|
-
</p>
|
|
30
|
-
</>
|
|
31
|
-
);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const FallbackValues: StoryFn = () => {
|
|
35
|
-
return (
|
|
36
|
-
<div>
|
|
37
|
-
<FallbackTest />
|
|
38
|
-
<TextDirectionProvider dir="rtl">
|
|
39
|
-
<div dir="rtl">
|
|
40
|
-
<h2>RTL</h2>
|
|
41
|
-
<FallbackTest isRtl />
|
|
42
|
-
</div>
|
|
43
|
-
</TextDirectionProvider>
|
|
44
|
-
</div>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export default {
|
|
49
|
-
title: 'Fallback values',
|
|
50
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { makeStyles } from '../../src/index.js';
|
|
2
|
-
|
|
3
|
-
const useStyles = makeStyles({
|
|
4
|
-
root: {
|
|
5
|
-
color: 'deeppink',
|
|
6
|
-
},
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
export const MakeStyles = () => {
|
|
10
|
-
const classes = useStyles();
|
|
11
|
-
|
|
12
|
-
return <div className={classes.root}>no stories yet</div>;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export default {
|
|
16
|
-
title: 'MakeStyles',
|
|
17
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import React from 'react';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export const useInsertionEffect: typeof React.useInsertionEffect | undefined =
|
|
9
|
-
// @ts-expect-error Hack to make sure that `useInsertionEffect` will not cause bundling issues in older React versions
|
|
10
|
-
// eslint-disable-next-line no-useless-concat
|
|
11
|
-
React['useInsertion' + 'Effect'] ? React['useInsertion' + 'Effect'] : undefined;
|
|
@@ -1,14 +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 } from 'vitest';
|
|
8
|
-
import { canUseDOM } from './canUseDOM.js';
|
|
9
|
-
|
|
10
|
-
describe('canUseDOM (node)', () => {
|
|
11
|
-
it('returns "false"', () => {
|
|
12
|
-
expect(canUseDOM()).toBe(false);
|
|
13
|
-
});
|
|
14
|
-
});
|
package/src/utils/canUseDOM.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import React from 'react';
|
|
4
|
-
|
|
5
|
-
function getDispatcher() {
|
|
6
|
-
try {
|
|
7
|
-
return (React as any)[''.concat('__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE')].H;
|
|
8
|
-
} catch {
|
|
9
|
-
// React 19+
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
try {
|
|
13
|
-
return (React as any)[''.concat('__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED')].ReactCurrentDispatcher
|
|
14
|
-
.current;
|
|
15
|
-
} catch {
|
|
16
|
-
// React 18 and below
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
export function isInsideComponent() {
|
|
24
|
-
// React 18 always logs errors if a dispatcher is not present:
|
|
25
|
-
// https://github.com/facebook/react/blob/42f15b324f50d0fd98322c21646ac3013e30344a/packages/react/src/ReactHooks.js#L26-L36
|
|
26
|
-
try {
|
|
27
|
-
const dispatcher = getDispatcher();
|
|
28
|
-
|
|
29
|
-
// Before any React component was rendered "dispatcher" will be "null"
|
|
30
|
-
if (dispatcher === null || dispatcher === undefined) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// A check with hooks call (i.e. call "React.useContext()" outside a component) will always produce errors, but
|
|
35
|
-
// a call on the dispatcher wont
|
|
36
|
-
dispatcher.useContext({});
|
|
37
|
-
return true;
|
|
38
|
-
} catch {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"jsx": "react-jsx",
|
|
5
|
-
"allowJs": true
|
|
6
|
-
},
|
|
7
|
-
"files": [],
|
|
8
|
-
"include": [],
|
|
9
|
-
"references": [
|
|
10
|
-
{
|
|
11
|
-
"path": "./tsconfig.lib.json"
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"path": "./tsconfig.spec.json"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"path": "./tsconfig.storybook.json"
|
|
18
|
-
}
|
|
19
|
-
]
|
|
20
|
-
}
|
package/tsconfig.lib.json
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"module": "NodeNext",
|
|
5
|
-
"moduleResolution": "NodeNext",
|
|
6
|
-
"outDir": "../../dist/out-tsc",
|
|
7
|
-
"declaration": true,
|
|
8
|
-
"stripInternal": true,
|
|
9
|
-
"types": ["node", "environment"]
|
|
10
|
-
},
|
|
11
|
-
"exclude": [
|
|
12
|
-
"**/*.spec.ts",
|
|
13
|
-
"**/*.test.ts",
|
|
14
|
-
"**/*.spec.tsx",
|
|
15
|
-
"**/*.test.tsx",
|
|
16
|
-
"**/*.spec.js",
|
|
17
|
-
"**/*.test.js",
|
|
18
|
-
"**/*.spec.jsx",
|
|
19
|
-
"**/*.test.jsx",
|
|
20
|
-
"**/*.stories.ts",
|
|
21
|
-
"**/*.stories.js",
|
|
22
|
-
"**/*.stories.jsx",
|
|
23
|
-
"**/*.stories.tsx",
|
|
24
|
-
"jest.config.ts",
|
|
25
|
-
"vitest.config.ts"
|
|
26
|
-
],
|
|
27
|
-
"include": ["src/**/*.ts", "src/**/*.tsx"]
|
|
28
|
-
}
|
package/tsconfig.spec.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../../dist/out-tsc",
|
|
5
|
-
"allowSyntheticDefaultImports": true,
|
|
6
|
-
"typeRoots": ["../../node_modules", "../../node_modules/@types", "../../typings"],
|
|
7
|
-
"types": ["vitest/importMeta", "vite/client", "node", "vitest", "environment"]
|
|
8
|
-
},
|
|
9
|
-
"include": [
|
|
10
|
-
"vitest.config.ts",
|
|
11
|
-
"**/*.test.ts",
|
|
12
|
-
"**/*.spec.ts",
|
|
13
|
-
"**/*.test.tsx",
|
|
14
|
-
"**/*.spec.tsx",
|
|
15
|
-
"**/*.test.js",
|
|
16
|
-
"**/*.spec.js",
|
|
17
|
-
"**/*.test.jsx",
|
|
18
|
-
"**/*.spec.jsx",
|
|
19
|
-
"**/*.d.ts"
|
|
20
|
-
]
|
|
21
|
-
}
|
package/tsconfig.storybook.json
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"emitDecoratorMetadata": true,
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"allowSyntheticDefaultImports": true,
|
|
7
|
-
"noEmit": true,
|
|
8
|
-
"outDir": ""
|
|
9
|
-
},
|
|
10
|
-
"exclude": ["src/**/*.spec.ts", "src/**/*.spec.js", "src/**/*.spec.tsx", "src/**/*.spec.jsx", "jest.config.ts"],
|
|
11
|
-
"include": ["src/**/*", ".storybook/*.js"]
|
|
12
|
-
}
|
package/vitest.config.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vitest/config';
|
|
2
|
-
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
3
|
-
|
|
4
|
-
export default defineConfig({
|
|
5
|
-
root: __dirname,
|
|
6
|
-
cacheDir: '../../node_modules/.vite/packages/react',
|
|
7
|
-
plugins: [nxViteTsPaths()],
|
|
8
|
-
define: {
|
|
9
|
-
IS_REACT_ACT_ENVIRONMENT: true,
|
|
10
|
-
},
|
|
11
|
-
test: {
|
|
12
|
-
watch: false,
|
|
13
|
-
environment: 'jsdom',
|
|
14
|
-
include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
15
|
-
reporters: ['default'],
|
|
16
|
-
coverage: {
|
|
17
|
-
reportsDirectory: '../../coverage/packages/react',
|
|
18
|
-
provider: 'v8',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
});
|