@ornikar/bumper 2.1.0 → 2.2.1-canary.0ceb6a0ec79212a49e36324c71e86b68677389c7.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/CHANGELOG.md +17 -0
- package/dist/definitions/core/BumperDecorator.d.ts +1 -1
- package/dist/definitions/core/BumperDecorator.d.ts.map +1 -1
- package/dist/definitions/index.d.ts +6 -0
- package/dist/definitions/index.d.ts.map +1 -1
- package/dist/definitions/story-components/StorySection.d.ts.map +1 -1
- package/dist/index-metro.es.android.js +118 -3
- package/dist/index-metro.es.android.js.map +1 -1
- package/dist/index-metro.es.ios.js +118 -3
- package/dist/index-metro.es.ios.js.map +1 -1
- package/dist/index-node-22.17.cjs.js +119 -0
- package/dist/index-node-22.17.cjs.js.map +1 -1
- package/dist/index-node-22.17.cjs.web.js +119 -0
- package/dist/index-node-22.17.cjs.web.js.map +1 -1
- package/dist/index-node-22.17.es.mjs +118 -3
- package/dist/index-node-22.17.es.mjs.map +1 -1
- package/dist/index-node-22.17.es.web.mjs +118 -3
- package/dist/index-node-22.17.es.web.mjs.map +1 -1
- package/dist/index.es.js +117 -3
- package/dist/index.es.js.map +1 -1
- package/dist/index.es.web.js +117 -3
- package/dist/index.es.web.js.map +1 -1
- package/dist/tsbuildinfo +1 -1
- package/package.json +15 -7
- package/src/components/breakpoints/hooks/useBreakpointValue.test.ts +40 -0
- package/src/components/breakpoints/hooks/useCurrentBreakpointName.test.ts +39 -0
- package/src/components/breakpoints/utils/breakpointsUtils.test.ts +10 -10
- package/src/index.ts +10 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ornikar/bumper",
|
|
3
|
-
"version": "2.1.0",
|
|
3
|
+
"version": "2.2.1-canary.0ceb6a0ec79212a49e36324c71e86b68677389c7.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"directory": "@ornikar/bumper",
|
|
@@ -11,9 +11,6 @@
|
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
13
|
"sideEffects": false,
|
|
14
|
-
"bin": {
|
|
15
|
-
"run-transformers": "./scripts/run-transformers.js"
|
|
16
|
-
},
|
|
17
14
|
"engines": {
|
|
18
15
|
"node": ">=22.17.0"
|
|
19
16
|
},
|
|
@@ -21,7 +18,14 @@
|
|
|
21
18
|
"build": "ORNIKAR_ONLY=bumper yarn ../.. build",
|
|
22
19
|
"lint:eslint": "yarn ../.. eslint --report-unused-disable-directives --quiet @ornikar/bumper"
|
|
23
20
|
},
|
|
24
|
-
"ornikar": {
|
|
21
|
+
"ornikar": {
|
|
22
|
+
"entries": [
|
|
23
|
+
"index"
|
|
24
|
+
],
|
|
25
|
+
"extraEntries": [
|
|
26
|
+
"./src/tamagui.config.ts"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
25
29
|
"dependencies": {
|
|
26
30
|
"@babel/runtime": "^7.24.0",
|
|
27
31
|
"@tamagui/core": "1.135.6"
|
|
@@ -45,11 +49,14 @@
|
|
|
45
49
|
},
|
|
46
50
|
"devDependencies": {
|
|
47
51
|
"@babel/core": "7.27.1",
|
|
52
|
+
"@testing-library/dom": "10.4.1",
|
|
53
|
+
"@testing-library/react": "16.3.0",
|
|
54
|
+
"@testing-library/react-native": "13.3.3",
|
|
48
55
|
"@types/react": "18.3.27",
|
|
49
56
|
"react": "18.3.1",
|
|
50
57
|
"react-dom": "18.3.1",
|
|
51
58
|
"react-native": "0.76.9",
|
|
52
|
-
"
|
|
59
|
+
"react-test-renderer": "18.3.1"
|
|
53
60
|
},
|
|
54
61
|
"expo": {},
|
|
55
62
|
"exports": {
|
|
@@ -70,7 +77,8 @@
|
|
|
70
77
|
"import": "./dist/index.es.web.js"
|
|
71
78
|
}
|
|
72
79
|
},
|
|
73
|
-
"./package.json": "./package.json"
|
|
80
|
+
"./package.json": "./package.json",
|
|
81
|
+
"./src/tamagui.config.ts": "./src/tamagui.config.ts"
|
|
74
82
|
},
|
|
75
83
|
"browser": "./dist/index.es",
|
|
76
84
|
"main": "./dist/index-node-22.17.es.mjs",
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { renderHook } from '@testing-library/react-native';
|
|
2
|
+
import { BreakpointNameEnum } from '../../../themes/utils/breakpoints';
|
|
3
|
+
import { getValueForBreakpoint } from '../utils/breakpointsUtils';
|
|
4
|
+
import { useBreakpointValue } from './useBreakpointValue';
|
|
5
|
+
import { useCurrentBreakpointName } from './useCurrentBreakpointName';
|
|
6
|
+
|
|
7
|
+
jest.mock('./useCurrentBreakpointName');
|
|
8
|
+
const mockUseCurrentBreakpointName = jest.mocked(useCurrentBreakpointName);
|
|
9
|
+
|
|
10
|
+
jest.mock('../utils/breakpointsUtils');
|
|
11
|
+
const mockGetValueForBreakpoint = jest.mocked(getValueForBreakpoint);
|
|
12
|
+
|
|
13
|
+
describe('useBreakpointValue', () => {
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
mockUseCurrentBreakpointName.mockClear();
|
|
16
|
+
mockGetValueForBreakpoint.mockClear();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should call getValueForBreakpoint with correct arguments', () => {
|
|
20
|
+
const returnValue = 'base-value';
|
|
21
|
+
const breakpoint = BreakpointNameEnum.BASE;
|
|
22
|
+
|
|
23
|
+
mockGetValueForBreakpoint.mockReturnValueOnce(returnValue);
|
|
24
|
+
mockUseCurrentBreakpointName.mockReturnValue(breakpoint);
|
|
25
|
+
|
|
26
|
+
renderHook(() => useBreakpointValue({ base: returnValue }));
|
|
27
|
+
expect(mockGetValueForBreakpoint).toHaveBeenCalledWith(breakpoint, { base: returnValue });
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should return the value provided by getValueForBreakpoint', () => {
|
|
31
|
+
const returnValue = 'base-value';
|
|
32
|
+
const breakpoint = BreakpointNameEnum.BASE;
|
|
33
|
+
|
|
34
|
+
mockGetValueForBreakpoint.mockReturnValueOnce(returnValue);
|
|
35
|
+
mockUseCurrentBreakpointName.mockReturnValue(breakpoint);
|
|
36
|
+
|
|
37
|
+
const { result } = renderHook(() => useBreakpointValue({ base: returnValue }));
|
|
38
|
+
expect(result.current).toEqual(returnValue);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type UseMediaState, useMedia } from '@tamagui/core';
|
|
2
|
+
import { renderHook } from '@testing-library/react-native';
|
|
3
|
+
import { BreakpointNameEnum } from '../../../themes/utils/breakpoints';
|
|
4
|
+
import { useCurrentBreakpointName } from './useCurrentBreakpointName';
|
|
5
|
+
|
|
6
|
+
jest.mock('@tamagui/core');
|
|
7
|
+
const mockedUseMedia = jest.mocked(useMedia);
|
|
8
|
+
|
|
9
|
+
describe('useCurrentBreakpointName', () => {
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
mockedUseMedia.mockClear();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it.each([
|
|
15
|
+
[BreakpointNameEnum.WIDE, { wide: true }],
|
|
16
|
+
[BreakpointNameEnum.LARGE, { large: true }],
|
|
17
|
+
[BreakpointNameEnum.MEDIUM, { medium: true }],
|
|
18
|
+
[BreakpointNameEnum.SMALL, { small: true }],
|
|
19
|
+
[BreakpointNameEnum.BASE, { base: true }],
|
|
20
|
+
])('should return the %s breakpoint when media returns a corresponding value', (breakpoint, mediaMock) => {
|
|
21
|
+
mockedUseMedia.mockReturnValue(mediaMock as UseMediaState);
|
|
22
|
+
|
|
23
|
+
const { result } = renderHook(() => useCurrentBreakpointName());
|
|
24
|
+
expect(result.current).toBe(breakpoint);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should default to BASE when there are no matching media queries', () => {
|
|
28
|
+
mockedUseMedia.mockReturnValue({
|
|
29
|
+
wide: false,
|
|
30
|
+
large: false,
|
|
31
|
+
medium: false,
|
|
32
|
+
small: false,
|
|
33
|
+
base: false,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const { result } = renderHook(() => useCurrentBreakpointName());
|
|
37
|
+
expect(result.current).toBe(BreakpointNameEnum.BASE);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -2,21 +2,21 @@ import { BreakpointNameEnum } from '../../../themes/utils/breakpoints';
|
|
|
2
2
|
import { getValueForBreakpoint } from './breakpointsUtils';
|
|
3
3
|
|
|
4
4
|
describe('getValueForBreakpoint', () => {
|
|
5
|
-
|
|
5
|
+
it('should return the base value for BASE breakpoint', () => {
|
|
6
6
|
expect(getValueForBreakpoint(BreakpointNameEnum.BASE, { base: 'base-value' })).toBe('base-value');
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
it('should return small value for SMALL breakpoint if available', () => {
|
|
10
10
|
expect(getValueForBreakpoint(BreakpointNameEnum.SMALL, { base: 'base-value', small: 'small-value' })).toBe(
|
|
11
11
|
'small-value',
|
|
12
12
|
);
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
it('should fallback to base value for SMALL breakpoint if small not provided', () => {
|
|
16
16
|
expect(getValueForBreakpoint(BreakpointNameEnum.SMALL, { base: 'base-value' })).toBe('base-value');
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
it('should return medium value for MEDIUM breakpoint if available', () => {
|
|
20
20
|
expect(
|
|
21
21
|
getValueForBreakpoint(BreakpointNameEnum.MEDIUM, {
|
|
22
22
|
base: 'base-value',
|
|
@@ -26,7 +26,7 @@ describe('getValueForBreakpoint', () => {
|
|
|
26
26
|
).toBe('medium-value');
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
it('should fallback to small value for MEDIUM breakpoint if medium not provided', () => {
|
|
30
30
|
expect(
|
|
31
31
|
getValueForBreakpoint(BreakpointNameEnum.MEDIUM, {
|
|
32
32
|
base: 'base-value',
|
|
@@ -35,7 +35,7 @@ describe('getValueForBreakpoint', () => {
|
|
|
35
35
|
).toBe('small-value');
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
it('should return large value for LARGE breakpoint if available', () => {
|
|
39
39
|
expect(
|
|
40
40
|
getValueForBreakpoint(BreakpointNameEnum.LARGE, {
|
|
41
41
|
base: 'base-value',
|
|
@@ -46,7 +46,7 @@ describe('getValueForBreakpoint', () => {
|
|
|
46
46
|
).toBe('large-value');
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
it('should fallback to medium value for LARGE breakpoint if large not provided', () => {
|
|
50
50
|
expect(
|
|
51
51
|
getValueForBreakpoint(BreakpointNameEnum.LARGE, {
|
|
52
52
|
base: 'base-value',
|
|
@@ -56,7 +56,7 @@ describe('getValueForBreakpoint', () => {
|
|
|
56
56
|
).toBe('medium-value');
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
it('should return wide value for WIDE breakpoint if available', () => {
|
|
60
60
|
expect(
|
|
61
61
|
getValueForBreakpoint(BreakpointNameEnum.WIDE, {
|
|
62
62
|
base: 'base-value',
|
|
@@ -68,7 +68,7 @@ describe('getValueForBreakpoint', () => {
|
|
|
68
68
|
).toBe('wide-value');
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
it('should fallback to large value for WIDE breakpoint if wide not provided', () => {
|
|
72
72
|
expect(
|
|
73
73
|
getValueForBreakpoint(BreakpointNameEnum.WIDE, {
|
|
74
74
|
base: 'base-value',
|
|
@@ -79,7 +79,7 @@ describe('getValueForBreakpoint', () => {
|
|
|
79
79
|
).toBe('large-value');
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
it('should return base value for unknown breakpoint', () => {
|
|
83
83
|
expect(getValueForBreakpoint('unknown' as BreakpointNameEnum, { base: 'base-value' })).toBe('base-value');
|
|
84
84
|
});
|
|
85
85
|
});
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
export { BumperDecorator } from './core/BumperDecorator';
|
|
2
2
|
export { BumperProvider } from './core/BumperProvider';
|
|
3
3
|
|
|
4
|
+
// Primitives
|
|
5
|
+
export type { HStackProps, StackProps, VStackProps } from './components/primitives/Stacks';
|
|
6
|
+
export { HStack, Stack, VStack } from './components/primitives/Stacks';
|
|
7
|
+
export type { ViewProps } from './components/primitives/View';
|
|
8
|
+
export { View } from './components/primitives/View';
|
|
9
|
+
|
|
10
|
+
// Typography
|
|
11
|
+
export type { TypographyTextProps } from './components/typography/Typograhy';
|
|
12
|
+
export { Typography } from './components/typography/Typograhy';
|
|
13
|
+
|
|
4
14
|
// Breakpoints
|
|
5
15
|
export { useBreakpointValue } from './components/breakpoints/hooks/useBreakpointValue';
|
|
6
16
|
export { useCurrentBreakpointName } from './components/breakpoints/hooks/useCurrentBreakpointName';
|