@onepercentio/one-ui 0.13.9-rc2 → 0.14.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.
- package/WebpackConfigs/scripts/css-inliner.ts +19 -14
- package/dist/hooks/ui/usePaginationControls.d.ts +1 -1
- package/dist/hooks/ui/usePaginationControls.js +51 -4
- package/dist/hooks/ui/usePaginationControls.js.map +1 -1
- package/dist/utils/html.utils.d.ts +1 -0
- package/dist/utils/html.utils.js +8 -0
- package/dist/utils/html.utils.js.map +1 -0
- package/package.json +1 -1
- package/dist/components/PaginationIndicator/PaginationIndicator.module.scss +0 -48
- package/dist/components/Recycler/Recycler.d.ts +0 -4
- package/dist/components/Recycler/Recycler.js +0 -14
- package/dist/components/Recycler/Recycler.js.map +0 -1
- package/dist/components/Recycler/Recycler.module.scss +0 -0
- package/dist/components/Recycler/index.d.ts +0 -1
- package/dist/components/Recycler/index.js +0 -9
- package/dist/components/Recycler/index.js.map +0 -1
- package/dist/context/AsyncProcessQueue.d.ts +0 -71
- package/dist/context/AsyncProcessQueue.development.d.ts +0 -8
- package/dist/context/AsyncProcessQueue.development.js +0 -42
- package/dist/context/AsyncProcessQueue.development.js.map +0 -1
- package/dist/context/AsyncProcessQueue.js +0 -186
- package/dist/context/AsyncProcessQueue.js.map +0 -1
- package/dist/hooks/usePaginationControls.d.ts +0 -5
- package/dist/hooks/usePaginationControls.js +0 -8
- package/dist/hooks/usePaginationControls.js.map +0 -1
- package/dist/utils.d.ts +0 -44
- package/dist/utils.js +0 -3
- package/dist/utils.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
function getTextNodesIn(elem: HTMLElement): ChildNode[] {
|
|
2
2
|
var textNodes: ChildNode[] = [];
|
|
3
3
|
if (elem) {
|
|
4
|
-
for (var nodes = elem.childNodes, i = nodes.length; i--;) {
|
|
5
|
-
var node = nodes[i],
|
|
4
|
+
for (var nodes = elem.childNodes, i = nodes.length; i--; ) {
|
|
5
|
+
var node = nodes[i],
|
|
6
|
+
nodeType = node.nodeType;
|
|
6
7
|
if (nodeType == 3) {
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
else if (nodeType == 1 || nodeType == 9 || nodeType == 11) {
|
|
8
|
+
textNodes.push(node);
|
|
9
|
+
} else if (nodeType == 1 || nodeType == 9 || nodeType == 11) {
|
|
10
10
|
textNodes = textNodes.concat(getTextNodesIn(node as HTMLElement));
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -23,6 +23,8 @@ export default function inlineCSS() {
|
|
|
23
23
|
allEls.forEach((el) => {
|
|
24
24
|
const styles = window.getComputedStyle(el);
|
|
25
25
|
|
|
26
|
+
if (el.getAttribute("data-debug")) console.log(styles);
|
|
27
|
+
|
|
26
28
|
const inlined = Array.from(styles)
|
|
27
29
|
.map((k) => `${k}: ${styles.getPropertyValue(k)}`)
|
|
28
30
|
.join("; ")
|
|
@@ -35,16 +37,19 @@ export default function inlineCSS() {
|
|
|
35
37
|
el.setAttribute("style", s);
|
|
36
38
|
});
|
|
37
39
|
|
|
38
|
-
getTextNodesIn(document.body).forEach(n => {
|
|
39
|
-
n.replaceWith(
|
|
40
|
-
.
|
|
41
|
-
|
|
42
|
-
(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
getTextNodesIn(document.body).forEach((n) => {
|
|
41
|
+
n.replaceWith(
|
|
42
|
+
...n.textContent
|
|
43
|
+
.split(/\n/g)
|
|
44
|
+
.reduce(
|
|
45
|
+
(r, txt, i, arr) =>
|
|
46
|
+
arr.length - 1 === i
|
|
47
|
+
? [...r, txt]
|
|
48
|
+
: [...r, txt, document.createElement("br")],
|
|
49
|
+
[] as (Node | string)[]
|
|
50
|
+
)
|
|
46
51
|
);
|
|
47
|
-
})
|
|
52
|
+
});
|
|
48
53
|
|
|
49
54
|
if (process.env.NODE_ENV !== "test")
|
|
50
55
|
document.querySelectorAll("style").forEach((e) => e.remove());
|
|
@@ -2,7 +2,7 @@ import { RefObject } from "react";
|
|
|
2
2
|
/**
|
|
3
3
|
* This hook handles the display of pagination controls for the user to move to another page
|
|
4
4
|
*/
|
|
5
|
-
export default function usePaginationControls(containerRef: RefObject<HTMLDivElement>, { snapToPage, baseWidth, snapToCutElement, }?: {
|
|
5
|
+
export default function usePaginationControls(containerRef: RefObject<HTMLDivElement>, { snapToPage, baseWidth, snapToCutElement: _snapToCutElement, }?: {
|
|
6
6
|
snapToPage?: boolean;
|
|
7
7
|
baseWidth?: number;
|
|
8
8
|
/** This will scroll only until the partially visible element is at the border, instead of scrolling all the container */
|
|
@@ -22,6 +22,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
};
|
|
25
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
38
|
};
|
|
@@ -32,22 +43,23 @@ const react_1 = __importStar(require("react"));
|
|
|
32
43
|
const FadeIn_1 = __importDefault(require("../../components/FadeIn"));
|
|
33
44
|
const OneUIProvider_1 = require("../../context/OneUIProvider");
|
|
34
45
|
const usePaginationControls_module_scss_1 = __importDefault(require("./usePaginationControls.module.scss"));
|
|
46
|
+
const html_utils_1 = require("../../utils/html.utils");
|
|
35
47
|
/**
|
|
36
48
|
* This hook handles the display of pagination controls for the user to move to another page
|
|
37
49
|
*/
|
|
38
|
-
function usePaginationControls(containerRef, { snapToPage, baseWidth, snapToCutElement, } = {}) {
|
|
50
|
+
function usePaginationControls(containerRef, { snapToPage, baseWidth, snapToCutElement: _snapToCutElement, } = {}) {
|
|
39
51
|
const [[leftControl, rightControl], setControls] = (0, react_1.useState)([false, false]);
|
|
40
52
|
const LeftControl = (0, OneUIProvider_1.useOneUIConfig)("hook.ui.usePaginationControls.LeftControl");
|
|
41
53
|
const RightControl = (0, OneUIProvider_1.useOneUIConfig)("hook.ui.usePaginationControls.RightControl");
|
|
42
54
|
const className = (0, OneUIProvider_1.useOneUIConfig)("hook.ui.usePaginationControls.className", "");
|
|
43
|
-
function move(direction) {
|
|
55
|
+
function move(direction, snapToCutElement = _snapToCutElement) {
|
|
44
56
|
return () => {
|
|
45
57
|
if (snapToCutElement !== null && snapToCutElement !== void 0 ? snapToCutElement : false) {
|
|
46
58
|
const childBaseWidth = baseWidth || containerRef.current.firstElementChild.clientWidth;
|
|
47
59
|
const howMuchDoesTheScrollAddsUpTo = containerRef.current.scrollLeft / childBaseWidth -
|
|
48
60
|
Math.floor(containerRef.current.scrollLeft / childBaseWidth);
|
|
49
61
|
const howMuchElementsFitOnAPage = containerRef.current.clientWidth / childBaseWidth;
|
|
50
|
-
const howMuchElementsFullyFitOnAPage = Math.floor(howMuchElementsFitOnAPage);
|
|
62
|
+
const howMuchElementsFullyFitOnAPage = Math.floor(howMuchElementsFitOnAPage) || 1;
|
|
51
63
|
const directionScale = direction === "l"
|
|
52
64
|
? 1 - howMuchDoesTheScrollAddsUpTo
|
|
53
65
|
: howMuchDoesTheScrollAddsUpTo;
|
|
@@ -57,6 +69,7 @@ function usePaginationControls(containerRef, { snapToPage, baseWidth, snapToCutE
|
|
|
57
69
|
const howMuchToScroll = (containerRef.current.clientWidth -
|
|
58
70
|
childBaseWidth * howMuchOfTheRemainingElementIsShown) *
|
|
59
71
|
(direction === "l" ? -1 : 1);
|
|
72
|
+
console.log("Scrolling", containerRef.current, "to", howMuchToScroll);
|
|
60
73
|
containerRef.current.scrollBy({
|
|
61
74
|
left: howMuchToScroll,
|
|
62
75
|
behavior: "smooth",
|
|
@@ -94,8 +107,42 @@ function usePaginationControls(containerRef, { snapToPage, baseWidth, snapToCutE
|
|
|
94
107
|
const el = containerRef.current;
|
|
95
108
|
const throttledCheck = (0, throttle_1.default)(checkControlsRequirement, 1000 / 4);
|
|
96
109
|
checkControlsRequirement();
|
|
110
|
+
let startingX;
|
|
111
|
+
let lastX;
|
|
112
|
+
const onTouchStart = (_a) => {
|
|
113
|
+
var { touches } = _a, e = __rest(_a, ["touches"]);
|
|
114
|
+
if (!(0, html_utils_1.isSameTarget)(e))
|
|
115
|
+
return;
|
|
116
|
+
const { pageX } = touches.item(0);
|
|
117
|
+
startingX = pageX;
|
|
118
|
+
console.log(startingX);
|
|
119
|
+
};
|
|
120
|
+
const onTouchMove = (_a) => {
|
|
121
|
+
var { touches } = _a, e = __rest(_a, ["touches"]);
|
|
122
|
+
if (!(0, html_utils_1.isSameTarget)(e))
|
|
123
|
+
return;
|
|
124
|
+
const touch = touches.item(0);
|
|
125
|
+
lastX = touch.pageX;
|
|
126
|
+
console.log(lastX.toFixed(0), startingX === null || startingX === void 0 ? void 0 : startingX.toFixed(0));
|
|
127
|
+
};
|
|
128
|
+
const onTouchEnd = (e) => {
|
|
129
|
+
if (!lastX)
|
|
130
|
+
return;
|
|
131
|
+
const dir = lastX > startingX ? "l" : "r";
|
|
132
|
+
console.log("Moving to", dir);
|
|
133
|
+
move(dir, true)();
|
|
134
|
+
startingX = undefined;
|
|
135
|
+
};
|
|
97
136
|
el.addEventListener("scroll", throttledCheck);
|
|
98
|
-
|
|
137
|
+
el.addEventListener("touchstart", onTouchStart);
|
|
138
|
+
el.addEventListener("touchend", onTouchEnd);
|
|
139
|
+
el.addEventListener("touchmove", onTouchMove);
|
|
140
|
+
return () => {
|
|
141
|
+
el.removeEventListener("scroll", throttledCheck);
|
|
142
|
+
el.removeEventListener("touchstart", onTouchStart);
|
|
143
|
+
el.removeEventListener("touchend", onTouchEnd);
|
|
144
|
+
el.removeEventListener("touchend", onTouchEnd);
|
|
145
|
+
};
|
|
99
146
|
}, []);
|
|
100
147
|
return {
|
|
101
148
|
controls: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePaginationControls.js","sourceRoot":"","sources":["../../../src/hooks/ui/usePaginationControls.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePaginationControls.js","sourceRoot":"","sources":["../../../src/hooks/ui/usePaginationControls.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAAuC;AACvC,+CAA8D;AAC9D,qEAA2C;AAC3C,+DAA6D;AAC7D,4GAAyD;AACzD,uDAAsD;AAEtD;;GAEG;AACH,SAAwB,qBAAqB,CAC3C,YAAuC,EACvC,EACE,UAAU,EACV,SAAS,EACT,gBAAgB,EAAE,iBAAiB,MAMjC,EAAE;IAEN,MAAM,CAAC,CAAC,WAAW,EAAE,YAAY,CAAC,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAEzD,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IAClB,MAAM,WAAW,GAAG,IAAA,8BAAc,EAChC,2CAA2C,CAC5C,CAAC;IACF,MAAM,YAAY,GAAG,IAAA,8BAAc,EACjC,4CAA4C,CAC7C,CAAC;IACF,MAAM,SAAS,GAAG,IAAA,8BAAc,EAC9B,yCAAyC,EACzC,EAAE,CACH,CAAC;IACF,SAAS,IAAI,CAAC,SAAoB,EAAE,gBAAgB,GAAG,iBAAiB;QACtE,OAAO,GAAG,EAAE;YACV,IAAI,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,GAAI,KAAK,EAAE;gBAC7B,MAAM,cAAc,GAClB,SAAU,IAAI,YAAY,CAAC,OAAQ,CAAC,iBAA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AAW,CAAC,CAAC;QAC9C,OAAO,GAAG,EAAE;YACV,EAAE,CAAC,mBAAmB,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;YACjD,EAAE,CAAC,mBAAmB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;YACnD,EAAE,CAAC,mBAAmB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;YAC/C,EAAE,CAAC,mBAAmB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QACjD,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,QAAQ,EAAE;YACR,8BAAC,gBAAI,IACH,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,GAAG,2CAAM,CAAC,IAAI,IAAI,2CAAM,CAAC,OAAO,IAAI,SAAS,EAAE,iBAC7C,4BAA4B,CAAC,YAAY,EACtD,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,IAEjB,WAAW,IAAI,8BAAC,WAAW,OAAG,CAC1B;YACP,8BAAC,gBAAI,IACH,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,GAAG,2CAAM,CAAC,KAAK,IAAI,2CAAM,CAAC,OAAO,IAAI,SAAS,EAAE,iBAC9C,4BAA4B,CAAC,aAAa,EACvD,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,IAEjB,YAAY,IAAI,8BAAC,YAAY,OAAG,CAC5B;SACR;QACD,wBAAwB;KACzB,CAAC;AACJ,CAAC;AAzJD,wCAyJC;AAED,IAAY,4BAGX;AAHD,WAAY,4BAA4B;IACtC,uDAAuB,CAAA;IACvB,wDAAwB,CAAA;AAC1B,CAAC,EAHW,4BAA4B,GAA5B,oCAA4B,KAA5B,oCAA4B,QAGvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isSameTarget({ target, currentTarget }: Event): boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSameTarget = void 0;
|
|
4
|
+
function isSameTarget({ target, currentTarget }) {
|
|
5
|
+
return target === currentTarget;
|
|
6
|
+
}
|
|
7
|
+
exports.isSameTarget = isSameTarget;
|
|
8
|
+
//# sourceMappingURL=html.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.utils.js","sourceRoot":"","sources":["../../src/utils/html.utils.ts"],"names":[],"mappings":";;;AAAA,SAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,aAAa,EAAS;IAC3D,OAAO,MAAM,KAAK,aAAa,CAAC;AAClC,CAAC;AAFD,oCAEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onepercentio/one-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"description": "A set of reusable components created through the development of Onepercent projects",
|
|
5
5
|
"repository": "git@github.com:onepercentio/one-ui.git",
|
|
6
6
|
"author": "Murilo Oliveira de Araujo <murilo.araujo@onepercent.io>",
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
$x: 0.1em;
|
|
2
|
-
|
|
3
|
-
.root {
|
|
4
|
-
position: relative;
|
|
5
|
-
height: 1.5em;
|
|
6
|
-
display: flex;
|
|
7
|
-
align-items: center;
|
|
8
|
-
justify-content: center;
|
|
9
|
-
filter: contrast(20);
|
|
10
|
-
background-color: #fff;
|
|
11
|
-
overflow: hidden;
|
|
12
|
-
> * {
|
|
13
|
-
height: 1em * 1.2;
|
|
14
|
-
width: 1em * 1.2;
|
|
15
|
-
margin: 0px 0.1em;
|
|
16
|
-
border-radius: 0.5em * 1.2;
|
|
17
|
-
background-color: #000;
|
|
18
|
-
position: relative;
|
|
19
|
-
filter: blur($x);
|
|
20
|
-
opacity: 0.485;
|
|
21
|
-
// animation-name: a;
|
|
22
|
-
// animation-iteration-count: infinite;
|
|
23
|
-
// animation-duration: 1s;
|
|
24
|
-
// animation-timing-function: linear;
|
|
25
|
-
// animation-direction: alternate;
|
|
26
|
-
}
|
|
27
|
-
&::after {
|
|
28
|
-
content: " ";
|
|
29
|
-
position: absolute;
|
|
30
|
-
background-color: #00f;
|
|
31
|
-
filter: blur($x * 2);
|
|
32
|
-
height: 1em * 0.8;
|
|
33
|
-
width: 1em * 0.8;
|
|
34
|
-
border-radius: 0.5em;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// @keyframes a {
|
|
39
|
-
// 0% {
|
|
40
|
-
// right: 2em;
|
|
41
|
-
// }
|
|
42
|
-
// 50% {
|
|
43
|
-
// right: 0em;
|
|
44
|
-
// }
|
|
45
|
-
// 100% {
|
|
46
|
-
// right: -2em;
|
|
47
|
-
// }
|
|
48
|
-
// }
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const react_1 = __importDefault(require("react"));
|
|
7
|
-
/**
|
|
8
|
-
* It shows only a limit of elements
|
|
9
|
-
**/
|
|
10
|
-
function Recycler() {
|
|
11
|
-
return react_1.default.createElement(react_1.default.Fragment, null, "Recycler");
|
|
12
|
-
}
|
|
13
|
-
exports.default = Recycler;
|
|
14
|
-
//# sourceMappingURL=Recycler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Recycler.js","sourceRoot":"","sources":["../../../src/components/Recycler/Recycler.tsx"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAG1B;;IAEI;AACJ,SAAwB,QAAQ;IAC5B,OAAO,yEAAa,CAAC;AACzB,CAAC;AAFD,2BAEC"}
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './Recycler';
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var Recycler_1 = require("./Recycler");
|
|
8
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(Recycler_1).default; } });
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Recycler/index.tsx"],"names":[],"mappings":";;;;;;AAAA,uCAAqC;AAA5B,oHAAA,OAAO,OAAA"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import React, { PropsWithChildren, ReactElement, RefObject } from "react";
|
|
2
|
-
export declare enum AsyncQueueErrors {
|
|
3
|
-
RECOVERY_IS_NOT_BEING_CALLED = "A recovery is not set for this call. If the user reloads the page, this process will not return to the async list"
|
|
4
|
-
}
|
|
5
|
-
declare type ReactElementWithState = ReactElement & {
|
|
6
|
-
status: "loading" | "succeded" | "failed";
|
|
7
|
-
};
|
|
8
|
-
declare type ContextShape = {
|
|
9
|
-
targetElRef: RefObject<HTMLDivElement>;
|
|
10
|
-
pendingTransactions: ReturnType<typeof useCounter>;
|
|
11
|
-
UIs: ReactElementWithState[];
|
|
12
|
-
setUIs: (updater: (previous: ReactElementWithState[]) => ReactElementWithState[]) => void;
|
|
13
|
-
watchPromise: <T extends keyof OnepercentUtility.AsyncQueue.UIModels>(promise: Promise<any>, retryFunc: () => Promise<any>, uiType: T, ...uiArgs: OnepercentUtility.AsyncQueue.UIModels[T]) => void;
|
|
14
|
-
recoveries: {
|
|
15
|
-
[k in keyof OnepercentUtility.AsyncQueue.RecoveryTypes]: {
|
|
16
|
-
write: (...args: OnepercentUtility.AsyncQueue.RecoveryTypes[k]) => void;
|
|
17
|
-
clear: (...args: OnepercentUtility.AsyncQueue.RecoveryTypes[k]) => void;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
declare function useCounter(): {
|
|
22
|
-
count: number;
|
|
23
|
-
setCounter: React.Dispatch<React.SetStateAction<number>>;
|
|
24
|
-
increment: () => void;
|
|
25
|
-
decrement: () => void;
|
|
26
|
-
reset: () => void;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* This propagates the utilitary functions
|
|
30
|
-
*/
|
|
31
|
-
export declare function AsyncProcessQueueProvider<R extends OnepercentUtility.AsyncQueue.RecoveryTypes = OnepercentUtility.AsyncQueue.RecoveryTypes, T extends keyof OnepercentUtility.AsyncQueue.UIModels = keyof OnepercentUtility.AsyncQueue.UIModels>({ children, recoveries, uiFactory, }: PropsWithChildren<{
|
|
32
|
-
recoveries: {
|
|
33
|
-
[k in keyof R]: {
|
|
34
|
-
write: (...args: R[k]) => void;
|
|
35
|
-
clear: (...args: R[k]) => void;
|
|
36
|
-
recover: () => [
|
|
37
|
-
promiseToWaitFor: Promise<any>,
|
|
38
|
-
promiseRetryFunction: () => Promise<any>,
|
|
39
|
-
uiType: T,
|
|
40
|
-
...uiArgs: OnepercentUtility.AsyncQueue.UIModels[T]
|
|
41
|
-
][];
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
uiFactory: (type: keyof OnepercentUtility.AsyncQueue.UIModels) => UIStateFactory;
|
|
45
|
-
}>): JSX.Element;
|
|
46
|
-
export declare function useAsyncProcessQueueContext(): ContextShape;
|
|
47
|
-
declare type AsyncProcessStatuses = "loading" | "succeded" | "failed";
|
|
48
|
-
export interface UIStateFactory {
|
|
49
|
-
(status: AsyncProcessStatuses, error?: Error, dismiss?: () => void, retry?: () => void): ReactElement;
|
|
50
|
-
}
|
|
51
|
-
/** This exposes the recovery registration functions available for abtract types of calls */
|
|
52
|
-
export declare function useRecoveries<R extends OnepercentUtility.AsyncQueue.RecoveryTypes = OnepercentUtility.AsyncQueue.RecoveryTypes>(): {
|
|
53
|
-
[K in keyof R]: {
|
|
54
|
-
write(...args: R[K]): void;
|
|
55
|
-
clear(...args: R[K]): void;
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
declare type Params<U extends keyof OnepercentUtility.AsyncQueue.UIModels = keyof OnepercentUtility.AsyncQueue.UIModels> = [U, ...OnepercentUtility.AsyncQueue.UIModels[U]];
|
|
59
|
-
/**
|
|
60
|
-
* This function wraps other async functions and decides when the ongoing promise should be put on the queue or not
|
|
61
|
-
*/
|
|
62
|
-
export declare function useAsyncProcessQueue<T extends {
|
|
63
|
-
[k: string]: (...args: any[]) => Promise<any>;
|
|
64
|
-
}>(functionsToQueue: T, UIParamsFactory: <F extends keyof T>(functionName: F) => Params): T & {
|
|
65
|
-
elToTransitionToQueue: RefObject<HTMLDivElement>;
|
|
66
|
-
/**
|
|
67
|
-
* Function that wraps the current running actions and animates to the target queue element
|
|
68
|
-
*/
|
|
69
|
-
wrapQueue: () => void;
|
|
70
|
-
};
|
|
71
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Binds to the promise and checks if a restore has been registered when finishing
|
|
3
|
-
* @param promise
|
|
4
|
-
*/
|
|
5
|
-
export declare function securePromise<T>(promise: Promise<T>): Promise<T>;
|
|
6
|
-
/** This registers that a registration has been made an this will be recoverable */
|
|
7
|
-
export declare function countRegistration(): void;
|
|
8
|
-
export declare function resetRegistrationCounter(): void;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// This file has been created to optimize module bundling and ignore development utility
|
|
3
|
-
// when on production by unused imports
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.resetRegistrationCounter = exports.countRegistration = exports.securePromise = void 0;
|
|
6
|
-
const AsyncProcessQueue_1 = require("./AsyncProcessQueue");
|
|
7
|
-
/** This count how many registrations have been made */
|
|
8
|
-
let amountOfRestorationThatShouldBeNeeded = 0;
|
|
9
|
-
/**
|
|
10
|
-
* Binds to the promise and checks if a restore has been registered when finishing
|
|
11
|
-
* @param promise
|
|
12
|
-
*/
|
|
13
|
-
function securePromise(promise) {
|
|
14
|
-
function validate() {
|
|
15
|
-
if (amountOfRestorationThatShouldBeNeeded === 0) {
|
|
16
|
-
throw new Error(AsyncProcessQueue_1.AsyncQueueErrors.RECOVERY_IS_NOT_BEING_CALLED);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return promise
|
|
20
|
-
.then((e) => {
|
|
21
|
-
validate();
|
|
22
|
-
return e;
|
|
23
|
-
})
|
|
24
|
-
.catch((e) => {
|
|
25
|
-
validate();
|
|
26
|
-
return Promise.reject(e);
|
|
27
|
-
})
|
|
28
|
-
.finally(() => amountOfRestorationThatShouldBeNeeded > 0
|
|
29
|
-
? amountOfRestorationThatShouldBeNeeded--
|
|
30
|
-
: 0);
|
|
31
|
-
}
|
|
32
|
-
exports.securePromise = securePromise;
|
|
33
|
-
/** This registers that a registration has been made an this will be recoverable */
|
|
34
|
-
function countRegistration() {
|
|
35
|
-
amountOfRestorationThatShouldBeNeeded++;
|
|
36
|
-
}
|
|
37
|
-
exports.countRegistration = countRegistration;
|
|
38
|
-
function resetRegistrationCounter() {
|
|
39
|
-
amountOfRestorationThatShouldBeNeeded = 0;
|
|
40
|
-
}
|
|
41
|
-
exports.resetRegistrationCounter = resetRegistrationCounter;
|
|
42
|
-
//# sourceMappingURL=AsyncProcessQueue.development.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AsyncProcessQueue.development.js","sourceRoot":"","sources":["../../src/context/AsyncProcessQueue.development.tsx"],"names":[],"mappings":";AAAA,wFAAwF;AACxF,uCAAuC;;;AAEvC,2DAAuD;AAEvD,uDAAuD;AACvD,IAAI,qCAAqC,GAAG,CAAC,CAAC;AAE9C;;;GAGG;AACH,SAAgB,aAAa,CAAI,OAAmB;IAClD,SAAS,QAAQ;QACf,IAAI,qCAAqC,KAAK,CAAC,EAAE;YAC/C,MAAM,IAAI,KAAK,CAAC,oCAAgB,CAAC,4BAA4B,CAAC,CAAC;SAChE;IACH,CAAC;IACD,OAAO,OAAO;SACX,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;QACV,QAAQ,EAAE,CAAC;QACX,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACX,QAAQ,EAAE,CAAC;QACX,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC,CAAC;SACD,OAAO,CAAC,GAAG,EAAE,CACZ,qCAAqC,GAAG,CAAC;QACvC,CAAC,CAAC,qCAAqC,EAAE;QACzC,CAAC,CAAC,CAAC,CACN,CAAC;AACN,CAAC;AApBD,sCAoBC;AAED,mFAAmF;AACnF,SAAgB,iBAAiB;IAC/B,qCAAqC,EAAE,CAAC;AAC1C,CAAC;AAFD,8CAEC;AAED,SAAgB,wBAAwB;IACtC,qCAAqC,GAAG,CAAC,CAAC;AAC5C,CAAC;AAFD,4DAEC"}
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.useAsyncProcessQueue = exports.useRecoveries = exports.useAsyncProcessQueueContext = exports.AsyncProcessQueueProvider = exports.AsyncQueueErrors = void 0;
|
|
27
|
-
const react_1 = __importStar(require("react"));
|
|
28
|
-
const AsyncProcessQueue_development_1 = require("./AsyncProcessQueue.development");
|
|
29
|
-
var AsyncQueueErrors;
|
|
30
|
-
(function (AsyncQueueErrors) {
|
|
31
|
-
AsyncQueueErrors["RECOVERY_IS_NOT_BEING_CALLED"] = "A recovery is not set for this call. If the user reloads the page, this process will not return to the async list";
|
|
32
|
-
})(AsyncQueueErrors = exports.AsyncQueueErrors || (exports.AsyncQueueErrors = {}));
|
|
33
|
-
const Context = (0, react_1.createContext)(null);
|
|
34
|
-
function useCounter() {
|
|
35
|
-
const [count, setCounter] = (0, react_1.useState)(0);
|
|
36
|
-
return {
|
|
37
|
-
count,
|
|
38
|
-
setCounter,
|
|
39
|
-
increment: () => setCounter((prev) => prev + 1),
|
|
40
|
-
decrement: () => setCounter((prev) => prev - 1),
|
|
41
|
-
reset: () => setCounter(0),
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* This propagates the utilitary functions
|
|
46
|
-
*/
|
|
47
|
-
function AsyncProcessQueueProvider({ children, recoveries, uiFactory, }) {
|
|
48
|
-
const targetRef = (0, react_1.useRef)(null);
|
|
49
|
-
const pendingCounter = useCounter();
|
|
50
|
-
const [UIs, setUIs] = (0, react_1.useState)([]);
|
|
51
|
-
const _recoveries = process.env.NODE_ENV === "development"
|
|
52
|
-
? Object.entries(recoveries).reduce((r, [k, v]) => (Object.assign(Object.assign({}, r), { [k]: Object.assign(Object.assign({}, v), { write: (...args) => {
|
|
53
|
-
(0, AsyncProcessQueue_development_1.countRegistration)();
|
|
54
|
-
return v.write(...args);
|
|
55
|
-
} }) })), {})
|
|
56
|
-
: recoveries;
|
|
57
|
-
const watchPromise = (0, react_1.useCallback)((promise, retry, uiType, ...uiParams) => {
|
|
58
|
-
const Factory = uiFactory(uiType);
|
|
59
|
-
const LoadingUIInstance = Object.assign(Object.assign({}, Factory("loading")), { status: "loading" });
|
|
60
|
-
if (process.env.NODE_ENV === "development" && !LoadingUIInstance.key)
|
|
61
|
-
throw new Error(`The UI generate for the async process should have a key`);
|
|
62
|
-
setUIs((prev) => [
|
|
63
|
-
...prev.filter((a) => a.key !== LoadingUIInstance.key),
|
|
64
|
-
LoadingUIInstance,
|
|
65
|
-
]);
|
|
66
|
-
promise.then((result) => {
|
|
67
|
-
// Write success UI
|
|
68
|
-
setUIs((prev) => prev.map((a) => a === LoadingUIInstance
|
|
69
|
-
? Object.assign(Object.assign({}, Factory("succeded")), { status: "succeded" }) : a));
|
|
70
|
-
return result;
|
|
71
|
-
});
|
|
72
|
-
promise.catch((error) => {
|
|
73
|
-
const UIInstance = Factory("failed", error, () => setUIs((prev) => prev.filter((ui) => ui !== UIInstance)), () => watchPromise(retry(), retry, uiType, ...uiParams));
|
|
74
|
-
// Write success UI
|
|
75
|
-
setUIs((prev) => prev.map((a) => a === LoadingUIInstance ? Object.assign(Object.assign({}, UIInstance), { status: "failed" }) : a));
|
|
76
|
-
throw error;
|
|
77
|
-
});
|
|
78
|
-
return promise;
|
|
79
|
-
}, []);
|
|
80
|
-
(0, react_1.useEffect)(() => {
|
|
81
|
-
for (let recovery in recoveries) {
|
|
82
|
-
const recoveredProcesses = recoveries[recovery].recover();
|
|
83
|
-
for (let [promise, ...recoveredProcess] of recoveredProcesses) {
|
|
84
|
-
watchPromise(promise.catch(() => { }), ...recoveredProcess);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}, []);
|
|
88
|
-
return (react_1.default.createElement(Context.Provider, { value: {
|
|
89
|
-
targetElRef: targetRef,
|
|
90
|
-
pendingTransactions: pendingCounter,
|
|
91
|
-
watchPromise,
|
|
92
|
-
setUIs,
|
|
93
|
-
UIs,
|
|
94
|
-
recoveries: _recoveries,
|
|
95
|
-
} }, children));
|
|
96
|
-
}
|
|
97
|
-
exports.AsyncProcessQueueProvider = AsyncProcessQueueProvider;
|
|
98
|
-
function useAsyncProcessQueueContext() {
|
|
99
|
-
return (0, react_1.useContext)(Context);
|
|
100
|
-
}
|
|
101
|
-
exports.useAsyncProcessQueueContext = useAsyncProcessQueueContext;
|
|
102
|
-
function calculateCenter(el) {
|
|
103
|
-
const boundsOnViewport = el.getBoundingClientRect();
|
|
104
|
-
return {
|
|
105
|
-
x: boundsOnViewport.x + boundsOnViewport.width / 2,
|
|
106
|
-
y: boundsOnViewport.y + boundsOnViewport.height / 2,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
/** This exposes the recovery registration functions available for abtract types of calls */
|
|
110
|
-
function useRecoveries() {
|
|
111
|
-
return useAsyncProcessQueueContext().recoveries;
|
|
112
|
-
}
|
|
113
|
-
exports.useRecoveries = useRecoveries;
|
|
114
|
-
/**
|
|
115
|
-
* This function wraps other async functions and decides when the ongoing promise should be put on the queue or not
|
|
116
|
-
*/
|
|
117
|
-
function useAsyncProcessQueue(functionsToQueue, UIParamsFactory) {
|
|
118
|
-
const loadingRef = (0, react_1.useRef)(null);
|
|
119
|
-
const wrapped = (0, react_1.useRef)(false);
|
|
120
|
-
const elToTransitionToQueue = (0, react_1.useRef)(null);
|
|
121
|
-
const { targetElRef: targetEl, watchPromise } = (0, react_1.useContext)(Context);
|
|
122
|
-
const initialCenter = (0, react_1.useRef)();
|
|
123
|
-
(0, react_1.useEffect)(() => {
|
|
124
|
-
if (targetEl.current)
|
|
125
|
-
initialCenter.current = {
|
|
126
|
-
center: calculateCenter(targetEl.current),
|
|
127
|
-
dimensions: [
|
|
128
|
-
targetEl.current.clientWidth,
|
|
129
|
-
targetEl.current.clientHeight,
|
|
130
|
-
],
|
|
131
|
-
};
|
|
132
|
-
}, []);
|
|
133
|
-
const wrapQueue = (0, react_1.useCallback)(() => {
|
|
134
|
-
if (wrapped.current || !loadingRef.current || !targetEl.current)
|
|
135
|
-
return;
|
|
136
|
-
const wrapUI = loadingRef.current;
|
|
137
|
-
wrapped.current = true;
|
|
138
|
-
const clone = elToTransitionToQueue.current.cloneNode(true);
|
|
139
|
-
const currPositionOnViewport = elToTransitionToQueue.current.getBoundingClientRect();
|
|
140
|
-
const currPosCenter = calculateCenter(elToTransitionToQueue.current);
|
|
141
|
-
const targetCenter = targetEl.current
|
|
142
|
-
? calculateCenter(targetEl.current)
|
|
143
|
-
: initialCenter.current.center;
|
|
144
|
-
clone.style.position = "fixed";
|
|
145
|
-
clone.style.top = `${currPositionOnViewport.top}px`;
|
|
146
|
-
clone.style.left = `${currPositionOnViewport.left}px`;
|
|
147
|
-
clone.style.width = `${currPositionOnViewport.width}px`;
|
|
148
|
-
clone.style.height = `${currPositionOnViewport.height}px`;
|
|
149
|
-
clone.style.transition = `transform 250ms ease-out, opacity 250ms ease-in`;
|
|
150
|
-
clone.style.opacity = "1";
|
|
151
|
-
clone.ontransitionend = ({ target, currentTarget }) => {
|
|
152
|
-
if (target === currentTarget)
|
|
153
|
-
wrapUI();
|
|
154
|
-
};
|
|
155
|
-
const targetHeight = Math.min(targetEl.current
|
|
156
|
-
? targetEl.current.clientHeight
|
|
157
|
-
: initialCenter.current.dimensions[1], elToTransitionToQueue.current.clientHeight);
|
|
158
|
-
const targetWidth = Math.min(targetHeight, targetEl.current
|
|
159
|
-
? targetEl.current.clientWidth
|
|
160
|
-
: initialCenter.current.dimensions[0], elToTransitionToQueue.current.clientWidth);
|
|
161
|
-
const targetScaleX = targetWidth / elToTransitionToQueue.current.clientWidth;
|
|
162
|
-
const targetScaleY = targetHeight / elToTransitionToQueue.current.clientHeight;
|
|
163
|
-
document.body.appendChild(clone);
|
|
164
|
-
setTimeout(() => {
|
|
165
|
-
clone.style.opacity = "0";
|
|
166
|
-
clone.style.transform = `translateX(${targetCenter.x - currPosCenter.x}px) translateY(${targetCenter.y - currPosCenter.y}px) scaleX(${targetScaleX}) scaleY(${targetScaleY})`;
|
|
167
|
-
clone.addEventListener("transitionend", ({ target, currentTarget }) => {
|
|
168
|
-
if (target === currentTarget)
|
|
169
|
-
clone.remove();
|
|
170
|
-
});
|
|
171
|
-
}, 100);
|
|
172
|
-
}, []);
|
|
173
|
-
return Object.entries(functionsToQueue).reduce((r, [k, v]) => {
|
|
174
|
-
const _process = (...args) => {
|
|
175
|
-
let promise = v(...args);
|
|
176
|
-
loadingRef.current = () => watchPromise(promise, () => v(...args), ...UIParamsFactory(k));
|
|
177
|
-
promise.finally(() => (loadingRef.current = null));
|
|
178
|
-
if (process.env.NODE_ENV === "development")
|
|
179
|
-
promise = (0, AsyncProcessQueue_development_1.securePromise)(promise);
|
|
180
|
-
return promise;
|
|
181
|
-
};
|
|
182
|
-
return Object.assign(Object.assign({}, r), { [k]: _process });
|
|
183
|
-
}, { elToTransitionToQueue, wrapQueue });
|
|
184
|
-
}
|
|
185
|
-
exports.useAsyncProcessQueue = useAsyncProcessQueue;
|
|
186
|
-
//# sourceMappingURL=AsyncProcessQueue.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AsyncProcessQueue.js","sourceRoot":"","sources":["../../src/context/AsyncProcessQueue.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAWe;AACf,mFAGyC;AAEzC,IAAY,gBAEX;AAFD,WAAY,gBAAgB;IAC1B,sKAAkJ,CAAA;AACpJ,CAAC,EAFW,gBAAgB,GAAhB,wBAAgB,KA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,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;YACzB,UAAU,CAAC,OAAO,GAAG,GAAG,EAAE,CACxB,YAAY,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;YACjE,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC;YACnD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa;gBACxC,OAAO,GAAG,IAAA,6CAAa,EAAC,OAAO,CAAC,CAAC;YACnC,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC;QACF,uCACK,CAAC,KACJ,CAAC,CAAC,CAAC,EAAE,QAAQ,IACb;IACJ,CAAC,EACD,EAAE,qBAAqB,EAAE,SAAS,EAMjC,CACF,CAAC;AACJ,CAAC;AAjHD,oDAiHC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* This hook handles the display of pagination controls for the user to move to another page
|
|
5
|
-
*/
|
|
6
|
-
function usePaginationControls(containerRef) { }
|
|
7
|
-
exports.default = usePaginationControls;
|
|
8
|
-
//# sourceMappingURL=usePaginationControls.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usePaginationControls.js","sourceRoot":"","sources":["../../src/hooks/usePaginationControls.ts"],"names":[],"mappings":";;AAEA;;GAEG;AACH,SAAwB,qBAAqB,CAC3C,YAAuC,IACtC,CAAC;AAFJ,wCAEI"}
|
package/dist/utils.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { FieldValues } from './fields';
|
|
2
|
-
import { NestedValue } from './form';
|
|
3
|
-
export declare type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
4
|
-
export declare type EmptyObject = {
|
|
5
|
-
[K in string | number]: never;
|
|
6
|
-
};
|
|
7
|
-
export declare type NonUndefined<T> = T extends undefined ? never : T;
|
|
8
|
-
export declare type LiteralUnion<T extends U, U extends Primitive> = T | (U & {
|
|
9
|
-
_?: never;
|
|
10
|
-
});
|
|
11
|
-
export declare type DeepPartial<T> = T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {
|
|
12
|
-
[key in keyof T]: T[key];
|
|
13
|
-
} ? {
|
|
14
|
-
[K in keyof T]?: DeepPartial<T[K]>;
|
|
15
|
-
} : T;
|
|
16
|
-
export declare type IsAny<T> = boolean extends (T extends never ? true : false) ? true : false;
|
|
17
|
-
export declare type DeepMap<T, TValue> = {
|
|
18
|
-
[K in keyof T]?: IsAny<T[K]> extends true ? any : NonNullable<T[K]> extends NestedValue | Date | FileList | File ? TValue : NonUndefined<T[K]> extends object | null ? DeepMap<T[K], TValue> : NonUndefined<T[K]> extends Array<infer U> ? IsAny<U> extends true ? Array<any> : U extends NestedValue | Date | FileList ? Array<TValue> : U extends object ? Array<DeepMap<U, TValue>> : Array<TValue> : TValue;
|
|
19
|
-
};
|
|
20
|
-
export declare type IsFlatObject<T extends object> = Extract<Exclude<T[keyof T], NestedValue | Date | FileList>, any[] | object> extends never ? true : false;
|
|
21
|
-
declare type IsTuple<T extends ReadonlyArray<any>> = number extends T['length'] ? false : true;
|
|
22
|
-
declare type TupleKey<T extends ReadonlyArray<any>> = Exclude<keyof T, keyof any[]>;
|
|
23
|
-
declare type ArrayKey = number;
|
|
24
|
-
declare type PathImpl<K extends string | number, V> = V extends Primitive ? `${K}` : `${K}` | `${K}.${Path<V>}`;
|
|
25
|
-
export declare type Path<T> = T extends ReadonlyArray<infer V> ? IsTuple<T> extends true ? {
|
|
26
|
-
[K in TupleKey<T>]-?: PathImpl<K & string, T[K]>;
|
|
27
|
-
}[TupleKey<T>] : PathImpl<ArrayKey, V> : {
|
|
28
|
-
[K in keyof T]-?: PathImpl<K & string, T[K]>;
|
|
29
|
-
}[keyof T];
|
|
30
|
-
export declare type FieldPath<TFieldValues extends FieldValues> = Path<TFieldValues>;
|
|
31
|
-
declare type ArrayPathImpl<K extends string | number, V> = V extends Primitive ? never : V extends ReadonlyArray<infer U> ? U extends Primitive ? never : `${K}` | `${K}.${ArrayPath<V>}` : `${K}.${ArrayPath<V>}`;
|
|
32
|
-
export declare type ArrayPath<T> = T extends ReadonlyArray<infer V> ? IsTuple<T> extends true ? {
|
|
33
|
-
[K in TupleKey<T>]-?: ArrayPathImpl<K & string, T[K]>;
|
|
34
|
-
}[TupleKey<T>] : ArrayPathImpl<ArrayKey, V> : {
|
|
35
|
-
[K in keyof T]-?: ArrayPathImpl<K & string, T[K]>;
|
|
36
|
-
}[keyof T];
|
|
37
|
-
export declare type FieldArrayPath<TFieldValues extends FieldValues> = ArrayPath<TFieldValues>;
|
|
38
|
-
export declare type PathValue<T, P extends Path<T> | ArrayPath<T>> = P extends `${infer K}.${infer R}` ? K extends keyof T ? R extends Path<T[K]> ? PathValue<T[K], R> : never : K extends `${ArrayKey}` ? T extends ReadonlyArray<infer V> ? PathValue<V, R & Path<V>> : never : never : P extends keyof T ? T[P] : P extends `${ArrayKey}` ? T extends ReadonlyArray<infer V> ? V : never : never;
|
|
39
|
-
export declare type FieldPathValue<TFieldValues extends FieldValues, TFieldPath extends FieldPath<TFieldValues>> = PathValue<TFieldValues, TFieldPath>;
|
|
40
|
-
export declare type FieldArrayPathValue<TFieldValues extends FieldValues, TFieldArrayPath extends FieldArrayPath<TFieldValues>> = PathValue<TFieldValues, TFieldArrayPath>;
|
|
41
|
-
export declare type FieldPathValues<TFieldValues extends FieldValues, TPath extends FieldPath<TFieldValues>[] | readonly FieldPath<TFieldValues>[]> = {} & {
|
|
42
|
-
[K in keyof TPath]: FieldPathValue<TFieldValues, TPath[K] & FieldPath<TFieldValues>>;
|
|
43
|
-
};
|
|
44
|
-
export {};
|
package/dist/utils.js
DELETED
package/dist/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":""}
|