@ornikar/bumper 2.2.1-canary.431a0c996598cbee4e3c07f6b9886d37d2a76679.0 → 2.2.1-canary.d9333a410786c9c1a722ce408a27e7980c9146a4.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 +2 -9
- 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 +0 -3
- package/dist/definitions/index.d.ts.map +1 -1
- package/dist/definitions/story-components/StorySection.d.ts.map +1 -1
- package/dist/definitions/tamagui.config.d.ts +1 -20
- package/dist/definitions/tamagui.config.d.ts.map +1 -1
- package/dist/index-metro.es.android.js +5 -168
- package/dist/index-metro.es.android.js.map +1 -1
- package/dist/index-metro.es.ios.js +5 -168
- package/dist/index-metro.es.ios.js.map +1 -1
- package/dist/index-node-22.17.cjs.js +2 -167
- package/dist/index-node-22.17.cjs.js.map +1 -1
- package/dist/index-node-22.17.cjs.web.js +1 -166
- package/dist/index-node-22.17.cjs.web.js.map +1 -1
- package/dist/index-node-22.17.es.mjs +4 -167
- package/dist/index-node-22.17.es.mjs.map +1 -1
- package/dist/index-node-22.17.es.web.mjs +4 -166
- package/dist/index-node-22.17.es.web.mjs.map +1 -1
- package/dist/index.es.js +5 -177
- package/dist/index.es.js.map +1 -1
- package/dist/index.es.web.js +4 -175
- package/dist/index.es.web.js.map +1 -1
- package/dist/tsbuildinfo +1 -1
- package/package.json +6 -10
- 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 +0 -5
- package/src/tamagui.config.ts +0 -3
- package/dist/definitions/animations.d.ts +0 -22
- package/dist/definitions/animations.d.ts.map +0 -1
- package/dist/definitions/components/toast/SafeToastViewport.d.ts +0 -9
- package/dist/definitions/components/toast/SafeToastViewport.d.ts.map +0 -1
- package/dist/definitions/components/toast/ToastProvider.d.ts +0 -10
- package/dist/definitions/components/toast/ToastProvider.d.ts.map +0 -1
- package/dist/definitions/components/toast/ToastRenderer.d.ts +0 -8
- package/dist/definitions/components/toast/ToastRenderer.d.ts.map +0 -1
- package/dist/definitions/components/toast/ToastStoreProvider.d.ts +0 -11
- package/dist/definitions/components/toast/ToastStoreProvider.d.ts.map +0 -1
- package/dist/definitions/components/toast/decorators/ToastProviderDecorator.d.ts +0 -2
- package/dist/definitions/components/toast/decorators/ToastProviderDecorator.d.ts.map +0 -1
- package/dist/definitions/components/toast/types.d.ts +0 -8
- package/dist/definitions/components/toast/types.d.ts.map +0 -1
- package/dist/definitions/components/toast/useToast.d.ts +0 -9
- package/dist/definitions/components/toast/useToast.d.ts.map +0 -1
- package/src/animations.ts +0 -25
- package/src/components/toast/SafeToastViewport.tsx +0 -26
- package/src/components/toast/Toast.stories.tsx +0 -75
- package/src/components/toast/ToastProvider.tsx +0 -33
- package/src/components/toast/ToastRenderer.tsx +0 -26
- package/src/components/toast/ToastStoreProvider.tsx +0 -41
- package/src/components/toast/__snapshots__/Toast.stories.tsx.snap +0 -146
- package/src/components/toast/__snapshots_web__/Toast.stories.tsx.snap +0 -81
- package/src/components/toast/decorators/ToastProviderDecorator.tsx +0 -23
- package/src/components/toast/types.ts +0 -9
- package/src/components/toast/useToast.tsx +0 -35
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ornikar/bumper",
|
|
3
|
-
"version": "2.2.1-canary.
|
|
3
|
+
"version": "2.2.1-canary.d9333a410786c9c1a722ce408a27e7980c9146a4.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"directory": "@ornikar/bumper",
|
|
@@ -28,17 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@babel/runtime": "^7.24.0",
|
|
31
|
-
"@tamagui/
|
|
32
|
-
"@tamagui/animations-react-native": "1.135.6",
|
|
33
|
-
"@tamagui/core": "1.135.6",
|
|
34
|
-
"@tamagui/portal": "1.135.6",
|
|
35
|
-
"@tamagui/toast": "1.135.6",
|
|
36
|
-
"burnt": "0.12.2",
|
|
37
|
-
"react-native-safe-area-context": "4.12.0"
|
|
31
|
+
"@tamagui/core": "1.135.6"
|
|
38
32
|
},
|
|
39
33
|
"peerDependencies": {
|
|
40
34
|
"@storybook/addons": ">=7.6.20",
|
|
41
|
-
"expo": "*",
|
|
42
35
|
"react": "^18.3.1",
|
|
43
36
|
"react-dom": "^18.3.1",
|
|
44
37
|
"react-native": ">=0.76.9"
|
|
@@ -56,11 +49,14 @@
|
|
|
56
49
|
},
|
|
57
50
|
"devDependencies": {
|
|
58
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",
|
|
59
55
|
"@types/react": "18.3.27",
|
|
60
56
|
"react": "18.3.1",
|
|
61
57
|
"react-dom": "18.3.1",
|
|
62
58
|
"react-native": "0.76.9",
|
|
63
|
-
"react-
|
|
59
|
+
"react-test-renderer": "18.3.1"
|
|
64
60
|
},
|
|
65
61
|
"expo": {},
|
|
66
62
|
"exports": {
|
|
@@ -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
|
@@ -19,8 +19,3 @@ export type { SwitchBreakpointsProps } from './components/breakpoints/SwitchBrea
|
|
|
19
19
|
export { SwitchBreakpoints } from './components/breakpoints/SwitchBreakpoins';
|
|
20
20
|
export type { ValueForBreakpoint } from './components/breakpoints/utils/breakpointsUtils';
|
|
21
21
|
export { getValueForBreakpoint } from './components/breakpoints/utils/breakpointsUtils';
|
|
22
|
-
|
|
23
|
-
// Toast
|
|
24
|
-
export { SafeToastViewport as ToastViewport } from './components/toast/SafeToastViewport';
|
|
25
|
-
export { ToastProvider } from './components/toast/ToastProvider';
|
|
26
|
-
export { useToast } from './components/toast/useToast';
|
package/src/tamagui.config.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { createTamagui, createTokens } from '@tamagui/core';
|
|
2
|
-
import { Platform } from 'react-native';
|
|
3
|
-
import { nativeAnimations, webAnimations } from './animations';
|
|
4
2
|
import { light } from './themes/light';
|
|
5
3
|
import { BreakpointNameEnum, breakpoints } from './themes/utils/breakpoints';
|
|
6
4
|
import { fonts } from './tokens/fonts';
|
|
@@ -35,7 +33,6 @@ export const config = createTamagui({
|
|
|
35
33
|
autocompleteSpecificTokens: true,
|
|
36
34
|
debug: false,
|
|
37
35
|
},
|
|
38
|
-
animations: Platform.OS === 'web' ? webAnimations : nativeAnimations,
|
|
39
36
|
});
|
|
40
37
|
|
|
41
38
|
type Conf = typeof config;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export declare const nativeAnimations: import("@tamagui/web").AnimationDriver<{
|
|
2
|
-
fast: {
|
|
3
|
-
damping: number;
|
|
4
|
-
mass: number;
|
|
5
|
-
stiffness: number;
|
|
6
|
-
};
|
|
7
|
-
medium: {
|
|
8
|
-
damping: number;
|
|
9
|
-
mass: number;
|
|
10
|
-
stiffness: number;
|
|
11
|
-
};
|
|
12
|
-
slow: {
|
|
13
|
-
damping: number;
|
|
14
|
-
stiffness: number;
|
|
15
|
-
};
|
|
16
|
-
}>;
|
|
17
|
-
export declare const webAnimations: import("@tamagui/web").AnimationDriver<{
|
|
18
|
-
fast: string;
|
|
19
|
-
medium: string;
|
|
20
|
-
slow: string;
|
|
21
|
-
}>;
|
|
22
|
-
//# sourceMappingURL=animations.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"animations.d.ts","sourceRoot":"","sources":["../../src/animations.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;EAe3B,CAAC;AAEH,eAAO,MAAM,aAAa;;;;EAIxB,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ToastViewportProps } from '@tamagui/toast';
|
|
2
|
-
import type { ReactNode } from 'react';
|
|
3
|
-
export interface SafeToastViewportProps {
|
|
4
|
-
name?: ToastViewportProps['name'];
|
|
5
|
-
position?: 'top' | 'bottom';
|
|
6
|
-
portalToRoot?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare function SafeToastViewport({ name, position, portalToRoot }: SafeToastViewportProps): ReactNode;
|
|
9
|
-
//# sourceMappingURL=SafeToastViewport.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SafeToastViewport.d.ts","sourceRoot":"","sources":["../../../../src/components/toast/SafeToastViewport.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,IAAI,EAAE,QAAgB,EAAE,YAAoB,EAAE,EAAE,sBAAsB,GAAG,SAAS,CAcrH"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import type { ToastProps } from './types';
|
|
3
|
-
export interface ToastProviderProps {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
position?: 'top' | 'bottom';
|
|
6
|
-
viewportName?: string;
|
|
7
|
-
ToastComponent: React.ComponentType<ToastProps>;
|
|
8
|
-
}
|
|
9
|
-
export declare function ToastProvider({ children, position, viewportName, ToastComponent, }: ToastProviderProps): ReactNode;
|
|
10
|
-
//# sourceMappingURL=ToastProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ToastProvider.d.ts","sourceRoot":"","sources":["../../../../src/components/toast/ToastProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;CACjD;AAED,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,QAAgB,EAChB,YAAY,EACZ,cAAc,GACf,EAAE,kBAAkB,GAAG,SAAS,CAYhC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import type { ToastProps } from './types';
|
|
3
|
-
interface ToastRendererProps {
|
|
4
|
-
ToastComponent: React.ComponentType<ToastProps>;
|
|
5
|
-
}
|
|
6
|
-
export declare function ToastRenderer({ ToastComponent }: ToastRendererProps): ReactNode;
|
|
7
|
-
export {};
|
|
8
|
-
//# sourceMappingURL=ToastRenderer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ToastRenderer.d.ts","sourceRoot":"","sources":["../../../../src/components/toast/ToastRenderer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG1C,UAAU,kBAAkB;IAC1B,cAAc,EAAE,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;CACjD;AAED,wBAAgB,aAAa,CAAC,EAAE,cAAc,EAAE,EAAE,kBAAkB,GAAG,SAAS,CAe/E"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { PropsWithChildren, ReactNode } from 'react';
|
|
2
|
-
import type { ToastOptions } from './types';
|
|
3
|
-
interface ToastStore {
|
|
4
|
-
toasts: ToastOptions[];
|
|
5
|
-
addToast: (toast: ToastOptions) => void;
|
|
6
|
-
removeToast: (id: string) => void;
|
|
7
|
-
}
|
|
8
|
-
export declare function ToastStoreProvider({ children }: PropsWithChildren): ReactNode;
|
|
9
|
-
export declare const useToastStore: () => ToastStore;
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=ToastStoreProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ToastStoreProvider.d.ts","sourceRoot":"","sources":["../../../../src/components/toast/ToastStoreProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,UAAU,UAAU;IAClB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IACxC,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAkBD,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,EAAE,iBAAiB,GAAG,SAAS,CAM7E;AAED,eAAO,MAAM,aAAa,QAAO,UAMhC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ToastProviderDecorator.d.ts","sourceRoot":"","sources":["../../../../../src/components/toast/decorators/ToastProviderDecorator.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,mBAAmB,kEAiB9B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/toast/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC9C,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,UAAW,SAAQ,YAAY;IAC9C,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ToastOptions } from './types';
|
|
2
|
-
interface UseToastReturn {
|
|
3
|
-
toasts: ToastOptions[];
|
|
4
|
-
showToast: (options: ToastOptions) => void;
|
|
5
|
-
hideToast: (id: string) => void;
|
|
6
|
-
}
|
|
7
|
-
export declare function useToast(): UseToastReturn;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=useToast.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useToast.d.ts","sourceRoot":"","sources":["../../../../src/components/toast/useToast.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,UAAU,cAAc;IACtB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,SAAS,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;IAC3C,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAED,wBAAgB,QAAQ,IAAI,cAAc,CAwBzC"}
|
package/src/animations.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { createAnimations as createWebAnimations } from '@tamagui/animations-css';
|
|
2
|
-
import { createAnimations as createNativeAnimations } from '@tamagui/animations-react-native';
|
|
3
|
-
|
|
4
|
-
export const nativeAnimations = createNativeAnimations({
|
|
5
|
-
fast: {
|
|
6
|
-
damping: 20,
|
|
7
|
-
mass: 1.2,
|
|
8
|
-
stiffness: 250,
|
|
9
|
-
},
|
|
10
|
-
medium: {
|
|
11
|
-
damping: 10,
|
|
12
|
-
mass: 0.9,
|
|
13
|
-
stiffness: 100,
|
|
14
|
-
},
|
|
15
|
-
slow: {
|
|
16
|
-
damping: 20,
|
|
17
|
-
stiffness: 60,
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
export const webAnimations = createWebAnimations({
|
|
22
|
-
fast: 'ease-in 150ms',
|
|
23
|
-
medium: 'ease-in 300ms',
|
|
24
|
-
slow: 'ease-in 450ms',
|
|
25
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ToastViewport } from '@tamagui/toast';
|
|
2
|
-
import type { ToastViewportProps } from '@tamagui/toast';
|
|
3
|
-
import type { ReactNode } from 'react';
|
|
4
|
-
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
5
|
-
|
|
6
|
-
export interface SafeToastViewportProps {
|
|
7
|
-
name?: ToastViewportProps['name'];
|
|
8
|
-
position?: 'top' | 'bottom';
|
|
9
|
-
portalToRoot?: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function SafeToastViewport({ name, position = 'top', portalToRoot = false }: SafeToastViewportProps): ReactNode {
|
|
13
|
-
const { left, top, bottom, right } = useSafeAreaInsets();
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<ToastViewport
|
|
17
|
-
multipleToasts
|
|
18
|
-
portalToRoot={portalToRoot}
|
|
19
|
-
name={name}
|
|
20
|
-
top={position === 'top' ? top : undefined}
|
|
21
|
-
bottom={position === 'bottom' ? bottom : undefined}
|
|
22
|
-
left={left}
|
|
23
|
-
right={right}
|
|
24
|
-
/>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import type { ComponentStory, Meta } from '@storybook/react';
|
|
2
|
-
import { type ReactNode } from 'react';
|
|
3
|
-
import { StorySection } from '../../story-components/StorySection';
|
|
4
|
-
import { VStack } from '../primitives/Stacks';
|
|
5
|
-
import { View } from '../primitives/View';
|
|
6
|
-
import { Typography } from '../typography/Typograhy';
|
|
7
|
-
import { ToastProvider } from './ToastProvider';
|
|
8
|
-
import { ToastStoryDecorator } from './decorators/ToastProviderDecorator';
|
|
9
|
-
import type { ToastProps } from './types';
|
|
10
|
-
import { useToast } from './useToast';
|
|
11
|
-
|
|
12
|
-
function ToastComponent(props: ToastProps) {
|
|
13
|
-
return (
|
|
14
|
-
<VStack
|
|
15
|
-
backgroundColor="$bg.highlight.default"
|
|
16
|
-
padding="$16"
|
|
17
|
-
borderRadius="$space.4"
|
|
18
|
-
height="$space.56"
|
|
19
|
-
justifyContent="center"
|
|
20
|
-
>
|
|
21
|
-
<Typography.Text variant="body-l" weight="bold">
|
|
22
|
-
{props.title}
|
|
23
|
-
</Typography.Text>
|
|
24
|
-
{props.description && <Typography.Text>{props.description}</Typography.Text>}
|
|
25
|
-
</VStack>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function ToastTrigger(): ReactNode {
|
|
30
|
-
const { showToast } = useToast();
|
|
31
|
-
|
|
32
|
-
const showExampleToast = () => {
|
|
33
|
-
showToast({
|
|
34
|
-
title: 'Example Toast',
|
|
35
|
-
description: 'This is an example of a toast message.',
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const showExampleToast2 = () => {
|
|
40
|
-
showToast({
|
|
41
|
-
title: 'Example Toast 2',
|
|
42
|
-
description: 'This is an other example of a toast message.',
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
return (
|
|
46
|
-
<>
|
|
47
|
-
<View onPress={showExampleToast}>
|
|
48
|
-
<Typography.Text>Show Toast</Typography.Text>
|
|
49
|
-
</View>
|
|
50
|
-
<View onPress={showExampleToast2}>
|
|
51
|
-
<Typography.Text>Show Toast 2</Typography.Text>
|
|
52
|
-
</View>
|
|
53
|
-
</>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export default {
|
|
58
|
-
title: 'bumper/Toast',
|
|
59
|
-
component: ToastProvider,
|
|
60
|
-
decorators: [ToastStoryDecorator],
|
|
61
|
-
} satisfies Meta<typeof ToastProvider>;
|
|
62
|
-
|
|
63
|
-
export const ToastProviderStory: ComponentStory<typeof ToastProvider> = () => (
|
|
64
|
-
<StorySection.Demo>
|
|
65
|
-
<ToastTrigger />
|
|
66
|
-
</StorySection.Demo>
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
ToastProviderStory.storyName = 'Toast';
|
|
70
|
-
ToastProviderStory.parameters = {
|
|
71
|
-
toast: {
|
|
72
|
-
position: 'top',
|
|
73
|
-
component: ToastComponent,
|
|
74
|
-
},
|
|
75
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { PortalProvider } from '@tamagui/portal';
|
|
2
|
-
import { ToastProvider as TamaguiToastProvider } from '@tamagui/toast';
|
|
3
|
-
import type { ReactNode } from 'react';
|
|
4
|
-
import { SafeToastViewport } from './SafeToastViewport';
|
|
5
|
-
import { ToastRenderer } from './ToastRenderer';
|
|
6
|
-
import { ToastStoreProvider } from './ToastStoreProvider';
|
|
7
|
-
import type { ToastProps } from './types';
|
|
8
|
-
|
|
9
|
-
export interface ToastProviderProps {
|
|
10
|
-
children: React.ReactNode;
|
|
11
|
-
position?: 'top' | 'bottom';
|
|
12
|
-
viewportName?: string;
|
|
13
|
-
ToastComponent: React.ComponentType<ToastProps>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function ToastProvider({
|
|
17
|
-
children,
|
|
18
|
-
position = 'top',
|
|
19
|
-
viewportName,
|
|
20
|
-
ToastComponent,
|
|
21
|
-
}: ToastProviderProps): ReactNode {
|
|
22
|
-
return (
|
|
23
|
-
<PortalProvider>
|
|
24
|
-
<TamaguiToastProvider swipeDirection="horizontal">
|
|
25
|
-
<ToastStoreProvider>
|
|
26
|
-
{children}
|
|
27
|
-
<SafeToastViewport portalToRoot name={viewportName} position={position} />
|
|
28
|
-
<ToastRenderer ToastComponent={ToastComponent} />
|
|
29
|
-
</ToastStoreProvider>
|
|
30
|
-
</TamaguiToastProvider>
|
|
31
|
-
</PortalProvider>
|
|
32
|
-
);
|
|
33
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Toast } from '@tamagui/toast';
|
|
2
|
-
import type { ReactNode } from 'react';
|
|
3
|
-
import { useCallback } from 'react';
|
|
4
|
-
import type { ToastProps } from './types';
|
|
5
|
-
import { useToast } from './useToast';
|
|
6
|
-
|
|
7
|
-
interface ToastRendererProps {
|
|
8
|
-
ToastComponent: React.ComponentType<ToastProps>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function ToastRenderer({ ToastComponent }: ToastRendererProps): ReactNode {
|
|
12
|
-
const { toasts, hideToast: removeToast } = useToast();
|
|
13
|
-
|
|
14
|
-
const hideToast = useCallback(
|
|
15
|
-
(id: string) => () => {
|
|
16
|
-
removeToast(id);
|
|
17
|
-
},
|
|
18
|
-
[removeToast],
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
return toasts.map((toast) => (
|
|
22
|
-
<Toast key={toast.id} id={toast.id} duration={toast.timeout} viewportName={toast.viewportName}>
|
|
23
|
-
<ToastComponent {...toast} hideToast={hideToast(toast.id)} />
|
|
24
|
-
</Toast>
|
|
25
|
-
));
|
|
26
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { PropsWithChildren, ReactNode } from 'react';
|
|
2
|
-
import { createContext, useCallback, useContext, useMemo, useState } from 'react';
|
|
3
|
-
import type { ToastOptions } from './types';
|
|
4
|
-
|
|
5
|
-
interface ToastStore {
|
|
6
|
-
toasts: ToastOptions[];
|
|
7
|
-
addToast: (toast: ToastOptions) => void;
|
|
8
|
-
removeToast: (id: string) => void;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const useToastState = (): ToastStore => {
|
|
12
|
-
const [toasts, setToasts] = useState<ToastOptions[]>([]);
|
|
13
|
-
|
|
14
|
-
const removeToast = useCallback((id: string) => {
|
|
15
|
-
setToasts((prevToasts) => prevToasts.filter((t) => t.id !== id));
|
|
16
|
-
}, []);
|
|
17
|
-
|
|
18
|
-
const addToast = useCallback((toast: ToastOptions) => {
|
|
19
|
-
setToasts((prevToasts) => [...prevToasts, toast]);
|
|
20
|
-
}, []);
|
|
21
|
-
|
|
22
|
-
return { toasts, addToast, removeToast };
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const ToastStoreContext = createContext<ToastStore | undefined>(undefined);
|
|
26
|
-
|
|
27
|
-
export function ToastStoreProvider({ children }: PropsWithChildren): ReactNode {
|
|
28
|
-
const { toasts, addToast, removeToast } = useToastState();
|
|
29
|
-
|
|
30
|
-
const value = useMemo(() => ({ toasts, addToast, removeToast }), [toasts, addToast, removeToast]);
|
|
31
|
-
|
|
32
|
-
return <ToastStoreContext.Provider value={value}>{children}</ToastStoreContext.Provider>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export const useToastStore = (): ToastStore => {
|
|
36
|
-
const context = useContext(ToastStoreContext);
|
|
37
|
-
if (!context) {
|
|
38
|
-
throw new Error('useToastStore must be used within a ToastStoreProvider');
|
|
39
|
-
}
|
|
40
|
-
return context;
|
|
41
|
-
};
|