@kopexa/react-utils 17.0.57 → 17.1.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.
@@ -0,0 +1,11 @@
1
+ "use client";
2
+
3
+ // src/client-only.tsx
4
+ import { useHydrated } from "@kopexa/use-hydrated";
5
+ var ClientOnly = ({ children, fallback = null }) => {
6
+ return useHydrated() ? children() : fallback;
7
+ };
8
+
9
+ export {
10
+ ClientOnly
11
+ };
@@ -0,0 +1,16 @@
1
+ import * as react from 'react';
2
+
3
+ type ClientOnlyProps = {
4
+ children: () => React.ReactNode;
5
+ fallback?: React.ReactNode;
6
+ };
7
+ /**
8
+ * Renders children only after the client has hydrated.
9
+ * Useful for avoiding hydration mismatches with browser-only APIs.
10
+ *
11
+ * Children is a render function (not a ReactNode) to avoid
12
+ * executing client-only code during SSR.
13
+ */
14
+ declare const ClientOnly: ({ children, fallback }: ClientOnlyProps) => react.ReactNode;
15
+
16
+ export { ClientOnly };
@@ -0,0 +1,16 @@
1
+ import * as react from 'react';
2
+
3
+ type ClientOnlyProps = {
4
+ children: () => React.ReactNode;
5
+ fallback?: React.ReactNode;
6
+ };
7
+ /**
8
+ * Renders children only after the client has hydrated.
9
+ * Useful for avoiding hydration mismatches with browser-only APIs.
10
+ *
11
+ * Children is a render function (not a ReactNode) to avoid
12
+ * executing client-only code during SSR.
13
+ */
14
+ declare const ClientOnly: ({ children, fallback }: ClientOnlyProps) => react.ReactNode;
15
+
16
+ export { ClientOnly };
@@ -0,0 +1,35 @@
1
+ "use client";
2
+ "use strict";
3
+ "use client";
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // src/client-only.tsx
23
+ var client_only_exports = {};
24
+ __export(client_only_exports, {
25
+ ClientOnly: () => ClientOnly
26
+ });
27
+ module.exports = __toCommonJS(client_only_exports);
28
+ var import_use_hydrated = require("@kopexa/use-hydrated");
29
+ var ClientOnly = ({ children, fallback = null }) => {
30
+ return (0, import_use_hydrated.useHydrated)() ? children() : fallback;
31
+ };
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ ClientOnly
35
+ });
@@ -0,0 +1,8 @@
1
+ "use client";
2
+ "use client";
3
+ import {
4
+ ClientOnly
5
+ } from "./chunk-D4ICWPWH.mjs";
6
+ export {
7
+ ClientOnly
8
+ };
package/dist/dom.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Ref, RefCallback, ReactNode } from 'react';
1
+ import { ReactNode, Ref, RefCallback } from 'react';
2
2
 
3
3
  /**
4
4
  * A function that merges React refs into one.
package/dist/dom.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Ref, RefCallback, ReactNode } from 'react';
1
+ import { ReactNode, Ref, RefCallback } from 'react';
2
2
 
3
3
  /**
4
4
  * A function that merges React refs into one.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { getValidChildren } from './children.mjs';
2
+ export { ClientOnly } from './client-only.mjs';
2
3
  export { createContext } from './context.mjs';
3
4
  export { getSubtree, mergeRefs } from './dom.mjs';
4
5
  export { ComponentPropsWithout, DOMAttributes, DOMElement, Merge, PropGetter, RemovedProps } from './types.mjs';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { getValidChildren } from './children.js';
2
+ export { ClientOnly } from './client-only.js';
2
3
  export { createContext } from './context.js';
3
4
  export { getSubtree, mergeRefs } from './dom.js';
4
5
  export { ComponentPropsWithout, DOMAttributes, DOMElement, Merge, PropGetter, RemovedProps } from './types.js';
package/dist/index.js CHANGED
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  // src/index.ts
22
22
  var index_exports = {};
23
23
  __export(index_exports, {
24
+ ClientOnly: () => ClientOnly,
24
25
  createContext: () => createContext,
25
26
  getSubtree: () => getSubtree,
26
27
  getValidChildren: () => getValidChildren,
@@ -36,6 +37,12 @@ function getValidChildren(children) {
36
37
  );
37
38
  }
38
39
 
40
+ // src/client-only.tsx
41
+ var import_use_hydrated = require("@kopexa/use-hydrated");
42
+ var ClientOnly = ({ children, fallback = null }) => {
43
+ return (0, import_use_hydrated.useHydrated)() ? children() : fallback;
44
+ };
45
+
39
46
  // src/context.ts
40
47
  var import_react2 = require("react");
41
48
  function getErrorMessage(hook, provider) {
@@ -101,6 +108,7 @@ function getSubtree(options, content) {
101
108
  }
102
109
  // Annotate the CommonJS export names for ESM import in node:
103
110
  0 && (module.exports = {
111
+ ClientOnly,
104
112
  createContext,
105
113
  getSubtree,
106
114
  getValidChildren,
package/dist/index.mjs CHANGED
@@ -2,6 +2,9 @@
2
2
  import {
3
3
  getValidChildren
4
4
  } from "./chunk-KGECMVHS.mjs";
5
+ import {
6
+ ClientOnly
7
+ } from "./chunk-D4ICWPWH.mjs";
5
8
  import {
6
9
  createContext
7
10
  } from "./chunk-2DAVPPDT.mjs";
@@ -10,6 +13,7 @@ import {
10
13
  mergeRefs
11
14
  } from "./chunk-S5G552ZW.mjs";
12
15
  export {
16
+ ClientOnly,
13
17
  createContext,
14
18
  getSubtree,
15
19
  getValidChildren,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kopexa/react-utils",
3
- "version": "17.0.57",
3
+ "version": "17.1.1",
4
4
  "description": "A set of utilities for react on client side",
5
5
  "keywords": [
6
6
  "react-utils"
@@ -28,7 +28,8 @@
28
28
  "react": ">=19.0.0-rc.0"
29
29
  },
30
30
  "dependencies": {
31
- "@kopexa/shared-utils": "17.0.57"
31
+ "@kopexa/shared-utils": "17.0.59",
32
+ "@kopexa/use-hydrated": "1.0.1"
32
33
  },
33
34
  "clean-package": "../../../clean-package.config.json",
34
35
  "module": "dist/index.mjs",