@ankhorage/surface 7.0.0 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- 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 +6 -6
- 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 +4 -4
- 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 +4 -4
- 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 +4 -4
- 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 +4 -4
- 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 +4 -4
- 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 +4 -4
- 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 +5 -0
- package/dist/features/pressable/adapters/inbound/Pressable.d.ts.map +1 -0
- package/dist/features/pressable/adapters/inbound/Pressable.js +48 -0
- package/dist/features/pressable/adapters/inbound/Pressable.js.map +1 -0
- package/dist/features/pressable/public.d.ts +3 -0
- package/dist/features/pressable/public.d.ts.map +1 -0
- package/dist/features/pressable/public.js +2 -0
- package/dist/features/pressable/public.js.map +1 -0
- 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 +11 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -7
- 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 +4 -4
- package/dist/types/button.d.ts.map +1 -1
- package/dist/types/button.js.map +1 -1
- package/dist/types/checkbox.d.ts +3 -3
- 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/{primitives/button-base/types.d.ts → types/pressable.d.ts} +5 -5
- package/dist/types/pressable.d.ts.map +1 -0
- package/dist/types/pressable.js +2 -0
- package/dist/types/pressable.js.map +1 -0
- package/dist/types/radio.d.ts +3 -3
- 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 +3 -3
- 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 +8 -7
- 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 +8 -8
- package/src/features/button/adapters/inbound/IconButton.tsx +4 -4
- package/src/features/card/adapters/inbound/Card.tsx +4 -4
- 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 +7 -7
- package/src/features/form/radio/adapters/inbound/Radio.tsx +7 -7
- package/src/features/form/switch/adapters/inbound/Switch.tsx +4 -4
- 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 +5 -5
- package/src/features/modal/adapters/inbound/Modal.tsx +1 -1
- package/src/features/popover-menu/adapters/inbound/PopoverMenu.tsx +1 -1
- package/src/{primitives/button-base/ButtonBase.tsx → features/pressable/adapters/inbound/Pressable.tsx} +45 -31
- package/src/features/pressable/public.ts +2 -0
- 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 +13 -9
- package/src/index.ts +32 -17
- 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 +4 -4
- package/src/types/checkbox.ts +3 -3
- 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/{primitives/button-base/types.ts → types/pressable.ts} +4 -4
- package/src/types/radio.ts +3 -3
- package/src/types/surfaceColor.test.ts +18 -0
- package/src/types/surfaceColor.ts +11 -0
- package/src/types/switch.ts +3 -3
- 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/primitives/button-base/ButtonBase.d.ts +0 -5
- package/dist/primitives/button-base/ButtonBase.d.ts.map +0 -1
- package/dist/primitives/button-base/ButtonBase.js +0 -42
- package/dist/primitives/button-base/ButtonBase.js.map +0 -1
- package/dist/primitives/button-base/index.d.ts +0 -3
- package/dist/primitives/button-base/index.d.ts.map +0 -1
- package/dist/primitives/button-base/index.js +0 -2
- package/dist/primitives/button-base/index.js.map +0 -1
- package/dist/primitives/button-base/types.d.ts.map +0 -1
- package/dist/primitives/button-base/types.js +0 -2
- package/dist/primitives/button-base/types.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/primitives/button-base/index.ts +0 -2
- 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
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import React, { createContext, use, useMemo } from 'react';
|
|
2
|
-
|
|
3
|
-
import { useFontContext } from '../context/FontContext';
|
|
4
|
-
import { ResponsiveProvider } from '../core/responsive/ResponsiveProvider';
|
|
5
|
-
import { OverlayProvider } from '../internal/overlay/OverlayProvider';
|
|
6
|
-
import { isDeepEqual } from '../utils/deepEqual';
|
|
7
|
-
import { deepMerge } from '../utils/deepMerge';
|
|
8
|
-
import { createTheme } from './createTheme';
|
|
9
|
-
import type { SurfaceTheme, ThemeConfig } from './types';
|
|
10
|
-
|
|
11
|
-
const defaultTheme = createTheme();
|
|
12
|
-
|
|
13
|
-
export const ThemeContext = createContext<{
|
|
14
|
-
theme: SurfaceTheme;
|
|
15
|
-
mode: 'light' | 'dark';
|
|
16
|
-
setThemeConfig: (config: Partial<ThemeConfig>) => void;
|
|
17
|
-
setMode: (mode: 'light' | 'dark') => void;
|
|
18
|
-
_hasProvider?: boolean;
|
|
19
|
-
}>({
|
|
20
|
-
theme: defaultTheme,
|
|
21
|
-
mode: 'light',
|
|
22
|
-
setThemeConfig: () => {
|
|
23
|
-
/* fallback */
|
|
24
|
-
},
|
|
25
|
-
setMode: () => {
|
|
26
|
-
/* fallback */
|
|
27
|
-
},
|
|
28
|
-
_hasProvider: false,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export const ThemeProvider = ({
|
|
32
|
-
children,
|
|
33
|
-
initialConfig,
|
|
34
|
-
initialMode = 'light',
|
|
35
|
-
}: {
|
|
36
|
-
children: React.ReactNode;
|
|
37
|
-
initialConfig?: Partial<ThemeConfig>;
|
|
38
|
-
initialMode?: 'light' | 'dark';
|
|
39
|
-
}) => {
|
|
40
|
-
const [config, setConfig] = React.useState<ThemeConfig>(() =>
|
|
41
|
-
initialConfig ? deepMerge(defaultTheme.config, initialConfig) : defaultTheme.config,
|
|
42
|
-
);
|
|
43
|
-
const [mode, setMode] = React.useState<'light' | 'dark'>(initialMode);
|
|
44
|
-
const { activeFontId } = useFontContext();
|
|
45
|
-
|
|
46
|
-
React.useEffect(() => {
|
|
47
|
-
if (initialConfig) {
|
|
48
|
-
setConfig((prev) => {
|
|
49
|
-
const merged = deepMerge(prev, initialConfig);
|
|
50
|
-
if (isDeepEqual(prev, merged)) return prev;
|
|
51
|
-
return merged;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}, [initialConfig]);
|
|
55
|
-
|
|
56
|
-
const theme = useMemo(
|
|
57
|
-
() => createTheme(config, mode, activeFontId),
|
|
58
|
-
[config, mode, activeFontId],
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
const value = useMemo(
|
|
62
|
-
() => ({
|
|
63
|
-
theme,
|
|
64
|
-
mode,
|
|
65
|
-
setThemeConfig: (newConfig: Partial<ThemeConfig>) =>
|
|
66
|
-
setConfig((prev) => deepMerge(prev, newConfig)),
|
|
67
|
-
setMode,
|
|
68
|
-
_hasProvider: true,
|
|
69
|
-
}),
|
|
70
|
-
[theme, mode],
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
return (
|
|
74
|
-
<ResponsiveProvider>
|
|
75
|
-
<ThemeContext value={value}>
|
|
76
|
-
<OverlayProvider>{children}</OverlayProvider>
|
|
77
|
-
</ThemeContext>
|
|
78
|
-
</ResponsiveProvider>
|
|
79
|
-
);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export const useTheme = () => {
|
|
83
|
-
return use(ThemeContext);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export const useThemeConfig = () => {
|
|
87
|
-
const { setThemeConfig } = useTheme();
|
|
88
|
-
return setThemeConfig;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export const useThemeMode = () => {
|
|
92
|
-
const { mode, setMode } = useTheme();
|
|
93
|
-
return { mode, setMode };
|
|
94
|
-
};
|
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
import type { SemanticColorToken } from '@ankhorage/color-theory';
|
|
2
|
-
import {
|
|
3
|
-
COLOR_HARMONIES,
|
|
4
|
-
DARK_SEMANTIC_COLOR_REFERENCES,
|
|
5
|
-
DEFAULT_SEMANTIC_STATUS_COLOR_SEEDS,
|
|
6
|
-
LIGHT_SEMANTIC_COLOR_REFERENCES,
|
|
7
|
-
} from '@ankhorage/color-theory';
|
|
8
|
-
import type { ThemeConfig } from '@ankhorage/contracts';
|
|
9
|
-
import { describe, expect, it } from 'bun:test';
|
|
10
|
-
|
|
11
|
-
import { generatePalette, resolveSemanticColors } from './colorEngine';
|
|
12
|
-
import type { ThemeSemantics } from './types';
|
|
13
|
-
|
|
14
|
-
const mockConfig: ThemeConfig = {
|
|
15
|
-
id: 'test',
|
|
16
|
-
name: 'Test Theme',
|
|
17
|
-
light: {
|
|
18
|
-
primaryColor: '#3B82F6',
|
|
19
|
-
harmony: 'triadic',
|
|
20
|
-
},
|
|
21
|
-
dark: {
|
|
22
|
-
primaryColor: '#3B82F6',
|
|
23
|
-
harmony: 'triadic',
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
function expectCompleteSemanticValues(semantics: ThemeSemantics) {
|
|
28
|
-
visitSemanticValues(semantics);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function visitSemanticValues(value: object): void {
|
|
32
|
-
for (const entry of Object.values(value)) {
|
|
33
|
-
if (typeof entry === 'string') {
|
|
34
|
-
expect(entry.length).toBeGreaterThan(0);
|
|
35
|
-
} else {
|
|
36
|
-
visitSemanticValues(entry as object);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
describe('colorEngine', () => {
|
|
42
|
-
it('generates a valid palette for light mode', () => {
|
|
43
|
-
const { colors, swatches, semantics } = generatePalette(mockConfig, 'light');
|
|
44
|
-
|
|
45
|
-
expect(colors.primary).toBeDefined();
|
|
46
|
-
expect(swatches.primary).toBeDefined();
|
|
47
|
-
expect(swatches.neutral).toBeDefined();
|
|
48
|
-
expect(Object.keys(swatches.primary)).toHaveLength(11);
|
|
49
|
-
expect(Object.keys(swatches.neutral)).toHaveLength(11);
|
|
50
|
-
|
|
51
|
-
// Surface semantic aliases
|
|
52
|
-
expect(semantics.surface.default).toBe(semantics.neutral.surface);
|
|
53
|
-
expect(semantics.content.muted).toBe(semantics.neutral.textMuted);
|
|
54
|
-
expect(semantics.border.focus).toBe(semantics.brand.outline);
|
|
55
|
-
expect(semantics.action.primary.base).toBe(semantics.brand.base);
|
|
56
|
-
expect(semantics.action.danger.base).toBe(semantics.danger.base);
|
|
57
|
-
|
|
58
|
-
// Surface runtime semantic aliases derived from ordinal swatches
|
|
59
|
-
expect(semantics.accent.base).toBeDefined();
|
|
60
|
-
expect(semantics.highlight.base).toBeDefined();
|
|
61
|
-
// accent/highlight are Surface semantic aliases (tertiary/quaternary fallback to primary when absent)
|
|
62
|
-
expect(semantics.accent.base).toBe(colors.accent);
|
|
63
|
-
expect(semantics.highlight.base).toBe(colors.highlight);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('generates a valid palette for dark mode', () => {
|
|
67
|
-
const { colors, swatches, semantics } = generatePalette(mockConfig, 'dark');
|
|
68
|
-
|
|
69
|
-
expect(colors.background).toBe(semantics.neutral.bg);
|
|
70
|
-
expect(semantics.surface.inverse).toBe(swatches.neutral[50]);
|
|
71
|
-
expect(semantics.content.inverse).toBe(swatches.neutral[900]);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('uses the Color Theory status owner independently from brand harmony', () => {
|
|
75
|
-
const statusConfig: ThemeConfig = {
|
|
76
|
-
...mockConfig,
|
|
77
|
-
light: { primaryColor: '#dc2626', harmony: 'monochromatic' },
|
|
78
|
-
dark: { primaryColor: '#dc2626', harmony: 'monochromatic' },
|
|
79
|
-
};
|
|
80
|
-
const light = generatePalette(statusConfig, 'light');
|
|
81
|
-
const dark = generatePalette(statusConfig, 'dark');
|
|
82
|
-
|
|
83
|
-
expect(light.semantics.danger.base).toBe('#ef4444');
|
|
84
|
-
expect(light.semantics.success.base).toBe('#22c55e');
|
|
85
|
-
expect(light.semantics.warning.base).toBe('#f59e0b');
|
|
86
|
-
expect(light.semantics.error.base).toBe(light.semantics.danger.base);
|
|
87
|
-
expect(light.semantics.info.base).toBe(DEFAULT_SEMANTIC_STATUS_COLOR_SEEDS.info);
|
|
88
|
-
expect(light.semantics.info.base).not.toBe(light.semantics.brand.base);
|
|
89
|
-
|
|
90
|
-
expect(dark.semantics.danger.base).toBe('#ef4444');
|
|
91
|
-
expect(dark.semantics.success.base).toBe('#22c55e');
|
|
92
|
-
expect(dark.semantics.warning.base).toBe('#f59e0b');
|
|
93
|
-
expect(dark.semantics.error.base).toBe(dark.semantics.danger.base);
|
|
94
|
-
expect(dark.semantics.info.base).toBe(DEFAULT_SEMANTIC_STATUS_COLOR_SEEDS.info);
|
|
95
|
-
expect(dark.semantics.info.base).not.toBe(dark.semantics.brand.base);
|
|
96
|
-
expect(light.semantics.error).toBe(light.semantics.danger);
|
|
97
|
-
expect(dark.semantics.error).toBe(dark.semantics.danger);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('uses mode-aware role semantics for dark mode soft states', () => {
|
|
101
|
-
const light = generatePalette(mockConfig, 'light');
|
|
102
|
-
const dark = generatePalette(mockConfig, 'dark');
|
|
103
|
-
|
|
104
|
-
expect(light.semantics.brand.softBg).toBe(light.swatches.primary[100]);
|
|
105
|
-
expect(light.semantics.brand.softHover).toBe(light.swatches.primary[200]);
|
|
106
|
-
expect(light.semantics.brand.softActive).toBe(light.swatches.primary[300]);
|
|
107
|
-
expect(dark.semantics.brand.softBg).toBe(dark.swatches.primary[900]);
|
|
108
|
-
expect(dark.semantics.brand.softHover).toBe(dark.swatches.primary[800]);
|
|
109
|
-
expect(dark.semantics.brand.softActive).toBe(dark.swatches.primary[700]);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it('preserves the primary color at swatch step 500 in light mode', () => {
|
|
113
|
-
const { swatches } = generatePalette(mockConfig, 'light');
|
|
114
|
-
expect(String(swatches.primary[500])).toBe(mockConfig.light.primaryColor);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it('preserves the primary color at swatch step 500 in dark mode', () => {
|
|
118
|
-
const { swatches } = generatePalette(mockConfig, 'dark');
|
|
119
|
-
expect(String(swatches.primary[500])).toBe(mockConfig.dark.primaryColor);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it('provides a neutral swatch with neutralKeyColor at step 500', () => {
|
|
123
|
-
const { swatches } = generatePalette(mockConfig, 'light');
|
|
124
|
-
// neutral swatch must have a step 500 entry
|
|
125
|
-
expect(swatches.neutral[500]).toBeDefined();
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it('throws deterministically on invalid primary color', () => {
|
|
129
|
-
const config = {
|
|
130
|
-
...mockConfig,
|
|
131
|
-
light: { ...mockConfig.light, primaryColor: 'not-a-hex-color' },
|
|
132
|
-
};
|
|
133
|
-
expect(() => generatePalette(config, 'light')).toThrow();
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it('throws deterministically on invalid primary color in dark mode', () => {
|
|
137
|
-
const config = {
|
|
138
|
-
...mockConfig,
|
|
139
|
-
dark: { ...mockConfig.dark, primaryColor: 'rgb(0,0,0)' },
|
|
140
|
-
};
|
|
141
|
-
expect(() => generatePalette(config, 'dark')).toThrow();
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it('emits required semantic roles for all harmonies', () => {
|
|
145
|
-
for (const harmony of COLOR_HARMONIES) {
|
|
146
|
-
const config = {
|
|
147
|
-
...mockConfig,
|
|
148
|
-
light: { ...mockConfig.light, harmony },
|
|
149
|
-
dark: { ...mockConfig.dark, harmony },
|
|
150
|
-
};
|
|
151
|
-
const light = generatePalette(config, 'light');
|
|
152
|
-
const dark = generatePalette(config, 'dark');
|
|
153
|
-
expectCompleteSemanticValues(light.semantics);
|
|
154
|
-
expectCompleteSemanticValues(dark.semantics);
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it('resolves canonical semantic references and returns their selected steps', () => {
|
|
159
|
-
const light = generatePalette(mockConfig, 'light');
|
|
160
|
-
const dark = generatePalette(mockConfig, 'dark');
|
|
161
|
-
|
|
162
|
-
expect(light.colorDiagnostics.semanticReferences).toBe(LIGHT_SEMANTIC_COLOR_REFERENCES);
|
|
163
|
-
expect(dark.colorDiagnostics.semanticReferences).toBe(DARK_SEMANTIC_COLOR_REFERENCES);
|
|
164
|
-
expect(light.colorDiagnostics.generated.swatches).toBe(light.swatches);
|
|
165
|
-
expect(dark.colorDiagnostics.generated.swatches).toBe(dark.swatches);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it('returns measured selections and contrast diagnostics for both modes', () => {
|
|
169
|
-
for (const mode of ['light', 'dark'] as const) {
|
|
170
|
-
const palette = generatePalette(mockConfig, mode);
|
|
171
|
-
|
|
172
|
-
expect(palette.colorDiagnostics.selections.length).toBeGreaterThan(0);
|
|
173
|
-
expect(
|
|
174
|
-
palette.colorDiagnostics.selections.every(({ result }) => result.selected !== null),
|
|
175
|
-
).toBe(true);
|
|
176
|
-
expect(palette.colorDiagnostics.contrasts.length).toBeGreaterThan(0);
|
|
177
|
-
expect(palette.colorDiagnostics.contrasts.every(({ passes }) => passes)).toBe(true);
|
|
178
|
-
expect(palette.colorDiagnostics.surfaceSeparation.length).toBeGreaterThan(0);
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it('reports neutral and surface-separation evidence without hiding failed separation', () => {
|
|
183
|
-
const palette = generatePalette(mockConfig, 'light');
|
|
184
|
-
const failedSeparation = palette.colorDiagnostics.surfaceSeparation.find(
|
|
185
|
-
({ passes }) => !passes,
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
expect(palette.colorDiagnostics.generated.neutral.neutralKeyColor).toBe(
|
|
189
|
-
palette.swatches.neutral[500],
|
|
190
|
-
);
|
|
191
|
-
expect(palette.colorDiagnostics.generated.neutral.diagnostics.isUsable).toBeBoolean();
|
|
192
|
-
expect(failedSeparation).toBeDefined();
|
|
193
|
-
expect(failedSeparation?.contrast).toBeLessThan(failedSeparation?.minimumContrast ?? 0);
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
it('preserves owner diagnostics for achromatic and low-chroma inputs', () => {
|
|
197
|
-
const achromaticConfig: ThemeConfig = {
|
|
198
|
-
...mockConfig,
|
|
199
|
-
light: { primaryColor: '#777777', harmony: 'square' },
|
|
200
|
-
};
|
|
201
|
-
const palette = generatePalette(achromaticConfig, 'light');
|
|
202
|
-
|
|
203
|
-
expect(palette.colorDiagnostics.generated.harmonyRoleColors.diagnostics.isHueReliable).toBe(
|
|
204
|
-
false,
|
|
205
|
-
);
|
|
206
|
-
expect(
|
|
207
|
-
palette.colorDiagnostics.generated.harmonyRoleColors.diagnostics.warnings.length,
|
|
208
|
-
).toBeGreaterThan(0);
|
|
209
|
-
expect(palette.colorDiagnostics.generated.neutral.diagnostics).toBeDefined();
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
it('generates ordinal chromatic role swatches (no accent/highlight as swatch keys)', () => {
|
|
213
|
-
const { swatches } = generatePalette(mockConfig, 'light');
|
|
214
|
-
const keys = Object.keys(swatches);
|
|
215
|
-
expect(keys).not.toContain('accent');
|
|
216
|
-
expect(keys).not.toContain('highlight');
|
|
217
|
-
expect(keys).not.toContain('surfaceTint');
|
|
218
|
-
expect(keys).not.toContain('base');
|
|
219
|
-
// ordinal roles are present
|
|
220
|
-
expect(keys).toContain('primary');
|
|
221
|
-
expect(keys).toContain('neutral');
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
it('semantic resolver maps all SemanticColorToken entries for light mode', () => {
|
|
225
|
-
const { swatches } = generatePalette(mockConfig, 'light');
|
|
226
|
-
// Build a minimal GeneratedThemeModeColors for resolver testing
|
|
227
|
-
const generated = {
|
|
228
|
-
harmonyRoleColors: {} as never,
|
|
229
|
-
swatches,
|
|
230
|
-
neutral: { neutralKeyColor: swatches.neutral[500], diagnostics: {} as never },
|
|
231
|
-
};
|
|
232
|
-
const resolved = resolveSemanticColors(generated, LIGHT_SEMANTIC_COLOR_REFERENCES);
|
|
233
|
-
const tokens: SemanticColorToken[] = [
|
|
234
|
-
'background',
|
|
235
|
-
'surface',
|
|
236
|
-
'surfaceRaised',
|
|
237
|
-
'border',
|
|
238
|
-
'divider',
|
|
239
|
-
'text',
|
|
240
|
-
'textMuted',
|
|
241
|
-
'disabledBg',
|
|
242
|
-
'disabledText',
|
|
243
|
-
'brand',
|
|
244
|
-
'brandEmphasis',
|
|
245
|
-
'action',
|
|
246
|
-
'actionEmphasis',
|
|
247
|
-
];
|
|
248
|
-
for (const token of tokens) {
|
|
249
|
-
expect(resolved[token]).toBeDefined();
|
|
250
|
-
expect(typeof resolved[token]).toBe('string');
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it('semantic resolver maps all SemanticColorToken entries for dark mode', () => {
|
|
255
|
-
const { swatches } = generatePalette(mockConfig, 'dark');
|
|
256
|
-
const generated = {
|
|
257
|
-
harmonyRoleColors: {} as never,
|
|
258
|
-
swatches,
|
|
259
|
-
neutral: { neutralKeyColor: swatches.neutral[500], diagnostics: {} as never },
|
|
260
|
-
};
|
|
261
|
-
const resolved = resolveSemanticColors(generated, DARK_SEMANTIC_COLOR_REFERENCES);
|
|
262
|
-
const tokens: SemanticColorToken[] = [
|
|
263
|
-
'background',
|
|
264
|
-
'surface',
|
|
265
|
-
'surfaceRaised',
|
|
266
|
-
'border',
|
|
267
|
-
'divider',
|
|
268
|
-
'text',
|
|
269
|
-
'textMuted',
|
|
270
|
-
'disabledBg',
|
|
271
|
-
'disabledText',
|
|
272
|
-
'brand',
|
|
273
|
-
'brandEmphasis',
|
|
274
|
-
'action',
|
|
275
|
-
'actionEmphasis',
|
|
276
|
-
];
|
|
277
|
-
for (const token of tokens) {
|
|
278
|
-
expect(resolved[token]).toBeDefined();
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
it('neutral semantics power backgrounds, borders, text in light mode', () => {
|
|
283
|
-
const { semantics } = generatePalette(mockConfig, 'light');
|
|
284
|
-
expect(semantics.neutral.bg).toBeDefined();
|
|
285
|
-
expect(semantics.neutral.bgSubtle).toBeDefined();
|
|
286
|
-
expect(semantics.neutral.surface).toBeDefined();
|
|
287
|
-
expect(semantics.neutral.surfaceHover).toBeDefined();
|
|
288
|
-
expect(semantics.neutral.border).toBeDefined();
|
|
289
|
-
expect(semantics.neutral.borderStrong).toBeDefined();
|
|
290
|
-
expect(semantics.neutral.divider).toBeDefined();
|
|
291
|
-
expect(semantics.neutral.text).toBeDefined();
|
|
292
|
-
expect(semantics.neutral.textMuted).toBeDefined();
|
|
293
|
-
expect(semantics.neutral.textSubtle).toBeDefined();
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
it('readable foregrounds are generated for brand base in both modes', () => {
|
|
297
|
-
const light = generatePalette(mockConfig, 'light');
|
|
298
|
-
const dark = generatePalette(mockConfig, 'dark');
|
|
299
|
-
expect(light.semantics.brand.onSolidText).toMatch(/^#/);
|
|
300
|
-
expect(dark.semantics.brand.onSolidText).toMatch(/^#/);
|
|
301
|
-
});
|
|
302
|
-
});
|
package/src/theme/createTheme.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { generatePalette } from './colorEngine';
|
|
2
|
-
import { resolveGlobalTokens } from './resolveGlobalTokens';
|
|
3
|
-
import type { FontWeight, SurfaceTheme, ThemeConfig } from './types';
|
|
4
|
-
|
|
5
|
-
export { DEFAULT_TOKENS } from './defaultTokens';
|
|
6
|
-
|
|
7
|
-
export const DEFAULT_CONFIG: ThemeConfig = {
|
|
8
|
-
id: 'default',
|
|
9
|
-
name: 'Default',
|
|
10
|
-
light: { primaryColor: '#3B82F6', harmony: 'monochromatic' },
|
|
11
|
-
dark: { primaryColor: '#3B82F6', harmony: 'monochromatic' },
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const ACTIVE_FONT_WEIGHTS: readonly FontWeight[] = [
|
|
15
|
-
'100',
|
|
16
|
-
'200',
|
|
17
|
-
'300',
|
|
18
|
-
'400',
|
|
19
|
-
'500',
|
|
20
|
-
'600',
|
|
21
|
-
'700',
|
|
22
|
-
'800',
|
|
23
|
-
'900',
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
export function createTheme(
|
|
27
|
-
config: ThemeConfig = DEFAULT_CONFIG,
|
|
28
|
-
mode: 'light' | 'dark' = 'light',
|
|
29
|
-
activeFontId?: string | null,
|
|
30
|
-
): SurfaceTheme {
|
|
31
|
-
const { colors, swatches, semantics, colorDiagnostics } = generatePalette(config, mode);
|
|
32
|
-
const theme: SurfaceTheme = {
|
|
33
|
-
...resolveGlobalTokens(config.tokens),
|
|
34
|
-
colors,
|
|
35
|
-
swatches,
|
|
36
|
-
semantics,
|
|
37
|
-
colorDiagnostics,
|
|
38
|
-
config,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
applyActiveFont(theme, activeFontId);
|
|
42
|
-
return theme;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function applyActiveFont(theme: SurfaceTheme, activeFontId: string | null | undefined): void {
|
|
46
|
-
if (!activeFontId) return;
|
|
47
|
-
|
|
48
|
-
const familyName = toPascalCase(activeFontId);
|
|
49
|
-
for (const weight of ACTIVE_FONT_WEIGHTS) {
|
|
50
|
-
theme.typography.fonts.normal[weight] = `${familyName}_${weight}Regular`;
|
|
51
|
-
theme.typography.fonts.italic[weight] = `${familyName}_${weight}Italic`;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function toPascalCase(value: string): string {
|
|
56
|
-
return value
|
|
57
|
-
.split(/[- ]+/)
|
|
58
|
-
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
59
|
-
.join('');
|
|
60
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { FontWeight, ThemeTokens } from './types';
|
|
2
|
-
|
|
3
|
-
const EMPTY_FONT_MAP: Record<FontWeight, string | undefined> = {
|
|
4
|
-
'100': undefined,
|
|
5
|
-
'200': undefined,
|
|
6
|
-
'300': undefined,
|
|
7
|
-
'400': undefined,
|
|
8
|
-
'500': undefined,
|
|
9
|
-
'600': undefined,
|
|
10
|
-
'700': undefined,
|
|
11
|
-
'800': undefined,
|
|
12
|
-
'900': undefined,
|
|
13
|
-
bold: undefined,
|
|
14
|
-
normal: undefined,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const DEFAULT_TOKENS: Omit<
|
|
18
|
-
ThemeTokens,
|
|
19
|
-
'colors' | 'swatches' | 'semantics' | 'colorDiagnostics'
|
|
20
|
-
> = {
|
|
21
|
-
spacing: { none: 0, xs: 4, s: 8, m: 16, l: 24, xl: 32, xxl: 48 },
|
|
22
|
-
radii: { none: 0, s: 4, m: 8, l: 16, full: 9999 },
|
|
23
|
-
typography: {
|
|
24
|
-
headings: {
|
|
25
|
-
1: { size: 32, lineHeight: 40, weight: 'bold' },
|
|
26
|
-
2: { size: 24, lineHeight: 32, weight: 'bold' },
|
|
27
|
-
3: { size: 20, lineHeight: 28, weight: 'bold' },
|
|
28
|
-
4: { size: 18, lineHeight: 24, weight: 'semiBold' },
|
|
29
|
-
5: { size: 16, lineHeight: 22, weight: 'semiBold' },
|
|
30
|
-
6: { size: 14, lineHeight: 20, weight: 'semiBold' },
|
|
31
|
-
},
|
|
32
|
-
sizes: {
|
|
33
|
-
xs: 12,
|
|
34
|
-
s: 14,
|
|
35
|
-
m: 16,
|
|
36
|
-
l: 18,
|
|
37
|
-
xl: 20,
|
|
38
|
-
xxl: 24,
|
|
39
|
-
'3xl': 30,
|
|
40
|
-
h1: 32,
|
|
41
|
-
h2: 24,
|
|
42
|
-
h3: 20,
|
|
43
|
-
h4: 18,
|
|
44
|
-
h5: 16,
|
|
45
|
-
h6: 14,
|
|
46
|
-
},
|
|
47
|
-
weights: {
|
|
48
|
-
thin: '100',
|
|
49
|
-
extraLight: '200',
|
|
50
|
-
light: '300',
|
|
51
|
-
regular: '400',
|
|
52
|
-
medium: '500',
|
|
53
|
-
semiBold: '600',
|
|
54
|
-
bold: '700',
|
|
55
|
-
extraBold: '800',
|
|
56
|
-
black: '900',
|
|
57
|
-
},
|
|
58
|
-
fonts: { normal: { ...EMPTY_FONT_MAP }, italic: { ...EMPTY_FONT_MAP } },
|
|
59
|
-
},
|
|
60
|
-
shadows: { soft: 2, medium: 4, hard: 8 },
|
|
61
|
-
};
|
package/src/theme/index.ts
DELETED
package/src/theme/public.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 1. Define the Conditional Logic
|
|
3
|
-
* If TValue is a key of TMap, return the map's value type.
|
|
4
|
-
* Otherwise, return TValue itself.
|
|
5
|
-
*/
|
|
6
|
-
type ResolvedToken<TMap, TValue> = TValue extends keyof TMap ? TMap[TValue] : TValue;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 2. The Generic Function
|
|
10
|
-
*/
|
|
11
|
-
export function resolveToken<
|
|
12
|
-
TMap extends Record<string | number, unknown>,
|
|
13
|
-
TValue extends string | number | undefined,
|
|
14
|
-
>(map: TMap, value: TValue): ResolvedToken<TMap, TValue> {
|
|
15
|
-
// Undefined check
|
|
16
|
-
if (value === undefined) {
|
|
17
|
-
return undefined as ResolvedToken<TMap, TValue>;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Runtime check: Is 'value' a key in 'map'?
|
|
21
|
-
if (
|
|
22
|
-
(typeof value === 'string' || typeof value === 'number') &&
|
|
23
|
-
Object.prototype.hasOwnProperty.call(map, value)
|
|
24
|
-
) {
|
|
25
|
-
// Return the mapped token
|
|
26
|
-
// We cast to the specific conditional type, strictly safer than 'any'
|
|
27
|
-
return map[value as keyof TMap] as ResolvedToken<TMap, TValue>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Fallback: Return raw value
|
|
31
|
-
return value as ResolvedToken<TMap, TValue>;
|
|
32
|
-
}
|
package/src/utils/deepEqual.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Simple deep equality check for JSON-serializable objects.
|
|
3
|
-
* Efficient enough for UI manifests.
|
|
4
|
-
*/
|
|
5
|
-
export const isDeepEqual = (a: unknown, b: unknown): boolean => {
|
|
6
|
-
if (a === b) return true;
|
|
7
|
-
|
|
8
|
-
if (a && b && typeof a === 'object' && typeof b === 'object') {
|
|
9
|
-
if (Array.isArray(a)) {
|
|
10
|
-
if (!Array.isArray(b) || a.length !== b.length) return false;
|
|
11
|
-
for (let i = 0; i < a.length; i++) {
|
|
12
|
-
if (!isDeepEqual(a[i], b[i])) return false;
|
|
13
|
-
}
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (Array.isArray(b)) return false;
|
|
18
|
-
|
|
19
|
-
const keysA = Object.keys(a);
|
|
20
|
-
const keysB = Object.keys(b);
|
|
21
|
-
if (keysA.length !== keysB.length) return false;
|
|
22
|
-
|
|
23
|
-
const objA = a as Record<string, unknown>;
|
|
24
|
-
const objB = b as Record<string, unknown>;
|
|
25
|
-
|
|
26
|
-
for (const key of keysA) {
|
|
27
|
-
if (!Object.prototype.hasOwnProperty.call(objB, key)) return false;
|
|
28
|
-
if (!isDeepEqual(objA[key], objB[key])) return false;
|
|
29
|
-
}
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return Number.isNaN(a) && Number.isNaN(b);
|
|
34
|
-
};
|