@ankhorage/surface 4.3.0 → 4.4.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 +6 -0
- package/README.md +4 -4
- package/dist/components/tabs/Tabs.js +2 -2
- package/dist/components/tabs/Tabs.js.map +1 -1
- package/dist/components/tabs/context.js +1 -1
- package/dist/components/tabs/context.js.map +1 -1
- package/dist/context/FontContext.d.ts.map +1 -1
- package/dist/context/FontContext.js +3 -3
- package/dist/context/FontContext.js.map +1 -1
- package/dist/context/TranslationContext.d.ts.map +1 -1
- package/dist/context/TranslationContext.js +3 -4
- package/dist/context/TranslationContext.js.map +1 -1
- package/dist/core/responsive/ResponsiveProvider.d.ts.map +1 -1
- package/dist/core/responsive/ResponsiveProvider.js +3 -3
- package/dist/core/responsive/ResponsiveProvider.js.map +1 -1
- package/dist/examples/DocsExamples.js +1 -1
- package/dist/examples/DocsExamples.js.map +1 -1
- package/dist/features/accordion/adapters/inbound/Accordion.js +2 -2
- package/dist/features/accordion/adapters/inbound/Accordion.js.map +1 -1
- package/dist/features/accordion/adapters/inbound/AccordionContent.js +1 -1
- package/dist/features/accordion/adapters/inbound/AccordionContent.js.map +1 -1
- package/dist/features/accordion/adapters/inbound/AccordionItem.js +3 -3
- package/dist/features/accordion/adapters/inbound/AccordionItem.js.map +1 -1
- package/dist/features/accordion/adapters/inbound/AccordionTrigger.js +1 -1
- package/dist/features/accordion/adapters/inbound/AccordionTrigger.js.map +1 -1
- package/dist/features/bottom-sheet/BottomSheetProvider.js +2 -2
- package/dist/features/bottom-sheet/BottomSheetProvider.js.map +1 -1
- package/dist/features/bottom-sheet/useBottomSheet.js +1 -1
- package/dist/features/bottom-sheet/useBottomSheet.js.map +1 -1
- package/dist/features/popover/adapters/inbound/Popover.d.ts +5 -0
- package/dist/features/popover/adapters/inbound/Popover.d.ts.map +1 -0
- package/dist/features/popover/adapters/inbound/Popover.js +31 -0
- package/dist/features/popover/adapters/inbound/Popover.js.map +1 -0
- package/dist/features/popover/adapters/inbound/PopoverOverlay.d.ts +17 -0
- package/dist/features/popover/adapters/inbound/PopoverOverlay.d.ts.map +1 -0
- package/dist/features/popover/adapters/inbound/PopoverOverlay.js +34 -0
- package/dist/features/popover/adapters/inbound/PopoverOverlay.js.map +1 -0
- package/dist/features/popover/adapters/inbound/usePopoverLayout.d.ts +21 -0
- package/dist/features/popover/adapters/inbound/usePopoverLayout.d.ts.map +1 -0
- package/dist/features/popover/adapters/inbound/usePopoverLayout.js +33 -0
- package/dist/features/popover/adapters/inbound/usePopoverLayout.js.map +1 -0
- package/dist/features/popover/public.d.ts +3 -0
- package/dist/features/popover/public.d.ts.map +1 -0
- package/dist/features/popover/public.js +2 -0
- package/dist/features/popover/public.js.map +1 -0
- package/dist/features/popover/utils/resolvePopoverPosition.d.ts +25 -0
- package/dist/features/popover/utils/resolvePopoverPosition.d.ts.map +1 -0
- package/dist/features/popover/utils/resolvePopoverPosition.js +23 -0
- package/dist/features/popover/utils/resolvePopoverPosition.js.map +1 -0
- package/dist/{components/toast → features/toast/adapters/inbound}/Toast.d.ts +2 -1
- package/dist/features/toast/adapters/inbound/Toast.d.ts.map +1 -0
- package/dist/{components/toast → features/toast/adapters/inbound}/Toast.js +37 -32
- package/dist/features/toast/adapters/inbound/Toast.js.map +1 -0
- package/dist/features/toast/adapters/inbound/ToastProvider.d.ts +5 -0
- package/dist/features/toast/adapters/inbound/ToastProvider.d.ts.map +1 -0
- package/dist/features/toast/adapters/inbound/ToastProvider.js +29 -0
- package/dist/features/toast/adapters/inbound/ToastProvider.js.map +1 -0
- package/dist/features/toast/adapters/inbound/useToast.d.ts +4 -0
- package/dist/features/toast/adapters/inbound/useToast.d.ts.map +1 -0
- package/dist/features/toast/adapters/inbound/useToast.js +11 -0
- package/dist/features/toast/adapters/inbound/useToast.js.map +1 -0
- package/dist/features/toast/composition/ToastContext.d.ts +4 -0
- package/dist/features/toast/composition/ToastContext.d.ts.map +1 -0
- package/dist/features/toast/composition/ToastContext.js +4 -0
- package/dist/features/toast/composition/ToastContext.js.map +1 -0
- package/dist/features/toast/composition/useToastRuntime.d.ts +11 -0
- package/dist/features/toast/composition/useToastRuntime.d.ts.map +1 -0
- package/dist/features/toast/composition/useToastRuntime.js +50 -0
- package/dist/features/toast/composition/useToastRuntime.js.map +1 -0
- package/dist/features/toast/public.d.ts +5 -0
- package/dist/features/toast/public.d.ts.map +1 -0
- package/dist/features/toast/public.js +4 -0
- package/dist/features/toast/public.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/overlay/OverlayProvider.d.ts +1 -0
- package/dist/internal/overlay/OverlayProvider.d.ts.map +1 -1
- package/dist/internal/overlay/OverlayProvider.js +9 -7
- package/dist/internal/overlay/OverlayProvider.js.map +1 -1
- package/dist/internal/overlay/useOverlayStack.js +1 -1
- package/dist/internal/overlay/useOverlayStack.js.map +1 -1
- package/dist/internal/resolvers/resolveOverlayZIndex.d.ts +1 -1
- package/dist/internal/resolvers/resolveOverlayZIndex.d.ts.map +1 -1
- package/dist/internal/resolvers/resolveOverlayZIndex.js +1 -0
- package/dist/internal/resolvers/resolveOverlayZIndex.js.map +1 -1
- package/dist/layout/AppBar.js +1 -1
- package/dist/layout/AppBar.js.map +1 -1
- package/dist/theme/ThemeContext.d.ts.map +1 -1
- package/dist/theme/ThemeContext.js +4 -5
- package/dist/theme/ThemeContext.js.map +1 -1
- package/dist/types/popover.d.ts +21 -0
- package/dist/types/popover.d.ts.map +1 -0
- package/dist/types/popover.js +2 -0
- package/dist/types/popover.js.map +1 -0
- package/dist/{components/toast/types.d.ts → types/toast.d.ts} +11 -3
- package/dist/types/toast.d.ts.map +1 -0
- package/dist/types/toast.js +2 -0
- package/dist/types/toast.js.map +1 -0
- package/package.json +1 -1
- package/src/components/tabs/Tabs.tsx +2 -2
- package/src/components/tabs/context.tsx +1 -1
- package/src/context/FontContext.tsx +3 -3
- package/src/context/TranslationContext.tsx +3 -4
- package/src/core/responsive/ResponsiveProvider.tsx +3 -3
- package/src/examples/DocsExamples.tsx +1 -1
- package/src/features/accordion/adapters/inbound/Accordion.tsx +2 -2
- package/src/features/accordion/adapters/inbound/AccordionContent.tsx +1 -1
- package/src/features/accordion/adapters/inbound/AccordionItem.tsx +3 -3
- package/src/features/accordion/adapters/inbound/AccordionTrigger.tsx +1 -1
- package/src/features/bottom-sheet/BottomSheetProvider.tsx +2 -2
- package/src/features/bottom-sheet/useBottomSheet.ts +1 -1
- package/src/features/popover/adapters/inbound/Popover.tsx +49 -0
- package/src/features/popover/adapters/inbound/PopoverOverlay.tsx +72 -0
- package/src/features/popover/adapters/inbound/usePopoverLayout.ts +51 -0
- package/src/features/popover/public.ts +2 -0
- package/src/features/popover/utils/resolvePopoverPosition.test.ts +31 -0
- package/src/features/popover/utils/resolvePopoverPosition.ts +40 -0
- package/src/{components/toast → features/toast/adapters/inbound}/Toast.tsx +58 -54
- package/src/features/toast/adapters/inbound/ToastProvider.tsx +47 -0
- package/src/features/toast/adapters/inbound/useToast.test.tsx +18 -0
- package/src/features/toast/adapters/inbound/useToast.ts +15 -0
- package/src/features/toast/composition/ToastContext.ts +6 -0
- package/src/features/toast/composition/useToastRuntime.ts +76 -0
- package/src/features/toast/public.ts +10 -0
- package/src/index.test.ts +3 -1
- package/src/index.ts +14 -2
- package/src/internal/overlay/OverlayProvider.tsx +10 -8
- package/src/internal/overlay/useOverlayStack.ts +1 -1
- package/src/internal/resolvers/resolveOverlayZIndex.test.ts +2 -1
- package/src/internal/resolvers/resolveOverlayZIndex.ts +2 -1
- package/src/layout/AppBar.tsx +1 -1
- package/src/theme/ThemeContext.tsx +4 -5
- package/src/types/popover.ts +25 -0
- package/src/{components/toast/types.ts → types/toast.ts} +12 -2
- package/dist/components/toast/Toast.d.ts.map +0 -1
- package/dist/components/toast/Toast.js.map +0 -1
- package/dist/components/toast/ToastProvider.d.ts +0 -13
- package/dist/components/toast/ToastProvider.d.ts.map +0 -1
- package/dist/components/toast/ToastProvider.js +0 -70
- package/dist/components/toast/ToastProvider.js.map +0 -1
- package/dist/components/toast/index.d.ts +0 -4
- package/dist/components/toast/index.d.ts.map +0 -1
- package/dist/components/toast/index.js +0 -3
- package/dist/components/toast/index.js.map +0 -1
- package/dist/components/toast/types.d.ts.map +0 -1
- package/dist/components/toast/types.js +0 -2
- package/dist/components/toast/types.js.map +0 -1
- package/src/components/toast/ToastProvider.tsx +0 -115
- package/src/components/toast/index.ts +0 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { createContext,
|
|
1
|
+
import React, { createContext, use, useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
import { useFontContext } from '../context/FontContext';
|
|
4
4
|
import { ResponsiveProvider } from '../core/responsive/ResponsiveProvider';
|
|
@@ -43,7 +43,6 @@ export const ThemeProvider = ({
|
|
|
43
43
|
const [mode, setMode] = React.useState<'light' | 'dark'>(initialMode);
|
|
44
44
|
const { activeFontId } = useFontContext();
|
|
45
45
|
|
|
46
|
-
// Keep state in sync with prop for real-time Studio updates
|
|
47
46
|
React.useEffect(() => {
|
|
48
47
|
if (initialConfig) {
|
|
49
48
|
setConfig((prev) => {
|
|
@@ -73,15 +72,15 @@ export const ThemeProvider = ({
|
|
|
73
72
|
|
|
74
73
|
return (
|
|
75
74
|
<ResponsiveProvider>
|
|
76
|
-
<ThemeContext
|
|
75
|
+
<ThemeContext value={value}>
|
|
77
76
|
<OverlayProvider>{children}</OverlayProvider>
|
|
78
|
-
</ThemeContext
|
|
77
|
+
</ThemeContext>
|
|
79
78
|
</ResponsiveProvider>
|
|
80
79
|
);
|
|
81
80
|
};
|
|
82
81
|
|
|
83
82
|
export const useTheme = () => {
|
|
84
|
-
return
|
|
83
|
+
return use(ThemeContext);
|
|
85
84
|
};
|
|
86
85
|
|
|
87
86
|
export const useThemeConfig = () => {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
|
|
3
|
+
import type { InteractionPolicy } from '../interactionPolicy';
|
|
4
|
+
|
|
5
|
+
export type PopoverPlacement =
|
|
6
|
+
'bottom-start' | 'bottom' | 'bottom-end' | 'top-start' | 'top' | 'top-end';
|
|
7
|
+
|
|
8
|
+
export interface PopoverAnchorRenderProps {
|
|
9
|
+
close: () => void;
|
|
10
|
+
open: boolean;
|
|
11
|
+
toggle: () => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface PopoverProps {
|
|
15
|
+
anchor: (controls: PopoverAnchorRenderProps) => React.ReactNode;
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
closeOnOutsidePress?: boolean;
|
|
18
|
+
defaultOpen?: boolean;
|
|
19
|
+
interactionPolicy?: InteractionPolicy;
|
|
20
|
+
offset?: number;
|
|
21
|
+
onOpenChange?: ((open: boolean) => void) | undefined;
|
|
22
|
+
open?: boolean;
|
|
23
|
+
placement?: PopoverPlacement;
|
|
24
|
+
testID?: string;
|
|
25
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
|
|
3
|
-
import type { InteractionPolicy } from '
|
|
4
|
-
import type { SurfaceStatusColor } from '
|
|
3
|
+
import type { InteractionPolicy } from '../interactionPolicy';
|
|
4
|
+
import type { SurfaceStatusColor } from '../surfaceColor';
|
|
5
5
|
|
|
6
6
|
export type ToastStatus = 'default' | SurfaceStatusColor;
|
|
7
7
|
|
|
@@ -18,3 +18,13 @@ export interface ToastOptions extends Omit<ToastProps, 'onDismiss'> {
|
|
|
18
18
|
duration?: number;
|
|
19
19
|
id?: string;
|
|
20
20
|
}
|
|
21
|
+
|
|
22
|
+
export interface ToastProviderProps {
|
|
23
|
+
children: React.ReactNode;
|
|
24
|
+
defaultDuration?: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ToastController {
|
|
28
|
+
dismissToast: (id: string) => void;
|
|
29
|
+
showToast: (options: ToastOptions) => string;
|
|
30
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../../../src/components/toast/Toast.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAgC1C,wBAAgB,KAAK,CAAC,EACpB,KAAK,EACL,WAAW,EACX,MAAkB,EAClB,SAAS,EACT,iBAA6B,EAC7B,MAAM,GACP,EAAE,UAAU,qBA0CZ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.js","sourceRoot":"","sources":["../../../src/components/toast/Toast.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,GAAG,EAAE,MAAM,8BAA8B,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAIpD,SAAS,uBAAuB,CAAC,KAAmB,EAAE,MAA4B;IAChF,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,SAAS;YACZ,OAAO,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;QACtC,KAAK,SAAS;YACZ,OAAO,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;QACtC,KAAK,OAAO;YACV,OAAO,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC;QACpC,KAAK,MAAM;YACT,OAAO,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;QACnC;YACE,OAAO,KAAK,CAAC,SAAS,CA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AC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CACnC;cAAA,CAAC,KAAK,CACR;YAAA,EAAE,IAAI,CAAC,CACR,CAAC,CAAC,CAAC,IAAI,CACR;UAAA,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CACnE;QAAA,EAAE,GAAG,CACL;QAAA,CAAC,SAAS,CAAC,CAAC,CAAC,CACX,CAAC,SAAS,CACR,kBAAkB,CAAC,sBAAsB,CACzC,iBAAiB,CAAC,QAAQ,CAC1B,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CACzC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAEjD;YAAA,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,IAAI,CACvC;UAAA,EAAE,SAAS,CAAC,CACb,CAAC,CAAC,CAAC,IAAI,CACV;MAAA,EAAE,MAAM,CACV;IAAA,EAAE,OAAO,CAAC,CACX,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\nimport { Pressable } from 'react-native';\n\nimport { Box } from '../../features/layout/public';\nimport { Surface } from '../../features/surface/public';\nimport { Text } from '../../features/typography/public';\nimport { Inline } from '../../layout';\nimport type { SurfaceColor } from '../../surfaceColor';\nimport { useTheme } from '../../theme/ThemeContext';\nimport type { SurfaceTheme } from '../../theme/types';\nimport type { ToastProps } from './types';\n\nfunction resolveToastStatusColor(theme: SurfaceTheme, status: ToastProps['status']) {\n switch (status) {\n case 'success':\n return theme.semantics.success.base;\n case 'warning':\n return theme.semantics.warning.base;\n case 'error':\n return theme.semantics.error.base;\n case 'info':\n return theme.semantics.info.base;\n default:\n return theme.semantics.action.primary.base;\n }\n}\n\nfunction resolveToastStatusTextColor(status: ToastProps['status']): SurfaceColor {\n switch (status) {\n case 'success':\n return 'success';\n case 'warning':\n return 'warning';\n case 'error':\n return 'error';\n case 'info':\n return 'info';\n default:\n return 'primary';\n }\n}\n\nexport function Toast({\n title,\n description,\n status = 'default',\n onDismiss,\n interactionPolicy = 'enabled',\n testID,\n}: ToastProps) {\n const { theme } = useTheme();\n const statusColor = resolveToastStatusColor(theme, status);\n const statusTextColor = resolveToastStatusTextColor(status);\n const passive = interactionPolicy === 'passive';\n\n return (\n <Surface\n p=\"m\"\n style={{\n borderLeftColor: statusColor,\n borderLeftWidth: 3,\n minWidth: 280,\n shadowOpacity: 0.14,\n shadowRadius: 12,\n shadowOffset: { width: 0, height: 6 },\n }}\n testID={testID}\n variant=\"raised\"\n >\n <Inline align=\"center\" justify=\"space-between\">\n <Box flex={1}>\n {title ? (\n <Text variant=\"label\" weight=\"medium\">\n {title}\n </Text>\n ) : null}\n {description ? <Text emphasis=\"muted\">{description}</Text> : null}\n </Box>\n {onDismiss ? (\n <Pressable\n accessibilityLabel=\"Dismiss notification\"\n accessibilityRole=\"button\"\n onPress={passive ? undefined : onDismiss}\n testID={testID ? `${testID}-dismiss` : undefined}\n >\n <Text color={statusTextColor}>×</Text>\n </Pressable>\n ) : null}\n </Inline>\n </Surface>\n );\n}\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { ToastOptions } from './types';
|
|
3
|
-
interface ToastContextValue {
|
|
4
|
-
dismissToast: (id: string) => void;
|
|
5
|
-
showToast: (options: ToastOptions) => string;
|
|
6
|
-
}
|
|
7
|
-
export declare function ToastProvider({ children, defaultDuration, }: {
|
|
8
|
-
children: React.ReactNode;
|
|
9
|
-
defaultDuration?: number;
|
|
10
|
-
}): React.JSX.Element;
|
|
11
|
-
export declare function useToast(): ToastContextValue;
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=ToastProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ToastProvider.d.ts","sourceRoot":"","sources":["../../../src/components/toast/ToastProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAM5C,UAAU,iBAAiB;IACzB,YAAY,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,SAAS,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,MAAM,CAAC;CAC9C;AAMD,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,eAAsB,GACvB,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,qBA6EA;AAED,wBAAgB,QAAQ,sBAQvB"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Stack } from '../../features/layout/public';
|
|
3
|
-
import { Portal } from '../../internal/overlay/Portal';
|
|
4
|
-
import { resolveOverlayAnimation } from '../../internal/resolvers';
|
|
5
|
-
import { Toast } from './Toast';
|
|
6
|
-
const ToastContext = React.createContext(null);
|
|
7
|
-
let toastCounter = 0;
|
|
8
|
-
export function ToastProvider({ children, defaultDuration = 4000, }) {
|
|
9
|
-
const [toasts, setToasts] = React.useState([]);
|
|
10
|
-
const animation = resolveOverlayAnimation('toast');
|
|
11
|
-
const timersRef = React.useRef(new Map());
|
|
12
|
-
const dismissToast = React.useCallback((id) => {
|
|
13
|
-
const timer = timersRef.current.get(id);
|
|
14
|
-
if (timer) {
|
|
15
|
-
clearTimeout(timer);
|
|
16
|
-
timersRef.current.delete(id);
|
|
17
|
-
}
|
|
18
|
-
setToasts((current) => current.filter((toast) => toast.id !== id));
|
|
19
|
-
}, []);
|
|
20
|
-
const showToast = React.useCallback((options) => {
|
|
21
|
-
const id = options.id ?? `toast-${toastCounter++}`;
|
|
22
|
-
setToasts((current) => [...current, { ...options, id }]);
|
|
23
|
-
return id;
|
|
24
|
-
}, []);
|
|
25
|
-
React.useEffect(() => {
|
|
26
|
-
toasts.forEach((toast) => {
|
|
27
|
-
if (timersRef.current.has(toast.id)) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
const timer = setTimeout(() => {
|
|
31
|
-
dismissToast(toast.id);
|
|
32
|
-
}, toast.duration ?? defaultDuration);
|
|
33
|
-
timersRef.current.set(toast.id, timer);
|
|
34
|
-
});
|
|
35
|
-
const activeToastIds = new Set(toasts.map((toast) => toast.id));
|
|
36
|
-
timersRef.current.forEach((timer, id) => {
|
|
37
|
-
if (!activeToastIds.has(id)) {
|
|
38
|
-
clearTimeout(timer);
|
|
39
|
-
timersRef.current.delete(id);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}, [defaultDuration, dismissToast, toasts]);
|
|
43
|
-
React.useEffect(() => {
|
|
44
|
-
const timers = timersRef.current;
|
|
45
|
-
return () => {
|
|
46
|
-
timers.forEach((timer) => clearTimeout(timer));
|
|
47
|
-
timers.clear();
|
|
48
|
-
};
|
|
49
|
-
}, []);
|
|
50
|
-
return (<ToastContext.Provider value={{ dismissToast, showToast }}>
|
|
51
|
-
{children}
|
|
52
|
-
<Portal layer="toast" visible={toasts.length > 0}>
|
|
53
|
-
<Stack gap="s" pointerEvents="box-none" style={{
|
|
54
|
-
alignItems: 'flex-end',
|
|
55
|
-
padding: 16,
|
|
56
|
-
paddingTop: 16 + animation.offset,
|
|
57
|
-
}}>
|
|
58
|
-
{toasts.map((toast) => (<Toast description={toast.description} key={toast.id} onDismiss={() => dismissToast(toast.id)} status={toast.status} testID={toast.testID} title={toast.title}/>))}
|
|
59
|
-
</Stack>
|
|
60
|
-
</Portal>
|
|
61
|
-
</ToastContext.Provider>);
|
|
62
|
-
}
|
|
63
|
-
export function useToast() {
|
|
64
|
-
const context = React.useContext(ToastContext);
|
|
65
|
-
if (!context) {
|
|
66
|
-
throw new Error('useToast must be used within <ToastProvider>.');
|
|
67
|
-
}
|
|
68
|
-
return context;
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=ToastProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ToastProvider.js","sourceRoot":"","sources":["../../../src/components/toast/ToastProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAYhC,MAAM,YAAY,GAAG,KAAK,CAAC,aAAa,CAA2B,IAAI,CAAC,CAAC;AAEzE,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB,MAAM,UAAU,aAAa,CAAC,EAC5B,QAAQ,EACR,eAAe,GAAG,IAAI,GAIvB;IACC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAe,EAAE,CAAC,CAAC;IAC7D,MAAM,SAAS,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;IACnD,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,GAAG,EAAyC,CAAC,CAAC;IAEjF,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,EAAU,EAAE,EAAE;QACpD,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACxC,IAAI,KAAK,EAAE,CAAC;YACV,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC/B,CAAC;QACD,SAAS,CAAC,CAAC,OAAO,EAAE,EAA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CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CACrB,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CACrB,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,EACnB,CACH,CAAC,CACJ;QAAA,EAAE,KAAK,CACT;MAAA,EAAE,MAAM,CACV;IAAA,EAAE,YAAY,CAAC,QAAQ,CAAC,CACzB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,QAAQ;IACtB,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAE/C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACnE,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import React from 'react';\n\nimport { Stack } from '../../features/layout/public';\nimport { Portal } from '../../internal/overlay/Portal';\nimport { resolveOverlayAnimation } from '../../internal/resolvers';\nimport { Toast } from './Toast';\nimport type { ToastOptions } from './types';\n\ninterface ToastEntry extends ToastOptions {\n id: string;\n}\n\ninterface ToastContextValue {\n dismissToast: (id: string) => void;\n showToast: (options: ToastOptions) => string;\n}\n\nconst ToastContext = React.createContext<ToastContextValue | null>(null);\n\nlet toastCounter = 0;\n\nexport function ToastProvider({\n children,\n defaultDuration = 4000,\n}: {\n children: React.ReactNode;\n defaultDuration?: number;\n}) {\n const [toasts, setToasts] = React.useState<ToastEntry[]>([]);\n const animation = resolveOverlayAnimation('toast');\n const timersRef = React.useRef(new Map<string, ReturnType<typeof setTimeout>>());\n\n const dismissToast = React.useCallback((id: string) => {\n const timer = timersRef.current.get(id);\n if (timer) {\n clearTimeout(timer);\n timersRef.current.delete(id);\n }\n setToasts((current) => current.filter((toast) => toast.id !== id));\n }, []);\n\n const showToast = React.useCallback((options: ToastOptions) => {\n const id = options.id ?? `toast-${toastCounter++}`;\n setToasts((current) => [...current, { ...options, id }]);\n return id;\n }, []);\n\n React.useEffect(() => {\n toasts.forEach((toast) => {\n if (timersRef.current.has(toast.id)) {\n return;\n }\n\n const timer = setTimeout(() => {\n dismissToast(toast.id);\n }, toast.duration ?? defaultDuration);\n\n timersRef.current.set(toast.id, timer);\n });\n\n const activeToastIds = new Set(toasts.map((toast) => toast.id));\n timersRef.current.forEach((timer, id) => {\n if (!activeToastIds.has(id)) {\n clearTimeout(timer);\n timersRef.current.delete(id);\n }\n });\n }, [defaultDuration, dismissToast, toasts]);\n\n React.useEffect(() => {\n const timers = timersRef.current;\n return () => {\n timers.forEach((timer) => clearTimeout(timer));\n timers.clear();\n };\n }, []);\n\n return (\n <ToastContext.Provider value={{ dismissToast, showToast }}>\n {children}\n <Portal layer=\"toast\" visible={toasts.length > 0}>\n <Stack\n gap=\"s\"\n pointerEvents=\"box-none\"\n style={{\n alignItems: 'flex-end',\n padding: 16,\n paddingTop: 16 + animation.offset,\n }}\n >\n {toasts.map((toast) => (\n <Toast\n description={toast.description}\n key={toast.id}\n onDismiss={() => dismissToast(toast.id)}\n status={toast.status}\n testID={toast.testID}\n title={toast.title}\n />\n ))}\n </Stack>\n </Portal>\n </ToastContext.Provider>\n );\n}\n\nexport function useToast() {\n const context = React.useContext(ToastContext);\n\n if (!context) {\n throw new Error('useToast must be used within <ToastProvider>.');\n }\n\n return context;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/toast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC1D,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/toast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["export { Toast } from './Toast';\nexport { ToastProvider, useToast } from './ToastProvider';\nexport type { ToastOptions, ToastProps, ToastStatus } from './types';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/toast/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,kBAAkB,CAAC;AAEzD,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IACrC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC;IACjE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/toast/types.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\n\nimport type { InteractionPolicy } from '../../interactionPolicy';\nimport type { SurfaceStatusColor } from '../../surfaceColor';\n\nexport type ToastStatus = 'default' | SurfaceStatusColor;\n\nexport interface ToastProps {\n title?: React.ReactNode;\n description?: React.ReactNode;\n status?: ToastStatus;\n onDismiss?: (() => void) | undefined;\n interactionPolicy?: InteractionPolicy;\n testID?: string;\n}\n\nexport interface ToastOptions extends Omit<ToastProps, 'onDismiss'> {\n duration?: number;\n id?: string;\n}\n"]}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { Stack } from '../../features/layout/public';
|
|
4
|
-
import { Portal } from '../../internal/overlay/Portal';
|
|
5
|
-
import { resolveOverlayAnimation } from '../../internal/resolvers';
|
|
6
|
-
import { Toast } from './Toast';
|
|
7
|
-
import type { ToastOptions } from './types';
|
|
8
|
-
|
|
9
|
-
interface ToastEntry extends ToastOptions {
|
|
10
|
-
id: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface ToastContextValue {
|
|
14
|
-
dismissToast: (id: string) => void;
|
|
15
|
-
showToast: (options: ToastOptions) => string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const ToastContext = React.createContext<ToastContextValue | null>(null);
|
|
19
|
-
|
|
20
|
-
let toastCounter = 0;
|
|
21
|
-
|
|
22
|
-
export function ToastProvider({
|
|
23
|
-
children,
|
|
24
|
-
defaultDuration = 4000,
|
|
25
|
-
}: {
|
|
26
|
-
children: React.ReactNode;
|
|
27
|
-
defaultDuration?: number;
|
|
28
|
-
}) {
|
|
29
|
-
const [toasts, setToasts] = React.useState<ToastEntry[]>([]);
|
|
30
|
-
const animation = resolveOverlayAnimation('toast');
|
|
31
|
-
const timersRef = React.useRef(new Map<string, ReturnType<typeof setTimeout>>());
|
|
32
|
-
|
|
33
|
-
const dismissToast = React.useCallback((id: string) => {
|
|
34
|
-
const timer = timersRef.current.get(id);
|
|
35
|
-
if (timer) {
|
|
36
|
-
clearTimeout(timer);
|
|
37
|
-
timersRef.current.delete(id);
|
|
38
|
-
}
|
|
39
|
-
setToasts((current) => current.filter((toast) => toast.id !== id));
|
|
40
|
-
}, []);
|
|
41
|
-
|
|
42
|
-
const showToast = React.useCallback((options: ToastOptions) => {
|
|
43
|
-
const id = options.id ?? `toast-${toastCounter++}`;
|
|
44
|
-
setToasts((current) => [...current, { ...options, id }]);
|
|
45
|
-
return id;
|
|
46
|
-
}, []);
|
|
47
|
-
|
|
48
|
-
React.useEffect(() => {
|
|
49
|
-
toasts.forEach((toast) => {
|
|
50
|
-
if (timersRef.current.has(toast.id)) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const timer = setTimeout(() => {
|
|
55
|
-
dismissToast(toast.id);
|
|
56
|
-
}, toast.duration ?? defaultDuration);
|
|
57
|
-
|
|
58
|
-
timersRef.current.set(toast.id, timer);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const activeToastIds = new Set(toasts.map((toast) => toast.id));
|
|
62
|
-
timersRef.current.forEach((timer, id) => {
|
|
63
|
-
if (!activeToastIds.has(id)) {
|
|
64
|
-
clearTimeout(timer);
|
|
65
|
-
timersRef.current.delete(id);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}, [defaultDuration, dismissToast, toasts]);
|
|
69
|
-
|
|
70
|
-
React.useEffect(() => {
|
|
71
|
-
const timers = timersRef.current;
|
|
72
|
-
return () => {
|
|
73
|
-
timers.forEach((timer) => clearTimeout(timer));
|
|
74
|
-
timers.clear();
|
|
75
|
-
};
|
|
76
|
-
}, []);
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<ToastContext.Provider value={{ dismissToast, showToast }}>
|
|
80
|
-
{children}
|
|
81
|
-
<Portal layer="toast" visible={toasts.length > 0}>
|
|
82
|
-
<Stack
|
|
83
|
-
gap="s"
|
|
84
|
-
pointerEvents="box-none"
|
|
85
|
-
style={{
|
|
86
|
-
alignItems: 'flex-end',
|
|
87
|
-
padding: 16,
|
|
88
|
-
paddingTop: 16 + animation.offset,
|
|
89
|
-
}}
|
|
90
|
-
>
|
|
91
|
-
{toasts.map((toast) => (
|
|
92
|
-
<Toast
|
|
93
|
-
description={toast.description}
|
|
94
|
-
key={toast.id}
|
|
95
|
-
onDismiss={() => dismissToast(toast.id)}
|
|
96
|
-
status={toast.status}
|
|
97
|
-
testID={toast.testID}
|
|
98
|
-
title={toast.title}
|
|
99
|
-
/>
|
|
100
|
-
))}
|
|
101
|
-
</Stack>
|
|
102
|
-
</Portal>
|
|
103
|
-
</ToastContext.Provider>
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export function useToast() {
|
|
108
|
-
const context = React.useContext(ToastContext);
|
|
109
|
-
|
|
110
|
-
if (!context) {
|
|
111
|
-
throw new Error('useToast must be used within <ToastProvider>.');
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return context;
|
|
115
|
-
}
|