@ankhorage/surface 4.2.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/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/accordion/adapters/inbound/Accordion.d.ts +5 -0
- package/dist/features/accordion/adapters/inbound/Accordion.d.ts.map +1 -0
- package/dist/features/accordion/adapters/inbound/Accordion.js +46 -0
- package/dist/features/accordion/adapters/inbound/Accordion.js.map +1 -0
- package/dist/features/accordion/adapters/inbound/AccordionContent.d.ts +5 -0
- package/dist/features/accordion/adapters/inbound/AccordionContent.d.ts.map +1 -0
- package/dist/features/accordion/adapters/inbound/AccordionContent.js +16 -0
- package/dist/features/accordion/adapters/inbound/AccordionContent.js.map +1 -0
- package/dist/features/accordion/adapters/inbound/AccordionContext.d.ts +4 -0
- package/dist/features/accordion/adapters/inbound/AccordionContext.d.ts.map +1 -0
- package/dist/features/accordion/adapters/inbound/AccordionContext.js +3 -0
- package/dist/features/accordion/adapters/inbound/AccordionContext.js.map +1 -0
- package/dist/features/accordion/adapters/inbound/AccordionItem.d.ts +5 -0
- package/dist/features/accordion/adapters/inbound/AccordionItem.d.ts.map +1 -0
- package/dist/features/accordion/adapters/inbound/AccordionItem.js +28 -0
- package/dist/features/accordion/adapters/inbound/AccordionItem.js.map +1 -0
- package/dist/features/accordion/adapters/inbound/AccordionItemContext.d.ts +4 -0
- package/dist/features/accordion/adapters/inbound/AccordionItemContext.d.ts.map +1 -0
- package/dist/features/accordion/adapters/inbound/AccordionItemContext.js +3 -0
- package/dist/features/accordion/adapters/inbound/AccordionItemContext.js.map +1 -0
- package/dist/features/accordion/adapters/inbound/AccordionTrigger.d.ts +5 -0
- package/dist/features/accordion/adapters/inbound/AccordionTrigger.d.ts.map +1 -0
- package/dist/features/accordion/adapters/inbound/AccordionTrigger.js +17 -0
- package/dist/features/accordion/adapters/inbound/AccordionTrigger.js.map +1 -0
- package/dist/features/accordion/public.d.ts +6 -0
- package/dist/features/accordion/public.d.ts.map +1 -0
- package/dist/features/accordion/public.js +5 -0
- package/dist/features/accordion/public.js.map +1 -0
- package/dist/features/accordion/utils/resolveAccordionToggle.d.ts +11 -0
- package/dist/features/accordion/utils/resolveAccordionToggle.d.ts.map +1 -0
- package/dist/features/accordion/utils/resolveAccordionToggle.js +13 -0
- package/dist/features/accordion/utils/resolveAccordionToggle.js.map +1 -0
- 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/{layout → features/keyboard-avoiding-view/adapters/inbound}/KeyboardAvoidingView.js +2 -2
- 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 +26 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -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 -14
- package/dist/layout/index.d.ts.map +1 -1
- package/dist/layout/index.js +0 -7
- 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/accordion.d.ts +54 -0
- package/dist/types/accordion.d.ts.map +1 -0
- package/dist/types/accordion.js +2 -0
- package/dist/types/accordion.js.map +1 -0
- 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/accordion/adapters/inbound/Accordion.tsx +83 -0
- package/src/features/accordion/adapters/inbound/AccordionContent.tsx +30 -0
- package/src/features/accordion/adapters/inbound/AccordionContext.ts +5 -0
- package/src/features/accordion/adapters/inbound/AccordionItem.tsx +42 -0
- package/src/features/accordion/adapters/inbound/AccordionItemContext.ts +5 -0
- package/src/features/accordion/adapters/inbound/AccordionTrigger.tsx +34 -0
- package/src/features/accordion/public.ts +13 -0
- package/src/features/accordion/utils/resolveAccordionToggle.test.ts +57 -0
- package/src/features/accordion/utils/resolveAccordionToggle.ts +28 -0
- 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 +58 -28
- package/src/index.ts +52 -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 -17
- package/src/primitives/button-base/ButtonBase.tsx +1 -1
- package/src/primitives/button-base/types.ts +1 -1
- package/src/types/accordion.ts +69 -0
- 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 +2 -3
- 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/KeyboardAvoidingView.d.ts +0 -7
- package/dist/layout/KeyboardAvoidingView.d.ts.map +0 -1
- package/dist/layout/KeyboardAvoidingView.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/KeyboardAvoidingView.tsx +0 -16
- 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,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Image as ReactNativeImage } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { useTheme } from '../../../../theme/ThemeContext';
|
|
5
|
+
import type { ImageProps } from '../../../../types/image';
|
|
6
|
+
import { getSourceKey } from '../../utils/getSourceKey';
|
|
7
|
+
import { normalizeSource } from '../../utils/normalizeSource';
|
|
8
|
+
import { resolveAccessibilityLabel } from '../../utils/resolveAccessibilityLabel';
|
|
9
|
+
import { resolveAlt } from '../../utils/resolveAlt';
|
|
10
|
+
import { resolveImageStyle } from '../../utils/resolveImageStyle';
|
|
11
|
+
import { resolveRenderedSource } from '../../utils/resolveRenderedSource';
|
|
12
|
+
import { resolveResizeMode } from '../../utils/resolveResizeMode';
|
|
13
|
+
|
|
14
|
+
/*** Renders a token-aware accessible image with optional fallback source. */
|
|
15
|
+
export function Image({
|
|
16
|
+
source,
|
|
17
|
+
fallbackSource,
|
|
18
|
+
alt,
|
|
19
|
+
accessibilityLabel,
|
|
20
|
+
width,
|
|
21
|
+
height,
|
|
22
|
+
aspectRatio,
|
|
23
|
+
fit,
|
|
24
|
+
resizeMode,
|
|
25
|
+
radius,
|
|
26
|
+
style,
|
|
27
|
+
testID,
|
|
28
|
+
onError,
|
|
29
|
+
}: ImageProps) {
|
|
30
|
+
const { theme } = useTheme();
|
|
31
|
+
const primaryKey = React.useMemo(() => getSourceKey(source), [source]);
|
|
32
|
+
const [failedPrimaryKey, setFailedPrimaryKey] = React.useState<string | null>(null);
|
|
33
|
+
const showFallback = primaryKey !== null && failedPrimaryKey === primaryKey;
|
|
34
|
+
const normalizedPrimary = normalizeSource(source);
|
|
35
|
+
const normalizedFallback = normalizeSource(fallbackSource);
|
|
36
|
+
const resolvedSource = resolveRenderedSource(normalizedPrimary, normalizedFallback, showFallback);
|
|
37
|
+
|
|
38
|
+
if (!resolvedSource) return null;
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<ReactNativeImage
|
|
42
|
+
accessibilityLabel={resolveAccessibilityLabel(alt, accessibilityLabel)}
|
|
43
|
+
accessibilityRole="image"
|
|
44
|
+
alt={resolveAlt(alt, accessibilityLabel)}
|
|
45
|
+
onError={(event) => {
|
|
46
|
+
onError?.(event);
|
|
47
|
+
if (!showFallback && normalizedFallback) setFailedPrimaryKey(primaryKey);
|
|
48
|
+
}}
|
|
49
|
+
resizeMode={resolveResizeMode(fit, resizeMode)}
|
|
50
|
+
source={resolvedSource}
|
|
51
|
+
style={[resolveImageStyle(theme, { width, height, aspectRatio, radius }), style]}
|
|
52
|
+
testID={testID}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ImageSourcePropType } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import type { SurfaceImageSource } from '../../../types/image';
|
|
4
|
+
|
|
5
|
+
/*** Derives a stable runtime key for one Surface image source. */
|
|
6
|
+
export function getSourceKey(source: SurfaceImageSource | null | undefined): string | null {
|
|
7
|
+
if (source === null || source === undefined) return null;
|
|
8
|
+
if (typeof source === 'string') return `uri:${source}`;
|
|
9
|
+
if (typeof source === 'number') return `asset:${source}`;
|
|
10
|
+
if (Array.isArray(source)) {
|
|
11
|
+
const parts = source
|
|
12
|
+
.map((item) => item.uri)
|
|
13
|
+
.filter((value): value is string => typeof value === 'string');
|
|
14
|
+
return `uri-set:${parts.join('|')}`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const uri = getUriFromSource(source);
|
|
18
|
+
if (uri) return `uri:${uri}`;
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
return `src:${JSON.stringify(source)}`;
|
|
22
|
+
} catch {
|
|
23
|
+
return 'src:unknown';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/*** Reads the first URI represented by a React Native image source. */
|
|
28
|
+
function getUriFromSource(source: ImageSourcePropType): string | undefined {
|
|
29
|
+
if (Array.isArray(source)) return source[0]?.uri;
|
|
30
|
+
if (typeof source === 'number') return undefined;
|
|
31
|
+
return source.uri;
|
|
32
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ImageSourcePropType } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import type { SurfaceImageSource } from '../../../types/image';
|
|
4
|
+
|
|
5
|
+
/*** Normalizes a Surface image source into React Native's source shape. */
|
|
6
|
+
export function normalizeSource(
|
|
7
|
+
source: SurfaceImageSource | null | undefined,
|
|
8
|
+
): ImageSourcePropType | undefined {
|
|
9
|
+
if (source === null || source === undefined) return undefined;
|
|
10
|
+
if (typeof source === 'string') return { uri: source };
|
|
11
|
+
return source;
|
|
12
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ImageProps } from '../../../types/image';
|
|
2
|
+
|
|
3
|
+
/*** Resolves the accessible image label from explicit label or alt text. */
|
|
4
|
+
export function resolveAccessibilityLabel(
|
|
5
|
+
alt: ImageProps['alt'],
|
|
6
|
+
accessibilityLabel: ImageProps['accessibilityLabel'],
|
|
7
|
+
): string | undefined {
|
|
8
|
+
return accessibilityLabel ?? alt;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ImageProps } from '../../../types/image';
|
|
2
|
+
|
|
3
|
+
/*** Resolves web alt text from alt or the accessible label. */
|
|
4
|
+
export function resolveAlt(
|
|
5
|
+
alt: ImageProps['alt'],
|
|
6
|
+
accessibilityLabel: ImageProps['accessibilityLabel'],
|
|
7
|
+
): string | undefined {
|
|
8
|
+
return alt ?? accessibilityLabel;
|
|
9
|
+
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { describe, expect, it } from 'bun:test';
|
|
2
2
|
|
|
3
|
-
import { createTheme } from '
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
resolveResizeMode,
|
|
10
|
-
} from './resolveImageProps';
|
|
3
|
+
import { createTheme } from '../../../theme/createTheme';
|
|
4
|
+
import { getSourceKey } from './getSourceKey';
|
|
5
|
+
import { normalizeSource } from './normalizeSource';
|
|
6
|
+
import { resolveImageStyle } from './resolveImageStyle';
|
|
7
|
+
import { resolveRenderedSource } from './resolveRenderedSource';
|
|
8
|
+
import { resolveResizeMode } from './resolveResizeMode';
|
|
11
9
|
|
|
12
10
|
describe('normalizeSource', () => {
|
|
13
11
|
it('normalizes string sources into uri objects', () => {
|
|
@@ -15,13 +13,11 @@ describe('normalizeSource', () => {
|
|
|
15
13
|
uri: 'https://example.com/image.png',
|
|
16
14
|
});
|
|
17
15
|
});
|
|
18
|
-
|
|
19
16
|
it('passes through react-native image sources', () => {
|
|
20
17
|
expect(normalizeSource({ uri: 'https://example.com/image.png' })).toEqual({
|
|
21
18
|
uri: 'https://example.com/image.png',
|
|
22
19
|
});
|
|
23
20
|
});
|
|
24
|
-
|
|
25
21
|
it('returns undefined for nullish sources', () => {
|
|
26
22
|
expect(normalizeSource(null)).toBeUndefined();
|
|
27
23
|
expect(normalizeSource(undefined)).toBeUndefined();
|
|
@@ -32,7 +28,6 @@ describe('resolveResizeMode', () => {
|
|
|
32
28
|
it('prefers fit over resizeMode', () => {
|
|
33
29
|
expect(resolveResizeMode('contain', 'cover')).toBe('contain');
|
|
34
30
|
});
|
|
35
|
-
|
|
36
31
|
it('defaults to cover when both are absent', () => {
|
|
37
32
|
expect(resolveResizeMode(undefined, undefined)).toBe('cover');
|
|
38
33
|
});
|
|
@@ -40,8 +35,8 @@ describe('resolveResizeMode', () => {
|
|
|
40
35
|
|
|
41
36
|
describe('resolveRenderedSource', () => {
|
|
42
37
|
it('renders fallback when the primary source is absent', () => {
|
|
43
|
-
const
|
|
44
|
-
expect(resolveRenderedSource(undefined,
|
|
38
|
+
const fallback = normalizeSource('https://example.com/fallback.png');
|
|
39
|
+
expect(resolveRenderedSource(undefined, fallback, false)).toEqual(fallback);
|
|
45
40
|
});
|
|
46
41
|
});
|
|
47
42
|
|
|
@@ -52,29 +47,22 @@ describe('getSourceKey', () => {
|
|
|
52
47
|
'uri:https://example.com/image.png',
|
|
53
48
|
);
|
|
54
49
|
});
|
|
55
|
-
|
|
56
|
-
it('derives stable keys for asset sources', () => {
|
|
57
|
-
expect(getSourceKey(12)).toBe('asset:12');
|
|
58
|
-
});
|
|
59
|
-
|
|
50
|
+
it('derives stable keys for asset sources', () => expect(getSourceKey(12)).toBe('asset:12'));
|
|
60
51
|
it('derives stable keys for uri sets', () => {
|
|
61
52
|
expect(getSourceKey([{ uri: 'a' }, { uri: 'b' }])).toBe('uri-set:a|b');
|
|
62
53
|
});
|
|
63
54
|
});
|
|
64
55
|
|
|
65
56
|
describe('resolveImageStyle', () => {
|
|
66
|
-
it('resolves spacing tokens for
|
|
57
|
+
it('resolves spacing tokens for dimensions and preserves raw strings', () => {
|
|
67
58
|
const theme = createTheme();
|
|
68
59
|
const style = resolveImageStyle(theme, { width: 'm', height: '100%' });
|
|
69
|
-
|
|
70
60
|
expect(style.width).toBe(theme.spacing.m);
|
|
71
61
|
expect(style.height).toBe('100%');
|
|
72
62
|
});
|
|
73
|
-
|
|
74
63
|
it('resolves radius tokens for borderRadius', () => {
|
|
75
64
|
const theme = createTheme();
|
|
76
65
|
const style = resolveImageStyle(theme, { radius: 'full' });
|
|
77
|
-
|
|
78
66
|
expect(style.borderRadius).toBe(theme.radii.full);
|
|
79
67
|
expect(style.overflow).toBe('hidden');
|
|
80
68
|
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ImageStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { resolveToken } from '../../../theme/resolveToken';
|
|
4
|
+
import type { SurfaceTheme } from '../../../theme/types';
|
|
5
|
+
import type { ImageProps } from '../../../types/image';
|
|
6
|
+
|
|
7
|
+
/*** Resolves token-aware dimensions and radius for a Surface image. */
|
|
8
|
+
export function resolveImageStyle(
|
|
9
|
+
theme: SurfaceTheme,
|
|
10
|
+
props: Pick<ImageProps, 'width' | 'height' | 'aspectRatio' | 'radius'>,
|
|
11
|
+
): ImageStyle {
|
|
12
|
+
const width = resolveToken(theme.spacing, props.width);
|
|
13
|
+
const height = resolveToken(theme.spacing, props.height);
|
|
14
|
+
const borderRadius = resolveToken(theme.radii, props.radius);
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
width,
|
|
18
|
+
height,
|
|
19
|
+
aspectRatio: props.aspectRatio,
|
|
20
|
+
borderRadius,
|
|
21
|
+
overflow: borderRadius !== undefined ? 'hidden' : undefined,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ImageSourcePropType } from 'react-native';
|
|
2
|
+
|
|
3
|
+
/*** Chooses the primary or fallback normalized image source. */
|
|
4
|
+
export function resolveRenderedSource(
|
|
5
|
+
normalizedPrimary: ImageSourcePropType | undefined,
|
|
6
|
+
normalizedFallback: ImageSourcePropType | undefined,
|
|
7
|
+
showFallback: boolean,
|
|
8
|
+
): ImageSourcePropType | undefined {
|
|
9
|
+
if (showFallback || !normalizedPrimary) return normalizedFallback;
|
|
10
|
+
return normalizedPrimary;
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ImageResizeMode } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import type { ImageProps } from '../../../types/image';
|
|
4
|
+
|
|
5
|
+
/*** Resolves the canonical resize mode, preferring the Surface fit alias. */
|
|
6
|
+
export function resolveResizeMode(
|
|
7
|
+
fit: ImageProps['fit'],
|
|
8
|
+
resizeMode: ImageProps['resizeMode'],
|
|
9
|
+
): ImageResizeMode {
|
|
10
|
+
return fit ?? resizeMode ?? 'cover';
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { KeyboardAvoidingView as ReactNativeKeyboardAvoidingView } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import type { KeyboardAvoidingViewProps } from '../../../../types/keyboard-avoiding-view';
|
|
5
|
+
|
|
6
|
+
/*** Preserves React Native keyboard avoidance behind the stable Surface feature boundary. */
|
|
7
|
+
export function KeyboardAvoidingView(props: KeyboardAvoidingViewProps) {
|
|
8
|
+
return <ReactNativeKeyboardAvoidingView {...props} />;
|
|
9
|
+
}
|
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { View
|
|
2
|
+
import { View } from 'react-native';
|
|
3
3
|
|
|
4
|
-
import { useResponsiveRuntime } from '
|
|
5
|
-
import { resolvePointerEvents } from '
|
|
6
|
-
import { useTheme } from '
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
export interface BoxProps extends BoxStyleProps {
|
|
10
|
-
accessibilityLabel?: ReactNativeViewProps['accessibilityLabel'];
|
|
11
|
-
accessibilityRole?: ReactNativeViewProps['accessibilityRole'];
|
|
12
|
-
accessibilityState?: ReactNativeViewProps['accessibilityState'];
|
|
13
|
-
accessible?: ReactNativeViewProps['accessible'];
|
|
14
|
-
children?: React.ReactNode;
|
|
15
|
-
pointerEvents?: ReactNativeViewProps['pointerEvents'];
|
|
16
|
-
testID?: string;
|
|
17
|
-
}
|
|
4
|
+
import { useResponsiveRuntime } from '../../../../core/responsive';
|
|
5
|
+
import { resolvePointerEvents } from '../../../../internal/resolvePointerEvents';
|
|
6
|
+
import { useTheme } from '../../../../theme/ThemeContext';
|
|
7
|
+
import type { BoxProps } from '../../../../types/layout';
|
|
8
|
+
import { resolveBoxStyles } from '../../../../utils/resolveBoxStyles';
|
|
18
9
|
|
|
10
|
+
/*** Renders the responsive foundational layout box. */
|
|
19
11
|
export function Box({
|
|
20
12
|
accessible,
|
|
21
13
|
accessibilityLabel,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet, View, type ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { resolveResponsive, useResponsiveRuntime } from '../../../../core/responsive';
|
|
5
|
+
import { useTheme } from '../../../../theme/ThemeContext';
|
|
6
|
+
import type { ContainerProps } from '../../../../types/layout';
|
|
7
|
+
import { resolveSpacing } from '../../../../utils/resolveSpacing';
|
|
8
|
+
import { Box } from './Box';
|
|
9
|
+
|
|
10
|
+
/*** Centers responsive content inside a configurable maximum width. */
|
|
11
|
+
export function Container({
|
|
12
|
+
children,
|
|
13
|
+
maxWidth = { base: Number.MAX_SAFE_INTEGER, lg: 1120 },
|
|
14
|
+
px = { base: 16, md: 24, lg: 32 },
|
|
15
|
+
...props
|
|
16
|
+
}: ContainerProps) {
|
|
17
|
+
const { theme } = useTheme();
|
|
18
|
+
const { breakpoint } = useResponsiveRuntime();
|
|
19
|
+
const activeMaxWidth = resolveResponsive(maxWidth, breakpoint);
|
|
20
|
+
const activePx = resolveSpacing(theme, resolveResponsive(px, breakpoint));
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Box {...props} width="100%" style={[styles.fullWidth, props.style]}>
|
|
24
|
+
<View style={resolveContainerStyle(activeMaxWidth, activePx)}>{children}</View>
|
|
25
|
+
</Box>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/*** Resolves centered responsive Container dimensions and padding. */
|
|
30
|
+
function resolveContainerStyle(
|
|
31
|
+
maxWidth: number | undefined,
|
|
32
|
+
horizontalPadding: number | undefined,
|
|
33
|
+
): ViewStyle {
|
|
34
|
+
return {
|
|
35
|
+
alignSelf: 'center',
|
|
36
|
+
maxWidth,
|
|
37
|
+
paddingLeft: horizontalPadding,
|
|
38
|
+
paddingRight: horizontalPadding,
|
|
39
|
+
width: '100%',
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const styles = StyleSheet.create({ fullWidth: { width: '100%' } });
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
export interface DividerProps extends Omit<BoxProps, 'bg' | 'height' | 'width'> {
|
|
7
|
-
orientation?: 'horizontal' | 'vertical';
|
|
8
|
-
color?: ColorValue;
|
|
9
|
-
thickness?: number;
|
|
10
|
-
}
|
|
3
|
+
import type { DividerProps } from '../../../../types/layout';
|
|
4
|
+
import { Box } from './Box';
|
|
11
5
|
|
|
6
|
+
/*** Renders a horizontal or vertical separator using layout tokens. */
|
|
12
7
|
export function Divider({
|
|
13
8
|
orientation = 'horizontal',
|
|
14
9
|
color = 'border',
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, type ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { resolveResponsive, useResponsiveRuntime } from '../../../../core/responsive';
|
|
5
|
+
import { useTheme } from '../../../../theme/ThemeContext';
|
|
6
|
+
import type { GridProps } from '../../../../types/layout';
|
|
7
|
+
import { resolveSpacing } from '../../../../utils/resolveSpacing';
|
|
8
|
+
import { Box } from './Box';
|
|
9
|
+
|
|
10
|
+
/*** Lays out children in a responsive wrapping grid. */
|
|
11
|
+
export function Grid({
|
|
12
|
+
children,
|
|
13
|
+
cols,
|
|
14
|
+
gap = 0,
|
|
15
|
+
rowGap,
|
|
16
|
+
colGap,
|
|
17
|
+
minItemWidth,
|
|
18
|
+
...props
|
|
19
|
+
}: GridProps) {
|
|
20
|
+
const { theme } = useTheme();
|
|
21
|
+
const { breakpoint } = useResponsiveRuntime();
|
|
22
|
+
const activeCols = Math.max(1, Math.floor(resolveResponsive(cols, breakpoint) ?? 1));
|
|
23
|
+
const defaultGap = resolveResponsive(gap, breakpoint) ?? 0;
|
|
24
|
+
const rowSpacing = Number(
|
|
25
|
+
resolveSpacing(theme, resolveResponsive(rowGap, breakpoint) ?? defaultGap) ?? 0,
|
|
26
|
+
);
|
|
27
|
+
const colSpacing = Number(
|
|
28
|
+
resolveSpacing(theme, resolveResponsive(colGap, breakpoint) ?? defaultGap) ?? 0,
|
|
29
|
+
);
|
|
30
|
+
const activeMinItemWidth = resolveResponsive(minItemWidth, breakpoint);
|
|
31
|
+
const basisPercent: `${number}%` = `${100 / activeCols}%`;
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Box {...props}>
|
|
35
|
+
<View style={resolveGridStyle(rowSpacing, colSpacing)}>
|
|
36
|
+
{React.Children.toArray(children).map((node, index) => (
|
|
37
|
+
<View
|
|
38
|
+
key={String(index)}
|
|
39
|
+
style={resolveGridItemStyle(activeMinItemWidth, basisPercent, rowSpacing, colSpacing)}
|
|
40
|
+
>
|
|
41
|
+
{node}
|
|
42
|
+
</View>
|
|
43
|
+
))}
|
|
44
|
+
</View>
|
|
45
|
+
</Box>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/*** Resolves the wrapping Grid container style. */
|
|
50
|
+
function resolveGridStyle(rowSpacing: number, colSpacing: number): ViewStyle {
|
|
51
|
+
return {
|
|
52
|
+
flexDirection: 'row',
|
|
53
|
+
flexWrap: 'wrap',
|
|
54
|
+
marginLeft: -colSpacing / 2,
|
|
55
|
+
marginRight: -colSpacing / 2,
|
|
56
|
+
marginTop: -rowSpacing / 2,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/*** Resolves a fixed-column or minimum-width grid item style. */
|
|
61
|
+
function resolveGridItemStyle(
|
|
62
|
+
minItemWidth: number | undefined,
|
|
63
|
+
basisPercent: `${number}%`,
|
|
64
|
+
rowSpacing: number,
|
|
65
|
+
colSpacing: number,
|
|
66
|
+
): ViewStyle {
|
|
67
|
+
const sizing =
|
|
68
|
+
minItemWidth === undefined
|
|
69
|
+
? { width: basisPercent, flexBasis: basisPercent }
|
|
70
|
+
: { minWidth: minItemWidth, flexBasis: minItemWidth, flexGrow: 1 };
|
|
71
|
+
return {
|
|
72
|
+
...sizing,
|
|
73
|
+
paddingBottom: rowSpacing / 2,
|
|
74
|
+
paddingLeft: colSpacing / 2,
|
|
75
|
+
paddingRight: colSpacing / 2,
|
|
76
|
+
paddingTop: rowSpacing / 2,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -5,7 +5,6 @@ import { describe, expect, it } from 'bun:test';
|
|
|
5
5
|
describe('Stack layout contract', () => {
|
|
6
6
|
it('keeps authored children as direct flex items and applies spacing through gap', async () => {
|
|
7
7
|
const source = await readFile(new URL('./Stack.tsx', import.meta.url), 'utf8');
|
|
8
|
-
|
|
9
8
|
expect(source).toContain('gap: activeGap');
|
|
10
9
|
expect(source).toContain('{children}');
|
|
11
10
|
expect(source).not.toContain("from 'react-native'");
|
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
|
|
3
|
-
import { resolveResponsive,
|
|
4
|
-
import { useTheme } from '
|
|
5
|
-
import {
|
|
6
|
-
import { resolveSpacing
|
|
7
|
-
|
|
8
|
-
export interface StackProps extends Omit<BoxProps, 'children'> {
|
|
9
|
-
children?: React.ReactNode;
|
|
10
|
-
direction?: Responsive<'row' | 'column'>;
|
|
11
|
-
gap?: Responsive<SpaceValue>;
|
|
12
|
-
align?: Responsive<'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline'>;
|
|
13
|
-
justify?: Responsive<
|
|
14
|
-
'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly'
|
|
15
|
-
>;
|
|
16
|
-
wrap?: Responsive<'nowrap' | 'wrap'>;
|
|
17
|
-
}
|
|
3
|
+
import { resolveResponsive, useResponsiveRuntime } from '../../../../core/responsive';
|
|
4
|
+
import { useTheme } from '../../../../theme/ThemeContext';
|
|
5
|
+
import type { StackProps } from '../../../../types/layout';
|
|
6
|
+
import { resolveSpacing } from '../../../../utils/resolveSpacing';
|
|
7
|
+
import { Box } from './Box';
|
|
18
8
|
|
|
9
|
+
/*** Stacks authored children directly along a responsive flex direction. */
|
|
19
10
|
export function Stack({
|
|
20
11
|
children,
|
|
21
12
|
direction = 'column',
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
BoxProps,
|
|
3
|
+
ContainerProps,
|
|
4
|
+
DividerProps,
|
|
5
|
+
GridProps,
|
|
6
|
+
StackProps,
|
|
7
|
+
} from '../../types/layout';
|
|
8
|
+
export { Box } from './adapters/inbound/Box';
|
|
9
|
+
export { Container } from './adapters/inbound/Container';
|
|
10
|
+
export { Divider } from './adapters/inbound/Divider';
|
|
11
|
+
export { Grid } from './adapters/inbound/Grid';
|
|
12
|
+
export { Stack } from './adapters/inbound/Stack';
|
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ViewStyle } from 'react-native';
|
|
3
3
|
|
|
4
|
-
import { useTheme } from '
|
|
5
|
-
import {
|
|
4
|
+
import { useTheme } from '../../../../theme/ThemeContext';
|
|
5
|
+
import type { SurfaceProps, SurfaceVariant } from '../../../../types/surface';
|
|
6
|
+
import { Box } from '../../../layout/public';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
/*** Renders a themed container surface with semantic elevation and border variants. */
|
|
9
|
+
export function Surface({ variant = 'default', radius = 'm', style, ...props }: SurfaceProps) {
|
|
10
|
+
const { theme } = useTheme();
|
|
11
|
+
const backgroundColor =
|
|
12
|
+
variant === 'subtle'
|
|
13
|
+
? theme.semantics.surface.subtle
|
|
14
|
+
: variant === 'raised'
|
|
15
|
+
? theme.semantics.surface.raised
|
|
16
|
+
: theme.semantics.surface.default;
|
|
17
|
+
const borderColor = theme.semantics.border.default;
|
|
8
18
|
|
|
9
|
-
|
|
10
|
-
|
|
19
|
+
return (
|
|
20
|
+
<Box
|
|
21
|
+
{...props}
|
|
22
|
+
radius={radius}
|
|
23
|
+
style={[resolveSurfaceVariantStyles(variant, borderColor, backgroundColor), style]}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
11
26
|
}
|
|
12
27
|
|
|
28
|
+
/*** Resolves the semantic visual treatment for one Surface variant. */
|
|
13
29
|
function resolveSurfaceVariantStyles(
|
|
14
30
|
variant: SurfaceVariant,
|
|
15
31
|
borderColor: string,
|
|
@@ -17,11 +33,7 @@ function resolveSurfaceVariantStyles(
|
|
|
17
33
|
): ViewStyle {
|
|
18
34
|
switch (variant) {
|
|
19
35
|
case 'subtle':
|
|
20
|
-
return {
|
|
21
|
-
backgroundColor,
|
|
22
|
-
borderColor: 'transparent',
|
|
23
|
-
borderWidth: 0,
|
|
24
|
-
};
|
|
36
|
+
return { backgroundColor, borderColor: 'transparent', borderWidth: 0 };
|
|
25
37
|
case 'raised':
|
|
26
38
|
return {
|
|
27
39
|
backgroundColor,
|
|
@@ -34,37 +46,8 @@ function resolveSurfaceVariantStyles(
|
|
|
34
46
|
shadowRadius: 8,
|
|
35
47
|
};
|
|
36
48
|
case 'outline':
|
|
37
|
-
return {
|
|
38
|
-
backgroundColor: 'transparent',
|
|
39
|
-
borderColor,
|
|
40
|
-
borderWidth: 1,
|
|
41
|
-
};
|
|
49
|
+
return { backgroundColor: 'transparent', borderColor, borderWidth: 1 };
|
|
42
50
|
case 'default':
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
backgroundColor,
|
|
46
|
-
borderColor,
|
|
47
|
-
borderWidth: 1,
|
|
48
|
-
};
|
|
51
|
+
return { backgroundColor, borderColor, borderWidth: 1 };
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
|
-
|
|
52
|
-
export function Surface({ variant = 'default', radius = 'm', style, ...props }: SurfaceProps) {
|
|
53
|
-
const { theme } = useTheme();
|
|
54
|
-
|
|
55
|
-
const backgroundColor =
|
|
56
|
-
variant === 'subtle'
|
|
57
|
-
? theme.semantics.surface.subtle
|
|
58
|
-
: variant === 'raised'
|
|
59
|
-
? theme.semantics.surface.raised
|
|
60
|
-
: theme.semantics.surface.default;
|
|
61
|
-
const borderColor = theme.semantics.border.default;
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<Box
|
|
65
|
-
{...props}
|
|
66
|
-
radius={radius}
|
|
67
|
-
style={[resolveSurfaceVariantStyles(variant, borderColor, backgroundColor), style]}
|
|
68
|
-
/>
|
|
69
|
-
);
|
|
70
|
-
}
|