@niibase/uniwind 1.1.8 → 1.1.9
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.
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.UniwindConfigBuilder = exports.Uniwind = void 0;
|
|
7
|
+
var _react = require("react");
|
|
7
8
|
var _reactNative = require("react-native");
|
|
9
|
+
var _withUniwind = require("../../hoc/withUniwind");
|
|
8
10
|
var _types = require("../../types");
|
|
9
11
|
var _listener = require("../listener");
|
|
10
12
|
const SYSTEM_THEME = "system";
|
|
@@ -38,6 +40,13 @@ class UniwindConfigBuilder {
|
|
|
38
40
|
}
|
|
39
41
|
return colorScheme ?? _types.ColorScheme.Light;
|
|
40
42
|
}
|
|
43
|
+
Wrapper({
|
|
44
|
+
as,
|
|
45
|
+
...props
|
|
46
|
+
}) {
|
|
47
|
+
const StyledComponent = (0, _react.useMemo)(() => (0, _withUniwind.withUniwind)(as), [as]);
|
|
48
|
+
return (0, _react.createElement)(StyledComponent, props);
|
|
49
|
+
}
|
|
41
50
|
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
42
51
|
setTheme(theme) {
|
|
43
52
|
const prevTheme = this.#currentTheme;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ElementType } from 'react';
|
|
1
2
|
import { Insets } from 'react-native';
|
|
3
|
+
import { ApplyUniwind } from '../../hoc/types';
|
|
2
4
|
import { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types';
|
|
3
5
|
declare const SYSTEM_THEME: "system";
|
|
4
6
|
export declare class UniwindConfigBuilder {
|
|
@@ -8,6 +10,9 @@ export declare class UniwindConfigBuilder {
|
|
|
8
10
|
get hasAdaptiveThemes(): boolean;
|
|
9
11
|
get currentTheme(): ThemeName;
|
|
10
12
|
private get colorScheme();
|
|
13
|
+
Wrapper<T extends ElementType>({ as, ...props }: {
|
|
14
|
+
as: T;
|
|
15
|
+
} & ApplyUniwind<Omit<ComponentPropsWithRef<T>, 'as'>>): import("react").FunctionComponentElement<any>;
|
|
11
16
|
setTheme(theme: ThemeName | typeof SYSTEM_THEME): void;
|
|
12
17
|
updateCSSVariables(theme: ThemeName, variables: CSSVariables): void;
|
|
13
18
|
updateInsets(insets: Insets): void;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { createElement, useMemo } from "react";
|
|
1
2
|
import { Appearance, Platform } from "react-native";
|
|
3
|
+
import { withUniwind } from "../../hoc/withUniwind.js";
|
|
2
4
|
import { ColorScheme, StyleDependency } from "../../types.js";
|
|
3
5
|
import { UniwindListener } from "../listener.js";
|
|
4
6
|
const SYSTEM_THEME = "system";
|
|
@@ -32,6 +34,10 @@ export class UniwindConfigBuilder {
|
|
|
32
34
|
}
|
|
33
35
|
return colorScheme ?? ColorScheme.Light;
|
|
34
36
|
}
|
|
37
|
+
Wrapper({ as, ...props }) {
|
|
38
|
+
const StyledComponent = useMemo(() => withUniwind(as), [as]);
|
|
39
|
+
return createElement(StyledComponent, props);
|
|
40
|
+
}
|
|
35
41
|
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
36
42
|
setTheme(theme) {
|
|
37
43
|
const prevTheme = this.#currentTheme;
|
package/package.json
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, createElement, ElementType, useMemo } from 'react'
|
|
1
2
|
import { Appearance, Insets, Platform } from 'react-native'
|
|
3
|
+
import { ApplyUniwind } from '../../hoc/types'
|
|
4
|
+
import { withUniwind } from '../../hoc/withUniwind'
|
|
2
5
|
import { ColorScheme, StyleDependency } from '../../types'
|
|
3
6
|
import { UniwindListener } from '../listener'
|
|
4
7
|
import { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types'
|
|
@@ -49,6 +52,13 @@ export class UniwindConfigBuilder {
|
|
|
49
52
|
return colorScheme ?? ColorScheme.Light
|
|
50
53
|
}
|
|
51
54
|
|
|
55
|
+
Wrapper<T extends ElementType>({ as, ...props }: {
|
|
56
|
+
as: T
|
|
57
|
+
} & ApplyUniwind<Omit<ComponentPropsWithRef<T>, 'as'>>) {
|
|
58
|
+
const StyledComponent = useMemo(() => withUniwind(as as any), [as])
|
|
59
|
+
return createElement(StyledComponent, props)
|
|
60
|
+
}
|
|
61
|
+
|
|
52
62
|
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
53
63
|
setTheme(theme: ThemeName | typeof SYSTEM_THEME) {
|
|
54
64
|
const prevTheme = this.#currentTheme
|