@fringeworks/react-utils 0.9.1 → 0.10.0
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/README.ja.md +123 -10
- package/README.md +123 -10
- package/_helpers/_useExecutionHandler.cjs +37 -0
- package/_helpers/_useExecutionHandler.d.cts +18 -0
- package/_helpers/_useExecutionHandler.d.mts +18 -0
- package/_helpers/_useExecutionHandler.mjs +36 -0
- package/hooks/index.cjs +17 -2
- package/hooks/index.d.cts +8 -3
- package/hooks/index.d.mts +8 -3
- package/hooks/index.mjs +13 -3
- package/hooks/useExecutionEffect/index.cjs +5 -0
- package/hooks/useExecutionEffect/index.d.cts +2 -0
- package/hooks/useExecutionEffect/index.d.mts +2 -0
- package/hooks/useExecutionEffect/index.mjs +3 -0
- package/hooks/useExecutionEffect/useExecutionEffect.cjs +37 -0
- package/hooks/useExecutionEffect/useExecutionEffect.d.cts +27 -0
- package/hooks/useExecutionEffect/useExecutionEffect.d.mts +27 -0
- package/hooks/useExecutionEffect/useExecutionEffect.mjs +36 -0
- package/hooks/useExecutionLayoutEffect/index.cjs +5 -0
- package/hooks/useExecutionLayoutEffect/index.d.cts +2 -0
- package/hooks/useExecutionLayoutEffect/index.d.mts +2 -0
- package/hooks/useExecutionLayoutEffect/index.mjs +3 -0
- package/hooks/useExecutionLayoutEffect/useExecutionLayoutEffect.cjs +24 -0
- package/hooks/useExecutionLayoutEffect/useExecutionLayoutEffect.d.cts +14 -0
- package/hooks/useExecutionLayoutEffect/useExecutionLayoutEffect.d.mts +14 -0
- package/hooks/useExecutionLayoutEffect/useExecutionLayoutEffect.mjs +23 -0
- package/hooks/useIsHydrated/index.cjs +5 -0
- package/hooks/useIsHydrated/index.d.cts +2 -0
- package/hooks/useIsHydrated/index.d.mts +2 -0
- package/hooks/useIsHydrated/index.mjs +3 -0
- package/hooks/useIsHydrated/useIsHydrated.cjs +28 -0
- package/hooks/useIsHydrated/useIsHydrated.d.cts +15 -0
- package/hooks/useIsHydrated/useIsHydrated.d.mts +15 -0
- package/hooks/useIsHydrated/useIsHydrated.mjs +27 -0
- package/hooks/useRerender/index.cjs +5 -0
- package/hooks/useRerender/index.d.cts +2 -0
- package/hooks/useRerender/index.d.mts +2 -0
- package/hooks/useRerender/index.mjs +3 -0
- package/hooks/useRerender/useRerender.cjs +19 -0
- package/hooks/useRerender/useRerender.d.cts +11 -0
- package/hooks/useRerender/useRerender.d.mts +11 -0
- package/hooks/useRerender/useRerender.mjs +18 -0
- package/hooks/useStableCallback/index.cjs +5 -0
- package/hooks/useStableCallback/index.d.cts +2 -0
- package/hooks/useStableCallback/index.d.mts +2 -0
- package/hooks/useStableCallback/index.mjs +3 -0
- package/hooks/useStableCallback/useStableCallback.cjs +25 -0
- package/hooks/useStableCallback/useStableCallback.d.cts +15 -0
- package/hooks/useStableCallback/useStableCallback.d.mts +15 -0
- package/hooks/useStableCallback/useStableCallback.mjs +24 -0
- package/index.cjs +13 -1
- package/index.d.cts +9 -3
- package/index.d.mts +9 -3
- package/index.mjs +8 -2
- package/package.json +61 -1
- package/utils/getComponentName/getComponentName.cjs +18 -0
- package/utils/getComponentName/getComponentName.d.cts +12 -0
- package/utils/getComponentName/getComponentName.d.mts +12 -0
- package/utils/getComponentName/getComponentName.mjs +17 -0
- package/utils/getComponentName/index.cjs +5 -0
- package/utils/getComponentName/index.d.cts +2 -0
- package/utils/getComponentName/index.d.mts +2 -0
- package/utils/getComponentName/index.mjs +3 -0
- package/utils/index.cjs +2 -0
- package/utils/index.d.cts +3 -1
- package/utils/index.d.mts +3 -1
- package/utils/index.mjs +2 -1
package/index.mjs
CHANGED
|
@@ -4,17 +4,23 @@ import useCombinedRefs from "./hooks/useCombinedRefs/useCombinedRefs.mjs";
|
|
|
4
4
|
import useConstant from "./hooks/useConstant/useConstant.mjs";
|
|
5
5
|
import markAt from "./utils/markAt/markAt.mjs";
|
|
6
6
|
import useExecutionAt from "./hooks/useExecutionAt/useExecutionAt.mjs";
|
|
7
|
-
import useIsMounted from "./hooks/useIsMounted/useIsMounted.mjs";
|
|
8
7
|
import useLatestRef from "./hooks/useLatestRef/useLatestRef.mjs";
|
|
8
|
+
import useExecutionEffect from "./hooks/useExecutionEffect/useExecutionEffect.mjs";
|
|
9
|
+
import useExecutionLayoutEffect from "./hooks/useExecutionLayoutEffect/useExecutionLayoutEffect.mjs";
|
|
10
|
+
import useIsHydrated from "./hooks/useIsHydrated/useIsHydrated.mjs";
|
|
11
|
+
import useIsMounted from "./hooks/useIsMounted/useIsMounted.mjs";
|
|
9
12
|
import usePreviousValue from "./hooks/usePreviousValue/usePreviousValue.mjs";
|
|
13
|
+
import useRerender from "./hooks/useRerender/useRerender.mjs";
|
|
14
|
+
import useStableCallback from "./hooks/useStableCallback/useStableCallback.mjs";
|
|
10
15
|
import "./hooks/index.mjs";
|
|
11
16
|
import applyDefaultProps from "./utils/applyDefaultProps/applyDefaultProps.mjs";
|
|
12
17
|
import ensureComponent from "./utils/ensureComponent/ensureComponent.mjs";
|
|
13
18
|
import extendElement from "./utils/extendElement/extendElement.mjs";
|
|
14
19
|
import forEachContent from "./utils/forEachContent/forEachContent.mjs";
|
|
15
20
|
import forEachElement from "./utils/forEachElement/forEachElement.mjs";
|
|
21
|
+
import getComponentName from "./utils/getComponentName/getComponentName.mjs";
|
|
16
22
|
import transformContent from "./utils/transformContent/transformContent.mjs";
|
|
17
23
|
import transformElement from "./utils/transformElement/transformElement.mjs";
|
|
18
24
|
import "./utils/index.mjs";
|
|
19
25
|
|
|
20
|
-
export { applyDefaultProps, ensureComponent, extendElement, forEachContent, forEachElement, markAt, setRefCurrent, transformContent, transformElement, useCombinedRefs, useConstant, useExecutionAt, useIsMounted, useLatestRef, usePreviousValue, useStableLength };
|
|
26
|
+
export { applyDefaultProps, ensureComponent, extendElement, forEachContent, forEachElement, getComponentName, markAt, setRefCurrent, transformContent, transformElement, useCombinedRefs, useConstant, useExecutionAt, useExecutionEffect, useExecutionLayoutEffect, useIsHydrated, useIsMounted, useLatestRef, usePreviousValue, useRerender, useStableCallback, useStableLength };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fringeworks/react-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "A library some will find handy, providing utilities for React.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react"
|
|
@@ -64,6 +64,36 @@
|
|
|
64
64
|
"default": "./hooks/useExecutionAt/index.cjs"
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
|
+
"./hooks/useExecutionEffect": {
|
|
68
|
+
"import": {
|
|
69
|
+
"types": "./hooks/useExecutionEffect/index.d.mts",
|
|
70
|
+
"default": "./hooks/useExecutionEffect/index.mjs"
|
|
71
|
+
},
|
|
72
|
+
"require": {
|
|
73
|
+
"types": "./hooks/useExecutionEffect/index.d.cts",
|
|
74
|
+
"default": "./hooks/useExecutionEffect/index.cjs"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"./hooks/useExecutionLayoutEffect": {
|
|
78
|
+
"import": {
|
|
79
|
+
"types": "./hooks/useExecutionLayoutEffect/index.d.mts",
|
|
80
|
+
"default": "./hooks/useExecutionLayoutEffect/index.mjs"
|
|
81
|
+
},
|
|
82
|
+
"require": {
|
|
83
|
+
"types": "./hooks/useExecutionLayoutEffect/index.d.cts",
|
|
84
|
+
"default": "./hooks/useExecutionLayoutEffect/index.cjs"
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"./hooks/useIsHydrated": {
|
|
88
|
+
"import": {
|
|
89
|
+
"types": "./hooks/useIsHydrated/index.d.mts",
|
|
90
|
+
"default": "./hooks/useIsHydrated/index.mjs"
|
|
91
|
+
},
|
|
92
|
+
"require": {
|
|
93
|
+
"types": "./hooks/useIsHydrated/index.d.cts",
|
|
94
|
+
"default": "./hooks/useIsHydrated/index.cjs"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
67
97
|
"./hooks/useIsMounted": {
|
|
68
98
|
"import": {
|
|
69
99
|
"types": "./hooks/useIsMounted/index.d.mts",
|
|
@@ -94,6 +124,26 @@
|
|
|
94
124
|
"default": "./hooks/usePreviousValue/index.cjs"
|
|
95
125
|
}
|
|
96
126
|
},
|
|
127
|
+
"./hooks/useRerender": {
|
|
128
|
+
"import": {
|
|
129
|
+
"types": "./hooks/useRerender/index.d.mts",
|
|
130
|
+
"default": "./hooks/useRerender/index.mjs"
|
|
131
|
+
},
|
|
132
|
+
"require": {
|
|
133
|
+
"types": "./hooks/useRerender/index.d.cts",
|
|
134
|
+
"default": "./hooks/useRerender/index.cjs"
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
"./hooks/useStableCallback": {
|
|
138
|
+
"import": {
|
|
139
|
+
"types": "./hooks/useStableCallback/index.d.mts",
|
|
140
|
+
"default": "./hooks/useStableCallback/index.mjs"
|
|
141
|
+
},
|
|
142
|
+
"require": {
|
|
143
|
+
"types": "./hooks/useStableCallback/index.d.cts",
|
|
144
|
+
"default": "./hooks/useStableCallback/index.cjs"
|
|
145
|
+
}
|
|
146
|
+
},
|
|
97
147
|
"./hooks/useStableLength": {
|
|
98
148
|
"import": {
|
|
99
149
|
"types": "./hooks/useStableLength/index.d.mts",
|
|
@@ -164,6 +214,16 @@
|
|
|
164
214
|
"default": "./utils/forEachElement/index.cjs"
|
|
165
215
|
}
|
|
166
216
|
},
|
|
217
|
+
"./utils/getComponentName": {
|
|
218
|
+
"import": {
|
|
219
|
+
"types": "./utils/getComponentName/index.d.mts",
|
|
220
|
+
"default": "./utils/getComponentName/index.mjs"
|
|
221
|
+
},
|
|
222
|
+
"require": {
|
|
223
|
+
"types": "./utils/getComponentName/index.d.cts",
|
|
224
|
+
"default": "./utils/getComponentName/index.cjs"
|
|
225
|
+
}
|
|
226
|
+
},
|
|
167
227
|
"./utils/markAt": {
|
|
168
228
|
"import": {
|
|
169
229
|
"types": "./utils/markAt/index.d.mts",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
//#region src/utils/getComponentName/getComponentName.ts
|
|
3
|
+
/**
|
|
4
|
+
* コンポーネントの名前を取得する(HOCのdisplayNameなどに使う)
|
|
5
|
+
*
|
|
6
|
+
* - HTMLの要素名はそのまま使う
|
|
7
|
+
* - displayName・関数名が無い(空文字の)場合は`Unknown`
|
|
8
|
+
* @param Component コンポーネント
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
function getComponentName(Component) {
|
|
12
|
+
if (typeof Component === "string") return Component;
|
|
13
|
+
const { displayName, name } = Component;
|
|
14
|
+
return displayName || name || "Unknown";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
exports.default = getComponentName;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ElementType } from "react";
|
|
2
|
+
//#region src/utils/getComponentName/getComponentName.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* コンポーネントの名前を取得する(HOCのdisplayNameなどに使う)
|
|
5
|
+
*
|
|
6
|
+
* - HTMLの要素名はそのまま使う
|
|
7
|
+
* - displayName・関数名が無い(空文字の)場合は`Unknown`
|
|
8
|
+
* @param Component コンポーネント
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
declare function getComponentName(Component: ElementType): string;
|
|
12
|
+
export = getComponentName;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ElementType } from "react";
|
|
2
|
+
//#region src/utils/getComponentName/getComponentName.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* コンポーネントの名前を取得する(HOCのdisplayNameなどに使う)
|
|
5
|
+
*
|
|
6
|
+
* - HTMLの要素名はそのまま使う
|
|
7
|
+
* - displayName・関数名が無い(空文字の)場合は`Unknown`
|
|
8
|
+
* @param Component コンポーネント
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export default function getComponentName(Component: ElementType): string;
|
|
12
|
+
//#endregion
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/utils/getComponentName/getComponentName.ts
|
|
2
|
+
/**
|
|
3
|
+
* コンポーネントの名前を取得する(HOCのdisplayNameなどに使う)
|
|
4
|
+
*
|
|
5
|
+
* - HTMLの要素名はそのまま使う
|
|
6
|
+
* - displayName・関数名が無い(空文字の)場合は`Unknown`
|
|
7
|
+
* @param Component コンポーネント
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
function getComponentName(Component) {
|
|
11
|
+
if (typeof Component === "string") return Component;
|
|
12
|
+
const { displayName, name } = Component;
|
|
13
|
+
return displayName || name || "Unknown";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { getComponentName as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
const require_utils_getComponentName_getComponentName = require("./getComponentName.cjs");
|
|
3
|
+
|
|
4
|
+
exports.default = require_utils_getComponentName_getComponentName.default;
|
|
5
|
+
exports.getComponentName = require_utils_getComponentName_getComponentName.default;
|
package/utils/index.cjs
CHANGED
|
@@ -10,6 +10,7 @@ const require_utils_forEachContent_forEachContent = require("./forEachContent/fo
|
|
|
10
10
|
require("./forEachContent/index.cjs");
|
|
11
11
|
const require_utils_forEachElement_forEachElement = require("./forEachElement/forEachElement.cjs");
|
|
12
12
|
require("./forEachElement/index.cjs");
|
|
13
|
+
const require_utils_getComponentName_getComponentName = require("./getComponentName/getComponentName.cjs");
|
|
13
14
|
const require_utils_transformContent_transformContent = require("./transformContent/transformContent.cjs");
|
|
14
15
|
require("./transformContent/index.cjs");
|
|
15
16
|
const require_utils_transformElement_transformElement = require("./transformElement/transformElement.cjs");
|
|
@@ -20,6 +21,7 @@ exports.ensureComponent = require_utils_ensureComponent_ensureComponent.default;
|
|
|
20
21
|
exports.extendElement = require_utils_extendElement_extendElement.default;
|
|
21
22
|
exports.forEachContent = require_utils_forEachContent_forEachContent.default;
|
|
22
23
|
exports.forEachElement = require_utils_forEachElement_forEachElement.default;
|
|
24
|
+
exports.getComponentName = require_utils_getComponentName_getComponentName.default;
|
|
23
25
|
exports.markAt = require_utils_markAt_markAt.default;
|
|
24
26
|
exports.setRefCurrent = require_utils_setRefCurrent_setRefCurrent.default;
|
|
25
27
|
exports.transformContent = require_utils_transformContent_transformContent.default;
|
package/utils/index.d.cts
CHANGED
|
@@ -11,10 +11,12 @@ import forEachContent from "./forEachContent/forEachContent.cjs";
|
|
|
11
11
|
import "./forEachContent/index.cjs";
|
|
12
12
|
import forEachElement from "./forEachElement/forEachElement.cjs";
|
|
13
13
|
import "./forEachElement/index.cjs";
|
|
14
|
+
import getComponentName from "./getComponentName/getComponentName.cjs";
|
|
15
|
+
import "./getComponentName/index.cjs";
|
|
14
16
|
import setRefCurrent from "./setRefCurrent/setRefCurrent.cjs";
|
|
15
17
|
import "./setRefCurrent/index.cjs";
|
|
16
18
|
import transformContent from "./transformContent/transformContent.cjs";
|
|
17
19
|
import "./transformContent/index.cjs";
|
|
18
20
|
import transformElement from "./transformElement/transformElement.cjs";
|
|
19
21
|
import "./transformElement/index.cjs";
|
|
20
|
-
export { type AppliedProps, type ExtendableProps, type MarkAtResult, type SkippedDefaults, applyDefaultProps, ensureComponent, extendElement, forEachContent, forEachElement, markAt, setRefCurrent, transformContent, transformElement };
|
|
22
|
+
export { type AppliedProps, type ExtendableProps, type MarkAtResult, type SkippedDefaults, applyDefaultProps, ensureComponent, extendElement, forEachContent, forEachElement, getComponentName, markAt, setRefCurrent, transformContent, transformElement };
|
package/utils/index.d.mts
CHANGED
|
@@ -11,10 +11,12 @@ import forEachContent from "./forEachContent/forEachContent.mjs";
|
|
|
11
11
|
import "./forEachContent/index.mjs";
|
|
12
12
|
import forEachElement from "./forEachElement/forEachElement.mjs";
|
|
13
13
|
import "./forEachElement/index.mjs";
|
|
14
|
+
import getComponentName from "./getComponentName/getComponentName.mjs";
|
|
15
|
+
import "./getComponentName/index.mjs";
|
|
14
16
|
import setRefCurrent from "./setRefCurrent/setRefCurrent.mjs";
|
|
15
17
|
import "./setRefCurrent/index.mjs";
|
|
16
18
|
import transformContent from "./transformContent/transformContent.mjs";
|
|
17
19
|
import "./transformContent/index.mjs";
|
|
18
20
|
import transformElement from "./transformElement/transformElement.mjs";
|
|
19
21
|
import "./transformElement/index.mjs";
|
|
20
|
-
export { type AppliedProps, type ExtendableProps, type MarkAtResult, type SkippedDefaults, applyDefaultProps, ensureComponent, extendElement, forEachContent, forEachElement, markAt, setRefCurrent, transformContent, transformElement };
|
|
22
|
+
export { type AppliedProps, type ExtendableProps, type MarkAtResult, type SkippedDefaults, applyDefaultProps, ensureComponent, extendElement, forEachContent, forEachElement, getComponentName, markAt, setRefCurrent, transformContent, transformElement };
|
package/utils/index.mjs
CHANGED
|
@@ -9,9 +9,10 @@ import forEachContent from "./forEachContent/forEachContent.mjs";
|
|
|
9
9
|
import "./forEachContent/index.mjs";
|
|
10
10
|
import forEachElement from "./forEachElement/forEachElement.mjs";
|
|
11
11
|
import "./forEachElement/index.mjs";
|
|
12
|
+
import getComponentName from "./getComponentName/getComponentName.mjs";
|
|
12
13
|
import transformContent from "./transformContent/transformContent.mjs";
|
|
13
14
|
import "./transformContent/index.mjs";
|
|
14
15
|
import transformElement from "./transformElement/transformElement.mjs";
|
|
15
16
|
import "./transformElement/index.mjs";
|
|
16
17
|
|
|
17
|
-
export { applyDefaultProps, ensureComponent, extendElement, forEachContent, forEachElement, markAt, setRefCurrent, transformContent, transformElement };
|
|
18
|
+
export { applyDefaultProps, ensureComponent, extendElement, forEachContent, forEachElement, getComponentName, markAt, setRefCurrent, transformContent, transformElement };
|