@snack-uikit/utils 3.0.0 → 3.1.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 +11 -0
- package/dist/components/ThemeProvider/ThemeProvider.d.ts +13 -0
- package/dist/components/ThemeProvider/ThemeProvider.js +19 -0
- package/dist/components/ThemeProvider/contexts.d.ts +8 -0
- package/dist/components/ThemeProvider/contexts.js +7 -0
- package/dist/components/ThemeProvider/index.d.ts +3 -0
- package/dist/components/ThemeProvider/index.js +3 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +2 -2
- package/src/components/ThemeProvider/ThemeProvider.tsx +15 -0
- package/src/components/ThemeProvider/contexts.ts +15 -0
- package/src/components/ThemeProvider/index.ts +5 -0
- package/src/components/index.ts +1 -0
- package/src/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 3.1.0 (2023-12-06)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **FF-3646:** add ThemeProvider/useThemeContext ([9a2ae54](https://github.com/cloud-ru-tech/snack-uikit/commit/9a2ae5425b6356bede25c89b3b14e60d9e8e9f75))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# 3.0.0 (2023-12-06)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
type UseThemePropsWithDefaultTheme = {
|
|
3
|
+
themeMap: Record<string, string>;
|
|
4
|
+
defaultTheme: string;
|
|
5
|
+
};
|
|
6
|
+
type UseThemeProps = {
|
|
7
|
+
themeMap: Record<string, string>;
|
|
8
|
+
};
|
|
9
|
+
export type ThemeProviderProps = {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
} & (UseThemePropsWithDefaultTheme | UseThemeProps);
|
|
12
|
+
export declare function ThemeProvider({ children, ...props }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { useThemeConfig } from '../../hooks';
|
|
14
|
+
import { ThemeContext } from './contexts';
|
|
15
|
+
export function ThemeProvider(_a) {
|
|
16
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
17
|
+
const themeConfig = useThemeConfig(props);
|
|
18
|
+
return _jsx(ThemeContext.Provider, Object.assign({ value: themeConfig }, { children: children }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export type ThemeContextType = {
|
|
3
|
+
theme: string | undefined;
|
|
4
|
+
themeClassName: string | undefined;
|
|
5
|
+
changeTheme: ((theme: string) => void) | undefined;
|
|
6
|
+
};
|
|
7
|
+
export declare const ThemeContext: import("react").Context<ThemeContextType>;
|
|
8
|
+
export declare const useThemeContext: () => ThemeContextType;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ThemeProvider';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ThemeProvider';
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Utils",
|
|
7
|
-
"version": "3.
|
|
7
|
+
"version": "3.1.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
],
|
|
32
32
|
"license": "Apache-2.0",
|
|
33
33
|
"scripts": {},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "76a159dde7baccf49dc7b11e1fd7abc31424b42f"
|
|
35
35
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { useThemeConfig } from '../../hooks';
|
|
4
|
+
import { ThemeContext } from './contexts';
|
|
5
|
+
|
|
6
|
+
type UseThemePropsWithDefaultTheme = { themeMap: Record<string, string>; defaultTheme: string };
|
|
7
|
+
type UseThemeProps = { themeMap: Record<string, string> };
|
|
8
|
+
|
|
9
|
+
export type ThemeProviderProps = { children: ReactNode } & (UseThemePropsWithDefaultTheme | UseThemeProps);
|
|
10
|
+
|
|
11
|
+
export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
|
|
12
|
+
const themeConfig = useThemeConfig(props);
|
|
13
|
+
|
|
14
|
+
return <ThemeContext.Provider value={themeConfig}>{children}</ThemeContext.Provider>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
export type ThemeContextType = {
|
|
4
|
+
theme: string | undefined;
|
|
5
|
+
themeClassName: string | undefined;
|
|
6
|
+
changeTheme: ((theme: string) => void) | undefined;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const ThemeContext = createContext<ThemeContextType>({
|
|
10
|
+
theme: undefined,
|
|
11
|
+
themeClassName: undefined,
|
|
12
|
+
changeTheme: undefined,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const useThemeContext = () => useContext<ThemeContextType>(ThemeContext);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ThemeProvider';
|
package/src/index.ts
CHANGED