@ankhorage/surface 6.0.0 → 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 +6 -0
- package/README.md +1 -1
- package/dist/{components/field → features/form/field/adapters/inbound}/Field.d.ts +2 -2
- 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/{components/switch → features/form/switch/adapters/inbound}/Switch.d.ts +1 -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/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/index.d.ts +6 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -6
- package/dist/index.js.map +1 -1
- 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/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/{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/package.json +1 -1
- package/src/features/form/field/adapters/inbound/Field.tsx +82 -0
- package/src/features/form/field/public.ts +2 -0
- 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/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/index.test.ts +15 -11
- package/src/index.ts +6 -12
- package/src/types/list.ts +22 -0
- package/src/{components/switch/types.ts → types/switch.ts} +3 -3
- package/dist/components/field/Field.d.ts.map +0 -1
- package/dist/components/field/Field.js +0 -27
- 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 -5
- package/dist/components/list-item/ListItem.d.ts.map +0 -1
- package/dist/components/list-item/ListItem.js +0 -44
- 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 -68
- 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/src/components/field/Field.tsx +0 -52
- 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 -76
- 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 -113
- 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/{components/field/types.ts → types/field.ts} +0 -0
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { View as ReactNativeView } from 'react-native';
|
|
3
|
-
|
|
4
|
-
import { View } from '../../features/layout/public';
|
|
5
|
-
import { Text } from '../../features/typography/public';
|
|
6
|
-
import { ButtonBase } from '../../primitives/button-base';
|
|
7
|
-
import { useTheme } from '../../theme/ThemeContext';
|
|
8
|
-
import type { ListItemProps } from './types';
|
|
9
|
-
|
|
10
|
-
/*** Renders the content row shared by static and interactive ListItem variants. */
|
|
11
|
-
function ListItemContent({
|
|
12
|
-
title,
|
|
13
|
-
description,
|
|
14
|
-
leading,
|
|
15
|
-
trailing,
|
|
16
|
-
testID,
|
|
17
|
-
}: Omit<ListItemProps, 'disabled' | 'onPress'>) {
|
|
18
|
-
const { theme } = useTheme();
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<View
|
|
22
|
-
px="m"
|
|
23
|
-
py="m"
|
|
24
|
-
testID={testID}
|
|
25
|
-
style={{
|
|
26
|
-
flexDirection: 'row',
|
|
27
|
-
alignItems: 'center',
|
|
28
|
-
}}
|
|
29
|
-
>
|
|
30
|
-
{leading ? (
|
|
31
|
-
<ReactNativeView style={{ marginRight: theme.spacing.m }}>{leading}</ReactNativeView>
|
|
32
|
-
) : null}
|
|
33
|
-
<View flex={1}>
|
|
34
|
-
{title ? (
|
|
35
|
-
<Text numberOfLines={1} variant="body" weight="medium">
|
|
36
|
-
{title}
|
|
37
|
-
</Text>
|
|
38
|
-
) : null}
|
|
39
|
-
{description ? (
|
|
40
|
-
<Text emphasis="muted" numberOfLines={2} variant="bodySmall">
|
|
41
|
-
{description}
|
|
42
|
-
</Text>
|
|
43
|
-
) : null}
|
|
44
|
-
</View>
|
|
45
|
-
{trailing ? (
|
|
46
|
-
<ReactNativeView style={{ marginLeft: theme.spacing.m }}>{trailing}</ReactNativeView>
|
|
47
|
-
) : null}
|
|
48
|
-
</View>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/*** Renders a static or pressable list item. */
|
|
53
|
-
export function ListItem({ onPress, disabled = false, testID, ...content }: ListItemProps) {
|
|
54
|
-
const { theme } = useTheme();
|
|
55
|
-
|
|
56
|
-
if (!onPress) return <ListItemContent {...content} testID={testID} />;
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<ButtonBase accessibilityRole="button" disabled={disabled} onPress={onPress} testID={testID}>
|
|
60
|
-
{(state) => (
|
|
61
|
-
<View
|
|
62
|
-
style={{
|
|
63
|
-
backgroundColor: state.pressed
|
|
64
|
-
? theme.semantics.neutral.surfaceActive
|
|
65
|
-
: state.hovered
|
|
66
|
-
? theme.semantics.neutral.surfaceHover
|
|
67
|
-
: 'transparent',
|
|
68
|
-
opacity: state.disabled ? 0.72 : 1,
|
|
69
|
-
}}
|
|
70
|
-
>
|
|
71
|
-
<ListItemContent {...content} />
|
|
72
|
-
</View>
|
|
73
|
-
)}
|
|
74
|
-
</ButtonBase>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
|
|
3
|
-
export interface ListItemProps {
|
|
4
|
-
title?: React.ReactNode;
|
|
5
|
-
description?: React.ReactNode;
|
|
6
|
-
leading?: React.ReactNode;
|
|
7
|
-
trailing?: React.ReactNode;
|
|
8
|
-
onPress?: (() => void) | undefined;
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
testID?: string;
|
|
11
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { View } from '../../features/layout/public';
|
|
4
|
-
import { Text } from '../../features/typography/public';
|
|
5
|
-
import {
|
|
6
|
-
resolveFieldState,
|
|
7
|
-
resolveIndicatorSize,
|
|
8
|
-
resolveSelectionControlColors,
|
|
9
|
-
resolveSelectionControlNextChecked,
|
|
10
|
-
} from '../../internal/resolvers';
|
|
11
|
-
import { useControllableState } from '../../internal/useControllableState';
|
|
12
|
-
import { ButtonBase } from '../../primitives/button-base';
|
|
13
|
-
import { useTheme } from '../../theme/ThemeContext';
|
|
14
|
-
import type { SwitchProps } from './types';
|
|
15
|
-
|
|
16
|
-
/*** Renders a controlled or uncontrolled accessible switch. */
|
|
17
|
-
export function Switch({
|
|
18
|
-
children,
|
|
19
|
-
checked,
|
|
20
|
-
defaultChecked = false,
|
|
21
|
-
onCheckedChange,
|
|
22
|
-
color = 'primary',
|
|
23
|
-
size = 'm',
|
|
24
|
-
disabled = false,
|
|
25
|
-
invalid = false,
|
|
26
|
-
readOnly = false,
|
|
27
|
-
accessibilityLabel,
|
|
28
|
-
testID,
|
|
29
|
-
...props
|
|
30
|
-
}: SwitchProps) {
|
|
31
|
-
const { theme } = useTheme();
|
|
32
|
-
const [isChecked, setChecked] = useControllableState<boolean>({
|
|
33
|
-
value: checked,
|
|
34
|
-
defaultValue: defaultChecked,
|
|
35
|
-
onChange: onCheckedChange,
|
|
36
|
-
});
|
|
37
|
-
const indicatorSize = resolveIndicatorSize(size);
|
|
38
|
-
const nextChecked = resolveSelectionControlNextChecked({
|
|
39
|
-
checked: isChecked,
|
|
40
|
-
disabled,
|
|
41
|
-
kind: 'switch',
|
|
42
|
-
readOnly,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<ButtonBase
|
|
47
|
-
{...props}
|
|
48
|
-
accessibilityLabel={accessibilityLabel}
|
|
49
|
-
accessibilityRole="switch"
|
|
50
|
-
accessibilityState={{ checked: isChecked }}
|
|
51
|
-
disabled={disabled}
|
|
52
|
-
onPress={nextChecked === null ? undefined : () => setChecked(nextChecked)}
|
|
53
|
-
testID={testID}
|
|
54
|
-
>
|
|
55
|
-
{(interactionState) => {
|
|
56
|
-
const fieldState = resolveFieldState({
|
|
57
|
-
disabled,
|
|
58
|
-
focused: interactionState.focused,
|
|
59
|
-
invalid,
|
|
60
|
-
readOnly,
|
|
61
|
-
});
|
|
62
|
-
const colors = resolveSelectionControlColors(theme, {
|
|
63
|
-
checked: isChecked,
|
|
64
|
-
fieldState,
|
|
65
|
-
hovered: interactionState.hovered,
|
|
66
|
-
pressed: interactionState.pressed,
|
|
67
|
-
color,
|
|
68
|
-
});
|
|
69
|
-
const labelEmphasis =
|
|
70
|
-
colors.labelColor === theme.semantics.content.muted ? 'muted' : 'default';
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<View
|
|
74
|
-
style={{
|
|
75
|
-
alignItems: 'center',
|
|
76
|
-
flexDirection: 'row',
|
|
77
|
-
opacity: colors.opacity,
|
|
78
|
-
}}
|
|
79
|
-
>
|
|
80
|
-
<View
|
|
81
|
-
radius="full"
|
|
82
|
-
style={{
|
|
83
|
-
backgroundColor: colors.trackColor,
|
|
84
|
-
borderColor: colors.borderColor,
|
|
85
|
-
borderWidth: 1,
|
|
86
|
-
justifyContent: 'center',
|
|
87
|
-
minWidth: indicatorSize.switchWidth,
|
|
88
|
-
paddingHorizontal: 2,
|
|
89
|
-
width: indicatorSize.switchWidth,
|
|
90
|
-
height: indicatorSize.switchHeight,
|
|
91
|
-
}}
|
|
92
|
-
>
|
|
93
|
-
<View
|
|
94
|
-
radius="full"
|
|
95
|
-
style={{
|
|
96
|
-
alignSelf: isChecked ? 'flex-end' : 'flex-start',
|
|
97
|
-
backgroundColor: colors.thumbColor,
|
|
98
|
-
height: indicatorSize.switchThumb,
|
|
99
|
-
width: indicatorSize.switchThumb,
|
|
100
|
-
}}
|
|
101
|
-
/>
|
|
102
|
-
</View>
|
|
103
|
-
{children ? (
|
|
104
|
-
<View ml="s">
|
|
105
|
-
<Text emphasis={labelEmphasis}>{children}</Text>
|
|
106
|
-
</View>
|
|
107
|
-
) : null}
|
|
108
|
-
</View>
|
|
109
|
-
);
|
|
110
|
-
}}
|
|
111
|
-
</ButtonBase>
|
|
112
|
-
);
|
|
113
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { TextInput } from '../../features/form/text-input/public';
|
|
4
|
-
import type { TextareaProps } from './types';
|
|
5
|
-
|
|
6
|
-
export function Textarea({ rows = 4, numberOfLines, style, ...props }: TextareaProps) {
|
|
7
|
-
return (
|
|
8
|
-
<TextInput
|
|
9
|
-
{...props}
|
|
10
|
-
multiline
|
|
11
|
-
numberOfLines={numberOfLines ?? rows}
|
|
12
|
-
style={[{ textAlignVertical: 'top' }, style]}
|
|
13
|
-
/>
|
|
14
|
-
);
|
|
15
|
-
}
|
|
File without changes
|