@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
package/src/index.test.ts
CHANGED
|
@@ -6,7 +6,6 @@ import type { SelectionSemantics, SurfaceColorDiagnostics } from './index';
|
|
|
6
6
|
import { createTheme } from './theme/createTheme';
|
|
7
7
|
|
|
8
8
|
const indexSource = readFileSync(new URL('./index.ts', import.meta.url), 'utf8');
|
|
9
|
-
const layoutIndexSource = readFileSync(new URL('./layout/index.ts', import.meta.url), 'utf8');
|
|
10
9
|
const packageJson = JSON.parse(
|
|
11
10
|
readFileSync(new URL('../package.json', import.meta.url), 'utf8'),
|
|
12
11
|
) as {
|
|
@@ -18,16 +17,20 @@ const packageJson = JSON.parse(
|
|
|
18
17
|
};
|
|
19
18
|
|
|
20
19
|
const expectedFeatureRootExports = [
|
|
20
|
+
"export { AppBar } from './features/app-bar/public';",
|
|
21
21
|
"export { Badge } from './features/badge/public';",
|
|
22
22
|
"export { Button, IconButton } from './features/button/public';",
|
|
23
23
|
"export { Card } from './features/card/public';",
|
|
24
24
|
"export { Checkbox } from './features/form/checkbox/public';",
|
|
25
|
+
"export { Field } from './features/form/field/public';",
|
|
25
26
|
"export { Radio } from './features/form/radio/public';",
|
|
27
|
+
"export { Switch } from './features/form/switch/public';",
|
|
26
28
|
"export { TextInput } from './features/form/text-input/public';",
|
|
27
29
|
"export { Icon, SUPPORTED_ICON_PROVIDERS } from './features/icon/public';",
|
|
28
30
|
"export { Image } from './features/image/public';",
|
|
29
31
|
"export { KeyboardAvoidingView } from './features/keyboard-avoiding-view/public';",
|
|
30
|
-
"export {
|
|
32
|
+
"export { Divider, Grid, ScrollView, View } from './features/layout/public';",
|
|
33
|
+
"export { List, ListItem } from './features/list/public';",
|
|
31
34
|
"export { Modal } from './features/modal/public';",
|
|
32
35
|
"export { PopoverMenu } from './features/popover-menu/public';",
|
|
33
36
|
"export { Popover } from './features/popover/public';",
|
|
@@ -38,64 +41,39 @@ const expectedFeatureRootExports = [
|
|
|
38
41
|
"export { Heading, Text } from './features/typography/public';",
|
|
39
42
|
] as const;
|
|
40
43
|
|
|
41
|
-
const
|
|
42
|
-
"export { Field } from './components/field';",
|
|
43
|
-
"export { HelperText } from './components/helper-text';",
|
|
44
|
-
"export { Label } from './components/label';",
|
|
45
|
-
"export { ListItem } from './components/list-item';",
|
|
46
|
-
"export { Switch } from './components/switch';",
|
|
47
|
-
"export { Textarea } from './components/textarea';",
|
|
44
|
+
const expectedCrossCuttingRootExports = [
|
|
48
45
|
"export type { InteractionPolicy, InteractionPolicyProps } from './interactionPolicy';",
|
|
49
46
|
"export * from './core/responsive';",
|
|
50
|
-
"export * from './layout';",
|
|
51
47
|
] as const;
|
|
52
48
|
|
|
53
49
|
describe('feature-owned root barrel contract', () => {
|
|
54
|
-
it('routes
|
|
50
|
+
it('routes UI through feature-owned public facades', () => {
|
|
55
51
|
expectedFeatureRootExports.forEach((line) => expect(indexSource).toContain(line));
|
|
56
52
|
});
|
|
57
53
|
|
|
58
|
-
it('does not retain
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
'./primitives/text',
|
|
76
|
-
]) {
|
|
77
|
-
expect(indexSource).not.toContain(legacyPath);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('removes migrated elements from the legacy layout facade', () => {
|
|
82
|
-
for (const name of [
|
|
83
|
-
'Box',
|
|
84
|
-
'Container',
|
|
85
|
-
'Divider',
|
|
86
|
-
'Grid',
|
|
87
|
-
'KeyboardAvoidingView',
|
|
88
|
-
'Stack',
|
|
89
|
-
'Surface',
|
|
90
|
-
]) {
|
|
91
|
-
expect(layoutIndexSource).not.toContain(`./${name}`);
|
|
92
|
-
}
|
|
54
|
+
it('does not retain removed component or layout facades and aliases', () => {
|
|
55
|
+
expect(indexSource).not.toContain("'./components/");
|
|
56
|
+
expect(indexSource).not.toContain("'./layout");
|
|
57
|
+
expect(indexSource).not.toMatch(/\bBoxProps\b/u);
|
|
58
|
+
expect(indexSource).not.toMatch(/\bContainerProps\b/u);
|
|
59
|
+
expect(indexSource).not.toMatch(/\bStackProps\b/u);
|
|
60
|
+
expect(indexSource).not.toMatch(/\bScrollAreaProps\b/u);
|
|
61
|
+
expect(indexSource).not.toMatch(/\bTextareaProps\b/u);
|
|
62
|
+
expect(indexSource).not.toMatch(/\bHelperTextProps\b/u);
|
|
63
|
+
expect(indexSource).not.toMatch(/\bLabelProps\b/u);
|
|
64
|
+
expect(indexSource).not.toMatch(/export\s*\{[^}]*\bBox\b/u);
|
|
65
|
+
expect(indexSource).not.toMatch(/export\s*\{[^}]*\bContainer\b/u);
|
|
66
|
+
expect(indexSource).not.toMatch(/export\s*\{[^}]*\bStack\b/u);
|
|
67
|
+
expect(indexSource).not.toMatch(/export\s*\{[^}]*\bScrollArea\b/u);
|
|
68
|
+
expect(indexSource).not.toMatch(/export\s*\{[^}]*\bTextarea\b/u);
|
|
69
|
+
expect(indexSource).not.toMatch(/export\s*\{[^}]*\bHelperText\b/u);
|
|
70
|
+
expect(indexSource).not.toMatch(/export\s*\{[^}]*\bLabel\b/u);
|
|
93
71
|
});
|
|
94
72
|
});
|
|
95
73
|
|
|
96
74
|
describe('remaining root barrel contract', () => {
|
|
97
|
-
it('keeps
|
|
98
|
-
|
|
75
|
+
it('keeps deliberate cross-cutting public APIs', () => {
|
|
76
|
+
expectedCrossCuttingRootExports.forEach((line) => expect(indexSource).toContain(line));
|
|
99
77
|
});
|
|
100
78
|
|
|
101
79
|
it('does not retain obsolete action-sheet, drawer, menu aliases, or navigation chrome', () => {
|
package/src/index.ts
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
export type { FieldProps } from './components/field';
|
|
2
|
-
export { Field } from './components/field';
|
|
3
|
-
export type { HelperTextProps } from './components/helper-text';
|
|
4
|
-
export { HelperText } from './components/helper-text';
|
|
5
|
-
export type { LabelProps } from './components/label';
|
|
6
|
-
export { Label } from './components/label';
|
|
7
|
-
export type { ListItemProps } from './components/list-item';
|
|
8
|
-
export { ListItem } from './components/list-item';
|
|
9
|
-
export type { SwitchProps } from './components/switch';
|
|
10
|
-
export { Switch } from './components/switch';
|
|
11
|
-
export type { TextareaProps } from './components/textarea';
|
|
12
|
-
export { Textarea } from './components/textarea';
|
|
13
1
|
export type { FontRuntime } from './context/FontContext';
|
|
14
2
|
export { FontProvider, useFontContext } from './context/FontContext';
|
|
15
3
|
export type { I18nInstance, TranslationRuntime, Translator } from './context/TranslationContext';
|
|
@@ -30,6 +18,8 @@ export {
|
|
|
30
18
|
AccordionItem,
|
|
31
19
|
AccordionTrigger,
|
|
32
20
|
} from './features/accordion/public';
|
|
21
|
+
export type { AppBarProps } from './features/app-bar/public';
|
|
22
|
+
export { AppBar } from './features/app-bar/public';
|
|
33
23
|
export type { BadgeProps } from './features/badge/public';
|
|
34
24
|
export { Badge } from './features/badge/public';
|
|
35
25
|
export type { ButtonIconSpec, ButtonProps, IconButtonProps } from './features/button/public';
|
|
@@ -38,8 +28,12 @@ export type { CardProps } from './features/card/public';
|
|
|
38
28
|
export { Card } from './features/card/public';
|
|
39
29
|
export type { CheckboxProps } from './features/form/checkbox/public';
|
|
40
30
|
export { Checkbox } from './features/form/checkbox/public';
|
|
31
|
+
export type { FieldProps } from './features/form/field/public';
|
|
32
|
+
export { Field } from './features/form/field/public';
|
|
41
33
|
export type { RadioProps } from './features/form/radio/public';
|
|
42
34
|
export { Radio } from './features/form/radio/public';
|
|
35
|
+
export type { SwitchProps } from './features/form/switch/public';
|
|
36
|
+
export { Switch } from './features/form/switch/public';
|
|
43
37
|
export type { TextInputProps } from './features/form/text-input/public';
|
|
44
38
|
export { TextInput } from './features/form/text-input/public';
|
|
45
39
|
export type {
|
|
@@ -58,14 +52,10 @@ export type {
|
|
|
58
52
|
KeyboardAvoidingViewProps,
|
|
59
53
|
} from './features/keyboard-avoiding-view/public';
|
|
60
54
|
export { KeyboardAvoidingView } from './features/keyboard-avoiding-view/public';
|
|
61
|
-
export type {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
GridProps,
|
|
66
|
-
StackProps,
|
|
67
|
-
} from './features/layout/public';
|
|
68
|
-
export { Box, Container, Divider, Grid, Stack } from './features/layout/public';
|
|
55
|
+
export type { DividerProps, GridProps, ScrollViewProps, ViewProps } from './features/layout/public';
|
|
56
|
+
export { Divider, Grid, ScrollView, View } from './features/layout/public';
|
|
57
|
+
export type { ListItemProps, ListProps } from './features/list/public';
|
|
58
|
+
export { List, ListItem } from './features/list/public';
|
|
69
59
|
export type { ModalProps } from './features/modal/public';
|
|
70
60
|
export { Modal } from './features/modal/public';
|
|
71
61
|
export type {
|
|
@@ -97,7 +87,6 @@ export { Tooltip } from './features/tooltip/public';
|
|
|
97
87
|
export type { HeadingLevel, HeadingProps, TextProps } from './features/typography/public';
|
|
98
88
|
export { Heading, Text } from './features/typography/public';
|
|
99
89
|
export type { InteractionPolicy, InteractionPolicyProps } from './interactionPolicy';
|
|
100
|
-
export * from './layout';
|
|
101
90
|
export type { ButtonBaseProps } from './primitives/button-base';
|
|
102
91
|
export { ButtonBase } from './primitives/button-base';
|
|
103
92
|
export type {
|
|
@@ -8,9 +8,10 @@ import {
|
|
|
8
8
|
resolveInteractiveState,
|
|
9
9
|
} from '../../internal/resolvers';
|
|
10
10
|
import { useTheme } from '../../theme/ThemeContext';
|
|
11
|
-
import {
|
|
11
|
+
import { resolveViewStyles } from '../../utils/resolveViewStyles';
|
|
12
12
|
import type { ButtonBaseProps } from './types';
|
|
13
13
|
|
|
14
|
+
/*** Resolves one Pressable state into the canonical Surface interaction state. */
|
|
14
15
|
function getInteractionState(
|
|
15
16
|
pressableState: PressableStateCallbackType,
|
|
16
17
|
hovered: boolean,
|
|
@@ -25,6 +26,7 @@ function getInteractionState(
|
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
/*** Renders the low-level token-aware Pressable boundary shared by Surface controls. */
|
|
28
30
|
export function ButtonBase({
|
|
29
31
|
children,
|
|
30
32
|
disabled = false,
|
|
@@ -43,7 +45,7 @@ export function ButtonBase({
|
|
|
43
45
|
const [hovered, setHovered] = React.useState(false);
|
|
44
46
|
const [focused, setFocused] = React.useState(false);
|
|
45
47
|
const isWeb = Platform.OS === 'web';
|
|
46
|
-
const
|
|
48
|
+
const resolvedViewStyles = resolveViewStyles(theme, breakpoint, props);
|
|
47
49
|
const passive = interactionPolicy === 'passive';
|
|
48
50
|
|
|
49
51
|
return (
|
|
@@ -54,9 +56,7 @@ export function ButtonBase({
|
|
|
54
56
|
disabled={disabled}
|
|
55
57
|
onBlur={() => setFocused(false)}
|
|
56
58
|
onFocus={() => {
|
|
57
|
-
if (isWeb)
|
|
58
|
-
setFocused(true);
|
|
59
|
-
}
|
|
59
|
+
if (isWeb) setFocused(true);
|
|
60
60
|
}}
|
|
61
61
|
onHoverIn={isWeb ? () => setHovered(true) : undefined}
|
|
62
62
|
onHoverOut={isWeb ? () => setHovered(false) : undefined}
|
|
@@ -64,9 +64,8 @@ export function ButtonBase({
|
|
|
64
64
|
onPress={passive ? undefined : onPress}
|
|
65
65
|
style={(pressableState) => {
|
|
66
66
|
const state = getInteractionState(pressableState, hovered, focused, disabled);
|
|
67
|
-
|
|
68
67
|
return [
|
|
69
|
-
|
|
68
|
+
resolvedViewStyles,
|
|
70
69
|
resolveFocusRingStyles(theme.semantics.border.focus, state.focused, isWeb),
|
|
71
70
|
style,
|
|
72
71
|
];
|
|
@@ -75,7 +74,6 @@ export function ButtonBase({
|
|
|
75
74
|
>
|
|
76
75
|
{(pressableState) => {
|
|
77
76
|
const state = getInteractionState(pressableState, hovered, focused, disabled);
|
|
78
|
-
|
|
79
77
|
return typeof children === 'function' ? children(state) : children;
|
|
80
78
|
}}
|
|
81
79
|
</Pressable>
|
|
@@ -3,10 +3,10 @@ import type { AccessibilityRole, AccessibilityState, GestureResponderEvent } fro
|
|
|
3
3
|
|
|
4
4
|
import type { InteractionPolicyProps } from '../../interactionPolicy';
|
|
5
5
|
import type { InteractionState } from '../../internal/resolvers/resolveInteractiveState';
|
|
6
|
-
import type {
|
|
6
|
+
import type { ViewProps } from '../../types/layout';
|
|
7
7
|
|
|
8
8
|
export interface ButtonBaseProps
|
|
9
|
-
extends Omit<
|
|
9
|
+
extends Omit<ViewProps, 'children' | 'pointerEvents'>, InteractionPolicyProps {
|
|
10
10
|
children?: React.ReactNode | ((state: InteractionState) => React.ReactNode);
|
|
11
11
|
disabled?: boolean;
|
|
12
12
|
onPress?: ((event: GestureResponderEvent) => void) | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import type { ViewProps } from './layout';
|
|
5
|
+
|
|
6
|
+
export interface AppBarProps extends Omit<ViewProps, 'children'> {
|
|
7
|
+
leading?: React.ReactNode;
|
|
8
|
+
trailing?: React.ReactNode;
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
safeAreaTop?: boolean;
|
|
11
|
+
divider?: boolean;
|
|
12
|
+
contentStyle?: StyleProp<ViewStyle>;
|
|
13
|
+
}
|
package/src/types/layout.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
ScrollViewProps as ReactNativeScrollViewProps,
|
|
4
|
+
StyleProp,
|
|
5
|
+
ViewProps as ReactNativeViewProps,
|
|
6
|
+
ViewStyle,
|
|
7
|
+
} from 'react-native';
|
|
3
8
|
|
|
4
9
|
import type { Responsive } from '../core/responsive';
|
|
5
10
|
import type { SurfaceTheme } from '../theme/types';
|
|
@@ -12,7 +17,7 @@ type RadiusValue = number | RadiusToken;
|
|
|
12
17
|
export type SpaceValue = number | SpaceToken;
|
|
13
18
|
export type ColorValue = string | ColorToken;
|
|
14
19
|
|
|
15
|
-
export interface
|
|
20
|
+
export interface ViewStyleProps {
|
|
16
21
|
p?: Responsive<SpaceValue>;
|
|
17
22
|
px?: Responsive<SpaceValue>;
|
|
18
23
|
py?: Responsive<SpaceValue>;
|
|
@@ -27,6 +32,9 @@ export interface BoxStyleProps {
|
|
|
27
32
|
mb?: Responsive<SpaceValue>;
|
|
28
33
|
ml?: Responsive<SpaceValue>;
|
|
29
34
|
mr?: Responsive<SpaceValue>;
|
|
35
|
+
gap?: Responsive<SpaceValue>;
|
|
36
|
+
rowGap?: Responsive<SpaceValue>;
|
|
37
|
+
columnGap?: Responsive<SpaceValue>;
|
|
30
38
|
bg?: Responsive<ColorValue>;
|
|
31
39
|
radius?: Responsive<RadiusValue>;
|
|
32
40
|
borderWidth?: Responsive<number>;
|
|
@@ -41,6 +49,12 @@ export interface BoxStyleProps {
|
|
|
41
49
|
flexGrow?: Responsive<number>;
|
|
42
50
|
flexShrink?: Responsive<number>;
|
|
43
51
|
flexBasis?: Responsive<number | string>;
|
|
52
|
+
direction?: Responsive<'row' | 'column'>;
|
|
53
|
+
align?: Responsive<'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline'>;
|
|
54
|
+
justify?: Responsive<
|
|
55
|
+
'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly'
|
|
56
|
+
>;
|
|
57
|
+
wrap?: Responsive<'nowrap' | 'wrap'>;
|
|
44
58
|
alignSelf?: Responsive<ViewStyle['alignSelf']>;
|
|
45
59
|
position?: Responsive<ViewStyle['position']>;
|
|
46
60
|
top?: Responsive<number>;
|
|
@@ -53,7 +67,7 @@ export interface BoxStyleProps {
|
|
|
53
67
|
style?: StyleProp<ViewStyle>;
|
|
54
68
|
}
|
|
55
69
|
|
|
56
|
-
export interface
|
|
70
|
+
export interface ViewProps extends ViewStyleProps {
|
|
57
71
|
accessibilityLabel?: ReactNativeViewProps['accessibilityLabel'];
|
|
58
72
|
accessibilityRole?: ReactNativeViewProps['accessibilityRole'];
|
|
59
73
|
accessibilityState?: ReactNativeViewProps['accessibilityState'];
|
|
@@ -63,34 +77,25 @@ export interface BoxProps extends BoxStyleProps {
|
|
|
63
77
|
testID?: string;
|
|
64
78
|
}
|
|
65
79
|
|
|
66
|
-
export interface
|
|
67
|
-
children?: React.ReactNode;
|
|
68
|
-
maxWidth?: Responsive<number>;
|
|
69
|
-
px?: Responsive<number | keyof SurfaceTheme['spacing']>;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface DividerProps extends Omit<BoxProps, 'bg' | 'height' | 'width'> {
|
|
80
|
+
export interface DividerProps extends Omit<ViewProps, 'bg' | 'height' | 'width'> {
|
|
73
81
|
orientation?: 'horizontal' | 'vertical';
|
|
74
82
|
color?: ColorValue;
|
|
75
83
|
thickness?: number;
|
|
76
84
|
}
|
|
77
85
|
|
|
78
|
-
export interface GridProps extends Omit<
|
|
86
|
+
export interface GridProps extends Omit<ViewProps, 'children'> {
|
|
79
87
|
children?: React.ReactNode;
|
|
80
|
-
cols
|
|
88
|
+
cols?: Responsive<number>;
|
|
81
89
|
gap?: Responsive<SpaceValue>;
|
|
82
90
|
rowGap?: Responsive<SpaceValue>;
|
|
83
91
|
colGap?: Responsive<SpaceValue>;
|
|
84
92
|
minItemWidth?: Responsive<number>;
|
|
85
93
|
}
|
|
86
94
|
|
|
87
|
-
export interface
|
|
95
|
+
export interface ScrollViewProps
|
|
96
|
+
extends
|
|
97
|
+
ViewStyleProps,
|
|
98
|
+
Omit<ReactNativeScrollViewProps, 'children' | 'contentContainerStyle' | 'style'> {
|
|
88
99
|
children?: React.ReactNode;
|
|
89
|
-
|
|
90
|
-
gap?: Responsive<SpaceValue>;
|
|
91
|
-
align?: Responsive<'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline'>;
|
|
92
|
-
justify?: Responsive<
|
|
93
|
-
'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly'
|
|
94
|
-
>;
|
|
95
|
-
wrap?: Responsive<'nowrap' | 'wrap'>;
|
|
100
|
+
contentContainerStyle?: StyleProp<ViewStyle>;
|
|
96
101
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
|
|
3
|
+
import type { InteractionPolicyProps } from '../interactionPolicy';
|
|
4
|
+
|
|
5
|
+
export interface ListProps {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
testID?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ListItemProps extends InteractionPolicyProps {
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
title?: React.ReactNode;
|
|
13
|
+
description?: React.ReactNode;
|
|
14
|
+
leading?: React.ReactNode;
|
|
15
|
+
trailing?: React.ReactNode;
|
|
16
|
+
onPress?: (() => void) | undefined;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
selected?: boolean;
|
|
19
|
+
compact?: boolean;
|
|
20
|
+
accessibilityLabel?: string;
|
|
21
|
+
testID?: string;
|
|
22
|
+
}
|
package/src/types/surface.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ViewProps } from './layout';
|
|
2
2
|
|
|
3
3
|
export type SurfaceVariant = 'default' | 'subtle' | 'raised' | 'outline';
|
|
4
4
|
|
|
5
|
-
export interface SurfaceProps extends Omit<
|
|
5
|
+
export interface SurfaceProps extends Omit<ViewProps, 'bg' | 'borderColor' | 'borderWidth'> {
|
|
6
6
|
variant?: SurfaceVariant;
|
|
7
7
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
|
|
3
|
-
import type { ControlSize } from '
|
|
4
|
-
import type { ButtonBaseProps } from '
|
|
5
|
-
import type { SurfaceColor } from '
|
|
3
|
+
import type { ControlSize } from '../internal/resolvers/resolveControlSize';
|
|
4
|
+
import type { ButtonBaseProps } from '../primitives/button-base';
|
|
5
|
+
import type { SurfaceColor } from '../surfaceColor';
|
|
6
6
|
|
|
7
7
|
export interface SwitchProps extends Omit<
|
|
8
8
|
ButtonBaseProps,
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
|
|
3
|
+
import type { SurfaceTheme } from '../theme/types';
|
|
4
|
+
import { resolveViewStyles } from './resolveViewStyles';
|
|
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('resolveViewStyles spacing and responsive layout', () => {
|
|
13
|
+
test('resolves padding and margins correctly', () => {
|
|
14
|
+
const styles = resolveViewStyles(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' }, direction: { base: 'column', lg: 'row' } } as const;
|
|
21
|
+
expect(resolveViewStyles(mockTheme, 'base', props).padding).toBe(4);
|
|
22
|
+
expect(resolveViewStyles(mockTheme, 'base', props).flexDirection).toBe('column');
|
|
23
|
+
expect(resolveViewStyles(mockTheme, 'lg', props).padding).toBe(16);
|
|
24
|
+
expect(resolveViewStyles(mockTheme, 'lg', props).flexDirection).toBe('row');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('resolves gap tokens with native flex layout props', () => {
|
|
28
|
+
const styles = resolveViewStyles(mockTheme, 'base', {
|
|
29
|
+
align: 'center',
|
|
30
|
+
gap: 'm',
|
|
31
|
+
justify: 'space-between',
|
|
32
|
+
wrap: 'wrap',
|
|
33
|
+
});
|
|
34
|
+
expect(styles.alignItems).toBe('center');
|
|
35
|
+
expect(styles.gap).toBe(8);
|
|
36
|
+
expect(styles.justifyContent).toBe('space-between');
|
|
37
|
+
expect(styles.flexWrap).toBe('wrap');
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('resolveViewStyles visual and dimension styles', () => {
|
|
42
|
+
test('resolves colors and border styles', () => {
|
|
43
|
+
const styles = resolveViewStyles(mockTheme, 'base', {
|
|
44
|
+
bg: 'primary',
|
|
45
|
+
radius: 'm',
|
|
46
|
+
borderWidth: 1,
|
|
47
|
+
borderColor: 'surface',
|
|
48
|
+
});
|
|
49
|
+
expect(styles.backgroundColor).toBe('#007AFF');
|
|
50
|
+
expect(styles.borderRadius).toBe(8);
|
|
51
|
+
expect(styles.borderWidth).toBe(1);
|
|
52
|
+
expect(styles.borderColor).toBe('#FFFFFF');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('resolves spacing tokens for dimension props and preserves raw strings', () => {
|
|
56
|
+
const styles = resolveViewStyles(mockTheme, 'base', {
|
|
57
|
+
width: 'm',
|
|
58
|
+
minHeight: 'l',
|
|
59
|
+
maxWidth: '50%',
|
|
60
|
+
});
|
|
61
|
+
expect(styles.width).toBe(8);
|
|
62
|
+
expect(styles.minHeight).toBe(16);
|
|
63
|
+
expect(styles.maxWidth).toBe('50%');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('handles undefined props gracefully', () => {
|
|
67
|
+
const styles = resolveViewStyles(mockTheme, 'base', {});
|
|
68
|
+
expect(styles.padding).toBeUndefined();
|
|
69
|
+
expect(styles.margin).toBeUndefined();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -4,14 +4,14 @@ import { resolveResponsive } from '../core/responsive/resolve';
|
|
|
4
4
|
import type { Breakpoint } from '../core/responsive/types';
|
|
5
5
|
import { resolveToken } from '../theme/resolveToken';
|
|
6
6
|
import type { SurfaceTheme } from '../theme/types';
|
|
7
|
-
import type {
|
|
7
|
+
import type { ColorValue, ViewStyleProps } from '../types/layout';
|
|
8
8
|
import { resolveSpacing } from './resolveSpacing';
|
|
9
9
|
|
|
10
|
-
/*** Resolves responsive
|
|
11
|
-
export function
|
|
10
|
+
/*** Resolves responsive Surface View style props into one React Native view style. */
|
|
11
|
+
export function resolveViewStyles(
|
|
12
12
|
theme: SurfaceTheme,
|
|
13
13
|
breakpoint: Breakpoint,
|
|
14
|
-
props:
|
|
14
|
+
props: ViewStyleProps,
|
|
15
15
|
): ViewStyle {
|
|
16
16
|
return {
|
|
17
17
|
elevation: 0,
|
|
@@ -22,11 +22,11 @@ export function resolveBoxStyles(
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
/*** Resolves padding and
|
|
25
|
+
/*** Resolves padding, margin, and gap styles from responsive spacing props. */
|
|
26
26
|
function resolveSpacingStyles(
|
|
27
27
|
theme: SurfaceTheme,
|
|
28
28
|
breakpoint: Breakpoint,
|
|
29
|
-
props:
|
|
29
|
+
props: ViewStyleProps,
|
|
30
30
|
): ViewStyle {
|
|
31
31
|
return {
|
|
32
32
|
padding: resolveSpacing(theme, resolveResponsive(props.p, breakpoint)),
|
|
@@ -43,6 +43,9 @@ function resolveSpacingStyles(
|
|
|
43
43
|
marginBottom: resolveSpacing(theme, resolveResponsive(props.mb, breakpoint)),
|
|
44
44
|
marginLeft: resolveSpacing(theme, resolveResponsive(props.ml, breakpoint)),
|
|
45
45
|
marginRight: resolveSpacing(theme, resolveResponsive(props.mr, breakpoint)),
|
|
46
|
+
gap: resolveSpacing(theme, resolveResponsive(props.gap, breakpoint)),
|
|
47
|
+
rowGap: resolveSpacing(theme, resolveResponsive(props.rowGap, breakpoint)),
|
|
48
|
+
columnGap: resolveSpacing(theme, resolveResponsive(props.columnGap, breakpoint)),
|
|
46
49
|
};
|
|
47
50
|
}
|
|
48
51
|
|
|
@@ -50,7 +53,7 @@ function resolveSpacingStyles(
|
|
|
50
53
|
function resolveVisualStyles(
|
|
51
54
|
theme: SurfaceTheme,
|
|
52
55
|
breakpoint: Breakpoint,
|
|
53
|
-
props:
|
|
56
|
+
props: ViewStyleProps,
|
|
54
57
|
): ViewStyle {
|
|
55
58
|
return {
|
|
56
59
|
backgroundColor: resolveColor(theme, resolveResponsive(props.bg, breakpoint)),
|
|
@@ -64,7 +67,7 @@ function resolveVisualStyles(
|
|
|
64
67
|
function resolveDimensionStyles(
|
|
65
68
|
theme: SurfaceTheme,
|
|
66
69
|
breakpoint: Breakpoint,
|
|
67
|
-
props:
|
|
70
|
+
props: ViewStyleProps,
|
|
68
71
|
): ViewStyle {
|
|
69
72
|
return {
|
|
70
73
|
width: resolveDimension(
|
|
@@ -95,12 +98,16 @@ function resolveDimensionStyles(
|
|
|
95
98
|
}
|
|
96
99
|
|
|
97
100
|
/*** Resolves responsive flex, positioning, and visibility styles. */
|
|
98
|
-
function resolveLayoutStyles(breakpoint: Breakpoint, props:
|
|
101
|
+
function resolveLayoutStyles(breakpoint: Breakpoint, props: ViewStyleProps): ViewStyle {
|
|
99
102
|
return {
|
|
100
103
|
flex: resolveResponsive(props.flex, breakpoint),
|
|
101
104
|
flexGrow: resolveResponsive(props.flexGrow, breakpoint),
|
|
102
105
|
flexShrink: resolveResponsive(props.flexShrink, breakpoint),
|
|
103
106
|
flexBasis: resolveResponsive(props.flexBasis, breakpoint) as ViewStyle['flexBasis'],
|
|
107
|
+
flexDirection: resolveResponsive(props.direction, breakpoint),
|
|
108
|
+
alignItems: resolveResponsive(props.align, breakpoint),
|
|
109
|
+
justifyContent: resolveResponsive(props.justify, breakpoint),
|
|
110
|
+
flexWrap: resolveResponsive(props.wrap, breakpoint),
|
|
104
111
|
alignSelf: resolveResponsive(props.alignSelf, breakpoint),
|
|
105
112
|
position: resolveResponsive(props.position, breakpoint),
|
|
106
113
|
top: resolveResponsive(props.top, breakpoint),
|
|
@@ -8,18 +8,17 @@ await mock.module('react-native', () => ReactNativeWeb);
|
|
|
8
8
|
|
|
9
9
|
const scrollContentStyle = { padding: 4 };
|
|
10
10
|
|
|
11
|
-
const {
|
|
11
|
+
const { Grid, ScrollView, View } = await import('./features/layout/public');
|
|
12
12
|
const { KeyboardAvoidingView } = await import('./features/keyboard-avoiding-view/public');
|
|
13
|
-
const {
|
|
14
|
-
const { Show } = await import('./layout/Show');
|
|
13
|
+
const { Show } = await import('./core/responsive/Show');
|
|
15
14
|
const { OverlayProvider } = await import('./internal/overlay/OverlayProvider');
|
|
16
15
|
const { ThemeProvider } = await import('./theme/ThemeContext');
|
|
17
16
|
|
|
18
17
|
function ResponsiveAcceptanceTree() {
|
|
19
18
|
return (
|
|
20
19
|
<ThemeProvider>
|
|
21
|
-
<
|
|
22
|
-
<
|
|
20
|
+
<View maxWidth={{ base: 640, md: 960 }} px={{ base: 12, md: 24 }} testID="container">
|
|
21
|
+
<ScrollView contentContainerStyle={scrollContentStyle} testID="scroll-view">
|
|
23
22
|
<Grid cols={{ base: 1, md: 2 }} gap={{ base: 8, md: 16 }} testID="grid">
|
|
24
23
|
<ReactNativeWeb.View testID="grid-first" />
|
|
25
24
|
<ReactNativeWeb.View testID="grid-second" />
|
|
@@ -30,8 +29,8 @@ function ResponsiveAcceptanceTree() {
|
|
|
30
29
|
>
|
|
31
30
|
<ReactNativeWeb.Text>wide-content</ReactNativeWeb.Text>
|
|
32
31
|
</Show>
|
|
33
|
-
</
|
|
34
|
-
</
|
|
32
|
+
</ScrollView>
|
|
33
|
+
</View>
|
|
35
34
|
</ThemeProvider>
|
|
36
35
|
);
|
|
37
36
|
}
|
|
@@ -40,7 +39,7 @@ test('RN Web 0.21 statically renders and hydrates representative responsive prim
|
|
|
40
39
|
const markup = renderToString(<ResponsiveAcceptanceTree />);
|
|
41
40
|
|
|
42
41
|
expect(markup).toContain('data-testid="container"');
|
|
43
|
-
expect(markup).toContain('data-testid="scroll-
|
|
42
|
+
expect(markup).toContain('data-testid="scroll-view"');
|
|
44
43
|
expect(markup).toContain('data-testid="grid"');
|
|
45
44
|
expect(markup).toContain('static-fallback');
|
|
46
45
|
expect(markup).not.toContain('wide-content');
|
|
@@ -68,7 +67,7 @@ test('RN Web 0.21 statically renders and hydrates representative responsive prim
|
|
|
68
67
|
await act(async () => Promise.resolve());
|
|
69
68
|
|
|
70
69
|
expect(container.querySelector('[data-testid="container"]')).not.toBeNull();
|
|
71
|
-
expect(container.querySelector('[data-testid="scroll-
|
|
70
|
+
expect(container.querySelector('[data-testid="scroll-view"]')).not.toBeNull();
|
|
72
71
|
expect(container.querySelectorAll('[data-testid^="grid-"]')).toHaveLength(2);
|
|
73
72
|
expect(hydrationErrors).toEqual([]);
|
|
74
73
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../../src/components/field/Field.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,wBAAgB,KAAK,CAAC,EACpB,QAAQ,EACR,KAAK,EACL,UAAU,EACV,SAAS,EACT,QAAgB,EAChB,QAAgB,EAChB,OAAe,EACf,QAAgB,EAChB,MAAM,GACP,EAAE,UAAU,qBAgCZ"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Box, Stack } from '../../features/layout/public';
|
|
3
|
-
import { resolveFieldPresentation, resolveFieldState } from '../../internal/resolvers';
|
|
4
|
-
import { HelperText } from '../helper-text';
|
|
5
|
-
import { Label } from '../label';
|
|
6
|
-
export function Field({ children, label, helperText, errorText, required = false, disabled = false, invalid = false, readOnly = false, testID, }) {
|
|
7
|
-
const hasErrorText = Boolean(errorText);
|
|
8
|
-
const fieldState = resolveFieldState({
|
|
9
|
-
disabled,
|
|
10
|
-
invalid: invalid || hasErrorText,
|
|
11
|
-
readOnly,
|
|
12
|
-
});
|
|
13
|
-
const presentation = resolveFieldPresentation(fieldState);
|
|
14
|
-
return (<Stack gap="xs" testID={testID}>
|
|
15
|
-
{label ? (<Label color={presentation.labelColor} emphasis={presentation.labelEmphasis} required={required}>
|
|
16
|
-
{label}
|
|
17
|
-
</Label>) : null}
|
|
18
|
-
<Box>{children}</Box>
|
|
19
|
-
{hasErrorText ? (<HelperText color={presentation.helperColor} emphasis={presentation.helperEmphasis}>
|
|
20
|
-
{errorText}
|
|
21
|
-
</HelperText>) : helperText ? (<HelperText color={presentation.helperColor} emphasis={presentation.helperEmphasis}>
|
|
22
|
-
{helperText}
|
|
23
|
-
</HelperText>) : null}
|
|
24
|
-
</Stack>);
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=Field.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Field.js","sourceRoot":"","sources":["../../../src/components/field/Field.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAGjC,MAAM,UAAU,KAAK,CAAC,EACpB,QAAQ,EACR,KAAK,EACL,UAAU,EACV,SAAS,EACT,QAAQ,GAAG,KAAK,EAChB,QAAQ,GAAG,KAAK,EAChB,OAAO,GAAG,KAAK,EACf,QAAQ,GAAG,KAAK,EAChB,MAAM,GACK;IACX,MAAM,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IACxC,MAAM,UAAU,GAAG,iBAAiB,CAAC;QACnC,QAAQ;QACR,OAAO,EAAE,OAAO,IAAI,YAAY;QAChC,QAAQ;KACT,CAAC,CAAC;IACH,MAAM,YAAY,GAAG,wBAAwB,CAAC,UAAU,CAAC,CAAC;IAE1D,OAAO,CACL,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAC7B;MAAA,CAAC,KAAK,CAAC,CAAC,CAAC,CACP,CAAC,KAAK,CACJ,KAAK,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,CAC/B,QAAQ,CAAC,CAAC,YAAY,CAAC,aAAa,CAAC,CACrC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAEnB;UAAA,CAAC,KAAK,CACR;QAAA,EAAE,KAAK,CAAC,CACT,CAAC,CAAC,CAAC,IAAI,CACR;MAAA,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,GAAG,CACpB;MAAA,CAAC,YAAY,CAAC,CAAC,CAAC,CACd,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,cAAc,CAAC,CACjF;UAAA,CAAC,SAAS,CACZ;QAAA,EAAE,UAAU,CAAC,CACd,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CACf,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,cAAc,CAAC,CACjF;UAAA,CAAC,UAAU,CACb;QAAA,EAAE,UAAU,CAAC,CACd,CAAC,CAAC,CAAC,IAAI,CACV;IAAA,EAAE,KAAK,CAAC,CACT,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\n\nimport { Box, Stack } from '../../features/layout/public';\nimport { resolveFieldPresentation, resolveFieldState } from '../../internal/resolvers';\nimport { HelperText } from '../helper-text';\nimport { Label } from '../label';\nimport type { FieldProps } from './types';\n\nexport function Field({\n children,\n label,\n helperText,\n errorText,\n required = false,\n disabled = false,\n invalid = false,\n readOnly = false,\n testID,\n}: FieldProps) {\n const hasErrorText = Boolean(errorText);\n const fieldState = resolveFieldState({\n disabled,\n invalid: invalid || hasErrorText,\n readOnly,\n });\n const presentation = resolveFieldPresentation(fieldState);\n\n return (\n <Stack gap=\"xs\" testID={testID}>\n {label ? (\n <Label\n color={presentation.labelColor}\n emphasis={presentation.labelEmphasis}\n required={required}\n >\n {label}\n </Label>\n ) : null}\n <Box>{children}</Box>\n {hasErrorText ? (\n <HelperText color={presentation.helperColor} emphasis={presentation.helperEmphasis}>\n {errorText}\n </HelperText>\n ) : helperText ? (\n <HelperText color={presentation.helperColor} emphasis={presentation.helperEmphasis}>\n {helperText}\n </HelperText>\n ) : null}\n </Stack>\n );\n}\n"]}
|