@onepercentio/one-ui 0.8.5-beta.7 → 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/WebpackConfigs/email-templates.js +35 -3
- package/cypress/support/component-index.html +4 -0
- package/dist/assets/styles/variables.scss +1 -0
- package/dist/components/AdaptiveContainer/AdaptiveContainer.d.ts +6 -0
- package/dist/components/AdaptiveContainer/AdaptiveContainer.js.map +1 -1
- package/dist/components/AdaptiveSidebar/AdaptiveSidebar.d.ts +17 -10
- package/dist/components/AdaptiveSidebar/AdaptiveSidebar.js +10 -5
- package/dist/components/AdaptiveSidebar/AdaptiveSidebar.js.map +1 -1
- package/dist/components/AdaptiveSidebar/AdaptiveSidebar.module.scss +21 -24
- package/dist/components/AnchoredTooltip/AnchoredTooltip.d.ts +3 -1
- package/dist/components/AnchoredTooltip/AnchoredTooltip.js +1 -0
- package/dist/components/AnchoredTooltip/AnchoredTooltip.js.map +1 -1
- package/dist/components/AnimatedEntrance/AnimatedEntrance.js +1 -1
- package/dist/components/AnimatedEntrance/AnimatedEntrance.js.map +1 -1
- package/dist/components/Collapsable/Collapsable.d.ts +5 -1
- package/dist/components/Collapsable/Collapsable.js +37 -7
- package/dist/components/Collapsable/Collapsable.js.map +1 -1
- package/dist/components/Collapsable/Collapsable.module.scss +5 -0
- package/dist/components/EmailInput/EmailInput.d.ts +2 -2
- package/dist/components/FadeIn/FadeIn.d.ts +1 -0
- package/dist/components/FadeIn/FadeIn.js +14 -2
- package/dist/components/FadeIn/FadeIn.js.map +1 -1
- package/dist/components/Input/Input.d.ts +1 -1
- package/dist/components/Loader/Loader.d.ts +3 -2
- package/dist/components/Loader/Loader.js +14 -2
- package/dist/components/Loader/Loader.js.map +1 -1
- package/dist/components/PaginationIndicator/PaginationIndicator.d.ts +28 -0
- package/dist/components/PaginationIndicator/PaginationIndicator.js +136 -0
- package/dist/components/PaginationIndicator/PaginationIndicator.js.map +1 -0
- package/dist/components/PaginationIndicator/PaginationIndicator.module.scss +48 -0
- package/dist/components/PaginationIndicator/index.d.ts +1 -0
- package/dist/components/PaginationIndicator/index.js +9 -0
- package/dist/components/PaginationIndicator/index.js.map +1 -0
- package/dist/components/PasswordInput/PasswordInput.d.ts +1 -1
- package/dist/components/Select/Select.d.ts +3 -1
- package/dist/components/Select/Select.js +2 -2
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Tabs/Tabs.d.ts +3 -1
- package/dist/components/Tabs/Tabs.js +17 -9
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/components/Tabs/Tabs.module.scss +0 -1
- package/dist/context/AsyncProcessQueue.js +9 -13
- package/dist/context/AsyncProcessQueue.js.map +1 -1
- package/dist/context/CustomBrowserRouter.d.ts +9 -1
- package/dist/context/CustomBrowserRouter.js +3 -2
- package/dist/context/CustomBrowserRouter.js.map +1 -1
- package/dist/context/OneUIProvider.d.ts +10 -1
- package/dist/context/OneUIProvider.js +1 -1
- package/dist/context/OneUIProvider.js.map +1 -1
- package/dist/hooks/ui/useBreakpoint.d.ts +5 -0
- package/dist/hooks/ui/useBreakpoint.js +25 -0
- package/dist/hooks/ui/useBreakpoint.js.map +1 -0
- package/dist/hooks/ui/usePaginationControls.d.ts +14 -0
- package/dist/hooks/ui/usePaginationControls.js +92 -0
- package/dist/hooks/ui/usePaginationControls.js.map +1 -0
- package/dist/hooks/ui/usePaginationControls.module.scss +16 -0
- package/dist/hooks/useAsyncControl.d.ts +4 -1
- package/dist/hooks/useAsyncControl.js +14 -4
- package/dist/hooks/useAsyncControl.js.map +1 -1
- package/dist/hooks/useContainedRepositioning.d.ts +3 -1
- package/dist/hooks/useContainedRepositioning.js +13 -10
- package/dist/hooks/useContainedRepositioning.js.map +1 -1
- package/dist/hooks/usePaginationControls.d.ts +5 -0
- package/dist/hooks/usePaginationControls.js +8 -0
- package/dist/hooks/usePaginationControls.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,25 @@
|
|
|
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 throttle_1 = __importDefault(require("lodash/throttle"));
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
/**
|
|
9
|
+
* A hook to trigger changes when the screen resizes
|
|
10
|
+
* @returns If the current resolution is lower than the specified width
|
|
11
|
+
*/
|
|
12
|
+
function useBreakpoint(breakInto) {
|
|
13
|
+
const [lowerThanBreakpoint, setIsLowerThanBreakpoint] = (0, react_1.useState)(() => window.visualViewport.width < breakInto);
|
|
14
|
+
(0, react_1.useEffect)(() => {
|
|
15
|
+
const onResizeThrottle = (0, throttle_1.default)(() => {
|
|
16
|
+
setIsLowerThanBreakpoint(window.visualViewport.width < breakInto);
|
|
17
|
+
}, 1000 / 4);
|
|
18
|
+
const onResize = () => onResizeThrottle();
|
|
19
|
+
window.addEventListener("resize", onResize);
|
|
20
|
+
return () => window.removeEventListener("resize", onResize);
|
|
21
|
+
}, []);
|
|
22
|
+
return lowerThanBreakpoint;
|
|
23
|
+
}
|
|
24
|
+
exports.default = useBreakpoint;
|
|
25
|
+
//# sourceMappingURL=useBreakpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBreakpoint.js","sourceRoot":"","sources":["../../../src/hooks/ui/useBreakpoint.tsx"],"names":[],"mappings":";;;;;AAAA,+DAAuC;AACvC,iCAA4C;AAE5C;;;GAGG;AACH,SAAwB,aAAa,CAAC,SAAiB;IACrD,MAAM,CAAC,mBAAmB,EAAE,wBAAwB,CAAC,GAAG,IAAA,gBAAQ,EAC9D,GAAG,EAAE,CAAC,MAAM,CAAC,cAAe,CAAC,KAAK,GAAG,SAAS,CAC/C,CAAC;IACF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,gBAAgB,GAAG,IAAA,kBAAQ,EAAC,GAAG,EAAE;YACrC,wBAAwB,CAAC,MAAM,CAAC,cAAe,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC;QACrE,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC;QACb,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,gBAAgB,EAAE,CAAC;QAC1C,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC5C,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AAbD,gCAaC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* This hook handles the display of pagination controls for the user to move to another page
|
|
4
|
+
*/
|
|
5
|
+
export default function usePaginationControls(containerRef: RefObject<HTMLDivElement>, { snapToPage, }?: {
|
|
6
|
+
snapToPage?: boolean;
|
|
7
|
+
}): {
|
|
8
|
+
controls: JSX.Element[];
|
|
9
|
+
checkControlsRequirement: () => void;
|
|
10
|
+
};
|
|
11
|
+
export declare enum usePaginationControlsTestIds {
|
|
12
|
+
LEFT_CONTROL = "page-l",
|
|
13
|
+
RIGHT_CONTROL = "page-r"
|
|
14
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.usePaginationControlsTestIds = void 0;
|
|
30
|
+
const throttle_1 = __importDefault(require("lodash/throttle"));
|
|
31
|
+
const react_1 = __importStar(require("react"));
|
|
32
|
+
const FadeIn_1 = __importDefault(require("../../components/FadeIn"));
|
|
33
|
+
const OneUIProvider_1 = require("../../context/OneUIProvider");
|
|
34
|
+
const usePaginationControls_module_scss_1 = __importDefault(require("./usePaginationControls.module.scss"));
|
|
35
|
+
/**
|
|
36
|
+
* This hook handles the display of pagination controls for the user to move to another page
|
|
37
|
+
*/
|
|
38
|
+
function usePaginationControls(containerRef, { snapToPage, } = {}) {
|
|
39
|
+
const [[leftControl, rightControl], setControls] = (0, react_1.useState)([false, false]);
|
|
40
|
+
const LeftControl = (0, OneUIProvider_1.useOneUIConfig)("hook.ui.usePaginationControls.LeftControl");
|
|
41
|
+
const RightControl = (0, OneUIProvider_1.useOneUIConfig)("hook.ui.usePaginationControls.RightControl");
|
|
42
|
+
const className = (0, OneUIProvider_1.useOneUIConfig)("hook.ui.usePaginationControls.className", "");
|
|
43
|
+
function move(direction) {
|
|
44
|
+
return () => {
|
|
45
|
+
const rest = containerRef.current.scrollLeft % containerRef.current.clientWidth;
|
|
46
|
+
const snapOffset = snapToPage
|
|
47
|
+
? direction === "l"
|
|
48
|
+
? rest
|
|
49
|
+
? containerRef.current.clientWidth - rest
|
|
50
|
+
: 0
|
|
51
|
+
: rest
|
|
52
|
+
: 0;
|
|
53
|
+
containerRef.current.scrollBy({
|
|
54
|
+
left: (containerRef.current.clientWidth - snapOffset) *
|
|
55
|
+
(direction === "l" ? -1 : 1),
|
|
56
|
+
behavior: "smooth",
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function checkControlsRequirement() {
|
|
61
|
+
const el = containerRef.current;
|
|
62
|
+
const shouldHaveAnyControl = el.scrollWidth > el.clientWidth;
|
|
63
|
+
if (!shouldHaveAnyControl)
|
|
64
|
+
setControls([false, false]);
|
|
65
|
+
else {
|
|
66
|
+
const shouldHaveRightControl = el.scrollLeft < el.scrollWidth - el.clientWidth;
|
|
67
|
+
const shouldHaveLeftControl = el.scrollLeft > 0;
|
|
68
|
+
setControls([shouldHaveLeftControl, shouldHaveRightControl]);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
(0, react_1.useEffect)(() => {
|
|
72
|
+
const el = containerRef.current;
|
|
73
|
+
const throttledCheck = (0, throttle_1.default)(checkControlsRequirement, 1000 / 4);
|
|
74
|
+
checkControlsRequirement();
|
|
75
|
+
el.addEventListener("scroll", throttledCheck);
|
|
76
|
+
return () => el.removeEventListener("scroll", throttledCheck);
|
|
77
|
+
}, []);
|
|
78
|
+
return {
|
|
79
|
+
controls: [
|
|
80
|
+
react_1.default.createElement(FadeIn_1.default, { active: leftControl, className: `${usePaginationControls_module_scss_1.default.left} ${usePaginationControls_module_scss_1.default.control} ${className}`, "data-testid": usePaginationControlsTestIds.LEFT_CONTROL, onClick: move("l") }, leftControl && react_1.default.createElement(LeftControl, null)),
|
|
81
|
+
react_1.default.createElement(FadeIn_1.default, { active: rightControl, className: `${usePaginationControls_module_scss_1.default.right} ${usePaginationControls_module_scss_1.default.control} ${className}`, "data-testid": usePaginationControlsTestIds.RIGHT_CONTROL, onClick: move("r") }, rightControl && react_1.default.createElement(RightControl, null)),
|
|
82
|
+
],
|
|
83
|
+
checkControlsRequirement,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
exports.default = usePaginationControls;
|
|
87
|
+
var usePaginationControlsTestIds;
|
|
88
|
+
(function (usePaginationControlsTestIds) {
|
|
89
|
+
usePaginationControlsTestIds["LEFT_CONTROL"] = "page-l";
|
|
90
|
+
usePaginationControlsTestIds["RIGHT_CONTROL"] = "page-r";
|
|
91
|
+
})(usePaginationControlsTestIds = exports.usePaginationControlsTestIds || (exports.usePaginationControlsTestIds = {}));
|
|
92
|
+
//# sourceMappingURL=usePaginationControls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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;AAEzD;;GAEG;AACH,SAAwB,qBAAqB,CAC3C,YAAuC,EACvC,EACE,UAAU,MAGR,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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C,OAAQ,CAAC;QACjC,MAAM,cAAc,GAAG,IAAA,kBAAQ,EAAC,wBAAwB,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC;QACpE,wBAAwB,EAAE,CAAC;QAC3B,EAAE,CAAC,gBAAgB,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;QAC9C,OAAO,GAAG,EAAE,CAAC,EAAE,CAAC,mBAAmB,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IAChE,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;AAlFD,wCAkFC;AAED,IAAY,4BAGX;AAHD,WAAY,4BAA4B;IACtC,uDAAuB,CAAA;IACvB,wDAAwB,CAAA;AAC1B,CAAC,EAHW,4BAA4B,GAA5B,oCAA4B,KAA5B,oCAA4B,QAGvC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
2
|
+
import { Primitive } from "type-fest";
|
|
3
|
+
export default function useAsyncControl<E = any, F extends {
|
|
4
|
+
[f: string]: ((...args: any[]) => Promise<any>) | Object | Primitive;
|
|
5
|
+
} = {}>(functionsToWrap?: F): {
|
|
3
6
|
process: (asyncFn: () => Promise<any>) => Promise<any>;
|
|
4
7
|
loading: boolean;
|
|
5
8
|
error: Error | E | undefined;
|
|
@@ -29,12 +29,22 @@ function useAsyncControl(functionsToWrap) {
|
|
|
29
29
|
setLoading(false);
|
|
30
30
|
}
|
|
31
31
|
}), []);
|
|
32
|
-
|
|
32
|
+
const { functionsToMemoize, other } = Object.entries(functionsToWrap || {}).reduce((r, [k, func]) => {
|
|
33
|
+
return Object.assign(Object.assign({}, r), (typeof func === "function"
|
|
34
|
+
? {
|
|
35
|
+
functionsToMemoize: Object.assign(Object.assign({}, r.functionsToMemoize), { [k]: func }),
|
|
36
|
+
}
|
|
37
|
+
: {
|
|
38
|
+
other: Object.assign(Object.assign({}, r.other), { [k]: func }),
|
|
39
|
+
}));
|
|
40
|
+
}, {
|
|
41
|
+
functionsToMemoize: {},
|
|
42
|
+
other: {},
|
|
43
|
+
});
|
|
44
|
+
return Object.assign(Object.assign({ process: _process, loading,
|
|
33
45
|
error,
|
|
34
46
|
setError,
|
|
35
|
-
setLoading }, Object.entries(
|
|
36
|
-
return Object.assign(Object.assign({}, r), { [k]: typeof func === "function" ? (...args) => _process(() => func(...args)) : func });
|
|
37
|
-
}, {}));
|
|
47
|
+
setLoading }, other), Object.entries(functionsToMemoize).reduce((r, [k, v]) => (Object.assign(Object.assign({}, r), { [k]: (0, react_1.useMemo)(() => (...args) => _process(() => v(...args)), [v]) })), {}));
|
|
38
48
|
}
|
|
39
49
|
exports.default = useAsyncControl;
|
|
40
50
|
//# sourceMappingURL=useAsyncControl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAsyncControl.js","sourceRoot":"","sources":["../../src/hooks/useAsyncControl.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"useAsyncControl.js","sourceRoot":"","sources":["../../src/hooks/useAsyncControl.ts"],"names":[],"mappings":";;;;;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CACE,OAAO,EAAE,QAAQ,EACjB,OAAO;QACP,KAAK;QACL,QAAQ;QACR,UAAU,IACP,KAAK,GACL,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAC1C,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,iCACV,CAAC,KACJ,CAAC,CAAC,CAAC,EAAE,IAAA,eAAO,EACV,GAAG,EAAE,CACH,CAAC,GAAG,IAAW,EAAE,EAAE,CACjB,QAAQ,CAAC,GAAG,EAAE,CAAE,CAAS,CAAC,GAAG,IAAI,CAAC,CAAC,EACvC,CAAC,CAAC,CAAC,CACJ,IACD,EACF,EAAO,CACR,EACD;AACJ,CAAC;AAzED,kCAyEC"}
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
* This hook takes an html and checks if its outside its parent
|
|
4
4
|
* If it is, it should move it so it can be totally visible inside the container
|
|
5
5
|
*/
|
|
6
|
-
export default function useContainedRepositioning(focused: boolean, getParent: (el: HTMLElement) => HTMLElement, { offset, scale }?: {
|
|
6
|
+
export default function useContainedRepositioning(focused: boolean, getParent: (el: HTMLElement) => HTMLElement, { offset, scale, offsetLimit, }?: {
|
|
7
7
|
/** The offset the element will be moved by from the closest bound */
|
|
8
8
|
offset?: number;
|
|
9
9
|
/** The scaled element width to be considered. usefull for when the focused element will change size */
|
|
10
10
|
scale?: number;
|
|
11
|
+
/** Limit offset */
|
|
12
|
+
offsetLimit?: number;
|
|
11
13
|
}): {
|
|
12
14
|
elementToCheck: import("react").RefObject<HTMLDivElement>;
|
|
13
15
|
};
|
|
@@ -9,7 +9,7 @@ const react_1 = require("react");
|
|
|
9
9
|
* This hook takes an html and checks if its outside its parent
|
|
10
10
|
* If it is, it should move it so it can be totally visible inside the container
|
|
11
11
|
*/
|
|
12
|
-
function useContainedRepositioning(focused, getParent, { offset = 16, scale = 1 } = {}) {
|
|
12
|
+
function useContainedRepositioning(focused, getParent, { offset = 16, scale = 1, offsetLimit = Number.POSITIVE_INFINITY, } = {}) {
|
|
13
13
|
const elementToCheck = (0, react_1.useRef)(null);
|
|
14
14
|
(0, react_1.useEffect)(() => {
|
|
15
15
|
const el = elementToCheck.current;
|
|
@@ -32,19 +32,23 @@ function useContainedRepositioning(focused, getParent, { offset = 16, scale = 1
|
|
|
32
32
|
const offsetOfScale = (elWidth - curr.clientWidth) / 2;
|
|
33
33
|
const cardLimit = curr.offsetLeft - offsetOfScale + alreadyRight + elWidth;
|
|
34
34
|
const exceedingSpace = cardLimit - limitOffset;
|
|
35
|
-
const offsetLeft = curr.offsetLeft -
|
|
35
|
+
const offsetLeft = curr.offsetLeft -
|
|
36
|
+
offsetOfScale +
|
|
37
|
+
alreadyRight -
|
|
38
|
+
relativeParent.scrollLeft;
|
|
36
39
|
const isOverflowedRight = exceedingSpace > 0;
|
|
37
40
|
const isOverflowedLeft = offsetLeft < 0;
|
|
38
|
-
const limit =
|
|
41
|
+
const limit = exceedingSpace + -offsetLeft;
|
|
39
42
|
if (isOverflowedRight) {
|
|
40
|
-
|
|
43
|
+
const val = Math.min(exceedingSpace - -Math.min(Math.abs(limit / 2), offset), offsetLimit);
|
|
44
|
+
curr.style.right = `${val}px`;
|
|
41
45
|
}
|
|
42
|
-
;
|
|
43
46
|
if (isOverflowedLeft) {
|
|
44
|
-
|
|
47
|
+
const val = Math.max(offsetLeft - Math.min(Math.abs(limit) / 2, offset), -offsetLimit);
|
|
48
|
+
curr.style.right = `${val}px`;
|
|
45
49
|
}
|
|
46
50
|
if (isOverflowedLeft || isOverflowedRight) {
|
|
47
|
-
curr.style.zIndex =
|
|
51
|
+
curr.style.zIndex = "1000";
|
|
48
52
|
}
|
|
49
53
|
}, 50);
|
|
50
54
|
reposition();
|
|
@@ -56,9 +60,8 @@ function useContainedRepositioning(focused, getParent, { offset = 16, scale = 1
|
|
|
56
60
|
el.style.right = `0px`;
|
|
57
61
|
const restore = ({ propertyName, currentTarget }) => {
|
|
58
62
|
const targetTransformation = window.getComputedStyle(currentTarget).right;
|
|
59
|
-
if (propertyName === "right" &&
|
|
60
|
-
|
|
61
|
-
curr.style.zIndex = '';
|
|
63
|
+
if (propertyName === "right" && targetTransformation === "0px") {
|
|
64
|
+
curr.style.zIndex = "";
|
|
62
65
|
el.removeEventListener("transitionend", restore);
|
|
63
66
|
}
|
|
64
67
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useContainedRepositioning.js","sourceRoot":"","sources":["../../src/hooks/useContainedRepositioning.ts"],"names":[],"mappings":";;;;;AAAA,+DAAuC;AACvC,iCAA0C;AAE1C;;;GAGG;AACH,SAAwB,yBAAyB,
|
|
1
|
+
{"version":3,"file":"useContainedRepositioning.js","sourceRoot":"","sources":["../../src/hooks/useContainedRepositioning.ts"],"names":[],"mappings":";;;;;AAAA,+DAAuC;AACvC,iCAA0C;AAE1C;;;GAGG;AACH,SAAwB,yBAAyB,CAC/C,OAAgB,EAChB,SAA2C,EAC3C,EACE,MAAM,GAAG,EAAE,EACX,KAAK,GAAG,CAAC,EACT,WAAW,GAAG,MAAM,CAAC,iBAAiB,MAUpC,EAAE;IAEN,MAAM,cAAc,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAC;IACpD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,EAAE,GAAG,cAAc,CAAC,OAAO,CAAC;QAClC,IAAI,CAAC,EAAE;YAAE,OAAO;QAEhB,MAAM,IAAI,GAAG,EAAE,CAAC;QAChB,MAAM,cAAc,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QAEvC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE;YAC1C,IAAI,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,QAAQ,KAAK,UAAU;gBACrD,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAC;YACJ,IAAI,MAAM,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,QAAQ,KAA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;KACf,CAAC;AACJ,CAAC;AApGD,4CAoGC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onepercentio/one-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
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 <muritavo@outlook.com>",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"@firebase/rules-unit-testing": "^2.0.2",
|
|
13
13
|
"@metamask/providers": "^9.1.0",
|
|
14
14
|
"@muritavo/cypress-toolkit": "^0.8.0",
|
|
15
|
-
"@muritavo/webpack-microfrontend-scripts": "^0.0.
|
|
15
|
+
"@muritavo/webpack-microfrontend-scripts": "^0.0.24",
|
|
16
16
|
"@storybook/addon-actions": "^6.4.18",
|
|
17
17
|
"@storybook/addon-essentials": "^6.4.18",
|
|
18
18
|
"@storybook/addon-links": "^6.4.18",
|