@laser-ui/components 0.4.0 → 0.4.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/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
4
4
 
5
+ ## [0.4.1](https://github.com/laser-ui/laser-ui/compare/v0.4.0...v0.4.1) (2023-12-12)
6
+
7
+ ### Bug Fixes
8
+
9
+ - **ui:** fix get window size ([c909d89](https://github.com/laser-ui/laser-ui/commit/c909d898d48d715758744d4201888824e1e09af4))
10
+
5
11
  # [0.4.0](https://github.com/laser-ui/laser-ui/compare/v0.3.0...v0.4.0) (2023-12-06)
6
12
 
7
13
  ### Features
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <p align="center">
2
- <a href="//laser-ui.surge.sh/" rel="noopener" target="_blank"><img width="150" src="apps/site/public/logo.png" alt="logo"></a>
2
+ <a href="//laser-ui.github.io/" rel="noopener" target="_blank"><img width="150" src="apps/site/public/logo.png" alt="logo"></a>
3
3
  </p>
4
4
 
5
5
  <h1 align="center">Laser UI</h1>
@@ -59,7 +59,7 @@ export default function App() {
59
59
 
60
60
  ## Links
61
61
 
62
- - [laser-ui.surge.sh](//laser-ui.surge.sh)
62
+ - [laser-admin.surge.sh](//laser-admin.surge.sh)
63
63
 
64
64
  ## Contributing
65
65
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laser-ui/components",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "React components.",
5
5
  "keywords": [
6
6
  "ui",
@@ -26,8 +26,8 @@
26
26
  "module": "./index.js",
27
27
  "types": "./index.d.ts",
28
28
  "dependencies": {
29
- "@laser-ui/hooks": "0.4.0",
30
- "@laser-ui/utils": "0.4.0",
29
+ "@laser-ui/hooks": "0.4.1",
30
+ "@laser-ui/utils": "0.4.1",
31
31
  "@material-design-icons/svg": "^0.14.12",
32
32
  "jss": "^10.10.0",
33
33
  "jss-preset-default": "^10.10.0",
@@ -45,5 +45,5 @@
45
45
  "access": "public",
46
46
  "directory": "../../dist/libs/components"
47
47
  },
48
- "gitHead": "434cf3de2a91e6557cf77801eda230c46e137ec9"
48
+ "gitHead": "83ceac5bb361608b2886a6697fc0943d49f520cc"
49
49
  }
package/root/Root.js CHANGED
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useEvent, useRefExtra } from '@laser-ui/hooks';
3
3
  import { isString, set } from 'lodash';
4
4
  import { useStore } from 'rcl-store';
@@ -7,10 +7,32 @@ import { ROOT_DATA, RootContext, Store } from './vars';
7
7
  import dayjs from '../dayjs';
8
8
  import { Portal } from '../internal/portal';
9
9
  import resources from '../resources.json';
10
+ function WindowSize() {
11
+ const windowSizeRef = useRef(null);
12
+ useEffect(() => {
13
+ if (windowSizeRef.current) {
14
+ const observer = new ResizeObserver((entries) => {
15
+ const entry = entries[0];
16
+ ROOT_DATA.windowSize = { width: entry.contentRect.width, height: entry.contentRect.height };
17
+ });
18
+ observer.observe(windowSizeRef.current);
19
+ return () => {
20
+ observer.disconnect();
21
+ };
22
+ }
23
+ });
24
+ return (_jsx("div", { ref: windowSizeRef, style: {
25
+ position: 'fixed',
26
+ top: 0,
27
+ right: 0,
28
+ bottom: 0,
29
+ left: 0,
30
+ pointerEvents: 'none',
31
+ } }));
32
+ }
10
33
  export function Root(props) {
11
34
  const { context: contextProp, children } = props;
12
35
  const windowRef = useRefExtra(() => window);
13
- const windowSizeRef = useRef(null);
14
36
  const [{ dialogs }] = useStore(Store, ['dialogs']);
15
37
  useEvent(windowRef, 'click', (e) => {
16
38
  // Check if click by keydown
@@ -25,18 +47,6 @@ export function Root(props) {
25
47
  }
26
48
  }
27
49
  }, { capture: true });
28
- useEffect(() => {
29
- if (windowSizeRef.current) {
30
- const observer = new ResizeObserver(() => {
31
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
32
- ROOT_DATA.windowSize = { width: windowSizeRef.current.clientWidth, height: windowSizeRef.current.clientHeight };
33
- });
34
- observer.observe(windowSizeRef.current);
35
- return () => {
36
- observer.disconnect();
37
- };
38
- }
39
- });
40
50
  const context = useMemo(() => {
41
51
  var _a, _b;
42
52
  const { i18n } = contextProp !== null && contextProp !== void 0 ? contextProp : {};
@@ -74,12 +84,5 @@ export function Root(props) {
74
84
  default:
75
85
  break;
76
86
  }
77
- return (_jsxs(RootContext.Provider, { value: context, children: [children, dialogs.map(({ type, key, props }) => createElement(type, Object.assign({ key }, props))), _jsx(Portal, { selector: () => document.body, children: _jsx("div", { ref: windowSizeRef, style: {
78
- position: 'fixed',
79
- top: 0,
80
- right: 0,
81
- bottom: 0,
82
- left: 0,
83
- pointerEvents: 'none',
84
- } }) })] }));
87
+ return (_jsxs(_Fragment, { children: [_jsxs(RootContext.Provider, { value: context, children: [children, dialogs.map(({ type, key, props }) => createElement(type, Object.assign({ key }, props)))] }), _jsx(Portal, { selector: () => document.body, children: _jsx(WindowSize, {}) })] }));
85
88
  }