@ttoss/ui 6.6.0 → 6.7.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/dist/esm/index.js CHANGED
@@ -5,6 +5,12 @@ var __name = (target, value) => __defProp(target, "name", {
5
5
  value,
6
6
  configurable: true
7
7
  });
8
+ var __export = (target, all) => {
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
13
+ };
8
14
 
9
15
  // src/chakra/ChakraThemeProvider.tsx
10
16
  import { ChakraProvider as ChakraProviderBase, createSystem, defaultConfig } from "@chakra-ui/react";
@@ -14,6 +20,123 @@ import * as React2 from "react";
14
20
  import { useThemeUI } from "theme-ui";
15
21
  var useTheme = useThemeUI;
16
22
 
23
+ // src/chakra/recipes/index.ts
24
+ var recipes_exports = {};
25
+ __export(recipes_exports, {
26
+ button: () => button
27
+ });
28
+
29
+ // src/chakra/recipes/button.ts
30
+ import { defineRecipe } from "@chakra-ui/react";
31
+ var button = defineRecipe({
32
+ className: "button",
33
+ base: {
34
+ color: "action.text.primary.default",
35
+ backgroundColor: "navigation.text.accent.default",
36
+ borderColor: "action.border.primary.default",
37
+ _hover: {
38
+ backgroundColor: "action.background.primary.active",
39
+ _disabled: {
40
+ backgroundColor: "action.background.primary.disabled"
41
+ }
42
+ },
43
+ _active: {
44
+ backgroundColor: "action.background.primary.active"
45
+ },
46
+ _disabled: {
47
+ backgroundColor: "action.background.primary.disabled",
48
+ color: "action.text.muted.default",
49
+ opacity: 1
50
+ }
51
+ },
52
+ variants: {
53
+ variant: {
54
+ solid: {
55
+ color: "action.text.primary.default",
56
+ backgroundColor: "navigation.text.accent.default",
57
+ _hover: {
58
+ backgroundColor: "action.background.primary.active"
59
+ }
60
+ },
61
+ outline: {
62
+ color: "action.text.primary.default",
63
+ backgroundColor: "navigation.text.accent.default",
64
+ borderColor: "action.border.primary.default",
65
+ _hover: {
66
+ backgroundColor: "action.background.primary.default"
67
+ }
68
+ },
69
+ ghost: {
70
+ color: "action.text.primary.default",
71
+ backgroundColor: "transparent",
72
+ _hover: {
73
+ backgroundColor: "action.background.secondary.default"
74
+ }
75
+ },
76
+ plain: {
77
+ color: "action.text.accent.default",
78
+ backgroundColor: "transparent",
79
+ _hover: {
80
+ color: "action.text.accent.default"
81
+ }
82
+ }
83
+ }
84
+ },
85
+ defaultVariants: {
86
+ variant: "solid"
87
+ }
88
+ });
89
+
90
+ // src/chakra/slotRecipes/index.ts
91
+ var slotRecipes_exports = {};
92
+ __export(slotRecipes_exports, {
93
+ steps: () => steps
94
+ });
95
+
96
+ // src/chakra/slotRecipes/steps.ts
97
+ import { defineSlotRecipe } from "@chakra-ui/react";
98
+ var steps = defineSlotRecipe({
99
+ className: "steps",
100
+ slots: ["root", "list", "item", "trigger", "indicator", "separator", "title", "description", "number"],
101
+ base: {
102
+ indicator: {
103
+ // Map to ttoss semantic colors
104
+ borderColor: "display.border.muted.default",
105
+ color: "display.text.muted.default",
106
+ backgroundColor: "display.background.secondary.default",
107
+ // Active/completed state
108
+ _complete: {
109
+ backgroundColor: "action.background.accent.default",
110
+ borderColor: "action.background.accent.default",
111
+ color: "action.text.accent.default"
112
+ },
113
+ // Current/active step
114
+ _current: {
115
+ borderColor: "display.border.accent.default",
116
+ color: "display.text.accent"
117
+ }
118
+ },
119
+ separator: {
120
+ // Map to ttoss semantic colors
121
+ backgroundColor: "display.border.muted.default",
122
+ _complete: {
123
+ backgroundColor: "action.background.accent.default"
124
+ }
125
+ },
126
+ title: {
127
+ // Map to ttoss semantic colors
128
+ color: "navigation.text.primary.default",
129
+ _current: {
130
+ color: "display.text.accent"
131
+ }
132
+ },
133
+ description: {
134
+ // Map to ttoss semantic colors
135
+ color: "navigation.text.muted.default"
136
+ }
137
+ }
138
+ });
139
+
17
140
  // src/chakra/ChakraThemeProvider.tsx
18
141
  var wrapTokenValues = /* @__PURE__ */__name(tokens => {
19
142
  if (!tokens) {
@@ -36,7 +159,6 @@ var toChakraTheme = /* @__PURE__ */__name((themeUITheme, overrides = {}) => {
36
159
  theme: {
37
160
  tokens: {
38
161
  borders: wrapTokenValues(themeUITheme.borders),
39
- colors: wrapTokenValues(themeUITheme.rawColors ?? themeUITheme.colors),
40
162
  fonts: wrapTokenValues(themeUITheme.fonts),
41
163
  fontSizes: wrapTokenValues(themeUITheme.fontSizes),
42
164
  fontWeights: wrapTokenValues(themeUITheme.fontWeights),
@@ -47,25 +169,39 @@ var toChakraTheme = /* @__PURE__ */__name((themeUITheme, overrides = {}) => {
47
169
  spacing: wrapTokenValues(themeUITheme.space),
48
170
  zIndex: wrapTokenValues(themeUITheme.zIndices)
49
171
  },
172
+ semanticTokens: {
173
+ colors: wrapTokenValues(themeUITheme.rawColors)
174
+ },
50
175
  breakpoints: themeUITheme.breakpoints && Array.isArray(themeUITheme.breakpoints) ? {
51
176
  sm: themeUITheme.breakpoints[0],
52
177
  md: themeUITheme.breakpoints[1],
53
178
  lg: themeUITheme.breakpoints[2],
54
179
  xl: themeUITheme.breakpoints[3],
55
180
  "2xl": themeUITheme.breakpoints[4]
56
- } : void 0
181
+ } : void 0,
182
+ recipes: {
183
+ ...recipes_exports,
184
+ ...overrides.theme?.recipes
185
+ },
186
+ slotRecipes: {
187
+ ...slotRecipes_exports,
188
+ ...overrides.theme?.slotRecipes
189
+ }
57
190
  },
58
191
  ...overrides
59
192
  };
60
193
  return createSystem(defaultConfig, config);
61
194
  }, "toChakraTheme");
62
195
  var ChakraProvider = /* @__PURE__ */__name(({
63
- children
196
+ children,
197
+ themeUITheme: themeUIThemeProp,
198
+ overrides
64
199
  }) => {
65
- const themeUITheme = useTheme();
200
+ const themeUIThemeContext = useTheme();
201
+ const themeUITheme = themeUIThemeProp ?? themeUIThemeContext.theme;
66
202
  const chakraSystem = React2.useMemo(() => {
67
- return toChakraTheme(themeUITheme.theme);
68
- }, [themeUITheme.theme]);
203
+ return toChakraTheme(themeUITheme, overrides);
204
+ }, [themeUITheme, overrides]);
69
205
  return /* @__PURE__ */React2.createElement(ChakraProviderBase, {
70
206
  value: chakraSystem
71
207
  }, children);
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { createSystem } from '@chakra-ui/react';
2
3
  import * as React from 'react';
3
- import { IconType } from '@ttoss/react-icons';
4
4
  import * as theme_ui from 'theme-ui';
5
- import { ButtonProps as ButtonProps$1, BadgeProps as BadgeProps$1, CardProps, BoxProps, CheckboxProps as CheckboxProps$1, CloseProps, TextProps, IconButtonProps as IconButtonProps$1, SxProp, InputProps as InputProps$1, LabelProps as LabelProps$1, LinkProps as LinkProps$1, FlexProps, SwitchProps, ThemeUIStyleObject, TextareaProps as TextareaProps$1, Theme } from 'theme-ui';
5
+ import { Theme, ButtonProps as ButtonProps$1, BadgeProps as BadgeProps$1, CardProps, BoxProps, CheckboxProps as CheckboxProps$1, CloseProps, TextProps, IconButtonProps as IconButtonProps$1, SxProp, InputProps as InputProps$1, LabelProps as LabelProps$1, LinkProps as LinkProps$1, FlexProps, SwitchProps, ThemeUIStyleObject, TextareaProps as TextareaProps$1 } from 'theme-ui';
6
6
  export { BaseStyles, Box, BoxProps, CardProps, ContainerProps, Divider, DividerProps, Flex, FlexProps, Global, Grid, GridProps, Heading, HeadingProps, Image, ImageProps, Progress as LinearProgress, ProgressProps as LinearProgressProps, Paragraph, ParagraphProps, Radio, RadioProps, Slider, SliderProps, Spinner, SpinnerProps, SwitchProps, SxProp, Text, TextProps, Theme, ThemeUIStyleObject } from 'theme-ui';
7
+ import { IconType } from '@ttoss/react-icons';
7
8
  import { ITooltip } from 'react-tooltip';
8
9
  import { Props } from 'react-select';
9
10
  export { Keyframes, keyframes } from '@emotion/react';
@@ -11,18 +12,43 @@ export { useBreakpointIndex, useResponsiveValue } from '@theme-ui/match-media';
11
12
 
12
13
  type ChakraThemeProviderProps = {
13
14
  children?: React.ReactNode;
15
+ /**
16
+ * Optional Theme UI theme to use instead of reading from context.
17
+ * Useful when you need to pass a specific theme directly.
18
+ */
19
+ themeUITheme?: Theme;
20
+ /**
21
+ * Optional Chakra-specific config overrides.
22
+ * Use this to add recipes, slot recipes, or customize tokens.
23
+ *
24
+ * @example
25
+ * ```tsx
26
+ * <ChakraProvider
27
+ * overrides={{
28
+ * theme: {
29
+ * slotRecipes: {
30
+ * steps: stepsSlotRecipe,
31
+ * },
32
+ * },
33
+ * }}
34
+ * >
35
+ * ...
36
+ * </ChakraProvider>
37
+ * ```
38
+ */
39
+ overrides?: Parameters<typeof createSystem>[1];
14
40
  };
15
41
  /**
16
42
  * Opt-in Chakra UI provider that inherits design tokens from the parent
17
43
  * theme-ui `ThemeProvider`.
18
44
  *
19
45
  * **Must be rendered as a child of `ThemeProvider`** so that `useThemeUI()`
20
- * can read the active theme.
46
+ * can read the active theme (unless `themeUITheme` prop is provided).
21
47
  *
22
48
  * This component automatically converts theme-ui tokens to Chakra UI v3
23
49
  * system format, allowing seamless integration between both systems.
24
50
  *
25
- * @example
51
+ * @example Basic usage (inherits from ThemeProvider context)
26
52
  * ```tsx
27
53
  * import { ThemeProvider } from '@ttoss/ui';
28
54
  * import { ChakraProvider } from '@ttoss/ui/chakra';
@@ -37,8 +63,30 @@ type ChakraThemeProviderProps = {
37
63
  * );
38
64
  * }
39
65
  * ```
66
+ *
67
+ * @example With custom theme
68
+ * ```tsx
69
+ * <ChakraProvider themeUITheme={customTheme}>
70
+ * <Button>Click me</Button>
71
+ * </ChakraProvider>
72
+ * ```
73
+ *
74
+ * @example With recipe overrides
75
+ * ```tsx
76
+ * <ChakraProvider
77
+ * overrides={{
78
+ * theme: {
79
+ * slotRecipes: {
80
+ * steps: customStepsRecipe,
81
+ * },
82
+ * },
83
+ * }}
84
+ * >
85
+ * <Steps.Root>...</Steps.Root>
86
+ * </ChakraProvider>
87
+ * ```
40
88
  */
41
- declare const ChakraProvider: ({ children }: ChakraThemeProviderProps) => react_jsx_runtime.JSX.Element;
89
+ declare const ChakraProvider: ({ children, themeUITheme: themeUIThemeProp, overrides, }: ChakraThemeProviderProps) => react_jsx_runtime.JSX.Element;
42
90
 
43
91
  type ButtonProps = ButtonProps$1 & {
44
92
  leftIcon?: IconType;
@@ -235,7 +283,7 @@ type SelectProps = Omit<Props<SelectOption, IsMulti>, 'styles' | 'value' | 'onCh
235
283
  /**
236
284
  * https://react-select.com/home
237
285
  */
238
- declare const Select: React.ForwardRefExoticComponent<Omit<Props<SelectOption, false>, "value" | "onChange" | "styles" | "components"> & SxProp & {
286
+ declare const Select: React.ForwardRefExoticComponent<Omit<Props<SelectOption, false>, "value" | "styles" | "onChange" | "components"> & SxProp & {
239
287
  value?: SelectOptionValue;
240
288
  onChange?: (value: SelectOptionValue | undefined) => void;
241
289
  disabled?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/ui",
3
- "version": "6.6.0",
3
+ "version": "6.7.0",
4
4
  "description": "Primitive layout, typographic, and other components for styling applications.",
5
5
  "license": "MIT",
6
6
  "author": "ttoss",
@@ -45,8 +45,8 @@
45
45
  "jest": "^30.2.0",
46
46
  "react": "^19.2.4",
47
47
  "tsup": "^8.5.1",
48
- "@ttoss/test-utils": "^4.1.0",
49
48
  "@ttoss/config": "^1.36.0",
49
+ "@ttoss/test-utils": "^4.1.0",
50
50
  "@ttoss/react-icons": "^0.6.0"
51
51
  },
52
52
  "keywords": [