@fringeworks/react-utils 0.8.1 → 0.9.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 +307 -0
- package/README.md +307 -3
- package/_helpers/_traverseChildren.cjs +32 -0
- package/_helpers/_traverseChildren.d.cts +24 -0
- package/_helpers/_traverseChildren.d.mts +24 -0
- package/_helpers/_traverseChildren.mjs +30 -0
- package/hooks/index.cjs +21 -40
- package/hooks/index.d.cts +5 -7
- package/hooks/index.d.mts +5 -7
- package/hooks/index.mjs +1 -14
- package/hooks/useCombinedRefs/index.cjs +4 -2
- package/hooks/useCombinedRefs/index.d.cts +1 -1
- package/hooks/useCombinedRefs/index.d.mts +1 -1
- package/hooks/useCombinedRefs/index.mjs +1 -1
- package/hooks/useCombinedRefs/useCombinedRefs.cjs +7 -6
- package/hooks/useCombinedRefs/useCombinedRefs.d.cts +0 -1
- package/hooks/useCombinedRefs/useCombinedRefs.d.mts +2 -4
- package/hooks/useConstant/index.cjs +4 -2
- package/hooks/useConstant/index.d.cts +1 -1
- package/hooks/useConstant/index.d.mts +1 -1
- package/hooks/useConstant/index.mjs +1 -1
- package/hooks/useConstant/useConstant.cjs +2 -1
- package/hooks/useConstant/useConstant.d.mts +2 -3
- package/hooks/useExecutionAt/index.cjs +4 -2
- package/hooks/useExecutionAt/index.d.cts +1 -1
- package/hooks/useExecutionAt/index.d.mts +1 -1
- package/hooks/useExecutionAt/index.mjs +1 -1
- package/hooks/useExecutionAt/types.cjs +1 -0
- package/hooks/useExecutionAt/types.d.cts +5 -7
- package/hooks/useExecutionAt/types.d.mts +5 -7
- package/hooks/useExecutionAt/useExecutionAt.cjs +4 -3
- package/hooks/useExecutionAt/useExecutionAt.d.cts +0 -1
- package/hooks/useExecutionAt/useExecutionAt.d.mts +2 -4
- package/hooks/useIsMounted/index.cjs +4 -2
- package/hooks/useIsMounted/index.d.cts +1 -1
- package/hooks/useIsMounted/index.d.mts +1 -1
- package/hooks/useIsMounted/index.mjs +1 -1
- package/hooks/useIsMounted/useIsMounted.cjs +8 -3
- package/hooks/useIsMounted/useIsMounted.d.cts +5 -1
- package/hooks/useIsMounted/useIsMounted.d.mts +7 -4
- package/hooks/useIsMounted/useIsMounted.mjs +7 -3
- package/hooks/useLatestRef/index.cjs +4 -2
- package/hooks/useLatestRef/index.d.cts +1 -1
- package/hooks/useLatestRef/index.d.mts +1 -1
- package/hooks/useLatestRef/index.mjs +1 -1
- package/hooks/useLatestRef/types.cjs +1 -0
- package/hooks/useLatestRef/types.d.cts +2 -3
- package/hooks/useLatestRef/types.d.mts +2 -3
- package/hooks/useLatestRef/useLatestRef.cjs +2 -1
- package/hooks/useLatestRef/useLatestRef.d.cts +0 -1
- package/hooks/useLatestRef/useLatestRef.d.mts +2 -4
- package/hooks/usePreviousValue/index.cjs +4 -2
- package/hooks/usePreviousValue/index.d.cts +1 -1
- package/hooks/usePreviousValue/index.d.mts +1 -1
- package/hooks/usePreviousValue/index.mjs +1 -1
- package/hooks/usePreviousValue/types.cjs +1 -0
- package/hooks/usePreviousValue/types.d.cts +8 -9
- package/hooks/usePreviousValue/types.d.mts +8 -9
- package/hooks/usePreviousValue/usePreviousValue.cjs +10 -5
- package/hooks/usePreviousValue/usePreviousValue.d.cts +6 -2
- package/hooks/usePreviousValue/usePreviousValue.d.mts +8 -5
- package/hooks/usePreviousValue/usePreviousValue.mjs +8 -4
- package/hooks/useStableLength/index.cjs +4 -2
- package/hooks/useStableLength/index.d.cts +1 -1
- package/hooks/useStableLength/index.d.mts +1 -1
- package/hooks/useStableLength/index.mjs +1 -1
- package/hooks/useStableLength/useStableLength.cjs +2 -1
- package/hooks/useStableLength/useStableLength.d.cts +1 -1
- package/hooks/useStableLength/useStableLength.d.mts +2 -3
- package/index.cjs +34 -14
- package/index.d.cts +25 -3
- package/index.d.mts +25 -3
- package/index.mjs +19 -3
- package/package.json +160 -38
- package/types.cjs +1 -0
- package/types.d.cts +2 -4
- package/types.d.mts +2 -4
- package/utils/applyDefaultProps/applyDefaultProps.cjs +6 -2
- package/utils/applyDefaultProps/applyDefaultProps.d.cts +6 -3
- package/utils/applyDefaultProps/applyDefaultProps.d.mts +8 -5
- package/utils/applyDefaultProps/applyDefaultProps.mjs +4 -0
- package/utils/applyDefaultProps/index.cjs +4 -2
- package/utils/applyDefaultProps/index.d.cts +1 -1
- package/utils/applyDefaultProps/index.d.mts +1 -1
- package/utils/applyDefaultProps/index.mjs +1 -1
- package/utils/applyDefaultProps/types.cjs +1 -0
- package/utils/applyDefaultProps/types.d.cts +6 -6
- package/utils/applyDefaultProps/types.d.mts +6 -6
- package/utils/ensureComponent/ensureComponent.cjs +2 -1
- package/utils/ensureComponent/ensureComponent.d.cts +0 -1
- package/utils/ensureComponent/ensureComponent.d.mts +2 -4
- package/utils/ensureComponent/index.cjs +4 -2
- package/utils/ensureComponent/index.d.cts +1 -1
- package/utils/ensureComponent/index.d.mts +1 -1
- package/utils/ensureComponent/index.mjs +1 -1
- package/utils/extendElement/extendElement.cjs +21 -17
- package/utils/extendElement/extendElement.d.cts +11 -6
- package/utils/extendElement/extendElement.d.mts +12 -8
- package/utils/extendElement/extendElement.mjs +19 -16
- package/utils/extendElement/index.cjs +4 -2
- package/utils/extendElement/index.d.cts +2 -1
- package/utils/extendElement/index.d.mts +2 -1
- package/utils/extendElement/index.mjs +1 -1
- package/utils/extendElement/types.cjs +1 -0
- package/utils/extendElement/types.d.cts +16 -0
- package/utils/extendElement/types.d.mts +16 -0
- package/utils/extendElement/types.mjs +1 -0
- package/utils/forEachContent/forEachContent.cjs +5 -4
- package/utils/forEachContent/forEachContent.d.cts +1 -2
- package/utils/forEachContent/forEachContent.d.mts +3 -5
- package/utils/forEachContent/forEachContent.mjs +3 -3
- package/utils/forEachContent/index.cjs +4 -2
- package/utils/forEachContent/index.d.cts +1 -1
- package/utils/forEachContent/index.d.mts +1 -1
- package/utils/forEachContent/index.mjs +1 -1
- package/utils/forEachElement/forEachElement.cjs +6 -4
- package/utils/forEachElement/forEachElement.d.cts +1 -2
- package/utils/forEachElement/forEachElement.d.mts +3 -5
- package/utils/forEachElement/forEachElement.mjs +4 -3
- package/utils/forEachElement/index.cjs +4 -2
- package/utils/forEachElement/index.d.cts +1 -1
- package/utils/forEachElement/index.d.mts +1 -1
- package/utils/forEachElement/index.mjs +1 -1
- package/utils/index.cjs +24 -45
- package/utils/index.d.cts +11 -5
- package/utils/index.d.mts +11 -5
- package/utils/index.mjs +1 -16
- package/utils/markAt/index.cjs +4 -2
- package/utils/markAt/index.d.cts +1 -1
- package/utils/markAt/index.d.mts +1 -1
- package/utils/markAt/index.mjs +1 -1
- package/utils/markAt/markAt.cjs +2 -2
- package/utils/markAt/markAt.d.cts +0 -1
- package/utils/markAt/markAt.d.mts +2 -4
- package/utils/markAt/types.cjs +1 -0
- package/utils/markAt/types.d.cts +2 -3
- package/utils/markAt/types.d.mts +2 -3
- package/utils/setRefCurrent/index.cjs +4 -2
- package/utils/setRefCurrent/index.d.cts +1 -1
- package/utils/setRefCurrent/index.d.mts +1 -1
- package/utils/setRefCurrent/index.mjs +1 -1
- package/utils/setRefCurrent/setRefCurrent.cjs +2 -2
- package/utils/setRefCurrent/setRefCurrent.d.cts +0 -1
- package/utils/setRefCurrent/setRefCurrent.d.mts +2 -4
- package/utils/transformContent/index.cjs +4 -2
- package/utils/transformContent/index.d.cts +1 -1
- package/utils/transformContent/index.d.mts +1 -1
- package/utils/transformContent/index.mjs +1 -1
- package/utils/transformContent/transformContent.cjs +11 -4
- package/utils/transformContent/transformContent.d.cts +7 -2
- package/utils/transformContent/transformContent.d.mts +9 -5
- package/utils/transformContent/transformContent.mjs +9 -3
- package/utils/transformElement/index.cjs +4 -2
- package/utils/transformElement/index.d.cts +1 -1
- package/utils/transformElement/index.d.mts +1 -1
- package/utils/transformElement/index.mjs +1 -1
- package/utils/transformElement/transformElement.cjs +12 -4
- package/utils/transformElement/transformElement.d.cts +7 -2
- package/utils/transformElement/transformElement.d.mts +9 -5
- package/utils/transformElement/transformElement.mjs +10 -3
- package/_helpers/_traverseContent.cjs +0 -24
- package/_helpers/_traverseContent.d.cts +0 -15
- package/_helpers/_traverseContent.d.mts +0 -16
- package/_helpers/_traverseContent.mjs +0 -22
- package/_helpers/_traverseElement.cjs +0 -23
- package/_helpers/_traverseElement.d.cts +0 -15
- package/_helpers/_traverseElement.d.mts +0 -16
- package/_helpers/_traverseElement.mjs +0 -21
- package/_virtual/_rolldown/runtime.cjs +0 -43
- package/_virtual/_rolldown/runtime.mjs +0 -18
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import transformContent from "./transformContent.cjs";
|
|
2
|
-
export
|
|
2
|
+
export { transformContent as default, transformContent };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import transformContent from "./transformContent.mjs";
|
|
2
|
-
export { transformContent as default };
|
|
2
|
+
export { transformContent as default, transformContent };
|
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
const require__helpers__traverseChildren = require("../../_helpers/_traverseChildren.cjs");
|
|
2
3
|
|
|
3
4
|
//#region src/utils/transformContent/transformContent.ts
|
|
4
5
|
/**
|
|
5
6
|
* React.Fragmentを透過し、children内のReactElement、string、numberをcallbackで処理した戻り値を返す
|
|
7
|
+
*
|
|
8
|
+
* `Children.map`と異なり、keyの付け直しは行わない。
|
|
9
|
+
* 別々のFragmentの中に同じkeyがあると、戻り値の配列の中でkeyが重複する。
|
|
10
|
+
* 戻り値をそのまま描画する場合は、callbackの中でkeyを付けること。
|
|
11
|
+
*
|
|
6
12
|
* @param children エレメントの子要素
|
|
7
|
-
* @param callback
|
|
13
|
+
* @param callback コールバック。indexはFragmentをまたいだ連番
|
|
14
|
+
* @returns callbackの戻り値の配列
|
|
8
15
|
*/
|
|
9
16
|
function transformContent(children, callback) {
|
|
10
17
|
const result = [];
|
|
11
|
-
|
|
18
|
+
require__helpers__traverseChildren.default(children, require__helpers__traverseChildren._isContent, callback, (value) => result.push(value));
|
|
12
19
|
return result;
|
|
13
20
|
}
|
|
14
21
|
|
|
15
22
|
//#endregion
|
|
16
|
-
|
|
23
|
+
exports.default = transformContent;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from "react";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/transformContent/transformContent.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* React.Fragmentを透過し、children内のReactElement、string、numberをcallbackで処理した戻り値を返す
|
|
5
|
+
*
|
|
6
|
+
* `Children.map`と異なり、keyの付け直しは行わない。
|
|
7
|
+
* 別々のFragmentの中に同じkeyがあると、戻り値の配列の中でkeyが重複する。
|
|
8
|
+
* 戻り値をそのまま描画する場合は、callbackの中でkeyを付けること。
|
|
9
|
+
*
|
|
6
10
|
* @param children エレメントの子要素
|
|
7
|
-
* @param callback
|
|
11
|
+
* @param callback コールバック。indexはFragmentをまたいだ連番
|
|
12
|
+
* @returns callbackの戻り値の配列
|
|
8
13
|
*/
|
|
9
14
|
declare function transformContent<T>(children: ReactNode, callback: (node: ReactElement | string | number, index: number) => T): T[];
|
|
10
15
|
export = transformContent;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from "react";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/transformContent/transformContent.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* React.Fragmentを透過し、children内のReactElement、string、numberをcallbackで処理した戻り値を返す
|
|
5
|
+
*
|
|
6
|
+
* `Children.map`と異なり、keyの付け直しは行わない。
|
|
7
|
+
* 別々のFragmentの中に同じkeyがあると、戻り値の配列の中でkeyが重複する。
|
|
8
|
+
* 戻り値をそのまま描画する場合は、callbackの中でkeyを付けること。
|
|
9
|
+
*
|
|
6
10
|
* @param children エレメントの子要素
|
|
7
|
-
* @param callback
|
|
11
|
+
* @param callback コールバック。indexはFragmentをまたいだ連番
|
|
12
|
+
* @returns callbackの戻り値の配列
|
|
8
13
|
*/
|
|
9
|
-
|
|
10
|
-
//#endregion
|
|
11
|
-
export { transformContent as default };
|
|
14
|
+
export default function transformContent<T>(children: ReactNode, callback: (node: ReactElement | string | number, index: number) => T): T[];
|
|
15
|
+
//#endregion
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _traverseChildren, { _isContent } from "../../_helpers/_traverseChildren.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/transformContent/transformContent.ts
|
|
4
4
|
/**
|
|
5
5
|
* React.Fragmentを透過し、children内のReactElement、string、numberをcallbackで処理した戻り値を返す
|
|
6
|
+
*
|
|
7
|
+
* `Children.map`と異なり、keyの付け直しは行わない。
|
|
8
|
+
* 別々のFragmentの中に同じkeyがあると、戻り値の配列の中でkeyが重複する。
|
|
9
|
+
* 戻り値をそのまま描画する場合は、callbackの中でkeyを付けること。
|
|
10
|
+
*
|
|
6
11
|
* @param children エレメントの子要素
|
|
7
|
-
* @param callback
|
|
12
|
+
* @param callback コールバック。indexはFragmentをまたいだ連番
|
|
13
|
+
* @returns callbackの戻り値の配列
|
|
8
14
|
*/
|
|
9
15
|
function transformContent(children, callback) {
|
|
10
16
|
const result = [];
|
|
11
|
-
|
|
17
|
+
_traverseChildren(children, _isContent, callback, (value) => result.push(value));
|
|
12
18
|
return result;
|
|
13
19
|
}
|
|
14
20
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
const require_utils_transformElement_transformElement = require("./transformElement.cjs");
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
exports.default = require_utils_transformElement_transformElement.default;
|
|
5
|
+
exports.transformElement = require_utils_transformElement_transformElement.default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import transformElement from "./transformElement.cjs";
|
|
2
|
-
export
|
|
2
|
+
export { transformElement as default, transformElement };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import transformElement from "./transformElement.mjs";
|
|
2
|
-
export { transformElement as default };
|
|
2
|
+
export { transformElement as default, transformElement };
|
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
const require__helpers__traverseChildren = require("../../_helpers/_traverseChildren.cjs");
|
|
3
|
+
let react = require("react");
|
|
2
4
|
|
|
3
5
|
//#region src/utils/transformElement/transformElement.ts
|
|
4
6
|
/**
|
|
5
7
|
* React.Fragmentを透過し、children内のReactElementをcallbackで処理した戻り値を返す
|
|
8
|
+
*
|
|
9
|
+
* `Children.map`と異なり、keyの付け直しは行わない。
|
|
10
|
+
* 別々のFragmentの中に同じkeyがあると、戻り値の配列の中でkeyが重複する。
|
|
11
|
+
* 戻り値をそのまま描画する場合は、callbackの中でkeyを付けること。
|
|
12
|
+
*
|
|
6
13
|
* @param children エレメントの子要素
|
|
7
|
-
* @param callback
|
|
14
|
+
* @param callback コールバック。indexはFragmentをまたいだ連番
|
|
15
|
+
* @returns callbackの戻り値の配列
|
|
8
16
|
*/
|
|
9
17
|
function transformElement(children, callback) {
|
|
10
18
|
const result = [];
|
|
11
|
-
|
|
19
|
+
require__helpers__traverseChildren.default(children, react.isValidElement, callback, (value) => result.push(value));
|
|
12
20
|
return result;
|
|
13
21
|
}
|
|
14
22
|
|
|
15
23
|
//#endregion
|
|
16
|
-
|
|
24
|
+
exports.default = transformElement;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from "react";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/transformElement/transformElement.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* React.Fragmentを透過し、children内のReactElementをcallbackで処理した戻り値を返す
|
|
5
|
+
*
|
|
6
|
+
* `Children.map`と異なり、keyの付け直しは行わない。
|
|
7
|
+
* 別々のFragmentの中に同じkeyがあると、戻り値の配列の中でkeyが重複する。
|
|
8
|
+
* 戻り値をそのまま描画する場合は、callbackの中でkeyを付けること。
|
|
9
|
+
*
|
|
6
10
|
* @param children エレメントの子要素
|
|
7
|
-
* @param callback
|
|
11
|
+
* @param callback コールバック。indexはFragmentをまたいだ連番
|
|
12
|
+
* @returns callbackの戻り値の配列
|
|
8
13
|
*/
|
|
9
14
|
declare function transformElement<T>(children: ReactNode, callback: (node: ReactElement, index: number) => T): T[];
|
|
10
15
|
export = transformElement;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from "react";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/transformElement/transformElement.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* React.Fragmentを透過し、children内のReactElementをcallbackで処理した戻り値を返す
|
|
5
|
+
*
|
|
6
|
+
* `Children.map`と異なり、keyの付け直しは行わない。
|
|
7
|
+
* 別々のFragmentの中に同じkeyがあると、戻り値の配列の中でkeyが重複する。
|
|
8
|
+
* 戻り値をそのまま描画する場合は、callbackの中でkeyを付けること。
|
|
9
|
+
*
|
|
6
10
|
* @param children エレメントの子要素
|
|
7
|
-
* @param callback
|
|
11
|
+
* @param callback コールバック。indexはFragmentをまたいだ連番
|
|
12
|
+
* @returns callbackの戻り値の配列
|
|
8
13
|
*/
|
|
9
|
-
|
|
10
|
-
//#endregion
|
|
11
|
-
export { transformElement as default };
|
|
14
|
+
export default function transformElement<T>(children: ReactNode, callback: (node: ReactElement, index: number) => T): T[];
|
|
15
|
+
//#endregion
|
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _traverseChildren from "../../_helpers/_traverseChildren.mjs";
|
|
2
|
+
import { isValidElement } from "react";
|
|
2
3
|
|
|
3
4
|
//#region src/utils/transformElement/transformElement.ts
|
|
4
5
|
/**
|
|
5
6
|
* React.Fragmentを透過し、children内のReactElementをcallbackで処理した戻り値を返す
|
|
7
|
+
*
|
|
8
|
+
* `Children.map`と異なり、keyの付け直しは行わない。
|
|
9
|
+
* 別々のFragmentの中に同じkeyがあると、戻り値の配列の中でkeyが重複する。
|
|
10
|
+
* 戻り値をそのまま描画する場合は、callbackの中でkeyを付けること。
|
|
11
|
+
*
|
|
6
12
|
* @param children エレメントの子要素
|
|
7
|
-
* @param callback
|
|
13
|
+
* @param callback コールバック。indexはFragmentをまたいだ連番
|
|
14
|
+
* @returns callbackの戻り値の配列
|
|
8
15
|
*/
|
|
9
16
|
function transformElement(children, callback) {
|
|
10
17
|
const result = [];
|
|
11
|
-
|
|
18
|
+
_traverseChildren(children, isValidElement, callback, (value) => result.push(value));
|
|
12
19
|
return result;
|
|
13
20
|
}
|
|
14
21
|
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
|
-
let react = require("react");
|
|
3
|
-
let _fringeworks_utils_type_isIterable = require("@fringeworks/utils/type/isIterable");
|
|
4
|
-
_fringeworks_utils_type_isIterable = require_runtime.__toESM(_fringeworks_utils_type_isIterable, 1);
|
|
5
|
-
|
|
6
|
-
//#region src/_helpers/_traverseContent.ts
|
|
7
|
-
/**
|
|
8
|
-
* React.Fragmentを透過し、children内のReactElement、string、numberを処理する
|
|
9
|
-
* @param children エレメントの子要素
|
|
10
|
-
* @param callback コールバック
|
|
11
|
-
* @param collect コールバックの結果を収集する処理
|
|
12
|
-
* @param cursor Fragmentをまたいでindexを連番にする為のカーソル(内部再帰用)
|
|
13
|
-
*/
|
|
14
|
-
function _traverseContent(children, callback, collect = () => {}, cursor = { current: 0 }) {
|
|
15
|
-
react.Children.forEach(children, (child) => {
|
|
16
|
-
if ((0, react.isValidElement)(child)) if (child.type === react.Fragment) _traverseContent(child.props.children, callback, collect, cursor);
|
|
17
|
-
else collect(callback(child, cursor.current++));
|
|
18
|
-
else if (typeof child === "string" || typeof child === "number") collect(callback(child, cursor.current++));
|
|
19
|
-
else if ((0, _fringeworks_utils_type_isIterable.default)(child)) _traverseContent(child, callback, collect, cursor);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
module.exports = _traverseContent;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
//#region src/_helpers/_traverseContent.d.ts
|
|
4
|
-
type IndexCursor = {
|
|
5
|
-
current: number;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* React.Fragmentを透過し、children内のReactElement、string、numberを処理する
|
|
9
|
-
* @param children エレメントの子要素
|
|
10
|
-
* @param callback コールバック
|
|
11
|
-
* @param collect コールバックの結果を収集する処理
|
|
12
|
-
* @param cursor Fragmentをまたいでindexを連番にする為のカーソル(内部再帰用)
|
|
13
|
-
*/
|
|
14
|
-
declare function _traverseContent<N, T>(children: ReactNode, callback: (node: N, index: number) => T, collect?: (value: T) => void, cursor?: IndexCursor): void;
|
|
15
|
-
export = _traverseContent;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
//#region src/_helpers/_traverseContent.d.ts
|
|
4
|
-
type IndexCursor = {
|
|
5
|
-
current: number;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* React.Fragmentを透過し、children内のReactElement、string、numberを処理する
|
|
9
|
-
* @param children エレメントの子要素
|
|
10
|
-
* @param callback コールバック
|
|
11
|
-
* @param collect コールバックの結果を収集する処理
|
|
12
|
-
* @param cursor Fragmentをまたいでindexを連番にする為のカーソル(内部再帰用)
|
|
13
|
-
*/
|
|
14
|
-
declare function _traverseContent<N, T>(children: ReactNode, callback: (node: N, index: number) => T, collect?: (value: T) => void, cursor?: IndexCursor): void;
|
|
15
|
-
//#endregion
|
|
16
|
-
export { _traverseContent as default };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Children, Fragment, isValidElement } from "react";
|
|
2
|
-
import isIterable from "@fringeworks/utils/type/isIterable";
|
|
3
|
-
|
|
4
|
-
//#region src/_helpers/_traverseContent.ts
|
|
5
|
-
/**
|
|
6
|
-
* React.Fragmentを透過し、children内のReactElement、string、numberを処理する
|
|
7
|
-
* @param children エレメントの子要素
|
|
8
|
-
* @param callback コールバック
|
|
9
|
-
* @param collect コールバックの結果を収集する処理
|
|
10
|
-
* @param cursor Fragmentをまたいでindexを連番にする為のカーソル(内部再帰用)
|
|
11
|
-
*/
|
|
12
|
-
function _traverseContent(children, callback, collect = () => {}, cursor = { current: 0 }) {
|
|
13
|
-
Children.forEach(children, (child) => {
|
|
14
|
-
if (isValidElement(child)) if (child.type === Fragment) _traverseContent(child.props.children, callback, collect, cursor);
|
|
15
|
-
else collect(callback(child, cursor.current++));
|
|
16
|
-
else if (typeof child === "string" || typeof child === "number") collect(callback(child, cursor.current++));
|
|
17
|
-
else if (isIterable(child)) _traverseContent(child, callback, collect, cursor);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
//#endregion
|
|
22
|
-
export { _traverseContent as default };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
|
-
let react = require("react");
|
|
3
|
-
let _fringeworks_utils_type_isIterable = require("@fringeworks/utils/type/isIterable");
|
|
4
|
-
_fringeworks_utils_type_isIterable = require_runtime.__toESM(_fringeworks_utils_type_isIterable, 1);
|
|
5
|
-
|
|
6
|
-
//#region src/_helpers/_traverseElement.ts
|
|
7
|
-
/**
|
|
8
|
-
* React.Fragmentを透過し、children内のReactElementを処理する
|
|
9
|
-
* @param children エレメントの子要素
|
|
10
|
-
* @param callback コールバック
|
|
11
|
-
* @param collect コールバックの結果を収集する処理
|
|
12
|
-
* @param cursor Fragmentをまたいでindexを連番にする為のカーソル(内部再帰用)
|
|
13
|
-
*/
|
|
14
|
-
function _traverseElement(children, callback, collect = () => {}, cursor = { current: 0 }) {
|
|
15
|
-
react.Children.forEach(children, (child) => {
|
|
16
|
-
if ((0, react.isValidElement)(child)) if (child.type === react.Fragment) _traverseElement(child.props.children, callback, collect, cursor);
|
|
17
|
-
else collect(callback(child, cursor.current++));
|
|
18
|
-
else if ((0, _fringeworks_utils_type_isIterable.default)(child) && typeof child !== "string") _traverseElement(child, callback, collect, cursor);
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
//#endregion
|
|
23
|
-
module.exports = _traverseElement;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
//#region src/_helpers/_traverseElement.d.ts
|
|
4
|
-
type IndexCursor = {
|
|
5
|
-
current: number;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* React.Fragmentを透過し、children内のReactElementを処理する
|
|
9
|
-
* @param children エレメントの子要素
|
|
10
|
-
* @param callback コールバック
|
|
11
|
-
* @param collect コールバックの結果を収集する処理
|
|
12
|
-
* @param cursor Fragmentをまたいでindexを連番にする為のカーソル(内部再帰用)
|
|
13
|
-
*/
|
|
14
|
-
declare function _traverseElement<N, T>(children: ReactNode, callback: (node: N, index: number) => T, collect?: (value: T) => void, cursor?: IndexCursor): void;
|
|
15
|
-
export = _traverseElement;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
//#region src/_helpers/_traverseElement.d.ts
|
|
4
|
-
type IndexCursor = {
|
|
5
|
-
current: number;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* React.Fragmentを透過し、children内のReactElementを処理する
|
|
9
|
-
* @param children エレメントの子要素
|
|
10
|
-
* @param callback コールバック
|
|
11
|
-
* @param collect コールバックの結果を収集する処理
|
|
12
|
-
* @param cursor Fragmentをまたいでindexを連番にする為のカーソル(内部再帰用)
|
|
13
|
-
*/
|
|
14
|
-
declare function _traverseElement<N, T>(children: ReactNode, callback: (node: N, index: number) => T, collect?: (value: T) => void, cursor?: IndexCursor): void;
|
|
15
|
-
//#endregion
|
|
16
|
-
export { _traverseElement as default };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Children, Fragment, isValidElement } from "react";
|
|
2
|
-
import isIterable from "@fringeworks/utils/type/isIterable";
|
|
3
|
-
|
|
4
|
-
//#region src/_helpers/_traverseElement.ts
|
|
5
|
-
/**
|
|
6
|
-
* React.Fragmentを透過し、children内のReactElementを処理する
|
|
7
|
-
* @param children エレメントの子要素
|
|
8
|
-
* @param callback コールバック
|
|
9
|
-
* @param collect コールバックの結果を収集する処理
|
|
10
|
-
* @param cursor Fragmentをまたいでindexを連番にする為のカーソル(内部再帰用)
|
|
11
|
-
*/
|
|
12
|
-
function _traverseElement(children, callback, collect = () => {}, cursor = { current: 0 }) {
|
|
13
|
-
Children.forEach(children, (child) => {
|
|
14
|
-
if (isValidElement(child)) if (child.type === Fragment) _traverseElement(child.props.children, callback, collect, cursor);
|
|
15
|
-
else collect(callback(child, cursor.current++));
|
|
16
|
-
else if (isIterable(child) && typeof child !== "string") _traverseElement(child, callback, collect, cursor);
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
export { _traverseElement as default };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __exportAll = (all, no_symbols) => {
|
|
9
|
-
let target = {};
|
|
10
|
-
for (var name in all) {
|
|
11
|
-
__defProp(target, name, {
|
|
12
|
-
get: all[name],
|
|
13
|
-
enumerable: true
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
if (!no_symbols) {
|
|
17
|
-
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
18
|
-
}
|
|
19
|
-
return target;
|
|
20
|
-
};
|
|
21
|
-
var __copyProps = (to, from, except, desc) => {
|
|
22
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
24
|
-
key = keys[i];
|
|
25
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
26
|
-
__defProp(to, key, {
|
|
27
|
-
get: ((k) => from[k]).bind(null, key),
|
|
28
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return to;
|
|
34
|
-
};
|
|
35
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
36
|
-
value: mod,
|
|
37
|
-
enumerable: true
|
|
38
|
-
}) : target, mod));
|
|
39
|
-
|
|
40
|
-
//#endregion
|
|
41
|
-
|
|
42
|
-
exports.__exportAll = __exportAll;
|
|
43
|
-
exports.__toESM = __toESM;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __exportAll = (all, no_symbols) => {
|
|
4
|
-
let target = {};
|
|
5
|
-
for (var name in all) {
|
|
6
|
-
__defProp(target, name, {
|
|
7
|
-
get: all[name],
|
|
8
|
-
enumerable: true
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
if (!no_symbols) {
|
|
12
|
-
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
-
}
|
|
14
|
-
return target;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
//#endregion
|
|
18
|
-
export { __exportAll };
|