@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,214 @@
|
|
|
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 { RadioProps } from '../../../../../types/radio';
|
|
17
|
+
import { Box } from '../../../../layout/public';
|
|
18
|
+
import { Text } from '../../../../typography/public';
|
|
19
|
+
import { isRadioTextContent } from '../../utils/isRadioTextContent';
|
|
20
|
+
|
|
21
|
+
/*** Renders one accessible radio control with text or structured label content. */
|
|
22
|
+
export function Radio({
|
|
23
|
+
accessibilityLabel,
|
|
24
|
+
checked,
|
|
25
|
+
children,
|
|
26
|
+
color = 'primary',
|
|
27
|
+
defaultChecked = false,
|
|
28
|
+
disabled = false,
|
|
29
|
+
invalid = false,
|
|
30
|
+
onCheckedChange,
|
|
31
|
+
readOnly = false,
|
|
32
|
+
size = 'm',
|
|
33
|
+
testID,
|
|
34
|
+
...buttonProps
|
|
35
|
+
}: RadioProps) {
|
|
36
|
+
const { theme } = useTheme();
|
|
37
|
+
const [isChecked, setChecked] = useControllableState<boolean>({
|
|
38
|
+
value: checked,
|
|
39
|
+
defaultValue: defaultChecked,
|
|
40
|
+
onChange: onCheckedChange,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<RadioControl
|
|
45
|
+
accessibilityLabel={accessibilityLabel}
|
|
46
|
+
buttonProps={buttonProps}
|
|
47
|
+
color={color}
|
|
48
|
+
disabled={disabled}
|
|
49
|
+
invalid={invalid}
|
|
50
|
+
isChecked={isChecked}
|
|
51
|
+
readOnly={readOnly}
|
|
52
|
+
setChecked={setChecked}
|
|
53
|
+
size={size}
|
|
54
|
+
testID={testID}
|
|
55
|
+
theme={theme}
|
|
56
|
+
>
|
|
57
|
+
{children}
|
|
58
|
+
</RadioControl>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/*** Owns the radio interaction boundary around resolved selection content. */
|
|
63
|
+
function RadioControl({
|
|
64
|
+
accessibilityLabel,
|
|
65
|
+
buttonProps,
|
|
66
|
+
children,
|
|
67
|
+
color,
|
|
68
|
+
disabled,
|
|
69
|
+
invalid,
|
|
70
|
+
isChecked,
|
|
71
|
+
readOnly,
|
|
72
|
+
setChecked,
|
|
73
|
+
size,
|
|
74
|
+
testID,
|
|
75
|
+
theme,
|
|
76
|
+
}: RadioControlProps) {
|
|
77
|
+
const nextChecked = resolveSelectionControlNextChecked({
|
|
78
|
+
checked: isChecked,
|
|
79
|
+
disabled,
|
|
80
|
+
kind: 'radio',
|
|
81
|
+
readOnly,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<ButtonBase
|
|
86
|
+
{...buttonProps}
|
|
87
|
+
accessibilityLabel={accessibilityLabel}
|
|
88
|
+
accessibilityRole="radio"
|
|
89
|
+
accessibilityState={{ checked: isChecked }}
|
|
90
|
+
disabled={disabled}
|
|
91
|
+
onPress={nextChecked === null ? undefined : () => setChecked(nextChecked)}
|
|
92
|
+
testID={testID}
|
|
93
|
+
>
|
|
94
|
+
{(interactionState) =>
|
|
95
|
+
renderRadioContent({
|
|
96
|
+
children,
|
|
97
|
+
color,
|
|
98
|
+
disabled,
|
|
99
|
+
interactionState,
|
|
100
|
+
invalid,
|
|
101
|
+
isChecked,
|
|
102
|
+
readOnly,
|
|
103
|
+
size,
|
|
104
|
+
theme,
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
</ButtonBase>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/*** Renders the radio indicator and optional content for one interaction state. */
|
|
112
|
+
function renderRadioContent(input: RadioContentInput) {
|
|
113
|
+
const { interactionState, theme } = input;
|
|
114
|
+
const fieldState = resolveFieldState({
|
|
115
|
+
disabled: input.disabled,
|
|
116
|
+
focused: interactionState.focused,
|
|
117
|
+
invalid: input.invalid,
|
|
118
|
+
readOnly: input.readOnly,
|
|
119
|
+
});
|
|
120
|
+
const colors = resolveSelectionControlColors(theme, {
|
|
121
|
+
checked: input.isChecked,
|
|
122
|
+
fieldState,
|
|
123
|
+
hovered: interactionState.hovered,
|
|
124
|
+
pressed: interactionState.pressed,
|
|
125
|
+
color: input.color,
|
|
126
|
+
});
|
|
127
|
+
const indicatorSize = resolveIndicatorSize(input.size);
|
|
128
|
+
const labelEmphasis = colors.labelColor === theme.semantics.content.muted ? 'muted' : 'default';
|
|
129
|
+
const hasContent =
|
|
130
|
+
input.children !== undefined && input.children !== null && input.children !== false;
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<Box style={resolveSelectionRowStyle(colors.opacity)}>
|
|
134
|
+
<Box
|
|
135
|
+
radius="full"
|
|
136
|
+
style={resolveRadioIndicatorStyle(
|
|
137
|
+
colors.backgroundColor,
|
|
138
|
+
colors.borderColor,
|
|
139
|
+
indicatorSize.radio,
|
|
140
|
+
)}
|
|
141
|
+
>
|
|
142
|
+
{input.isChecked ? (
|
|
143
|
+
<Box
|
|
144
|
+
radius="full"
|
|
145
|
+
style={resolveRadioDotStyle(colors.indicatorColor, indicatorSize.radioDot)}
|
|
146
|
+
/>
|
|
147
|
+
) : null}
|
|
148
|
+
</Box>
|
|
149
|
+
{hasContent ? (
|
|
150
|
+
<Box flex={1} ml="s">
|
|
151
|
+
{isRadioTextContent(input.children) ? (
|
|
152
|
+
<Text emphasis={labelEmphasis}>{input.children}</Text>
|
|
153
|
+
) : (
|
|
154
|
+
input.children
|
|
155
|
+
)}
|
|
156
|
+
</Box>
|
|
157
|
+
) : null}
|
|
158
|
+
</Box>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/*** Resolves the horizontal selection-control row style. */
|
|
163
|
+
function resolveSelectionRowStyle(opacity: number | undefined): ViewStyle {
|
|
164
|
+
return { alignItems: 'center', flexDirection: 'row', opacity };
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/*** Resolves radio indicator dimensions and interaction colors. */
|
|
168
|
+
function resolveRadioIndicatorStyle(
|
|
169
|
+
backgroundColor: string,
|
|
170
|
+
borderColor: string,
|
|
171
|
+
size: number,
|
|
172
|
+
): ViewStyle {
|
|
173
|
+
return {
|
|
174
|
+
alignItems: 'center',
|
|
175
|
+
backgroundColor,
|
|
176
|
+
borderColor,
|
|
177
|
+
borderWidth: 1.5,
|
|
178
|
+
height: size,
|
|
179
|
+
justifyContent: 'center',
|
|
180
|
+
width: size,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/*** Resolves the checked radio dot style. */
|
|
185
|
+
function resolveRadioDotStyle(backgroundColor: string, size: number): ViewStyle {
|
|
186
|
+
return { backgroundColor, height: size, width: size };
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
interface RadioControlProps {
|
|
190
|
+
accessibilityLabel: RadioProps['accessibilityLabel'];
|
|
191
|
+
buttonProps: ButtonBaseProps;
|
|
192
|
+
children: RadioProps['children'];
|
|
193
|
+
color: NonNullable<RadioProps['color']>;
|
|
194
|
+
disabled: boolean;
|
|
195
|
+
invalid: boolean;
|
|
196
|
+
isChecked: boolean;
|
|
197
|
+
readOnly: boolean;
|
|
198
|
+
setChecked: (checked: boolean) => void;
|
|
199
|
+
size: NonNullable<RadioProps['size']>;
|
|
200
|
+
testID: RadioProps['testID'];
|
|
201
|
+
theme: SurfaceTheme;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
interface RadioContentInput {
|
|
205
|
+
children: RadioProps['children'];
|
|
206
|
+
color: NonNullable<RadioProps['color']>;
|
|
207
|
+
disabled: boolean;
|
|
208
|
+
interactionState: InteractionState;
|
|
209
|
+
invalid: boolean;
|
|
210
|
+
isChecked: boolean;
|
|
211
|
+
readOnly: boolean;
|
|
212
|
+
size: NonNullable<RadioProps['size']>;
|
|
213
|
+
theme: SurfaceTheme;
|
|
214
|
+
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
|
|
3
|
-
/***
|
|
4
|
-
* Reports whether Radio content should use the built-in text-label presentation.
|
|
5
|
-
*/
|
|
3
|
+
/*** Reports whether Radio content should use the built-in text-label presentation. */
|
|
6
4
|
export function isRadioTextContent(children: React.ReactNode): children is string | number {
|
|
7
5
|
return typeof children === 'string' || typeof children === 'number';
|
|
8
6
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Platform, TextInput as ReactNativeTextInput, View, type ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { resolveFocusRingStyles } from '../../../../../internal/resolvers';
|
|
5
|
+
import { useTheme } from '../../../../../theme/ThemeContext';
|
|
6
|
+
import type { TextInputProps } from '../../../../../types/text-input';
|
|
7
|
+
import { resolveTextInputPresentation } from '../../utils/resolveTextInputPresentation';
|
|
8
|
+
|
|
9
|
+
/*** Renders a token-aware text input with controlled interaction policy. */
|
|
10
|
+
export function TextInput(props: TextInputProps) {
|
|
11
|
+
const { theme } = useTheme();
|
|
12
|
+
const [focused, setFocused] = React.useState(false);
|
|
13
|
+
const {
|
|
14
|
+
disabled: _disabled,
|
|
15
|
+
interactionPolicy = 'enabled',
|
|
16
|
+
invalid: _invalid,
|
|
17
|
+
leadingAccessory,
|
|
18
|
+
readOnly = false,
|
|
19
|
+
size: _size,
|
|
20
|
+
trailingAccessory,
|
|
21
|
+
...nativeProps
|
|
22
|
+
} = props;
|
|
23
|
+
const presentation = resolveTextInputPresentation(theme, props, focused);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<View
|
|
27
|
+
style={[
|
|
28
|
+
presentation.containerStyle,
|
|
29
|
+
resolveFocusRingStyles(theme.semantics.border.focus, focused, Platform.OS === 'web'),
|
|
30
|
+
]}
|
|
31
|
+
>
|
|
32
|
+
{renderAccessory(leadingAccessory, presentation.accessorySpacing, 'leading')}
|
|
33
|
+
<ReactNativeTextInput
|
|
34
|
+
{...nativeProps}
|
|
35
|
+
editable={presentation.editable}
|
|
36
|
+
numberOfLines={presentation.numberOfLines}
|
|
37
|
+
onBlur={(event) => {
|
|
38
|
+
setFocused(false);
|
|
39
|
+
nativeProps.onBlur?.(event);
|
|
40
|
+
}}
|
|
41
|
+
onChangeText={(nextValue) => {
|
|
42
|
+
if (interactionPolicy !== 'passive') {
|
|
43
|
+
nativeProps.onChangeText?.(nextValue);
|
|
44
|
+
}
|
|
45
|
+
}}
|
|
46
|
+
onFocus={(event) => {
|
|
47
|
+
setFocused(true);
|
|
48
|
+
nativeProps.onFocus?.(event);
|
|
49
|
+
}}
|
|
50
|
+
placeholderTextColor={presentation.placeholderColor}
|
|
51
|
+
readOnly={readOnly}
|
|
52
|
+
style={[presentation.inputStyle, nativeProps.style]}
|
|
53
|
+
/>
|
|
54
|
+
{renderAccessory(trailingAccessory, presentation.accessorySpacing, 'trailing')}
|
|
55
|
+
</View>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/*** Renders one optional TextInput accessory with directional spacing. */
|
|
60
|
+
function renderAccessory(
|
|
61
|
+
accessory: React.ReactNode,
|
|
62
|
+
spacing: number,
|
|
63
|
+
position: 'leading' | 'trailing',
|
|
64
|
+
) {
|
|
65
|
+
if (!accessory) return null;
|
|
66
|
+
return <View style={resolveAccessoryStyle(spacing, position)}>{accessory}</View>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/*** Resolves spacing around a leading or trailing TextInput accessory. */
|
|
70
|
+
function resolveAccessoryStyle(spacing: number, position: 'leading' | 'trailing'): ViewStyle {
|
|
71
|
+
return position === 'leading' ? { marginRight: spacing } : { marginLeft: spacing };
|
|
72
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { TextStyle, ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
resolveControlSize,
|
|
5
|
+
resolveFieldState,
|
|
6
|
+
resolveInputColors,
|
|
7
|
+
resolveTextStyles,
|
|
8
|
+
} from '../../../../internal/resolvers';
|
|
9
|
+
import type { SurfaceTheme } from '../../../../theme/types';
|
|
10
|
+
import type { TextInputProps } from '../../../../types/text-input';
|
|
11
|
+
|
|
12
|
+
/*** Resolves layout, colors, and editability for one TextInput state. */
|
|
13
|
+
export function resolveTextInputPresentation(
|
|
14
|
+
theme: SurfaceTheme,
|
|
15
|
+
props: TextInputProps,
|
|
16
|
+
focused: boolean,
|
|
17
|
+
): TextInputPresentation {
|
|
18
|
+
const controlSize = resolveControlSize(theme, props.size ?? 'm');
|
|
19
|
+
const disabled = props.disabled ?? false;
|
|
20
|
+
const readOnly = props.readOnly ?? false;
|
|
21
|
+
const fieldState = resolveFieldState({
|
|
22
|
+
disabled,
|
|
23
|
+
focused,
|
|
24
|
+
invalid: props.invalid ?? false,
|
|
25
|
+
readOnly,
|
|
26
|
+
});
|
|
27
|
+
const colors = resolveInputColors(theme, fieldState);
|
|
28
|
+
const textStyle = resolveTextStyles(theme, { variant: controlSize.textVariant });
|
|
29
|
+
const heights = resolveTextInputHeights(
|
|
30
|
+
controlSize,
|
|
31
|
+
props.multiline,
|
|
32
|
+
props.numberOfLines,
|
|
33
|
+
textStyle.lineHeight,
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
accessorySpacing: theme.spacing.s,
|
|
38
|
+
containerStyle: {
|
|
39
|
+
alignItems: props.multiline ? 'flex-start' : 'center',
|
|
40
|
+
backgroundColor: colors.backgroundColor,
|
|
41
|
+
borderColor: colors.borderColor,
|
|
42
|
+
borderRadius: controlSize.borderRadius,
|
|
43
|
+
borderWidth: 1,
|
|
44
|
+
flexDirection: 'row',
|
|
45
|
+
minHeight: heights.container,
|
|
46
|
+
opacity: colors.opacity,
|
|
47
|
+
paddingHorizontal: controlSize.paddingHorizontal,
|
|
48
|
+
paddingVertical: controlSize.paddingVertical,
|
|
49
|
+
},
|
|
50
|
+
editable: props.interactionPolicy === 'passive' ? false : !disabled && !readOnly,
|
|
51
|
+
inputStyle: {
|
|
52
|
+
color: colors.contentColor,
|
|
53
|
+
flex: 1,
|
|
54
|
+
minHeight: heights.input,
|
|
55
|
+
padding: 0,
|
|
56
|
+
textAlignVertical: props.multiline ? 'top' : 'center',
|
|
57
|
+
},
|
|
58
|
+
numberOfLines: props.multiline ? props.numberOfLines : 1,
|
|
59
|
+
placeholderColor: colors.placeholderColor,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/*** Resolves input and container heights from control typography and multiline state. */
|
|
64
|
+
function resolveTextInputHeights(
|
|
65
|
+
controlSize: ReturnType<typeof resolveControlSize>,
|
|
66
|
+
multiline: boolean | undefined,
|
|
67
|
+
numberOfLines: number | undefined,
|
|
68
|
+
lineHeight: TextStyle['lineHeight'],
|
|
69
|
+
) {
|
|
70
|
+
const resolvedLineHeight =
|
|
71
|
+
typeof lineHeight === 'number'
|
|
72
|
+
? lineHeight
|
|
73
|
+
: controlSize.minHeight - controlSize.paddingVertical * 2;
|
|
74
|
+
const lineCount = Math.max(numberOfLines ?? 1, 1);
|
|
75
|
+
const input = multiline
|
|
76
|
+
? resolvedLineHeight * lineCount
|
|
77
|
+
: controlSize.minHeight - controlSize.paddingVertical * 2;
|
|
78
|
+
return {
|
|
79
|
+
input,
|
|
80
|
+
container: multiline ? input + controlSize.paddingVertical * 2 : controlSize.minHeight,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface TextInputPresentation {
|
|
85
|
+
accessorySpacing: number;
|
|
86
|
+
containerStyle: ViewStyle;
|
|
87
|
+
editable: boolean;
|
|
88
|
+
inputStyle: TextStyle;
|
|
89
|
+
numberOfLines: number | undefined;
|
|
90
|
+
placeholderColor: string;
|
|
91
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { resolveToken } from '../../../../theme/resolveToken';
|
|
2
|
+
import { useTheme } from '../../../../theme/ThemeContext';
|
|
3
|
+
import type { IconProps } from '../../../../types/icon';
|
|
4
|
+
import { PortableIcon } from './PortableIcon';
|
|
5
|
+
|
|
6
|
+
/*** Renders a theme-aware font or SVG icon through the portable icon adapter. */
|
|
7
|
+
export function Icon(props: IconProps) {
|
|
8
|
+
const { theme } = useTheme();
|
|
9
|
+
const size = props.size ?? 'm';
|
|
10
|
+
const color = props.color ?? 'text';
|
|
11
|
+
const resolvedSize = typeof size === 'number' ? size : resolveToken(theme.spacing, size);
|
|
12
|
+
const resolvedColor = resolveToken(theme.colors, color);
|
|
13
|
+
return <PortableIcon {...props} color={resolvedColor} size={resolvedSize} />;
|
|
14
|
+
}
|
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from '@react-native-vector-icons/
|
|
5
|
-
import {
|
|
6
|
-
FontAwesome5,
|
|
7
|
-
type FontAwesome5BrandIconName,
|
|
8
|
-
type FontAwesome5RegularIconName,
|
|
9
|
-
type FontAwesome5SolidIconName,
|
|
10
|
-
} from '@react-native-vector-icons/fontawesome5/static';
|
|
11
|
-
import {
|
|
12
|
-
FontAwesome6,
|
|
13
|
-
type FontAwesome6BrandIconName,
|
|
14
|
-
type FontAwesome6RegularIconName,
|
|
15
|
-
type FontAwesome6SolidIconName,
|
|
16
|
-
} from '@react-native-vector-icons/fontawesome6/static';
|
|
17
|
-
import { Ionicons, type IoniconsIconName } from '@react-native-vector-icons/ionicons/static';
|
|
18
|
-
import {
|
|
19
|
-
MaterialDesignIcons,
|
|
20
|
-
type MaterialDesignIconsIconName,
|
|
21
|
-
} from '@react-native-vector-icons/material-design-icons/static';
|
|
1
|
+
import { FontAwesome } from '@react-native-vector-icons/fontawesome/static';
|
|
2
|
+
import { FontAwesome5 } from '@react-native-vector-icons/fontawesome5/static';
|
|
3
|
+
import { FontAwesome6 } from '@react-native-vector-icons/fontawesome6/static';
|
|
4
|
+
import { Ionicons } from '@react-native-vector-icons/ionicons/static';
|
|
5
|
+
import { MaterialDesignIcons } from '@react-native-vector-icons/material-design-icons/static';
|
|
22
6
|
import React from 'react';
|
|
23
7
|
import {
|
|
24
8
|
Image,
|
|
@@ -30,39 +14,38 @@ import {
|
|
|
30
14
|
} from 'react-native';
|
|
31
15
|
import { SvgUri } from 'react-native-svg';
|
|
32
16
|
|
|
33
|
-
import type {
|
|
17
|
+
import type { FontIconSource, IconSource, SvgIconSource } from '../../../../types/icon';
|
|
18
|
+
import type { SurfaceImageSource } from '../../../../types/image';
|
|
34
19
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
'
|
|
38
|
-
'FontAwesome5',
|
|
39
|
-
'FontAwesome6',
|
|
40
|
-
'MaterialDesignIcons',
|
|
41
|
-
] as const;
|
|
42
|
-
|
|
43
|
-
export type IconProvider = (typeof SUPPORTED_ICON_PROVIDERS)[number];
|
|
44
|
-
export type IconVariant = 'regular' | 'solid' | 'brand';
|
|
20
|
+
/*** Renders a resolved portable icon using the configured font or SVG runtime. */
|
|
21
|
+
export function PortableIcon(props: PortableIconProps) {
|
|
22
|
+
if ('source' in props) return renderSvgIcon(props);
|
|
45
23
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
| { name: FontAwesome6SolidIconName; provider: 'FontAwesome6'; variant: 'solid' }
|
|
54
|
-
| { name: FontAwesome6BrandIconName; provider: 'FontAwesome6'; variant: 'brand' }
|
|
55
|
-
| { name: MaterialDesignIconsIconName; provider: 'MaterialDesignIcons'; variant?: never };
|
|
24
|
+
const { provider } = props;
|
|
25
|
+
const sharedProps = {
|
|
26
|
+
color: props.color,
|
|
27
|
+
size: props.size,
|
|
28
|
+
style: props.style,
|
|
29
|
+
testID: props.testID,
|
|
30
|
+
};
|
|
56
31
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
32
|
+
switch (provider) {
|
|
33
|
+
case undefined:
|
|
34
|
+
case 'Ionicons':
|
|
35
|
+
return <Ionicons {...sharedProps} name={props.name} />;
|
|
36
|
+
case 'FontAwesome':
|
|
37
|
+
return <FontAwesome {...sharedProps} name={props.name} />;
|
|
38
|
+
case 'FontAwesome5':
|
|
39
|
+
return renderFontAwesome5(props, sharedProps);
|
|
40
|
+
case 'FontAwesome6':
|
|
41
|
+
return renderFontAwesome6(props, sharedProps);
|
|
42
|
+
case 'MaterialDesignIcons':
|
|
43
|
+
return <MaterialDesignIcons {...sharedProps} name={props.name} />;
|
|
44
|
+
default:
|
|
45
|
+
return assertNever(provider, 'provider');
|
|
46
|
+
}
|
|
62
47
|
}
|
|
63
48
|
|
|
64
|
-
export type IconSource = FontIconSource | SvgIconSource;
|
|
65
|
-
|
|
66
49
|
interface PortableIconPresentationProps {
|
|
67
50
|
color: string;
|
|
68
51
|
size: number;
|
|
@@ -70,37 +53,25 @@ interface PortableIconPresentationProps {
|
|
|
70
53
|
}
|
|
71
54
|
|
|
72
55
|
type FontPortableIconProps = FontIconSource &
|
|
73
|
-
PortableIconPresentationProps & {
|
|
74
|
-
style?: StyleProp<TextStyle>;
|
|
75
|
-
};
|
|
76
|
-
|
|
56
|
+
PortableIconPresentationProps & { style?: StyleProp<TextStyle> };
|
|
77
57
|
type SvgPortableIconProps = SvgIconSource &
|
|
78
|
-
PortableIconPresentationProps & {
|
|
79
|
-
style?: StyleProp<ViewStyle>;
|
|
80
|
-
};
|
|
81
|
-
|
|
58
|
+
PortableIconPresentationProps & { style?: StyleProp<ViewStyle> };
|
|
82
59
|
type PortableIconProps = FontPortableIconProps | SvgPortableIconProps;
|
|
60
|
+
type SharedIconProps = PortableIconPresentationProps & { style?: StyleProp<TextStyle> };
|
|
83
61
|
|
|
84
|
-
|
|
85
|
-
style?: StyleProp<TextStyle>;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const styles = StyleSheet.create({
|
|
89
|
-
bundledSvgImage: { height: '100%', width: '100%' },
|
|
90
|
-
});
|
|
62
|
+
const styles = StyleSheet.create({ bundledSvgImage: { height: '100%', width: '100%' } });
|
|
91
63
|
|
|
92
|
-
/***
|
|
64
|
+
/*** Resolves an SVG URI directly or through React Native's bundled-asset API. */
|
|
93
65
|
function resolveSvgIconUri(source: SurfaceImageSource): string | null {
|
|
94
66
|
if (typeof source === 'string') return source;
|
|
95
67
|
if (!Array.isArray(source) && typeof source === 'object' && typeof source.uri === 'string') {
|
|
96
68
|
return source.uri;
|
|
97
69
|
}
|
|
98
70
|
if (typeof Image.resolveAssetSource !== 'function') return null;
|
|
99
|
-
|
|
100
71
|
return Image.resolveAssetSource(source).uri;
|
|
101
72
|
}
|
|
102
73
|
|
|
103
|
-
/***
|
|
74
|
+
/*** Renders URI-backed SVGs and bundled SVG image assets. */
|
|
104
75
|
function renderSvgIcon(props: SvgPortableIconProps) {
|
|
105
76
|
const uri = resolveSvgIconUri(props.source);
|
|
106
77
|
if (uri) {
|
|
@@ -124,10 +95,12 @@ function renderSvgIcon(props: SvgPortableIconProps) {
|
|
|
124
95
|
);
|
|
125
96
|
}
|
|
126
97
|
|
|
98
|
+
/*** Rejects unsupported icon configuration at runtime. */
|
|
127
99
|
function assertNever(value: never, configuration: string): never {
|
|
128
100
|
throw new Error(`Unsupported icon ${configuration}: ${String(value)}`);
|
|
129
101
|
}
|
|
130
102
|
|
|
103
|
+
/*** Renders one FontAwesome5 variant. */
|
|
131
104
|
function renderFontAwesome5(
|
|
132
105
|
props: Extract<IconSource, { provider: 'FontAwesome5' }>,
|
|
133
106
|
sharedProps: SharedIconProps,
|
|
@@ -146,6 +119,7 @@ function renderFontAwesome5(
|
|
|
146
119
|
}
|
|
147
120
|
}
|
|
148
121
|
|
|
122
|
+
/*** Renders one FontAwesome6 variant. */
|
|
149
123
|
function renderFontAwesome6(
|
|
150
124
|
props: Extract<IconSource, { provider: 'FontAwesome6' }>,
|
|
151
125
|
sharedProps: SharedIconProps,
|
|
@@ -163,33 +137,3 @@ function renderFontAwesome6(
|
|
|
163
137
|
return assertNever(variant, 'FontAwesome6 variant');
|
|
164
138
|
}
|
|
165
139
|
}
|
|
166
|
-
|
|
167
|
-
export function PortableIcon(props: PortableIconProps) {
|
|
168
|
-
if ('source' in props) {
|
|
169
|
-
return renderSvgIcon(props);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const { provider } = props;
|
|
173
|
-
const sharedProps = {
|
|
174
|
-
color: props.color,
|
|
175
|
-
size: props.size,
|
|
176
|
-
style: props.style,
|
|
177
|
-
testID: props.testID,
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
switch (provider) {
|
|
181
|
-
case undefined:
|
|
182
|
-
case 'Ionicons':
|
|
183
|
-
return <Ionicons {...sharedProps} name={props.name} />;
|
|
184
|
-
case 'FontAwesome':
|
|
185
|
-
return <FontAwesome {...sharedProps} name={props.name} />;
|
|
186
|
-
case 'FontAwesome5':
|
|
187
|
-
return renderFontAwesome5(props, sharedProps);
|
|
188
|
-
case 'FontAwesome6':
|
|
189
|
-
return renderFontAwesome6(props, sharedProps);
|
|
190
|
-
case 'MaterialDesignIcons':
|
|
191
|
-
return <MaterialDesignIcons {...sharedProps} name={props.name} />;
|
|
192
|
-
default:
|
|
193
|
-
return assertNever(provider, 'provider');
|
|
194
|
-
}
|
|
195
|
-
}
|
|
@@ -34,13 +34,13 @@ await mock.module('react-native-svg', () => ({
|
|
|
34
34
|
}),
|
|
35
35
|
}));
|
|
36
36
|
|
|
37
|
+
const { SUPPORTED_ICON_PROVIDERS } = await import('../../constants');
|
|
37
38
|
const { Icon } = await import('./Icon');
|
|
38
|
-
const { PortableIcon
|
|
39
|
+
const { PortableIcon } = await import('./PortableIcon');
|
|
39
40
|
|
|
40
41
|
describe('portable icon rendering', () => {
|
|
41
42
|
test('renders Ionicons through the public Icon API', () => {
|
|
42
43
|
const markup = renderToStaticMarkup(<Icon color="#123456" name="home-outline" size={18} />);
|
|
43
|
-
|
|
44
44
|
expect(markup).toContain('font-family:Ionicons');
|
|
45
45
|
});
|
|
46
46
|
|
|
@@ -48,7 +48,6 @@ describe('portable icon rendering', () => {
|
|
|
48
48
|
const markup = renderToStaticMarkup(
|
|
49
49
|
<Icon color="#123456" name="github" provider="FontAwesome" size={18} />,
|
|
50
50
|
);
|
|
51
|
-
|
|
52
51
|
expect(markup).toContain('font-family:FontAwesome');
|
|
53
52
|
});
|
|
54
53
|
|
|
@@ -56,7 +55,6 @@ describe('portable icon rendering', () => {
|
|
|
56
55
|
const markup = renderToStaticMarkup(
|
|
57
56
|
<Icon color="#123456" name="microsoft" provider="FontAwesome5" size={18} variant="brand" />,
|
|
58
57
|
);
|
|
59
|
-
|
|
60
58
|
expect(markup).toContain('font-family:FontAwesome5Brands-Regular');
|
|
61
59
|
});
|
|
62
60
|
|
|
@@ -64,7 +62,6 @@ describe('portable icon rendering', () => {
|
|
|
64
62
|
const markup = renderToStaticMarkup(
|
|
65
63
|
<Icon color="#123456" name="video" provider="FontAwesome5" size={18} variant="solid" />,
|
|
66
64
|
);
|
|
67
|
-
|
|
68
65
|
expect(markup).toContain('font-family:FontAwesome5Free-Solid');
|
|
69
66
|
});
|
|
70
67
|
|
|
@@ -72,7 +69,6 @@ describe('portable icon rendering', () => {
|
|
|
72
69
|
const markup = renderToStaticMarkup(
|
|
73
70
|
<Icon color="#123456" name="x-twitter" provider="FontAwesome6" size={18} variant="brand" />,
|
|
74
71
|
);
|
|
75
|
-
|
|
76
72
|
expect(markup).toContain('font-family:FontAwesome6Brands-Regular');
|
|
77
73
|
});
|
|
78
74
|
|
|
@@ -80,7 +76,6 @@ describe('portable icon rendering', () => {
|
|
|
80
76
|
const markup = renderToStaticMarkup(
|
|
81
77
|
<Icon color="#123456" name="bookshelf" provider="MaterialDesignIcons" size={18} />,
|
|
82
78
|
);
|
|
83
|
-
|
|
84
79
|
expect(markup).toContain('font-family:MaterialDesignIcons');
|
|
85
80
|
});
|
|
86
81
|
|
|
@@ -88,7 +83,6 @@ describe('portable icon rendering', () => {
|
|
|
88
83
|
const markup = renderToStaticMarkup(
|
|
89
84
|
<Icon color="#123456" size={18} source="https://example.com/icons/home.svg" />,
|
|
90
85
|
);
|
|
91
|
-
|
|
92
86
|
expect(markup).toContain('data-uri="https://example.com/icons/home.svg"');
|
|
93
87
|
expect(markup).toContain('data-color="#123456"');
|
|
94
88
|
expect(markup).toContain('width="18"');
|
|
@@ -101,7 +95,6 @@ describe('portable icon web assets', () => {
|
|
|
101
95
|
const markup = renderToStaticMarkup(
|
|
102
96
|
<Icon color="#123456" size={18} source={42} testID="bundled-svg" />,
|
|
103
97
|
);
|
|
104
|
-
|
|
105
98
|
expect(markup).toContain('data-image-source="42"');
|
|
106
99
|
expect(markup).toContain('data-testid="bundled-svg"');
|
|
107
100
|
expect(markup).toContain('data-tint-color="#123456"');
|
|
@@ -162,7 +155,10 @@ describe('portable icon runtime rejection', () => {
|
|
|
162
155
|
|
|
163
156
|
describe('portable icon dependency boundary', () => {
|
|
164
157
|
test('has no Expo icon dependency or resolver path', () => {
|
|
165
|
-
const packageSource = readFileSync(
|
|
158
|
+
const packageSource = readFileSync(
|
|
159
|
+
new URL('../../../../../package.json', import.meta.url),
|
|
160
|
+
'utf8',
|
|
161
|
+
);
|
|
166
162
|
const iconSource = readFileSync(new URL('./PortableIcon.tsx', import.meta.url), 'utf8');
|
|
167
163
|
|
|
168
164
|
expect(packageSource).not.toContain('@expo/vector-icons');
|