@ankhorage/surface 4.1.0 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/dist/components/field/Field.js +1 -1
- package/dist/components/field/Field.js.map +1 -1
- package/dist/components/helper-text/HelperText.js +1 -1
- package/dist/components/helper-text/HelperText.js.map +1 -1
- package/dist/components/label/Label.js +1 -1
- package/dist/components/label/Label.js.map +1 -1
- package/dist/components/list-item/ListItem.js +2 -2
- package/dist/components/list-item/ListItem.js.map +1 -1
- package/dist/components/menu/Menu.d.ts.map +1 -1
- package/dist/components/menu/Menu.js +4 -2
- package/dist/components/menu/Menu.js.map +1 -1
- package/dist/components/modal/Modal.d.ts.map +1 -1
- package/dist/components/modal/Modal.js +2 -1
- package/dist/components/modal/Modal.js.map +1 -1
- package/dist/components/switch/Switch.js +2 -2
- package/dist/components/switch/Switch.js.map +1 -1
- package/dist/components/tabs/Tab.js +2 -2
- package/dist/components/tabs/Tab.js.map +1 -1
- package/dist/components/tabs/TabList.js +1 -1
- package/dist/components/tabs/TabList.js.map +1 -1
- package/dist/components/tabs/Tabs.js +1 -1
- package/dist/components/tabs/Tabs.js.map +1 -1
- package/dist/components/textarea/Textarea.js +1 -1
- package/dist/components/textarea/Textarea.js.map +1 -1
- package/dist/components/textarea/types.d.ts +1 -1
- package/dist/components/textarea/types.d.ts.map +1 -1
- package/dist/components/textarea/types.js.map +1 -1
- package/dist/components/toast/Toast.d.ts.map +1 -1
- package/dist/components/toast/Toast.js +4 -2
- package/dist/components/toast/Toast.js.map +1 -1
- package/dist/components/toast/ToastProvider.js +1 -1
- package/dist/components/toast/ToastProvider.js.map +1 -1
- package/dist/components/tooltip/Tooltip.js +2 -2
- package/dist/components/tooltip/Tooltip.js.map +1 -1
- package/dist/examples/DocsExamples.js +6 -6
- package/dist/examples/DocsExamples.js.map +1 -1
- package/dist/features/badge/adapters/inbound/Badge.d.ts +5 -0
- package/dist/features/badge/adapters/inbound/Badge.d.ts.map +1 -0
- package/dist/features/badge/adapters/inbound/Badge.js +30 -0
- package/dist/features/badge/adapters/inbound/Badge.js.map +1 -0
- package/dist/features/badge/public.d.ts +3 -0
- package/dist/features/badge/public.d.ts.map +1 -0
- package/dist/features/badge/public.js +2 -0
- package/dist/features/badge/public.js.map +1 -0
- package/dist/{components/button → features/button/adapters/inbound}/Button.d.ts +2 -1
- package/dist/features/button/adapters/inbound/Button.d.ts.map +1 -0
- package/dist/features/button/adapters/inbound/Button.js +60 -0
- package/dist/features/button/adapters/inbound/Button.js.map +1 -0
- package/dist/{components/icon-button → features/button/adapters/inbound}/IconButton.d.ts +2 -1
- package/dist/features/button/adapters/inbound/IconButton.d.ts.map +1 -0
- package/dist/features/button/adapters/inbound/IconButton.js +33 -0
- package/dist/features/button/adapters/inbound/IconButton.js.map +1 -0
- package/dist/features/button/public.d.ts +4 -0
- package/dist/features/button/public.d.ts.map +1 -0
- package/dist/features/button/public.js +3 -0
- package/dist/features/button/public.js.map +1 -0
- package/dist/features/card/adapters/inbound/Card.d.ts +5 -0
- package/dist/features/card/adapters/inbound/Card.d.ts.map +1 -0
- package/dist/features/card/adapters/inbound/Card.js +44 -0
- package/dist/features/card/adapters/inbound/Card.js.map +1 -0
- package/dist/features/card/public.d.ts +3 -0
- package/dist/features/card/public.d.ts.map +1 -0
- package/dist/features/card/public.js +2 -0
- package/dist/features/card/public.js.map +1 -0
- package/dist/features/form/checkbox/adapters/inbound/Checkbox.d.ts +5 -0
- package/dist/features/form/checkbox/adapters/inbound/Checkbox.d.ts.map +1 -0
- package/dist/features/form/checkbox/adapters/inbound/Checkbox.js +88 -0
- package/dist/features/form/checkbox/adapters/inbound/Checkbox.js.map +1 -0
- package/dist/features/form/checkbox/public.d.ts +3 -0
- package/dist/features/form/checkbox/public.d.ts.map +1 -0
- package/dist/features/form/checkbox/public.js +2 -0
- package/dist/features/form/checkbox/public.js.map +1 -0
- package/dist/features/form/radio/adapters/inbound/Radio.d.ts +5 -0
- package/dist/features/form/radio/adapters/inbound/Radio.d.ts.map +1 -0
- package/dist/features/form/radio/adapters/inbound/Radio.js +91 -0
- package/dist/features/form/radio/adapters/inbound/Radio.js.map +1 -0
- package/dist/features/form/radio/public.d.ts +3 -0
- package/dist/features/form/radio/public.d.ts.map +1 -0
- package/dist/features/form/radio/public.js +2 -0
- package/dist/features/form/radio/public.js.map +1 -0
- package/dist/features/form/radio/utils/isRadioTextContent.d.ts +4 -0
- package/dist/features/form/radio/utils/isRadioTextContent.d.ts.map +1 -0
- package/dist/features/form/radio/utils/isRadioTextContent.js +5 -0
- package/dist/features/form/radio/utils/isRadioTextContent.js.map +1 -0
- package/dist/features/form/text-input/adapters/inbound/TextInput.d.ts +5 -0
- package/dist/features/form/text-input/adapters/inbound/TextInput.d.ts.map +1 -0
- package/dist/features/form/text-input/adapters/inbound/TextInput.js +41 -0
- package/dist/features/form/text-input/adapters/inbound/TextInput.js.map +1 -0
- package/dist/features/form/text-input/public.d.ts +3 -0
- package/dist/features/form/text-input/public.d.ts.map +1 -0
- package/dist/features/form/text-input/public.js +2 -0
- package/dist/features/form/text-input/public.js.map +1 -0
- package/dist/features/form/text-input/utils/resolveTextInputPresentation.d.ts +15 -0
- package/dist/features/form/text-input/utils/resolveTextInputPresentation.d.ts.map +1 -0
- package/dist/features/form/text-input/utils/resolveTextInputPresentation.js +56 -0
- package/dist/features/form/text-input/utils/resolveTextInputPresentation.js.map +1 -0
- package/dist/features/icon/adapters/inbound/Icon.d.ts +4 -0
- package/dist/features/icon/adapters/inbound/Icon.d.ts.map +1 -0
- package/dist/{primitives/icon → features/icon/adapters/inbound}/Icon.js +3 -3
- package/dist/features/icon/adapters/inbound/Icon.js.map +1 -0
- package/dist/features/icon/adapters/inbound/PortableIcon.d.ts +19 -0
- package/dist/features/icon/adapters/inbound/PortableIcon.d.ts.map +1 -0
- package/dist/{primitives/icon → features/icon/adapters/inbound}/PortableIcon.js +37 -43
- package/dist/features/icon/adapters/inbound/PortableIcon.js.map +1 -0
- package/dist/features/icon/constants.d.ts +2 -0
- package/dist/features/icon/constants.d.ts.map +1 -0
- package/dist/features/icon/constants.js +8 -0
- package/dist/features/icon/constants.js.map +1 -0
- package/dist/features/icon/public.d.ts +4 -0
- package/dist/features/icon/public.d.ts.map +1 -0
- package/dist/features/icon/public.js +3 -0
- package/dist/features/icon/public.js.map +1 -0
- package/dist/{primitives/image → features/image/adapters/inbound}/Image.d.ts +2 -1
- package/dist/features/image/adapters/inbound/Image.d.ts.map +1 -0
- package/dist/features/image/adapters/inbound/Image.js +28 -0
- package/dist/features/image/adapters/inbound/Image.js.map +1 -0
- package/dist/features/image/public.d.ts +3 -0
- package/dist/features/image/public.d.ts.map +1 -0
- package/dist/features/image/public.js +2 -0
- package/dist/features/image/public.js.map +1 -0
- package/dist/features/image/utils/getSourceKey.d.ts +4 -0
- package/dist/features/image/utils/getSourceKey.d.ts.map +1 -0
- package/dist/features/image/utils/getSourceKey.js +33 -0
- package/dist/features/image/utils/getSourceKey.js.map +1 -0
- package/dist/features/image/utils/normalizeSource.d.ts +5 -0
- package/dist/features/image/utils/normalizeSource.d.ts.map +1 -0
- package/dist/features/image/utils/normalizeSource.js +9 -0
- package/dist/features/image/utils/normalizeSource.js.map +1 -0
- package/dist/features/image/utils/resolveAccessibilityLabel.d.ts +4 -0
- package/dist/features/image/utils/resolveAccessibilityLabel.d.ts.map +1 -0
- package/dist/features/image/utils/resolveAccessibilityLabel.js +5 -0
- package/dist/features/image/utils/resolveAccessibilityLabel.js.map +1 -0
- package/dist/features/image/utils/resolveAlt.d.ts +4 -0
- package/dist/features/image/utils/resolveAlt.d.ts.map +1 -0
- package/dist/features/image/utils/resolveAlt.js +5 -0
- package/dist/features/image/utils/resolveAlt.js.map +1 -0
- package/dist/features/image/utils/resolveImageStyle.d.ts +6 -0
- package/dist/features/image/utils/resolveImageStyle.d.ts.map +1 -0
- package/dist/features/image/utils/resolveImageStyle.js +15 -0
- package/dist/features/image/utils/resolveImageStyle.js.map +1 -0
- package/dist/features/image/utils/resolveRenderedSource.d.ts +4 -0
- package/dist/features/image/utils/resolveRenderedSource.d.ts.map +1 -0
- package/dist/features/image/utils/resolveRenderedSource.js +7 -0
- package/dist/features/image/utils/resolveRenderedSource.js.map +1 -0
- package/dist/features/image/utils/resolveResizeMode.d.ts +5 -0
- package/dist/features/image/utils/resolveResizeMode.d.ts.map +1 -0
- package/dist/features/image/utils/resolveResizeMode.js +5 -0
- package/dist/features/image/utils/resolveResizeMode.js.map +1 -0
- package/dist/features/keyboard-avoiding-view/adapters/inbound/KeyboardAvoidingView.d.ts +5 -0
- package/dist/features/keyboard-avoiding-view/adapters/inbound/KeyboardAvoidingView.d.ts.map +1 -0
- package/dist/features/keyboard-avoiding-view/adapters/inbound/KeyboardAvoidingView.js +7 -0
- package/dist/features/keyboard-avoiding-view/adapters/inbound/KeyboardAvoidingView.js.map +1 -0
- package/dist/features/keyboard-avoiding-view/public.d.ts +3 -0
- package/dist/features/keyboard-avoiding-view/public.d.ts.map +1 -0
- package/dist/features/keyboard-avoiding-view/public.js +2 -0
- package/dist/features/keyboard-avoiding-view/public.js.map +1 -0
- package/dist/features/layout/adapters/inbound/Box.d.ts +5 -0
- package/dist/features/layout/adapters/inbound/Box.d.ts.map +1 -0
- package/dist/{layout → features/layout/adapters/inbound}/Box.js +5 -4
- package/dist/features/layout/adapters/inbound/Box.js.map +1 -0
- package/dist/features/layout/adapters/inbound/Container.d.ts +5 -0
- package/dist/features/layout/adapters/inbound/Container.d.ts.map +1 -0
- package/dist/features/layout/adapters/inbound/Container.js +28 -0
- package/dist/features/layout/adapters/inbound/Container.js.map +1 -0
- package/dist/features/layout/adapters/inbound/Divider.d.ts +5 -0
- package/dist/features/layout/adapters/inbound/Divider.d.ts.map +1 -0
- package/dist/{layout → features/layout/adapters/inbound}/Divider.js +1 -0
- package/dist/features/layout/adapters/inbound/Divider.js.map +1 -0
- package/dist/features/layout/adapters/inbound/Grid.d.ts +5 -0
- package/dist/features/layout/adapters/inbound/Grid.d.ts.map +1 -0
- package/dist/features/layout/adapters/inbound/Grid.js +48 -0
- package/dist/features/layout/adapters/inbound/Grid.js.map +1 -0
- package/dist/features/layout/adapters/inbound/Stack.d.ts +5 -0
- package/dist/features/layout/adapters/inbound/Stack.d.ts.map +1 -0
- package/dist/{layout → features/layout/adapters/inbound}/Stack.js +4 -3
- package/dist/features/layout/adapters/inbound/Stack.js.map +1 -0
- package/dist/features/layout/public.d.ts +7 -0
- package/dist/features/layout/public.d.ts.map +1 -0
- package/dist/features/layout/public.js +6 -0
- package/dist/features/layout/public.js.map +1 -0
- package/dist/features/surface/adapters/inbound/Surface.d.ts +5 -0
- package/dist/features/surface/adapters/inbound/Surface.d.ts.map +1 -0
- package/dist/{layout → features/surface/adapters/inbound}/Surface.js +17 -28
- package/dist/features/surface/adapters/inbound/Surface.js.map +1 -0
- package/dist/features/surface/public.d.ts +3 -0
- package/dist/features/surface/public.d.ts.map +1 -0
- package/dist/features/surface/public.js +2 -0
- package/dist/features/surface/public.js.map +1 -0
- package/dist/features/typography/adapters/inbound/Heading.d.ts +5 -0
- package/dist/features/typography/adapters/inbound/Heading.d.ts.map +1 -0
- package/dist/features/typography/adapters/inbound/Heading.js +29 -0
- package/dist/features/typography/adapters/inbound/Heading.js.map +1 -0
- package/dist/{primitives/text → features/typography/adapters/inbound}/Text.d.ts +2 -1
- package/dist/features/typography/adapters/inbound/Text.d.ts.map +1 -0
- package/dist/{primitives/text → features/typography/adapters/inbound}/Text.js +18 -25
- package/dist/features/typography/adapters/inbound/Text.js.map +1 -0
- package/dist/features/typography/public.d.ts +4 -0
- package/dist/features/typography/public.d.ts.map +1 -0
- package/dist/features/typography/public.js +3 -0
- package/dist/features/typography/public.js.map +1 -0
- package/dist/features/typography/utils/resolveHeadingTextStyle.d.ts +7 -0
- package/dist/features/typography/utils/resolveHeadingTextStyle.d.ts.map +1 -0
- package/dist/features/typography/utils/resolveHeadingTextStyle.js +10 -0
- package/dist/features/typography/utils/resolveHeadingTextStyle.js.map +1 -0
- package/dist/index.d.ts +24 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -11
- package/dist/index.js.map +1 -1
- package/dist/layout/AppBar.d.ts +1 -1
- package/dist/layout/AppBar.d.ts.map +1 -1
- package/dist/layout/AppBar.js +1 -2
- package/dist/layout/AppBar.js.map +1 -1
- package/dist/layout/Center.d.ts +1 -1
- package/dist/layout/Center.d.ts.map +1 -1
- package/dist/layout/Center.js +1 -1
- package/dist/layout/Center.js.map +1 -1
- package/dist/layout/Inline.d.ts +1 -1
- package/dist/layout/Inline.d.ts.map +1 -1
- package/dist/layout/Inline.js +1 -1
- package/dist/layout/Inline.js.map +1 -1
- package/dist/layout/ScrollArea.d.ts +1 -1
- package/dist/layout/ScrollArea.d.ts.map +1 -1
- package/dist/layout/ScrollArea.js +1 -1
- package/dist/layout/ScrollArea.js.map +1 -1
- package/dist/layout/Spacer.d.ts +1 -1
- package/dist/layout/Spacer.d.ts.map +1 -1
- package/dist/layout/Spacer.js +1 -1
- package/dist/layout/Spacer.js.map +1 -1
- package/dist/layout/Template.d.ts +2 -2
- package/dist/layout/Template.d.ts.map +1 -1
- package/dist/layout/Template.js +2 -2
- package/dist/layout/Template.js.map +1 -1
- package/dist/layout/index.d.ts +0 -12
- package/dist/layout/index.d.ts.map +1 -1
- package/dist/layout/index.js +0 -6
- package/dist/layout/index.js.map +1 -1
- package/dist/primitives/button-base/ButtonBase.js +1 -1
- package/dist/primitives/button-base/ButtonBase.js.map +1 -1
- package/dist/primitives/button-base/types.d.ts +1 -1
- package/dist/primitives/button-base/types.d.ts.map +1 -1
- package/dist/primitives/button-base/types.js.map +1 -1
- package/dist/types/badge.d.ts +12 -0
- package/dist/types/badge.d.ts.map +1 -0
- package/dist/types/badge.js +2 -0
- package/dist/types/badge.js.map +1 -0
- package/dist/types/button.d.ts +25 -0
- package/dist/types/button.d.ts.map +1 -0
- package/dist/types/button.js +2 -0
- package/dist/types/button.js.map +1 -0
- package/dist/{components/card/types.d.ts → types/card.d.ts} +2 -2
- package/dist/types/card.d.ts.map +1 -0
- package/dist/types/card.js +2 -0
- package/dist/types/card.js.map +1 -0
- package/dist/{components/checkbox/types.d.ts → types/checkbox.d.ts} +4 -4
- package/dist/types/checkbox.d.ts.map +1 -0
- package/dist/types/checkbox.js +2 -0
- package/dist/types/checkbox.js.map +1 -0
- package/dist/types/icon.d.ts +66 -0
- package/dist/types/icon.d.ts.map +1 -0
- package/dist/types/icon.js +2 -0
- package/dist/types/icon.js.map +1 -0
- package/dist/{primitives/image/types.d.ts → types/image.d.ts} +3 -4
- package/dist/types/image.d.ts.map +1 -0
- package/dist/types/image.js +2 -0
- package/dist/types/image.js.map +1 -0
- package/dist/types/keyboard-avoiding-view.d.ts +4 -0
- package/dist/types/keyboard-avoiding-view.d.ts.map +1 -0
- package/dist/types/keyboard-avoiding-view.js +2 -0
- package/dist/types/keyboard-avoiding-view.js.map +1 -0
- package/dist/{layout/helpers.d.ts → types/layout.d.ts} +39 -5
- package/dist/types/layout.d.ts.map +1 -0
- package/dist/types/layout.js +2 -0
- package/dist/types/layout.js.map +1 -0
- package/dist/{components/radio/types.d.ts → types/radio.d.ts} +4 -4
- package/dist/types/radio.d.ts.map +1 -0
- package/dist/types/radio.js +2 -0
- package/dist/types/radio.js.map +1 -0
- package/dist/types/surface.d.ts +6 -0
- package/dist/types/surface.d.ts.map +1 -0
- package/dist/types/surface.js +2 -0
- package/dist/types/surface.js.map +1 -0
- package/dist/{components/text-input/types.d.ts → types/text-input.d.ts} +3 -3
- package/dist/types/text-input.d.ts.map +1 -0
- package/dist/types/text-input.js +2 -0
- package/dist/types/text-input.js.map +1 -0
- package/dist/types/typography.d.ts +29 -0
- package/dist/types/typography.d.ts.map +1 -0
- package/dist/types/typography.js +2 -0
- package/dist/types/typography.js.map +1 -0
- package/dist/utils/resolveBoxStyles.d.ts +7 -0
- package/dist/utils/resolveBoxStyles.d.ts.map +1 -0
- package/dist/utils/resolveBoxStyles.js +83 -0
- package/dist/utils/resolveBoxStyles.js.map +1 -0
- package/dist/utils/resolveSpacing.d.ts +5 -0
- package/dist/utils/resolveSpacing.d.ts.map +1 -0
- package/dist/utils/resolveSpacing.js +6 -0
- package/dist/utils/resolveSpacing.js.map +1 -0
- package/package.json +1 -1
- package/src/components/field/Field.tsx +1 -1
- package/src/components/helper-text/HelperText.tsx +1 -1
- package/src/components/label/Label.tsx +1 -1
- package/src/components/list-item/ListItem.tsx +2 -2
- package/src/components/menu/Menu.tsx +4 -2
- package/src/components/modal/Modal.tsx +2 -1
- package/src/components/switch/Switch.tsx +2 -2
- package/src/components/tabs/Tab.tsx +2 -2
- package/src/components/tabs/TabList.tsx +1 -1
- package/src/components/tabs/Tabs.tsx +1 -1
- package/src/components/textarea/Textarea.tsx +1 -1
- package/src/components/textarea/types.ts +1 -1
- package/src/components/toast/Toast.tsx +4 -2
- package/src/components/toast/ToastProvider.tsx +1 -1
- package/src/components/tooltip/Tooltip.tsx +2 -2
- package/src/examples/DocsExamples.tsx +6 -6
- package/src/features/badge/adapters/inbound/Badge.tsx +58 -0
- package/src/features/badge/public.ts +2 -0
- package/src/features/button/adapters/inbound/Button.tsx +159 -0
- package/src/features/button/adapters/inbound/IconButton.tsx +69 -0
- package/src/features/button/public.ts +3 -0
- package/src/features/card/adapters/inbound/Card.tsx +88 -0
- package/src/features/card/public.ts +2 -0
- package/src/features/form/checkbox/adapters/inbound/Checkbox.tsx +207 -0
- package/src/features/form/checkbox/public.ts +2 -0
- package/src/{components/radio → features/form/radio/adapters/inbound}/Radio.test.ts +5 -5
- package/src/features/form/radio/adapters/inbound/Radio.tsx +214 -0
- package/src/features/form/radio/public.ts +2 -0
- package/src/{components/radio → features/form/radio/utils}/isRadioTextContent.ts +1 -3
- package/src/features/form/text-input/adapters/inbound/TextInput.tsx +72 -0
- package/src/features/form/text-input/public.ts +2 -0
- package/src/features/form/text-input/utils/resolveTextInputPresentation.ts +91 -0
- package/src/features/icon/adapters/inbound/Icon.tsx +14 -0
- package/src/{primitives/icon → features/icon/adapters/inbound}/PortableIcon.tsx +41 -97
- package/src/{primitives/icon → features/icon/adapters/inbound}/PortableIcon.web.test.tsx +6 -10
- package/src/features/icon/constants.ts +9 -0
- package/src/features/icon/public.ts +10 -0
- package/src/features/image/adapters/inbound/Image.tsx +55 -0
- package/src/features/image/public.ts +2 -0
- package/src/features/image/utils/getSourceKey.ts +32 -0
- package/src/features/image/utils/normalizeSource.ts +12 -0
- package/src/features/image/utils/resolveAccessibilityLabel.ts +9 -0
- package/src/features/image/utils/resolveAlt.ts +9 -0
- package/src/{primitives/image → features/image/utils}/resolveImageProps.test.ts +10 -22
- package/src/features/image/utils/resolveImageStyle.ts +23 -0
- package/src/features/image/utils/resolveRenderedSource.ts +11 -0
- package/src/features/image/utils/resolveResizeMode.ts +11 -0
- package/src/features/keyboard-avoiding-view/adapters/inbound/KeyboardAvoidingView.tsx +9 -0
- package/src/features/keyboard-avoiding-view/public.ts +5 -0
- package/src/{layout → features/layout/adapters/inbound}/Box.tsx +7 -15
- package/src/features/layout/adapters/inbound/Container.tsx +43 -0
- package/src/{layout → features/layout/adapters/inbound}/Divider.tsx +3 -8
- package/src/features/layout/adapters/inbound/Grid.tsx +78 -0
- package/src/{layout → features/layout/adapters/inbound}/Stack.test.ts +0 -1
- package/src/{layout → features/layout/adapters/inbound}/Stack.tsx +6 -15
- package/src/features/layout/public.ts +12 -0
- package/src/{layout → features/surface/adapters/inbound}/Surface.tsx +24 -41
- package/src/features/surface/public.ts +2 -0
- package/src/{primitives/heading → features/typography/adapters/inbound}/Heading.tsx +35 -38
- package/src/{primitives/text → features/typography/adapters/inbound}/Text.tsx +25 -35
- package/src/features/typography/public.ts +3 -0
- package/src/{primitives/heading/resolveHeadingStyle.test.ts → features/typography/utils/resolveHeadingTextStyle.test.ts} +5 -12
- package/src/features/typography/utils/resolveHeadingTextStyle.ts +21 -0
- package/src/index.test.ts +59 -19
- package/src/index.ts +37 -26
- package/src/layout/AppBar.tsx +1 -2
- package/src/layout/Center.tsx +1 -1
- package/src/layout/Inline.tsx +1 -1
- package/src/layout/ScrollArea.tsx +2 -1
- package/src/layout/Spacer.tsx +2 -2
- package/src/layout/Template.tsx +3 -2
- package/src/layout/index.ts +0 -12
- package/src/primitives/button-base/ButtonBase.tsx +1 -1
- package/src/primitives/button-base/types.ts +1 -1
- package/src/{components/badge/types.ts → types/badge.ts} +3 -3
- package/src/types/button.ts +34 -0
- package/src/{components/card/types.ts → types/card.ts} +1 -1
- package/src/{components/checkbox/types.ts → types/checkbox.ts} +3 -3
- package/src/types/icon.ts +52 -0
- package/src/{primitives/image/types.ts → types/image.ts} +3 -3
- package/src/types/keyboard-avoiding-view.ts +6 -0
- package/src/types/layout.ts +96 -0
- package/src/{components/radio/types.ts → types/radio.ts} +3 -3
- package/src/types/surface.ts +7 -0
- package/src/{components/text-input/types.ts → types/text-input.ts} +2 -2
- package/src/types/typography.ts +32 -0
- package/src/{layout/helpers.test.ts → utils/resolveBoxStyles.test.ts} +8 -25
- package/src/utils/resolveBoxStyles.ts +135 -0
- package/src/utils/resolveSpacing.ts +11 -0
- package/src/webAcceptance.test.tsx +18 -2
- package/dist/components/badge/Badge.d.ts +0 -4
- package/dist/components/badge/Badge.d.ts.map +0 -1
- package/dist/components/badge/Badge.js +0 -30
- package/dist/components/badge/Badge.js.map +0 -1
- package/dist/components/badge/index.d.ts +0 -3
- package/dist/components/badge/index.d.ts.map +0 -1
- package/dist/components/badge/index.js +0 -2
- package/dist/components/badge/index.js.map +0 -1
- package/dist/components/badge/types.d.ts +0 -12
- package/dist/components/badge/types.d.ts.map +0 -1
- package/dist/components/badge/types.js +0 -2
- package/dist/components/badge/types.js.map +0 -1
- package/dist/components/button/Button.d.ts.map +0 -1
- package/dist/components/button/Button.js +0 -51
- package/dist/components/button/Button.js.map +0 -1
- package/dist/components/button/index.d.ts +0 -3
- package/dist/components/button/index.d.ts.map +0 -1
- package/dist/components/button/index.js +0 -2
- package/dist/components/button/index.js.map +0 -1
- package/dist/components/button/types.d.ts +0 -18
- package/dist/components/button/types.d.ts.map +0 -1
- package/dist/components/button/types.js +0 -2
- package/dist/components/button/types.js.map +0 -1
- package/dist/components/card/Card.d.ts +0 -4
- package/dist/components/card/Card.d.ts.map +0 -1
- package/dist/components/card/Card.js +0 -46
- package/dist/components/card/Card.js.map +0 -1
- package/dist/components/card/index.d.ts +0 -3
- package/dist/components/card/index.d.ts.map +0 -1
- package/dist/components/card/index.js +0 -2
- package/dist/components/card/index.js.map +0 -1
- package/dist/components/card/types.d.ts.map +0 -1
- package/dist/components/card/types.js +0 -2
- package/dist/components/card/types.js.map +0 -1
- package/dist/components/checkbox/Checkbox.d.ts +0 -4
- package/dist/components/checkbox/Checkbox.d.ts.map +0 -1
- package/dist/components/checkbox/Checkbox.js +0 -69
- package/dist/components/checkbox/Checkbox.js.map +0 -1
- package/dist/components/checkbox/index.d.ts +0 -3
- package/dist/components/checkbox/index.d.ts.map +0 -1
- package/dist/components/checkbox/index.js +0 -2
- package/dist/components/checkbox/index.js.map +0 -1
- package/dist/components/checkbox/types.d.ts.map +0 -1
- package/dist/components/checkbox/types.js +0 -2
- package/dist/components/checkbox/types.js.map +0 -1
- package/dist/components/icon-button/IconButton.d.ts.map +0 -1
- package/dist/components/icon-button/IconButton.js +0 -28
- package/dist/components/icon-button/IconButton.js.map +0 -1
- package/dist/components/icon-button/index.d.ts +0 -3
- package/dist/components/icon-button/index.d.ts.map +0 -1
- package/dist/components/icon-button/index.js +0 -2
- package/dist/components/icon-button/index.js.map +0 -1
- package/dist/components/icon-button/types.d.ts +0 -13
- package/dist/components/icon-button/types.d.ts.map +0 -1
- package/dist/components/icon-button/types.js +0 -2
- package/dist/components/icon-button/types.js.map +0 -1
- package/dist/components/radio/Radio.d.ts +0 -7
- package/dist/components/radio/Radio.d.ts.map +0 -1
- package/dist/components/radio/Radio.js +0 -75
- package/dist/components/radio/Radio.js.map +0 -1
- package/dist/components/radio/index.d.ts +0 -3
- package/dist/components/radio/index.d.ts.map +0 -1
- package/dist/components/radio/index.js +0 -2
- package/dist/components/radio/index.js.map +0 -1
- package/dist/components/radio/isRadioTextContent.d.ts +0 -6
- package/dist/components/radio/isRadioTextContent.d.ts.map +0 -1
- package/dist/components/radio/isRadioTextContent.js +0 -7
- package/dist/components/radio/isRadioTextContent.js.map +0 -1
- package/dist/components/radio/types.d.ts.map +0 -1
- package/dist/components/radio/types.js +0 -2
- package/dist/components/radio/types.js.map +0 -1
- package/dist/components/text-input/TextInput.d.ts +0 -4
- package/dist/components/text-input/TextInput.d.ts.map +0 -1
- package/dist/components/text-input/TextInput.js +0 -72
- package/dist/components/text-input/TextInput.js.map +0 -1
- package/dist/components/text-input/index.d.ts +0 -3
- package/dist/components/text-input/index.d.ts.map +0 -1
- package/dist/components/text-input/index.js +0 -2
- package/dist/components/text-input/index.js.map +0 -1
- package/dist/components/text-input/types.d.ts.map +0 -1
- package/dist/components/text-input/types.js +0 -2
- package/dist/components/text-input/types.js.map +0 -1
- package/dist/layout/Box.d.ts +0 -14
- package/dist/layout/Box.d.ts.map +0 -1
- package/dist/layout/Box.js.map +0 -1
- package/dist/layout/Container.d.ts +0 -11
- package/dist/layout/Container.d.ts.map +0 -1
- package/dist/layout/Container.js +0 -24
- package/dist/layout/Container.js.map +0 -1
- package/dist/layout/Divider.d.ts +0 -10
- package/dist/layout/Divider.d.ts.map +0 -1
- package/dist/layout/Divider.js.map +0 -1
- package/dist/layout/Grid.d.ts +0 -14
- package/dist/layout/Grid.d.ts.map +0 -1
- package/dist/layout/Grid.js +0 -51
- package/dist/layout/Grid.js.map +0 -1
- package/dist/layout/Stack.d.ts +0 -14
- package/dist/layout/Stack.d.ts.map +0 -1
- package/dist/layout/Stack.js.map +0 -1
- package/dist/layout/Surface.d.ts +0 -8
- package/dist/layout/Surface.d.ts.map +0 -1
- package/dist/layout/Surface.js.map +0 -1
- package/dist/layout/helpers.d.ts.map +0 -1
- package/dist/layout/helpers.js +0 -91
- package/dist/layout/helpers.js.map +0 -1
- package/dist/primitives/heading/Heading.d.ts +0 -4
- package/dist/primitives/heading/Heading.d.ts.map +0 -1
- package/dist/primitives/heading/Heading.js +0 -30
- package/dist/primitives/heading/Heading.js.map +0 -1
- package/dist/primitives/heading/index.d.ts +0 -3
- package/dist/primitives/heading/index.d.ts.map +0 -1
- package/dist/primitives/heading/index.js +0 -2
- package/dist/primitives/heading/index.js.map +0 -1
- package/dist/primitives/heading/resolveHeadingStyle.d.ts +0 -6
- package/dist/primitives/heading/resolveHeadingStyle.d.ts.map +0 -1
- package/dist/primitives/heading/resolveHeadingStyle.js +0 -9
- package/dist/primitives/heading/resolveHeadingStyle.js.map +0 -1
- package/dist/primitives/heading/types.d.ts +0 -15
- package/dist/primitives/heading/types.d.ts.map +0 -1
- package/dist/primitives/heading/types.js +0 -2
- package/dist/primitives/heading/types.js.map +0 -1
- package/dist/primitives/icon/Icon.d.ts +0 -16
- package/dist/primitives/icon/Icon.d.ts.map +0 -1
- package/dist/primitives/icon/Icon.js.map +0 -1
- package/dist/primitives/icon/PortableIcon.d.ts +0 -70
- package/dist/primitives/icon/PortableIcon.d.ts.map +0 -1
- package/dist/primitives/icon/PortableIcon.js.map +0 -1
- package/dist/primitives/icon/index.d.ts +0 -4
- package/dist/primitives/icon/index.d.ts.map +0 -1
- package/dist/primitives/icon/index.js +0 -3
- package/dist/primitives/icon/index.js.map +0 -1
- package/dist/primitives/image/Image.d.ts.map +0 -1
- package/dist/primitives/image/Image.js +0 -26
- package/dist/primitives/image/Image.js.map +0 -1
- package/dist/primitives/image/index.d.ts +0 -3
- package/dist/primitives/image/index.d.ts.map +0 -1
- package/dist/primitives/image/index.js +0 -2
- package/dist/primitives/image/index.js.map +0 -1
- package/dist/primitives/image/resolveImageProps.d.ts +0 -12
- package/dist/primitives/image/resolveImageProps.d.ts.map +0 -1
- package/dist/primitives/image/resolveImageProps.js +0 -67
- package/dist/primitives/image/resolveImageProps.js.map +0 -1
- package/dist/primitives/image/types.d.ts.map +0 -1
- package/dist/primitives/image/types.js +0 -2
- package/dist/primitives/image/types.js.map +0 -1
- package/dist/primitives/text/Text.d.ts.map +0 -1
- package/dist/primitives/text/Text.js.map +0 -1
- package/dist/primitives/text/index.d.ts +0 -3
- package/dist/primitives/text/index.d.ts.map +0 -1
- package/dist/primitives/text/index.js +0 -2
- package/dist/primitives/text/index.js.map +0 -1
- package/dist/primitives/text/types.d.ts +0 -17
- package/dist/primitives/text/types.d.ts.map +0 -1
- package/dist/primitives/text/types.js +0 -2
- package/dist/primitives/text/types.js.map +0 -1
- package/src/components/badge/Badge.tsx +0 -52
- package/src/components/badge/index.ts +0 -2
- package/src/components/button/Button.tsx +0 -98
- package/src/components/button/index.ts +0 -2
- package/src/components/button/types.ts +0 -23
- package/src/components/card/Card.tsx +0 -81
- package/src/components/card/index.ts +0 -2
- package/src/components/checkbox/Checkbox.tsx +0 -120
- package/src/components/checkbox/index.ts +0 -2
- package/src/components/icon-button/IconButton.tsx +0 -55
- package/src/components/icon-button/index.ts +0 -2
- package/src/components/icon-button/types.ts +0 -16
- package/src/components/radio/Radio.tsx +0 -124
- package/src/components/radio/index.ts +0 -2
- package/src/components/text-input/TextInput.tsx +0 -124
- package/src/components/text-input/index.ts +0 -2
- package/src/layout/Container.tsx +0 -43
- package/src/layout/Grid.tsx +0 -83
- package/src/layout/helpers.ts +0 -205
- package/src/primitives/heading/index.ts +0 -2
- package/src/primitives/heading/resolveHeadingStyle.ts +0 -20
- package/src/primitives/heading/types.ts +0 -17
- package/src/primitives/icon/Icon.tsx +0 -34
- package/src/primitives/icon/index.ts +0 -10
- package/src/primitives/image/Image.tsx +0 -65
- package/src/primitives/image/index.ts +0 -2
- package/src/primitives/image/resolveImageProps.ts +0 -92
- package/src/primitives/text/index.ts +0 -2
- package/src/primitives/text/types.ts +0 -18
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ActivityIndicator, View, type ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
type InteractionState,
|
|
6
|
+
resolveButtonColors,
|
|
7
|
+
resolveControlSize,
|
|
8
|
+
resolveIconSize,
|
|
9
|
+
} from '../../../../internal/resolvers';
|
|
10
|
+
import { ButtonBase } from '../../../../primitives/button-base';
|
|
11
|
+
import { useTheme } from '../../../../theme/ThemeContext';
|
|
12
|
+
import type { SurfaceTheme } from '../../../../theme/types';
|
|
13
|
+
import type { ButtonProps } from '../../../../types/button';
|
|
14
|
+
import { Icon } from '../../../icon/public';
|
|
15
|
+
import { Box } from '../../../layout/public';
|
|
16
|
+
import { Text } from '../../../typography/public';
|
|
17
|
+
|
|
18
|
+
/*** Renders the primary Surface action control with semantic visual states. */
|
|
19
|
+
export function Button({
|
|
20
|
+
children,
|
|
21
|
+
variant = 'solid',
|
|
22
|
+
color = 'primary',
|
|
23
|
+
size = 'm',
|
|
24
|
+
disabled = false,
|
|
25
|
+
loading = false,
|
|
26
|
+
leadingIcon,
|
|
27
|
+
trailingIcon,
|
|
28
|
+
fullWidth = false,
|
|
29
|
+
onPress,
|
|
30
|
+
testID,
|
|
31
|
+
...props
|
|
32
|
+
}: ButtonProps) {
|
|
33
|
+
const { theme } = useTheme();
|
|
34
|
+
const controlSize = resolveControlSize(theme, size);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<ButtonBase
|
|
38
|
+
{...props}
|
|
39
|
+
disabled={disabled || loading}
|
|
40
|
+
onPress={onPress}
|
|
41
|
+
style={resolveButtonBaseStyle(fullWidth)}
|
|
42
|
+
testID={testID}
|
|
43
|
+
>
|
|
44
|
+
{(state) => (
|
|
45
|
+
<ButtonContent
|
|
46
|
+
color={color}
|
|
47
|
+
controlSize={controlSize}
|
|
48
|
+
fullWidth={fullWidth}
|
|
49
|
+
leadingIcon={leadingIcon}
|
|
50
|
+
loading={loading}
|
|
51
|
+
size={size}
|
|
52
|
+
state={state}
|
|
53
|
+
theme={theme}
|
|
54
|
+
trailingIcon={trailingIcon}
|
|
55
|
+
variant={variant}
|
|
56
|
+
>
|
|
57
|
+
{children}
|
|
58
|
+
</ButtonContent>
|
|
59
|
+
)}
|
|
60
|
+
</ButtonBase>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/*** Renders Button content after interaction colors have been resolved. */
|
|
65
|
+
function ButtonContent({
|
|
66
|
+
children,
|
|
67
|
+
color,
|
|
68
|
+
controlSize,
|
|
69
|
+
fullWidth,
|
|
70
|
+
leadingIcon,
|
|
71
|
+
loading,
|
|
72
|
+
size,
|
|
73
|
+
state,
|
|
74
|
+
theme,
|
|
75
|
+
trailingIcon,
|
|
76
|
+
variant,
|
|
77
|
+
}: ButtonContentProps) {
|
|
78
|
+
const colors = resolveButtonColors(theme, { variant, color, state });
|
|
79
|
+
const muted = colors.contentColor === theme.semantics.content.muted;
|
|
80
|
+
const iconSize = resolveIconSize(theme, size);
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<Box
|
|
84
|
+
px={controlSize.paddingHorizontal}
|
|
85
|
+
py={controlSize.paddingVertical}
|
|
86
|
+
radius={controlSize.borderRadius}
|
|
87
|
+
style={resolveButtonContentStyle(controlSize, colors, fullWidth, variant)}
|
|
88
|
+
>
|
|
89
|
+
{loading ? (
|
|
90
|
+
<ActivityIndicator color={colors.contentColor} size="small" />
|
|
91
|
+
) : (
|
|
92
|
+
<>
|
|
93
|
+
{leadingIcon ? (
|
|
94
|
+
<View style={resolveAccessoryStyle(theme.spacing.s, 'leading')}>
|
|
95
|
+
<Icon {...leadingIcon} color={colors.contentColor} size={iconSize} />
|
|
96
|
+
</View>
|
|
97
|
+
) : null}
|
|
98
|
+
<Text
|
|
99
|
+
color={muted ? undefined : color}
|
|
100
|
+
emphasis={muted ? 'muted' : variant === 'solid' ? 'inverse' : 'default'}
|
|
101
|
+
variant={controlSize.textVariant}
|
|
102
|
+
weight="semiBold"
|
|
103
|
+
>
|
|
104
|
+
{children}
|
|
105
|
+
</Text>
|
|
106
|
+
{trailingIcon ? (
|
|
107
|
+
<View style={resolveAccessoryStyle(theme.spacing.s, 'trailing')}>
|
|
108
|
+
<Icon {...trailingIcon} color={colors.contentColor} size={iconSize} />
|
|
109
|
+
</View>
|
|
110
|
+
) : null}
|
|
111
|
+
</>
|
|
112
|
+
)}
|
|
113
|
+
</Box>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/*** Resolves the outer ButtonBase layout style. */
|
|
118
|
+
function resolveButtonBaseStyle(fullWidth: boolean): ViewStyle {
|
|
119
|
+
return { alignSelf: fullWidth ? 'stretch' : 'flex-start' };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/*** Resolves the themed Button content container style. */
|
|
123
|
+
function resolveButtonContentStyle(
|
|
124
|
+
controlSize: ReturnType<typeof resolveControlSize>,
|
|
125
|
+
colors: ReturnType<typeof resolveButtonColors>,
|
|
126
|
+
fullWidth: boolean,
|
|
127
|
+
variant: NonNullable<ButtonProps['variant']>,
|
|
128
|
+
): ViewStyle {
|
|
129
|
+
return {
|
|
130
|
+
alignItems: 'center',
|
|
131
|
+
backgroundColor: colors.backgroundColor,
|
|
132
|
+
borderColor: colors.borderColor,
|
|
133
|
+
borderWidth: variant === 'solid' ? 0 : 1,
|
|
134
|
+
flexDirection: 'row',
|
|
135
|
+
justifyContent: 'center',
|
|
136
|
+
minHeight: controlSize.minHeight,
|
|
137
|
+
opacity: colors.opacity,
|
|
138
|
+
width: fullWidth ? '100%' : undefined,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/*** Resolves spacing around a leading or trailing Button icon. */
|
|
143
|
+
function resolveAccessoryStyle(spacing: number, position: 'leading' | 'trailing'): ViewStyle {
|
|
144
|
+
return position === 'leading' ? { marginRight: spacing } : { marginLeft: spacing };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
interface ButtonContentProps {
|
|
148
|
+
children: ButtonProps['children'];
|
|
149
|
+
color: NonNullable<ButtonProps['color']>;
|
|
150
|
+
controlSize: ReturnType<typeof resolveControlSize>;
|
|
151
|
+
fullWidth: boolean;
|
|
152
|
+
leadingIcon: ButtonProps['leadingIcon'];
|
|
153
|
+
loading: boolean;
|
|
154
|
+
size: NonNullable<ButtonProps['size']>;
|
|
155
|
+
state: InteractionState;
|
|
156
|
+
theme: SurfaceTheme;
|
|
157
|
+
trailingIcon: ButtonProps['trailingIcon'];
|
|
158
|
+
variant: NonNullable<ButtonProps['variant']>;
|
|
159
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
resolveButtonColors,
|
|
6
|
+
resolveControlSize,
|
|
7
|
+
resolveIconSize,
|
|
8
|
+
} from '../../../../internal/resolvers';
|
|
9
|
+
import { ButtonBase } from '../../../../primitives/button-base';
|
|
10
|
+
import { useTheme } from '../../../../theme/ThemeContext';
|
|
11
|
+
import type { IconButtonProps } from '../../../../types/button';
|
|
12
|
+
import { Icon } from '../../../icon/public';
|
|
13
|
+
import { Box } from '../../../layout/public';
|
|
14
|
+
|
|
15
|
+
/*** Renders a compact accessible icon-only action control. */
|
|
16
|
+
export function IconButton({
|
|
17
|
+
icon,
|
|
18
|
+
accessibilityLabel,
|
|
19
|
+
variant = 'ghost',
|
|
20
|
+
color = 'primary',
|
|
21
|
+
size = 'm',
|
|
22
|
+
disabled = false,
|
|
23
|
+
onPress,
|
|
24
|
+
testID,
|
|
25
|
+
...props
|
|
26
|
+
}: IconButtonProps) {
|
|
27
|
+
const { theme } = useTheme();
|
|
28
|
+
const controlSize = resolveControlSize(theme, size);
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<ButtonBase
|
|
32
|
+
{...props}
|
|
33
|
+
accessibilityLabel={accessibilityLabel}
|
|
34
|
+
disabled={disabled}
|
|
35
|
+
onPress={onPress}
|
|
36
|
+
testID={testID}
|
|
37
|
+
>
|
|
38
|
+
{(state) => {
|
|
39
|
+
const colors = resolveButtonColors(theme, { color, state, variant });
|
|
40
|
+
return (
|
|
41
|
+
<Box
|
|
42
|
+
radius={controlSize.borderRadius}
|
|
43
|
+
style={resolveIconButtonStyle(controlSize, colors, variant)}
|
|
44
|
+
>
|
|
45
|
+
<Icon {...icon} color={colors.contentColor} size={resolveIconSize(theme, size)} />
|
|
46
|
+
</Box>
|
|
47
|
+
);
|
|
48
|
+
}}
|
|
49
|
+
</ButtonBase>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/*** Resolves the visual container style for an IconButton interaction state. */
|
|
54
|
+
function resolveIconButtonStyle(
|
|
55
|
+
controlSize: ReturnType<typeof resolveControlSize>,
|
|
56
|
+
colors: ReturnType<typeof resolveButtonColors>,
|
|
57
|
+
variant: NonNullable<IconButtonProps['variant']>,
|
|
58
|
+
): ViewStyle {
|
|
59
|
+
return {
|
|
60
|
+
alignItems: 'center',
|
|
61
|
+
backgroundColor: colors.backgroundColor,
|
|
62
|
+
borderColor: colors.borderColor,
|
|
63
|
+
borderWidth: variant === 'solid' ? 0 : 1,
|
|
64
|
+
justifyContent: 'center',
|
|
65
|
+
minHeight: controlSize.minHeight,
|
|
66
|
+
minWidth: controlSize.minHeight,
|
|
67
|
+
opacity: colors.opacity,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { ButtonBase } from '../../../../primitives/button-base';
|
|
5
|
+
import { useTheme } from '../../../../theme/ThemeContext';
|
|
6
|
+
import type { CardProps } from '../../../../types/card';
|
|
7
|
+
import type { SurfaceVariant } from '../../../../types/surface';
|
|
8
|
+
import { Surface } from '../../../surface/public';
|
|
9
|
+
|
|
10
|
+
/*** Renders a themed content card with optional interactive press states. */
|
|
11
|
+
export function Card({
|
|
12
|
+
children,
|
|
13
|
+
variant = 'default',
|
|
14
|
+
onPress,
|
|
15
|
+
disabled = false,
|
|
16
|
+
testID,
|
|
17
|
+
style,
|
|
18
|
+
...props
|
|
19
|
+
}: CardProps) {
|
|
20
|
+
const { theme } = useTheme();
|
|
21
|
+
|
|
22
|
+
if (!onPress) {
|
|
23
|
+
return (
|
|
24
|
+
<Surface {...props} style={style} testID={testID} variant={variant}>
|
|
25
|
+
{children}
|
|
26
|
+
</Surface>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<ButtonBase accessibilityRole="button" disabled={disabled} onPress={onPress} testID={testID}>
|
|
32
|
+
{(state) => (
|
|
33
|
+
<Surface
|
|
34
|
+
{...props}
|
|
35
|
+
style={[
|
|
36
|
+
resolveInteractiveCardStyle(variant, state.pressed, state.hovered, state.disabled, {
|
|
37
|
+
active: theme.semantics.neutral.surfaceActive,
|
|
38
|
+
base: theme.semantics.surface.default,
|
|
39
|
+
hover: theme.semantics.neutral.surfaceHover,
|
|
40
|
+
subtle: theme.semantics.surface.subtle,
|
|
41
|
+
}),
|
|
42
|
+
style,
|
|
43
|
+
]}
|
|
44
|
+
variant={variant}
|
|
45
|
+
>
|
|
46
|
+
{children}
|
|
47
|
+
</Surface>
|
|
48
|
+
)}
|
|
49
|
+
</ButtonBase>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/*** Resolves the complete interactive style for one Card state. */
|
|
54
|
+
function resolveInteractiveCardStyle(
|
|
55
|
+
variant: SurfaceVariant,
|
|
56
|
+
pressed: boolean,
|
|
57
|
+
hovered: boolean,
|
|
58
|
+
disabled: boolean,
|
|
59
|
+
backgrounds: CardBackgrounds,
|
|
60
|
+
): ViewStyle {
|
|
61
|
+
return {
|
|
62
|
+
backgroundColor: resolveCardStateBackground(variant, pressed, hovered, backgrounds),
|
|
63
|
+
opacity: disabled ? 0.72 : 1,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/*** Resolves the interactive background for one Card variant and state. */
|
|
68
|
+
function resolveCardStateBackground(
|
|
69
|
+
variant: SurfaceVariant,
|
|
70
|
+
pressed: boolean,
|
|
71
|
+
hovered: boolean,
|
|
72
|
+
backgrounds: CardBackgrounds,
|
|
73
|
+
) {
|
|
74
|
+
if (variant === 'outline') {
|
|
75
|
+
return pressed ? backgrounds.active : hovered ? backgrounds.hover : 'transparent';
|
|
76
|
+
}
|
|
77
|
+
if (variant === 'subtle') {
|
|
78
|
+
return pressed ? backgrounds.active : hovered ? backgrounds.hover : backgrounds.subtle;
|
|
79
|
+
}
|
|
80
|
+
return pressed ? backgrounds.active : hovered ? backgrounds.hover : backgrounds.base;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
interface CardBackgrounds {
|
|
84
|
+
active: string;
|
|
85
|
+
base: string;
|
|
86
|
+
hover: string;
|
|
87
|
+
subtle: string;
|
|
88
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
type InteractionState,
|
|
6
|
+
resolveFieldState,
|
|
7
|
+
resolveIndicatorSize,
|
|
8
|
+
resolveSelectionControlColors,
|
|
9
|
+
resolveSelectionControlNextChecked,
|
|
10
|
+
} from '../../../../../internal/resolvers';
|
|
11
|
+
import { useControllableState } from '../../../../../internal/useControllableState';
|
|
12
|
+
import { ButtonBase } from '../../../../../primitives/button-base';
|
|
13
|
+
import type { ButtonBaseProps } from '../../../../../primitives/button-base/types';
|
|
14
|
+
import { useTheme } from '../../../../../theme/ThemeContext';
|
|
15
|
+
import type { SurfaceTheme } from '../../../../../theme/types';
|
|
16
|
+
import type { CheckboxProps } from '../../../../../types/checkbox';
|
|
17
|
+
import { Box } from '../../../../layout/public';
|
|
18
|
+
import { Text } from '../../../../typography/public';
|
|
19
|
+
|
|
20
|
+
/*** Renders a controlled or uncontrolled accessible checkbox. */
|
|
21
|
+
export function Checkbox({
|
|
22
|
+
accessibilityLabel,
|
|
23
|
+
checked,
|
|
24
|
+
children,
|
|
25
|
+
color = 'primary',
|
|
26
|
+
defaultChecked = false,
|
|
27
|
+
disabled = false,
|
|
28
|
+
invalid = false,
|
|
29
|
+
onCheckedChange,
|
|
30
|
+
readOnly = false,
|
|
31
|
+
size = 'm',
|
|
32
|
+
testID,
|
|
33
|
+
...buttonProps
|
|
34
|
+
}: CheckboxProps) {
|
|
35
|
+
const { theme } = useTheme();
|
|
36
|
+
const [isChecked, setChecked] = useControllableState<boolean>({
|
|
37
|
+
value: checked,
|
|
38
|
+
defaultValue: defaultChecked,
|
|
39
|
+
onChange: onCheckedChange,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<CheckboxControl
|
|
44
|
+
accessibilityLabel={accessibilityLabel}
|
|
45
|
+
buttonProps={buttonProps}
|
|
46
|
+
color={color}
|
|
47
|
+
disabled={disabled}
|
|
48
|
+
invalid={invalid}
|
|
49
|
+
isChecked={isChecked}
|
|
50
|
+
readOnly={readOnly}
|
|
51
|
+
setChecked={setChecked}
|
|
52
|
+
size={size}
|
|
53
|
+
testID={testID}
|
|
54
|
+
theme={theme}
|
|
55
|
+
>
|
|
56
|
+
{children}
|
|
57
|
+
</CheckboxControl>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/*** Owns the checkbox interaction boundary around resolved selection content. */
|
|
62
|
+
function CheckboxControl({
|
|
63
|
+
accessibilityLabel,
|
|
64
|
+
buttonProps,
|
|
65
|
+
children,
|
|
66
|
+
color,
|
|
67
|
+
disabled,
|
|
68
|
+
invalid,
|
|
69
|
+
isChecked,
|
|
70
|
+
readOnly,
|
|
71
|
+
setChecked,
|
|
72
|
+
size,
|
|
73
|
+
testID,
|
|
74
|
+
theme,
|
|
75
|
+
}: CheckboxControlProps) {
|
|
76
|
+
const nextChecked = resolveSelectionControlNextChecked({
|
|
77
|
+
checked: isChecked,
|
|
78
|
+
disabled,
|
|
79
|
+
kind: 'checkbox',
|
|
80
|
+
readOnly,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<ButtonBase
|
|
85
|
+
{...buttonProps}
|
|
86
|
+
accessibilityLabel={accessibilityLabel}
|
|
87
|
+
accessibilityRole="checkbox"
|
|
88
|
+
accessibilityState={{ checked: isChecked }}
|
|
89
|
+
disabled={disabled}
|
|
90
|
+
onPress={nextChecked === null ? undefined : () => setChecked(nextChecked)}
|
|
91
|
+
testID={testID}
|
|
92
|
+
>
|
|
93
|
+
{(interactionState) =>
|
|
94
|
+
renderCheckboxContent({
|
|
95
|
+
children,
|
|
96
|
+
color,
|
|
97
|
+
disabled,
|
|
98
|
+
interactionState,
|
|
99
|
+
invalid,
|
|
100
|
+
isChecked,
|
|
101
|
+
readOnly,
|
|
102
|
+
size,
|
|
103
|
+
theme,
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
</ButtonBase>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/*** Renders the checkbox indicator and optional label for one interaction state. */
|
|
111
|
+
function renderCheckboxContent(input: CheckboxContentInput) {
|
|
112
|
+
const { interactionState, theme } = input;
|
|
113
|
+
const fieldState = resolveFieldState({
|
|
114
|
+
disabled: input.disabled,
|
|
115
|
+
focused: interactionState.focused,
|
|
116
|
+
invalid: input.invalid,
|
|
117
|
+
readOnly: input.readOnly,
|
|
118
|
+
});
|
|
119
|
+
const colors = resolveSelectionControlColors(theme, {
|
|
120
|
+
checked: input.isChecked,
|
|
121
|
+
fieldState,
|
|
122
|
+
hovered: interactionState.hovered,
|
|
123
|
+
pressed: interactionState.pressed,
|
|
124
|
+
color: input.color,
|
|
125
|
+
});
|
|
126
|
+
const indicatorSize = resolveIndicatorSize(input.size);
|
|
127
|
+
const labelEmphasis = colors.labelColor === theme.semantics.content.muted ? 'muted' : 'default';
|
|
128
|
+
const indicatorColor = fieldState.invalid ? 'error' : input.color;
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<Box style={resolveSelectionRowStyle(colors.opacity)}>
|
|
132
|
+
<Box
|
|
133
|
+
radius="s"
|
|
134
|
+
style={resolveCheckboxIndicatorStyle(
|
|
135
|
+
colors.backgroundColor,
|
|
136
|
+
colors.borderColor,
|
|
137
|
+
indicatorSize.checkbox,
|
|
138
|
+
)}
|
|
139
|
+
>
|
|
140
|
+
{input.isChecked ? (
|
|
141
|
+
<Text
|
|
142
|
+
color={input.disabled ? undefined : indicatorColor}
|
|
143
|
+
emphasis={input.disabled ? 'muted' : 'inverse'}
|
|
144
|
+
variant="caption"
|
|
145
|
+
weight="bold"
|
|
146
|
+
>
|
|
147
|
+
✓
|
|
148
|
+
</Text>
|
|
149
|
+
) : null}
|
|
150
|
+
</Box>
|
|
151
|
+
{input.children ? (
|
|
152
|
+
<Box ml="s">
|
|
153
|
+
<Text emphasis={labelEmphasis}>{input.children}</Text>
|
|
154
|
+
</Box>
|
|
155
|
+
) : null}
|
|
156
|
+
</Box>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/*** Resolves the horizontal selection-control row style. */
|
|
161
|
+
function resolveSelectionRowStyle(opacity: number | undefined): ViewStyle {
|
|
162
|
+
return { alignItems: 'center', flexDirection: 'row', opacity };
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/*** Resolves checkbox indicator dimensions and interaction colors. */
|
|
166
|
+
function resolveCheckboxIndicatorStyle(
|
|
167
|
+
backgroundColor: string,
|
|
168
|
+
borderColor: string,
|
|
169
|
+
size: number,
|
|
170
|
+
): ViewStyle {
|
|
171
|
+
return {
|
|
172
|
+
alignItems: 'center',
|
|
173
|
+
backgroundColor,
|
|
174
|
+
borderColor,
|
|
175
|
+
borderWidth: 1.5,
|
|
176
|
+
height: size,
|
|
177
|
+
justifyContent: 'center',
|
|
178
|
+
width: size,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
interface CheckboxControlProps {
|
|
183
|
+
accessibilityLabel: CheckboxProps['accessibilityLabel'];
|
|
184
|
+
buttonProps: ButtonBaseProps;
|
|
185
|
+
children: CheckboxProps['children'];
|
|
186
|
+
color: NonNullable<CheckboxProps['color']>;
|
|
187
|
+
disabled: boolean;
|
|
188
|
+
invalid: boolean;
|
|
189
|
+
isChecked: boolean;
|
|
190
|
+
readOnly: boolean;
|
|
191
|
+
setChecked: (checked: boolean) => void;
|
|
192
|
+
size: NonNullable<CheckboxProps['size']>;
|
|
193
|
+
testID: CheckboxProps['testID'];
|
|
194
|
+
theme: SurfaceTheme;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
interface CheckboxContentInput {
|
|
198
|
+
children: CheckboxProps['children'];
|
|
199
|
+
color: NonNullable<CheckboxProps['color']>;
|
|
200
|
+
disabled: boolean;
|
|
201
|
+
interactionState: InteractionState;
|
|
202
|
+
invalid: boolean;
|
|
203
|
+
isChecked: boolean;
|
|
204
|
+
readOnly: boolean;
|
|
205
|
+
size: NonNullable<CheckboxProps['size']>;
|
|
206
|
+
theme: SurfaceTheme;
|
|
207
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { expect, test } from 'bun:test';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
|
-
import { isRadioTextContent } from '
|
|
4
|
+
import { isRadioTextContent } from '../../utils/isRadioTextContent';
|
|
5
5
|
|
|
6
6
|
test('classifies only primitive labels for the built-in text presentation', () => {
|
|
7
7
|
expect(isRadioTextContent('Option')).toBe(true);
|
|
@@ -11,10 +11,10 @@ test('classifies only primitive labels for the built-in text presentation', () =
|
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
test('Radio preserves one radio interaction boundary and renders structured content directly', async () => {
|
|
14
|
-
const source = await Bun.file('
|
|
15
|
-
|
|
14
|
+
const source = await Bun.file(new URL('./Radio.tsx', import.meta.url)).text();
|
|
16
15
|
expect(source).toContain('accessibilityRole="radio"');
|
|
17
16
|
expect(source).toContain('accessibilityState={{ checked: isChecked }}');
|
|
18
|
-
expect(source).toContain('
|
|
19
|
-
expect(source).
|
|
17
|
+
expect(source).toContain('isRadioTextContent(input.children)');
|
|
18
|
+
expect(source).toContain('<Text emphasis={labelEmphasis}>{input.children}</Text>');
|
|
19
|
+
expect(source).toMatch(/:\s*\(\s*input\.children\s*\)/);
|
|
20
20
|
});
|