@terreno/ui 0.20.1 → 0.21.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/src/Card.test.tsx CHANGED
@@ -1,61 +1,183 @@
1
- import {describe, expect, it} from "bun:test";
1
+ import {describe, expect, it, mock} from "bun:test";
2
+ import type {ScaledSize} from "react-native";
3
+ import {useWindowDimensions} from "react-native";
4
+ import type {ReactTestRendererJSON} from "react-test-renderer";
2
5
 
3
6
  import {Card} from "./Card";
4
7
  import {Text} from "./Text";
5
8
  import {renderWithTheme} from "./test-utils";
6
9
 
7
- describe("Card", () => {
8
- it("renders correctly with default props", () => {
9
- const {toJSON} = renderWithTheme(
10
- <Card>
11
- <Text>Card content</Text>
12
- </Card>
13
- );
14
- expect(toJSON()).toMatchSnapshot();
15
- });
10
+ type WindowDimensionsImpl = () => ScaledSize;
11
+ type MockableUseWindowDimensions = WindowDimensionsImpl & {
12
+ mockImplementation?: (impl: WindowDimensionsImpl) => void;
13
+ };
16
14
 
17
- it("renders children correctly", () => {
18
- const {getByText} = renderWithTheme(
19
- <Card>
20
- <Text>Test content</Text>
21
- </Card>
22
- );
23
- expect(getByText("Test content")).toBeTruthy();
15
+ const getScaledSize =
16
+ (width: number): WindowDimensionsImpl =>
17
+ (): ScaledSize => ({
18
+ fontScale: 1,
19
+ height: 1000,
20
+ scale: 2,
21
+ width,
24
22
  });
25
23
 
26
- it("applies custom padding", () => {
27
- const {toJSON} = renderWithTheme(
28
- <Card padding={8}>
29
- <Text>Content</Text>
30
- </Card>
31
- );
32
- expect(toJSON()).toMatchSnapshot();
33
- });
24
+ const setWindowWidth = (width: number): (() => void) => {
25
+ const useWindowDimensionsMock = useWindowDimensions as MockableUseWindowDimensions;
26
+ const dimensionsImpl = getScaledSize(width);
34
27
 
35
- it("applies custom color", () => {
36
- const {toJSON} = renderWithTheme(
37
- <Card color="secondary">
38
- <Text>Content</Text>
39
- </Card>
40
- );
41
- expect(toJSON()).toMatchSnapshot();
42
- });
28
+ if (typeof useWindowDimensionsMock.mockImplementation === "function") {
29
+ useWindowDimensionsMock.mockImplementation(dimensionsImpl);
30
+
31
+ return (): void => {
32
+ useWindowDimensionsMock.mockImplementation(getScaledSize(375));
33
+ };
34
+ }
35
+
36
+ return (): void => {};
37
+ };
38
+
39
+ describe("Card", () => {
40
+ describe("container variant (default)", () => {
41
+ it("renders correctly with default props", () => {
42
+ const {toJSON} = renderWithTheme(
43
+ <Card>
44
+ <Text>Card content</Text>
45
+ </Card>
46
+ );
47
+ expect(toJSON()).toMatchSnapshot();
48
+ });
49
+
50
+ it("renders children correctly", () => {
51
+ const {getByText} = renderWithTheme(
52
+ <Card>
53
+ <Text>Test content</Text>
54
+ </Card>
55
+ );
56
+ expect(getByText("Test content")).toBeTruthy();
57
+ });
58
+
59
+ it("applies custom padding", () => {
60
+ const {toJSON} = renderWithTheme(
61
+ <Card padding={8}>
62
+ <Text>Content</Text>
63
+ </Card>
64
+ );
65
+ expect(toJSON()).toMatchSnapshot();
66
+ });
67
+
68
+ it("applies custom color", () => {
69
+ const {toJSON} = renderWithTheme(
70
+ <Card color="secondary">
71
+ <Text>Content</Text>
72
+ </Card>
73
+ );
74
+ expect(toJSON()).toMatchSnapshot();
75
+ });
76
+
77
+ it("passes additional Box props", () => {
78
+ const {toJSON} = renderWithTheme(
79
+ <Card gap={2} marginTop={4}>
80
+ <Text>Content</Text>
81
+ </Card>
82
+ );
83
+ expect(toJSON()).toMatchSnapshot();
84
+ });
43
85
 
44
- it("passes additional Box props", () => {
45
- const {toJSON} = renderWithTheme(
46
- <Card gap={2} marginTop={4}>
47
- <Text>Content</Text>
48
- </Card>
49
- );
50
- expect(toJSON()).toMatchSnapshot();
86
+ it("renders with testID", () => {
87
+ const {getByTestId} = renderWithTheme(
88
+ <Card testID="test-card">
89
+ <Text>Content</Text>
90
+ </Card>
91
+ );
92
+ expect(getByTestId("test-card")).toBeTruthy();
93
+ });
51
94
  });
52
95
 
53
- it("renders with testID", () => {
54
- const {getByTestId} = renderWithTheme(
55
- <Card testID="test-card">
56
- <Text>Content</Text>
57
- </Card>
58
- );
59
- expect(getByTestId("test-card")).toBeTruthy();
96
+ describe("display variant", () => {
97
+ it("renders correctly with required props", () => {
98
+ const {toJSON} = renderWithTheme(<Card title="Feature Title" variant="display" />);
99
+ expect(toJSON()).toMatchSnapshot();
100
+ });
101
+
102
+ it("renders title", () => {
103
+ const {getByText} = renderWithTheme(<Card title="My Feature" variant="display" />);
104
+ expect(getByText("My Feature")).toBeTruthy();
105
+ });
106
+
107
+ it("renders description when provided", () => {
108
+ const {getByText} = renderWithTheme(
109
+ <Card description="Check out this new feature" title="My Feature" variant="display" />
110
+ );
111
+ expect(getByText("Check out this new feature")).toBeTruthy();
112
+ });
113
+
114
+ it("uses 8px spacing between the title and description", () => {
115
+ const {toJSON} = renderWithTheme(
116
+ <Card description="Body text" title="Feature Title" variant="display" />
117
+ );
118
+ const json = toJSON() as ReactTestRendererJSON;
119
+ const contentBox = json.children?.[0] as ReactTestRendererJSON;
120
+ const titleDescriptionBox = contentBox.children?.[0] as ReactTestRendererJSON;
121
+
122
+ expect(titleDescriptionBox.props.style.gap).toBe(8);
123
+ });
124
+
125
+ it("uses a 600px width for the default display card size on desktop", () => {
126
+ const restoreWindowWidth = setWindowWidth(1024);
127
+ const {toJSON} = renderWithTheme(<Card title="Feature Title" variant="display" />);
128
+ const json = toJSON() as ReactTestRendererJSON;
129
+
130
+ restoreWindowWidth();
131
+
132
+ expect(json.props.style.width).toBe(600);
133
+ });
134
+
135
+ it("renders action button when buttonText and buttonOnClick are provided", () => {
136
+ const onClick = mock(() => {});
137
+ const {getByText} = renderWithTheme(
138
+ <Card
139
+ buttonOnClick={onClick}
140
+ buttonText="Learn More"
141
+ title="My Feature"
142
+ variant="display"
143
+ />
144
+ );
145
+ expect(getByText("Learn More")).toBeTruthy();
146
+ });
147
+
148
+ it("does not render button when only buttonText is provided", () => {
149
+ const {queryByText} = renderWithTheme(
150
+ <Card buttonText="Learn More" title="My Feature" variant="display" />
151
+ );
152
+ expect(queryByText("Learn More")).toBeNull();
153
+ });
154
+
155
+ it("renders children below structured content", () => {
156
+ const {getByText} = renderWithTheme(
157
+ <Card title="My Feature" variant="display">
158
+ <Text>Extra content</Text>
159
+ </Card>
160
+ );
161
+ expect(getByText("Extra content")).toBeTruthy();
162
+ });
163
+
164
+ it("renders image when imageUri is provided", () => {
165
+ const {toJSON} = renderWithTheme(
166
+ <Card
167
+ imageAlt="Test image"
168
+ imageUri="https://example.com/img.jpg"
169
+ title="My Feature"
170
+ variant="display"
171
+ />
172
+ );
173
+ expect(toJSON()).toMatchSnapshot();
174
+ });
175
+
176
+ it("renders with testID", () => {
177
+ const {getByTestId} = renderWithTheme(
178
+ <Card testID="display-card" title="My Feature" variant="display" />
179
+ );
180
+ expect(getByTestId("display-card")).toBeTruthy();
181
+ });
60
182
  });
61
183
  });
package/src/Card.tsx CHANGED
@@ -1,18 +1,185 @@
1
+ import type React from "react";
2
+ import {Image, useWindowDimensions} from "react-native";
3
+
1
4
  import {Box} from "./Box";
2
- import type {BoxProps} from "./Common";
5
+ import {Button} from "./Button";
6
+ import type {CardProps} from "./Common";
7
+ import {Heading} from "./Heading";
8
+ import {Text} from "./Text";
9
+
10
+ const DEFAULT_DISPLAY_CARD_WIDTH = 600;
11
+ const MOBILE_SMALL_DISPLAY_CARD_WIDTH = 200;
12
+ const MOBILE_ROW_IMAGE_WIDTH = 100;
13
+ const DESKTOP_ROW_IMAGE_WIDTH = 160;
14
+ const MOBILE_LARGE_IMAGE_HEIGHT = 300;
15
+ const TITLE_DESCRIPTION_GAP = 2;
16
+ const MOBILE_BREAKPOINT = 768;
17
+
18
+ const getDisplayCardWidth = ({
19
+ isMobile,
20
+ size,
21
+ }: {
22
+ isMobile: boolean;
23
+ size: CardProps["size"];
24
+ }): number | undefined => {
25
+ if (isMobile && size === "small") {
26
+ return MOBILE_SMALL_DISPLAY_CARD_WIDTH;
27
+ }
28
+
29
+ if (!isMobile && size === "default") {
30
+ return DEFAULT_DISPLAY_CARD_WIDTH;
31
+ }
32
+
33
+ return undefined;
34
+ };
35
+
36
+ type DisplayCardProps = CardProps & {
37
+ isMobile: boolean;
38
+ };
39
+
40
+ const DisplayCard = ({
41
+ children,
42
+ color = "base",
43
+ padding,
44
+ size = "default",
45
+ title,
46
+ description,
47
+ buttonText,
48
+ buttonOnClick,
49
+ imageUri,
50
+ imageAlt,
51
+ imageHeight = 160,
52
+ isMobile,
53
+ maxWidth = "100%",
54
+ minWidth = 0,
55
+ overflow = "hidden",
56
+ variant: _variant,
57
+ ...rest
58
+ }: DisplayCardProps): React.ReactElement => {
59
+ const isRow = !isMobile && size !== "small";
60
+ const cardWidth = getDisplayCardWidth({isMobile, size});
61
+
62
+ const columnImageHeight = isMobile && size === "large" ? MOBILE_LARGE_IMAGE_HEIGHT : imageHeight;
63
+
64
+ const imageStyle = isRow
65
+ ? {
66
+ alignSelf: "stretch" as const,
67
+ flexShrink: 0,
68
+ width: isMobile ? MOBILE_ROW_IMAGE_WIDTH : DESKTOP_ROW_IMAGE_WIDTH,
69
+ }
70
+ : {
71
+ flexShrink: 0,
72
+ height: columnImageHeight,
73
+ width: "100%" as const,
74
+ };
3
75
 
4
- export const Card = ({children, color = "base", padding = 4, ...rest}: BoxProps) => {
5
76
  return (
6
77
  <Box
78
+ alignItems={isRow ? "stretch" : undefined}
79
+ alignSelf={cardWidth === undefined && isMobile ? "stretch" : undefined}
80
+ borderBottom="default"
81
+ borderLeft="default"
82
+ borderRight="default"
83
+ borderTop="default"
7
84
  color={color}
8
- direction="column"
9
- display="flex"
10
- padding={padding}
85
+ direction={isRow ? "row" : "column"}
86
+ gap={isMobile ? 0 : 6}
87
+ maxWidth={maxWidth}
88
+ minWidth={minWidth}
89
+ overflow={overflow}
90
+ padding={padding ?? (isMobile ? 0 : 6)}
11
91
  rounding="md"
12
- shadow
92
+ width={cardWidth ?? (isMobile ? "100%" : undefined)}
13
93
  {...rest}
14
94
  >
15
- {children}
95
+ {imageUri && (
96
+ <Image
97
+ accessibilityLabel={imageAlt}
98
+ resizeMode="cover"
99
+ source={{uri: imageUri}}
100
+ style={imageStyle}
101
+ />
102
+ )}
103
+ <Box
104
+ direction="column"
105
+ flex={isRow ? "shrink" : undefined}
106
+ gap={4}
107
+ minWidth={0}
108
+ padding={isMobile ? 4 : 0}
109
+ {...(isRow ? {} : {width: "100%"})}
110
+ >
111
+ {(Boolean(title) || Boolean(description)) && (
112
+ <Box direction="column" gap={TITLE_DESCRIPTION_GAP} minWidth={0} width="100%">
113
+ {Boolean(title) && (
114
+ <Box minWidth={0} width="100%">
115
+ <Heading size="lg">{title}</Heading>
116
+ </Box>
117
+ )}
118
+ {Boolean(description) && (
119
+ <Box minWidth={0} width="100%">
120
+ <Text>{description}</Text>
121
+ </Box>
122
+ )}
123
+ </Box>
124
+ )}
125
+ {Boolean(buttonText && buttonOnClick) && (
126
+ <Button onClick={buttonOnClick!} text={buttonText!} />
127
+ )}
128
+ {children}
129
+ </Box>
16
130
  </Box>
17
131
  );
18
132
  };
133
+
134
+ type ContainerCardProps = CardProps & {
135
+ isMobile: boolean;
136
+ };
137
+
138
+ const ContainerCard = ({
139
+ children,
140
+ color = "base",
141
+ padding,
142
+ isMobile,
143
+ maxWidth = "100%",
144
+ minWidth = 0,
145
+ overflow = "hidden",
146
+ variant: _variant,
147
+ size: _size,
148
+ title: _title,
149
+ description: _description,
150
+ buttonText: _buttonText,
151
+ buttonOnClick: _buttonOnClick,
152
+ imageUri: _imageUri,
153
+ imageAlt: _imageAlt,
154
+ imageHeight: _imageHeight,
155
+ ...rest
156
+ }: ContainerCardProps): React.ReactElement => {
157
+ const containerBoxProps = {
158
+ borderBottom: "default" as const,
159
+ borderLeft: isMobile ? undefined : ("default" as const),
160
+ borderRight: isMobile ? undefined : ("default" as const),
161
+ borderTop: "default" as const,
162
+ color,
163
+ direction: "column" as const,
164
+ display: "flex" as const,
165
+ maxWidth,
166
+ minWidth,
167
+ overflow,
168
+ padding: padding ?? (isMobile ? 4 : 6),
169
+ rounding: isMobile ? undefined : ("md" as const),
170
+ ...rest,
171
+ };
172
+
173
+ return <Box {...containerBoxProps}>{children}</Box>;
174
+ };
175
+
176
+ export const Card = ({variant = "container", ...props}: CardProps): React.ReactElement => {
177
+ const {width: windowWidth} = useWindowDimensions();
178
+ const isMobile = windowWidth <= MOBILE_BREAKPOINT;
179
+
180
+ if (variant === "display") {
181
+ return <DisplayCard {...props} isMobile={isMobile} variant={variant} />;
182
+ }
183
+
184
+ return <ContainerCard {...props} isMobile={isMobile} variant={variant} />;
185
+ };
package/src/Common.ts CHANGED
@@ -605,6 +605,62 @@ export type BoxProps =
605
605
  | (BoxPropsBase & {onClick: () => void} & AccessibilityProps);
606
606
  export type BoxColor = SurfaceColor | "transparent";
607
607
 
608
+ export type CardProps = BoxProps & {
609
+ /**
610
+ * The visual variant of the card.
611
+ * - "container": A simple surface wrapper for arbitrary children (default).
612
+ * - "display": A structured card with a colored header, title, description, and optional action button.
613
+ * @default "container"
614
+ */
615
+ variant?: "container" | "display";
616
+
617
+ /**
618
+ * The size of the display card.
619
+ * - "large": On desktop, horizontal layout with image/header on the left (160px wide). On mobile, vertical with a full-width image.
620
+ * - "default": 600px wide with the same horizontal layout as large on desktop. On mobile, vertical layout with a full-width image.
621
+ * - "small": Always vertical layout — image/header stacked above content (160px wide on mobile).
622
+ * @default "default"
623
+ */
624
+ size?: "small" | "default" | "large";
625
+
626
+ /**
627
+ * The title displayed in the card body. Used in the "display" variant.
628
+ */
629
+ title?: string;
630
+
631
+ /**
632
+ * A short description displayed below the title. Used in the "display" variant.
633
+ */
634
+ description?: string;
635
+
636
+ /**
637
+ * The label for the action button. Used in the "display" variant.
638
+ */
639
+ buttonText?: string;
640
+
641
+ /**
642
+ * Callback invoked when the action button is pressed. Used in the "display" variant.
643
+ */
644
+ buttonOnClick?: () => void | Promise<void>;
645
+
646
+ /**
647
+ * URI of an image to display at the top of the card. When provided in the "display" variant,
648
+ * replaces the colored header with a full-width cover image.
649
+ */
650
+ imageUri?: string;
651
+
652
+ /**
653
+ * Accessibility label for the card image.
654
+ */
655
+ imageAlt?: string;
656
+
657
+ /**
658
+ * Height in pixels for the image area when imageUri is provided.
659
+ * @default 160
660
+ */
661
+ imageHeight?: number;
662
+ };
663
+
608
664
  export interface ErrorBoundaryProps {
609
665
  onError?: (error: Error, stack: string) => void;
610
666
  children?: ReactNode;
@@ -2000,7 +2056,8 @@ export interface PageProps {
2000
2056
  closeButton?: boolean;
2001
2057
  direction?: "row" | "column";
2002
2058
  padding?: UnsignedUpTo12;
2003
- color?: SurfaceColor;
2059
+ /** Page body surface; use `transparent` when a parent (e.g. admin shell) supplies the canvas color. */
2060
+ color?: BoxColor;
2004
2061
  maxWidth?: number | string;
2005
2062
  keyboardOffset?: number;
2006
2063
  footer?: ReactNode;
@@ -8,7 +8,7 @@ import {Button} from "./Button";
8
8
  import type {CustomIconProps, IconRegistryMap} from "./Common";
9
9
  import {Icon} from "./Icon";
10
10
  import {IconButton} from "./IconButton";
11
- import {IconRegistryProvider, useCustomIcon} from "./IconRegistry";
11
+ import {IconRegistryProvider, useCustomIcon, useIconRegistry} from "./IconRegistry";
12
12
  import {ThemeProvider} from "./Theme";
13
13
 
14
14
  // Register a custom icon name so it type-checks anywhere an `iconName` is accepted.
@@ -86,6 +86,27 @@ describe("IconRegistry", () => {
86
86
  ).not.toThrow();
87
87
  });
88
88
 
89
+ it("useIconRegistry returns the registered icon map", () => {
90
+ const wrapper = ({children}: {children: React.ReactNode}) => (
91
+ <ThemeProvider>
92
+ <IconRegistryProvider icons={ICONS}>{children}</IconRegistryProvider>
93
+ </ThemeProvider>
94
+ );
95
+ const {result} = renderHook(() => useIconRegistry(), {wrapper});
96
+ expect(result.current).toBe(ICONS);
97
+ expect(result.current.customStar).toBe(CustomStar);
98
+ });
99
+
100
+ it("useIconRegistry returns empty registry when no icons are provided", () => {
101
+ const wrapper = ({children}: {children: React.ReactNode}) => (
102
+ <ThemeProvider>
103
+ <IconRegistryProvider>{children}</IconRegistryProvider>
104
+ </ThemeProvider>
105
+ );
106
+ const {result} = renderHook(() => useIconRegistry(), {wrapper});
107
+ expect(Object.keys(result.current)).toHaveLength(0);
108
+ });
109
+
89
110
  it("useCustomIcon resolves registered names and ignores everything else", () => {
90
111
  const wrapper = ({children}: {children: React.ReactNode}) => (
91
112
  <ThemeProvider>
package/src/Page.tsx CHANGED
@@ -100,7 +100,9 @@ export class Page extends React.Component<PageProps, {}> {
100
100
  {Boolean(this.props.footer) && (
101
101
  <Box
102
102
  alignSelf="center"
103
- color={this.props.color || "neutralLight"}
103
+ color={
104
+ this.props.color === "transparent" ? "base" : (this.props.color ?? "neutralLight")
105
+ }
104
106
  direction={this.props.direction || "column"}
105
107
  display={this.props.display || "flex"}
106
108
  flex="shrink"
@@ -38,7 +38,6 @@ import {
38
38
  Text,
39
39
  TextInput,
40
40
  type TextInputProps,
41
- type TextProps,
42
41
  TouchableOpacity,
43
42
  View,
44
43
  } from "react-native";
@@ -389,37 +388,30 @@ export const RNPickerSelect = ({
389
388
  return <View style={{pointerEvents: "box-only"}}>{children}</View>;
390
389
  }
391
390
 
392
- const textProps = textInputProps as Partial<TextProps> | undefined;
391
+ const selectedLabel = selectedItem?.inputLabel ?? selectedItem?.label ?? "";
392
+ const baseTextInputStyle = {
393
+ color: disabled ? theme.text.secondaryLight : theme.text.primary,
394
+ flex: 1,
395
+ };
393
396
  return (
394
397
  <View
395
398
  style={{
399
+ alignItems: "center",
396
400
  flexDirection: "row",
397
- justifyContent: "space-between",
398
401
  pointerEvents: "box-only",
399
402
  width: "100%",
400
403
  }}
401
404
  >
402
- {disabled ? (
403
- <Text
404
- {...textProps}
405
- style={
406
- textProps?.style
407
- ? [{color: theme.text.secondaryLight, flex: 1}, textProps.style]
408
- : {color: theme.text.secondaryLight, flex: 1}
409
- }
410
- testID={textInputProps?.testID ?? "text_input"}
411
- >
412
- {selectedItem?.inputLabel ? selectedItem?.inputLabel : selectedItem?.label}
413
- </Text>
414
- ) : (
415
- <TextInput
416
- readOnly
417
- style={{color: theme.text.primary}}
418
- testID="text_input"
419
- value={selectedItem?.inputLabel ? selectedItem?.inputLabel : selectedItem?.label}
420
- {...textInputProps}
421
- />
422
- )}
405
+ <TextInput
406
+ editable={false}
407
+ multiline
408
+ {...textInputProps}
409
+ style={
410
+ textInputProps?.style ? [baseTextInputStyle, textInputProps.style] : baseTextInputStyle
411
+ }
412
+ testID={textInputProps?.testID ?? "text_input"}
413
+ value={selectedLabel}
414
+ />
423
415
  {renderIcon()}
424
416
  </View>
425
417
  );
@@ -440,6 +432,7 @@ export const RNPickerSelect = ({
440
432
  ]}
441
433
  >
442
434
  <Pressable
435
+ disabled={disabled}
443
436
  onPress={() => {
444
437
  togglePicker(true);
445
438
  }}
@@ -448,7 +441,8 @@ export const RNPickerSelect = ({
448
441
  flexDirection: "row",
449
442
  justifyContent: "center",
450
443
  minHeight: 40,
451
- width: "95%",
444
+ paddingHorizontal: 8,
445
+ width: "100%",
452
446
  }}
453
447
  testID="ios_touchable_wrapper"
454
448
  {...touchableWrapperProps}
@@ -507,7 +501,12 @@ export const RNPickerSelect = ({
507
501
  children?: ReactNode;
508
502
  }>;
509
503
  return (
510
- <Component onPress={onOpen} testID="android_touchable_wrapper" {...touchableWrapperProps}>
504
+ <Component
505
+ {...(!fixAndroidTouchableBug ? {disabled} : {})}
506
+ onPress={onOpen}
507
+ testID="android_touchable_wrapper"
508
+ {...touchableWrapperProps}
509
+ >
511
510
  <View>
512
511
  {renderTextInputOrChildren()}
513
512
  <Picker
@@ -636,7 +635,6 @@ export const RNPickerSelect = ({
636
635
  style={{
637
636
  alignItems: "center",
638
637
  flexDirection: "row",
639
- justifyContent: "space-between",
640
638
  minHeight: 40,
641
639
  paddingHorizontal: 8,
642
640
  width: "100%",
package/src/Theme.tsx CHANGED
@@ -203,11 +203,14 @@ export const ThemeContext = createContext({
203
203
 
204
204
  interface ThemeProviderProps {
205
205
  children: React.ReactNode;
206
+ initialPrimitives?: DeepPartial<ThemePrimitives>;
206
207
  }
207
208
 
208
- export const ThemeProvider = ({children}: ThemeProviderProps) => {
209
+ export const ThemeProvider = ({children, initialPrimitives}: ThemeProviderProps) => {
209
210
  const [providerTheme, setProviderTheme] = useState<DeepPartial<TerrenoThemeConfig>>(defaultTheme);
210
- const [providerPrimitives, setProviderPrimitives] = useState<ThemePrimitives>(defaultPrimitives);
211
+ const [providerPrimitives, setProviderPrimitives] = useState<ThemePrimitives>(
212
+ initialPrimitives ? {...defaultPrimitives, ...initialPrimitives} : defaultPrimitives
213
+ );
211
214
 
212
215
  const computedTheme = useMemo(
213
216
  () => computeTheme(providerTheme, providerPrimitives),