@ultraviolet/ui 3.0.0-beta.0 → 3.0.0-beta.2

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.
@@ -52,7 +52,7 @@ export declare const Dialog: (({ ariaLabel, className, children, "data-testid":
52
52
  href?: string;
53
53
  target?: string;
54
54
  download?: string;
55
- } & import("react").RefAttributes<Element>, "onClick" | "tooltip" | "disabled">) => import("@emotion/react/jsx-runtime").JSX.Element;
55
+ } & import("react").RefAttributes<Element>, "tooltip" | "onClick" | "disabled">) => import("@emotion/react/jsx-runtime").JSX.Element;
56
56
  Buttons: ({ secondaryButton, primaryButton, }: {
57
57
  secondaryButton: import("react").ReactNode;
58
58
  primaryButton: import("react").ReactNode;
@@ -53,7 +53,7 @@ export declare const StyledTooltip: import("@emotion/styled").StyledComponent<Pi
53
53
  disableAnimation?: boolean;
54
54
  portalTarget?: HTMLElement;
55
55
  dynamicDomRendering?: boolean;
56
- } & import("react").RefAttributes<HTMLDivElement>, "children" | "className" | "text" | "id" | "tabIndex" | "role" | "maxWidth" | "data-testid" | "containerFullHeight" | "containerFullWidth" | "visible" | "debounceDelay" | "portalTarget" | "innerRef"> & {
56
+ } & import("react").RefAttributes<HTMLDivElement>, "children" | "className" | "text" | "maxWidth" | "id" | "tabIndex" | "role" | "data-testid" | "containerFullHeight" | "containerFullWidth" | "visible" | "debounceDelay" | "portalTarget" | "innerRef"> & {
57
57
  placement?: Exclude<import("react").ComponentProps<typeof import("..").Popup>["placement"], "nested-menu">;
58
58
  } & import("react").RefAttributes<HTMLDivElement> & {
59
59
  theme?: Theme;
@@ -23,7 +23,7 @@ export declare const Tabs: {
23
23
  subtitle?: string;
24
24
  tooltip?: string;
25
25
  value?: string | number;
26
- } & Omit<any, "children" | "className" | "value" | "role" | "tooltip" | "as" | "disabled" | "badge" | "counter">, "ref"> & import("react").RefAttributes<HTMLElement>>;
26
+ } & Omit<any, "children" | "className" | "value" | "tooltip" | "role" | "as" | "disabled" | "badge" | "counter">, "ref"> & import("react").RefAttributes<HTMLElement>>;
27
27
  Menu: import("react").ForwardRefExoticComponent<{
28
28
  children: ReactNode;
29
29
  disclosure: ReactNode;
@@ -36,6 +36,6 @@ export declare const Tooltip: import("react").ForwardRefExoticComponent<Pick<{
36
36
  disableAnimation?: boolean;
37
37
  portalTarget?: HTMLElement;
38
38
  dynamicDomRendering?: boolean;
39
- } & import("react").RefAttributes<HTMLDivElement>, "children" | "className" | "text" | "id" | "tabIndex" | "role" | "maxWidth" | "data-testid" | "containerFullHeight" | "containerFullWidth" | "visible" | "debounceDelay" | "portalTarget" | "innerRef"> & {
39
+ } & import("react").RefAttributes<HTMLDivElement>, "children" | "className" | "text" | "maxWidth" | "id" | "tabIndex" | "role" | "data-testid" | "containerFullHeight" | "containerFullWidth" | "visible" | "debounceDelay" | "portalTarget" | "innerRef"> & {
40
40
  placement?: Exclude<ComponentProps<typeof Popup>["placement"], "nested-menu">;
41
41
  } & import("react").RefAttributes<HTMLDivElement>>;
@@ -16,6 +16,28 @@ const useTheme = () => {
16
16
  const ThemeProvider = ({
17
17
  children,
18
18
  theme = themes.consoleLightTheme
19
- }) => /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, { value: theme, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: dynamic.assignInlineVars(themes.theme, theme), children }) });
19
+ }) => {
20
+ react.useEffect(() => {
21
+ const styleId = "uv-theme";
22
+ const existingStyle = document.getElementById(styleId);
23
+ const cssVars = dynamic.assignInlineVars(themes.theme, theme);
24
+ const cssString = `:root { ${Object.entries(cssVars).map(([key, value]) => `${key}: ${value};`).join(" ")} }`;
25
+ if (existingStyle) {
26
+ existingStyle.textContent = cssString;
27
+ } else {
28
+ const style = document.createElement("style");
29
+ style.id = styleId;
30
+ style.textContent = cssString;
31
+ document.head.appendChild(style);
32
+ }
33
+ return () => {
34
+ const style = document.getElementById(styleId);
35
+ if (style) {
36
+ style.remove();
37
+ }
38
+ };
39
+ }, [theme]);
40
+ return /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, { value: theme, children });
41
+ };
20
42
  exports.ThemeProvider = ThemeProvider;
21
43
  exports.useTheme = useTheme;
@@ -730,7 +730,7 @@ type ThemeProviderProps = {
730
730
  children: ReactNode;
731
731
  };
732
732
  /**
733
- * ThemeProvider will apply generated global CSS variables to the application.
733
+ * ThemeProvider will apply generated global CSS variables to the application in the `<head>`.
734
734
  * If no theme is provided, it will default to `lightTheme`.
735
735
  */
736
736
  export declare const ThemeProvider: ({ children, theme, }: ThemeProviderProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import { jsx } from "@emotion/react/jsx-runtime";
3
- import { consoleLightTheme, theme } from "@ultraviolet/themes";
3
+ import { theme, consoleLightTheme } from "@ultraviolet/themes";
4
4
  import { assignInlineVars } from "@vanilla-extract/dynamic";
5
- import { createContext, useContext } from "react";
5
+ import { useEffect, createContext, useContext } from "react";
6
6
  const ThemeContext = createContext(consoleLightTheme);
7
7
  const useTheme = () => {
8
8
  const context = useContext(ThemeContext);
@@ -14,7 +14,29 @@ const useTheme = () => {
14
14
  const ThemeProvider = ({
15
15
  children,
16
16
  theme: theme$1 = consoleLightTheme
17
- }) => /* @__PURE__ */ jsx(ThemeContext.Provider, { value: theme$1, children: /* @__PURE__ */ jsx("div", { style: assignInlineVars(theme, theme$1), children }) });
17
+ }) => {
18
+ useEffect(() => {
19
+ const styleId = "uv-theme";
20
+ const existingStyle = document.getElementById(styleId);
21
+ const cssVars = assignInlineVars(theme, theme$1);
22
+ const cssString = `:root { ${Object.entries(cssVars).map(([key, value]) => `${key}: ${value};`).join(" ")} }`;
23
+ if (existingStyle) {
24
+ existingStyle.textContent = cssString;
25
+ } else {
26
+ const style = document.createElement("style");
27
+ style.id = styleId;
28
+ style.textContent = cssString;
29
+ document.head.appendChild(style);
30
+ }
31
+ return () => {
32
+ const style = document.getElementById(styleId);
33
+ if (style) {
34
+ style.remove();
35
+ }
36
+ };
37
+ }, [theme$1]);
38
+ return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: theme$1, children });
39
+ };
18
40
  export {
19
41
  ThemeProvider,
20
42
  useTheme
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultraviolet/ui",
3
- "version": "3.0.0-beta.0",
3
+ "version": "3.0.0-beta.2",
4
4
  "description": "Ultraviolet UI",
5
5
  "homepage": "https://github.com/scaleway/ultraviolet#readme",
6
6
  "repository": {
@@ -89,8 +89,8 @@
89
89
  "deepmerge": "4.3.1",
90
90
  "react-toastify": "11.0.5",
91
91
  "react-use-clipboard": "1.0.9",
92
- "@ultraviolet/icons": "4.0.3",
93
- "@ultraviolet/themes": "2.0.0"
92
+ "@ultraviolet/icons": "4.0.4-beta.0",
93
+ "@ultraviolet/themes": "2.1.0-beta.0"
94
94
  },
95
95
  "scripts": {
96
96
  "type:generate": "tsc --declaration -p tsconfig.build.json",