@choksheak/react-utils 0.4.5 → 0.4.7

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/NoSSR.cjs CHANGED
@@ -1,37 +1,11 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/NoSSR.tsx
21
- var NoSSR_exports = {};
22
- __export(NoSSR_exports, {
23
- NoSSR: () => NoSSR
24
- });
25
- module.exports = __toCommonJS(NoSSR_exports);
26
- var import_react = require("react");
27
- var NoSSR = ({ children, fallback }) => {
28
- const [isClient, setIsClient] = (0, import_react.useState)(false);
29
- (0, import_react.useEffect)(() => {
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _react = require('react');
2
+ const NoSSR = ({ children, fallback }) => {
3
+ const [isClient, setIsClient] = _react.useState.call(void 0, false);
4
+ _react.useEffect.call(void 0, () => {
30
5
  setIsClient(true);
31
6
  }, []);
32
7
  return isClient ? children : fallback;
33
8
  };
34
- // Annotate the CommonJS export names for ESM import in node:
35
- 0 && (module.exports = {
36
- NoSSR
37
- });
9
+
10
+
11
+ exports.NoSSR = NoSSR;
package/NoSSR.min.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var a=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var n=(t,e)=>{for(var o in e)a(t,o,{get:e[o],enumerable:!0})},p=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of S(e))!l.call(t,c)&&c!==o&&a(t,c,{get:()=>e[c],enumerable:!(r=R(e,c))||r.enumerable});return t};var N=t=>p(a({},"__esModule",{value:!0}),t);var i={};n(i,{NoSSR:()=>f});module.exports=N(i);var s=require("react"),f=({children:t,fallback:e})=>{let[o,r]=(0,s.useState)(!1);return(0,s.useEffect)(()=>{r(!0)},[]),o?t:e};0&&(module.exports={NoSSR});
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _react = require('react');const l=({children:e,fallback:t})=>{const[o,c]=_react.useState.call(void 0, !1);return _react.useEffect.call(void 0, ()=>{c(!0)},[]),o?e:t};exports.NoSSR = l;
2
2
  //# sourceMappingURL=NoSSR.min.cjs.map
package/NoSSR.min.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/NoSSR.tsx"],"sourcesContent":["/**\n * @packageDocumentation\n *\n * Wraps components in <NoSSR>...</NoSSR> to make sure they only render on the\n * client side, and not on the server side.\n */\n\nimport React, { ReactNode, useEffect, useState } from \"react\";\n\n/** Props for the NoSSR component. */\nexport type NoSSRProps = {\n /** The content to render only on the client side. */\n children: ReactNode;\n\n /** A component to render during SSR or initial load. */\n fallback?: ReactNode;\n};\n\n/**\n * A component that prevents its children from being rendered during\n * Server-Side Rendering (SSR). It renders a optional fallback during SSR, and\n * only renders its children after the component has mounted on the client.\n */\nexport const NoSSR: React.FC<NoSSRProps> = ({ children, fallback }) => {\n const [isClient, setIsClient] = useState(false);\n\n // 2. useEffect runs ONLY on the client after the initial hydration is complete.\n useEffect(() => {\n // This forces the component to render a second time.\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setIsClient(true);\n }, []);\n\n return isClient ? children : fallback;\n};\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,WAAAE,IAAA,eAAAC,EAAAH,GAOA,IAAAI,EAAsD,iBAgBzCF,EAA8B,CAAC,CAAE,SAAAG,EAAU,SAAAC,CAAS,IAAM,CACrE,GAAM,CAACC,EAAUC,CAAW,KAAI,YAAS,EAAK,EAG9C,sBAAU,IAAM,CAGdA,EAAY,EAAI,CAClB,EAAG,CAAC,CAAC,EAEED,EAAWF,EAAWC,CAC/B","names":["NoSSR_exports","__export","NoSSR","__toCommonJS","import_react","children","fallback","isClient","setIsClient"]}
1
+ {"version":3,"sources":["../src/NoSSR.tsx"],"names":["NoSSR","children","fallback","isClient","setIsClient","useState","useEffect"],"mappings":"AAOA,uGAAsD,MAgBzCA,CAAAA,CAA8B,CAAC,CAAE,QAAA,CAAAC,CAAAA,CAAU,QAAA,CAAAC,CAAS,CAAA,CAAA,EAAM,CACrE,KAAM,CAACC,CAAAA,CAAUC,CAAW,CAAA,CAAIC,6BAAAA,CAAS,CAAK,CAAA,CAG9C,OAAAC,8BAAAA,CAAU,CAAA,EAAM,CAGdF,CAAAA,CAAY,CAAA,CAAI,CAClB,CAAA,CAAG,CAAC,CAAC,CAAA,CAEED,CAAAA,CAAWF,CAAAA,CAAWC,CAC/B,CAAA,CAAA,kBAAA","file":"/Users/choksheaklau/src/react-utils/dist/NoSSR.min.cjs","sourcesContent":["/**\n * @packageDocumentation\n *\n * Wraps components in <NoSSR>...</NoSSR> to make sure they only render on the\n * client side, and not on the server side.\n */\n\nimport React, { ReactNode, useEffect, useState } from \"react\";\n\n/** Props for the NoSSR component. */\nexport type NoSSRProps = {\n /** The content to render only on the client side. */\n children: ReactNode;\n\n /** A component to render during SSR or initial load. */\n fallback?: ReactNode;\n};\n\n/**\n * A component that prevents its children from being rendered during\n * Server-Side Rendering (SSR). It renders a optional fallback during SSR, and\n * only renders its children after the component has mounted on the client.\n */\nexport const NoSSR: React.FC<NoSSRProps> = ({ children, fallback }) => {\n const [isClient, setIsClient] = useState(false);\n\n // 2. useEffect runs ONLY on the client after the initial hydration is complete.\n useEffect(() => {\n // This forces the component to render a second time.\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setIsClient(true);\n }, []);\n\n return isClient ? children : fallback;\n};\n"]}
package/NoSSR.min.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{useEffect as r,useState as s}from"react";var l=({children:e,fallback:t})=>{let[o,c]=s(!1);return r(()=>{c(!0)},[]),o?e:t};export{l as NoSSR};
1
+ import{useEffect as r,useState as s}from"react";const l=({children:e,fallback:t})=>{const[o,c]=s(!1);return r(()=>{c(!0)},[]),o?e:t};export{l as NoSSR};
2
2
  //# sourceMappingURL=NoSSR.min.mjs.map
package/NoSSR.min.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/NoSSR.tsx"],"sourcesContent":["/**\n * @packageDocumentation\n *\n * Wraps components in <NoSSR>...</NoSSR> to make sure they only render on the\n * client side, and not on the server side.\n */\n\nimport React, { ReactNode, useEffect, useState } from \"react\";\n\n/** Props for the NoSSR component. */\nexport type NoSSRProps = {\n /** The content to render only on the client side. */\n children: ReactNode;\n\n /** A component to render during SSR or initial load. */\n fallback?: ReactNode;\n};\n\n/**\n * A component that prevents its children from being rendered during\n * Server-Side Rendering (SSR). It renders a optional fallback during SSR, and\n * only renders its children after the component has mounted on the client.\n */\nexport const NoSSR: React.FC<NoSSRProps> = ({ children, fallback }) => {\n const [isClient, setIsClient] = useState(false);\n\n // 2. useEffect runs ONLY on the client after the initial hydration is complete.\n useEffect(() => {\n // This forces the component to render a second time.\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setIsClient(true);\n }, []);\n\n return isClient ? children : fallback;\n};\n"],"mappings":"AAOA,OAA2B,aAAAA,EAAW,YAAAC,MAAgB,QAgB/C,IAAMC,EAA8B,CAAC,CAAE,SAAAC,EAAU,SAAAC,CAAS,IAAM,CACrE,GAAM,CAACC,EAAUC,CAAW,EAAIL,EAAS,EAAK,EAG9C,OAAAD,EAAU,IAAM,CAGdM,EAAY,EAAI,CAClB,EAAG,CAAC,CAAC,EAEED,EAAWF,EAAWC,CAC/B","names":["useEffect","useState","NoSSR","children","fallback","isClient","setIsClient"]}
1
+ {"version":3,"sources":["../src/NoSSR.tsx"],"sourcesContent":["/**\n * @packageDocumentation\n *\n * Wraps components in <NoSSR>...</NoSSR> to make sure they only render on the\n * client side, and not on the server side.\n */\n\nimport React, { ReactNode, useEffect, useState } from \"react\";\n\n/** Props for the NoSSR component. */\nexport type NoSSRProps = {\n /** The content to render only on the client side. */\n children: ReactNode;\n\n /** A component to render during SSR or initial load. */\n fallback?: ReactNode;\n};\n\n/**\n * A component that prevents its children from being rendered during\n * Server-Side Rendering (SSR). It renders a optional fallback during SSR, and\n * only renders its children after the component has mounted on the client.\n */\nexport const NoSSR: React.FC<NoSSRProps> = ({ children, fallback }) => {\n const [isClient, setIsClient] = useState(false);\n\n // 2. useEffect runs ONLY on the client after the initial hydration is complete.\n useEffect(() => {\n // This forces the component to render a second time.\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setIsClient(true);\n }, []);\n\n return isClient ? children : fallback;\n};\n"],"mappings":"AAOA,OAA2B,aAAAA,EAAW,YAAAC,MAAgB,QAgB/C,MAAMC,EAA8B,CAAC,CAAE,SAAAC,EAAU,SAAAC,CAAS,IAAM,CACrE,KAAM,CAACC,EAAUC,CAAW,EAAIL,EAAS,EAAK,EAG9C,OAAAD,EAAU,IAAM,CAGdM,EAAY,EAAI,CAClB,EAAG,CAAC,CAAC,EAEED,EAAWF,EAAWC,CAC/B","names":["useEffect","useState","NoSSR","children","fallback","isClient","setIsClient"]}
package/NoSSR.mjs CHANGED
@@ -1,6 +1,5 @@
1
- // src/NoSSR.tsx
2
1
  import { useEffect, useState } from "react";
3
- var NoSSR = ({ children, fallback }) => {
2
+ const NoSSR = ({ children, fallback }) => {
4
3
  const [isClient, setIsClient] = useState(false);
5
4
  useEffect(() => {
6
5
  setIsClient(true);