@uni-design-system/uni-react 0.0.16 → 0.0.18
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/README.md +1 -1
- package/dist/cjs/components/switch/switch.component.d.ts +1 -1
- package/dist/cjs/core/background/background.component.d.ts +11 -5
- package/dist/cjs/core/background/background.component.js +13 -11
- package/dist/cjs/core/background/index.d.ts +1 -0
- package/dist/cjs/core/background/index.js +17 -0
- package/dist/cjs/core/index.d.ts +1 -0
- package/dist/cjs/core/index.js +1 -0
- package/dist/cjs/core/text/text.component.js +1 -1
- package/dist/cjs/core/theme/index.d.ts +9 -2
- package/dist/cjs/core/theme/index.js +5 -16
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/utils/index.d.ts +1 -0
- package/dist/cjs/utils/index.js +17 -0
- package/dist/cjs/utils/storage-manager.d.ts +7 -0
- package/dist/cjs/utils/storage-manager.js +49 -0
- package/dist/esm/components/switch/switch.component.d.ts +1 -1
- package/dist/esm/core/background/background.component.d.ts +11 -5
- package/dist/esm/core/background/background.component.js +12 -10
- package/dist/esm/core/background/index.d.ts +1 -0
- package/dist/esm/core/background/index.js +1 -0
- package/dist/esm/core/index.d.ts +1 -0
- package/dist/esm/core/index.js +1 -0
- package/dist/esm/core/text/text.component.js +1 -1
- package/dist/esm/core/theme/index.d.ts +9 -2
- package/dist/esm/core/theme/index.js +3 -2
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/utils/index.d.ts +1 -0
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/storage-manager.d.ts +7 -0
- package/dist/esm/utils/storage-manager.js +44 -0
- package/package.json +3 -2
- package/dist/cjs/core/theme/theme.context.d.ts +0 -4
- package/dist/cjs/core/theme/theme.context.js +0 -11
- package/dist/cjs/core/theme/theme.hook.d.ts +0 -3
- package/dist/cjs/core/theme/theme.hook.js +0 -57
- package/dist/cjs/core/theme/theme.provider.d.ts +0 -9
- package/dist/cjs/core/theme/theme.provider.js +0 -74
- package/dist/esm/core/theme/theme.context.d.ts +0 -4
- package/dist/esm/core/theme/theme.context.js +0 -6
- package/dist/esm/core/theme/theme.hook.d.ts +0 -3
- package/dist/esm/core/theme/theme.hook.js +0 -26
- package/dist/esm/core/theme/theme.provider.d.ts +0 -9
- package/dist/esm/core/theme/theme.provider.js +0 -44
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<a href="https://uni-design-system.github.io/uni-react/" target="_blank">
|
|
3
|
-
<img src="
|
|
3
|
+
<img src="https://github.com/uni-design-system/uni-react/raw/v0.0.17/.github/uni-logo.png" alt="UNI Design System">
|
|
4
4
|
</a>
|
|
5
5
|
</p>
|
|
6
6
|
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { Property } from 'csstype';
|
|
3
|
-
interface BackgroundProps {
|
|
3
|
+
export interface BackgroundProps {
|
|
4
|
+
className?: string;
|
|
4
5
|
children?: ReactNode;
|
|
5
|
-
image?: Property.BackgroundImage
|
|
6
|
-
|
|
6
|
+
image?: Property.BackgroundImage;
|
|
7
|
+
imageUrl?: string;
|
|
8
|
+
gradiant?: Property.BackgroundImage;
|
|
9
|
+
position?: Property.BackgroundPosition;
|
|
10
|
+
size?: Property.BackgroundSize;
|
|
11
|
+
attachment?: 'fixed' | 'local' | 'scroll';
|
|
12
|
+
minHeight?: Property.MinHeight;
|
|
13
|
+
color?: string;
|
|
7
14
|
}
|
|
8
|
-
export declare const Background: ({ children, image, gradiant }: BackgroundProps) => JSX.Element;
|
|
9
|
-
export {};
|
|
15
|
+
export declare const Background: ({ children, image, imageUrl, gradiant, position, size, attachment, className, minHeight, color, }: BackgroundProps) => JSX.Element;
|
|
@@ -5,16 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Background = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
exports.Background = Background;
|
|
15
|
-
function BackgroundStyle({ image, gradiant, theme }) {
|
|
16
|
-
return {
|
|
17
|
-
backgroundColor: theme.colors.background,
|
|
8
|
+
const Background = ({ children, image, imageUrl, gradiant, position, size, attachment, className, minHeight, color, }) => {
|
|
9
|
+
if (!!imageUrl) {
|
|
10
|
+
image = `url(${imageUrl})`;
|
|
11
|
+
}
|
|
12
|
+
const style = {
|
|
13
|
+
backgroundColor: color,
|
|
18
14
|
backgroundImage: image || gradiant,
|
|
15
|
+
backgroundPosition: position,
|
|
16
|
+
backgroundSize: size,
|
|
17
|
+
minHeight,
|
|
18
|
+
backgroundAttachment: attachment,
|
|
19
19
|
};
|
|
20
|
-
}
|
|
20
|
+
return (react_1.default.createElement("div", { className: className, style: style }, children));
|
|
21
|
+
};
|
|
22
|
+
exports.Background = Background;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './background.component';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./background.component"), exports);
|
package/dist/cjs/core/index.d.ts
CHANGED
package/dist/cjs/core/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./background"), exports);
|
|
17
18
|
__exportStar(require("./border"), exports);
|
|
18
19
|
__exportStar(require("./container"), exports);
|
|
19
20
|
__exportStar(require("./flex"), exports);
|
|
@@ -17,7 +17,7 @@ exports.Text = Text;
|
|
|
17
17
|
function Style(theme, textAlign, role, color) {
|
|
18
18
|
const { fontSize, letterSpacing, lineHeight, fontWeight, fontFamily, fontStyle, textTransform } = theme.typography[role];
|
|
19
19
|
return {
|
|
20
|
-
color: theme.colors[color],
|
|
20
|
+
color: theme.colors[color || 'on-background'],
|
|
21
21
|
fontSize: fontSize + 'px',
|
|
22
22
|
letterSpacing,
|
|
23
23
|
textAlign,
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Theme } from '@uni-design-system/uni-core';
|
|
3
|
+
export declare const ThemeProvider: import("react").ComponentType<{
|
|
4
|
+
theme?: Theme | undefined;
|
|
5
|
+
}>, withTheme: <Props extends {
|
|
6
|
+
theme: Theme;
|
|
7
|
+
}, C>(WrappedComponent: import("react").ComponentType<Props> & C) => import("react").ComponentType<import("@callstack/react-theme-provider").$Without<Props, "theme"> & {
|
|
8
|
+
theme?: import("@callstack/react-theme-provider").$DeepPartial<Theme> | undefined;
|
|
9
|
+
}> & import("@callstack/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<import("react").ComponentType<Props> & C, {}>, useTheme: <T = Theme>(overrides?: import("@callstack/react-theme-provider").$DeepPartial<T> | undefined) => T;
|
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
2
|
+
var _a;
|
|
16
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
exports.useTheme = exports.withTheme = exports.ThemeProvider = void 0;
|
|
5
|
+
const react_theme_provider_1 = require("@callstack/react-theme-provider");
|
|
6
|
+
const uni_core_1 = require("@uni-design-system/uni-core");
|
|
7
|
+
_a = (0, react_theme_provider_1.createTheming)(uni_core_1.LightTheme), exports.ThemeProvider = _a.ThemeProvider, exports.withTheme = _a.withTheme, exports.useTheme = _a.useTheme;
|
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./core"), exports);
|
|
18
18
|
__exportStar(require("./components"), exports);
|
|
19
|
+
__exportStar(require("./utils"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './storage-manager';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./storage-manager"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface StorageManager<T> {
|
|
2
|
+
type: 'cookie' | 'localStorage';
|
|
3
|
+
get(init?: T): T | undefined;
|
|
4
|
+
set(value: T): void;
|
|
5
|
+
}
|
|
6
|
+
export declare const createLocalStorageManager: <T>(key: string) => StorageManager<T>;
|
|
7
|
+
export declare const createCookieStorageManager: (key: string, cookie?: string) => StorageManager<string>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCookieStorageManager = exports.createLocalStorageManager = void 0;
|
|
4
|
+
// Usage
|
|
5
|
+
// export const localStorageManager = createLocalStorageManager(STORAGE_KEY);
|
|
6
|
+
const createLocalStorageManager = (key) => ({
|
|
7
|
+
type: 'localStorage',
|
|
8
|
+
get(init) {
|
|
9
|
+
if (!(globalThis === null || globalThis === void 0 ? void 0 : globalThis.document))
|
|
10
|
+
return init;
|
|
11
|
+
let value;
|
|
12
|
+
try {
|
|
13
|
+
value = localStorage.getItem(key) || init;
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
// no op
|
|
17
|
+
}
|
|
18
|
+
return JSON.parse(value) || init;
|
|
19
|
+
},
|
|
20
|
+
set(value) {
|
|
21
|
+
try {
|
|
22
|
+
localStorage.setItem(key, JSON.stringify(value));
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
// no op
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
exports.createLocalStorageManager = createLocalStorageManager;
|
|
30
|
+
const parseCookie = (cookie, key) => {
|
|
31
|
+
const match = cookie.match(new RegExp(`(^| )${key}=([^;]+)`));
|
|
32
|
+
return match === null || match === void 0 ? void 0 : match[2];
|
|
33
|
+
};
|
|
34
|
+
// Usage
|
|
35
|
+
// export const cookieStorageManager = createCookieStorageManager(STORAGE_KEY);
|
|
36
|
+
const createCookieStorageManager = (key, cookie) => ({
|
|
37
|
+
type: 'cookie',
|
|
38
|
+
get(init) {
|
|
39
|
+
if (cookie)
|
|
40
|
+
return parseCookie(cookie, key);
|
|
41
|
+
if (!(globalThis === null || globalThis === void 0 ? void 0 : globalThis.document))
|
|
42
|
+
return init;
|
|
43
|
+
return parseCookie(document.cookie, key) || init;
|
|
44
|
+
},
|
|
45
|
+
set(value) {
|
|
46
|
+
document.cookie = `${key}=${value}; max-age=31536000; path=/`;
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
exports.createCookieStorageManager = createCookieStorageManager;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { Property } from 'csstype';
|
|
3
|
-
interface BackgroundProps {
|
|
3
|
+
export interface BackgroundProps {
|
|
4
|
+
className?: string;
|
|
4
5
|
children?: ReactNode;
|
|
5
|
-
image?: Property.BackgroundImage
|
|
6
|
-
|
|
6
|
+
image?: Property.BackgroundImage;
|
|
7
|
+
imageUrl?: string;
|
|
8
|
+
gradiant?: Property.BackgroundImage;
|
|
9
|
+
position?: Property.BackgroundPosition;
|
|
10
|
+
size?: Property.BackgroundSize;
|
|
11
|
+
attachment?: 'fixed' | 'local' | 'scroll';
|
|
12
|
+
minHeight?: Property.MinHeight;
|
|
13
|
+
color?: string;
|
|
7
14
|
}
|
|
8
|
-
export declare const Background: ({ children, image, gradiant }: BackgroundProps) => JSX.Element;
|
|
9
|
-
export {};
|
|
15
|
+
export declare const Background: ({ children, image, imageUrl, gradiant, position, size, attachment, className, minHeight, color, }: BackgroundProps) => JSX.Element;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function BackgroundStyle({ image, gradiant, theme }) {
|
|
9
|
-
return {
|
|
10
|
-
backgroundColor: theme.colors.background,
|
|
2
|
+
export const Background = ({ children, image, imageUrl, gradiant, position, size, attachment, className, minHeight, color, }) => {
|
|
3
|
+
if (!!imageUrl) {
|
|
4
|
+
image = `url(${imageUrl})`;
|
|
5
|
+
}
|
|
6
|
+
const style = {
|
|
7
|
+
backgroundColor: color,
|
|
11
8
|
backgroundImage: image || gradiant,
|
|
9
|
+
backgroundPosition: position,
|
|
10
|
+
backgroundSize: size,
|
|
11
|
+
minHeight,
|
|
12
|
+
backgroundAttachment: attachment,
|
|
12
13
|
};
|
|
13
|
-
}
|
|
14
|
+
return (React.createElement("div", { className: className, style: style }, children));
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './background.component';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './background.component';
|
package/dist/esm/core/index.d.ts
CHANGED
package/dist/esm/core/index.js
CHANGED
|
@@ -10,7 +10,7 @@ export function Text(props) {
|
|
|
10
10
|
function Style(theme, textAlign, role, color) {
|
|
11
11
|
const { fontSize, letterSpacing, lineHeight, fontWeight, fontFamily, fontStyle, textTransform } = theme.typography[role];
|
|
12
12
|
return {
|
|
13
|
-
color: theme.colors[color],
|
|
13
|
+
color: theme.colors[color || 'on-background'],
|
|
14
14
|
fontSize: fontSize + 'px',
|
|
15
15
|
letterSpacing,
|
|
16
16
|
textAlign,
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Theme } from '@uni-design-system/uni-core';
|
|
3
|
+
export declare const ThemeProvider: import("react").ComponentType<{
|
|
4
|
+
theme?: Theme | undefined;
|
|
5
|
+
}>, withTheme: <Props extends {
|
|
6
|
+
theme: Theme;
|
|
7
|
+
}, C>(WrappedComponent: import("react").ComponentType<Props> & C) => import("react").ComponentType<import("@callstack/react-theme-provider").$Without<Props, "theme"> & {
|
|
8
|
+
theme?: import("@callstack/react-theme-provider").$DeepPartial<Theme> | undefined;
|
|
9
|
+
}> & import("@callstack/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<import("react").ComponentType<Props> & C, {}>, useTheme: <T = Theme>(overrides?: import("@callstack/react-theme-provider").$DeepPartial<T> | undefined) => T;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { createTheming } from '@callstack/react-theme-provider';
|
|
2
|
+
import { LightTheme } from '@uni-design-system/uni-core';
|
|
3
|
+
export const { ThemeProvider, withTheme, useTheme } = createTheming(LightTheme);
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './storage-manager';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './storage-manager';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface StorageManager<T> {
|
|
2
|
+
type: 'cookie' | 'localStorage';
|
|
3
|
+
get(init?: T): T | undefined;
|
|
4
|
+
set(value: T): void;
|
|
5
|
+
}
|
|
6
|
+
export declare const createLocalStorageManager: <T>(key: string) => StorageManager<T>;
|
|
7
|
+
export declare const createCookieStorageManager: (key: string, cookie?: string) => StorageManager<string>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Usage
|
|
2
|
+
// export const localStorageManager = createLocalStorageManager(STORAGE_KEY);
|
|
3
|
+
export const createLocalStorageManager = (key) => ({
|
|
4
|
+
type: 'localStorage',
|
|
5
|
+
get(init) {
|
|
6
|
+
if (!(globalThis === null || globalThis === void 0 ? void 0 : globalThis.document))
|
|
7
|
+
return init;
|
|
8
|
+
let value;
|
|
9
|
+
try {
|
|
10
|
+
value = localStorage.getItem(key) || init;
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
// no op
|
|
14
|
+
}
|
|
15
|
+
return JSON.parse(value) || init;
|
|
16
|
+
},
|
|
17
|
+
set(value) {
|
|
18
|
+
try {
|
|
19
|
+
localStorage.setItem(key, JSON.stringify(value));
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
// no op
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
const parseCookie = (cookie, key) => {
|
|
27
|
+
const match = cookie.match(new RegExp(`(^| )${key}=([^;]+)`));
|
|
28
|
+
return match === null || match === void 0 ? void 0 : match[2];
|
|
29
|
+
};
|
|
30
|
+
// Usage
|
|
31
|
+
// export const cookieStorageManager = createCookieStorageManager(STORAGE_KEY);
|
|
32
|
+
export const createCookieStorageManager = (key, cookie) => ({
|
|
33
|
+
type: 'cookie',
|
|
34
|
+
get(init) {
|
|
35
|
+
if (cookie)
|
|
36
|
+
return parseCookie(cookie, key);
|
|
37
|
+
if (!(globalThis === null || globalThis === void 0 ? void 0 : globalThis.document))
|
|
38
|
+
return init;
|
|
39
|
+
return parseCookie(document.cookie, key) || init;
|
|
40
|
+
},
|
|
41
|
+
set(value) {
|
|
42
|
+
document.cookie = `${key}=${value}; max-age=31536000; path=/`;
|
|
43
|
+
},
|
|
44
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uni-design-system/uni-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"description": "React component library for the UNI Design System.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -33,10 +33,11 @@
|
|
|
33
33
|
"homepage": "https://github.com/uni-design-system/uni-react#readme",
|
|
34
34
|
"packageManager": "yarn@3.0.2",
|
|
35
35
|
"dependencies": {
|
|
36
|
+
"@callstack/react-theme-provider": "^3.0.8",
|
|
36
37
|
"@dnd-kit/core": "^6.0.7",
|
|
37
38
|
"@dnd-kit/modifiers": "^6.0.1",
|
|
38
39
|
"@dnd-kit/sortable": "^7.0.2",
|
|
39
|
-
"@uni-design-system/uni-core": "^0.0.
|
|
40
|
+
"@uni-design-system/uni-core": "^0.0.35",
|
|
40
41
|
"@uni-design-system/uni-react-icons": "^0.1.2",
|
|
41
42
|
"framer-motion": "4.1.17",
|
|
42
43
|
"use-ripple-hook": "^1.0.22"
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const react_1 = __importDefault(require("react"));
|
|
7
|
-
const ThemeContext = react_1.default.createContext({});
|
|
8
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
9
|
-
ThemeContext.displayName = 'ThemeContext';
|
|
10
|
-
}
|
|
11
|
-
exports.default = ThemeContext;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.useSwitchTheme = exports.useTheme = void 0;
|
|
30
|
-
const react_1 = __importStar(require("react"));
|
|
31
|
-
const theme_context_1 = __importDefault(require("./theme.context"));
|
|
32
|
-
const uni_core_1 = require("@uni-design-system/uni-core");
|
|
33
|
-
const findTheme = (props) => {
|
|
34
|
-
const { themeId, themes } = props;
|
|
35
|
-
return themes && themeId ? themes[themeId] : uni_core_1.BaseTheme;
|
|
36
|
-
};
|
|
37
|
-
const useTheme = () => {
|
|
38
|
-
const themeProps = (0, react_1.useContext)(theme_context_1.default);
|
|
39
|
-
const theme = findTheme(themeProps);
|
|
40
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
41
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
42
|
-
react_1.default.useDebugValue(theme);
|
|
43
|
-
}
|
|
44
|
-
// return theme || LightTheme;
|
|
45
|
-
return theme;
|
|
46
|
-
};
|
|
47
|
-
exports.useTheme = useTheme;
|
|
48
|
-
const useSwitchTheme = (defaultThemeId) => {
|
|
49
|
-
const [themeId, setThemeId] = (0, react_1.useState)(defaultThemeId || uni_core_1.DefaultThemeId);
|
|
50
|
-
const switchTheme = (themeId) => {
|
|
51
|
-
if (!themeId)
|
|
52
|
-
return;
|
|
53
|
-
setThemeId(themeId);
|
|
54
|
-
};
|
|
55
|
-
return [themeId, switchTheme];
|
|
56
|
-
};
|
|
57
|
-
exports.useSwitchTheme = useSwitchTheme;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Theme } from '@uni-design-system/uni-core';
|
|
3
|
-
interface ThemeProviderProps {
|
|
4
|
-
themeId?: string;
|
|
5
|
-
themes?: Record<string, Theme>;
|
|
6
|
-
children?: React.ReactChild;
|
|
7
|
-
}
|
|
8
|
-
export declare const ThemeProvider: ({ children, themeId, themes }: ThemeProviderProps) => JSX.Element;
|
|
9
|
-
export {};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.ThemeProvider = void 0;
|
|
39
|
-
const react_1 = __importStar(require("react"));
|
|
40
|
-
const theme_context_1 = __importDefault(require("./theme.context"));
|
|
41
|
-
const theme_hook_1 = require("./theme.hook");
|
|
42
|
-
const STORAGE_KEY = 'THEME_ID';
|
|
43
|
-
const ThemeProvider = ({ children, themeId, themes }) => {
|
|
44
|
-
const [_themeId, setThemeId] = (0, theme_hook_1.useSwitchTheme)(themeId);
|
|
45
|
-
(0, react_1.useEffect)(() => {
|
|
46
|
-
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
-
const id = localStorage.getItem(STORAGE_KEY);
|
|
48
|
-
setThemeId(id || themeId);
|
|
49
|
-
}))();
|
|
50
|
-
}, [themeId]);
|
|
51
|
-
return (react_1.default.createElement(theme_context_1.default.Provider, { value: { themeId: _themeId, themes } }, _themeId ? children : null));
|
|
52
|
-
};
|
|
53
|
-
exports.ThemeProvider = ThemeProvider;
|
|
54
|
-
/*export function withTheme(Component: ({children, theme, themes }: (any & ThemeProps)) => JSX.Element) {
|
|
55
|
-
|
|
56
|
-
return (props: JSX.IntrinsicAttributes) => {
|
|
57
|
-
const { themeId, setThemeId } = useContext(ThemeContext);
|
|
58
|
-
|
|
59
|
-
const getTheme = (themeId: string) => themes[themeId];
|
|
60
|
-
const setTheme = (themeId: string) => {
|
|
61
|
-
localStorage.setItem(STORAGE_KEY, themeId);
|
|
62
|
-
setThemeId(themeId);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<Component
|
|
67
|
-
{...props}
|
|
68
|
-
themes={Themes}
|
|
69
|
-
theme={getTheme(themeId)}
|
|
70
|
-
setTheme={setTheme}
|
|
71
|
-
/>
|
|
72
|
-
);
|
|
73
|
-
};
|
|
74
|
-
}*/
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React, { useContext, useState } from 'react';
|
|
2
|
-
import ThemeContext from './theme.context';
|
|
3
|
-
import { BaseTheme, DefaultThemeId } from '@uni-design-system/uni-core';
|
|
4
|
-
const findTheme = (props) => {
|
|
5
|
-
const { themeId, themes } = props;
|
|
6
|
-
return themes && themeId ? themes[themeId] : BaseTheme;
|
|
7
|
-
};
|
|
8
|
-
export const useTheme = () => {
|
|
9
|
-
const themeProps = useContext(ThemeContext);
|
|
10
|
-
const theme = findTheme(themeProps);
|
|
11
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
12
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
13
|
-
React.useDebugValue(theme);
|
|
14
|
-
}
|
|
15
|
-
// return theme || LightTheme;
|
|
16
|
-
return theme;
|
|
17
|
-
};
|
|
18
|
-
export const useSwitchTheme = (defaultThemeId) => {
|
|
19
|
-
const [themeId, setThemeId] = useState(defaultThemeId || DefaultThemeId);
|
|
20
|
-
const switchTheme = (themeId) => {
|
|
21
|
-
if (!themeId)
|
|
22
|
-
return;
|
|
23
|
-
setThemeId(themeId);
|
|
24
|
-
};
|
|
25
|
-
return [themeId, switchTheme];
|
|
26
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Theme } from '@uni-design-system/uni-core';
|
|
3
|
-
interface ThemeProviderProps {
|
|
4
|
-
themeId?: string;
|
|
5
|
-
themes?: Record<string, Theme>;
|
|
6
|
-
children?: React.ReactChild;
|
|
7
|
-
}
|
|
8
|
-
export declare const ThemeProvider: ({ children, themeId, themes }: ThemeProviderProps) => JSX.Element;
|
|
9
|
-
export {};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import React, { useEffect } from 'react';
|
|
11
|
-
import ThemeContext from './theme.context';
|
|
12
|
-
import { useSwitchTheme } from './theme.hook';
|
|
13
|
-
const STORAGE_KEY = 'THEME_ID';
|
|
14
|
-
export const ThemeProvider = ({ children, themeId, themes }) => {
|
|
15
|
-
const [_themeId, setThemeId] = useSwitchTheme(themeId);
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
-
const id = localStorage.getItem(STORAGE_KEY);
|
|
19
|
-
setThemeId(id || themeId);
|
|
20
|
-
}))();
|
|
21
|
-
}, [themeId]);
|
|
22
|
-
return (React.createElement(ThemeContext.Provider, { value: { themeId: _themeId, themes } }, _themeId ? children : null));
|
|
23
|
-
};
|
|
24
|
-
/*export function withTheme(Component: ({children, theme, themes }: (any & ThemeProps)) => JSX.Element) {
|
|
25
|
-
|
|
26
|
-
return (props: JSX.IntrinsicAttributes) => {
|
|
27
|
-
const { themeId, setThemeId } = useContext(ThemeContext);
|
|
28
|
-
|
|
29
|
-
const getTheme = (themeId: string) => themes[themeId];
|
|
30
|
-
const setTheme = (themeId: string) => {
|
|
31
|
-
localStorage.setItem(STORAGE_KEY, themeId);
|
|
32
|
-
setThemeId(themeId);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<Component
|
|
37
|
-
{...props}
|
|
38
|
-
themes={Themes}
|
|
39
|
-
theme={getTheme(themeId)}
|
|
40
|
-
setTheme={setTheme}
|
|
41
|
-
/>
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
}*/
|