@ankhorage/surface 5.0.1 → 7.0.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 +12 -0
- package/README.md +1 -2
- package/dist/{layout → core/responsive}/Show.d.ts +2 -1
- package/dist/core/responsive/Show.d.ts.map +1 -0
- package/dist/{layout → core/responsive}/Show.js +3 -1
- package/dist/core/responsive/Show.js.map +1 -0
- package/dist/core/responsive/index.d.ts +1 -0
- package/dist/core/responsive/index.d.ts.map +1 -1
- package/dist/core/responsive/index.js +1 -0
- package/dist/core/responsive/index.js.map +1 -1
- package/dist/features/app-bar/adapters/inbound/AppBar.d.ts +5 -0
- package/dist/features/app-bar/adapters/inbound/AppBar.d.ts.map +1 -0
- package/dist/features/app-bar/adapters/inbound/AppBar.js +40 -0
- package/dist/features/app-bar/adapters/inbound/AppBar.js.map +1 -0
- package/dist/features/app-bar/public.d.ts +3 -0
- package/dist/features/app-bar/public.d.ts.map +1 -0
- package/dist/features/app-bar/public.js +2 -0
- package/dist/features/app-bar/public.js.map +1 -0
- package/dist/features/badge/adapters/inbound/Badge.js +3 -3
- package/dist/features/badge/adapters/inbound/Badge.js.map +1 -1
- package/dist/features/button/adapters/inbound/Button.js +8 -8
- package/dist/features/button/adapters/inbound/Button.js.map +1 -1
- package/dist/features/button/adapters/inbound/IconButton.js +3 -3
- package/dist/features/button/adapters/inbound/IconButton.js.map +1 -1
- package/dist/features/form/checkbox/adapters/inbound/Checkbox.js +7 -7
- package/dist/features/form/checkbox/adapters/inbound/Checkbox.js.map +1 -1
- package/dist/{components/field → features/form/field/adapters/inbound}/Field.d.ts +2 -1
- package/dist/features/form/field/adapters/inbound/Field.d.ts.map +1 -0
- package/dist/features/form/field/adapters/inbound/Field.js +40 -0
- package/dist/features/form/field/adapters/inbound/Field.js.map +1 -0
- package/dist/features/form/field/public.d.ts +3 -0
- package/dist/features/form/field/public.d.ts.map +1 -0
- package/dist/features/form/field/public.js +2 -0
- package/dist/features/form/field/public.js.map +1 -0
- package/dist/features/form/radio/adapters/inbound/Radio.js +8 -8
- package/dist/features/form/radio/adapters/inbound/Radio.js.map +1 -1
- package/dist/{components/switch → features/form/switch/adapters/inbound}/Switch.d.ts +2 -1
- package/dist/features/form/switch/adapters/inbound/Switch.d.ts.map +1 -0
- package/dist/features/form/switch/adapters/inbound/Switch.js +52 -0
- package/dist/features/form/switch/adapters/inbound/Switch.js.map +1 -0
- package/dist/features/form/switch/public.d.ts +3 -0
- package/dist/features/form/switch/public.d.ts.map +1 -0
- package/dist/features/form/switch/public.js +2 -0
- package/dist/features/form/switch/public.js.map +1 -0
- package/dist/features/form/text-input/adapters/inbound/TextInput.d.ts.map +1 -1
- package/dist/features/form/text-input/adapters/inbound/TextInput.js +8 -4
- package/dist/features/form/text-input/adapters/inbound/TextInput.js.map +1 -1
- package/dist/features/layout/adapters/inbound/Divider.js +2 -2
- package/dist/features/layout/adapters/inbound/Divider.js.map +1 -1
- package/dist/features/layout/adapters/inbound/Grid.d.ts.map +1 -1
- package/dist/features/layout/adapters/inbound/Grid.js +7 -9
- package/dist/features/layout/adapters/inbound/Grid.js.map +1 -1
- package/dist/features/layout/adapters/inbound/ScrollView.d.ts +5 -0
- package/dist/features/layout/adapters/inbound/ScrollView.d.ts.map +1 -0
- package/dist/features/layout/adapters/inbound/ScrollView.js +69 -0
- package/dist/features/layout/adapters/inbound/ScrollView.js.map +1 -0
- package/dist/features/layout/adapters/inbound/View.d.ts +5 -0
- package/dist/features/layout/adapters/inbound/View.d.ts.map +1 -0
- package/dist/features/layout/adapters/inbound/View.js +17 -0
- package/dist/features/layout/adapters/inbound/View.js.map +1 -0
- package/dist/features/layout/public.d.ts +3 -4
- package/dist/features/layout/public.d.ts.map +1 -1
- package/dist/features/layout/public.js +2 -3
- package/dist/features/layout/public.js.map +1 -1
- package/dist/features/list/adapters/inbound/List.d.ts +5 -0
- package/dist/features/list/adapters/inbound/List.d.ts.map +1 -0
- package/dist/features/list/adapters/inbound/List.js +7 -0
- package/dist/features/list/adapters/inbound/List.js.map +1 -0
- package/dist/features/list/adapters/inbound/ListItem.d.ts +5 -0
- package/dist/features/list/adapters/inbound/ListItem.d.ts.map +1 -0
- package/dist/features/list/adapters/inbound/ListItem.js +59 -0
- package/dist/features/list/adapters/inbound/ListItem.js.map +1 -0
- package/dist/features/list/public.d.ts +4 -0
- package/dist/features/list/public.d.ts.map +1 -0
- package/dist/features/list/public.js +3 -0
- package/dist/features/list/public.js.map +1 -0
- package/dist/features/modal/adapters/inbound/Modal.d.ts.map +1 -1
- package/dist/features/modal/adapters/inbound/Modal.js +8 -8
- package/dist/features/modal/adapters/inbound/Modal.js.map +1 -1
- package/dist/features/popover-menu/adapters/inbound/PopoverMenu.d.ts.map +1 -1
- package/dist/features/popover-menu/adapters/inbound/PopoverMenu.js +11 -12
- package/dist/features/popover-menu/adapters/inbound/PopoverMenu.js.map +1 -1
- package/dist/features/surface/adapters/inbound/Surface.d.ts +1 -1
- package/dist/features/surface/adapters/inbound/Surface.d.ts.map +1 -1
- package/dist/features/surface/adapters/inbound/Surface.js +3 -3
- package/dist/features/surface/adapters/inbound/Surface.js.map +1 -1
- package/dist/features/tabs/adapters/inbound/Tab.js +3 -3
- package/dist/features/tabs/adapters/inbound/Tab.js.map +1 -1
- package/dist/features/tabs/adapters/inbound/TabList.d.ts.map +1 -1
- package/dist/features/tabs/adapters/inbound/TabList.js +3 -5
- package/dist/features/tabs/adapters/inbound/TabList.js.map +1 -1
- package/dist/features/tabs/adapters/inbound/Tabs.js +2 -2
- package/dist/features/tabs/adapters/inbound/Tabs.js.map +1 -1
- package/dist/features/toast/adapters/inbound/Toast.js +5 -5
- package/dist/features/toast/adapters/inbound/Toast.js.map +1 -1
- package/dist/features/toast/adapters/inbound/ToastProvider.js +3 -3
- package/dist/features/toast/adapters/inbound/ToastProvider.js.map +1 -1
- package/dist/index.d.ts +10 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -8
- package/dist/index.js.map +1 -1
- package/dist/primitives/button-base/ButtonBase.d.ts +1 -0
- package/dist/primitives/button-base/ButtonBase.d.ts.map +1 -1
- package/dist/primitives/button-base/ButtonBase.js +6 -5
- package/dist/primitives/button-base/ButtonBase.js.map +1 -1
- package/dist/primitives/button-base/types.d.ts +2 -2
- package/dist/primitives/button-base/types.d.ts.map +1 -1
- package/dist/primitives/button-base/types.js.map +1 -1
- package/dist/types/app-bar.d.ts +12 -0
- package/dist/types/app-bar.d.ts.map +1 -0
- package/dist/types/app-bar.js +2 -0
- package/dist/types/app-bar.js.map +1 -0
- package/dist/{components/field/types.d.ts → types/field.d.ts} +1 -1
- package/dist/types/field.d.ts.map +1 -0
- package/dist/types/field.js +2 -0
- package/dist/types/field.js.map +1 -0
- package/dist/types/layout.d.ts +15 -17
- package/dist/types/layout.d.ts.map +1 -1
- package/dist/types/layout.js.map +1 -1
- package/dist/types/list.d.ts +20 -0
- package/dist/types/list.d.ts.map +1 -0
- package/dist/types/list.js +2 -0
- package/dist/types/list.js.map +1 -0
- package/dist/types/surface.d.ts +2 -2
- package/dist/types/surface.d.ts.map +1 -1
- package/dist/types/surface.js.map +1 -1
- package/dist/{components/switch/types.d.ts → types/switch.d.ts} +4 -4
- package/dist/types/switch.d.ts.map +1 -0
- package/dist/types/switch.js +2 -0
- package/dist/types/switch.js.map +1 -0
- package/dist/utils/resolveViewStyles.d.ts +7 -0
- package/dist/utils/resolveViewStyles.d.ts.map +1 -0
- package/dist/utils/{resolveBoxStyles.js → resolveViewStyles.js} +11 -4
- package/dist/utils/resolveViewStyles.js.map +1 -0
- package/package.json +1 -1
- package/src/{layout → core/responsive}/Show.tsx +4 -1
- package/src/core/responsive/index.ts +1 -0
- package/src/features/app-bar/adapters/inbound/AppBar.tsx +69 -0
- package/src/features/app-bar/public.ts +2 -0
- package/src/features/badge/adapters/inbound/Badge.tsx +3 -3
- package/src/features/button/adapters/inbound/Button.tsx +8 -8
- package/src/features/button/adapters/inbound/IconButton.tsx +3 -3
- package/src/features/form/checkbox/adapters/inbound/Checkbox.tsx +7 -7
- package/src/features/form/field/adapters/inbound/Field.tsx +82 -0
- package/src/features/form/field/public.ts +2 -0
- package/src/features/form/radio/adapters/inbound/Radio.tsx +8 -8
- package/src/features/form/switch/adapters/inbound/Switch.tsx +123 -0
- package/src/features/form/switch/public.ts +2 -0
- package/src/features/form/text-input/adapters/inbound/TextInput.tsx +21 -5
- package/src/features/layout/adapters/inbound/Divider.tsx +2 -2
- package/src/features/layout/adapters/inbound/Grid.tsx +12 -14
- package/src/features/layout/adapters/inbound/ScrollView.tsx +102 -0
- package/src/features/layout/adapters/inbound/{Box.tsx → View.tsx} +9 -9
- package/src/features/layout/public.ts +3 -10
- package/src/features/list/adapters/inbound/List.tsx +9 -0
- package/src/features/list/adapters/inbound/ListItem.tsx +128 -0
- package/src/features/list/public.test.ts +13 -0
- package/src/features/list/public.ts +3 -0
- package/src/features/modal/adapters/inbound/Modal.tsx +11 -8
- package/src/features/popover-menu/adapters/inbound/PopoverMenu.tsx +11 -14
- package/src/features/surface/adapters/inbound/Surface.tsx +3 -3
- package/src/features/tabs/adapters/inbound/Tab.tsx +3 -3
- package/src/features/tabs/adapters/inbound/TabList.tsx +3 -6
- package/src/features/tabs/adapters/inbound/Tabs.tsx +2 -2
- package/src/features/toast/adapters/inbound/Toast.tsx +5 -5
- package/src/features/toast/adapters/inbound/ToastProvider.tsx +3 -3
- package/src/index.test.ts +26 -48
- package/src/index.ts +10 -21
- package/src/primitives/button-base/ButtonBase.tsx +6 -8
- package/src/primitives/button-base/types.ts +2 -2
- package/src/types/app-bar.ts +13 -0
- package/src/types/layout.ts +25 -20
- package/src/types/list.ts +22 -0
- package/src/types/surface.ts +2 -2
- package/src/{components/switch/types.ts → types/switch.ts} +3 -3
- package/src/utils/resolveViewStyles.test.ts +71 -0
- package/src/utils/{resolveBoxStyles.ts → resolveViewStyles.ts} +16 -9
- package/src/webAcceptance.test.tsx +8 -9
- package/dist/components/field/Field.d.ts.map +0 -1
- package/dist/components/field/Field.js +0 -26
- package/dist/components/field/Field.js.map +0 -1
- package/dist/components/field/index.d.ts +0 -3
- package/dist/components/field/index.d.ts.map +0 -1
- package/dist/components/field/index.js +0 -2
- package/dist/components/field/index.js.map +0 -1
- package/dist/components/field/types.d.ts.map +0 -1
- package/dist/components/field/types.js +0 -2
- package/dist/components/field/types.js.map +0 -1
- package/dist/components/helper-text/HelperText.d.ts +0 -4
- package/dist/components/helper-text/HelperText.d.ts.map +0 -1
- package/dist/components/helper-text/HelperText.js +0 -8
- package/dist/components/helper-text/HelperText.js.map +0 -1
- package/dist/components/helper-text/index.d.ts +0 -3
- package/dist/components/helper-text/index.d.ts.map +0 -1
- package/dist/components/helper-text/index.js +0 -2
- package/dist/components/helper-text/index.js.map +0 -1
- package/dist/components/helper-text/types.d.ts +0 -9
- package/dist/components/helper-text/types.d.ts.map +0 -1
- package/dist/components/helper-text/types.js +0 -2
- package/dist/components/helper-text/types.js.map +0 -1
- package/dist/components/label/Label.d.ts +0 -4
- package/dist/components/label/Label.d.ts.map +0 -1
- package/dist/components/label/Label.js +0 -11
- package/dist/components/label/Label.js.map +0 -1
- package/dist/components/label/index.d.ts +0 -3
- package/dist/components/label/index.d.ts.map +0 -1
- package/dist/components/label/index.js +0 -2
- package/dist/components/label/index.js.map +0 -1
- package/dist/components/label/types.d.ts +0 -10
- package/dist/components/label/types.d.ts.map +0 -1
- package/dist/components/label/types.js +0 -2
- package/dist/components/label/types.js.map +0 -1
- package/dist/components/list-item/ListItem.d.ts +0 -4
- package/dist/components/list-item/ListItem.d.ts.map +0 -1
- package/dist/components/list-item/ListItem.js +0 -43
- package/dist/components/list-item/ListItem.js.map +0 -1
- package/dist/components/list-item/index.d.ts +0 -3
- package/dist/components/list-item/index.d.ts.map +0 -1
- package/dist/components/list-item/index.js +0 -2
- package/dist/components/list-item/index.js.map +0 -1
- package/dist/components/list-item/types.d.ts +0 -11
- package/dist/components/list-item/types.d.ts.map +0 -1
- package/dist/components/list-item/types.js +0 -2
- package/dist/components/list-item/types.js.map +0 -1
- package/dist/components/switch/Switch.d.ts.map +0 -1
- package/dist/components/switch/Switch.js +0 -71
- package/dist/components/switch/Switch.js.map +0 -1
- package/dist/components/switch/index.d.ts +0 -3
- package/dist/components/switch/index.d.ts.map +0 -1
- package/dist/components/switch/index.js +0 -2
- package/dist/components/switch/index.js.map +0 -1
- package/dist/components/switch/types.d.ts.map +0 -1
- package/dist/components/switch/types.js +0 -2
- package/dist/components/switch/types.js.map +0 -1
- package/dist/components/textarea/Textarea.d.ts +0 -4
- package/dist/components/textarea/Textarea.d.ts.map +0 -1
- package/dist/components/textarea/Textarea.js +0 -6
- package/dist/components/textarea/Textarea.js.map +0 -1
- package/dist/components/textarea/index.d.ts +0 -3
- package/dist/components/textarea/index.d.ts.map +0 -1
- package/dist/components/textarea/index.js +0 -2
- package/dist/components/textarea/index.js.map +0 -1
- package/dist/components/textarea/types.d.ts +0 -5
- package/dist/components/textarea/types.d.ts.map +0 -1
- package/dist/components/textarea/types.js +0 -2
- package/dist/components/textarea/types.js.map +0 -1
- package/dist/features/layout/adapters/inbound/Box.d.ts +0 -5
- package/dist/features/layout/adapters/inbound/Box.d.ts.map +0 -1
- package/dist/features/layout/adapters/inbound/Box.js +0 -17
- package/dist/features/layout/adapters/inbound/Box.js.map +0 -1
- package/dist/features/layout/adapters/inbound/Container.d.ts +0 -5
- package/dist/features/layout/adapters/inbound/Container.d.ts.map +0 -1
- package/dist/features/layout/adapters/inbound/Container.js +0 -28
- package/dist/features/layout/adapters/inbound/Container.js.map +0 -1
- package/dist/features/layout/adapters/inbound/Stack.d.ts +0 -5
- package/dist/features/layout/adapters/inbound/Stack.d.ts.map +0 -1
- package/dist/features/layout/adapters/inbound/Stack.js +0 -27
- package/dist/features/layout/adapters/inbound/Stack.js.map +0 -1
- package/dist/layout/AppBar.d.ts +0 -13
- package/dist/layout/AppBar.d.ts.map +0 -1
- package/dist/layout/AppBar.js +0 -30
- package/dist/layout/AppBar.js.map +0 -1
- package/dist/layout/Center.d.ts +0 -7
- package/dist/layout/Center.d.ts.map +0 -1
- package/dist/layout/Center.js +0 -12
- package/dist/layout/Center.js.map +0 -1
- package/dist/layout/Inline.d.ts +0 -5
- package/dist/layout/Inline.d.ts.map +0 -1
- package/dist/layout/Inline.js +0 -6
- package/dist/layout/Inline.js.map +0 -1
- package/dist/layout/ScrollArea.d.ts +0 -9
- package/dist/layout/ScrollArea.d.ts.map +0 -1
- package/dist/layout/ScrollArea.js +0 -52
- package/dist/layout/ScrollArea.js.map +0 -1
- package/dist/layout/Show.d.ts.map +0 -1
- package/dist/layout/Show.js.map +0 -1
- package/dist/layout/Spacer.d.ts +0 -9
- package/dist/layout/Spacer.d.ts.map +0 -1
- package/dist/layout/Spacer.js +0 -12
- package/dist/layout/Spacer.js.map +0 -1
- package/dist/layout/Template.d.ts +0 -18
- package/dist/layout/Template.d.ts.map +0 -1
- package/dist/layout/Template.js +0 -36
- package/dist/layout/Template.js.map +0 -1
- package/dist/layout/index.d.ts +0 -15
- package/dist/layout/index.d.ts.map +0 -1
- package/dist/layout/index.js +0 -8
- package/dist/layout/index.js.map +0 -1
- package/dist/utils/resolveBoxStyles.d.ts +0 -7
- package/dist/utils/resolveBoxStyles.d.ts.map +0 -1
- package/dist/utils/resolveBoxStyles.js.map +0 -1
- package/src/components/field/Field.tsx +0 -51
- package/src/components/field/index.ts +0 -2
- package/src/components/helper-text/HelperText.tsx +0 -12
- package/src/components/helper-text/index.ts +0 -2
- package/src/components/helper-text/types.ts +0 -10
- package/src/components/label/Label.tsx +0 -23
- package/src/components/label/index.ts +0 -2
- package/src/components/label/types.ts +0 -11
- package/src/components/list-item/ListItem.tsx +0 -72
- package/src/components/list-item/index.ts +0 -2
- package/src/components/list-item/types.ts +0 -11
- package/src/components/switch/Switch.tsx +0 -118
- package/src/components/switch/index.ts +0 -2
- package/src/components/textarea/Textarea.tsx +0 -15
- package/src/components/textarea/index.ts +0 -2
- package/src/components/textarea/types.ts +0 -5
- package/src/features/layout/adapters/inbound/Container.tsx +0 -43
- package/src/features/layout/adapters/inbound/Stack.test.ts +0 -13
- package/src/features/layout/adapters/inbound/Stack.tsx +0 -44
- package/src/layout/AppBar.tsx +0 -60
- package/src/layout/Center.tsx +0 -22
- package/src/layout/Inline.tsx +0 -9
- package/src/layout/ScrollArea.tsx +0 -116
- package/src/layout/Spacer.tsx +0 -22
- package/src/layout/Template.tsx +0 -86
- package/src/layout/index.ts +0 -14
- package/src/utils/resolveBoxStyles.test.ts +0 -54
- /package/src/{components/field/types.ts → types/field.ts} +0 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ScrollView as ReactNativeScrollView } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { useResponsiveRuntime } from '../../../../core/responsive';
|
|
5
|
+
import { useTheme } from '../../../../theme/ThemeContext';
|
|
6
|
+
import type { ScrollViewProps } from '../../../../types/layout';
|
|
7
|
+
import { resolveViewStyles } from '../../../../utils/resolveViewStyles';
|
|
8
|
+
|
|
9
|
+
/*** Renders the token-aware responsive Surface adapter for React Native ScrollView. */
|
|
10
|
+
export function ScrollView(props: ScrollViewProps) {
|
|
11
|
+
const { theme } = useTheme();
|
|
12
|
+
const { breakpoint } = useResponsiveRuntime();
|
|
13
|
+
const spacing = splitSpacingProps(props);
|
|
14
|
+
const visual = splitVisualProps(spacing.rest);
|
|
15
|
+
const dimensions = splitDimensionProps(visual.rest);
|
|
16
|
+
const layout = splitLayoutProps(dimensions.rest);
|
|
17
|
+
const { children, contentContainerStyle, style, ...scrollProps } = layout.rest;
|
|
18
|
+
const resolved = resolveViewStyles(theme, breakpoint, {
|
|
19
|
+
...spacing.styleProps,
|
|
20
|
+
...visual.styleProps,
|
|
21
|
+
...dimensions.styleProps,
|
|
22
|
+
...layout.styleProps,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<ReactNativeScrollView
|
|
27
|
+
{...scrollProps}
|
|
28
|
+
contentContainerStyle={contentContainerStyle}
|
|
29
|
+
style={[resolved, style]}
|
|
30
|
+
>
|
|
31
|
+
{children}
|
|
32
|
+
</ReactNativeScrollView>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/*** Splits spacing-aware Surface props from native ScrollView props. */
|
|
37
|
+
function splitSpacingProps(props: ScrollViewProps) {
|
|
38
|
+
const { p, px, py, pt, pb, pl, pr, m, mx, my, mt, mb, ml, mr, gap, rowGap, columnGap, ...rest } =
|
|
39
|
+
props;
|
|
40
|
+
return {
|
|
41
|
+
rest,
|
|
42
|
+
styleProps: { p, px, py, pt, pb, pl, pr, m, mx, my, mt, mb, ml, mr, gap, rowGap, columnGap },
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/*** Splits token-aware visual Surface props from native ScrollView props. */
|
|
47
|
+
function splitVisualProps(props: ReturnType<typeof splitSpacingProps>['rest']) {
|
|
48
|
+
const { bg, radius, borderWidth, borderColor, ...rest } = props;
|
|
49
|
+
return { rest, styleProps: { bg, radius, borderWidth, borderColor } };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/*** Splits responsive dimension Surface props from native ScrollView props. */
|
|
53
|
+
function splitDimensionProps(props: ReturnType<typeof splitVisualProps>['rest']) {
|
|
54
|
+
const { width, height, minWidth, maxWidth, minHeight, maxHeight, ...rest } = props;
|
|
55
|
+
return { rest, styleProps: { width, height, minWidth, maxWidth, minHeight, maxHeight } };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/*** Splits responsive flex and positioning Surface props from native ScrollView props. */
|
|
59
|
+
function splitLayoutProps(props: ReturnType<typeof splitDimensionProps>['rest']) {
|
|
60
|
+
const {
|
|
61
|
+
flex,
|
|
62
|
+
flexGrow,
|
|
63
|
+
flexShrink,
|
|
64
|
+
flexBasis,
|
|
65
|
+
direction,
|
|
66
|
+
align,
|
|
67
|
+
justify,
|
|
68
|
+
wrap,
|
|
69
|
+
alignSelf,
|
|
70
|
+
position,
|
|
71
|
+
top,
|
|
72
|
+
bottom,
|
|
73
|
+
left,
|
|
74
|
+
right,
|
|
75
|
+
overflow,
|
|
76
|
+
zIndex,
|
|
77
|
+
opacity,
|
|
78
|
+
...rest
|
|
79
|
+
} = props;
|
|
80
|
+
return {
|
|
81
|
+
rest,
|
|
82
|
+
styleProps: {
|
|
83
|
+
flex,
|
|
84
|
+
flexGrow,
|
|
85
|
+
flexShrink,
|
|
86
|
+
flexBasis,
|
|
87
|
+
direction,
|
|
88
|
+
align,
|
|
89
|
+
justify,
|
|
90
|
+
wrap,
|
|
91
|
+
alignSelf,
|
|
92
|
+
position,
|
|
93
|
+
top,
|
|
94
|
+
bottom,
|
|
95
|
+
left,
|
|
96
|
+
right,
|
|
97
|
+
overflow,
|
|
98
|
+
zIndex,
|
|
99
|
+
opacity,
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
2
|
+
import { View as ReactNativeView } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import { useResponsiveRuntime } from '../../../../core/responsive';
|
|
5
5
|
import { resolvePointerEvents } from '../../../../internal/resolvePointerEvents';
|
|
6
6
|
import { useTheme } from '../../../../theme/ThemeContext';
|
|
7
|
-
import type {
|
|
8
|
-
import {
|
|
7
|
+
import type { ViewProps } from '../../../../types/layout';
|
|
8
|
+
import { resolveViewStyles } from '../../../../utils/resolveViewStyles';
|
|
9
9
|
|
|
10
|
-
/*** Renders the responsive
|
|
11
|
-
export function
|
|
10
|
+
/*** Renders the token-aware responsive Surface adapter for React Native View. */
|
|
11
|
+
export function View({
|
|
12
12
|
accessible,
|
|
13
13
|
accessibilityLabel,
|
|
14
14
|
accessibilityRole,
|
|
@@ -18,14 +18,14 @@ export function Box({
|
|
|
18
18
|
style,
|
|
19
19
|
testID,
|
|
20
20
|
...props
|
|
21
|
-
}:
|
|
21
|
+
}: ViewProps) {
|
|
22
22
|
const { theme } = useTheme();
|
|
23
23
|
const { breakpoint } = useResponsiveRuntime();
|
|
24
|
-
const resolved =
|
|
24
|
+
const resolved = resolveViewStyles(theme, breakpoint, props);
|
|
25
25
|
const resolvedPointerEvents = pointerEvents ? resolvePointerEvents(pointerEvents) : null;
|
|
26
26
|
|
|
27
27
|
return (
|
|
28
|
-
<
|
|
28
|
+
<ReactNativeView
|
|
29
29
|
{...resolvedPointerEvents?.props}
|
|
30
30
|
accessible={accessible}
|
|
31
31
|
accessibilityLabel={accessibilityLabel}
|
|
@@ -35,6 +35,6 @@ export function Box({
|
|
|
35
35
|
style={[resolved, resolvedPointerEvents?.style, style]}
|
|
36
36
|
>
|
|
37
37
|
{children}
|
|
38
|
-
</
|
|
38
|
+
</ReactNativeView>
|
|
39
39
|
);
|
|
40
40
|
}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
BoxProps,
|
|
3
|
-
ContainerProps,
|
|
4
|
-
DividerProps,
|
|
5
|
-
GridProps,
|
|
6
|
-
StackProps,
|
|
7
|
-
} from '../../types/layout';
|
|
8
|
-
export { Box } from './adapters/inbound/Box';
|
|
9
|
-
export { Container } from './adapters/inbound/Container';
|
|
1
|
+
export type { DividerProps, GridProps, ScrollViewProps, ViewProps } from '../../types/layout';
|
|
10
2
|
export { Divider } from './adapters/inbound/Divider';
|
|
11
3
|
export { Grid } from './adapters/inbound/Grid';
|
|
12
|
-
export {
|
|
4
|
+
export { ScrollView } from './adapters/inbound/ScrollView';
|
|
5
|
+
export { View } from './adapters/inbound/View';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import type { ListProps } from '../../../../types/list';
|
|
4
|
+
import { View } from '../../../layout/public';
|
|
5
|
+
|
|
6
|
+
/*** Groups list items under one neutral Surface list boundary. */
|
|
7
|
+
export function List({ children, testID }: ListProps) {
|
|
8
|
+
return <View testID={testID}>{children}</View>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { ButtonBase } from '../../../../primitives/button-base';
|
|
4
|
+
import { useTheme } from '../../../../theme/ThemeContext';
|
|
5
|
+
import type { SurfaceTheme } from '../../../../theme/types';
|
|
6
|
+
import type { ListItemProps } from '../../../../types/list';
|
|
7
|
+
import { View } from '../../../layout/public';
|
|
8
|
+
import { Text } from '../../../typography/public';
|
|
9
|
+
|
|
10
|
+
/*** Renders a static or interactive list item with shared row geometry and interaction states. */
|
|
11
|
+
export function ListItem(props: ListItemProps) {
|
|
12
|
+
const { theme } = useTheme();
|
|
13
|
+
if (!props.onPress) return renderStaticListItem(props, theme);
|
|
14
|
+
return renderInteractiveListItem({ ...props, onPress: props.onPress }, theme);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/*** Renders a non-pressable list item. */
|
|
18
|
+
function renderStaticListItem(props: ListItemProps, theme: SurfaceTheme) {
|
|
19
|
+
return (
|
|
20
|
+
<ListItemContent
|
|
21
|
+
{...props}
|
|
22
|
+
backgroundColor={props.selected ? theme.semantics.selection.background : 'transparent'}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/*** Renders a pressable list item with shared interaction-state presentation. */
|
|
28
|
+
function renderInteractiveListItem(
|
|
29
|
+
props: ListItemProps & { onPress: NonNullable<ListItemProps['onPress']> },
|
|
30
|
+
theme: SurfaceTheme,
|
|
31
|
+
) {
|
|
32
|
+
return (
|
|
33
|
+
<ButtonBase
|
|
34
|
+
accessibilityLabel={props.accessibilityLabel}
|
|
35
|
+
accessibilityRole="button"
|
|
36
|
+
accessibilityState={{ disabled: props.disabled ?? false, selected: props.selected ?? false }}
|
|
37
|
+
disabled={props.disabled ?? false}
|
|
38
|
+
interactionPolicy={props.interactionPolicy}
|
|
39
|
+
onPress={props.onPress}
|
|
40
|
+
testID={props.testID}
|
|
41
|
+
>
|
|
42
|
+
{(state) => (
|
|
43
|
+
<ListItemContent
|
|
44
|
+
{...props}
|
|
45
|
+
backgroundColor={resolveListItemBackground(theme, {
|
|
46
|
+
hovered: state.hovered,
|
|
47
|
+
pressed: state.pressed,
|
|
48
|
+
selected: props.selected ?? false,
|
|
49
|
+
})}
|
|
50
|
+
disabled={state.disabled}
|
|
51
|
+
testID={undefined}
|
|
52
|
+
/>
|
|
53
|
+
)}
|
|
54
|
+
</ButtonBase>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface ListItemBackgroundState {
|
|
59
|
+
hovered: boolean;
|
|
60
|
+
pressed: boolean;
|
|
61
|
+
selected: boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
type ListItemContentProps = Omit<
|
|
65
|
+
ListItemProps,
|
|
66
|
+
'accessibilityLabel' | 'interactionPolicy' | 'onPress' | 'selected'
|
|
67
|
+
> & {
|
|
68
|
+
backgroundColor: string;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/*** Resolves the neutral list-item background for one interaction state. */
|
|
72
|
+
function resolveListItemBackground(theme: SurfaceTheme, state: ListItemBackgroundState) {
|
|
73
|
+
if (state.pressed) return theme.semantics.neutral.surfaceActive;
|
|
74
|
+
if (state.hovered) return theme.semantics.neutral.surfaceHover;
|
|
75
|
+
if (state.selected) return theme.semantics.selection.background;
|
|
76
|
+
return 'transparent';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/*** Renders the shared visual row content for static and interactive list items. */
|
|
80
|
+
function ListItemContent({
|
|
81
|
+
backgroundColor,
|
|
82
|
+
children,
|
|
83
|
+
compact = false,
|
|
84
|
+
description,
|
|
85
|
+
disabled = false,
|
|
86
|
+
leading,
|
|
87
|
+
testID,
|
|
88
|
+
title,
|
|
89
|
+
trailing,
|
|
90
|
+
}: ListItemContentProps) {
|
|
91
|
+
const content = children ?? renderDefaultContent(title, description);
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<View
|
|
95
|
+
align="center"
|
|
96
|
+
bg={backgroundColor}
|
|
97
|
+
direction="row"
|
|
98
|
+
gap="m"
|
|
99
|
+
opacity={disabled ? 0.72 : 1}
|
|
100
|
+
px="m"
|
|
101
|
+
py={compact ? 's' : 'm'}
|
|
102
|
+
testID={testID}
|
|
103
|
+
>
|
|
104
|
+
{leading !== undefined ? <View>{leading}</View> : null}
|
|
105
|
+
<View flex={1}>{content}</View>
|
|
106
|
+
{trailing !== undefined ? <View>{trailing}</View> : null}
|
|
107
|
+
</View>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/*** Renders the default title and description content when custom children are absent. */
|
|
112
|
+
function renderDefaultContent(title: React.ReactNode, description: React.ReactNode) {
|
|
113
|
+
if (title === undefined && description === undefined) return null;
|
|
114
|
+
return (
|
|
115
|
+
<View flex={1} gap="xs">
|
|
116
|
+
{title !== undefined ? (
|
|
117
|
+
<Text numberOfLines={1} variant="body" weight="medium">
|
|
118
|
+
{title}
|
|
119
|
+
</Text>
|
|
120
|
+
) : null}
|
|
121
|
+
{description !== undefined ? (
|
|
122
|
+
<Text emphasis="muted" numberOfLines={2} variant="bodySmall">
|
|
123
|
+
{description}
|
|
124
|
+
</Text>
|
|
125
|
+
) : null}
|
|
126
|
+
</View>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { expect, test } from 'bun:test';
|
|
2
|
+
|
|
3
|
+
test('list capability owns List and ListItem under one feature boundary', async () => {
|
|
4
|
+
const listSource = await Bun.file('src/features/list/adapters/inbound/List.tsx').text();
|
|
5
|
+
const listItemSource = await Bun.file('src/features/list/adapters/inbound/ListItem.tsx').text();
|
|
6
|
+
|
|
7
|
+
expect(listSource).toContain('export function List');
|
|
8
|
+
expect(listItemSource).toContain('export function ListItem');
|
|
9
|
+
expect(listItemSource).toContain('interactionPolicy={props.interactionPolicy}');
|
|
10
|
+
expect(listItemSource).toContain('selected');
|
|
11
|
+
expect(listItemSource).toContain('compact');
|
|
12
|
+
expect(listItemSource).not.toContain('components/list-item');
|
|
13
|
+
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Pressable, StyleSheet, View, type ViewStyle } from 'react-native';
|
|
2
|
+
import { Pressable, StyleSheet, View as ReactNativeView, type ViewStyle } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import { FocusScope } from '../../../../internal/focus/FocusScope';
|
|
5
5
|
import { Portal } from '../../../../internal/overlay/Portal';
|
|
6
6
|
import { resolvePointerEvents } from '../../../../internal/resolvePointerEvents';
|
|
7
7
|
import { resolveOverlayAnimation } from '../../../../internal/resolvers';
|
|
8
|
-
import { Center } from '../../../../layout';
|
|
9
8
|
import { useTheme } from '../../../../theme/ThemeContext';
|
|
10
9
|
import type { ModalProps } from '../../../../types/modal';
|
|
10
|
+
import { View } from '../../../layout/public';
|
|
11
11
|
import { Surface } from '../../../surface/public';
|
|
12
12
|
|
|
13
13
|
const boxNonePointerEvents = resolvePointerEvents('box-none');
|
|
@@ -30,7 +30,10 @@ export function Modal({
|
|
|
30
30
|
|
|
31
31
|
return (
|
|
32
32
|
<Portal layer="modal" visible={visible}>
|
|
33
|
-
<
|
|
33
|
+
<ReactNativeView
|
|
34
|
+
{...boxNonePointerEvents.props}
|
|
35
|
+
style={[boxNonePointerEvents.style, styles.fill]}
|
|
36
|
+
>
|
|
34
37
|
<Pressable
|
|
35
38
|
onPress={backdropPress}
|
|
36
39
|
style={[
|
|
@@ -44,15 +47,15 @@ export function Modal({
|
|
|
44
47
|
onEscape={passive ? undefined : onDismiss}
|
|
45
48
|
testID={testID ? `${testID}-focus` : undefined}
|
|
46
49
|
>
|
|
47
|
-
<
|
|
48
|
-
<
|
|
50
|
+
<View align="center" justify="center" p="l" style={styles.center}>
|
|
51
|
+
<ReactNativeView accessible accessibilityViewIsModal style={styles.content}>
|
|
49
52
|
<Surface p="l" style={styles.surface} testID={testID} variant="raised">
|
|
50
53
|
{children}
|
|
51
54
|
</Surface>
|
|
52
|
-
</
|
|
53
|
-
</
|
|
55
|
+
</ReactNativeView>
|
|
56
|
+
</View>
|
|
54
57
|
</FocusScope>
|
|
55
|
-
</
|
|
58
|
+
</ReactNativeView>
|
|
56
59
|
</Portal>
|
|
57
60
|
);
|
|
58
61
|
}
|
|
@@ -3,10 +3,9 @@ import { Pressable } from 'react-native';
|
|
|
3
3
|
|
|
4
4
|
import { FocusScope } from '../../../../internal/focus/FocusScope';
|
|
5
5
|
import { useFocusManager } from '../../../../internal/focus/useFocusManager';
|
|
6
|
-
import { Inline } from '../../../../layout';
|
|
7
6
|
import { useTheme } from '../../../../theme/ThemeContext';
|
|
8
7
|
import type { PopoverMenuAction, PopoverMenuProps } from '../../../../types/popoverMenu';
|
|
9
|
-
import {
|
|
8
|
+
import { View } from '../../../layout/public';
|
|
10
9
|
import { Popover } from '../../../popover/public';
|
|
11
10
|
import { Surface } from '../../../surface/public';
|
|
12
11
|
import { Text } from '../../../typography/public';
|
|
@@ -103,10 +102,8 @@ function usePopoverMenuKeyboard({
|
|
|
103
102
|
() =>
|
|
104
103
|
bindKeydown((event) => {
|
|
105
104
|
if (passive) return;
|
|
106
|
-
|
|
107
105
|
const { key } = event;
|
|
108
106
|
if (key === undefined) return;
|
|
109
|
-
|
|
110
107
|
if (['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(key)) {
|
|
111
108
|
event.preventDefault();
|
|
112
109
|
setActiveIndex((current) => resolveNextMenuIndex(actions, current, key));
|
|
@@ -152,7 +149,7 @@ function PopoverMenuItem({
|
|
|
152
149
|
onPress={passive ? undefined : () => activateAction(action)}
|
|
153
150
|
testID={testID ? `${testID}-item-${action.id}` : undefined}
|
|
154
151
|
>
|
|
155
|
-
<
|
|
152
|
+
<View
|
|
156
153
|
bg={selected ? theme.semantics.action.neutral.softBg : 'transparent'}
|
|
157
154
|
opacity={action.disabled ? 0.56 : 1}
|
|
158
155
|
px="m"
|
|
@@ -160,7 +157,7 @@ function PopoverMenuItem({
|
|
|
160
157
|
radius="s"
|
|
161
158
|
>
|
|
162
159
|
<PopoverMenuItemContent action={action} active={active} />
|
|
163
|
-
</
|
|
160
|
+
</View>
|
|
164
161
|
</Pressable>
|
|
165
162
|
);
|
|
166
163
|
}
|
|
@@ -177,10 +174,10 @@ function PopoverMenuItemContent({
|
|
|
177
174
|
action.intent === 'danger' ? 'danger' : active || action.selected ? 'neutral' : undefined;
|
|
178
175
|
|
|
179
176
|
return (
|
|
180
|
-
<
|
|
181
|
-
{action.leading ? <
|
|
182
|
-
<
|
|
183
|
-
<
|
|
177
|
+
<View align="center" direction="row" gap="s" justify="space-between" wrap="nowrap">
|
|
178
|
+
{action.leading ? <View>{action.leading}</View> : null}
|
|
179
|
+
<View flex={1}>
|
|
180
|
+
<View gap="xxs">
|
|
184
181
|
<Text
|
|
185
182
|
color={titleColor}
|
|
186
183
|
variant="bodySmall"
|
|
@@ -193,9 +190,9 @@ function PopoverMenuItemContent({
|
|
|
193
190
|
{action.description}
|
|
194
191
|
</Text>
|
|
195
192
|
) : null}
|
|
196
|
-
</
|
|
197
|
-
</
|
|
198
|
-
{action.trailing ? <
|
|
199
|
-
</
|
|
193
|
+
</View>
|
|
194
|
+
</View>
|
|
195
|
+
{action.trailing ? <View>{action.trailing}</View> : null}
|
|
196
|
+
</View>
|
|
200
197
|
);
|
|
201
198
|
}
|
|
@@ -3,9 +3,9 @@ import type { ViewStyle } from 'react-native';
|
|
|
3
3
|
|
|
4
4
|
import { useTheme } from '../../../../theme/ThemeContext';
|
|
5
5
|
import type { SurfaceProps, SurfaceVariant } from '../../../../types/surface';
|
|
6
|
-
import {
|
|
6
|
+
import { View } from '../../../layout/public';
|
|
7
7
|
|
|
8
|
-
/*** Renders a themed
|
|
8
|
+
/*** Renders a themed content surface with semantic elevation and border variants. */
|
|
9
9
|
export function Surface({ variant = 'default', radius = 'm', style, ...props }: SurfaceProps) {
|
|
10
10
|
const { theme } = useTheme();
|
|
11
11
|
const backgroundColor =
|
|
@@ -17,7 +17,7 @@ export function Surface({ variant = 'default', radius = 'm', style, ...props }:
|
|
|
17
17
|
const borderColor = theme.semantics.border.default;
|
|
18
18
|
|
|
19
19
|
return (
|
|
20
|
-
<
|
|
20
|
+
<View
|
|
21
21
|
{...props}
|
|
22
22
|
radius={radius}
|
|
23
23
|
style={[resolveSurfaceVariantStyles(variant, borderColor, backgroundColor), style]}
|
|
@@ -3,7 +3,7 @@ import { Pressable, type ViewStyle } from 'react-native';
|
|
|
3
3
|
|
|
4
4
|
import { useTheme } from '../../../../theme/ThemeContext';
|
|
5
5
|
import type { TabProps } from '../../../../types/tabs';
|
|
6
|
-
import {
|
|
6
|
+
import { View } from '../../../layout/public';
|
|
7
7
|
import { Text } from '../../../typography/public';
|
|
8
8
|
import { useTabRegistration } from '../../composition/useTabRegistration';
|
|
9
9
|
import { useTabsContext } from '../../composition/useTabsContext';
|
|
@@ -37,7 +37,7 @@ export function Tab({
|
|
|
37
37
|
ref={pressableRef}
|
|
38
38
|
testID={testID}
|
|
39
39
|
>
|
|
40
|
-
<
|
|
40
|
+
<View
|
|
41
41
|
px="m"
|
|
42
42
|
py="s"
|
|
43
43
|
style={resolveTabStyle({
|
|
@@ -50,7 +50,7 @@ export function Tab({
|
|
|
50
50
|
<Text color={selected ? 'primary' : undefined} variant="label" weight="medium">
|
|
51
51
|
{children}
|
|
52
52
|
</Text>
|
|
53
|
-
</
|
|
53
|
+
</View>
|
|
54
54
|
</Pressable>
|
|
55
55
|
);
|
|
56
56
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { StyleSheet } from 'react-native';
|
|
3
2
|
|
|
4
3
|
import { useFocusManager } from '../../../../internal/focus/useFocusManager';
|
|
5
4
|
import type { TabListProps, TabNavigationKey } from '../../../../types/tabs';
|
|
6
|
-
import {
|
|
5
|
+
import { View } from '../../../layout/public';
|
|
7
6
|
import { useTabsContext } from '../../composition/useTabsContext';
|
|
8
7
|
import { resolveNextTabValue } from '../../utils/resolveNextTabValue';
|
|
9
8
|
|
|
@@ -36,9 +35,9 @@ export function TabList({ children, testID }: TabListProps) {
|
|
|
36
35
|
}, [bindKeydown, focusedValue, setActiveValue, tabs]);
|
|
37
36
|
|
|
38
37
|
return (
|
|
39
|
-
<
|
|
38
|
+
<View accessibilityRole="tablist" direction="row" testID={testID}>
|
|
40
39
|
{children}
|
|
41
|
-
</
|
|
40
|
+
</View>
|
|
42
41
|
);
|
|
43
42
|
}
|
|
44
43
|
|
|
@@ -46,5 +45,3 @@ export function TabList({ children, testID }: TabListProps) {
|
|
|
46
45
|
function isTabNavigationKey(key: string | undefined): key is TabNavigationKey {
|
|
47
46
|
return key !== undefined && navigationKeys.includes(key);
|
|
48
47
|
}
|
|
49
|
-
|
|
50
|
-
const styles = StyleSheet.create({ list: { flexDirection: 'row' } });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import type { TabsProps } from '../../../../types/tabs';
|
|
4
|
-
import {
|
|
4
|
+
import { View } from '../../../layout/public';
|
|
5
5
|
import { TabsContext } from '../../composition/TabsContext';
|
|
6
6
|
import { useTabsController } from '../../composition/useTabsController';
|
|
7
7
|
|
|
@@ -11,7 +11,7 @@ export function Tabs({ children, ...props }: TabsProps) {
|
|
|
11
11
|
|
|
12
12
|
return (
|
|
13
13
|
<TabsContext value={contextValue}>
|
|
14
|
-
<
|
|
14
|
+
<View testID={props.testID}>{children}</View>
|
|
15
15
|
</TabsContext>
|
|
16
16
|
);
|
|
17
17
|
}
|
|
@@ -5,7 +5,7 @@ import type { SurfaceColor } from '../../../../surfaceColor';
|
|
|
5
5
|
import { useTheme } from '../../../../theme/ThemeContext';
|
|
6
6
|
import type { SurfaceTheme } from '../../../../theme/types';
|
|
7
7
|
import type { ToastProps } from '../../../../types/toast';
|
|
8
|
-
import {
|
|
8
|
+
import { View } from '../../../layout/public';
|
|
9
9
|
import { Surface } from '../../../surface/public';
|
|
10
10
|
import { Text } from '../../../typography/public';
|
|
11
11
|
|
|
@@ -29,15 +29,15 @@ export function Toast({
|
|
|
29
29
|
|
|
30
30
|
return (
|
|
31
31
|
<Surface p="m" style={[styles.root, statusStyle]} testID={testID} variant="raised">
|
|
32
|
-
<
|
|
33
|
-
<
|
|
32
|
+
<View align="center" direction="row" justify="space-between">
|
|
33
|
+
<View flex={1}>
|
|
34
34
|
{title ? (
|
|
35
35
|
<Text variant="label" weight="medium">
|
|
36
36
|
{title}
|
|
37
37
|
</Text>
|
|
38
38
|
) : null}
|
|
39
39
|
{description ? <Text emphasis="muted">{description}</Text> : null}
|
|
40
|
-
</
|
|
40
|
+
</View>
|
|
41
41
|
{onDismiss ? (
|
|
42
42
|
<Pressable
|
|
43
43
|
accessibilityLabel="Dismiss notification"
|
|
@@ -48,7 +48,7 @@ export function Toast({
|
|
|
48
48
|
<Text color={statusTextColor}>×</Text>
|
|
49
49
|
</Pressable>
|
|
50
50
|
) : null}
|
|
51
|
-
</
|
|
51
|
+
</View>
|
|
52
52
|
</Surface>
|
|
53
53
|
);
|
|
54
54
|
}
|
|
@@ -4,7 +4,7 @@ import { StyleSheet, type ViewStyle } from 'react-native';
|
|
|
4
4
|
import { Portal } from '../../../../internal/overlay/Portal';
|
|
5
5
|
import { resolveOverlayAnimation } from '../../../../internal/resolvers';
|
|
6
6
|
import type { ToastProviderProps } from '../../../../types/toast';
|
|
7
|
-
import {
|
|
7
|
+
import { View } from '../../../layout/public';
|
|
8
8
|
import { ToastContext } from '../../composition/ToastContext';
|
|
9
9
|
import { useToastRuntime } from '../../composition/useToastRuntime';
|
|
10
10
|
import { Toast } from './Toast';
|
|
@@ -22,7 +22,7 @@ export function ToastProvider({ children, defaultDuration = 4000 }: ToastProvide
|
|
|
22
22
|
<ToastContext value={controller}>
|
|
23
23
|
{children}
|
|
24
24
|
<Portal layer="toast" visible={toasts.length > 0}>
|
|
25
|
-
<
|
|
25
|
+
<View gap="s" pointerEvents="box-none" style={[styles.container, animationStyle]}>
|
|
26
26
|
{toasts.map((toast) => (
|
|
27
27
|
<Toast
|
|
28
28
|
description={toast.description}
|
|
@@ -33,7 +33,7 @@ export function ToastProvider({ children, defaultDuration = 4000 }: ToastProvide
|
|
|
33
33
|
title={toast.title}
|
|
34
34
|
/>
|
|
35
35
|
))}
|
|
36
|
-
</
|
|
36
|
+
</View>
|
|
37
37
|
</Portal>
|
|
38
38
|
</ToastContext>
|
|
39
39
|
);
|