@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
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { Box } 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
|
-
export function Switch({
|
|
17
|
-
children,
|
|
18
|
-
checked,
|
|
19
|
-
defaultChecked = false,
|
|
20
|
-
onCheckedChange,
|
|
21
|
-
color = 'primary',
|
|
22
|
-
size = 'm',
|
|
23
|
-
disabled = false,
|
|
24
|
-
invalid = false,
|
|
25
|
-
readOnly = false,
|
|
26
|
-
accessibilityLabel,
|
|
27
|
-
testID,
|
|
28
|
-
...props
|
|
29
|
-
}: SwitchProps) {
|
|
30
|
-
const { theme } = useTheme();
|
|
31
|
-
const [isChecked, setChecked] = useControllableState<boolean>({
|
|
32
|
-
value: checked,
|
|
33
|
-
defaultValue: defaultChecked,
|
|
34
|
-
onChange: onCheckedChange,
|
|
35
|
-
});
|
|
36
|
-
const indicatorSize = resolveIndicatorSize(size);
|
|
37
|
-
const nextChecked = resolveSelectionControlNextChecked({
|
|
38
|
-
checked: isChecked,
|
|
39
|
-
disabled,
|
|
40
|
-
kind: 'switch',
|
|
41
|
-
readOnly,
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<ButtonBase
|
|
46
|
-
{...props}
|
|
47
|
-
accessibilityLabel={accessibilityLabel}
|
|
48
|
-
accessibilityRole="switch"
|
|
49
|
-
accessibilityState={{ checked: isChecked }}
|
|
50
|
-
disabled={disabled}
|
|
51
|
-
onPress={
|
|
52
|
-
nextChecked === null
|
|
53
|
-
? undefined
|
|
54
|
-
: () => {
|
|
55
|
-
setChecked(nextChecked);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
testID={testID}
|
|
59
|
-
>
|
|
60
|
-
{(interactionState) => {
|
|
61
|
-
const fieldState = resolveFieldState({
|
|
62
|
-
disabled,
|
|
63
|
-
focused: interactionState.focused,
|
|
64
|
-
invalid,
|
|
65
|
-
readOnly,
|
|
66
|
-
});
|
|
67
|
-
const colors = resolveSelectionControlColors(theme, {
|
|
68
|
-
checked: isChecked,
|
|
69
|
-
fieldState,
|
|
70
|
-
hovered: interactionState.hovered,
|
|
71
|
-
pressed: interactionState.pressed,
|
|
72
|
-
color,
|
|
73
|
-
});
|
|
74
|
-
const labelEmphasis =
|
|
75
|
-
colors.labelColor === theme.semantics.content.muted ? 'muted' : 'default';
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<Box
|
|
79
|
-
style={{
|
|
80
|
-
alignItems: 'center',
|
|
81
|
-
flexDirection: 'row',
|
|
82
|
-
opacity: colors.opacity,
|
|
83
|
-
}}
|
|
84
|
-
>
|
|
85
|
-
<Box
|
|
86
|
-
radius="full"
|
|
87
|
-
style={{
|
|
88
|
-
backgroundColor: colors.trackColor,
|
|
89
|
-
borderColor: colors.borderColor,
|
|
90
|
-
borderWidth: 1,
|
|
91
|
-
justifyContent: 'center',
|
|
92
|
-
minWidth: indicatorSize.switchWidth,
|
|
93
|
-
paddingHorizontal: 2,
|
|
94
|
-
width: indicatorSize.switchWidth,
|
|
95
|
-
height: indicatorSize.switchHeight,
|
|
96
|
-
}}
|
|
97
|
-
>
|
|
98
|
-
<Box
|
|
99
|
-
radius="full"
|
|
100
|
-
style={{
|
|
101
|
-
alignSelf: isChecked ? 'flex-end' : 'flex-start',
|
|
102
|
-
backgroundColor: colors.thumbColor,
|
|
103
|
-
height: indicatorSize.switchThumb,
|
|
104
|
-
width: indicatorSize.switchThumb,
|
|
105
|
-
}}
|
|
106
|
-
/>
|
|
107
|
-
</Box>
|
|
108
|
-
{children ? (
|
|
109
|
-
<Box ml="s">
|
|
110
|
-
<Text emphasis={labelEmphasis}>{children}</Text>
|
|
111
|
-
</Box>
|
|
112
|
-
) : null}
|
|
113
|
-
</Box>
|
|
114
|
-
);
|
|
115
|
-
}}
|
|
116
|
-
</ButtonBase>
|
|
117
|
-
);
|
|
118
|
-
}
|
|
@@ -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
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { StyleSheet, View, type ViewStyle } from 'react-native';
|
|
3
|
-
|
|
4
|
-
import { resolveResponsive, useResponsiveRuntime } from '../../../../core/responsive';
|
|
5
|
-
import { useTheme } from '../../../../theme/ThemeContext';
|
|
6
|
-
import type { ContainerProps } from '../../../../types/layout';
|
|
7
|
-
import { resolveSpacing } from '../../../../utils/resolveSpacing';
|
|
8
|
-
import { Box } from './Box';
|
|
9
|
-
|
|
10
|
-
/*** Centers responsive content inside a configurable maximum width. */
|
|
11
|
-
export function Container({
|
|
12
|
-
children,
|
|
13
|
-
maxWidth = { base: Number.MAX_SAFE_INTEGER, lg: 1120 },
|
|
14
|
-
px = { base: 16, md: 24, lg: 32 },
|
|
15
|
-
...props
|
|
16
|
-
}: ContainerProps) {
|
|
17
|
-
const { theme } = useTheme();
|
|
18
|
-
const { breakpoint } = useResponsiveRuntime();
|
|
19
|
-
const activeMaxWidth = resolveResponsive(maxWidth, breakpoint);
|
|
20
|
-
const activePx = resolveSpacing(theme, resolveResponsive(px, breakpoint));
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<Box {...props} width="100%" style={[styles.fullWidth, props.style]}>
|
|
24
|
-
<View style={resolveContainerStyle(activeMaxWidth, activePx)}>{children}</View>
|
|
25
|
-
</Box>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/*** Resolves centered responsive Container dimensions and padding. */
|
|
30
|
-
function resolveContainerStyle(
|
|
31
|
-
maxWidth: number | undefined,
|
|
32
|
-
horizontalPadding: number | undefined,
|
|
33
|
-
): ViewStyle {
|
|
34
|
-
return {
|
|
35
|
-
alignSelf: 'center',
|
|
36
|
-
maxWidth,
|
|
37
|
-
paddingLeft: horizontalPadding,
|
|
38
|
-
paddingRight: horizontalPadding,
|
|
39
|
-
width: '100%',
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const styles = StyleSheet.create({ fullWidth: { width: '100%' } });
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
2
|
-
|
|
3
|
-
import { describe, expect, it } from 'bun:test';
|
|
4
|
-
|
|
5
|
-
describe('Stack layout contract', () => {
|
|
6
|
-
it('keeps authored children as direct flex items and applies spacing through gap', async () => {
|
|
7
|
-
const source = await readFile(new URL('./Stack.tsx', import.meta.url), 'utf8');
|
|
8
|
-
expect(source).toContain('gap: activeGap');
|
|
9
|
-
expect(source).toContain('{children}');
|
|
10
|
-
expect(source).not.toContain("from 'react-native'");
|
|
11
|
-
expect(source).not.toContain('React.Children');
|
|
12
|
-
});
|
|
13
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
|
|
3
|
-
import { resolveResponsive, useResponsiveRuntime } from '../../../../core/responsive';
|
|
4
|
-
import { useTheme } from '../../../../theme/ThemeContext';
|
|
5
|
-
import type { StackProps } from '../../../../types/layout';
|
|
6
|
-
import { resolveSpacing } from '../../../../utils/resolveSpacing';
|
|
7
|
-
import { Box } from './Box';
|
|
8
|
-
|
|
9
|
-
/*** Stacks authored children directly along a responsive flex direction. */
|
|
10
|
-
export function Stack({
|
|
11
|
-
children,
|
|
12
|
-
direction = 'column',
|
|
13
|
-
gap = 0,
|
|
14
|
-
align,
|
|
15
|
-
justify,
|
|
16
|
-
wrap,
|
|
17
|
-
...props
|
|
18
|
-
}: StackProps) {
|
|
19
|
-
const { theme } = useTheme();
|
|
20
|
-
const { breakpoint } = useResponsiveRuntime();
|
|
21
|
-
const activeDirection = resolveResponsive(direction, breakpoint) ?? 'column';
|
|
22
|
-
const activeGap = resolveSpacing(theme, resolveResponsive(gap, breakpoint)) ?? 0;
|
|
23
|
-
const activeAlign = resolveResponsive(align, breakpoint);
|
|
24
|
-
const activeJustify = resolveResponsive(justify, breakpoint);
|
|
25
|
-
const activeWrap = resolveResponsive(wrap, breakpoint);
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<Box
|
|
29
|
-
{...props}
|
|
30
|
-
style={[
|
|
31
|
-
{
|
|
32
|
-
flexDirection: activeDirection,
|
|
33
|
-
gap: activeGap,
|
|
34
|
-
alignItems: activeAlign,
|
|
35
|
-
justifyContent: activeJustify,
|
|
36
|
-
flexWrap: activeWrap,
|
|
37
|
-
},
|
|
38
|
-
props.style,
|
|
39
|
-
]}
|
|
40
|
-
>
|
|
41
|
-
{children}
|
|
42
|
-
</Box>
|
|
43
|
-
);
|
|
44
|
-
}
|
package/src/layout/AppBar.tsx
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type StyleProp, View, type ViewStyle } from 'react-native';
|
|
3
|
-
import { SafeAreaInsetsContext } from 'react-native-safe-area-context';
|
|
4
|
-
|
|
5
|
-
import { Box, type BoxProps, Divider } from '../features/layout/public';
|
|
6
|
-
import { useTheme } from '../theme/ThemeContext';
|
|
7
|
-
|
|
8
|
-
export interface AppBarProps extends Omit<BoxProps, 'children'> {
|
|
9
|
-
leading?: React.ReactNode;
|
|
10
|
-
trailing?: React.ReactNode;
|
|
11
|
-
children?: React.ReactNode;
|
|
12
|
-
safeAreaTop?: boolean;
|
|
13
|
-
divider?: boolean;
|
|
14
|
-
contentStyle?: StyleProp<ViewStyle>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function AppBar({
|
|
18
|
-
leading,
|
|
19
|
-
trailing,
|
|
20
|
-
children,
|
|
21
|
-
safeAreaTop = true,
|
|
22
|
-
divider = false,
|
|
23
|
-
contentStyle,
|
|
24
|
-
bg,
|
|
25
|
-
style,
|
|
26
|
-
...props
|
|
27
|
-
}: AppBarProps) {
|
|
28
|
-
const { theme } = useTheme();
|
|
29
|
-
const insets = React.use(SafeAreaInsetsContext);
|
|
30
|
-
const topInset = safeAreaTop ? (insets?.top ?? 0) : 0;
|
|
31
|
-
const safeAreaStyle: ViewStyle | undefined =
|
|
32
|
-
topInset === 0 ? undefined : { paddingTop: topInset };
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<Box {...props} bg={bg ?? theme.semantics.surface.default} style={style}>
|
|
36
|
-
<View style={safeAreaStyle}>
|
|
37
|
-
<View
|
|
38
|
-
style={[
|
|
39
|
-
{
|
|
40
|
-
minHeight: 56,
|
|
41
|
-
flexDirection: 'row',
|
|
42
|
-
alignItems: 'center',
|
|
43
|
-
paddingHorizontal: theme.spacing.m,
|
|
44
|
-
},
|
|
45
|
-
contentStyle,
|
|
46
|
-
]}
|
|
47
|
-
>
|
|
48
|
-
{leading ? (
|
|
49
|
-
<View style={{ marginRight: theme.spacing.s, flexShrink: 0 }}>{leading}</View>
|
|
50
|
-
) : null}
|
|
51
|
-
<View style={{ flex: 1, minWidth: 0 }}>{children}</View>
|
|
52
|
-
{trailing ? (
|
|
53
|
-
<View style={{ marginLeft: theme.spacing.s, flexShrink: 0 }}>{trailing}</View>
|
|
54
|
-
) : null}
|
|
55
|
-
</View>
|
|
56
|
-
{divider ? <Divider color={theme.semantics.neutral.divider} thickness={1} /> : null}
|
|
57
|
-
</View>
|
|
58
|
-
</Box>
|
|
59
|
-
);
|
|
60
|
-
}
|
package/src/layout/Center.tsx
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { Box, type BoxProps } from '../features/layout/public';
|
|
4
|
-
|
|
5
|
-
export interface CenterProps extends BoxProps {
|
|
6
|
-
axis?: 'horizontal' | 'vertical' | 'both';
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function Center({ axis = 'both', style, ...props }: CenterProps) {
|
|
10
|
-
return (
|
|
11
|
-
<Box
|
|
12
|
-
{...props}
|
|
13
|
-
style={[
|
|
14
|
-
{
|
|
15
|
-
alignItems: axis === 'both' || axis === 'horizontal' ? 'center' : undefined,
|
|
16
|
-
justifyContent: axis === 'both' || axis === 'vertical' ? 'center' : undefined,
|
|
17
|
-
},
|
|
18
|
-
style,
|
|
19
|
-
]}
|
|
20
|
-
/>
|
|
21
|
-
);
|
|
22
|
-
}
|
package/src/layout/Inline.tsx
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { Stack, type StackProps } from '../features/layout/public';
|
|
4
|
-
|
|
5
|
-
export type InlineProps = Omit<StackProps, 'direction'>;
|
|
6
|
-
|
|
7
|
-
export function Inline({ wrap = 'wrap', align = 'center', ...props }: InlineProps) {
|
|
8
|
-
return <Stack {...props} align={align} direction="row" wrap={wrap} />;
|
|
9
|
-
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
ScrollView,
|
|
4
|
-
type ScrollViewProps as ReactNativeScrollViewProps,
|
|
5
|
-
type StyleProp,
|
|
6
|
-
type ViewStyle,
|
|
7
|
-
} from 'react-native';
|
|
8
|
-
|
|
9
|
-
import { useResponsiveRuntime } from '../core/responsive';
|
|
10
|
-
import { useTheme } from '../theme/ThemeContext';
|
|
11
|
-
import type { BoxStyleProps } from '../types/layout';
|
|
12
|
-
import { resolveBoxStyles } from '../utils/resolveBoxStyles';
|
|
13
|
-
|
|
14
|
-
export interface ScrollAreaProps
|
|
15
|
-
extends
|
|
16
|
-
BoxStyleProps,
|
|
17
|
-
Omit<ReactNativeScrollViewProps, 'children' | 'contentContainerStyle' | 'style'> {
|
|
18
|
-
children?: React.ReactNode;
|
|
19
|
-
contentContainerStyle?: StyleProp<ViewStyle>;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function ScrollArea({
|
|
23
|
-
children,
|
|
24
|
-
contentContainerStyle,
|
|
25
|
-
p,
|
|
26
|
-
px,
|
|
27
|
-
py,
|
|
28
|
-
pt,
|
|
29
|
-
pb,
|
|
30
|
-
pl,
|
|
31
|
-
pr,
|
|
32
|
-
m,
|
|
33
|
-
mx,
|
|
34
|
-
my,
|
|
35
|
-
mt,
|
|
36
|
-
mb,
|
|
37
|
-
ml,
|
|
38
|
-
mr,
|
|
39
|
-
bg,
|
|
40
|
-
radius,
|
|
41
|
-
borderWidth,
|
|
42
|
-
borderColor,
|
|
43
|
-
width,
|
|
44
|
-
height,
|
|
45
|
-
minWidth,
|
|
46
|
-
maxWidth,
|
|
47
|
-
minHeight,
|
|
48
|
-
maxHeight,
|
|
49
|
-
flex,
|
|
50
|
-
flexGrow,
|
|
51
|
-
flexShrink,
|
|
52
|
-
flexBasis,
|
|
53
|
-
alignSelf,
|
|
54
|
-
position,
|
|
55
|
-
top,
|
|
56
|
-
bottom,
|
|
57
|
-
left,
|
|
58
|
-
right,
|
|
59
|
-
overflow,
|
|
60
|
-
zIndex,
|
|
61
|
-
opacity,
|
|
62
|
-
style,
|
|
63
|
-
...scrollProps
|
|
64
|
-
}: ScrollAreaProps) {
|
|
65
|
-
const { theme } = useTheme();
|
|
66
|
-
const { breakpoint } = useResponsiveRuntime();
|
|
67
|
-
const resolved = resolveBoxStyles(theme, breakpoint, {
|
|
68
|
-
p,
|
|
69
|
-
px,
|
|
70
|
-
py,
|
|
71
|
-
pt,
|
|
72
|
-
pb,
|
|
73
|
-
pl,
|
|
74
|
-
pr,
|
|
75
|
-
m,
|
|
76
|
-
mx,
|
|
77
|
-
my,
|
|
78
|
-
mt,
|
|
79
|
-
mb,
|
|
80
|
-
ml,
|
|
81
|
-
mr,
|
|
82
|
-
bg,
|
|
83
|
-
radius,
|
|
84
|
-
borderWidth,
|
|
85
|
-
borderColor,
|
|
86
|
-
width,
|
|
87
|
-
height,
|
|
88
|
-
minWidth,
|
|
89
|
-
maxWidth,
|
|
90
|
-
minHeight,
|
|
91
|
-
maxHeight,
|
|
92
|
-
flex,
|
|
93
|
-
flexGrow,
|
|
94
|
-
flexShrink,
|
|
95
|
-
flexBasis,
|
|
96
|
-
alignSelf,
|
|
97
|
-
position,
|
|
98
|
-
top,
|
|
99
|
-
bottom,
|
|
100
|
-
left,
|
|
101
|
-
right,
|
|
102
|
-
overflow,
|
|
103
|
-
zIndex,
|
|
104
|
-
opacity,
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
return (
|
|
108
|
-
<ScrollView
|
|
109
|
-
{...scrollProps}
|
|
110
|
-
contentContainerStyle={contentContainerStyle}
|
|
111
|
-
style={[resolved, style]}
|
|
112
|
-
>
|
|
113
|
-
{children}
|
|
114
|
-
</ScrollView>
|
|
115
|
-
);
|
|
116
|
-
}
|
package/src/layout/Spacer.tsx
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { Box } from '../features/layout/public';
|
|
4
|
-
import type { SpaceValue } from '../types/layout';
|
|
5
|
-
|
|
6
|
-
export interface SpacerProps {
|
|
7
|
-
size?: SpaceValue;
|
|
8
|
-
axis?: 'horizontal' | 'vertical' | 'both';
|
|
9
|
-
testID?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function Spacer({ size = 'm', axis = 'vertical', testID }: SpacerProps) {
|
|
13
|
-
if (axis === 'horizontal') {
|
|
14
|
-
return <Box testID={testID} width={size} />;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (axis === 'both') {
|
|
18
|
-
return <Box testID={testID} height={size} width={size} />;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return <Box testID={testID} height={size} />;
|
|
22
|
-
}
|
package/src/layout/Template.tsx
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
type Breakpoint,
|
|
6
|
-
resolveResponsive,
|
|
7
|
-
type Responsive,
|
|
8
|
-
useResponsiveRuntime,
|
|
9
|
-
} from '../core/responsive';
|
|
10
|
-
import { Box, type BoxProps } from '../features/layout/public';
|
|
11
|
-
import { useTheme } from '../theme/ThemeContext';
|
|
12
|
-
import type { SpaceValue } from '../types/layout';
|
|
13
|
-
import { resolveSpacing } from '../utils/resolveSpacing';
|
|
14
|
-
|
|
15
|
-
type SlotMap = Record<string, React.ReactNode>;
|
|
16
|
-
type TemplateMap = Partial<Record<Breakpoint, string[][]>>;
|
|
17
|
-
type ColumnsMap = Partial<Record<Breakpoint, number[]>>;
|
|
18
|
-
|
|
19
|
-
export interface TemplateProps extends Omit<BoxProps, 'children'> {
|
|
20
|
-
slots: SlotMap;
|
|
21
|
-
templates: TemplateMap;
|
|
22
|
-
columns?: ColumnsMap;
|
|
23
|
-
gap?: Responsive<SpaceValue>;
|
|
24
|
-
rowGap?: Responsive<SpaceValue>;
|
|
25
|
-
colGap?: Responsive<SpaceValue>;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function resolveByBreakpointMap<T>(
|
|
29
|
-
map: Partial<Record<Breakpoint, T>> | undefined,
|
|
30
|
-
breakpoint: Breakpoint,
|
|
31
|
-
): T | undefined {
|
|
32
|
-
return resolveResponsive(map, breakpoint);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function Template({
|
|
36
|
-
slots,
|
|
37
|
-
templates,
|
|
38
|
-
columns,
|
|
39
|
-
gap = 0,
|
|
40
|
-
rowGap,
|
|
41
|
-
colGap,
|
|
42
|
-
...props
|
|
43
|
-
}: TemplateProps) {
|
|
44
|
-
const { theme } = useTheme();
|
|
45
|
-
const { breakpoint } = useResponsiveRuntime();
|
|
46
|
-
|
|
47
|
-
const resolvedTemplate = resolveByBreakpointMap(templates, breakpoint) ?? [];
|
|
48
|
-
const resolvedColumns = resolveByBreakpointMap(columns, breakpoint);
|
|
49
|
-
const defaultGap = resolveResponsive(gap, breakpoint) ?? 0;
|
|
50
|
-
const rowSpacing = Number(
|
|
51
|
-
resolveSpacing(theme, resolveResponsive(rowGap, breakpoint) ?? defaultGap) ?? 0,
|
|
52
|
-
);
|
|
53
|
-
const colSpacing = Number(
|
|
54
|
-
resolveSpacing(theme, resolveResponsive(colGap, breakpoint) ?? defaultGap) ?? 0,
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<Box {...props}>
|
|
59
|
-
{resolvedTemplate.map((row, rowIndex) => (
|
|
60
|
-
<View
|
|
61
|
-
key={`row-${String(rowIndex)}`}
|
|
62
|
-
style={{
|
|
63
|
-
flexDirection: 'row',
|
|
64
|
-
marginTop: rowIndex === 0 ? 0 : rowSpacing,
|
|
65
|
-
}}
|
|
66
|
-
>
|
|
67
|
-
{row.map((slotId, cellIndex) => {
|
|
68
|
-
const weight = resolvedColumns?.[cellIndex] ?? 1;
|
|
69
|
-
const node = slots[slotId];
|
|
70
|
-
return (
|
|
71
|
-
<View
|
|
72
|
-
key={`${slotId}-${String(rowIndex)}-${String(cellIndex)}`}
|
|
73
|
-
style={{
|
|
74
|
-
flex: weight,
|
|
75
|
-
marginLeft: cellIndex === 0 ? 0 : colSpacing,
|
|
76
|
-
}}
|
|
77
|
-
>
|
|
78
|
-
{node}
|
|
79
|
-
</View>
|
|
80
|
-
);
|
|
81
|
-
})}
|
|
82
|
-
</View>
|
|
83
|
-
))}
|
|
84
|
-
</Box>
|
|
85
|
-
);
|
|
86
|
-
}
|
package/src/layout/index.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type { AppBarProps } from './AppBar';
|
|
2
|
-
export { AppBar } from './AppBar';
|
|
3
|
-
export type { CenterProps } from './Center';
|
|
4
|
-
export { Center } from './Center';
|
|
5
|
-
export type { InlineProps } from './Inline';
|
|
6
|
-
export { Inline } from './Inline';
|
|
7
|
-
export type { ScrollAreaProps } from './ScrollArea';
|
|
8
|
-
export { ScrollArea } from './ScrollArea';
|
|
9
|
-
export type { ShowProps } from './Show';
|
|
10
|
-
export { Show } from './Show';
|
|
11
|
-
export type { SpacerProps } from './Spacer';
|
|
12
|
-
export { Spacer } from './Spacer';
|
|
13
|
-
export type { TemplateProps } from './Template';
|
|
14
|
-
export { Template } from './Template';
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'bun:test';
|
|
2
|
-
|
|
3
|
-
import type { SurfaceTheme } from '../theme/types';
|
|
4
|
-
import { resolveBoxStyles } from './resolveBoxStyles';
|
|
5
|
-
|
|
6
|
-
const mockTheme = {
|
|
7
|
-
spacing: { s: 4, m: 8, l: 16 },
|
|
8
|
-
radii: { m: 8 },
|
|
9
|
-
colors: { primary: '#007AFF', surface: '#FFFFFF' },
|
|
10
|
-
} as unknown as SurfaceTheme;
|
|
11
|
-
|
|
12
|
-
describe('resolveBoxStyles', () => {
|
|
13
|
-
test('resolves padding and margins correctly', () => {
|
|
14
|
-
const styles = resolveBoxStyles(mockTheme, 'base', { p: 's', m: 8 });
|
|
15
|
-
expect(styles.padding).toBe(4);
|
|
16
|
-
expect(styles.margin).toBe(8);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test('resolves responsive properties', () => {
|
|
20
|
-
const props = { p: { base: 's', lg: 'l' } } as const;
|
|
21
|
-
expect(resolveBoxStyles(mockTheme, 'base', props).padding).toBe(4);
|
|
22
|
-
expect(resolveBoxStyles(mockTheme, 'lg', props).padding).toBe(16);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test('resolves colors and border styles', () => {
|
|
26
|
-
const styles = resolveBoxStyles(mockTheme, 'base', {
|
|
27
|
-
bg: 'primary',
|
|
28
|
-
radius: 'm',
|
|
29
|
-
borderWidth: 1,
|
|
30
|
-
borderColor: 'surface',
|
|
31
|
-
});
|
|
32
|
-
expect(styles.backgroundColor).toBe('#007AFF');
|
|
33
|
-
expect(styles.borderRadius).toBe(8);
|
|
34
|
-
expect(styles.borderWidth).toBe(1);
|
|
35
|
-
expect(styles.borderColor).toBe('#FFFFFF');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('resolves spacing tokens for dimension props and preserves raw strings', () => {
|
|
39
|
-
const styles = resolveBoxStyles(mockTheme, 'base', {
|
|
40
|
-
width: 'm',
|
|
41
|
-
minHeight: 'l',
|
|
42
|
-
maxWidth: '50%',
|
|
43
|
-
});
|
|
44
|
-
expect(styles.width).toBe(8);
|
|
45
|
-
expect(styles.minHeight).toBe(16);
|
|
46
|
-
expect(styles.maxWidth).toBe('50%');
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test('handles undefined props gracefully', () => {
|
|
50
|
-
const styles = resolveBoxStyles(mockTheme, 'base', {});
|
|
51
|
-
expect(styles.padding).toBeUndefined();
|
|
52
|
-
expect(styles.margin).toBeUndefined();
|
|
53
|
-
});
|
|
54
|
-
});
|
|
File without changes
|