@ankhorage/surface 8.0.0 → 9.0.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/dist/{surfaceColor.d.ts → constants/surfaceColor.d.ts} +0 -4
- package/dist/constants/surfaceColor.d.ts.map +1 -0
- package/dist/constants/surfaceColor.js.map +1 -0
- package/dist/features/app-bar/adapters/inbound/AppBar.d.ts.map +1 -1
- package/dist/features/app-bar/adapters/inbound/AppBar.js +1 -1
- package/dist/features/app-bar/adapters/inbound/AppBar.js.map +1 -1
- package/dist/features/badge/adapters/inbound/Badge.d.ts.map +1 -1
- package/dist/features/badge/adapters/inbound/Badge.js +1 -1
- package/dist/features/badge/adapters/inbound/Badge.js.map +1 -1
- package/dist/features/button/adapters/inbound/Button.d.ts.map +1 -1
- package/dist/features/button/adapters/inbound/Button.js +1 -1
- package/dist/features/button/adapters/inbound/Button.js.map +1 -1
- package/dist/features/button/adapters/inbound/IconButton.d.ts.map +1 -1
- package/dist/features/button/adapters/inbound/IconButton.js +1 -1
- package/dist/features/button/adapters/inbound/IconButton.js.map +1 -1
- package/dist/features/card/adapters/inbound/Card.d.ts.map +1 -1
- package/dist/features/card/adapters/inbound/Card.js +1 -1
- package/dist/features/card/adapters/inbound/Card.js.map +1 -1
- package/dist/features/font/adapters/inbound/FontProvider.d.ts +4 -0
- package/dist/features/font/adapters/inbound/FontProvider.d.ts.map +1 -0
- package/dist/features/font/adapters/inbound/FontProvider.js +16 -0
- package/dist/features/font/adapters/inbound/FontProvider.js.map +1 -0
- package/dist/features/font/adapters/inbound/FontRuntimeContext.d.ts +4 -0
- package/dist/features/font/adapters/inbound/FontRuntimeContext.d.ts.map +1 -0
- package/dist/features/font/adapters/inbound/FontRuntimeContext.js +9 -0
- package/dist/features/font/adapters/inbound/FontRuntimeContext.js.map +1 -0
- package/dist/features/font/adapters/inbound/useFontRuntime.d.ts +4 -0
- package/dist/features/font/adapters/inbound/useFontRuntime.d.ts.map +1 -0
- package/dist/features/font/adapters/inbound/useFontRuntime.js +7 -0
- package/dist/features/font/adapters/inbound/useFontRuntime.js.map +1 -0
- package/dist/features/font/public.d.ts +3 -0
- package/dist/features/font/public.d.ts.map +1 -0
- package/dist/features/font/public.js +2 -0
- package/dist/features/font/public.js.map +1 -0
- package/dist/features/form/checkbox/adapters/inbound/Checkbox.d.ts.map +1 -1
- package/dist/features/form/checkbox/adapters/inbound/Checkbox.js +1 -1
- package/dist/features/form/checkbox/adapters/inbound/Checkbox.js.map +1 -1
- package/dist/features/form/radio/adapters/inbound/Radio.d.ts.map +1 -1
- package/dist/features/form/radio/adapters/inbound/Radio.js +1 -1
- package/dist/features/form/radio/adapters/inbound/Radio.js.map +1 -1
- package/dist/features/form/switch/adapters/inbound/Switch.d.ts.map +1 -1
- package/dist/features/form/switch/adapters/inbound/Switch.js +1 -1
- package/dist/features/form/switch/adapters/inbound/Switch.js.map +1 -1
- package/dist/features/form/text-input/adapters/inbound/TextInput.d.ts.map +1 -1
- package/dist/features/form/text-input/adapters/inbound/TextInput.js +1 -1
- package/dist/features/form/text-input/adapters/inbound/TextInput.js.map +1 -1
- package/dist/features/form/text-input/utils/resolveTextInputPresentation.d.ts +1 -1
- package/dist/features/form/text-input/utils/resolveTextInputPresentation.d.ts.map +1 -1
- package/dist/features/form/text-input/utils/resolveTextInputPresentation.js.map +1 -1
- package/dist/features/icon/adapters/inbound/Icon.d.ts.map +1 -1
- package/dist/features/icon/adapters/inbound/Icon.js +2 -2
- package/dist/features/icon/adapters/inbound/Icon.js.map +1 -1
- package/dist/features/image/adapters/inbound/Image.d.ts.map +1 -1
- package/dist/features/image/adapters/inbound/Image.js +1 -1
- package/dist/features/image/adapters/inbound/Image.js.map +1 -1
- package/dist/features/image/utils/resolveImageStyle.d.ts +1 -1
- package/dist/features/image/utils/resolveImageStyle.d.ts.map +1 -1
- package/dist/features/image/utils/resolveImageStyle.js +1 -1
- package/dist/features/image/utils/resolveImageStyle.js.map +1 -1
- package/dist/features/layout/adapters/inbound/Grid.d.ts.map +1 -1
- package/dist/features/layout/adapters/inbound/Grid.js +1 -1
- package/dist/features/layout/adapters/inbound/Grid.js.map +1 -1
- package/dist/features/layout/adapters/inbound/ScrollView.d.ts.map +1 -1
- package/dist/features/layout/adapters/inbound/ScrollView.js +1 -1
- package/dist/features/layout/adapters/inbound/ScrollView.js.map +1 -1
- package/dist/features/layout/adapters/inbound/View.d.ts.map +1 -1
- package/dist/features/layout/adapters/inbound/View.js +1 -1
- package/dist/features/layout/adapters/inbound/View.js.map +1 -1
- package/dist/features/list/adapters/inbound/ListItem.d.ts.map +1 -1
- package/dist/features/list/adapters/inbound/ListItem.js +1 -1
- package/dist/features/list/adapters/inbound/ListItem.js.map +1 -1
- package/dist/features/modal/adapters/inbound/Modal.d.ts.map +1 -1
- package/dist/features/modal/adapters/inbound/Modal.js +1 -1
- package/dist/features/modal/adapters/inbound/Modal.js.map +1 -1
- package/dist/features/popover-menu/adapters/inbound/PopoverMenu.d.ts.map +1 -1
- package/dist/features/popover-menu/adapters/inbound/PopoverMenu.js +1 -1
- package/dist/features/popover-menu/adapters/inbound/PopoverMenu.js.map +1 -1
- package/dist/features/pressable/adapters/inbound/Pressable.d.ts.map +1 -1
- package/dist/features/pressable/adapters/inbound/Pressable.js +1 -1
- package/dist/features/pressable/adapters/inbound/Pressable.js.map +1 -1
- package/dist/features/surface/adapters/inbound/Surface.d.ts.map +1 -1
- package/dist/features/surface/adapters/inbound/Surface.js +1 -1
- package/dist/features/surface/adapters/inbound/Surface.js.map +1 -1
- package/dist/features/tabs/adapters/inbound/Tab.d.ts.map +1 -1
- package/dist/features/tabs/adapters/inbound/Tab.js +1 -1
- package/dist/features/tabs/adapters/inbound/Tab.js.map +1 -1
- package/dist/features/theme/adapters/inbound/ThemeProvider.d.ts +4 -0
- package/dist/features/theme/adapters/inbound/ThemeProvider.d.ts.map +1 -0
- package/dist/features/theme/adapters/inbound/ThemeProvider.js +27 -0
- package/dist/features/theme/adapters/inbound/ThemeProvider.js.map +1 -0
- package/dist/features/theme/adapters/inbound/ThemeRuntimeContext.d.ts +4 -0
- package/dist/features/theme/adapters/inbound/ThemeRuntimeContext.d.ts.map +1 -0
- package/dist/features/theme/adapters/inbound/ThemeRuntimeContext.js +11 -0
- package/dist/features/theme/adapters/inbound/ThemeRuntimeContext.js.map +1 -0
- package/dist/features/theme/adapters/inbound/ThemeScope.d.ts +4 -0
- package/dist/features/theme/adapters/inbound/ThemeScope.d.ts.map +1 -0
- package/dist/features/theme/adapters/inbound/ThemeScope.js +17 -0
- package/dist/features/theme/adapters/inbound/ThemeScope.js.map +1 -0
- package/dist/features/theme/adapters/inbound/useTheme.d.ts +4 -0
- package/dist/features/theme/adapters/inbound/useTheme.d.ts.map +1 -0
- package/dist/features/theme/adapters/inbound/useTheme.js +7 -0
- package/dist/features/theme/adapters/inbound/useTheme.js.map +1 -0
- package/dist/features/theme/application/use-cases/createTheme.d.ts +5 -0
- package/dist/features/theme/application/use-cases/createTheme.d.ts.map +1 -0
- package/dist/features/theme/application/use-cases/createTheme.js +56 -0
- package/dist/features/theme/application/use-cases/createTheme.js.map +1 -0
- package/dist/features/theme/constants.d.ts +10 -0
- package/dist/features/theme/constants.d.ts.map +1 -0
- package/dist/{theme/defaultTokens.js → features/theme/constants.js} +9 -2
- package/dist/features/theme/constants.js.map +1 -0
- package/dist/{theme → features/theme/domain}/createSurfaceColorDiagnosticCollector.d.ts +1 -1
- package/dist/features/theme/domain/createSurfaceColorDiagnosticCollector.d.ts.map +1 -0
- package/dist/features/theme/domain/createSurfaceColorDiagnosticCollector.js.map +1 -0
- package/dist/{theme → features/theme/domain}/createSurfaceSemanticPolicy.d.ts +1 -1
- package/dist/features/theme/domain/createSurfaceSemanticPolicy.d.ts.map +1 -0
- package/dist/{theme → features/theme/domain}/createSurfaceSemanticPolicy.js +1 -1
- package/dist/features/theme/domain/createSurfaceSemanticPolicy.js.map +1 -0
- package/dist/features/theme/domain/generatePalette.d.ts +10 -0
- package/dist/features/theme/domain/generatePalette.d.ts.map +1 -0
- package/dist/{theme/colorEngine.js → features/theme/domain/generatePalette.js} +2 -10
- package/dist/features/theme/domain/generatePalette.js.map +1 -0
- package/dist/{theme → features/theme/domain}/resolveRoleSemantics.d.ts +1 -1
- package/dist/features/theme/domain/resolveRoleSemantics.d.ts.map +1 -0
- package/dist/{theme → features/theme/domain}/resolveRoleSemantics.js +1 -1
- package/dist/features/theme/domain/resolveRoleSemantics.js.map +1 -0
- package/dist/features/theme/domain/resolveSemanticColors.d.ts +4 -0
- package/dist/features/theme/domain/resolveSemanticColors.d.ts.map +1 -0
- package/dist/features/theme/domain/resolveSemanticColors.js +10 -0
- package/dist/features/theme/domain/resolveSemanticColors.js.map +1 -0
- package/dist/{theme → features/theme/domain}/resolveSurfaceSemanticModel.d.ts +1 -1
- package/dist/features/theme/domain/resolveSurfaceSemanticModel.d.ts.map +1 -0
- package/dist/features/theme/domain/resolveSurfaceSemanticModel.js.map +1 -0
- package/dist/features/theme/public.d.ts +3 -0
- package/dist/features/theme/public.d.ts.map +1 -0
- package/dist/features/theme/public.js +2 -0
- package/dist/features/theme/public.js.map +1 -0
- package/dist/features/theme/runtime.d.ts +5 -0
- package/dist/features/theme/runtime.d.ts.map +1 -0
- package/dist/features/theme/runtime.js +4 -0
- package/dist/features/theme/runtime.js.map +1 -0
- package/dist/{theme → features/theme/utils}/resolveGlobalTokens.d.ts +1 -1
- package/dist/features/theme/utils/resolveGlobalTokens.d.ts.map +1 -0
- package/dist/{theme → features/theme/utils}/resolveGlobalTokens.js +1 -1
- package/dist/features/theme/utils/resolveGlobalTokens.js.map +1 -0
- package/dist/{theme → features/theme/utils}/resolveHeadingTokenOverrides.d.ts +1 -1
- package/dist/features/theme/utils/resolveHeadingTokenOverrides.d.ts.map +1 -0
- package/dist/features/theme/utils/resolveHeadingTokenOverrides.js.map +1 -0
- package/dist/features/theme/utils/resolveNumericTokenOverrides.d.ts.map +1 -0
- package/dist/features/theme/utils/resolveNumericTokenOverrides.js.map +1 -0
- package/dist/{theme → features/theme/utils}/resolveToken.d.ts +2 -8
- package/dist/features/theme/utils/resolveToken.d.ts.map +1 -0
- package/dist/features/theme/utils/resolveToken.js +10 -0
- package/dist/features/theme/utils/resolveToken.js.map +1 -0
- package/dist/{theme → features/theme/utils}/resolveWeightTokenOverrides.d.ts +1 -1
- package/dist/features/theme/utils/resolveWeightTokenOverrides.d.ts.map +1 -0
- package/dist/{theme → features/theme/utils}/resolveWeightTokenOverrides.js +3 -5
- package/dist/features/theme/utils/resolveWeightTokenOverrides.js.map +1 -0
- package/dist/features/toast/adapters/inbound/Toast.d.ts.map +1 -1
- package/dist/features/toast/adapters/inbound/Toast.js +1 -1
- package/dist/features/toast/adapters/inbound/Toast.js.map +1 -1
- package/dist/features/tooltip/adapters/inbound/Tooltip.d.ts.map +1 -1
- package/dist/features/tooltip/adapters/inbound/Tooltip.js +1 -1
- package/dist/features/tooltip/adapters/inbound/Tooltip.js.map +1 -1
- package/dist/features/typography/adapters/inbound/Heading.d.ts +2 -2
- package/dist/features/typography/adapters/inbound/Heading.d.ts.map +1 -1
- package/dist/features/typography/adapters/inbound/Heading.js +4 -20
- package/dist/features/typography/adapters/inbound/Heading.js.map +1 -1
- package/dist/features/typography/adapters/inbound/Text.d.ts +1 -1
- package/dist/features/typography/adapters/inbound/Text.d.ts.map +1 -1
- package/dist/features/typography/adapters/inbound/Text.js +3 -20
- package/dist/features/typography/adapters/inbound/Text.js.map +1 -1
- package/dist/features/typography/utils/resolveHeadingTextStyle.d.ts +2 -2
- package/dist/features/typography/utils/resolveHeadingTextStyle.d.ts.map +1 -1
- package/dist/features/typography/utils/resolveHeadingTextStyle.js.map +1 -1
- package/dist/index.d.ts +9 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -6
- package/dist/index.js.map +1 -1
- package/dist/internal/resolvers/resolveControlSize.d.ts +1 -1
- package/dist/internal/resolvers/resolveControlSize.js.map +1 -1
- package/dist/internal/resolvers/resolveFieldPresentation.d.ts +1 -1
- package/dist/internal/resolvers/resolveFieldPresentation.d.ts.map +1 -1
- package/dist/internal/resolvers/resolveFieldPresentation.js.map +1 -1
- package/dist/internal/resolvers/resolveIconSize.d.ts +1 -1
- package/dist/internal/resolvers/resolveIconSize.js.map +1 -1
- package/dist/internal/resolvers/resolveInteractiveColors.d.ts +2 -2
- package/dist/internal/resolvers/resolveInteractiveColors.d.ts.map +1 -1
- package/dist/internal/resolvers/resolveInteractiveColors.js.map +1 -1
- package/dist/internal/resolvers/resolveSelectionControlColors.d.ts +2 -2
- package/dist/internal/resolvers/resolveSelectionControlColors.d.ts.map +1 -1
- package/dist/internal/resolvers/resolveSelectionControlColors.js.map +1 -1
- package/dist/internal/resolvers/resolveSurfaceColor.d.ts +2 -2
- package/dist/internal/resolvers/resolveSurfaceColor.d.ts.map +1 -1
- package/dist/internal/resolvers/resolveSurfaceColor.js.map +1 -1
- package/dist/internal/resolvers/resolveTextColor.d.ts +2 -2
- package/dist/internal/resolvers/resolveTextColor.d.ts.map +1 -1
- package/dist/internal/resolvers/resolveTextColor.js.map +1 -1
- package/dist/internal/resolvers/resolveTextStyles.d.ts +1 -1
- package/dist/internal/resolvers/resolveTextStyles.js.map +1 -1
- package/dist/types/accordion.d.ts +1 -1
- package/dist/types/accordion.d.ts.map +1 -1
- package/dist/types/accordion.js.map +1 -1
- package/dist/types/badge.d.ts +1 -1
- package/dist/types/badge.d.ts.map +1 -1
- package/dist/types/badge.js.map +1 -1
- package/dist/types/button.d.ts +1 -1
- package/dist/types/button.d.ts.map +1 -1
- package/dist/types/button.js.map +1 -1
- package/dist/types/checkbox.d.ts +1 -1
- package/dist/types/checkbox.d.ts.map +1 -1
- package/dist/types/checkbox.js.map +1 -1
- package/dist/types/font.d.ts +13 -0
- package/dist/types/font.d.ts.map +1 -0
- package/dist/types/font.js +2 -0
- package/dist/types/font.js.map +1 -0
- package/dist/types/icon.d.ts +1 -1
- package/dist/types/icon.d.ts.map +1 -1
- package/dist/types/icon.js.map +1 -1
- package/dist/types/image.d.ts +1 -1
- package/dist/types/image.d.ts.map +1 -1
- package/dist/types/image.js.map +1 -1
- package/dist/types/interactionPolicy.d.ts.map +1 -0
- package/dist/types/interactionPolicy.js.map +1 -0
- package/dist/types/layout.d.ts +1 -1
- package/dist/types/layout.d.ts.map +1 -1
- package/dist/types/layout.js.map +1 -1
- package/dist/types/list.d.ts +1 -1
- package/dist/types/list.d.ts.map +1 -1
- package/dist/types/list.js.map +1 -1
- package/dist/types/modal.d.ts +1 -1
- package/dist/types/modal.d.ts.map +1 -1
- package/dist/types/modal.js.map +1 -1
- package/dist/types/popover.d.ts +1 -1
- package/dist/types/popover.d.ts.map +1 -1
- package/dist/types/popover.js.map +1 -1
- package/dist/types/popoverMenu.d.ts +1 -1
- package/dist/types/popoverMenu.d.ts.map +1 -1
- package/dist/types/popoverMenu.js.map +1 -1
- package/dist/types/pressable.d.ts +1 -1
- package/dist/types/pressable.d.ts.map +1 -1
- package/dist/types/pressable.js.map +1 -1
- package/dist/types/radio.d.ts +1 -1
- package/dist/types/radio.d.ts.map +1 -1
- package/dist/types/radio.js.map +1 -1
- package/dist/types/surfaceColor.d.ts +6 -0
- package/dist/types/surfaceColor.d.ts.map +1 -0
- package/dist/types/surfaceColor.js +2 -0
- package/dist/types/surfaceColor.js.map +1 -0
- package/dist/types/switch.d.ts +1 -1
- package/dist/types/switch.d.ts.map +1 -1
- package/dist/types/switch.js.map +1 -1
- package/dist/types/tabs.d.ts +1 -1
- package/dist/types/tabs.d.ts.map +1 -1
- package/dist/types/tabs.js.map +1 -1
- package/dist/types/text-input.d.ts +1 -1
- package/dist/types/text-input.d.ts.map +1 -1
- package/dist/types/text-input.js.map +1 -1
- package/dist/{theme/types.d.ts → types/theme.d.ts} +19 -3
- package/dist/types/theme.d.ts.map +1 -0
- package/dist/types/theme.js +2 -0
- package/dist/types/theme.js.map +1 -0
- package/dist/types/toast.d.ts +2 -2
- package/dist/types/toast.d.ts.map +1 -1
- package/dist/types/toast.js.map +1 -1
- package/dist/types/tooltip.d.ts +1 -1
- package/dist/types/tooltip.d.ts.map +1 -1
- package/dist/types/tooltip.js.map +1 -1
- package/dist/types/typography.d.ts +1 -1
- package/dist/types/typography.d.ts.map +1 -1
- package/dist/types/typography.js.map +1 -1
- package/dist/utils/resolveSpacing.d.ts +1 -1
- package/dist/utils/resolveSpacing.d.ts.map +1 -1
- package/dist/utils/resolveSpacing.js +1 -1
- package/dist/utils/resolveSpacing.js.map +1 -1
- package/dist/utils/resolveViewStyles.d.ts +1 -1
- package/dist/utils/resolveViewStyles.d.ts.map +1 -1
- package/dist/utils/resolveViewStyles.js +1 -1
- package/dist/utils/resolveViewStyles.js.map +1 -1
- package/package.json +16 -7
- package/src/constants/surfaceColor.public.test.ts +34 -0
- package/src/constants/surfaceColor.test.ts +18 -0
- package/src/{surfaceColor.ts → constants/surfaceColor.ts} +0 -5
- package/src/features/app-bar/adapters/inbound/AppBar.tsx +1 -1
- package/src/features/badge/adapters/inbound/Badge.tsx +1 -1
- package/src/features/button/adapters/inbound/Button.tsx +2 -2
- package/src/features/button/adapters/inbound/IconButton.tsx +1 -1
- package/src/features/card/adapters/inbound/Card.tsx +1 -1
- package/src/features/font/adapters/inbound/FontProvider.tsx +27 -0
- package/src/features/font/adapters/inbound/FontRuntimeContext.tsx +12 -0
- package/src/features/font/adapters/inbound/useFontRuntime.ts +9 -0
- package/src/features/font/public.ts +2 -0
- package/src/features/form/checkbox/adapters/inbound/Checkbox.tsx +2 -2
- package/src/features/form/radio/adapters/inbound/Radio.tsx +2 -2
- package/src/features/form/switch/adapters/inbound/Switch.tsx +1 -1
- package/src/features/form/text-input/adapters/inbound/TextInput.tsx +1 -1
- package/src/features/form/text-input/utils/resolveTextInputPresentation.ts +1 -1
- package/src/features/icon/adapters/inbound/Icon.tsx +2 -2
- package/src/features/image/adapters/inbound/Image.tsx +1 -1
- package/src/features/image/utils/resolveImageProps.test.ts +1 -1
- package/src/features/image/utils/resolveImageStyle.ts +2 -2
- package/src/features/layout/adapters/inbound/Grid.tsx +1 -1
- package/src/features/layout/adapters/inbound/ScrollView.tsx +1 -1
- package/src/features/layout/adapters/inbound/View.tsx +1 -1
- package/src/features/list/adapters/inbound/ListItem.tsx +2 -2
- package/src/features/modal/adapters/inbound/Modal.tsx +1 -1
- package/src/features/popover-menu/adapters/inbound/PopoverMenu.tsx +1 -1
- package/src/features/pressable/adapters/inbound/Pressable.tsx +1 -1
- package/src/features/surface/adapters/inbound/Surface.tsx +1 -1
- package/src/features/tabs/adapters/inbound/Tab.tsx +1 -1
- package/src/features/theme/adapters/inbound/ThemeProvider.tsx +46 -0
- package/src/features/theme/adapters/inbound/ThemeRuntimeContext.tsx +14 -0
- package/src/features/theme/adapters/inbound/ThemeScope.test.tsx +52 -0
- package/src/features/theme/adapters/inbound/ThemeScope.tsx +29 -0
- package/src/features/theme/adapters/inbound/useTheme.ts +9 -0
- package/src/features/theme/application/use-cases/createTheme.ts +71 -0
- package/src/{theme → features/theme/application/use-cases}/createThemeOverrides.test.ts +8 -9
- package/src/{theme → features/theme/application/use-cases}/createThemeValidation.test.ts +4 -2
- package/src/features/theme/constants.ts +68 -0
- package/src/{theme → features/theme/domain}/createSurfaceColorDiagnosticCollector.ts +4 -1
- package/src/{theme → features/theme/domain}/createSurfaceSemanticPolicy.ts +2 -2
- package/src/features/theme/domain/generatePalette.test.ts +294 -0
- package/src/{theme/colorEngine.ts → features/theme/domain/generatePalette.ts} +3 -30
- package/src/{theme → features/theme/domain}/inverseSemantics.test.ts +1 -1
- package/src/{theme → features/theme/domain}/resolveRoleSemantics.ts +2 -2
- package/src/features/theme/domain/resolveSemanticColors.ts +23 -0
- package/src/{theme → features/theme/domain}/resolveSurfaceSemanticModel.ts +4 -4
- package/src/{theme → features/theme}/public.test.ts +1 -1
- package/src/features/theme/public.ts +18 -0
- package/src/features/theme/runtime.test.ts +13 -0
- package/src/features/theme/runtime.ts +4 -0
- package/src/{theme → features/theme/utils}/resolveGlobalTokens.ts +2 -2
- package/src/{theme → features/theme/utils}/resolveHeadingTokenOverrides.ts +1 -1
- package/src/features/theme/utils/resolveToken.ts +16 -0
- package/src/{theme → features/theme/utils}/resolveWeightTokenOverrides.ts +12 -12
- package/src/features/toast/adapters/inbound/Toast.tsx +3 -3
- package/src/features/tooltip/adapters/inbound/Tooltip.tsx +1 -1
- package/src/features/typography/adapters/inbound/Heading.tsx +3 -30
- package/src/features/typography/adapters/inbound/Text.tsx +3 -23
- package/src/features/typography/utils/resolveHeadingTextStyle.test.ts +1 -1
- package/src/features/typography/utils/resolveHeadingTextStyle.ts +2 -2
- package/src/index.test.ts +19 -9
- package/src/index.ts +30 -15
- package/src/internal/resolvers/resolveControlSize.test.ts +1 -1
- package/src/internal/resolvers/resolveControlSize.ts +1 -1
- package/src/internal/resolvers/resolveFieldPresentation.ts +1 -1
- package/src/internal/resolvers/resolveIconSize.ts +1 -1
- package/src/internal/resolvers/resolveInteractiveColors.test.ts +1 -1
- package/src/internal/resolvers/resolveInteractiveColors.ts +2 -2
- package/src/internal/resolvers/resolveSelectionControlColors.test.ts +1 -1
- package/src/internal/resolvers/resolveSelectionControlColors.ts +2 -2
- package/src/internal/resolvers/resolveSurfaceColor.test.ts +1 -1
- package/src/internal/resolvers/resolveSurfaceColor.ts +2 -2
- package/src/internal/resolvers/resolveTextColor.test.ts +1 -1
- package/src/internal/resolvers/resolveTextColor.ts +2 -2
- package/src/internal/resolvers/resolveTextStyles.test.ts +1 -1
- package/src/internal/resolvers/resolveTextStyles.ts +1 -1
- package/src/structureOwnership.test.ts +16 -0
- package/src/types/accordion.ts +1 -1
- package/src/types/badge.ts +1 -1
- package/src/types/button.ts +1 -1
- package/src/types/checkbox.ts +1 -1
- package/src/types/font.ts +14 -0
- package/src/types/icon.ts +1 -1
- package/src/types/image.ts +1 -1
- package/src/types/interactionPolicy.test.ts +30 -0
- package/src/types/layout.ts +1 -1
- package/src/types/list.ts +1 -1
- package/src/types/modal.ts +1 -1
- package/src/types/popover.ts +1 -1
- package/src/types/popoverMenu.ts +1 -1
- package/src/types/pressable.ts +1 -1
- package/src/types/radio.ts +1 -1
- package/src/types/surfaceColor.test.ts +18 -0
- package/src/types/surfaceColor.ts +11 -0
- package/src/types/switch.ts +1 -1
- package/src/types/tabs.ts +1 -1
- package/src/types/text-input.ts +1 -1
- package/src/{theme/types.ts → types/theme.ts} +22 -13
- package/src/types/toast.ts +2 -2
- package/src/types/tooltip.ts +1 -1
- package/src/types/typography.ts +1 -1
- package/src/utils/resolveSpacing.ts +2 -2
- package/src/utils/resolveViewStyles.test.ts +1 -1
- package/src/utils/resolveViewStyles.ts +2 -2
- package/src/webAcceptance.test.tsx +1 -1
- package/dist/context/FontContext.d.ts +0 -20
- package/dist/context/FontContext.d.ts.map +0 -1
- package/dist/context/FontContext.js +0 -27
- package/dist/context/FontContext.js.map +0 -1
- package/dist/context/TranslationContext.d.ts +0 -22
- package/dist/context/TranslationContext.d.ts.map +0 -1
- package/dist/context/TranslationContext.js +0 -25
- package/dist/context/TranslationContext.js.map +0 -1
- package/dist/interactionPolicy.d.ts.map +0 -1
- package/dist/interactionPolicy.js.map +0 -1
- package/dist/surfaceColor.d.ts.map +0 -1
- package/dist/surfaceColor.js.map +0 -1
- package/dist/theme/ThemeContext.d.ts +0 -27
- package/dist/theme/ThemeContext.d.ts.map +0 -1
- package/dist/theme/ThemeContext.js +0 -59
- package/dist/theme/ThemeContext.js.map +0 -1
- package/dist/theme/colorEngine.d.ts +0 -16
- package/dist/theme/colorEngine.d.ts.map +0 -1
- package/dist/theme/colorEngine.js.map +0 -1
- package/dist/theme/createSurfaceColorDiagnosticCollector.d.ts.map +0 -1
- package/dist/theme/createSurfaceColorDiagnosticCollector.js.map +0 -1
- package/dist/theme/createSurfaceSemanticPolicy.d.ts.map +0 -1
- package/dist/theme/createSurfaceSemanticPolicy.js.map +0 -1
- package/dist/theme/createTheme.d.ts +0 -5
- package/dist/theme/createTheme.d.ts.map +0 -1
- package/dist/theme/createTheme.js +0 -49
- package/dist/theme/createTheme.js.map +0 -1
- package/dist/theme/defaultTokens.d.ts +0 -3
- package/dist/theme/defaultTokens.d.ts.map +0 -1
- package/dist/theme/defaultTokens.js.map +0 -1
- package/dist/theme/index.d.ts +0 -3
- package/dist/theme/index.d.ts.map +0 -1
- package/dist/theme/index.js +0 -3
- package/dist/theme/index.js.map +0 -1
- package/dist/theme/public.d.ts +0 -5
- package/dist/theme/public.d.ts.map +0 -1
- package/dist/theme/public.js +0 -5
- package/dist/theme/public.js.map +0 -1
- package/dist/theme/resolveGlobalTokens.d.ts.map +0 -1
- package/dist/theme/resolveGlobalTokens.js.map +0 -1
- package/dist/theme/resolveHeadingTokenOverrides.d.ts.map +0 -1
- package/dist/theme/resolveHeadingTokenOverrides.js.map +0 -1
- package/dist/theme/resolveNumericTokenOverrides.d.ts.map +0 -1
- package/dist/theme/resolveNumericTokenOverrides.js.map +0 -1
- package/dist/theme/resolveRoleSemantics.d.ts.map +0 -1
- package/dist/theme/resolveRoleSemantics.js.map +0 -1
- package/dist/theme/resolveSurfaceSemanticModel.d.ts.map +0 -1
- package/dist/theme/resolveSurfaceSemanticModel.js.map +0 -1
- package/dist/theme/resolveToken.d.ts.map +0 -1
- package/dist/theme/resolveToken.js +0 -19
- package/dist/theme/resolveToken.js.map +0 -1
- package/dist/theme/resolveWeightTokenOverrides.d.ts.map +0 -1
- package/dist/theme/resolveWeightTokenOverrides.js.map +0 -1
- package/dist/theme/surfaceColorPolicy.d.ts +0 -8
- package/dist/theme/surfaceColorPolicy.d.ts.map +0 -1
- package/dist/theme/surfaceColorPolicy.js +0 -8
- package/dist/theme/surfaceColorPolicy.js.map +0 -1
- package/dist/theme/types.d.ts.map +0 -1
- package/dist/theme/types.js +0 -2
- package/dist/theme/types.js.map +0 -1
- package/dist/utils/deepEqual.d.ts +0 -6
- package/dist/utils/deepEqual.d.ts.map +0 -1
- package/dist/utils/deepEqual.js +0 -36
- package/dist/utils/deepEqual.js.map +0 -1
- package/dist/utils/deepMerge.d.ts +0 -6
- package/dist/utils/deepMerge.d.ts.map +0 -1
- package/dist/utils/deepMerge.js +0 -26
- package/dist/utils/deepMerge.js.map +0 -1
- package/src/context/FontContext.tsx +0 -59
- package/src/context/TranslationContext.tsx +0 -50
- package/src/interactionPolicy.test.ts +0 -86
- package/src/surfaceColor.test.ts +0 -44
- package/src/theme/ThemeContext.tsx +0 -94
- package/src/theme/colorEngine.test.ts +0 -302
- package/src/theme/createTheme.ts +0 -60
- package/src/theme/defaultTokens.ts +0 -61
- package/src/theme/index.ts +0 -2
- package/src/theme/public.ts +0 -4
- package/src/theme/resolveToken.ts +0 -32
- package/src/theme/surfaceColorPolicy.ts +0 -7
- package/src/utils/deepEqual.ts +0 -34
- package/src/utils/deepMerge.test.ts +0 -113
- package/src/utils/deepMerge.ts +0 -29
- /package/dist/{surfaceColor.js → constants/surfaceColor.js} +0 -0
- /package/dist/{theme → features/theme/domain}/createSurfaceColorDiagnosticCollector.js +0 -0
- /package/dist/{theme → features/theme/domain}/resolveSurfaceSemanticModel.js +0 -0
- /package/dist/{theme → features/theme/utils}/resolveHeadingTokenOverrides.js +0 -0
- /package/dist/{theme → features/theme/utils}/resolveNumericTokenOverrides.d.ts +0 -0
- /package/dist/{theme → features/theme/utils}/resolveNumericTokenOverrides.js +0 -0
- /package/dist/{interactionPolicy.d.ts → types/interactionPolicy.d.ts} +0 -0
- /package/dist/{interactionPolicy.js → types/interactionPolicy.js} +0 -0
- /package/src/{theme → features/theme/utils}/resolveNumericTokenOverrides.ts +0 -0
- /package/src/{interactionPolicy.ts → types/interactionPolicy.ts} +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
SURFACE_COLORS,
|
|
5
|
+
SURFACE_EMPHASES,
|
|
6
|
+
SURFACE_PALETTE_COLORS,
|
|
7
|
+
SURFACE_STATUS_COLORS,
|
|
8
|
+
} from './surfaceColor';
|
|
9
|
+
|
|
10
|
+
describe('public color subpath', () => {
|
|
11
|
+
test('imports canonical catalogs through the package subpath in plain Bun', async () => {
|
|
12
|
+
const script = [
|
|
13
|
+
"import { SURFACE_COLORS, SURFACE_EMPHASES } from '@ankhorage/surface/color';",
|
|
14
|
+
'process.stdout.write(`${SURFACE_COLORS.length}:${SURFACE_EMPHASES.length}`);',
|
|
15
|
+
].join('\n');
|
|
16
|
+
const subprocess = Bun.spawn({
|
|
17
|
+
cmd: [process.execPath, '-e', script],
|
|
18
|
+
stdout: 'pipe',
|
|
19
|
+
stderr: 'pipe',
|
|
20
|
+
});
|
|
21
|
+
const [stdout, stderr, exitCode] = await Promise.all([
|
|
22
|
+
new Response(subprocess.stdout).text(),
|
|
23
|
+
new Response(subprocess.stderr).text(),
|
|
24
|
+
subprocess.exited,
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
expect(exitCode, stderr).toBe(0);
|
|
28
|
+
expect(stdout).toBe(`${SURFACE_COLORS.length}:${SURFACE_EMPHASES.length}`);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('keeps the package subpath aligned with the canonical catalogs', () => {
|
|
32
|
+
expect(SURFACE_COLORS).toEqual([...SURFACE_PALETTE_COLORS, ...SURFACE_STATUS_COLORS, 'danger']);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
SURFACE_COLORS,
|
|
5
|
+
SURFACE_EMPHASES,
|
|
6
|
+
SURFACE_PALETTE_COLORS,
|
|
7
|
+
SURFACE_STATUS_COLORS,
|
|
8
|
+
} from './surfaceColor';
|
|
9
|
+
|
|
10
|
+
describe('surface color constants', () => {
|
|
11
|
+
it('keeps canonical color and emphasis catalogs unique and aligned', () => {
|
|
12
|
+
expect(new Set(SURFACE_COLORS).size).toBe(SURFACE_COLORS.length);
|
|
13
|
+
expect(new Set(SURFACE_EMPHASES).size).toBe(SURFACE_EMPHASES.length);
|
|
14
|
+
for (const color of [...SURFACE_PALETTE_COLORS, ...SURFACE_STATUS_COLORS]) {
|
|
15
|
+
expect(SURFACE_COLORS).toContain(color);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -15,8 +15,3 @@ export const SURFACE_COLORS = [
|
|
|
15
15
|
] as const;
|
|
16
16
|
|
|
17
17
|
export const SURFACE_EMPHASES = ['default', 'muted', 'subtle', 'inverse'] as const;
|
|
18
|
-
|
|
19
|
-
export type SurfacePaletteColor = (typeof SURFACE_PALETTE_COLORS)[number];
|
|
20
|
-
export type SurfaceStatusColor = (typeof SURFACE_STATUS_COLORS)[number];
|
|
21
|
-
export type SurfaceColor = (typeof SURFACE_COLORS)[number];
|
|
22
|
-
export type SurfaceEmphasis = (typeof SURFACE_EMPHASES)[number];
|
|
@@ -2,9 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import { StyleSheet, View as ReactNativeView, type ViewStyle } from 'react-native';
|
|
3
3
|
import { SafeAreaInsetsContext } from 'react-native-safe-area-context';
|
|
4
4
|
|
|
5
|
-
import { useTheme } from '../../../../theme/ThemeContext';
|
|
6
5
|
import type { AppBarProps } from '../../../../types/app-bar';
|
|
7
6
|
import { Divider, View } from '../../../layout/public';
|
|
7
|
+
import { useTheme } from '../../../theme/runtime';
|
|
8
8
|
|
|
9
9
|
/*** Renders application chrome with optional safe-area padding and leading/trailing slots. */
|
|
10
10
|
export function AppBar({
|
|
@@ -2,9 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import type { ViewStyle } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import { resolveButtonColors, resolveControlSize } from '../../../../internal/resolvers';
|
|
5
|
-
import { useTheme } from '../../../../theme/ThemeContext';
|
|
6
5
|
import type { BadgeProps } from '../../../../types/badge';
|
|
7
6
|
import { View } from '../../../layout/public';
|
|
7
|
+
import { useTheme } from '../../../theme/runtime';
|
|
8
8
|
import { Text } from '../../../typography/public';
|
|
9
9
|
|
|
10
10
|
/*** Renders compact semantic status or metadata content. */
|
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
resolveControlSize,
|
|
8
8
|
resolveIconSize,
|
|
9
9
|
} from '../../../../internal/resolvers';
|
|
10
|
-
import { useTheme } from '../../../../theme/ThemeContext';
|
|
11
|
-
import type { SurfaceTheme } from '../../../../theme/types';
|
|
12
10
|
import type { ButtonProps } from '../../../../types/button';
|
|
11
|
+
import type { SurfaceTheme } from '../../../../types/theme';
|
|
13
12
|
import { Icon } from '../../../icon/public';
|
|
14
13
|
import { View } from '../../../layout/public';
|
|
15
14
|
import { Pressable } from '../../../pressable/public';
|
|
15
|
+
import { useTheme } from '../../../theme/runtime';
|
|
16
16
|
import { Text } from '../../../typography/public';
|
|
17
17
|
|
|
18
18
|
/*** Renders the primary Surface action control with semantic visual states. */
|
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
resolveControlSize,
|
|
7
7
|
resolveIconSize,
|
|
8
8
|
} from '../../../../internal/resolvers';
|
|
9
|
-
import { useTheme } from '../../../../theme/ThemeContext';
|
|
10
9
|
import type { IconButtonProps } from '../../../../types/button';
|
|
11
10
|
import { Icon } from '../../../icon/public';
|
|
12
11
|
import { View } from '../../../layout/public';
|
|
13
12
|
import { Pressable } from '../../../pressable/public';
|
|
13
|
+
import { useTheme } from '../../../theme/runtime';
|
|
14
14
|
|
|
15
15
|
/*** Renders a compact accessible icon-only action control. */
|
|
16
16
|
export function IconButton({
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ViewStyle } from 'react-native';
|
|
3
3
|
|
|
4
|
-
import { useTheme } from '../../../../theme/ThemeContext';
|
|
5
4
|
import type { CardProps } from '../../../../types/card';
|
|
6
5
|
import type { SurfaceVariant } from '../../../../types/surface';
|
|
7
6
|
import { Pressable } from '../../../pressable/public';
|
|
8
7
|
import { Surface } from '../../../surface/public';
|
|
8
|
+
import { useTheme } from '../../../theme/runtime';
|
|
9
9
|
|
|
10
10
|
/*** Renders a themed content card with optional interactive press states. */
|
|
11
11
|
export function Card({
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useMemo, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { FontProviderProps, FontRuntime } from '../../../../types/font';
|
|
4
|
+
import { FontRuntimeContext } from './FontRuntimeContext';
|
|
5
|
+
|
|
6
|
+
/*** Provide loaded-font state and the active font id to Surface theme composition. */
|
|
7
|
+
export function FontProvider({
|
|
8
|
+
fontsLoaded,
|
|
9
|
+
activeFontId: initialActiveFontId = null,
|
|
10
|
+
children,
|
|
11
|
+
onActiveFontChange,
|
|
12
|
+
}: FontProviderProps) {
|
|
13
|
+
const [activeFontId, setActiveFontIdState] = useState(initialActiveFontId);
|
|
14
|
+
const value = useMemo<FontRuntime>(
|
|
15
|
+
() => ({
|
|
16
|
+
fontsLoaded,
|
|
17
|
+
activeFontId,
|
|
18
|
+
setActiveFontId: (id: string) => {
|
|
19
|
+
setActiveFontIdState(id);
|
|
20
|
+
onActiveFontChange?.(id);
|
|
21
|
+
},
|
|
22
|
+
}),
|
|
23
|
+
[activeFontId, fontsLoaded, onActiveFontChange],
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
return <FontRuntimeContext value={value}>{children}</FontRuntimeContext>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { FontRuntime } from '../../../../types/font';
|
|
4
|
+
|
|
5
|
+
const fallbackRuntime: FontRuntime = {
|
|
6
|
+
fontsLoaded: true,
|
|
7
|
+
activeFontId: null,
|
|
8
|
+
setActiveFontId: () => undefined,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/*** Holds Surface font runtime state for theme resolution. */
|
|
12
|
+
export const FontRuntimeContext = createContext<FontRuntime>(fallbackRuntime);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { use } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { FontRuntime } from '../../../../types/font';
|
|
4
|
+
import { FontRuntimeContext } from './FontRuntimeContext';
|
|
5
|
+
|
|
6
|
+
/*** Read the internal font runtime used by Surface theme composition. */
|
|
7
|
+
export function useFontRuntime(): FontRuntime {
|
|
8
|
+
return use(FontRuntimeContext);
|
|
9
|
+
}
|
|
@@ -9,12 +9,12 @@ import {
|
|
|
9
9
|
resolveSelectionControlNextChecked,
|
|
10
10
|
} from '../../../../../internal/resolvers';
|
|
11
11
|
import { useControllableState } from '../../../../../internal/useControllableState';
|
|
12
|
-
import { useTheme } from '../../../../../theme/ThemeContext';
|
|
13
|
-
import type { SurfaceTheme } from '../../../../../theme/types';
|
|
14
12
|
import type { CheckboxProps } from '../../../../../types/checkbox';
|
|
13
|
+
import type { SurfaceTheme } from '../../../../../types/theme';
|
|
15
14
|
import { View } from '../../../../layout/public';
|
|
16
15
|
import type { PressableProps } from '../../../../pressable/public';
|
|
17
16
|
import { Pressable } from '../../../../pressable/public';
|
|
17
|
+
import { useTheme } from '../../../../theme/runtime';
|
|
18
18
|
import { Text } from '../../../../typography/public';
|
|
19
19
|
|
|
20
20
|
/*** Renders a controlled or uncontrolled accessible checkbox. */
|
|
@@ -9,12 +9,12 @@ import {
|
|
|
9
9
|
resolveSelectionControlNextChecked,
|
|
10
10
|
} from '../../../../../internal/resolvers';
|
|
11
11
|
import { useControllableState } from '../../../../../internal/useControllableState';
|
|
12
|
-
import { useTheme } from '../../../../../theme/ThemeContext';
|
|
13
|
-
import type { SurfaceTheme } from '../../../../../theme/types';
|
|
14
12
|
import type { RadioProps } from '../../../../../types/radio';
|
|
13
|
+
import type { SurfaceTheme } from '../../../../../types/theme';
|
|
15
14
|
import { View } from '../../../../layout/public';
|
|
16
15
|
import type { PressableProps } from '../../../../pressable/public';
|
|
17
16
|
import { Pressable } from '../../../../pressable/public';
|
|
17
|
+
import { useTheme } from '../../../../theme/runtime';
|
|
18
18
|
import { Text } from '../../../../typography/public';
|
|
19
19
|
import { isRadioTextContent } from '../../utils/isRadioTextContent';
|
|
20
20
|
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
resolveSelectionControlNextChecked,
|
|
9
9
|
} from '../../../../../internal/resolvers';
|
|
10
10
|
import { useControllableState } from '../../../../../internal/useControllableState';
|
|
11
|
-
import { useTheme } from '../../../../../theme/ThemeContext';
|
|
12
11
|
import type { SwitchProps } from '../../../../../types/switch';
|
|
13
12
|
import { View } from '../../../../layout/public';
|
|
14
13
|
import { Pressable } from '../../../../pressable/public';
|
|
14
|
+
import { useTheme } from '../../../../theme/runtime';
|
|
15
15
|
import { Text } from '../../../../typography/public';
|
|
16
16
|
|
|
17
17
|
/*** Renders a controlled or uncontrolled accessible switch. */
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
} from 'react-native';
|
|
10
10
|
|
|
11
11
|
import { resolveFocusRingStyles } from '../../../../../internal/resolvers';
|
|
12
|
-
import { useTheme } from '../../../../../theme/ThemeContext';
|
|
13
12
|
import type { TextInputProps } from '../../../../../types/text-input';
|
|
13
|
+
import { useTheme } from '../../../../theme/runtime';
|
|
14
14
|
import { resolveTextInputPresentation } from '../../utils/resolveTextInputPresentation';
|
|
15
15
|
|
|
16
16
|
/*** Renders a token-aware text input with controlled interaction policy. */
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
resolveInputColors,
|
|
7
7
|
resolveTextStyles,
|
|
8
8
|
} from '../../../../internal/resolvers';
|
|
9
|
-
import type { SurfaceTheme } from '../../../../theme/types';
|
|
10
9
|
import type { TextInputProps } from '../../../../types/text-input';
|
|
10
|
+
import type { SurfaceTheme } from '../../../../types/theme';
|
|
11
11
|
|
|
12
12
|
/*** Resolves layout, colors, and editability for one TextInput state. */
|
|
13
13
|
export function resolveTextInputPresentation(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { resolveToken } from '../../../../theme/resolveToken';
|
|
2
|
-
import { useTheme } from '../../../../theme/ThemeContext';
|
|
3
1
|
import type { IconProps } from '../../../../types/icon';
|
|
2
|
+
import { useTheme } from '../../../theme/runtime';
|
|
3
|
+
import { resolveToken } from '../../../theme/utils/resolveToken';
|
|
4
4
|
import { PortableIcon } from './PortableIcon';
|
|
5
5
|
|
|
6
6
|
/*** Renders a theme-aware font or SVG icon through the portable icon adapter. */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Image as ReactNativeImage } from 'react-native';
|
|
3
3
|
|
|
4
|
-
import { useTheme } from '../../../../theme/ThemeContext';
|
|
5
4
|
import type { ImageProps } from '../../../../types/image';
|
|
5
|
+
import { useTheme } from '../../../theme/runtime';
|
|
6
6
|
import { getSourceKey } from '../../utils/getSourceKey';
|
|
7
7
|
import { normalizeSource } from '../../utils/normalizeSource';
|
|
8
8
|
import { resolveAccessibilityLabel } from '../../utils/resolveAccessibilityLabel';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it } from 'bun:test';
|
|
2
2
|
|
|
3
|
-
import { createTheme } from '
|
|
3
|
+
import { createTheme } from '../../theme/application/use-cases/createTheme';
|
|
4
4
|
import { getSourceKey } from './getSourceKey';
|
|
5
5
|
import { normalizeSource } from './normalizeSource';
|
|
6
6
|
import { resolveImageStyle } from './resolveImageStyle';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ImageStyle } from 'react-native';
|
|
2
2
|
|
|
3
|
-
import { resolveToken } from '../../../theme/resolveToken';
|
|
4
|
-
import type { SurfaceTheme } from '../../../theme/types';
|
|
5
3
|
import type { ImageProps } from '../../../types/image';
|
|
4
|
+
import type { SurfaceTheme } from '../../../types/theme';
|
|
5
|
+
import { resolveToken } from '../../theme/utils/resolveToken';
|
|
6
6
|
|
|
7
7
|
/*** Resolves token-aware dimensions and radius for a Surface image. */
|
|
8
8
|
export function resolveImageStyle(
|
|
@@ -2,9 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import { View as ReactNativeView, type ViewStyle } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import { resolveResponsive, useResponsiveRuntime } from '../../../../core/responsive';
|
|
5
|
-
import { useTheme } from '../../../../theme/ThemeContext';
|
|
6
5
|
import type { GridProps } from '../../../../types/layout';
|
|
7
6
|
import { resolveSpacing } from '../../../../utils/resolveSpacing';
|
|
7
|
+
import { useTheme } from '../../../theme/runtime';
|
|
8
8
|
import { View } from './View';
|
|
9
9
|
|
|
10
10
|
/*** Lays out children in a responsive wrapping grid. */
|
|
@@ -2,9 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import { ScrollView as ReactNativeScrollView } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import { useResponsiveRuntime } from '../../../../core/responsive';
|
|
5
|
-
import { useTheme } from '../../../../theme/ThemeContext';
|
|
6
5
|
import type { ScrollViewProps } from '../../../../types/layout';
|
|
7
6
|
import { resolveViewStyles } from '../../../../utils/resolveViewStyles';
|
|
7
|
+
import { useTheme } from '../../../theme/runtime';
|
|
8
8
|
|
|
9
9
|
/*** Renders the token-aware responsive Surface adapter for React Native ScrollView. */
|
|
10
10
|
export function ScrollView(props: ScrollViewProps) {
|
|
@@ -3,9 +3,9 @@ import { View as ReactNativeView } from 'react-native';
|
|
|
3
3
|
|
|
4
4
|
import { useResponsiveRuntime } from '../../../../core/responsive';
|
|
5
5
|
import { resolvePointerEvents } from '../../../../internal/resolvePointerEvents';
|
|
6
|
-
import { useTheme } from '../../../../theme/ThemeContext';
|
|
7
6
|
import type { ViewProps } from '../../../../types/layout';
|
|
8
7
|
import { resolveViewStyles } from '../../../../utils/resolveViewStyles';
|
|
8
|
+
import { useTheme } from '../../../theme/runtime';
|
|
9
9
|
|
|
10
10
|
/*** Renders the token-aware responsive Surface adapter for React Native View. */
|
|
11
11
|
export function View({
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import { useTheme } from '../../../../theme/ThemeContext';
|
|
4
|
-
import type { SurfaceTheme } from '../../../../theme/types';
|
|
5
3
|
import type { ListItemProps } from '../../../../types/list';
|
|
4
|
+
import type { SurfaceTheme } from '../../../../types/theme';
|
|
6
5
|
import { View } from '../../../layout/public';
|
|
7
6
|
import { Pressable } from '../../../pressable/public';
|
|
7
|
+
import { useTheme } from '../../../theme/runtime';
|
|
8
8
|
import { Text } from '../../../typography/public';
|
|
9
9
|
|
|
10
10
|
/*** Renders a static or interactive list item with shared row geometry and interaction states. */
|
|
@@ -5,10 +5,10 @@ import { FocusScope } from '../../../../internal/focus/FocusScope';
|
|
|
5
5
|
import { Portal } from '../../../../internal/overlay/Portal';
|
|
6
6
|
import { resolvePointerEvents } from '../../../../internal/resolvePointerEvents';
|
|
7
7
|
import { resolveOverlayAnimation } from '../../../../internal/resolvers';
|
|
8
|
-
import { useTheme } from '../../../../theme/ThemeContext';
|
|
9
8
|
import type { ModalProps } from '../../../../types/modal';
|
|
10
9
|
import { View } from '../../../layout/public';
|
|
11
10
|
import { Surface } from '../../../surface/public';
|
|
11
|
+
import { useTheme } from '../../../theme/runtime';
|
|
12
12
|
|
|
13
13
|
const boxNonePointerEvents = resolvePointerEvents('box-none');
|
|
14
14
|
|
|
@@ -3,11 +3,11 @@ import { Pressable } from 'react-native';
|
|
|
3
3
|
|
|
4
4
|
import { FocusScope } from '../../../../internal/focus/FocusScope';
|
|
5
5
|
import { useFocusManager } from '../../../../internal/focus/useFocusManager';
|
|
6
|
-
import { useTheme } from '../../../../theme/ThemeContext';
|
|
7
6
|
import type { PopoverMenuAction, PopoverMenuProps } from '../../../../types/popoverMenu';
|
|
8
7
|
import { View } from '../../../layout/public';
|
|
9
8
|
import { Popover } from '../../../popover/public';
|
|
10
9
|
import { Surface } from '../../../surface/public';
|
|
10
|
+
import { useTheme } from '../../../theme/runtime';
|
|
11
11
|
import { Text } from '../../../typography/public';
|
|
12
12
|
import { usePopoverMenuController } from '../../composition/usePopoverMenuController';
|
|
13
13
|
import { resolveNextMenuIndex } from '../../utils/resolveNextMenuIndex';
|
|
@@ -11,9 +11,9 @@ import {
|
|
|
11
11
|
resolveFocusRingStyles,
|
|
12
12
|
resolveInteractiveState,
|
|
13
13
|
} from '../../../../internal/resolvers';
|
|
14
|
-
import { useTheme } from '../../../../theme/ThemeContext';
|
|
15
14
|
import type { PressableProps } from '../../../../types/pressable';
|
|
16
15
|
import { resolveViewStyles } from '../../../../utils/resolveViewStyles';
|
|
16
|
+
import { useTheme } from '../../../theme/runtime';
|
|
17
17
|
|
|
18
18
|
/*** Renders the token-aware Surface adapter for React Native Pressable. */
|
|
19
19
|
export function Pressable({
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ViewStyle } from 'react-native';
|
|
3
3
|
|
|
4
|
-
import { useTheme } from '../../../../theme/ThemeContext';
|
|
5
4
|
import type { SurfaceProps, SurfaceVariant } from '../../../../types/surface';
|
|
6
5
|
import { View } from '../../../layout/public';
|
|
6
|
+
import { useTheme } from '../../../theme/runtime';
|
|
7
7
|
|
|
8
8
|
/*** Renders a themed content surface with semantic elevation and border variants. */
|
|
9
9
|
export function Surface({ variant = 'default', radius = 'm', style, ...props }: SurfaceProps) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Pressable, type ViewStyle } from 'react-native';
|
|
3
3
|
|
|
4
|
-
import { useTheme } from '../../../../theme/ThemeContext';
|
|
5
4
|
import type { TabProps } from '../../../../types/tabs';
|
|
6
5
|
import { View } from '../../../layout/public';
|
|
6
|
+
import { useTheme } from '../../../theme/runtime';
|
|
7
7
|
import { Text } from '../../../typography/public';
|
|
8
8
|
import { useTabRegistration } from '../../composition/useTabRegistration';
|
|
9
9
|
import { useTabsContext } from '../../composition/useTabsContext';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ThemeConfig } from '@ankhorage/contracts';
|
|
2
|
+
import { deepMerge } from '@ankhorage/utility/object';
|
|
3
|
+
import { useMemo, useState } from 'react';
|
|
4
|
+
|
|
5
|
+
import { ResponsiveProvider } from '../../../../core/responsive/ResponsiveProvider';
|
|
6
|
+
import { OverlayProvider } from '../../../../internal/overlay/OverlayProvider';
|
|
7
|
+
import type { ThemeProviderProps, ThemeRuntime } from '../../../../types/theme';
|
|
8
|
+
import { useFontRuntime } from '../../../font/adapters/inbound/useFontRuntime';
|
|
9
|
+
import { createTheme } from '../../application/use-cases/createTheme';
|
|
10
|
+
import { ThemeRuntimeContext } from './ThemeRuntimeContext';
|
|
11
|
+
|
|
12
|
+
/*** Install the app-level Surface theme together with global responsive and overlay runtime. */
|
|
13
|
+
export function ThemeProvider({
|
|
14
|
+
children,
|
|
15
|
+
initialConfig,
|
|
16
|
+
initialMode = 'light',
|
|
17
|
+
}: ThemeProviderProps) {
|
|
18
|
+
const defaultTheme = useMemo(() => createTheme(), []);
|
|
19
|
+
const [config, setConfig] = useState<ThemeConfig>(() =>
|
|
20
|
+
initialConfig ? deepMerge(defaultTheme.config, initialConfig) : defaultTheme.config,
|
|
21
|
+
);
|
|
22
|
+
const [mode, setMode] = useState(initialMode);
|
|
23
|
+
const { activeFontId } = useFontRuntime();
|
|
24
|
+
|
|
25
|
+
const theme = useMemo(
|
|
26
|
+
() => createTheme(config, mode, activeFontId),
|
|
27
|
+
[activeFontId, config, mode],
|
|
28
|
+
);
|
|
29
|
+
const value = useMemo<ThemeRuntime>(
|
|
30
|
+
() => ({
|
|
31
|
+
theme,
|
|
32
|
+
mode,
|
|
33
|
+
setThemeConfig: (nextConfig) => setConfig((previous) => deepMerge(previous, nextConfig)),
|
|
34
|
+
setMode,
|
|
35
|
+
}),
|
|
36
|
+
[mode, theme],
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<ResponsiveProvider>
|
|
41
|
+
<ThemeRuntimeContext value={value}>
|
|
42
|
+
<OverlayProvider>{children}</OverlayProvider>
|
|
43
|
+
</ThemeRuntimeContext>
|
|
44
|
+
</ResponsiveProvider>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { ThemeRuntime } from '../../../../types/theme';
|
|
4
|
+
import { createTheme } from '../../application/use-cases/createTheme';
|
|
5
|
+
|
|
6
|
+
const defaultTheme = createTheme();
|
|
7
|
+
|
|
8
|
+
/*** Holds the active Surface theme runtime for component consumption. */
|
|
9
|
+
export const ThemeRuntimeContext = createContext<ThemeRuntime>({
|
|
10
|
+
theme: defaultTheme,
|
|
11
|
+
mode: 'light',
|
|
12
|
+
setThemeConfig: () => undefined,
|
|
13
|
+
setMode: () => undefined,
|
|
14
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { expect, test } from 'bun:test';
|
|
2
|
+
import { renderToStaticMarkup } from 'react-dom/server';
|
|
3
|
+
|
|
4
|
+
import type { ThemeRuntime } from '../../../../types/theme';
|
|
5
|
+
import { createTheme } from '../../application/use-cases/createTheme';
|
|
6
|
+
import { ThemeRuntimeContext } from './ThemeRuntimeContext';
|
|
7
|
+
import { ThemeScope } from './ThemeScope';
|
|
8
|
+
import { useTheme } from './useTheme';
|
|
9
|
+
|
|
10
|
+
function ThemeProbe() {
|
|
11
|
+
const { mode, theme } = useTheme();
|
|
12
|
+
return <span>{`${theme.config.id}:${mode}:${theme.colorDiagnostics.mode}`}</span>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const parentRuntime: ThemeRuntime = {
|
|
16
|
+
theme: createTheme(),
|
|
17
|
+
mode: 'light',
|
|
18
|
+
setThemeConfig: () => undefined,
|
|
19
|
+
setMode: () => undefined,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
test('overrides mode without mutating the parent theme runtime', () => {
|
|
23
|
+
const markup = renderToStaticMarkup(
|
|
24
|
+
<ThemeRuntimeContext value={parentRuntime}>
|
|
25
|
+
<ThemeProbe />
|
|
26
|
+
<ThemeScope mode="dark">
|
|
27
|
+
<ThemeProbe />
|
|
28
|
+
</ThemeScope>
|
|
29
|
+
<ThemeProbe />
|
|
30
|
+
</ThemeRuntimeContext>,
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
expect(markup).toContain('default:light:light');
|
|
34
|
+
expect(markup).toContain('default:dark:dark');
|
|
35
|
+
expect(markup.match(/default:light:light/g)).toHaveLength(2);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('deep-merges a nested config override while preserving the parent config', () => {
|
|
39
|
+
const markup = renderToStaticMarkup(
|
|
40
|
+
<ThemeRuntimeContext value={parentRuntime}>
|
|
41
|
+
<ThemeProbe />
|
|
42
|
+
<ThemeScope themeConfig={{ id: 'scoped' }}>
|
|
43
|
+
<ThemeProbe />
|
|
44
|
+
</ThemeScope>
|
|
45
|
+
<ThemeProbe />
|
|
46
|
+
</ThemeRuntimeContext>,
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
expect(markup).toContain('scoped:light:light');
|
|
50
|
+
expect(markup.match(/default:light:light/g)).toHaveLength(2);
|
|
51
|
+
expect(parentRuntime.theme.config.id).toBe('default');
|
|
52
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { deepMerge } from '@ankhorage/utility/object';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
import type { ThemeRuntime, ThemeScopeProps } from '../../../../types/theme';
|
|
5
|
+
import { useFontRuntime } from '../../../font/adapters/inbound/useFontRuntime';
|
|
6
|
+
import { createTheme } from '../../application/use-cases/createTheme';
|
|
7
|
+
import { ThemeRuntimeContext } from './ThemeRuntimeContext';
|
|
8
|
+
import { useTheme } from './useTheme';
|
|
9
|
+
|
|
10
|
+
/*** Apply a nested Surface theme or mode override without remounting app-level providers. */
|
|
11
|
+
export function ThemeScope({ children, themeConfig, mode }: ThemeScopeProps) {
|
|
12
|
+
const parent = useTheme();
|
|
13
|
+
const { activeFontId } = useFontRuntime();
|
|
14
|
+
const scopedMode = mode ?? parent.mode;
|
|
15
|
+
const scopedConfig = useMemo(
|
|
16
|
+
() => (themeConfig ? deepMerge(parent.theme.config, themeConfig) : parent.theme.config),
|
|
17
|
+
[parent.theme.config, themeConfig],
|
|
18
|
+
);
|
|
19
|
+
const theme = useMemo(
|
|
20
|
+
() => createTheme(scopedConfig, scopedMode, activeFontId),
|
|
21
|
+
[activeFontId, scopedConfig, scopedMode],
|
|
22
|
+
);
|
|
23
|
+
const value = useMemo<ThemeRuntime>(
|
|
24
|
+
() => ({ ...parent, theme, mode: scopedMode }),
|
|
25
|
+
[parent, scopedMode, theme],
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
return <ThemeRuntimeContext value={value}>{children}</ThemeRuntimeContext>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { use } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { ThemeRuntime } from '../../../../types/theme';
|
|
4
|
+
import { ThemeRuntimeContext } from './ThemeRuntimeContext';
|
|
5
|
+
|
|
6
|
+
/*** Read the active Surface theme runtime. */
|
|
7
|
+
export function useTheme(): ThemeRuntime {
|
|
8
|
+
return use(ThemeRuntimeContext);
|
|
9
|
+
}
|