@newtonedev/components 0.1.12 → 0.1.13

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.
Files changed (149) hide show
  1. package/dist/_COMPONENT_TEMPLATE/ComponentName.styles.d.ts +3 -2
  2. package/dist/_COMPONENT_TEMPLATE/ComponentName.styles.d.ts.map +1 -1
  3. package/dist/_COMPONENT_TEMPLATE/ComponentName.types.d.ts +1 -1
  4. package/dist/_COMPONENT_TEMPLATE/ComponentName.types.d.ts.map +1 -1
  5. package/dist/composites/actions/Button/Button.styles.d.ts +1 -1
  6. package/dist/composites/actions/Button/Button.styles.d.ts.map +1 -1
  7. package/dist/composites/form-controls/Select/Select.d.ts.map +1 -1
  8. package/dist/composites/form-controls/Select/Select.styles.d.ts +2 -2
  9. package/dist/composites/form-controls/Select/Select.styles.d.ts.map +1 -1
  10. package/dist/composites/form-controls/Select/SelectOption.d.ts.map +1 -1
  11. package/dist/composites/form-controls/TextInput/TextInput.d.ts.map +1 -1
  12. package/dist/composites/form-controls/TextInput/TextInput.styles.d.ts +2 -2
  13. package/dist/composites/form-controls/TextInput/TextInput.styles.d.ts.map +1 -1
  14. package/dist/composites/form-controls/Toggle/Toggle.styles.d.ts +2 -2
  15. package/dist/composites/form-controls/Toggle/Toggle.styles.d.ts.map +1 -1
  16. package/dist/composites/layout/AppShell/AppShell.styles.d.ts +2 -2
  17. package/dist/composites/layout/AppShell/AppShell.styles.d.ts.map +1 -1
  18. package/dist/composites/layout/Card/Card.styles.d.ts +2 -2
  19. package/dist/composites/layout/Card/Card.styles.d.ts.map +1 -1
  20. package/dist/composites/layout/Card/Card.types.d.ts +1 -1
  21. package/dist/composites/layout/Card/Card.types.d.ts.map +1 -1
  22. package/dist/composites/layout/Navbar/Navbar.styles.d.ts +3 -2
  23. package/dist/composites/layout/Navbar/Navbar.styles.d.ts.map +1 -1
  24. package/dist/composites/layout/Sidebar/Sidebar.styles.d.ts +3 -2
  25. package/dist/composites/layout/Sidebar/Sidebar.styles.d.ts.map +1 -1
  26. package/dist/composites/overlays/Popover/Popover.styles.d.ts +2 -2
  27. package/dist/composites/overlays/Popover/Popover.styles.d.ts.map +1 -1
  28. package/dist/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.d.ts +1 -1
  29. package/dist/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.d.ts.map +1 -1
  30. package/dist/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.styles.d.ts +2 -2
  31. package/dist/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.styles.d.ts.map +1 -1
  32. package/dist/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.types.d.ts +2 -0
  33. package/dist/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.types.d.ts.map +1 -1
  34. package/dist/composites/range-inputs/HueSlider/HueSlider.d.ts +3 -4
  35. package/dist/composites/range-inputs/HueSlider/HueSlider.d.ts.map +1 -1
  36. package/dist/composites/range-inputs/HueSlider/HueSlider.styles.d.ts +4 -4
  37. package/dist/composites/range-inputs/HueSlider/HueSlider.styles.d.ts.map +1 -1
  38. package/dist/composites/range-inputs/Slider/Slider.styles.d.ts +2 -2
  39. package/dist/composites/range-inputs/Slider/Slider.styles.d.ts.map +1 -1
  40. package/dist/index.cjs +1232 -1823
  41. package/dist/index.cjs.map +1 -1
  42. package/dist/index.d.ts +12 -24
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +1084 -1737
  45. package/dist/index.js.map +1 -1
  46. package/dist/primitives/Frame/Frame.d.ts.map +1 -1
  47. package/dist/primitives/Frame/Frame.styles.d.ts +3 -2
  48. package/dist/primitives/Frame/Frame.styles.d.ts.map +1 -1
  49. package/dist/primitives/Frame/Frame.types.d.ts +1 -1
  50. package/dist/primitives/Frame/Frame.types.d.ts.map +1 -1
  51. package/dist/primitives/Frame/Frame.utils.d.ts +1 -1
  52. package/dist/primitives/Frame/Frame.utils.d.ts.map +1 -1
  53. package/dist/primitives/Icon/Icon.d.ts.map +1 -1
  54. package/dist/primitives/Text/Text.d.ts +1 -1
  55. package/dist/primitives/Text/Text.d.ts.map +1 -1
  56. package/dist/primitives/Text/Text.types.d.ts +1 -1
  57. package/dist/primitives/Text/Text.types.d.ts.map +1 -1
  58. package/dist/primitives/Wrapper/Wrapper.styles.d.ts +1 -1
  59. package/dist/primitives/Wrapper/Wrapper.styles.d.ts.map +1 -1
  60. package/package.json +3 -2
  61. package/src/_COMPONENT_TEMPLATE/ComponentName.styles.ts +4 -4
  62. package/src/_COMPONENT_TEMPLATE/ComponentName.tsx +2 -2
  63. package/src/_COMPONENT_TEMPLATE/ComponentName.types.ts +1 -1
  64. package/src/composites/actions/Button/Button.styles.ts +37 -36
  65. package/src/composites/actions/Button/Button.tsx +1 -1
  66. package/src/composites/form-controls/Select/Select.styles.ts +8 -8
  67. package/src/composites/form-controls/Select/Select.tsx +4 -5
  68. package/src/composites/form-controls/Select/SelectOption.tsx +7 -8
  69. package/src/composites/form-controls/TextInput/TextInput.styles.ts +7 -8
  70. package/src/composites/form-controls/TextInput/TextInput.tsx +3 -4
  71. package/src/composites/form-controls/Toggle/Toggle.styles.ts +6 -6
  72. package/src/composites/form-controls/Toggle/Toggle.tsx +2 -2
  73. package/src/composites/layout/AppShell/AppShell.styles.ts +3 -4
  74. package/src/composites/layout/AppShell/AppShell.tsx +2 -2
  75. package/src/composites/layout/Card/Card.styles.ts +4 -5
  76. package/src/composites/layout/Card/Card.tsx +2 -2
  77. package/src/composites/layout/Card/Card.types.ts +1 -1
  78. package/src/composites/layout/Navbar/Navbar.styles.ts +5 -5
  79. package/src/composites/layout/Navbar/Navbar.tsx +2 -2
  80. package/src/composites/layout/Sidebar/Sidebar.styles.ts +5 -5
  81. package/src/composites/layout/Sidebar/Sidebar.tsx +2 -2
  82. package/src/composites/overlays/Popover/Popover.styles.ts +4 -4
  83. package/src/composites/overlays/Popover/Popover.tsx +2 -2
  84. package/src/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.styles.ts +5 -6
  85. package/src/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.tsx +6 -3
  86. package/src/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.types.ts +2 -0
  87. package/src/composites/range-inputs/HueSlider/HueSlider.styles.ts +14 -21
  88. package/src/composites/range-inputs/HueSlider/HueSlider.tsx +8 -9
  89. package/src/composites/range-inputs/Slider/Slider.styles.ts +9 -10
  90. package/src/composites/range-inputs/Slider/Slider.tsx +2 -2
  91. package/src/index.ts +73 -60
  92. package/src/primitives/Frame/Frame.styles.ts +8 -7
  93. package/src/primitives/Frame/Frame.tsx +9 -9
  94. package/src/primitives/Frame/Frame.types.ts +1 -1
  95. package/src/primitives/Frame/Frame.utils.ts +1 -1
  96. package/src/primitives/Icon/Icon.tsx +2 -3
  97. package/src/primitives/Text/Text.spans.ts +1 -1
  98. package/src/primitives/Text/Text.tsx +16 -16
  99. package/src/primitives/Text/Text.types.ts +1 -1
  100. package/src/primitives/Wrapper/Wrapper.styles.ts +1 -1
  101. package/src/primitives/Wrapper/Wrapper.tsx +1 -1
  102. package/dist/fonts/GoogleFontLoader.d.ts +0 -20
  103. package/dist/fonts/GoogleFontLoader.d.ts.map +0 -1
  104. package/dist/fonts/IconFontLoader.d.ts +0 -13
  105. package/dist/fonts/IconFontLoader.d.ts.map +0 -1
  106. package/dist/fonts/SelfHostedFontLoader.d.ts +0 -14
  107. package/dist/fonts/SelfHostedFontLoader.d.ts.map +0 -1
  108. package/dist/fonts/buildGoogleFontsUrl.d.ts +0 -2
  109. package/dist/fonts/buildGoogleFontsUrl.d.ts.map +0 -1
  110. package/dist/fonts/measureFont.d.ts +0 -19
  111. package/dist/fonts/measureFont.d.ts.map +0 -1
  112. package/dist/fonts/reportQueue.d.ts +0 -7
  113. package/dist/fonts/reportQueue.d.ts.map +0 -1
  114. package/dist/fonts/useLocalCalibration.d.ts +0 -19
  115. package/dist/fonts/useLocalCalibration.d.ts.map +0 -1
  116. package/dist/fonts/useTypographyCalibrations.d.ts +0 -11
  117. package/dist/fonts/useTypographyCalibrations.d.ts.map +0 -1
  118. package/dist/theme/FrameContext.d.ts +0 -26
  119. package/dist/theme/FrameContext.d.ts.map +0 -1
  120. package/dist/theme/NewtoneProvider.d.ts +0 -40
  121. package/dist/theme/NewtoneProvider.d.ts.map +0 -1
  122. package/dist/theme/defaults.d.ts +0 -8
  123. package/dist/theme/defaults.d.ts.map +0 -1
  124. package/dist/theme/types.d.ts +0 -156
  125. package/dist/theme/types.d.ts.map +0 -1
  126. package/dist/theme/useBreakpoint.d.ts +0 -9
  127. package/dist/theme/useBreakpoint.d.ts.map +0 -1
  128. package/dist/tokens/computeTokens.d.ts +0 -151
  129. package/dist/tokens/computeTokens.d.ts.map +0 -1
  130. package/dist/tokens/types.d.ts +0 -162
  131. package/dist/tokens/types.d.ts.map +0 -1
  132. package/dist/tokens/useTokens.d.ts +0 -26
  133. package/dist/tokens/useTokens.d.ts.map +0 -1
  134. package/src/fonts/GoogleFontLoader.tsx +0 -80
  135. package/src/fonts/IconFontLoader.tsx +0 -51
  136. package/src/fonts/SelfHostedFontLoader.tsx +0 -44
  137. package/src/fonts/buildGoogleFontsUrl.ts +0 -2
  138. package/src/fonts/measureFont.ts +0 -55
  139. package/src/fonts/reportQueue.ts +0 -54
  140. package/src/fonts/useLocalCalibration.ts +0 -97
  141. package/src/fonts/useTypographyCalibrations.ts +0 -15
  142. package/src/theme/FrameContext.tsx +0 -31
  143. package/src/theme/NewtoneProvider.tsx +0 -84
  144. package/src/theme/defaults.ts +0 -71
  145. package/src/theme/types.ts +0 -191
  146. package/src/theme/useBreakpoint.ts +0 -14
  147. package/src/tokens/computeTokens.ts +0 -516
  148. package/src/tokens/types.ts +0 -146
  149. package/src/tokens/useTokens.ts +0 -62
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { View, Text, Pressable } from 'react-native';
3
3
  import type { ToggleProps } from './Toggle.types';
4
- import { useTokens } from '../../../tokens/useTokens';
4
+ import { useTokens } from 'newtone-api';
5
5
  import { getToggleStyles } from './Toggle.styles';
6
6
 
7
7
  export function Toggle({
@@ -14,7 +14,7 @@ export function Toggle({
14
14
  const tokens = useTokens(1);
15
15
 
16
16
  const styles = React.useMemo(
17
- () => getToggleStyles(tokens, value, disabled),
17
+ () => getToggleStyles(tokens, tokens.gamut, value, disabled),
18
18
  [tokens, value, disabled]
19
19
  );
20
20
 
@@ -1,14 +1,13 @@
1
1
  import { StyleSheet } from 'react-native';
2
- import { srgbToHex } from 'newtone';
3
- import type { ResolvedTokens } from '../../../tokens/types';
2
+ import type { ResolvedTokens, ColorGamut } from 'newtone-api';
4
3
 
5
- export function getAppShellStyles(tokens: ResolvedTokens) {
4
+ export function getAppShellStyles(tokens: ResolvedTokens, gamut: ColorGamut) {
6
5
  return StyleSheet.create({
7
6
  container: {
8
7
  flex: 1,
9
8
  flexDirection: 'row',
10
9
  overflow: 'hidden',
11
- backgroundColor: srgbToHex(tokens.background.srgb),
10
+ backgroundColor: tokens.background[gamut],
12
11
  },
13
12
  main: {
14
13
  flex: 1,
@@ -1,12 +1,12 @@
1
1
  import React from 'react';
2
2
  import { View } from 'react-native';
3
3
  import type { AppShellProps } from './AppShell.types';
4
- import { useTokens } from '../../../tokens/useTokens';
4
+ import { useTokens } from 'newtone-api';
5
5
  import { getAppShellStyles } from './AppShell.styles';
6
6
 
7
7
  export function AppShell({ sidebar, children }: AppShellProps) {
8
8
  const tokens = useTokens();
9
- const styles = React.useMemo(() => getAppShellStyles(tokens), [tokens]);
9
+ const styles = React.useMemo(() => getAppShellStyles(tokens, tokens.gamut), [tokens]);
10
10
 
11
11
  return (
12
12
  <View style={styles.container}>
@@ -1,13 +1,12 @@
1
1
  import { StyleSheet } from 'react-native';
2
- import { srgbToHex } from 'newtone';
3
- import type { ResolvedTokens } from '../../../tokens/types';
2
+ import type { ResolvedTokens, ColorGamut } from 'newtone-api';
4
3
 
5
- export function getCardStyles(tokens: ResolvedTokens, disabled: boolean) {
4
+ export function getCardStyles(tokens: ResolvedTokens, gamut: ColorGamut, disabled: boolean) {
6
5
  return StyleSheet.create({
7
6
  container: {
8
- backgroundColor: srgbToHex(tokens.background.srgb),
7
+ backgroundColor: tokens.background[gamut],
9
8
  borderWidth: 1,
10
- borderColor: srgbToHex(tokens.border.srgb),
9
+ borderColor: tokens.border[gamut],
11
10
  borderRadius: tokens.radius.lg,
12
11
  padding: tokens.spacing['16'],
13
12
  opacity: disabled ? 0.5 : 1,
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { View } from 'react-native';
3
3
  import type { CardProps } from './Card.types';
4
- import { useTokens } from '../../../tokens/useTokens';
4
+ import { useTokens } from 'newtone-api';
5
5
  import { getCardStyles } from './Card.styles';
6
6
 
7
7
  export function Card({
@@ -13,7 +13,7 @@ export function Card({
13
13
  const tokens = useTokens(elevation);
14
14
 
15
15
  const styles = React.useMemo(
16
- () => getCardStyles(tokens, disabled),
16
+ () => getCardStyles(tokens, tokens.gamut, disabled),
17
17
  [tokens, disabled]
18
18
  );
19
19
 
@@ -1,5 +1,5 @@
1
1
  import type { ViewStyle } from 'react-native';
2
- import type { ElevationLevel } from '../../../theme/types';
2
+ import type { ElevationLevel } from 'newtone-api';
3
3
 
4
4
  export interface CardProps {
5
5
  readonly children: React.ReactNode;
@@ -1,15 +1,15 @@
1
1
  import { StyleSheet } from 'react-native';
2
- import { srgbToHex } from 'newtone';
3
- import type { ResolvedTokens } from '../../../tokens/types';
2
+ import type { ResolvedTokens, ColorGamut } from 'newtone-api';
4
3
 
5
4
  interface NavbarStyleInput {
6
5
  readonly tokens: ResolvedTokens;
6
+ readonly gamut: ColorGamut;
7
7
  readonly height: number;
8
8
  readonly bordered: boolean;
9
9
  }
10
10
 
11
- export function getNavbarStyles({ tokens, height, bordered }: NavbarStyleInput) {
12
- const borderColor = srgbToHex(tokens.border.srgb);
11
+ export function getNavbarStyles({ tokens, gamut, height, bordered }: NavbarStyleInput) {
12
+ const borderColor = tokens.border[gamut];
13
13
 
14
14
  return StyleSheet.create({
15
15
  container: {
@@ -18,7 +18,7 @@ export function getNavbarStyles({ tokens, height, bordered }: NavbarStyleInput)
18
18
  height,
19
19
  flexShrink: 0,
20
20
  paddingHorizontal: 24,
21
- backgroundColor: srgbToHex(tokens.background.srgb),
21
+ backgroundColor: tokens.background[gamut],
22
22
  borderBottomWidth: bordered ? 1 : 0,
23
23
  borderBottomColor: borderColor,
24
24
  },
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { View } from 'react-native';
3
3
  import type { NavbarProps } from './Navbar.types';
4
- import { useTokens } from '../../../tokens/useTokens';
4
+ import { useTokens } from 'newtone-api';
5
5
  import { getNavbarStyles } from './Navbar.styles';
6
6
 
7
7
  export function Navbar({
@@ -13,7 +13,7 @@ export function Navbar({
13
13
  }: NavbarProps) {
14
14
  const tokens = useTokens();
15
15
  const styles = React.useMemo(
16
- () => getNavbarStyles({ tokens, height, bordered }),
16
+ () => getNavbarStyles({ tokens, gamut: tokens.gamut, height, bordered }),
17
17
  [tokens, height, bordered]
18
18
  );
19
19
 
@@ -1,22 +1,22 @@
1
1
  import { StyleSheet } from 'react-native';
2
- import { srgbToHex } from 'newtone';
3
- import type { ResolvedTokens } from '../../../tokens/types';
2
+ import type { ResolvedTokens, ColorGamut } from 'newtone-api';
4
3
 
5
4
  interface SidebarStyleInput {
6
5
  readonly tokens: ResolvedTokens;
6
+ readonly gamut: ColorGamut;
7
7
  readonly width: number;
8
8
  readonly bordered: boolean;
9
9
  }
10
10
 
11
- export function getSidebarStyles({ tokens, width, bordered }: SidebarStyleInput) {
12
- const borderColor = srgbToHex(tokens.border.srgb);
11
+ export function getSidebarStyles({ tokens, gamut, width, bordered }: SidebarStyleInput) {
12
+ const borderColor = tokens.border[gamut];
13
13
 
14
14
  return StyleSheet.create({
15
15
  container: {
16
16
  width,
17
17
  flexShrink: 0,
18
18
  flexDirection: 'column',
19
- backgroundColor: srgbToHex(tokens.background.srgb),
19
+ backgroundColor: tokens.background[gamut],
20
20
  borderRightWidth: bordered ? 1 : 0,
21
21
  borderRightColor: borderColor,
22
22
  },
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { View, ScrollView } from 'react-native';
3
3
  import type { SidebarProps } from './Sidebar.types';
4
- import { useTokens } from '../../../tokens/useTokens';
4
+ import { useTokens } from 'newtone-api';
5
5
  import { getSidebarStyles } from './Sidebar.styles';
6
6
 
7
7
  export function Sidebar({
@@ -13,7 +13,7 @@ export function Sidebar({
13
13
  }: SidebarProps) {
14
14
  const tokens = useTokens();
15
15
  const styles = React.useMemo(
16
- () => getSidebarStyles({ tokens, width, bordered }),
16
+ () => getSidebarStyles({ tokens, gamut: tokens.gamut, width, bordered }),
17
17
  [tokens, width, bordered]
18
18
  );
19
19
 
@@ -1,9 +1,9 @@
1
1
  import { StyleSheet } from 'react-native';
2
- import { srgbToHex } from 'newtone';
3
- import type { ResolvedTokens } from '../../../tokens/types';
2
+ import type { ResolvedTokens, ColorGamut } from 'newtone-api';
4
3
 
5
4
  export function getPopoverStyles(
6
5
  tokens: ResolvedTokens,
6
+ gamut: ColorGamut,
7
7
  triggerHeight: number,
8
8
  offset: number,
9
9
  maxHeight: number,
@@ -26,9 +26,9 @@ export function getPopoverStyles(
26
26
  position: 'absolute',
27
27
  top: triggerHeight + offset,
28
28
  ...widthStyle,
29
- backgroundColor: srgbToHex(tokens.backgroundElevated.srgb),
29
+ backgroundColor: tokens.backgroundElevated[gamut],
30
30
  borderWidth: 1,
31
- borderColor: srgbToHex(tokens.border.srgb),
31
+ borderColor: tokens.border[gamut],
32
32
  borderRadius: tokens.radius.md,
33
33
  maxHeight,
34
34
  zIndex: 1000,
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
2
  import { View } from 'react-native';
3
3
  import type { PopoverProps } from './Popover.types';
4
- import { useTokens } from '../../../tokens/useTokens';
4
+ import { useTokens } from 'newtone-api';
5
5
  import { getPopoverStyles } from './Popover.styles';
6
6
 
7
7
  // Module-level: set of close callbacks for all open Popovers.
@@ -68,7 +68,7 @@ export function Popover({
68
68
  );
69
69
 
70
70
  const styles = useMemo(
71
- () => getPopoverStyles(tokens, triggerHeight, offset, maxHeight, width, isOpen),
71
+ () => getPopoverStyles(tokens, tokens.gamut, triggerHeight, offset, maxHeight, width, isOpen),
72
72
  [tokens, triggerHeight, offset, maxHeight, width, isOpen]
73
73
  );
74
74
 
@@ -1,11 +1,10 @@
1
1
  import { StyleSheet } from 'react-native';
2
- import { srgbToHex } from 'newtone';
3
- import type { ResolvedTokens } from '../../../tokens/types';
2
+ import type { ResolvedTokens, ColorGamut } from 'newtone-api';
4
3
 
5
4
  const TRACK_HEIGHT = 22;
6
5
  export const THUMB_SIZE = 18;
7
6
 
8
- export function getColorScaleSliderStyles(tokens: ResolvedTokens, disabled: boolean) {
7
+ export function getColorScaleSliderStyles(tokens: ResolvedTokens, gamut: ColorGamut, disabled: boolean) {
9
8
  return StyleSheet.create({
10
9
  container: {
11
10
  gap: tokens.spacing['04'],
@@ -20,7 +19,7 @@ export function getColorScaleSliderStyles(tokens: ResolvedTokens, disabled: bool
20
19
  fontFamily: tokens.typography.fonts.main.family,
21
20
  fontSize: tokens.typography.fontSizes['04'],
22
21
  fontWeight: tokens.typography.fonts.main.weights.medium as any,
23
- color: srgbToHex(tokens.textSecondary.srgb),
22
+ color: tokens.textSecondary[gamut],
24
23
  },
25
24
  trackContainer: {
26
25
  height: TRACK_HEIGHT + THUMB_SIZE,
@@ -46,13 +45,13 @@ export function getColorScaleSliderStyles(tokens: ResolvedTokens, disabled: bool
46
45
  borderRadius: THUMB_SIZE / 2,
47
46
  backgroundColor: '#ffffff',
48
47
  borderWidth: 2,
49
- borderColor: srgbToHex(tokens.border.srgb),
48
+ borderColor: tokens.border[gamut],
50
49
  },
51
50
  warning: {
52
51
  fontFamily: tokens.typography.fonts.main.family,
53
52
  fontSize: tokens.typography.fontSizes['01'],
54
53
  fontWeight: tokens.typography.fonts.main.weights.medium as any,
55
- color: srgbToHex(tokens.error.fill.srgb),
54
+ color: tokens.error.fill[gamut],
56
55
  },
57
56
  });
58
57
  }
@@ -1,8 +1,10 @@
1
1
  import React from 'react';
2
2
  import { View, Text, PanResponder, Animated } from 'react-native';
3
3
  import { srgbToHex } from 'newtone';
4
+ import { oklchToP3Css } from '@newtonedev/colors';
5
+ import type { Oklch } from '@newtonedev/colors';
4
6
  import type { ColorScaleSliderProps } from './ColorScaleSlider.types';
5
- import { useTokens } from '../../../tokens/useTokens';
7
+ import { useTokens } from 'newtone-api';
6
8
  import { getColorScaleSliderStyles, THUMB_SIZE } from './ColorScaleSlider.styles';
7
9
 
8
10
  /**
@@ -24,12 +26,13 @@ export function ColorScaleSlider({
24
26
  snap = false,
25
27
  disabled = false,
26
28
  animateValue = false,
29
+ useP3: _useP3,
27
30
  style,
28
31
  }: ColorScaleSliderProps) {
29
32
  const tokens = useTokens(1);
30
33
 
31
34
  const styles = React.useMemo(
32
- () => getColorScaleSliderStyles(tokens, disabled),
35
+ () => getColorScaleSliderStyles(tokens, tokens.gamut, disabled),
33
36
  [tokens, disabled]
34
37
  );
35
38
 
@@ -143,7 +146,7 @@ export function ColorScaleSlider({
143
146
  >
144
147
  <View style={styles.gradientTrack}>
145
148
  {visibleColors.map((color, i) => (
146
- <View key={i} style={[styles.segment, { backgroundColor: srgbToHex(color.srgb) }]} />
149
+ <View key={i} style={[styles.segment, { backgroundColor: tokens.gamut === 'p3' ? oklchToP3Css(color.oklch) : srgbToHex(color.srgb) }]} />
147
150
  ))}
148
151
  </View>
149
152
  <Animated.View style={[styles.thumb, { left: thumbAnim }]} />
@@ -20,6 +20,8 @@ export interface ColorScaleSliderProps {
20
20
  readonly disabled?: boolean;
21
21
  /** Animate thumb position on prop-driven value changes (e.g., mode switch). Default: false */
22
22
  readonly animateValue?: boolean;
23
+ /** @deprecated Gamut is now read from context via `useTokens().gamut`. This prop is ignored. */
24
+ readonly useP3?: boolean;
23
25
  /** Optional style override */
24
26
  readonly style?: ViewStyle | ViewStyle[];
25
27
  }
@@ -1,24 +1,17 @@
1
1
  import { StyleSheet } from 'react-native';
2
- import { srgbToHex } from 'newtone';
3
- import type { ResolvedTokens } from '../../../tokens/types';
2
+ import { srgbToHex, gamutMapToSrgb } from 'newtone';
3
+ import type { ResolvedTokens, ColorGamut } from 'newtone-api';
4
4
 
5
5
  const TRACK_HEIGHT = 22;
6
6
  export const THUMB_SIZE = 18;
7
7
  const SEGMENT_COUNT = 48;
8
+ const OKLCH_L = 0.7;
9
+ const OKLCH_C = 0.4;
8
10
 
9
- /** Convert an HSL hue (S=100%, L=50%) to a hex string. */
10
- export function hueToHex(hue: number): string {
11
- const h = ((hue % 360) + 360) % 360;
12
- const x = 1 - Math.abs((h / 60) % 2 - 1);
13
- let r: number, g: number, b: number;
14
- if (h < 60) { r = 1; g = x; b = 0; }
15
- else if (h < 120) { r = x; g = 1; b = 0; }
16
- else if (h < 180) { r = 0; g = 1; b = x; }
17
- else if (h < 240) { r = 0; g = x; b = 1; }
18
- else if (h < 300) { r = x; g = 0; b = 1; }
19
- else { r = 1; g = 0; b = x; }
20
- const toHex = (v: number) => Math.round(v * 255).toString(16).padStart(2, '0');
21
- return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
11
+ /** Convert an OKLCH hue [0, 360) to a hex string via gamut-mapped rendering. */
12
+ export function hueToHex(oklchHue: number): string {
13
+ const { color } = gamutMapToSrgb({ L: OKLCH_L, C: OKLCH_C, h: oklchHue });
14
+ return srgbToHex(color);
22
15
  }
23
16
 
24
17
  /** Build an array of hex colors for the gradient track segments. */
@@ -29,7 +22,7 @@ export function buildHueSegments(min: number, max: number): string[] {
29
22
  });
30
23
  }
31
24
 
32
- export function getHueSliderStyles(tokens: ResolvedTokens, disabled: boolean) {
25
+ export function getHueSliderStyles(tokens: ResolvedTokens, gamut: ColorGamut, disabled: boolean) {
33
26
  return StyleSheet.create({
34
27
  container: {
35
28
  gap: tokens.spacing['04'],
@@ -44,23 +37,23 @@ export function getHueSliderStyles(tokens: ResolvedTokens, disabled: boolean) {
44
37
  fontFamily: tokens.typography.fonts.main.family,
45
38
  fontSize: tokens.typography.fontSizes['04'],
46
39
  fontWeight: tokens.typography.fonts.main.weights.medium as any,
47
- color: srgbToHex(tokens.textSecondary.srgb),
40
+ color: tokens.textSecondary[gamut],
48
41
  },
49
42
  value: {
50
43
  fontFamily: tokens.typography.fonts.main.family,
51
44
  fontSize: tokens.typography.fontSizes['04'],
52
45
  fontWeight: tokens.typography.fonts.main.weights.medium as any,
53
- color: srgbToHex(tokens.textPrimary.srgb),
46
+ color: tokens.textPrimary[gamut],
54
47
  },
55
48
  valueInput: {
56
49
  width: 48,
57
50
  paddingVertical: 0,
58
51
  paddingHorizontal: 4,
59
52
  borderWidth: 1,
60
- borderColor: srgbToHex(tokens.border.srgb),
53
+ borderColor: tokens.border[gamut],
61
54
  borderRadius: 4,
62
55
  backgroundColor: 'transparent',
63
- color: srgbToHex(tokens.textPrimary.srgb),
56
+ color: tokens.textPrimary[gamut],
64
57
  fontFamily: tokens.typography.fonts.main.family,
65
58
  fontSize: tokens.typography.fontSizes['04'],
66
59
  fontWeight: tokens.typography.fonts.main.weights.medium as any,
@@ -90,7 +83,7 @@ export function getHueSliderStyles(tokens: ResolvedTokens, disabled: boolean) {
90
83
  borderRadius: THUMB_SIZE / 2,
91
84
  backgroundColor: '#ffffff',
92
85
  borderWidth: 2,
93
- borderColor: srgbToHex(tokens.border.srgb),
86
+ borderColor: tokens.border[gamut],
94
87
  },
95
88
  });
96
89
  }
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { View, Text, TextInput, PanResponder } from 'react-native';
3
3
  import type { HueSliderProps } from './HueSlider.types';
4
- import { useTokens } from '../../../tokens/useTokens';
4
+ import { useTokens } from 'newtone-api';
5
5
  import {
6
6
  getHueSliderStyles,
7
7
  buildHueSegments,
@@ -11,18 +11,17 @@ import {
11
11
  /**
12
12
  * Hue slider with rainbow gradient track.
13
13
  *
14
- * Value range: 0-359 (traditional color wheel hue).
15
- * 0=red, 60=yellow, 120=green, 180=cyan, 240=blue, 300=magenta.
14
+ * Value range: OKLCH hue [0, 360).
16
15
  *
17
16
  * Optional min/max constrain the selectable range.
18
- * For wrapping ranges (e.g. red: min=345 max=375), max may exceed 359;
19
- * the returned value is always normalized to [0, 359].
17
+ * For wrapping ranges, max may exceed 360;
18
+ * the returned value is always normalized to [0, 360).
20
19
  */
21
20
  export function HueSlider({
22
21
  value,
23
22
  onValueChange,
24
23
  min = 0,
25
- max = 359,
24
+ max = 360,
26
25
  label,
27
26
  showValue = false,
28
27
  editableValue = false,
@@ -32,7 +31,7 @@ export function HueSlider({
32
31
  const tokens = useTokens(1);
33
32
 
34
33
  const styles = React.useMemo(
35
- () => getHueSliderStyles(tokens, disabled),
34
+ () => getHueSliderStyles(tokens, tokens.gamut, disabled),
36
35
  [tokens, disabled]
37
36
  );
38
37
 
@@ -78,8 +77,8 @@ export function HueSlider({
78
77
  })
79
78
  ).current;
80
79
 
81
- // For wrapping ranges (max > 359), convert stored value to slider range
82
- const sliderValue = max > 359 && value < min ? value + 360 : value;
80
+ // For wrapping ranges (max > 360), convert stored value to slider range
81
+ const sliderValue = max > 360 && value < min ? value + 360 : value;
83
82
  const ratio = max > min ? (sliderValue - min) / (max - min) : 0;
84
83
  const usableWidth = Math.max(0, layoutWidth - THUMB_SIZE);
85
84
  const thumbLeft = ratio * usableWidth;
@@ -1,11 +1,10 @@
1
1
  import { StyleSheet } from 'react-native';
2
- import { srgbToHex } from 'newtone';
3
- import type { ResolvedTokens } from '../../../tokens/types';
2
+ import type { ResolvedTokens, ColorGamut } from 'newtone-api';
4
3
 
5
4
  const TRACK_HEIGHT = 6;
6
5
  export const THUMB_SIZE = 16;
7
6
 
8
- export function getSliderStyles(tokens: ResolvedTokens, disabled: boolean) {
7
+ export function getSliderStyles(tokens: ResolvedTokens, gamut: ColorGamut, disabled: boolean) {
9
8
  return StyleSheet.create({
10
9
  container: {
11
10
  gap: tokens.spacing['04'],
@@ -20,23 +19,23 @@ export function getSliderStyles(tokens: ResolvedTokens, disabled: boolean) {
20
19
  fontFamily: tokens.typography.fonts.main.family,
21
20
  fontSize: tokens.typography.fontSizes['04'],
22
21
  fontWeight: tokens.typography.fonts.main.weights.medium as any,
23
- color: srgbToHex(tokens.textSecondary.srgb),
22
+ color: tokens.textSecondary[gamut],
24
23
  },
25
24
  value: {
26
25
  fontFamily: tokens.typography.fonts.main.family,
27
26
  fontSize: tokens.typography.fontSizes['04'],
28
27
  fontWeight: tokens.typography.fonts.main.weights.medium as any,
29
- color: srgbToHex(tokens.textPrimary.srgb),
28
+ color: tokens.textPrimary[gamut],
30
29
  },
31
30
  valueInput: {
32
31
  width: 48,
33
32
  paddingVertical: 0,
34
33
  paddingHorizontal: 4,
35
34
  borderWidth: 1,
36
- borderColor: srgbToHex(tokens.border.srgb),
35
+ borderColor: tokens.border[gamut],
37
36
  borderRadius: 4,
38
37
  backgroundColor: 'transparent',
39
- color: srgbToHex(tokens.textPrimary.srgb),
38
+ color: tokens.textPrimary[gamut],
40
39
  fontFamily: tokens.typography.fonts.main.family,
41
40
  fontSize: tokens.typography.fontSizes['04'],
42
41
  fontWeight: tokens.typography.fonts.main.weights.medium as any,
@@ -53,21 +52,21 @@ export function getSliderStyles(tokens: ResolvedTokens, disabled: boolean) {
53
52
  right: 0,
54
53
  height: TRACK_HEIGHT,
55
54
  borderRadius: TRACK_HEIGHT / 2,
56
- backgroundColor: srgbToHex(tokens.border.srgb),
55
+ backgroundColor: tokens.border[gamut],
57
56
  },
58
57
  trackFill: {
59
58
  position: 'absolute',
60
59
  left: 0,
61
60
  height: TRACK_HEIGHT,
62
61
  borderRadius: TRACK_HEIGHT / 2,
63
- backgroundColor: srgbToHex(tokens.accent.fill.srgb),
62
+ backgroundColor: tokens.accent.fill[gamut],
64
63
  },
65
64
  thumb: {
66
65
  position: 'absolute',
67
66
  width: THUMB_SIZE,
68
67
  height: THUMB_SIZE,
69
68
  borderRadius: THUMB_SIZE / 2,
70
- backgroundColor: srgbToHex(tokens.accent.fill.srgb),
69
+ backgroundColor: tokens.accent.fill[gamut],
71
70
  },
72
71
  });
73
72
  }
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { View, Text, TextInput, PanResponder } from 'react-native';
3
3
  import type { SliderProps } from './Slider.types';
4
- import { useTokens } from '../../../tokens/useTokens';
4
+ import { useTokens } from 'newtone-api';
5
5
  import { getSliderStyles, THUMB_SIZE } from './Slider.styles';
6
6
 
7
7
  export function Slider({
@@ -19,7 +19,7 @@ export function Slider({
19
19
  const tokens = useTokens(1);
20
20
 
21
21
  const styles = React.useMemo(
22
- () => getSliderStyles(tokens, disabled),
22
+ () => getSliderStyles(tokens, tokens.gamut, disabled),
23
23
  [tokens, disabled]
24
24
  );
25
25