@particle-network/ui-shared 0.3.0-beta.0 → 0.3.0-beta.1

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/dist/index.d.ts CHANGED
@@ -3,4 +3,3 @@ export * from './radius';
3
3
  export * from './size';
4
4
  export * from './spacing';
5
5
  export * from './tailwind-color';
6
- export * from './theme';
package/dist/index.js CHANGED
@@ -3,4 +3,3 @@ export * from "./radius.js";
3
3
  export * from "./size.js";
4
4
  export * from "./spacing.js";
5
5
  export * from "./tailwind-color.js";
6
- export * from "./theme.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@particle-network/ui-shared",
3
- "version": "0.3.0-beta.0",
3
+ "version": "0.3.0-beta.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "react-native": "./dist/index.js",
package/dist/theme.d.ts DELETED
@@ -1,6 +0,0 @@
1
- type Theme = 'dark' | 'light';
2
- /**
3
- * 监听主题变化(兼容 data-theme 和 class 两种方式)
4
- */
5
- export declare function useTheme(): Theme;
6
- export {};
package/dist/theme.js DELETED
@@ -1,27 +0,0 @@
1
- import { useEffect, useState } from "react";
2
- function getCurrentTheme() {
3
- const html = document.documentElement;
4
- if (html.hasAttribute('data-theme')) return 'dark' === html.getAttribute('data-theme') ? 'dark' : 'light';
5
- return html.classList.contains('dark') ? 'dark' : 'light';
6
- }
7
- function useTheme() {
8
- const [theme, setTheme] = useState(getCurrentTheme);
9
- useEffect(()=>{
10
- const observer = new MutationObserver(()=>{
11
- const newTheme = getCurrentTheme();
12
- if (newTheme !== theme) setTheme(newTheme);
13
- });
14
- observer.observe(document.documentElement, {
15
- attributes: true,
16
- attributeFilter: [
17
- 'class',
18
- 'data-theme'
19
- ]
20
- });
21
- return ()=>observer.disconnect();
22
- }, [
23
- theme
24
- ]);
25
- return theme;
26
- }
27
- export { useTheme };