assui 3.0.18 → 3.0.19

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.
@@ -0,0 +1,7 @@
1
+ import type React from 'react';
2
+ declare type ClientOnlyProps = {
3
+ /** 需要渲染的元素 */
4
+ children: React.ReactElement;
5
+ };
6
+ declare const ClientOnly: React.FC<ClientOnlyProps>;
7
+ export default ClientOnly;
@@ -0,0 +1,10 @@
1
+ import { useClientOnly } from './useClientOnly';
2
+ var ClientOnly = function ClientOnly(_a) {
3
+ var children = _a.children;
4
+ var hasMounted = useClientOnly();
5
+ if (!hasMounted) {
6
+ return null;
7
+ }
8
+ return children;
9
+ };
10
+ export default ClientOnly;
@@ -0,0 +1 @@
1
+
File without changes
@@ -0,0 +1 @@
1
+ export declare const useClientOnly: () => boolean;
@@ -0,0 +1,34 @@
1
+ var __read = this && this.__read || function (o, n) {
2
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
3
+ if (!m) return o;
4
+ var i = m.call(o),
5
+ r,
6
+ ar = [],
7
+ e;
8
+ try {
9
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
10
+ ar.push(r.value);
11
+ }
12
+ } catch (error) {
13
+ e = {
14
+ error: error
15
+ };
16
+ } finally {
17
+ try {
18
+ if (r && !r.done && (m = i["return"])) m.call(i);
19
+ } finally {
20
+ if (e) throw e.error;
21
+ }
22
+ }
23
+ return ar;
24
+ };
25
+ import { useEffect, useState } from 'react';
26
+ export var useClientOnly = function useClientOnly() {
27
+ var _a = __read(useState(false), 2),
28
+ hasMounted = _a[0],
29
+ setHasMounted = _a[1];
30
+ useEffect(function () {
31
+ setHasMounted(true);
32
+ }, []);
33
+ return hasMounted;
34
+ };
@@ -0,0 +1,7 @@
1
+ import type React from 'react';
2
+ declare type ClientOnlyProps = {
3
+ /** 需要渲染的元素 */
4
+ children: React.ReactElement;
5
+ };
6
+ declare const ClientOnly: React.FC<ClientOnlyProps>;
7
+ export default ClientOnly;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var useClientOnly_1 = require("./useClientOnly");
7
+ var ClientOnly = function ClientOnly(_a) {
8
+ var children = _a.children;
9
+ var hasMounted = (0, useClientOnly_1.useClientOnly)();
10
+ if (!hasMounted) {
11
+ return null;
12
+ }
13
+ return children;
14
+ };
15
+ exports["default"] = ClientOnly;
@@ -0,0 +1 @@
1
+
File without changes
@@ -0,0 +1 @@
1
+ export declare const useClientOnly: () => boolean;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ var __read = this && this.__read || function (o, n) {
4
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
5
+ if (!m) return o;
6
+ var i = m.call(o),
7
+ r,
8
+ ar = [],
9
+ e;
10
+ try {
11
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
12
+ ar.push(r.value);
13
+ }
14
+ } catch (error) {
15
+ e = {
16
+ error: error
17
+ };
18
+ } finally {
19
+ try {
20
+ if (r && !r.done && (m = i["return"])) m.call(i);
21
+ } finally {
22
+ if (e) throw e.error;
23
+ }
24
+ }
25
+ return ar;
26
+ };
27
+ Object.defineProperty(exports, "__esModule", {
28
+ value: true
29
+ });
30
+ exports.useClientOnly = void 0;
31
+ var react_1 = require("react");
32
+ var useClientOnly = function useClientOnly() {
33
+ var _a = __read((0, react_1.useState)(false), 2),
34
+ hasMounted = _a[0],
35
+ setHasMounted = _a[1];
36
+ (0, react_1.useEffect)(function () {
37
+ setHasMounted(true);
38
+ }, []);
39
+ return hasMounted;
40
+ };
41
+ exports.useClientOnly = useClientOnly;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assui",
3
- "version": "3.0.18",
3
+ "version": "3.0.19",
4
4
  "description": "react ui library",
5
5
  "author": "jason <usochen@gmail.com>",
6
6
  "main": "./lib/index.js",
@@ -80,5 +80,5 @@
80
80
  "node": ">=10.0.0"
81
81
  },
82
82
  "license": "MIT",
83
- "gitHead": "65ae72bc437a71b1465d6746d84b56a409c68288"
83
+ "gitHead": "c7b3f84b1906af95910b049d8d5014b818ac97c7"
84
84
  }