@ankhorage/surface 5.0.1 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -2
- package/dist/{layout → core/responsive}/Show.d.ts +2 -1
- package/dist/core/responsive/Show.d.ts.map +1 -0
- package/dist/{layout → core/responsive}/Show.js +3 -1
- package/dist/core/responsive/Show.js.map +1 -0
- package/dist/core/responsive/index.d.ts +1 -0
- package/dist/core/responsive/index.d.ts.map +1 -1
- package/dist/core/responsive/index.js +1 -0
- package/dist/core/responsive/index.js.map +1 -1
- package/dist/features/app-bar/adapters/inbound/AppBar.d.ts +5 -0
- package/dist/features/app-bar/adapters/inbound/AppBar.d.ts.map +1 -0
- package/dist/features/app-bar/adapters/inbound/AppBar.js +40 -0
- package/dist/features/app-bar/adapters/inbound/AppBar.js.map +1 -0
- package/dist/features/app-bar/public.d.ts +3 -0
- package/dist/features/app-bar/public.d.ts.map +1 -0
- package/dist/features/app-bar/public.js +2 -0
- package/dist/features/app-bar/public.js.map +1 -0
- package/dist/features/badge/adapters/inbound/Badge.js +3 -3
- package/dist/features/badge/adapters/inbound/Badge.js.map +1 -1
- package/dist/features/button/adapters/inbound/Button.js +8 -8
- package/dist/features/button/adapters/inbound/Button.js.map +1 -1
- package/dist/features/button/adapters/inbound/IconButton.js +3 -3
- package/dist/features/button/adapters/inbound/IconButton.js.map +1 -1
- package/dist/features/form/checkbox/adapters/inbound/Checkbox.js +7 -7
- package/dist/features/form/checkbox/adapters/inbound/Checkbox.js.map +1 -1
- package/dist/{components/field → features/form/field/adapters/inbound}/Field.d.ts +2 -1
- package/dist/features/form/field/adapters/inbound/Field.d.ts.map +1 -0
- package/dist/features/form/field/adapters/inbound/Field.js +40 -0
- package/dist/features/form/field/adapters/inbound/Field.js.map +1 -0
- package/dist/features/form/field/public.d.ts +3 -0
- package/dist/features/form/field/public.d.ts.map +1 -0
- package/dist/features/form/field/public.js +2 -0
- package/dist/features/form/field/public.js.map +1 -0
- package/dist/features/form/radio/adapters/inbound/Radio.js +8 -8
- package/dist/features/form/radio/adapters/inbound/Radio.js.map +1 -1
- package/dist/{components/switch → features/form/switch/adapters/inbound}/Switch.d.ts +2 -1
- package/dist/features/form/switch/adapters/inbound/Switch.d.ts.map +1 -0
- package/dist/features/form/switch/adapters/inbound/Switch.js +52 -0
- package/dist/features/form/switch/adapters/inbound/Switch.js.map +1 -0
- package/dist/features/form/switch/public.d.ts +3 -0
- package/dist/features/form/switch/public.d.ts.map +1 -0
- package/dist/features/form/switch/public.js +2 -0
- package/dist/features/form/switch/public.js.map +1 -0
- package/dist/features/form/text-input/adapters/inbound/TextInput.d.ts.map +1 -1
- package/dist/features/form/text-input/adapters/inbound/TextInput.js +8 -4
- package/dist/features/form/text-input/adapters/inbound/TextInput.js.map +1 -1
- package/dist/features/layout/adapters/inbound/Divider.js +2 -2
- package/dist/features/layout/adapters/inbound/Divider.js.map +1 -1
- package/dist/features/layout/adapters/inbound/Grid.d.ts.map +1 -1
- package/dist/features/layout/adapters/inbound/Grid.js +7 -9
- package/dist/features/layout/adapters/inbound/Grid.js.map +1 -1
- package/dist/features/layout/adapters/inbound/ScrollView.d.ts +5 -0
- package/dist/features/layout/adapters/inbound/ScrollView.d.ts.map +1 -0
- package/dist/features/layout/adapters/inbound/ScrollView.js +69 -0
- package/dist/features/layout/adapters/inbound/ScrollView.js.map +1 -0
- package/dist/features/layout/adapters/inbound/View.d.ts +5 -0
- package/dist/features/layout/adapters/inbound/View.d.ts.map +1 -0
- package/dist/features/layout/adapters/inbound/View.js +17 -0
- package/dist/features/layout/adapters/inbound/View.js.map +1 -0
- package/dist/features/layout/public.d.ts +3 -4
- package/dist/features/layout/public.d.ts.map +1 -1
- package/dist/features/layout/public.js +2 -3
- package/dist/features/layout/public.js.map +1 -1
- package/dist/features/list/adapters/inbound/List.d.ts +5 -0
- package/dist/features/list/adapters/inbound/List.d.ts.map +1 -0
- package/dist/features/list/adapters/inbound/List.js +7 -0
- package/dist/features/list/adapters/inbound/List.js.map +1 -0
- package/dist/features/list/adapters/inbound/ListItem.d.ts +5 -0
- package/dist/features/list/adapters/inbound/ListItem.d.ts.map +1 -0
- package/dist/features/list/adapters/inbound/ListItem.js +59 -0
- package/dist/features/list/adapters/inbound/ListItem.js.map +1 -0
- package/dist/features/list/public.d.ts +4 -0
- package/dist/features/list/public.d.ts.map +1 -0
- package/dist/features/list/public.js +3 -0
- package/dist/features/list/public.js.map +1 -0
- package/dist/features/modal/adapters/inbound/Modal.d.ts.map +1 -1
- package/dist/features/modal/adapters/inbound/Modal.js +8 -8
- package/dist/features/modal/adapters/inbound/Modal.js.map +1 -1
- package/dist/features/popover-menu/adapters/inbound/PopoverMenu.d.ts.map +1 -1
- package/dist/features/popover-menu/adapters/inbound/PopoverMenu.js +11 -12
- package/dist/features/popover-menu/adapters/inbound/PopoverMenu.js.map +1 -1
- package/dist/features/surface/adapters/inbound/Surface.d.ts +1 -1
- package/dist/features/surface/adapters/inbound/Surface.d.ts.map +1 -1
- package/dist/features/surface/adapters/inbound/Surface.js +3 -3
- package/dist/features/surface/adapters/inbound/Surface.js.map +1 -1
- package/dist/features/tabs/adapters/inbound/Tab.js +3 -3
- package/dist/features/tabs/adapters/inbound/Tab.js.map +1 -1
- package/dist/features/tabs/adapters/inbound/TabList.d.ts.map +1 -1
- package/dist/features/tabs/adapters/inbound/TabList.js +3 -5
- package/dist/features/tabs/adapters/inbound/TabList.js.map +1 -1
- package/dist/features/tabs/adapters/inbound/Tabs.js +2 -2
- package/dist/features/tabs/adapters/inbound/Tabs.js.map +1 -1
- package/dist/features/toast/adapters/inbound/Toast.js +5 -5
- package/dist/features/toast/adapters/inbound/Toast.js.map +1 -1
- package/dist/features/toast/adapters/inbound/ToastProvider.js +3 -3
- package/dist/features/toast/adapters/inbound/ToastProvider.js.map +1 -1
- package/dist/index.d.ts +10 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -8
- package/dist/index.js.map +1 -1
- package/dist/primitives/button-base/ButtonBase.d.ts +1 -0
- package/dist/primitives/button-base/ButtonBase.d.ts.map +1 -1
- package/dist/primitives/button-base/ButtonBase.js +6 -5
- package/dist/primitives/button-base/ButtonBase.js.map +1 -1
- package/dist/primitives/button-base/types.d.ts +2 -2
- package/dist/primitives/button-base/types.d.ts.map +1 -1
- package/dist/primitives/button-base/types.js.map +1 -1
- package/dist/types/app-bar.d.ts +12 -0
- package/dist/types/app-bar.d.ts.map +1 -0
- package/dist/types/app-bar.js +2 -0
- package/dist/types/app-bar.js.map +1 -0
- package/dist/{components/field/types.d.ts → types/field.d.ts} +1 -1
- package/dist/types/field.d.ts.map +1 -0
- package/dist/types/field.js +2 -0
- package/dist/types/field.js.map +1 -0
- package/dist/types/layout.d.ts +15 -17
- package/dist/types/layout.d.ts.map +1 -1
- package/dist/types/layout.js.map +1 -1
- package/dist/types/list.d.ts +20 -0
- package/dist/types/list.d.ts.map +1 -0
- package/dist/types/list.js +2 -0
- package/dist/types/list.js.map +1 -0
- package/dist/types/surface.d.ts +2 -2
- package/dist/types/surface.d.ts.map +1 -1
- package/dist/types/surface.js.map +1 -1
- package/dist/{components/switch/types.d.ts → types/switch.d.ts} +4 -4
- package/dist/types/switch.d.ts.map +1 -0
- package/dist/types/switch.js +2 -0
- package/dist/types/switch.js.map +1 -0
- package/dist/utils/resolveViewStyles.d.ts +7 -0
- package/dist/utils/resolveViewStyles.d.ts.map +1 -0
- package/dist/utils/{resolveBoxStyles.js → resolveViewStyles.js} +11 -4
- package/dist/utils/resolveViewStyles.js.map +1 -0
- package/package.json +1 -1
- package/src/{layout → core/responsive}/Show.tsx +4 -1
- package/src/core/responsive/index.ts +1 -0
- package/src/features/app-bar/adapters/inbound/AppBar.tsx +69 -0
- package/src/features/app-bar/public.ts +2 -0
- package/src/features/badge/adapters/inbound/Badge.tsx +3 -3
- package/src/features/button/adapters/inbound/Button.tsx +8 -8
- package/src/features/button/adapters/inbound/IconButton.tsx +3 -3
- package/src/features/form/checkbox/adapters/inbound/Checkbox.tsx +7 -7
- package/src/features/form/field/adapters/inbound/Field.tsx +82 -0
- package/src/features/form/field/public.ts +2 -0
- package/src/features/form/radio/adapters/inbound/Radio.tsx +8 -8
- package/src/features/form/switch/adapters/inbound/Switch.tsx +123 -0
- package/src/features/form/switch/public.ts +2 -0
- package/src/features/form/text-input/adapters/inbound/TextInput.tsx +21 -5
- package/src/features/layout/adapters/inbound/Divider.tsx +2 -2
- package/src/features/layout/adapters/inbound/Grid.tsx +12 -14
- package/src/features/layout/adapters/inbound/ScrollView.tsx +102 -0
- package/src/features/layout/adapters/inbound/{Box.tsx → View.tsx} +9 -9
- package/src/features/layout/public.ts +3 -10
- package/src/features/list/adapters/inbound/List.tsx +9 -0
- package/src/features/list/adapters/inbound/ListItem.tsx +128 -0
- package/src/features/list/public.test.ts +13 -0
- package/src/features/list/public.ts +3 -0
- package/src/features/modal/adapters/inbound/Modal.tsx +11 -8
- package/src/features/popover-menu/adapters/inbound/PopoverMenu.tsx +11 -14
- package/src/features/surface/adapters/inbound/Surface.tsx +3 -3
- package/src/features/tabs/adapters/inbound/Tab.tsx +3 -3
- package/src/features/tabs/adapters/inbound/TabList.tsx +3 -6
- package/src/features/tabs/adapters/inbound/Tabs.tsx +2 -2
- package/src/features/toast/adapters/inbound/Toast.tsx +5 -5
- package/src/features/toast/adapters/inbound/ToastProvider.tsx +3 -3
- package/src/index.test.ts +26 -48
- package/src/index.ts +10 -21
- package/src/primitives/button-base/ButtonBase.tsx +6 -8
- package/src/primitives/button-base/types.ts +2 -2
- package/src/types/app-bar.ts +13 -0
- package/src/types/layout.ts +25 -20
- package/src/types/list.ts +22 -0
- package/src/types/surface.ts +2 -2
- package/src/{components/switch/types.ts → types/switch.ts} +3 -3
- package/src/utils/resolveViewStyles.test.ts +71 -0
- package/src/utils/{resolveBoxStyles.ts → resolveViewStyles.ts} +16 -9
- package/src/webAcceptance.test.tsx +8 -9
- package/dist/components/field/Field.d.ts.map +0 -1
- package/dist/components/field/Field.js +0 -26
- package/dist/components/field/Field.js.map +0 -1
- package/dist/components/field/index.d.ts +0 -3
- package/dist/components/field/index.d.ts.map +0 -1
- package/dist/components/field/index.js +0 -2
- package/dist/components/field/index.js.map +0 -1
- package/dist/components/field/types.d.ts.map +0 -1
- package/dist/components/field/types.js +0 -2
- package/dist/components/field/types.js.map +0 -1
- package/dist/components/helper-text/HelperText.d.ts +0 -4
- package/dist/components/helper-text/HelperText.d.ts.map +0 -1
- package/dist/components/helper-text/HelperText.js +0 -8
- package/dist/components/helper-text/HelperText.js.map +0 -1
- package/dist/components/helper-text/index.d.ts +0 -3
- package/dist/components/helper-text/index.d.ts.map +0 -1
- package/dist/components/helper-text/index.js +0 -2
- package/dist/components/helper-text/index.js.map +0 -1
- package/dist/components/helper-text/types.d.ts +0 -9
- package/dist/components/helper-text/types.d.ts.map +0 -1
- package/dist/components/helper-text/types.js +0 -2
- package/dist/components/helper-text/types.js.map +0 -1
- package/dist/components/label/Label.d.ts +0 -4
- package/dist/components/label/Label.d.ts.map +0 -1
- package/dist/components/label/Label.js +0 -11
- package/dist/components/label/Label.js.map +0 -1
- package/dist/components/label/index.d.ts +0 -3
- package/dist/components/label/index.d.ts.map +0 -1
- package/dist/components/label/index.js +0 -2
- package/dist/components/label/index.js.map +0 -1
- package/dist/components/label/types.d.ts +0 -10
- package/dist/components/label/types.d.ts.map +0 -1
- package/dist/components/label/types.js +0 -2
- package/dist/components/label/types.js.map +0 -1
- package/dist/components/list-item/ListItem.d.ts +0 -4
- package/dist/components/list-item/ListItem.d.ts.map +0 -1
- package/dist/components/list-item/ListItem.js +0 -43
- package/dist/components/list-item/ListItem.js.map +0 -1
- package/dist/components/list-item/index.d.ts +0 -3
- package/dist/components/list-item/index.d.ts.map +0 -1
- package/dist/components/list-item/index.js +0 -2
- package/dist/components/list-item/index.js.map +0 -1
- package/dist/components/list-item/types.d.ts +0 -11
- package/dist/components/list-item/types.d.ts.map +0 -1
- package/dist/components/list-item/types.js +0 -2
- package/dist/components/list-item/types.js.map +0 -1
- package/dist/components/switch/Switch.d.ts.map +0 -1
- package/dist/components/switch/Switch.js +0 -71
- package/dist/components/switch/Switch.js.map +0 -1
- package/dist/components/switch/index.d.ts +0 -3
- package/dist/components/switch/index.d.ts.map +0 -1
- package/dist/components/switch/index.js +0 -2
- package/dist/components/switch/index.js.map +0 -1
- package/dist/components/switch/types.d.ts.map +0 -1
- package/dist/components/switch/types.js +0 -2
- package/dist/components/switch/types.js.map +0 -1
- package/dist/components/textarea/Textarea.d.ts +0 -4
- package/dist/components/textarea/Textarea.d.ts.map +0 -1
- package/dist/components/textarea/Textarea.js +0 -6
- package/dist/components/textarea/Textarea.js.map +0 -1
- package/dist/components/textarea/index.d.ts +0 -3
- package/dist/components/textarea/index.d.ts.map +0 -1
- package/dist/components/textarea/index.js +0 -2
- package/dist/components/textarea/index.js.map +0 -1
- package/dist/components/textarea/types.d.ts +0 -5
- package/dist/components/textarea/types.d.ts.map +0 -1
- package/dist/components/textarea/types.js +0 -2
- package/dist/components/textarea/types.js.map +0 -1
- package/dist/features/layout/adapters/inbound/Box.d.ts +0 -5
- package/dist/features/layout/adapters/inbound/Box.d.ts.map +0 -1
- package/dist/features/layout/adapters/inbound/Box.js +0 -17
- package/dist/features/layout/adapters/inbound/Box.js.map +0 -1
- package/dist/features/layout/adapters/inbound/Container.d.ts +0 -5
- package/dist/features/layout/adapters/inbound/Container.d.ts.map +0 -1
- package/dist/features/layout/adapters/inbound/Container.js +0 -28
- package/dist/features/layout/adapters/inbound/Container.js.map +0 -1
- package/dist/features/layout/adapters/inbound/Stack.d.ts +0 -5
- package/dist/features/layout/adapters/inbound/Stack.d.ts.map +0 -1
- package/dist/features/layout/adapters/inbound/Stack.js +0 -27
- package/dist/features/layout/adapters/inbound/Stack.js.map +0 -1
- package/dist/layout/AppBar.d.ts +0 -13
- package/dist/layout/AppBar.d.ts.map +0 -1
- package/dist/layout/AppBar.js +0 -30
- package/dist/layout/AppBar.js.map +0 -1
- package/dist/layout/Center.d.ts +0 -7
- package/dist/layout/Center.d.ts.map +0 -1
- package/dist/layout/Center.js +0 -12
- package/dist/layout/Center.js.map +0 -1
- package/dist/layout/Inline.d.ts +0 -5
- package/dist/layout/Inline.d.ts.map +0 -1
- package/dist/layout/Inline.js +0 -6
- package/dist/layout/Inline.js.map +0 -1
- package/dist/layout/ScrollArea.d.ts +0 -9
- package/dist/layout/ScrollArea.d.ts.map +0 -1
- package/dist/layout/ScrollArea.js +0 -52
- package/dist/layout/ScrollArea.js.map +0 -1
- package/dist/layout/Show.d.ts.map +0 -1
- package/dist/layout/Show.js.map +0 -1
- package/dist/layout/Spacer.d.ts +0 -9
- package/dist/layout/Spacer.d.ts.map +0 -1
- package/dist/layout/Spacer.js +0 -12
- package/dist/layout/Spacer.js.map +0 -1
- package/dist/layout/Template.d.ts +0 -18
- package/dist/layout/Template.d.ts.map +0 -1
- package/dist/layout/Template.js +0 -36
- package/dist/layout/Template.js.map +0 -1
- package/dist/layout/index.d.ts +0 -15
- package/dist/layout/index.d.ts.map +0 -1
- package/dist/layout/index.js +0 -8
- package/dist/layout/index.js.map +0 -1
- package/dist/utils/resolveBoxStyles.d.ts +0 -7
- package/dist/utils/resolveBoxStyles.d.ts.map +0 -1
- package/dist/utils/resolveBoxStyles.js.map +0 -1
- package/src/components/field/Field.tsx +0 -51
- package/src/components/field/index.ts +0 -2
- package/src/components/helper-text/HelperText.tsx +0 -12
- package/src/components/helper-text/index.ts +0 -2
- package/src/components/helper-text/types.ts +0 -10
- package/src/components/label/Label.tsx +0 -23
- package/src/components/label/index.ts +0 -2
- package/src/components/label/types.ts +0 -11
- package/src/components/list-item/ListItem.tsx +0 -72
- package/src/components/list-item/index.ts +0 -2
- package/src/components/list-item/types.ts +0 -11
- package/src/components/switch/Switch.tsx +0 -118
- package/src/components/switch/index.ts +0 -2
- package/src/components/textarea/Textarea.tsx +0 -15
- package/src/components/textarea/index.ts +0 -2
- package/src/components/textarea/types.ts +0 -5
- package/src/features/layout/adapters/inbound/Container.tsx +0 -43
- package/src/features/layout/adapters/inbound/Stack.test.ts +0 -13
- package/src/features/layout/adapters/inbound/Stack.tsx +0 -44
- package/src/layout/AppBar.tsx +0 -60
- package/src/layout/Center.tsx +0 -22
- package/src/layout/Inline.tsx +0 -9
- package/src/layout/ScrollArea.tsx +0 -116
- package/src/layout/Spacer.tsx +0 -22
- package/src/layout/Template.tsx +0 -86
- package/src/layout/index.ts +0 -14
- package/src/utils/resolveBoxStyles.test.ts +0 -54
- /package/src/{components/field/types.ts → types/field.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveViewStyles.js","sourceRoot":"","sources":["../../src/utils/resolveViewStyles.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,sFAAsF;AACtF,MAAM,UAAU,iBAAiB,CAC/B,KAAmB,EACnB,UAAsB,EACtB,KAAqB;IAErB,OAAO;QACL,SAAS,EAAE,CAAC;QACZ,GAAG,oBAAoB,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC;QACjD,GAAG,mBAAmB,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC;QAChD,GAAG,sBAAsB,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC;QACnD,GAAG,mBAAmB,CAAC,UAAU,EAAE,KAAK,CAAC;KAC1C,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,SAAS,oBAAoB,CAC3B,KAAmB,EACnB,UAAsB,EACtB,KAAqB;IAErB,OAAO;QACL,OAAO,EAAE,cAAc,CAAC,KAAK,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;QACtE,iBAAiB,EAAE,cAAc,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QACnD,IAAI,EAAE,iBAAiB,CAAC,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC;QAC/C,KAAK,EAAE,iBAAiB,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC;QACjD,QAAQ,EAAE,iBAAiB,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAU,CAAC;QACvD,MAAM,EAAE,iBAAiB,CAAC,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC;QACnD,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC;KACtD,CAAC;AACJ,CAAC;AAED,sDAAsD;AACtD,SAAS,aAAa,CACpB,KAAmB,EACnB,KAAuD;IAEvD,OAAO,YAAY,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC1C,CAAC;AAED,gFAAgF;AAChF,SAAS,YAAY,CAAC,KAAmB,EAAE,KAA6B;IACtE,OAAO,YAAY,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAC3C,CAAC;AAED,iFAAiF;AACjF,SAAS,gBAAgB,CACvB,KAAmB,EACnB,KAAkC;IAElC,OAAO,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import type { ViewStyle } from 'react-native';\n\nimport { resolveResponsive } from '../core/responsive/resolve';\nimport type { Breakpoint } from '../core/responsive/types';\nimport { resolveToken } from '../theme/resolveToken';\nimport type { SurfaceTheme } from '../theme/types';\nimport type { ColorValue, ViewStyleProps } from '../types/layout';\nimport { resolveSpacing } from './resolveSpacing';\n\n/*** Resolves responsive Surface View style props into one React Native view style. */\nexport function resolveViewStyles(\n theme: SurfaceTheme,\n breakpoint: Breakpoint,\n props: ViewStyleProps,\n): ViewStyle {\n return {\n elevation: 0,\n ...resolveSpacingStyles(theme, breakpoint, props),\n ...resolveVisualStyles(theme, breakpoint, props),\n ...resolveDimensionStyles(theme, breakpoint, props),\n ...resolveLayoutStyles(breakpoint, props),\n };\n}\n\n/*** Resolves padding, margin, and gap styles from responsive spacing props. */\nfunction resolveSpacingStyles(\n theme: SurfaceTheme,\n breakpoint: Breakpoint,\n props: ViewStyleProps,\n): ViewStyle {\n return {\n padding: resolveSpacing(theme, resolveResponsive(props.p, breakpoint)),\n paddingHorizontal: resolveSpacing(theme, resolveResponsive(props.px, breakpoint)),\n paddingVertical: resolveSpacing(theme, resolveResponsive(props.py, breakpoint)),\n paddingTop: resolveSpacing(theme, resolveResponsive(props.pt, breakpoint)),\n paddingBottom: resolveSpacing(theme, resolveResponsive(props.pb, breakpoint)),\n paddingLeft: resolveSpacing(theme, resolveResponsive(props.pl, breakpoint)),\n paddingRight: resolveSpacing(theme, resolveResponsive(props.pr, breakpoint)),\n margin: resolveSpacing(theme, resolveResponsive(props.m, breakpoint)),\n marginHorizontal: resolveSpacing(theme, resolveResponsive(props.mx, breakpoint)),\n marginVertical: resolveSpacing(theme, resolveResponsive(props.my, breakpoint)),\n marginTop: resolveSpacing(theme, resolveResponsive(props.mt, breakpoint)),\n marginBottom: resolveSpacing(theme, resolveResponsive(props.mb, breakpoint)),\n marginLeft: resolveSpacing(theme, resolveResponsive(props.ml, breakpoint)),\n marginRight: resolveSpacing(theme, resolveResponsive(props.mr, breakpoint)),\n gap: resolveSpacing(theme, resolveResponsive(props.gap, breakpoint)),\n rowGap: resolveSpacing(theme, resolveResponsive(props.rowGap, breakpoint)),\n columnGap: resolveSpacing(theme, resolveResponsive(props.columnGap, breakpoint)),\n };\n}\n\n/*** Resolves background, radius, and border styles. */\nfunction resolveVisualStyles(\n theme: SurfaceTheme,\n breakpoint: Breakpoint,\n props: ViewStyleProps,\n): ViewStyle {\n return {\n backgroundColor: resolveColor(theme, resolveResponsive(props.bg, breakpoint)),\n borderRadius: resolveRadius(theme, resolveResponsive(props.radius, breakpoint)),\n borderWidth: resolveResponsive(props.borderWidth, breakpoint),\n borderColor: resolveColor(theme, resolveResponsive(props.borderColor, breakpoint)),\n };\n}\n\n/*** Resolves responsive dimension props through spacing tokens. */\nfunction resolveDimensionStyles(\n theme: SurfaceTheme,\n breakpoint: Breakpoint,\n props: ViewStyleProps,\n): ViewStyle {\n return {\n width: resolveDimension(\n theme,\n resolveResponsive(props.width, breakpoint),\n ) as ViewStyle['width'],\n height: resolveDimension(\n theme,\n resolveResponsive(props.height, breakpoint),\n ) as ViewStyle['height'],\n minWidth: resolveDimension(\n theme,\n resolveResponsive(props.minWidth, breakpoint),\n ) as ViewStyle['minWidth'],\n maxWidth: resolveDimension(\n theme,\n resolveResponsive(props.maxWidth, breakpoint),\n ) as ViewStyle['maxWidth'],\n minHeight: resolveDimension(\n theme,\n resolveResponsive(props.minHeight, breakpoint),\n ) as ViewStyle['minHeight'],\n maxHeight: resolveDimension(\n theme,\n resolveResponsive(props.maxHeight, breakpoint),\n ) as ViewStyle['maxHeight'],\n };\n}\n\n/*** Resolves responsive flex, positioning, and visibility styles. */\nfunction resolveLayoutStyles(breakpoint: Breakpoint, props: ViewStyleProps): ViewStyle {\n return {\n flex: resolveResponsive(props.flex, breakpoint),\n flexGrow: resolveResponsive(props.flexGrow, breakpoint),\n flexShrink: resolveResponsive(props.flexShrink, breakpoint),\n flexBasis: resolveResponsive(props.flexBasis, breakpoint) as ViewStyle['flexBasis'],\n flexDirection: resolveResponsive(props.direction, breakpoint),\n alignItems: resolveResponsive(props.align, breakpoint),\n justifyContent: resolveResponsive(props.justify, breakpoint),\n flexWrap: resolveResponsive(props.wrap, breakpoint),\n alignSelf: resolveResponsive(props.alignSelf, breakpoint),\n position: resolveResponsive(props.position, breakpoint),\n top: resolveResponsive(props.top, breakpoint),\n bottom: resolveResponsive(props.bottom, breakpoint),\n left: resolveResponsive(props.left, breakpoint),\n right: resolveResponsive(props.right, breakpoint),\n overflow: resolveResponsive(props.overflow, breakpoint),\n zIndex: resolveResponsive(props.zIndex, breakpoint),\n opacity: resolveResponsive(props.opacity, breakpoint),\n };\n}\n\n/*** Resolves a Surface radius token or raw number. */\nfunction resolveRadius(\n theme: SurfaceTheme,\n value: number | keyof SurfaceTheme['radii'] | undefined,\n): number | undefined {\n return resolveToken(theme.radii, value);\n}\n\n/*** Resolves a Surface color token while preserving arbitrary color strings. */\nfunction resolveColor(theme: SurfaceTheme, value: ColorValue | undefined): string | undefined {\n return resolveToken(theme.colors, value);\n}\n\n/*** Resolves spacing-token dimensions while preserving raw dimension strings. */\nfunction resolveDimension(\n theme: SurfaceTheme,\n value: number | string | undefined,\n): number | string | undefined {\n return resolveToken(theme.spacing, value);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import { resolveResponsive
|
|
3
|
+
import { resolveResponsive } from './resolve';
|
|
4
|
+
import { useResponsiveRuntime } from './ResponsiveProvider';
|
|
5
|
+
import type { Responsive } from './types';
|
|
4
6
|
|
|
5
7
|
export interface ShowProps {
|
|
6
8
|
when: Responsive<boolean>;
|
|
@@ -8,6 +10,7 @@ export interface ShowProps {
|
|
|
8
10
|
fallback?: React.ReactNode;
|
|
9
11
|
}
|
|
10
12
|
|
|
13
|
+
/*** Conditionally renders one responsive subtree or its fallback. */
|
|
11
14
|
export function Show({ when, children, fallback = null }: ShowProps) {
|
|
12
15
|
const { breakpoint } = useResponsiveRuntime();
|
|
13
16
|
const visible = resolveResponsive(when, breakpoint) ?? false;
|
|
@@ -2,5 +2,6 @@ export { BREAKPOINT_ORDER, BREAKPOINTS } from './breakpoints';
|
|
|
2
2
|
export { getBreakpointFromWidth } from './getBreakpointFromWidth';
|
|
3
3
|
export { resolveResponsive } from './resolve';
|
|
4
4
|
export { ResponsiveProvider, useResponsiveRuntime } from './ResponsiveProvider';
|
|
5
|
+
export { Show, type ShowProps } from './Show';
|
|
5
6
|
export type { Breakpoint, Responsive, ResponsiveRuntime } from './types';
|
|
6
7
|
export { useBreakpoint } from './useBreakpoint';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet, View as ReactNativeView, type ViewStyle } from 'react-native';
|
|
3
|
+
import { SafeAreaInsetsContext } from 'react-native-safe-area-context';
|
|
4
|
+
|
|
5
|
+
import { useTheme } from '../../../../theme/ThemeContext';
|
|
6
|
+
import type { AppBarProps } from '../../../../types/app-bar';
|
|
7
|
+
import { Divider, View } from '../../../layout/public';
|
|
8
|
+
|
|
9
|
+
/*** Renders application chrome with optional safe-area padding and leading/trailing slots. */
|
|
10
|
+
export function AppBar({
|
|
11
|
+
leading,
|
|
12
|
+
trailing,
|
|
13
|
+
children,
|
|
14
|
+
safeAreaTop = true,
|
|
15
|
+
divider = false,
|
|
16
|
+
contentStyle,
|
|
17
|
+
bg,
|
|
18
|
+
style,
|
|
19
|
+
...props
|
|
20
|
+
}: AppBarProps) {
|
|
21
|
+
const { theme } = useTheme();
|
|
22
|
+
const insets = React.use(SafeAreaInsetsContext);
|
|
23
|
+
const topInset = safeAreaTop ? (insets?.top ?? 0) : 0;
|
|
24
|
+
const safeAreaStyle: ViewStyle | undefined =
|
|
25
|
+
topInset === 0 ? undefined : { paddingTop: topInset };
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<View {...props} bg={bg ?? theme.semantics.surface.default} style={style}>
|
|
29
|
+
<ReactNativeView style={safeAreaStyle}>
|
|
30
|
+
<ReactNativeView
|
|
31
|
+
style={[styles.content, resolveHorizontalPadding(theme.spacing.m), contentStyle]}
|
|
32
|
+
>
|
|
33
|
+
{leading ? (
|
|
34
|
+
<ReactNativeView
|
|
35
|
+
style={[styles.accessory, resolveAccessoryMargin(theme.spacing.s, 'leading')]}
|
|
36
|
+
>
|
|
37
|
+
{leading}
|
|
38
|
+
</ReactNativeView>
|
|
39
|
+
) : null}
|
|
40
|
+
<ReactNativeView style={styles.center}>{children}</ReactNativeView>
|
|
41
|
+
{trailing ? (
|
|
42
|
+
<ReactNativeView
|
|
43
|
+
style={[styles.accessory, resolveAccessoryMargin(theme.spacing.s, 'trailing')]}
|
|
44
|
+
>
|
|
45
|
+
{trailing}
|
|
46
|
+
</ReactNativeView>
|
|
47
|
+
) : null}
|
|
48
|
+
</ReactNativeView>
|
|
49
|
+
{divider ? <Divider color={theme.semantics.neutral.divider} thickness={1} /> : null}
|
|
50
|
+
</ReactNativeView>
|
|
51
|
+
</View>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/*** Resolves dynamic horizontal padding for the AppBar content row. */
|
|
56
|
+
function resolveHorizontalPadding(paddingHorizontal: number): ViewStyle {
|
|
57
|
+
return { paddingHorizontal };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/*** Resolves directional spacing for one AppBar accessory. */
|
|
61
|
+
function resolveAccessoryMargin(spacing: number, position: 'leading' | 'trailing'): ViewStyle {
|
|
62
|
+
return position === 'leading' ? { marginRight: spacing } : { marginLeft: spacing };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const styles = StyleSheet.create({
|
|
66
|
+
accessory: { flexShrink: 0 },
|
|
67
|
+
center: { flex: 1, minWidth: 0 },
|
|
68
|
+
content: { alignItems: 'center', flexDirection: 'row', minHeight: 56 },
|
|
69
|
+
});
|
|
@@ -4,7 +4,7 @@ import type { ViewStyle } from 'react-native';
|
|
|
4
4
|
import { resolveButtonColors, resolveControlSize } from '../../../../internal/resolvers';
|
|
5
5
|
import { useTheme } from '../../../../theme/ThemeContext';
|
|
6
6
|
import type { BadgeProps } from '../../../../types/badge';
|
|
7
|
-
import {
|
|
7
|
+
import { View } from '../../../layout/public';
|
|
8
8
|
import { Text } from '../../../typography/public';
|
|
9
9
|
|
|
10
10
|
/*** Renders compact semantic status or metadata content. */
|
|
@@ -24,7 +24,7 @@ export function Badge({
|
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
return (
|
|
27
|
-
<
|
|
27
|
+
<View
|
|
28
28
|
px={Math.max(theme.spacing.xs, controlSize.paddingHorizontal - 4)}
|
|
29
29
|
py={Math.max(4, controlSize.paddingVertical - 2)}
|
|
30
30
|
radius={controlSize.borderRadius}
|
|
@@ -39,7 +39,7 @@ export function Badge({
|
|
|
39
39
|
>
|
|
40
40
|
{content}
|
|
41
41
|
</Text>
|
|
42
|
-
</
|
|
42
|
+
</View>
|
|
43
43
|
);
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ActivityIndicator, View, type ViewStyle } from 'react-native';
|
|
2
|
+
import { ActivityIndicator, View as ReactNativeView, type ViewStyle } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
type InteractionState,
|
|
@@ -12,7 +12,7 @@ import { useTheme } from '../../../../theme/ThemeContext';
|
|
|
12
12
|
import type { SurfaceTheme } from '../../../../theme/types';
|
|
13
13
|
import type { ButtonProps } from '../../../../types/button';
|
|
14
14
|
import { Icon } from '../../../icon/public';
|
|
15
|
-
import {
|
|
15
|
+
import { View } from '../../../layout/public';
|
|
16
16
|
import { Text } from '../../../typography/public';
|
|
17
17
|
|
|
18
18
|
/*** Renders the primary Surface action control with semantic visual states. */
|
|
@@ -80,7 +80,7 @@ function ButtonContent({
|
|
|
80
80
|
const iconSize = resolveIconSize(theme, size);
|
|
81
81
|
|
|
82
82
|
return (
|
|
83
|
-
<
|
|
83
|
+
<View
|
|
84
84
|
px={controlSize.paddingHorizontal}
|
|
85
85
|
py={controlSize.paddingVertical}
|
|
86
86
|
radius={controlSize.borderRadius}
|
|
@@ -91,9 +91,9 @@ function ButtonContent({
|
|
|
91
91
|
) : (
|
|
92
92
|
<>
|
|
93
93
|
{leadingIcon ? (
|
|
94
|
-
<
|
|
94
|
+
<ReactNativeView style={resolveAccessoryStyle(theme.spacing.s, 'leading')}>
|
|
95
95
|
<Icon {...leadingIcon} color={colors.contentColor} size={iconSize} />
|
|
96
|
-
</
|
|
96
|
+
</ReactNativeView>
|
|
97
97
|
) : null}
|
|
98
98
|
<Text
|
|
99
99
|
color={muted ? undefined : color}
|
|
@@ -104,13 +104,13 @@ function ButtonContent({
|
|
|
104
104
|
{children}
|
|
105
105
|
</Text>
|
|
106
106
|
{trailingIcon ? (
|
|
107
|
-
<
|
|
107
|
+
<ReactNativeView style={resolveAccessoryStyle(theme.spacing.s, 'trailing')}>
|
|
108
108
|
<Icon {...trailingIcon} color={colors.contentColor} size={iconSize} />
|
|
109
|
-
</
|
|
109
|
+
</ReactNativeView>
|
|
110
110
|
) : null}
|
|
111
111
|
</>
|
|
112
112
|
)}
|
|
113
|
-
</
|
|
113
|
+
</View>
|
|
114
114
|
);
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -10,7 +10,7 @@ import { ButtonBase } from '../../../../primitives/button-base';
|
|
|
10
10
|
import { useTheme } from '../../../../theme/ThemeContext';
|
|
11
11
|
import type { IconButtonProps } from '../../../../types/button';
|
|
12
12
|
import { Icon } from '../../../icon/public';
|
|
13
|
-
import {
|
|
13
|
+
import { View } from '../../../layout/public';
|
|
14
14
|
|
|
15
15
|
/*** Renders a compact accessible icon-only action control. */
|
|
16
16
|
export function IconButton({
|
|
@@ -38,12 +38,12 @@ export function IconButton({
|
|
|
38
38
|
{(state) => {
|
|
39
39
|
const colors = resolveButtonColors(theme, { color, state, variant });
|
|
40
40
|
return (
|
|
41
|
-
<
|
|
41
|
+
<View
|
|
42
42
|
radius={controlSize.borderRadius}
|
|
43
43
|
style={resolveIconButtonStyle(controlSize, colors, variant)}
|
|
44
44
|
>
|
|
45
45
|
<Icon {...icon} color={colors.contentColor} size={resolveIconSize(theme, size)} />
|
|
46
|
-
</
|
|
46
|
+
</View>
|
|
47
47
|
);
|
|
48
48
|
}}
|
|
49
49
|
</ButtonBase>
|
|
@@ -14,7 +14,7 @@ import type { ButtonBaseProps } from '../../../../../primitives/button-base/type
|
|
|
14
14
|
import { useTheme } from '../../../../../theme/ThemeContext';
|
|
15
15
|
import type { SurfaceTheme } from '../../../../../theme/types';
|
|
16
16
|
import type { CheckboxProps } from '../../../../../types/checkbox';
|
|
17
|
-
import {
|
|
17
|
+
import { View } from '../../../../layout/public';
|
|
18
18
|
import { Text } from '../../../../typography/public';
|
|
19
19
|
|
|
20
20
|
/*** Renders a controlled or uncontrolled accessible checkbox. */
|
|
@@ -128,8 +128,8 @@ function renderCheckboxContent(input: CheckboxContentInput) {
|
|
|
128
128
|
const indicatorColor = fieldState.invalid ? 'error' : input.color;
|
|
129
129
|
|
|
130
130
|
return (
|
|
131
|
-
<
|
|
132
|
-
<
|
|
131
|
+
<View style={resolveSelectionRowStyle(colors.opacity)}>
|
|
132
|
+
<View
|
|
133
133
|
radius="s"
|
|
134
134
|
style={resolveCheckboxIndicatorStyle(
|
|
135
135
|
colors.backgroundColor,
|
|
@@ -147,13 +147,13 @@ function renderCheckboxContent(input: CheckboxContentInput) {
|
|
|
147
147
|
✓
|
|
148
148
|
</Text>
|
|
149
149
|
) : null}
|
|
150
|
-
</
|
|
150
|
+
</View>
|
|
151
151
|
{input.children ? (
|
|
152
|
-
<
|
|
152
|
+
<View ml="s">
|
|
153
153
|
<Text emphasis={labelEmphasis}>{input.children}</Text>
|
|
154
|
-
</
|
|
154
|
+
</View>
|
|
155
155
|
) : null}
|
|
156
|
-
</
|
|
156
|
+
</View>
|
|
157
157
|
);
|
|
158
158
|
}
|
|
159
159
|
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type ResolvedFieldPresentation,
|
|
5
|
+
resolveFieldPresentation,
|
|
6
|
+
resolveFieldState,
|
|
7
|
+
} from '../../../../../internal/resolvers';
|
|
8
|
+
import type { FieldProps } from '../../../../../types/field';
|
|
9
|
+
import { View } from '../../../../layout/public';
|
|
10
|
+
import { Text } from '../../../../typography/public';
|
|
11
|
+
|
|
12
|
+
/*** Composes a control with its label and helper or error message. */
|
|
13
|
+
export function Field({
|
|
14
|
+
children,
|
|
15
|
+
label,
|
|
16
|
+
helperText,
|
|
17
|
+
errorText,
|
|
18
|
+
required = false,
|
|
19
|
+
disabled = false,
|
|
20
|
+
invalid = false,
|
|
21
|
+
readOnly = false,
|
|
22
|
+
testID,
|
|
23
|
+
}: FieldProps) {
|
|
24
|
+
const hasErrorText = Boolean(errorText);
|
|
25
|
+
const presentation = resolveFieldPresentation(
|
|
26
|
+
resolveFieldState({ disabled, invalid: invalid || hasErrorText, readOnly }),
|
|
27
|
+
);
|
|
28
|
+
const message = hasErrorText ? errorText : helperText;
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<View gap="xs" testID={testID}>
|
|
32
|
+
{renderFieldLabel(label, required, presentation)}
|
|
33
|
+
<View>{children}</View>
|
|
34
|
+
{renderFieldMessage(message, presentation)}
|
|
35
|
+
</View>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/*** Renders an optional field label and required indicator. */
|
|
40
|
+
function renderFieldLabel(
|
|
41
|
+
label: React.ReactNode,
|
|
42
|
+
required: boolean,
|
|
43
|
+
presentation: ResolvedFieldPresentation,
|
|
44
|
+
) {
|
|
45
|
+
if (label === undefined || label === null) return null;
|
|
46
|
+
const labelContent =
|
|
47
|
+
typeof label === 'string' || typeof label === 'number' ? (
|
|
48
|
+
<Text
|
|
49
|
+
color={presentation.labelColor}
|
|
50
|
+
emphasis={presentation.labelEmphasis}
|
|
51
|
+
variant="label"
|
|
52
|
+
weight="medium"
|
|
53
|
+
>
|
|
54
|
+
{label}
|
|
55
|
+
</Text>
|
|
56
|
+
) : (
|
|
57
|
+
label
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<View align="center" direction="row" gap="xs">
|
|
62
|
+
<View flex={1}>{labelContent}</View>
|
|
63
|
+
{required ? (
|
|
64
|
+
<Text color="error" variant="label" weight="medium">
|
|
65
|
+
*
|
|
66
|
+
</Text>
|
|
67
|
+
) : null}
|
|
68
|
+
</View>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/*** Renders an optional helper or error message using field presentation semantics. */
|
|
73
|
+
function renderFieldMessage(message: React.ReactNode, presentation: ResolvedFieldPresentation) {
|
|
74
|
+
if (message === undefined || message === null || message === '') return null;
|
|
75
|
+
if (typeof message !== 'string' && typeof message !== 'number') return message;
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<Text color={presentation.helperColor} emphasis={presentation.helperEmphasis} variant="caption">
|
|
79
|
+
{message}
|
|
80
|
+
</Text>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
@@ -14,7 +14,7 @@ import type { ButtonBaseProps } from '../../../../../primitives/button-base/type
|
|
|
14
14
|
import { useTheme } from '../../../../../theme/ThemeContext';
|
|
15
15
|
import type { SurfaceTheme } from '../../../../../theme/types';
|
|
16
16
|
import type { RadioProps } from '../../../../../types/radio';
|
|
17
|
-
import {
|
|
17
|
+
import { View } from '../../../../layout/public';
|
|
18
18
|
import { Text } from '../../../../typography/public';
|
|
19
19
|
import { isRadioTextContent } from '../../utils/isRadioTextContent';
|
|
20
20
|
|
|
@@ -130,8 +130,8 @@ function renderRadioContent(input: RadioContentInput) {
|
|
|
130
130
|
input.children !== undefined && input.children !== null && input.children !== false;
|
|
131
131
|
|
|
132
132
|
return (
|
|
133
|
-
<
|
|
134
|
-
<
|
|
133
|
+
<View style={resolveSelectionRowStyle(colors.opacity)}>
|
|
134
|
+
<View
|
|
135
135
|
radius="full"
|
|
136
136
|
style={resolveRadioIndicatorStyle(
|
|
137
137
|
colors.backgroundColor,
|
|
@@ -140,22 +140,22 @@ function renderRadioContent(input: RadioContentInput) {
|
|
|
140
140
|
)}
|
|
141
141
|
>
|
|
142
142
|
{input.isChecked ? (
|
|
143
|
-
<
|
|
143
|
+
<View
|
|
144
144
|
radius="full"
|
|
145
145
|
style={resolveRadioDotStyle(colors.indicatorColor, indicatorSize.radioDot)}
|
|
146
146
|
/>
|
|
147
147
|
) : null}
|
|
148
|
-
</
|
|
148
|
+
</View>
|
|
149
149
|
{hasContent ? (
|
|
150
|
-
<
|
|
150
|
+
<View flex={1} ml="s">
|
|
151
151
|
{isRadioTextContent(input.children) ? (
|
|
152
152
|
<Text emphasis={labelEmphasis}>{input.children}</Text>
|
|
153
153
|
) : (
|
|
154
154
|
input.children
|
|
155
155
|
)}
|
|
156
|
-
</
|
|
156
|
+
</View>
|
|
157
157
|
) : null}
|
|
158
|
-
</
|
|
158
|
+
</View>
|
|
159
159
|
);
|
|
160
160
|
}
|
|
161
161
|
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type InteractionState,
|
|
5
|
+
resolveFieldState,
|
|
6
|
+
resolveIndicatorSize,
|
|
7
|
+
resolveSelectionControlColors,
|
|
8
|
+
resolveSelectionControlNextChecked,
|
|
9
|
+
} from '../../../../../internal/resolvers';
|
|
10
|
+
import { useControllableState } from '../../../../../internal/useControllableState';
|
|
11
|
+
import { ButtonBase } from '../../../../../primitives/button-base';
|
|
12
|
+
import { useTheme } from '../../../../../theme/ThemeContext';
|
|
13
|
+
import type { SwitchProps } from '../../../../../types/switch';
|
|
14
|
+
import { View } from '../../../../layout/public';
|
|
15
|
+
import { Text } from '../../../../typography/public';
|
|
16
|
+
|
|
17
|
+
/*** Renders a controlled or uncontrolled accessible switch. */
|
|
18
|
+
export function Switch({
|
|
19
|
+
children,
|
|
20
|
+
checked,
|
|
21
|
+
defaultChecked = false,
|
|
22
|
+
onCheckedChange,
|
|
23
|
+
color = 'primary',
|
|
24
|
+
size = 'm',
|
|
25
|
+
disabled = false,
|
|
26
|
+
invalid = false,
|
|
27
|
+
readOnly = false,
|
|
28
|
+
accessibilityLabel,
|
|
29
|
+
testID,
|
|
30
|
+
...props
|
|
31
|
+
}: SwitchProps) {
|
|
32
|
+
const { theme } = useTheme();
|
|
33
|
+
const [isChecked, setChecked] = useControllableState<boolean>({
|
|
34
|
+
value: checked,
|
|
35
|
+
defaultValue: defaultChecked,
|
|
36
|
+
onChange: onCheckedChange,
|
|
37
|
+
});
|
|
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
|
+
renderSwitchContent(
|
|
57
|
+
{ children, color, disabled, invalid, isChecked, readOnly, size, theme },
|
|
58
|
+
interactionState,
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
</ButtonBase>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface SwitchContentInput {
|
|
66
|
+
children: React.ReactNode;
|
|
67
|
+
color: NonNullable<SwitchProps['color']>;
|
|
68
|
+
disabled: boolean;
|
|
69
|
+
invalid: boolean;
|
|
70
|
+
isChecked: boolean;
|
|
71
|
+
readOnly: boolean;
|
|
72
|
+
size: NonNullable<SwitchProps['size']>;
|
|
73
|
+
theme: ReturnType<typeof useTheme>['theme'];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/*** Resolves switch presentation for one interaction state and renders the visual control. */
|
|
77
|
+
function renderSwitchContent(input: SwitchContentInput, interactionState: InteractionState) {
|
|
78
|
+
const fieldState = resolveFieldState({
|
|
79
|
+
disabled: input.disabled,
|
|
80
|
+
focused: interactionState.focused,
|
|
81
|
+
invalid: input.invalid,
|
|
82
|
+
readOnly: input.readOnly,
|
|
83
|
+
});
|
|
84
|
+
const colors = resolveSelectionControlColors(input.theme, {
|
|
85
|
+
checked: input.isChecked,
|
|
86
|
+
fieldState,
|
|
87
|
+
hovered: interactionState.hovered,
|
|
88
|
+
pressed: interactionState.pressed,
|
|
89
|
+
color: input.color,
|
|
90
|
+
});
|
|
91
|
+
const indicatorSize = resolveIndicatorSize(input.size);
|
|
92
|
+
const labelEmphasis =
|
|
93
|
+
colors.labelColor === input.theme.semantics.content.muted ? 'muted' : 'default';
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<View align="center" direction="row" opacity={colors.opacity}>
|
|
97
|
+
<View
|
|
98
|
+
bg={colors.trackColor}
|
|
99
|
+
borderColor={colors.borderColor}
|
|
100
|
+
borderWidth={1}
|
|
101
|
+
height={indicatorSize.switchHeight}
|
|
102
|
+
justify="center"
|
|
103
|
+
minWidth={indicatorSize.switchWidth}
|
|
104
|
+
px={2}
|
|
105
|
+
radius="full"
|
|
106
|
+
width={indicatorSize.switchWidth}
|
|
107
|
+
>
|
|
108
|
+
<View
|
|
109
|
+
alignSelf={input.isChecked ? 'flex-end' : 'flex-start'}
|
|
110
|
+
bg={colors.thumbColor}
|
|
111
|
+
height={indicatorSize.switchThumb}
|
|
112
|
+
radius="full"
|
|
113
|
+
width={indicatorSize.switchThumb}
|
|
114
|
+
/>
|
|
115
|
+
</View>
|
|
116
|
+
{input.children ? (
|
|
117
|
+
<View ml="s">
|
|
118
|
+
<Text emphasis={labelEmphasis}>{input.children}</Text>
|
|
119
|
+
</View>
|
|
120
|
+
) : null}
|
|
121
|
+
</View>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Platform,
|
|
4
|
+
type StyleProp,
|
|
5
|
+
TextInput as ReactNativeTextInput,
|
|
6
|
+
type TextStyle,
|
|
7
|
+
View,
|
|
8
|
+
type ViewStyle,
|
|
9
|
+
} from 'react-native';
|
|
3
10
|
|
|
4
11
|
import { resolveFocusRingStyles } from '../../../../../internal/resolvers';
|
|
5
12
|
import { useTheme } from '../../../../../theme/ThemeContext';
|
|
@@ -39,9 +46,7 @@ export function TextInput(props: TextInputProps) {
|
|
|
39
46
|
nativeProps.onBlur?.(event);
|
|
40
47
|
}}
|
|
41
48
|
onChangeText={(nextValue) => {
|
|
42
|
-
if (interactionPolicy !== 'passive')
|
|
43
|
-
nativeProps.onChangeText?.(nextValue);
|
|
44
|
-
}
|
|
49
|
+
if (interactionPolicy !== 'passive') nativeProps.onChangeText?.(nextValue);
|
|
45
50
|
}}
|
|
46
51
|
onFocus={(event) => {
|
|
47
52
|
setFocused(true);
|
|
@@ -49,13 +54,24 @@ export function TextInput(props: TextInputProps) {
|
|
|
49
54
|
}}
|
|
50
55
|
placeholderTextColor={presentation.placeholderColor}
|
|
51
56
|
readOnly={readOnly}
|
|
52
|
-
style={
|
|
57
|
+
style={resolveInputStyle(presentation.inputStyle, nativeProps.multiline, nativeProps.style)}
|
|
53
58
|
/>
|
|
54
59
|
{renderAccessory(trailingAccessory, presentation.accessorySpacing, 'trailing')}
|
|
55
60
|
</View>
|
|
56
61
|
);
|
|
57
62
|
}
|
|
58
63
|
|
|
64
|
+
const multilineInputStyle: TextStyle = { textAlignVertical: 'top' };
|
|
65
|
+
|
|
66
|
+
/*** Resolves TextInput style composition including canonical multiline alignment. */
|
|
67
|
+
function resolveInputStyle(
|
|
68
|
+
presentationStyle: StyleProp<TextStyle>,
|
|
69
|
+
multiline: boolean | undefined,
|
|
70
|
+
style: StyleProp<TextStyle>,
|
|
71
|
+
): StyleProp<TextStyle> {
|
|
72
|
+
return [presentationStyle, multiline ? multilineInputStyle : undefined, style];
|
|
73
|
+
}
|
|
74
|
+
|
|
59
75
|
/*** Renders one optional TextInput accessory with directional spacing. */
|
|
60
76
|
function renderAccessory(
|
|
61
77
|
accessory: React.ReactNode,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import type { DividerProps } from '../../../../types/layout';
|
|
4
|
-
import {
|
|
4
|
+
import { View } from './View';
|
|
5
5
|
|
|
6
6
|
/*** Renders a horizontal or vertical separator using layout tokens. */
|
|
7
7
|
export function Divider({
|
|
@@ -11,7 +11,7 @@ export function Divider({
|
|
|
11
11
|
...props
|
|
12
12
|
}: DividerProps) {
|
|
13
13
|
return (
|
|
14
|
-
<
|
|
14
|
+
<View
|
|
15
15
|
{...props}
|
|
16
16
|
bg={color}
|
|
17
17
|
height={orientation === 'horizontal' ? thickness : '100%'}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { View, type ViewStyle } from 'react-native';
|
|
2
|
+
import { View as ReactNativeView, type ViewStyle } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import { resolveResponsive, useResponsiveRuntime } from '../../../../core/responsive';
|
|
5
5
|
import { useTheme } from '../../../../theme/ThemeContext';
|
|
6
6
|
import type { GridProps } from '../../../../types/layout';
|
|
7
7
|
import { resolveSpacing } from '../../../../utils/resolveSpacing';
|
|
8
|
-
import {
|
|
8
|
+
import { View } from './View';
|
|
9
9
|
|
|
10
10
|
/*** Lays out children in a responsive wrapping grid. */
|
|
11
11
|
export function Grid({
|
|
@@ -31,18 +31,16 @@ export function Grid({
|
|
|
31
31
|
const basisPercent: `${number}%` = `${100 / activeCols}%`;
|
|
32
32
|
|
|
33
33
|
return (
|
|
34
|
-
<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
</View>
|
|
45
|
-
</Box>
|
|
34
|
+
<View {...props} style={[resolveGridStyle(rowSpacing, colSpacing), props.style]}>
|
|
35
|
+
{React.Children.toArray(children).map((node, index) => (
|
|
36
|
+
<ReactNativeView
|
|
37
|
+
key={React.isValidElement(node) && node.key !== null ? String(node.key) : String(index)}
|
|
38
|
+
style={resolveGridItemStyle(activeMinItemWidth, basisPercent, rowSpacing, colSpacing)}
|
|
39
|
+
>
|
|
40
|
+
{node}
|
|
41
|
+
</ReactNativeView>
|
|
42
|
+
))}
|
|
43
|
+
</View>
|
|
46
44
|
);
|
|
47
45
|
}
|
|
48
46
|
|