related-ui-components 2.4.0 → 2.4.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.
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React, { createContext, useContext } from "react";
|
|
3
|
+
import React, { createContext, useContext, useState, useMemo, useEffect } from "react";
|
|
4
4
|
import { I18nManager } from "react-native";
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
6
|
export const ThemeContext = /*#__PURE__*/createContext({
|
|
7
7
|
theme: {},
|
|
8
|
-
isRTL: I18nManager.isRTL
|
|
8
|
+
isRTL: I18nManager.isRTL,
|
|
9
|
+
setTheme: () => {
|
|
10
|
+
console.warn("setTheme was called without a ThemeProvider");
|
|
11
|
+
}
|
|
9
12
|
});
|
|
10
13
|
export const RelatedProvider = ({
|
|
11
14
|
children,
|
|
12
|
-
theme
|
|
15
|
+
theme: initialTheme
|
|
13
16
|
}) => {
|
|
14
|
-
const
|
|
17
|
+
const [theme, setTheme] = useState(initialTheme);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
setTheme(initialTheme);
|
|
20
|
+
}, [initialTheme]);
|
|
21
|
+
const contextValue = useMemo(() => ({
|
|
15
22
|
theme,
|
|
23
|
+
setTheme,
|
|
16
24
|
isRTL: I18nManager.isRTL
|
|
17
|
-
};
|
|
25
|
+
}), [theme]);
|
|
18
26
|
return /*#__PURE__*/_jsx(ThemeContext.Provider, {
|
|
19
27
|
value: contextValue,
|
|
20
28
|
children: children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","createContext","useContext","I18nManager","jsx","_jsx","ThemeContext","theme","isRTL","RelatedProvider","children","contextValue","Provider","value","useTheme"],"sourceRoot":"..\\..\\..\\src","sources":["theme/ThemeContext.tsx"],"mappings":";;AAAA,OAAOA,KAAK,
|
|
1
|
+
{"version":3,"names":["React","createContext","useContext","useState","useMemo","useEffect","I18nManager","jsx","_jsx","ThemeContext","theme","isRTL","setTheme","console","warn","RelatedProvider","children","initialTheme","contextValue","Provider","value","useTheme"],"sourceRoot":"..\\..\\..\\src","sources":["theme/ThemeContext.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IACVC,aAAa,EACbC,UAAU,EAEVC,QAAQ,EACRC,OAAO,EACPC,SAAS,QACJ,OAAO;AACd,SAASC,WAAW,QAAQ,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAS3C,OAAO,MAAMC,YAAY,gBAAGR,aAAa,CAAoB;EAC3DS,KAAK,EAAE,CAAC,CAAc;EACtBC,KAAK,EAAEL,WAAW,CAACK,KAAK;EACxBC,QAAQ,EAAEA,CAAA,KAAM;IACdC,OAAO,CAACC,IAAI,CAAC,6CAA6C,CAAC;EAC7D;AACF,CAAC,CAAC;AAOF,OAAO,MAAMC,eAA6C,GAAGA,CAAC;EAC5DC,QAAQ;EACRN,KAAK,EAAEO;AACT,CAAC,KAAK;EACJ,MAAM,CAACP,KAAK,EAAEE,QAAQ,CAAC,GAAGT,QAAQ,CAAYc,YAAY,CAAC;EAE3DZ,SAAS,CAAC,MAAM;IACdO,QAAQ,CAACK,YAAY,CAAC;EACxB,CAAC,EAAE,CAACA,YAAY,CAAC,CAAC;EAElB,MAAMC,YAAY,GAAGd,OAAO,CAC1B,OAAO;IACLM,KAAK;IACLE,QAAQ;IACRD,KAAK,EAAEL,WAAW,CAACK;EACrB,CAAC,CAAC,EACF,CAACD,KAAK,CACR,CAAC;EAED,oBACEF,IAAA,CAACC,YAAY,CAACU,QAAQ;IAACC,KAAK,EAAEF,YAAa;IAAAF,QAAA,EACxCA;EAAQ,CACY,CAAC;AAE5B,CAAC;AAED,OAAO,MAAMK,QAAQ,GAAGA,CAAA,KAAMnB,UAAU,CAACO,YAAY,CAAC","ignoreList":[]}
|
|
@@ -3,12 +3,12 @@ import { ThemeType } from "./Colors";
|
|
|
3
3
|
interface ThemeContextValue {
|
|
4
4
|
theme: ThemeType;
|
|
5
5
|
isRTL: boolean;
|
|
6
|
+
setTheme: (theme: ThemeType) => void;
|
|
6
7
|
}
|
|
7
8
|
export declare const ThemeContext: React.Context<ThemeContextValue>;
|
|
8
9
|
interface ThemeProviderProps {
|
|
9
10
|
children: ReactNode;
|
|
10
11
|
theme: ThemeType;
|
|
11
|
-
toggleTheme: () => void;
|
|
12
12
|
}
|
|
13
13
|
export declare const RelatedProvider: React.FC<ThemeProviderProps>;
|
|
14
14
|
export declare const useTheme: () => ThemeContextValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeContext.d.ts","sourceRoot":"","sources":["../../../../src/theme/ThemeContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ThemeContext.d.ts","sourceRoot":"","sources":["../../../../src/theme/ThemeContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAGZ,SAAS,EAIV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,UAAU,iBAAiB;IACzB,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;CACtC;AAED,eAAO,MAAM,YAAY,kCAMvB,CAAC;AAEH,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,EAAE,SAAS,CAAC;CAClB;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAwBxD,CAAC;AAEF,eAAO,MAAM,QAAQ,yBAAiC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,31 +1,51 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
createContext,
|
|
3
|
+
useContext,
|
|
4
|
+
ReactNode,
|
|
5
|
+
useState,
|
|
6
|
+
useMemo,
|
|
7
|
+
useEffect,
|
|
8
|
+
} from "react";
|
|
2
9
|
import { I18nManager } from "react-native";
|
|
3
|
-
import { ThemeType } from "./Colors";
|
|
10
|
+
import { ThemeType } from "./Colors";
|
|
4
11
|
|
|
5
12
|
interface ThemeContextValue {
|
|
6
13
|
theme: ThemeType;
|
|
7
14
|
isRTL: boolean;
|
|
15
|
+
setTheme: (theme: ThemeType) => void;
|
|
8
16
|
}
|
|
9
17
|
|
|
10
18
|
export const ThemeContext = createContext<ThemeContextValue>({
|
|
11
19
|
theme: {} as ThemeType,
|
|
12
20
|
isRTL: I18nManager.isRTL,
|
|
21
|
+
setTheme: () => {
|
|
22
|
+
console.warn("setTheme was called without a ThemeProvider");
|
|
23
|
+
},
|
|
13
24
|
});
|
|
14
25
|
|
|
15
26
|
interface ThemeProviderProps {
|
|
16
27
|
children: ReactNode;
|
|
17
28
|
theme: ThemeType;
|
|
18
|
-
toggleTheme: () => void;
|
|
19
29
|
}
|
|
20
30
|
|
|
21
31
|
export const RelatedProvider: React.FC<ThemeProviderProps> = ({
|
|
22
32
|
children,
|
|
23
|
-
theme,
|
|
33
|
+
theme: initialTheme,
|
|
24
34
|
}) => {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
35
|
+
const [theme, setTheme] = useState<ThemeType>(initialTheme);
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
setTheme(initialTheme);
|
|
39
|
+
}, [initialTheme]);
|
|
40
|
+
|
|
41
|
+
const contextValue = useMemo(
|
|
42
|
+
() => ({
|
|
43
|
+
theme,
|
|
44
|
+
setTheme,
|
|
45
|
+
isRTL: I18nManager.isRTL,
|
|
46
|
+
}),
|
|
47
|
+
[theme],
|
|
48
|
+
);
|
|
29
49
|
|
|
30
50
|
return (
|
|
31
51
|
<ThemeContext.Provider value={contextValue}>
|
|
@@ -34,4 +54,4 @@ export const RelatedProvider: React.FC<ThemeProviderProps> = ({
|
|
|
34
54
|
);
|
|
35
55
|
};
|
|
36
56
|
|
|
37
|
-
export const useTheme = () => useContext(ThemeContext);
|
|
57
|
+
export const useTheme = () => useContext(ThemeContext);
|