@ankhorage/surface 5.0.0 → 5.0.1
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 +2 -2
- package/dist/{components/modal → features/modal/adapters/inbound}/Modal.d.ts +2 -1
- package/dist/features/modal/adapters/inbound/Modal.d.ts.map +1 -0
- package/dist/features/modal/adapters/inbound/Modal.js +51 -0
- package/dist/features/modal/adapters/inbound/Modal.js.map +1 -0
- package/dist/features/modal/public.d.ts +3 -0
- package/dist/features/modal/public.d.ts.map +1 -0
- package/dist/features/modal/public.js +2 -0
- package/dist/features/modal/public.js.map +1 -0
- package/dist/features/tabs/adapters/inbound/Tab.d.ts +5 -0
- package/dist/features/tabs/adapters/inbound/Tab.d.ts.map +1 -0
- package/dist/features/tabs/adapters/inbound/Tab.js +33 -0
- package/dist/features/tabs/adapters/inbound/Tab.js.map +1 -0
- package/dist/features/tabs/adapters/inbound/TabList.d.ts +5 -0
- package/dist/features/tabs/adapters/inbound/TabList.d.ts.map +1 -0
- package/dist/features/tabs/adapters/inbound/TabList.js +42 -0
- package/dist/features/tabs/adapters/inbound/TabList.js.map +1 -0
- package/dist/features/tabs/adapters/inbound/TabPanel.d.ts +5 -0
- package/dist/features/tabs/adapters/inbound/TabPanel.d.ts.map +1 -0
- package/dist/features/tabs/adapters/inbound/TabPanel.js +14 -0
- package/dist/features/tabs/adapters/inbound/TabPanel.js.map +1 -0
- package/dist/features/tabs/adapters/inbound/Tabs.d.ts +5 -0
- package/dist/features/tabs/adapters/inbound/Tabs.d.ts.map +1 -0
- package/dist/features/tabs/adapters/inbound/Tabs.js +12 -0
- package/dist/features/tabs/adapters/inbound/Tabs.js.map +1 -0
- package/dist/features/tabs/composition/TabsContext.d.ts +4 -0
- package/dist/features/tabs/composition/TabsContext.d.ts.map +1 -0
- package/dist/features/tabs/composition/TabsContext.js +3 -0
- package/dist/features/tabs/composition/TabsContext.js.map +1 -0
- package/dist/features/tabs/composition/useTabRegistration.d.ts +7 -0
- package/dist/features/tabs/composition/useTabRegistration.d.ts.map +1 -0
- package/dist/features/tabs/composition/useTabRegistration.js +20 -0
- package/dist/features/tabs/composition/useTabRegistration.js.map +1 -0
- package/dist/features/tabs/composition/useTabsContext.d.ts +4 -0
- package/dist/features/tabs/composition/useTabsContext.d.ts.map +1 -0
- package/dist/{components/tabs/context.js → features/tabs/composition/useTabsContext.js} +4 -4
- package/dist/features/tabs/composition/useTabsContext.js.map +1 -0
- package/dist/features/tabs/composition/useTabsController.d.ts +4 -0
- package/dist/features/tabs/composition/useTabsController.d.ts.map +1 -0
- package/dist/features/tabs/composition/useTabsController.js +43 -0
- package/dist/features/tabs/composition/useTabsController.js.map +1 -0
- package/dist/features/tabs/public.d.ts +6 -0
- package/dist/features/tabs/public.d.ts.map +1 -0
- package/dist/features/tabs/public.js +5 -0
- package/dist/features/tabs/public.js.map +1 -0
- package/dist/features/tabs/utils/resolveNextTabValue.d.ts +4 -0
- package/dist/features/tabs/utils/resolveNextTabValue.d.ts.map +1 -0
- package/dist/{components/tabs/navigation.js → features/tabs/utils/resolveNextTabValue.js} +10 -13
- package/dist/features/tabs/utils/resolveNextTabValue.js.map +1 -0
- package/dist/features/tabs/utils/resolveTabElementId.d.ts +3 -0
- package/dist/features/tabs/utils/resolveTabElementId.d.ts.map +1 -0
- package/dist/features/tabs/utils/resolveTabElementId.js +10 -0
- package/dist/features/tabs/utils/resolveTabElementId.js.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/{components/modal/types.d.ts → types/modal.d.ts} +2 -2
- package/dist/types/modal.d.ts.map +1 -0
- package/dist/types/modal.js +2 -0
- package/dist/types/modal.js.map +1 -0
- package/dist/types/tabs.d.ts +43 -0
- package/dist/types/tabs.d.ts.map +1 -0
- package/dist/types/tabs.js +2 -0
- package/dist/types/tabs.js.map +1 -0
- package/package.json +1 -1
- package/src/features/modal/adapters/inbound/Modal.tsx +74 -0
- package/src/features/modal/public.ts +2 -0
- package/src/features/tabs/adapters/inbound/Tab.tsx +67 -0
- package/src/features/tabs/adapters/inbound/TabList.tsx +50 -0
- package/src/{components/tabs → features/tabs/adapters/inbound}/TabPanel.tsx +6 -10
- package/src/features/tabs/adapters/inbound/Tabs.tsx +17 -0
- package/src/features/tabs/composition/TabsContext.tsx +5 -0
- package/src/features/tabs/composition/useTabRegistration.ts +27 -0
- package/src/features/tabs/composition/useTabsContext.ts +13 -0
- package/src/features/tabs/composition/useTabsController.ts +55 -0
- package/src/features/tabs/public.ts +5 -0
- package/src/{components/tabs/navigation.test.ts → features/tabs/utils/resolveNextTabValue.test.ts} +2 -2
- package/src/features/tabs/utils/resolveNextTabValue.ts +24 -0
- package/src/features/tabs/utils/resolveTabElementId.test.ts +19 -0
- package/src/features/tabs/utils/resolveTabElementId.ts +14 -0
- package/src/index.test.ts +4 -2
- package/src/index.ts +4 -4
- package/src/{components/modal/types.ts → types/modal.ts} +1 -1
- package/src/types/tabs.ts +51 -0
- package/dist/components/modal/Modal.d.ts.map +0 -1
- package/dist/components/modal/Modal.js +0 -59
- package/dist/components/modal/Modal.js.map +0 -1
- package/dist/components/modal/index.d.ts +0 -3
- package/dist/components/modal/index.d.ts.map +0 -1
- package/dist/components/modal/index.js +0 -2
- package/dist/components/modal/index.js.map +0 -1
- package/dist/components/modal/types.d.ts.map +0 -1
- package/dist/components/modal/types.js +0 -2
- package/dist/components/modal/types.js.map +0 -1
- package/dist/components/tabs/Tab.d.ts +0 -4
- package/dist/components/tabs/Tab.d.ts.map +0 -1
- package/dist/components/tabs/Tab.js +0 -48
- package/dist/components/tabs/Tab.js.map +0 -1
- package/dist/components/tabs/TabList.d.ts +0 -4
- package/dist/components/tabs/TabList.d.ts.map +0 -1
- package/dist/components/tabs/TabList.js +0 -37
- package/dist/components/tabs/TabList.js.map +0 -1
- package/dist/components/tabs/TabPanel.d.ts +0 -4
- package/dist/components/tabs/TabPanel.d.ts.map +0 -1
- package/dist/components/tabs/TabPanel.js +0 -16
- package/dist/components/tabs/TabPanel.js.map +0 -1
- package/dist/components/tabs/Tabs.d.ts +0 -4
- package/dist/components/tabs/Tabs.d.ts.map +0 -1
- package/dist/components/tabs/Tabs.js +0 -54
- package/dist/components/tabs/Tabs.js.map +0 -1
- package/dist/components/tabs/a11y.d.ts +0 -3
- package/dist/components/tabs/a11y.d.ts.map +0 -1
- package/dist/components/tabs/a11y.js +0 -13
- package/dist/components/tabs/a11y.js.map +0 -1
- package/dist/components/tabs/context.d.ts +0 -20
- package/dist/components/tabs/context.d.ts.map +0 -1
- package/dist/components/tabs/context.js.map +0 -1
- package/dist/components/tabs/index.d.ts +0 -6
- package/dist/components/tabs/index.d.ts.map +0 -1
- package/dist/components/tabs/index.js +0 -5
- package/dist/components/tabs/index.js.map +0 -1
- package/dist/components/tabs/navigation.d.ts +0 -3
- package/dist/components/tabs/navigation.d.ts.map +0 -1
- package/dist/components/tabs/navigation.js.map +0 -1
- package/dist/components/tabs/types.d.ts +0 -26
- package/dist/components/tabs/types.d.ts.map +0 -1
- package/dist/components/tabs/types.js +0 -2
- package/dist/components/tabs/types.js.map +0 -1
- package/src/components/modal/Modal.tsx +0 -96
- package/src/components/modal/index.ts +0 -2
- package/src/components/tabs/Tab.tsx +0 -89
- package/src/components/tabs/TabList.tsx +0 -51
- package/src/components/tabs/Tabs.tsx +0 -67
- package/src/components/tabs/a11y.test.ts +0 -15
- package/src/components/tabs/a11y.ts +0 -15
- package/src/components/tabs/context.tsx +0 -31
- package/src/components/tabs/index.ts +0 -5
- package/src/components/tabs/navigation.ts +0 -32
- package/src/components/tabs/types.ts +0 -30
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*** Creates a stable tab or tab-panel id from a Tabs test id and tab value. */
|
|
2
|
+
export function resolveTabElementId(
|
|
3
|
+
kind: 'tab' | 'panel',
|
|
4
|
+
testID: string | undefined,
|
|
5
|
+
value: string,
|
|
6
|
+
): string {
|
|
7
|
+
const base = testID ? `${testID}-tabs` : 'tabs';
|
|
8
|
+
return `${base}-${kind}-${sanitizeTabValue(value)}`;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/*** Normalizes a tab value for use inside an accessibility id. */
|
|
12
|
+
function sanitizeTabValue(value: string): string {
|
|
13
|
+
return value.trim().replace(/[^a-zA-Z0-9_-]+/g, '-');
|
|
14
|
+
}
|
package/src/index.test.ts
CHANGED
|
@@ -28,9 +28,11 @@ const expectedFeatureRootExports = [
|
|
|
28
28
|
"export { Image } from './features/image/public';",
|
|
29
29
|
"export { KeyboardAvoidingView } from './features/keyboard-avoiding-view/public';",
|
|
30
30
|
"export { Box, Container, Divider, Grid, Stack } from './features/layout/public';",
|
|
31
|
+
"export { Modal } from './features/modal/public';",
|
|
31
32
|
"export { PopoverMenu } from './features/popover-menu/public';",
|
|
32
33
|
"export { Popover } from './features/popover/public';",
|
|
33
34
|
"export { Surface } from './features/surface/public';",
|
|
35
|
+
"export { Tab, TabList, TabPanel, Tabs } from './features/tabs/public';",
|
|
34
36
|
"export { Tooltip } from './features/tooltip/public';",
|
|
35
37
|
"export { Toast, ToastProvider, useToast } from './features/toast/public';",
|
|
36
38
|
"export { Heading, Text } from './features/typography/public';",
|
|
@@ -41,9 +43,7 @@ const expectedLegacyRootExports = [
|
|
|
41
43
|
"export { HelperText } from './components/helper-text';",
|
|
42
44
|
"export { Label } from './components/label';",
|
|
43
45
|
"export { ListItem } from './components/list-item';",
|
|
44
|
-
"export { Modal } from './components/modal';",
|
|
45
46
|
"export { Switch } from './components/switch';",
|
|
46
|
-
"export { Tab, TabList, TabPanel, Tabs } from './components/tabs';",
|
|
47
47
|
"export { Textarea } from './components/textarea';",
|
|
48
48
|
"export type { InteractionPolicy, InteractionPolicyProps } from './interactionPolicy';",
|
|
49
49
|
"export * from './core/responsive';",
|
|
@@ -63,7 +63,9 @@ describe('feature-owned root barrel contract', () => {
|
|
|
63
63
|
'./components/checkbox',
|
|
64
64
|
'./components/icon-button',
|
|
65
65
|
'./components/menu',
|
|
66
|
+
'./components/modal',
|
|
66
67
|
'./components/radio',
|
|
68
|
+
'./components/tabs',
|
|
67
69
|
'./components/text-input',
|
|
68
70
|
'./components/toast',
|
|
69
71
|
'./components/tooltip',
|
package/src/index.ts
CHANGED
|
@@ -6,12 +6,8 @@ export type { LabelProps } from './components/label';
|
|
|
6
6
|
export { Label } from './components/label';
|
|
7
7
|
export type { ListItemProps } from './components/list-item';
|
|
8
8
|
export { ListItem } from './components/list-item';
|
|
9
|
-
export type { ModalProps } from './components/modal';
|
|
10
|
-
export { Modal } from './components/modal';
|
|
11
9
|
export type { SwitchProps } from './components/switch';
|
|
12
10
|
export { Switch } from './components/switch';
|
|
13
|
-
export type { TabListProps, TabPanelProps, TabProps, TabsProps } from './components/tabs';
|
|
14
|
-
export { Tab, TabList, TabPanel, Tabs } from './components/tabs';
|
|
15
11
|
export type { TextareaProps } from './components/textarea';
|
|
16
12
|
export { Textarea } from './components/textarea';
|
|
17
13
|
export type { FontRuntime } from './context/FontContext';
|
|
@@ -70,6 +66,8 @@ export type {
|
|
|
70
66
|
StackProps,
|
|
71
67
|
} from './features/layout/public';
|
|
72
68
|
export { Box, Container, Divider, Grid, Stack } from './features/layout/public';
|
|
69
|
+
export type { ModalProps } from './features/modal/public';
|
|
70
|
+
export { Modal } from './features/modal/public';
|
|
73
71
|
export type {
|
|
74
72
|
PopoverAnchorRenderProps,
|
|
75
73
|
PopoverPlacement,
|
|
@@ -84,6 +82,8 @@ export type {
|
|
|
84
82
|
export { PopoverMenu } from './features/popover-menu/public';
|
|
85
83
|
export type { SurfaceProps, SurfaceVariant } from './features/surface/public';
|
|
86
84
|
export { Surface } from './features/surface/public';
|
|
85
|
+
export type { TabListProps, TabPanelProps, TabProps, TabsProps } from './features/tabs/public';
|
|
86
|
+
export { Tab, TabList, TabPanel, Tabs } from './features/tabs/public';
|
|
87
87
|
export type {
|
|
88
88
|
ToastController,
|
|
89
89
|
ToastOptions,
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
|
|
3
|
+
import type { InteractionPolicy } from '../interactionPolicy';
|
|
4
|
+
|
|
5
|
+
export interface TabsProps {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
value?: string;
|
|
8
|
+
defaultValue?: string;
|
|
9
|
+
onValueChange?: ((value: string) => void) | undefined;
|
|
10
|
+
testID?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface TabListProps {
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
testID?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface TabProps {
|
|
19
|
+
value: string;
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
interactionPolicy?: InteractionPolicy;
|
|
23
|
+
testID?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface TabPanelProps {
|
|
27
|
+
value: string;
|
|
28
|
+
children?: React.ReactNode;
|
|
29
|
+
testID?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface TabRegistration {
|
|
33
|
+
disabled: boolean;
|
|
34
|
+
focus: () => void;
|
|
35
|
+
value: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface TabsContextValue {
|
|
39
|
+
activeValue: string | undefined;
|
|
40
|
+
focusedValue: string | undefined;
|
|
41
|
+
getPanelId: (value: string) => string;
|
|
42
|
+
getTabId: (value: string) => string;
|
|
43
|
+
registerTab: (tab: TabRegistration) => void;
|
|
44
|
+
setActiveValue: (value: string) => void;
|
|
45
|
+
setFocusedValue: (value: string | undefined) => void;
|
|
46
|
+
tabs: readonly TabRegistration[];
|
|
47
|
+
unregisterTab: (value: string) => void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type TabNavigationKey =
|
|
51
|
+
'ArrowLeft' | 'ArrowRight' | 'ArrowUp' | 'ArrowDown' | 'Home' | 'End';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/components/modal/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAI1C,wBAAgB,KAAK,CAAC,EACpB,OAAO,EACP,SAAS,EACT,QAAQ,EACR,eAAsB,EACtB,iBAA6B,EAC7B,MAAM,GACP,EAAE,UAAU,4BA0EZ"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Pressable, View } from 'react-native';
|
|
3
|
-
import { Surface } from '../../features/surface/public';
|
|
4
|
-
import { FocusScope } from '../../internal/focus/FocusScope';
|
|
5
|
-
import { Portal } from '../../internal/overlay/Portal';
|
|
6
|
-
import { resolvePointerEvents } from '../../internal/resolvePointerEvents';
|
|
7
|
-
import { resolveOverlayAnimation } from '../../internal/resolvers';
|
|
8
|
-
import { Center } from '../../layout';
|
|
9
|
-
import { useTheme } from '../../theme/ThemeContext';
|
|
10
|
-
const boxNonePointerEvents = resolvePointerEvents('box-none');
|
|
11
|
-
export function Modal({ visible, onDismiss, children, closeOnBackdrop = true, interactionPolicy = 'enabled', testID, }) {
|
|
12
|
-
const { theme } = useTheme();
|
|
13
|
-
const animation = resolveOverlayAnimation('modal');
|
|
14
|
-
const passive = interactionPolicy === 'passive';
|
|
15
|
-
if (!visible) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
return (<Portal layer="modal" visible={visible}>
|
|
19
|
-
<View {...boxNonePointerEvents.props} style={[
|
|
20
|
-
boxNonePointerEvents.style,
|
|
21
|
-
{
|
|
22
|
-
bottom: 0,
|
|
23
|
-
left: 0,
|
|
24
|
-
position: 'absolute',
|
|
25
|
-
right: 0,
|
|
26
|
-
top: 0,
|
|
27
|
-
},
|
|
28
|
-
]}>
|
|
29
|
-
<Pressable onPress={passive ? undefined : closeOnBackdrop ? onDismiss : undefined} style={{
|
|
30
|
-
backgroundColor: theme.semantics.neutral.text,
|
|
31
|
-
bottom: 0,
|
|
32
|
-
left: 0,
|
|
33
|
-
opacity: animation.backdropOpacity,
|
|
34
|
-
position: 'absolute',
|
|
35
|
-
right: 0,
|
|
36
|
-
top: 0,
|
|
37
|
-
}} testID={testID ? `${testID}-backdrop` : undefined}/>
|
|
38
|
-
<FocusScope active={visible} onEscape={passive ? undefined : onDismiss} testID={testID ? `${testID}-focus` : undefined}>
|
|
39
|
-
<Center p="l" style={{
|
|
40
|
-
flex: 1,
|
|
41
|
-
}}>
|
|
42
|
-
<View accessible accessibilityViewIsModal style={{
|
|
43
|
-
maxWidth: 560,
|
|
44
|
-
width: '100%',
|
|
45
|
-
}}>
|
|
46
|
-
<Surface p="l" style={{
|
|
47
|
-
shadowOpacity: 0.14,
|
|
48
|
-
shadowRadius: 18,
|
|
49
|
-
shadowOffset: { width: 0, height: 8 },
|
|
50
|
-
}} testID={testID} variant="raised">
|
|
51
|
-
{children}
|
|
52
|
-
</Surface>
|
|
53
|
-
</View>
|
|
54
|
-
</Center>
|
|
55
|
-
</FocusScope>
|
|
56
|
-
</View>
|
|
57
|
-
</Portal>);
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=Modal.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../../src/components/modal/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qC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AO,EAAE,SAAS,CAAC,eAAe;YAClC,QAAQ,EAAE,UAAU;YACpB,KAAK,EAAE,CAAC;YACR,GAAG,EAAE,CAAC;SACP,CAAC,CACF,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,EAEpD;QAAA,CAAC,UAAU,CACT,MAAM,CAAC,CAAC,OAAO,CAAC,CAChB,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAC1C,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAE/C;UAAA,CAAC,MAAM,CACL,CAAC,CAAC,GAAG,CACL,KAAK,CAAC,CAAC;YACL,IAAI,EAAE,CAAC;SACR,CAAC,CAEF;YAAA,CAAC,IAAI,CACH,UAAU,CACV,wBAAwB,CACxB,KAAK,CAAC,CAAC;YACL,QAAQ,EAAE,GAAG;YACb,KAAK,EAAE,MAAM;SACd,CAAC,CAEF;cAAA,CAAC,OAAO,CACN,CAAC,CAAC,GAAG,CACL,KAAK,CAAC,CAAC;YACL,aAAa,EAAE,IAAI;YACnB,YAAY,EAAE,EAAE;YAChB,YAAY,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;SACtC,CAAC,CACF,MAAM,CAAC,CAAC,MAAM,CAAC,CACf,OAAO,CAAC,QAAQ,CAEhB;gBAAA,CAAC,QAAQ,CACX;cAAA,EAAE,OAAO,CACX;YAAA,EAAE,IAAI,CACR;UAAA,EAAE,MAAM,CACV;QAAA,EAAE,UAAU,CACd;MAAA,EAAE,IAAI,CACR;IAAA,EAAE,MAAM,CAAC,CACV,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\nimport { Pressable, View } from 'react-native';\n\nimport { Surface } from '../../features/surface/public';\nimport { FocusScope } from '../../internal/focus/FocusScope';\nimport { Portal } from '../../internal/overlay/Portal';\nimport { resolvePointerEvents } from '../../internal/resolvePointerEvents';\nimport { resolveOverlayAnimation } from '../../internal/resolvers';\nimport { Center } from '../../layout';\nimport { useTheme } from '../../theme/ThemeContext';\nimport type { ModalProps } from './types';\n\nconst boxNonePointerEvents = resolvePointerEvents('box-none');\n\nexport function Modal({\n visible,\n onDismiss,\n children,\n closeOnBackdrop = true,\n interactionPolicy = 'enabled',\n testID,\n}: ModalProps) {\n const { theme } = useTheme();\n const animation = resolveOverlayAnimation('modal');\n const passive = interactionPolicy === 'passive';\n\n if (!visible) {\n return null;\n }\n\n return (\n <Portal layer=\"modal\" visible={visible}>\n <View\n {...boxNonePointerEvents.props}\n style={[\n boxNonePointerEvents.style,\n {\n bottom: 0,\n left: 0,\n position: 'absolute',\n right: 0,\n top: 0,\n },\n ]}\n >\n <Pressable\n onPress={passive ? undefined : closeOnBackdrop ? onDismiss : undefined}\n style={{\n backgroundColor: theme.semantics.neutral.text,\n bottom: 0,\n left: 0,\n opacity: animation.backdropOpacity,\n position: 'absolute',\n right: 0,\n top: 0,\n }}\n testID={testID ? `${testID}-backdrop` : undefined}\n />\n <FocusScope\n active={visible}\n onEscape={passive ? undefined : onDismiss}\n testID={testID ? `${testID}-focus` : undefined}\n >\n <Center\n p=\"l\"\n style={{\n flex: 1,\n }}\n >\n <View\n accessible\n accessibilityViewIsModal\n style={{\n maxWidth: 560,\n width: '100%',\n }}\n >\n <Surface\n p=\"l\"\n style={{\n shadowOpacity: 0.14,\n shadowRadius: 18,\n shadowOffset: { width: 0, height: 8 },\n }}\n testID={testID}\n variant=\"raised\"\n >\n {children}\n </Surface>\n </View>\n </Center>\n </FocusScope>\n </View>\n </Portal>\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/modal/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/modal/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC","sourcesContent":["export { Modal } from './Modal';\nexport type { ModalProps } from './types';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/modal/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/modal/types.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\n\nimport type { InteractionPolicy } from '../../interactionPolicy';\n\nexport interface ModalProps {\n visible: boolean;\n onDismiss?: (() => void) | undefined;\n children?: React.ReactNode;\n closeOnBackdrop?: boolean;\n interactionPolicy?: InteractionPolicy;\n testID?: string;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Tab.d.ts","sourceRoot":"","sources":["../../../src/components/tabs/Tab.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,wBAAgB,GAAG,CAAC,EAClB,KAAK,EACL,QAAQ,EACR,QAAgB,EAChB,iBAA6B,EAC7B,MAAM,GACP,EAAE,QAAQ,qBAyEV"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Pressable } from 'react-native';
|
|
3
|
-
import { Box } from '../../features/layout/public';
|
|
4
|
-
import { Text } from '../../features/typography/public';
|
|
5
|
-
import { useTheme } from '../../theme/ThemeContext';
|
|
6
|
-
import { useTabsContext } from './context';
|
|
7
|
-
export function Tab({ value, children, disabled = false, interactionPolicy = 'enabled', testID, }) {
|
|
8
|
-
const { theme } = useTheme();
|
|
9
|
-
const { activeValue, getPanelId, getTabId, registerTab, setActiveValue, setFocusedValue, unregisterTab, } = useTabsContext();
|
|
10
|
-
const pressableRef = React.useRef(null);
|
|
11
|
-
const selected = activeValue === value;
|
|
12
|
-
const tabId = getTabId(value);
|
|
13
|
-
const panelId = getPanelId(value);
|
|
14
|
-
const passive = interactionPolicy === 'passive';
|
|
15
|
-
React.useEffect(() => {
|
|
16
|
-
registerTab({
|
|
17
|
-
disabled,
|
|
18
|
-
focus: () => {
|
|
19
|
-
const focusable = pressableRef.current;
|
|
20
|
-
focusable?.focus?.();
|
|
21
|
-
},
|
|
22
|
-
value,
|
|
23
|
-
});
|
|
24
|
-
return () => {
|
|
25
|
-
unregisterTab(value);
|
|
26
|
-
};
|
|
27
|
-
}, [disabled, registerTab, unregisterTab, value]);
|
|
28
|
-
return (<Pressable accessibilityLabel={undefined} accessibilityRole="tab" accessibilityState={{ disabled, selected }} nativeID={tabId} aria-controls={panelId} disabled={disabled} onFocus={() => setFocusedValue(value)} onBlur={() => setFocusedValue(undefined)} onPress={passive
|
|
29
|
-
? undefined
|
|
30
|
-
: () => {
|
|
31
|
-
if (!disabled) {
|
|
32
|
-
setActiveValue(value);
|
|
33
|
-
}
|
|
34
|
-
}} ref={pressableRef} testID={testID}>
|
|
35
|
-
<Box px="m" py="s" style={{
|
|
36
|
-
borderBottomColor: selected
|
|
37
|
-
? theme.semantics.action.primary.base
|
|
38
|
-
: theme.semantics.border.default,
|
|
39
|
-
borderBottomWidth: 2,
|
|
40
|
-
opacity: disabled ? 0.64 : 1,
|
|
41
|
-
}}>
|
|
42
|
-
<Text color={selected ? 'primary' : undefined} variant="label" weight="medium">
|
|
43
|
-
{children}
|
|
44
|
-
</Text>
|
|
45
|
-
</Box>
|
|
46
|
-
</Pressable>);
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=Tab.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Tab.js","sourceRoot":"","sources":["../../../src/components/tabs/Tab.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,IAAI,EAAE,MAAM,kCAAkC,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG3C,MAAM,UAAU,GAAG,CAAC,EAClB,KAAK,EACL,QAAQ,EACR,QAAQ,GAAG,KAAK,EAChB,iBAAiB,GAAG,SAAS,EAC7B,MAAM,GACG;IACT,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC7B,MAAM,EACJ,WAAW,EACX,UAAU,EACV,QAAQ,EACR,WAAW,EACX,cAAc,EACd,eAAe,EACf,aAAa,GACd,GAAG,cAAc,EAAE,CAAC;IACrB,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAA4C,IAAI,CAAC,CAAC;IACnF,MAAM,QAAQ,GAAG,WAAW,KAAK,KAAK,CAAC;IACvC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9B,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G,CACN,KAAK,CAAC,CAAC;YACL,iBAAiB,EAAE,QAAQ;gBACzB,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI;gBACrC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO;YAClC,iBAAiB,EAAE,CAAC;YACpB,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SAC7B,CAAC,CAEF;QAAA,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAC5E;UAAA,CAAC,QAAQ,CACX;QAAA,EAAE,IAAI,CACR;MAAA,EAAE,GAAG,CACP;IAAA,EAAE,SAAS,CAAC,CACb,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\nimport { Pressable } from 'react-native';\n\nimport { Box } from '../../features/layout/public';\nimport { Text } from '../../features/typography/public';\nimport { useTheme } from '../../theme/ThemeContext';\nimport { useTabsContext } from './context';\nimport type { TabProps } from './types';\n\nexport function Tab({\n value,\n children,\n disabled = false,\n interactionPolicy = 'enabled',\n testID,\n}: TabProps) {\n const { theme } = useTheme();\n const {\n activeValue,\n getPanelId,\n getTabId,\n registerTab,\n setActiveValue,\n setFocusedValue,\n unregisterTab,\n } = useTabsContext();\n const pressableRef = React.useRef<React.ElementRef<typeof Pressable> | null>(null);\n const selected = activeValue === value;\n const tabId = getTabId(value);\n const panelId = getPanelId(value);\n const passive = interactionPolicy === 'passive';\n\n React.useEffect(() => {\n registerTab({\n disabled,\n focus: () => {\n const focusable = pressableRef.current as unknown as {\n focus?: (() => void) | undefined;\n } | null;\n focusable?.focus?.();\n },\n value,\n });\n\n return () => {\n unregisterTab(value);\n };\n }, [disabled, registerTab, unregisterTab, value]);\n\n return (\n <Pressable\n accessibilityLabel={undefined}\n accessibilityRole=\"tab\"\n accessibilityState={{ disabled, selected }}\n nativeID={tabId}\n aria-controls={panelId}\n disabled={disabled}\n onFocus={() => setFocusedValue(value)}\n onBlur={() => setFocusedValue(undefined)}\n onPress={\n passive\n ? undefined\n : () => {\n if (!disabled) {\n setActiveValue(value);\n }\n }\n }\n ref={pressableRef}\n testID={testID}\n >\n <Box\n px=\"m\"\n py=\"s\"\n style={{\n borderBottomColor: selected\n ? theme.semantics.action.primary.base\n : theme.semantics.border.default,\n borderBottomWidth: 2,\n opacity: disabled ? 0.64 : 1,\n }}\n >\n <Text color={selected ? 'primary' : undefined} variant=\"label\" weight=\"medium\">\n {children}\n </Text>\n </Box>\n </Pressable>\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TabList.d.ts","sourceRoot":"","sources":["../../../src/components/tabs/TabList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,wBAAgB,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,YAAY,qBA0CzD"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Box } from '../../features/layout/public';
|
|
3
|
-
import { useFocusManager } from '../../internal/focus/useFocusManager';
|
|
4
|
-
import { useTabsContext } from './context';
|
|
5
|
-
import { resolveNextTabValue } from './navigation';
|
|
6
|
-
export function TabList({ children, testID }) {
|
|
7
|
-
const { bindKeydown } = useFocusManager();
|
|
8
|
-
const { focusedValue, setActiveValue, tabs } = useTabsContext();
|
|
9
|
-
React.useEffect(() => {
|
|
10
|
-
if (!focusedValue) {
|
|
11
|
-
return undefined;
|
|
12
|
-
}
|
|
13
|
-
return bindKeydown((event) => {
|
|
14
|
-
const nextValue = event.key === 'ArrowLeft' ||
|
|
15
|
-
event.key === 'ArrowRight' ||
|
|
16
|
-
event.key === 'ArrowUp' ||
|
|
17
|
-
event.key === 'ArrowDown' ||
|
|
18
|
-
event.key === 'Home' ||
|
|
19
|
-
event.key === 'End'
|
|
20
|
-
? resolveNextTabValue(tabs, focusedValue, event.key)
|
|
21
|
-
: undefined;
|
|
22
|
-
if (!nextValue) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
event.preventDefault();
|
|
26
|
-
const nextTab = tabs.find((tab) => tab.value === nextValue);
|
|
27
|
-
nextTab?.focus();
|
|
28
|
-
setActiveValue(nextValue);
|
|
29
|
-
});
|
|
30
|
-
}, [bindKeydown, focusedValue, setActiveValue, tabs]);
|
|
31
|
-
return (<Box accessibilityRole="tablist" style={{
|
|
32
|
-
flexDirection: 'row',
|
|
33
|
-
}} testID={testID}>
|
|
34
|
-
{children}
|
|
35
|
-
</Box>);
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=TabList.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TabList.js","sourceRoot":"","sources":["../../../src/components/tabs/TabList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,GAAG,EAAE,MAAM,8BAA8B,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGnD,MAAM,UAAU,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAgB;IACxD,MAAM,EAAE,WAAW,EAAE,GAAG,eAAe,EAAE,CAAC;IAC1C,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG,cAAc,EAAE,CAAC;IAEhE,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,WAAW,CAAC,CAAC,KAAK,EAAE,EAAE;YAC3B,MAAM,SAAS,GACb,KAAK,CAAC,GAAG,KAAK,WAAW;gBACzB,KAAK,CAAC,GAAG,KAAK,YAAY;gBAC1B,KAAK,CAAC,GAAG,KAAK,SAAS;gBACvB,KAAK,CAAC,GAAG,KAAK,WAAW;gBACzB,KAAK,CAAC,GAAG,KAAK,MAAM;gBACpB,KAAK,CAAC,GAAG,KAAK,KAAK;gBACjB,CAAC,CAAC,mBAAmB,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,CAAC,GAAG,CAAC;gBACpD,CAAC,CAAC,SAAS,CAAC;YAEhB,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,OAAO;YACT,CAAC;YAED,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;YAC5D,OAAO,EAAE,KAAK,EAAE,CAAC;YACjB,cAAc,CAAC,SAAS,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC;IAEtD,OAAO,CACL,CAAC,GAAG,CACF,iBAAiB,CAAC,SAAS,CAC3B,KAAK,CAAC,CAAC;YACL,aAAa,EAAE,KAAK;SACrB,CAAC,CACF,MAAM,CAAC,CAAC,MAAM,CAAC,CAEf;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,GAAG,CAAC,CACP,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\n\nimport { Box } from '../../features/layout/public';\nimport { useFocusManager } from '../../internal/focus/useFocusManager';\nimport { useTabsContext } from './context';\nimport { resolveNextTabValue } from './navigation';\nimport type { TabListProps } from './types';\n\nexport function TabList({ children, testID }: TabListProps) {\n const { bindKeydown } = useFocusManager();\n const { focusedValue, setActiveValue, tabs } = useTabsContext();\n\n React.useEffect(() => {\n if (!focusedValue) {\n return undefined;\n }\n\n return bindKeydown((event) => {\n const nextValue =\n event.key === 'ArrowLeft' ||\n event.key === 'ArrowRight' ||\n event.key === 'ArrowUp' ||\n event.key === 'ArrowDown' ||\n event.key === 'Home' ||\n event.key === 'End'\n ? resolveNextTabValue(tabs, focusedValue, event.key)\n : undefined;\n\n if (!nextValue) {\n return;\n }\n\n event.preventDefault();\n const nextTab = tabs.find((tab) => tab.value === nextValue);\n nextTab?.focus();\n setActiveValue(nextValue);\n });\n }, [bindKeydown, focusedValue, setActiveValue, tabs]);\n\n return (\n <Box\n accessibilityRole=\"tablist\"\n style={{\n flexDirection: 'row',\n }}\n testID={testID}\n >\n {children}\n </Box>\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TabPanel.d.ts","sourceRoot":"","sources":["../../../src/components/tabs/TabPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAI7C,wBAAgB,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,aAAa,4BAoBlE"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
3
|
-
import { useTabsContext } from './context';
|
|
4
|
-
const TAB_PANEL_ROLE = 'tabpanel';
|
|
5
|
-
export function TabPanel({ value, children, testID }) {
|
|
6
|
-
const { activeValue, getPanelId, getTabId } = useTabsContext();
|
|
7
|
-
if (activeValue !== value) {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
const tabId = getTabId(value);
|
|
11
|
-
const panelId = getPanelId(value);
|
|
12
|
-
return (<View accessibilityLabelledBy={tabId} accessibilityRole={TAB_PANEL_ROLE} nativeID={panelId} testID={testID}>
|
|
13
|
-
{children}
|
|
14
|
-
</View>);
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=TabPanel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TabPanel.js","sourceRoot":"","sources":["../../../src/components/tabs/TabPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG3C,MAAM,cAAc,GAAG,UAAoE,CAAC;AAE5F,MAAM,UAAU,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAiB;IACjE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,cAAc,EAAE,CAAC;IAE/D,IAAI,WAAW,KAAK,KAAK,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9B,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAElC,OAAO,CACL,CAAC,IAAI,CACH,uBAAuB,CAAC,CAAC,KAAK,CAAC,CAC/B,iBAAiB,CAAC,CAAC,cAAc,CAAC,CAClC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAClB,MAAM,CAAC,CAAC,MAAM,CAAC,CAEf;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\nimport { View } from 'react-native';\n\nimport { useTabsContext } from './context';\nimport type { TabPanelProps } from './types';\n\nconst TAB_PANEL_ROLE = 'tabpanel' as React.ComponentProps<typeof View>['accessibilityRole'];\n\nexport function TabPanel({ value, children, testID }: TabPanelProps) {\n const { activeValue, getPanelId, getTabId } = useTabsContext();\n\n if (activeValue !== value) {\n return null;\n }\n\n const tabId = getTabId(value);\n const panelId = getPanelId(value);\n\n return (\n <View\n accessibilityLabelledBy={tabId}\n accessibilityRole={TAB_PANEL_ROLE}\n nativeID={panelId}\n testID={testID}\n >\n {children}\n </View>\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../../src/components/tabs/Tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,wBAAgB,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,SAAS,qBA0DvF"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Box } from '../../features/layout/public';
|
|
3
|
-
import { useControllableState } from '../../internal/useControllableState';
|
|
4
|
-
import { getTabId as resolveTabId, getTabPanelId as resolveTabPanelId } from './a11y';
|
|
5
|
-
import { TabsContext } from './context';
|
|
6
|
-
export function Tabs({ children, value, defaultValue, onValueChange, testID }) {
|
|
7
|
-
const [activeValue, setActiveValue] = useControllableState({
|
|
8
|
-
value,
|
|
9
|
-
defaultValue,
|
|
10
|
-
onChange: (nextValue) => {
|
|
11
|
-
if (nextValue !== undefined) {
|
|
12
|
-
onValueChange?.(nextValue);
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
const [focusedValue, setFocusedValue] = React.useState(undefined);
|
|
17
|
-
const [tabs, setTabs] = React.useState([]);
|
|
18
|
-
const registerTab = React.useCallback((tab) => {
|
|
19
|
-
setTabs((current) => {
|
|
20
|
-
return current.some((entry) => entry.value === tab.value)
|
|
21
|
-
? current.map((entry) => (entry.value === tab.value ? tab : entry))
|
|
22
|
-
: [...current, tab];
|
|
23
|
-
});
|
|
24
|
-
}, []);
|
|
25
|
-
const unregisterTab = React.useCallback((valueToRemove) => {
|
|
26
|
-
setTabs((current) => current.filter((entry) => entry.value !== valueToRemove));
|
|
27
|
-
}, []);
|
|
28
|
-
React.useEffect(() => {
|
|
29
|
-
if (activeValue !== undefined) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const firstEnabledTab = tabs.find((entry) => !entry.disabled);
|
|
33
|
-
if (firstEnabledTab) {
|
|
34
|
-
setActiveValue(firstEnabledTab.value);
|
|
35
|
-
}
|
|
36
|
-
}, [activeValue, setActiveValue, tabs]);
|
|
37
|
-
const contextValue = React.useMemo(() => ({
|
|
38
|
-
activeValue,
|
|
39
|
-
focusedValue,
|
|
40
|
-
getPanelId: (tabValue) => resolveTabPanelId(testID, tabValue),
|
|
41
|
-
getTabId: (tabValue) => resolveTabId(testID, tabValue),
|
|
42
|
-
registerTab,
|
|
43
|
-
setActiveValue: (nextValue) => {
|
|
44
|
-
setActiveValue(nextValue);
|
|
45
|
-
},
|
|
46
|
-
setFocusedValue,
|
|
47
|
-
tabs,
|
|
48
|
-
unregisterTab,
|
|
49
|
-
}), [activeValue, focusedValue, registerTab, setActiveValue, tabs, testID, unregisterTab]);
|
|
50
|
-
return (<TabsContext value={contextValue}>
|
|
51
|
-
<Box testID={testID}>{children}</Box>
|
|
52
|
-
</TabsContext>);
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=Tabs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../../src/components/tabs/Tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,GAAG,EAAE,MAAM,8BAA8B,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AACtF,OAAO,EAAwB,WAAW,EAAE,MAAM,WAAW,CAAC;AAG9D,MAAM,UAAU,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n\nimport { Box } from '../../features/layout/public';\nimport { useControllableState } from '../../internal/useControllableState';\nimport { getTabId as resolveTabId, getTabPanelId as resolveTabPanelId } from './a11y';\nimport { type TabRegistration, TabsContext } from './context';\nimport type { TabsProps } from './types';\n\nexport function Tabs({ children, value, defaultValue, onValueChange, testID }: TabsProps) {\n const [activeValue, setActiveValue] = useControllableState<string | undefined>({\n value,\n defaultValue,\n onChange: (nextValue) => {\n if (nextValue !== undefined) {\n onValueChange?.(nextValue);\n }\n },\n });\n const [focusedValue, setFocusedValue] = React.useState<string | undefined>(undefined);\n const [tabs, setTabs] = React.useState<TabRegistration[]>([]);\n\n const registerTab = React.useCallback((tab: TabRegistration) => {\n setTabs((current) => {\n return current.some((entry) => entry.value === tab.value)\n ? current.map((entry) => (entry.value === tab.value ? tab : entry))\n : [...current, tab];\n });\n }, []);\n\n const unregisterTab = React.useCallback((valueToRemove: string) => {\n setTabs((current) => current.filter((entry) => entry.value !== valueToRemove));\n }, []);\n\n React.useEffect(() => {\n if (activeValue !== undefined) {\n return;\n }\n\n const firstEnabledTab = tabs.find((entry) => !entry.disabled);\n if (firstEnabledTab) {\n setActiveValue(firstEnabledTab.value);\n }\n }, [activeValue, setActiveValue, tabs]);\n\n const contextValue = React.useMemo(\n () => ({\n activeValue,\n focusedValue,\n getPanelId: (tabValue: string) => resolveTabPanelId(testID, tabValue),\n getTabId: (tabValue: string) => resolveTabId(testID, tabValue),\n registerTab,\n setActiveValue: (nextValue: string) => {\n setActiveValue(nextValue);\n },\n setFocusedValue,\n tabs,\n unregisterTab,\n }),\n [activeValue, focusedValue, registerTab, setActiveValue, tabs, testID, unregisterTab],\n );\n\n return (\n <TabsContext value={contextValue}>\n <Box testID={testID}>{children}</Box>\n </TabsContext>\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"a11y.d.ts","sourceRoot":"","sources":["../../../src/components/tabs/a11y.ts"],"names":[],"mappings":"AAQA,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE1E;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/E"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
function sanitizeTabValue(value) {
|
|
2
|
-
return value.trim().replace(/[^a-zA-Z0-9_-]+/g, '-');
|
|
3
|
-
}
|
|
4
|
-
function createTabsIdBase(testID) {
|
|
5
|
-
return testID ? `${testID}-tabs` : 'tabs';
|
|
6
|
-
}
|
|
7
|
-
export function getTabId(testID, value) {
|
|
8
|
-
return `${createTabsIdBase(testID)}-tab-${sanitizeTabValue(value)}`;
|
|
9
|
-
}
|
|
10
|
-
export function getTabPanelId(testID, value) {
|
|
11
|
-
return `${createTabsIdBase(testID)}-panel-${sanitizeTabValue(value)}`;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=a11y.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"a11y.js","sourceRoot":"","sources":["../../../src/components/tabs/a11y.ts"],"names":[],"mappings":"AAAA,SAAS,gBAAgB,CAAC,KAAa;IACrC,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,gBAAgB,CAAC,MAA0B;IAClD,OAAO,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,MAA0B,EAAE,KAAa;IAChE,OAAO,GAAG,gBAAgB,CAAC,MAAM,CAAC,QAAQ,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAA0B,EAAE,KAAa;IACrE,OAAO,GAAG,gBAAgB,CAAC,MAAM,CAAC,UAAU,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;AACxE,CAAC","sourcesContent":["function sanitizeTabValue(value: string): string {\n return value.trim().replace(/[^a-zA-Z0-9_-]+/g, '-');\n}\n\nfunction createTabsIdBase(testID: string | undefined): string {\n return testID ? `${testID}-tabs` : 'tabs';\n}\n\nexport function getTabId(testID: string | undefined, value: string): string {\n return `${createTabsIdBase(testID)}-tab-${sanitizeTabValue(value)}`;\n}\n\nexport function getTabPanelId(testID: string | undefined, value: string): string {\n return `${createTabsIdBase(testID)}-panel-${sanitizeTabValue(value)}`;\n}\n"]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export interface TabRegistration {
|
|
3
|
-
disabled: boolean;
|
|
4
|
-
focus: () => void;
|
|
5
|
-
value: string;
|
|
6
|
-
}
|
|
7
|
-
export interface TabsContextValue {
|
|
8
|
-
activeValue: string | undefined;
|
|
9
|
-
focusedValue: string | undefined;
|
|
10
|
-
getPanelId: (value: string) => string;
|
|
11
|
-
getTabId: (value: string) => string;
|
|
12
|
-
registerTab: (tab: TabRegistration) => void;
|
|
13
|
-
setActiveValue: (value: string) => void;
|
|
14
|
-
setFocusedValue: (value: string | undefined) => void;
|
|
15
|
-
tabs: TabRegistration[];
|
|
16
|
-
unregisterTab: (value: string) => void;
|
|
17
|
-
}
|
|
18
|
-
export declare const TabsContext: React.Context<TabsContextValue | null>;
|
|
19
|
-
export declare function useTabsContext(): TabsContextValue;
|
|
20
|
-
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/components/tabs/context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACtC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC,WAAW,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,CAAC;IAC5C,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IACrD,IAAI,EAAE,eAAe,EAAE,CAAC;IACxB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED,eAAO,MAAM,WAAW,wCAAqD,CAAC;AAE9E,wBAAgB,cAAc,IAAI,gBAAgB,CAQjD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/components/tabs/context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAoB1B,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC,aAAa,CAA0B,IAAI,CAAC,CAAC;AAE9E,MAAM,UAAU,cAAc;IAC5B,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAErC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import React from 'react';\n\nexport interface TabRegistration {\n disabled: boolean;\n focus: () => void;\n value: string;\n}\n\nexport interface TabsContextValue {\n activeValue: string | undefined;\n focusedValue: string | undefined;\n getPanelId: (value: string) => string;\n getTabId: (value: string) => string;\n registerTab: (tab: TabRegistration) => void;\n setActiveValue: (value: string) => void;\n setFocusedValue: (value: string | undefined) => void;\n tabs: TabRegistration[];\n unregisterTab: (value: string) => void;\n}\n\nexport const TabsContext = React.createContext<TabsContextValue | null>(null);\n\nexport function useTabsContext(): TabsContextValue {\n const value = React.use(TabsContext);\n\n if (!value) {\n throw new Error('Tabs components must be used within <Tabs>.');\n }\n\n return value;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/tabs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/tabs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC","sourcesContent":["export { Tab } from './Tab';\nexport { TabList } from './TabList';\nexport { TabPanel } from './TabPanel';\nexport { Tabs } from './Tabs';\nexport type { TabListProps, TabPanelProps, TabProps, TabsProps } from './types';\n"]}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { TabRegistration } from './context';
|
|
2
|
-
export declare function resolveNextTabValue(tabs: TabRegistration[], currentValue: string | undefined, key: 'ArrowLeft' | 'ArrowRight' | 'ArrowUp' | 'ArrowDown' | 'Home' | 'End'): string | undefined;
|
|
3
|
-
//# sourceMappingURL=navigation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../src/components/tabs/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,eAAe,EAAE,EACvB,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,GAAG,EAAE,WAAW,GAAG,YAAY,GAAG,SAAS,GAAG,WAAW,GAAG,MAAM,GAAG,KAAK,GACzE,MAAM,GAAG,SAAS,CAyBpB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.js","sourceRoot":"","sources":["../../../src/components/tabs/navigation.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,mBAAmB,CACjC,IAAuB,EACvB,YAAgC,EAChC,GAA0E;IAE1E,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACxD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;QACnB,OAAO,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC;IAC/B,CAAC;IAED,IAAI,GAAG,KAAK,KAAK,EAAE,CAAC;QAClB,OAAO,WAAW,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC;IACpD,CAAC;IAED,MAAM,YAAY,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,YAAY,CAAC,CAAC;IAChF,IAAI,YAAY,KAAK,CAAC,CAAC,EAAE,CAAC;QACxB,OAAO,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC;IAC/B,CAAC;IAED,MAAM,SAAS,GACb,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,SAAS;QACtC,CAAC,CAAC,CAAC,YAAY,GAAG,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,MAAM;QAC9D,CAAC,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC;IAE9C,OAAO,WAAW,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC;AACvC,CAAC","sourcesContent":["import type { TabRegistration } from './context';\n\nexport function resolveNextTabValue(\n tabs: TabRegistration[],\n currentValue: string | undefined,\n key: 'ArrowLeft' | 'ArrowRight' | 'ArrowUp' | 'ArrowDown' | 'Home' | 'End',\n): string | undefined {\n const enabledTabs = tabs.filter((tab) => !tab.disabled);\n if (enabledTabs.length === 0) {\n return undefined;\n }\n\n if (key === 'Home') {\n return enabledTabs[0]?.value;\n }\n\n if (key === 'End') {\n return enabledTabs[enabledTabs.length - 1]?.value;\n }\n\n const currentIndex = enabledTabs.findIndex((tab) => tab.value === currentValue);\n if (currentIndex === -1) {\n return enabledTabs[0]?.value;\n }\n\n const nextIndex =\n key === 'ArrowLeft' || key === 'ArrowUp'\n ? (currentIndex - 1 + enabledTabs.length) % enabledTabs.length\n : (currentIndex + 1) % enabledTabs.length;\n\n return enabledTabs[nextIndex]?.value;\n}\n"]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
import type { InteractionPolicy } from '../../interactionPolicy';
|
|
3
|
-
export interface TabsProps {
|
|
4
|
-
children?: React.ReactNode;
|
|
5
|
-
value?: string;
|
|
6
|
-
defaultValue?: string;
|
|
7
|
-
onValueChange?: ((value: string) => void) | undefined;
|
|
8
|
-
testID?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface TabListProps {
|
|
11
|
-
children?: React.ReactNode;
|
|
12
|
-
testID?: string;
|
|
13
|
-
}
|
|
14
|
-
export interface TabProps {
|
|
15
|
-
value: string;
|
|
16
|
-
children?: React.ReactNode;
|
|
17
|
-
disabled?: boolean;
|
|
18
|
-
interactionPolicy?: InteractionPolicy;
|
|
19
|
-
testID?: string;
|
|
20
|
-
}
|
|
21
|
-
export interface TabPanelProps {
|
|
22
|
-
value: string;
|
|
23
|
-
children?: React.ReactNode;
|
|
24
|
-
testID?: string;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=types.d.ts.map
|