@onepercentio/one-ui 0.7.1 → 0.7.4

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.
Files changed (29) hide show
  1. package/dist/components/AdaptiveButton/AdaptiveButton.js +3 -68
  2. package/dist/components/AdaptiveButton/AdaptiveButton.js.map +1 -1
  3. package/dist/components/AdaptiveContainer/AdaptiveContainer.d.ts +10 -0
  4. package/dist/components/AdaptiveContainer/AdaptiveContainer.js +93 -0
  5. package/dist/components/AdaptiveContainer/AdaptiveContainer.js.map +1 -0
  6. package/dist/components/AdaptiveContainer/AdaptiveContainer.module.scss +51 -0
  7. package/dist/components/AdaptiveContainer/AdaptiveContainer.stories.d.ts +17 -0
  8. package/dist/components/AdaptiveContainer/AdaptiveContainer.stories.js +82 -0
  9. package/dist/components/AdaptiveContainer/AdaptiveContainer.stories.js.map +1 -0
  10. package/dist/components/AdaptiveContainer/index.d.ts +1 -0
  11. package/dist/components/AdaptiveContainer/index.js +9 -0
  12. package/dist/components/AdaptiveContainer/index.js.map +1 -0
  13. package/dist/components/Freeze/Freeze.d.ts +2 -2
  14. package/dist/components/Freeze/Freeze.js +5 -4
  15. package/dist/components/Freeze/Freeze.js.map +1 -1
  16. package/dist/components/HSForms/HSForms.d.ts +4 -1
  17. package/dist/components/HSForms/HSForms.js +37 -17
  18. package/dist/components/HSForms/HSForms.js.map +1 -1
  19. package/dist/context/AsyncProcessQueue.d.ts +37 -0
  20. package/dist/context/AsyncProcessQueue.js +160 -0
  21. package/dist/context/AsyncProcessQueue.js.map +1 -0
  22. package/dist/hooks/useAsyncControl.d.ts +1 -1
  23. package/dist/hooks/useAsyncControl.js.map +1 -1
  24. package/dist/hooks/useFreeze.d.ts +5 -0
  25. package/dist/hooks/useFreeze.js +14 -0
  26. package/dist/hooks/useFreeze.js.map +1 -0
  27. package/dist/models/GenericContract.d.ts +13 -8
  28. package/dist/models/GenericContract.js.map +1 -1
  29. package/package.json +3 -2
@@ -1,27 +1,4 @@
1
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
2
  var __rest = (this && this.__rest) || function (s, e) {
26
3
  var t = {};
27
4
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -37,57 +14,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
15
  };
39
16
  Object.defineProperty(exports, "__esModule", { value: true });
40
- const react_1 = __importStar(require("react"));
17
+ const react_1 = __importDefault(require("react"));
18
+ const AdaptiveContainer_1 = __importDefault(require("../AdaptiveContainer"));
41
19
  const Button_1 = __importDefault(require("../Button"));
42
- const Transition_1 = require("../Transition");
43
- const UncontrolledTransition_1 = __importDefault(require("../UncontrolledTransition"));
44
- const AdaptiveButton_module_scss_1 = __importDefault(require("./AdaptiveButton.module.scss"));
45
20
  /**
46
21
  * A button that adapts it's width according to the content size
47
22
  **/
48
23
  function AdaptiveButton(_a) {
49
24
  var { children, className = "" } = _a, buttonProps = __rest(_a, ["children", "className"]);
50
- const uncontrolledRef = (0, react_1.useRef)(null);
51
- const buttonRef = (0, react_1.useRef)(null);
52
- (0, react_1.useEffect)(() => {
53
- const sectionDiv = uncontrolledRef.current.sectionRef.current;
54
- if (sectionDiv)
55
- sectionDiv.style.width = `${sectionDiv.clientWidth}px`;
56
- setTimeout(() => {
57
- if (uncontrolledRef.current) {
58
- const sectionDiv = uncontrolledRef.current.sectionRef.current;
59
- if (sectionDiv) {
60
- const lastChild = sectionDiv.lastChild;
61
- if (lastChild) {
62
- const contentWidth = lastChild.clientWidth;
63
- const targetWidth = `${contentWidth}px`;
64
- sectionDiv.style.width = targetWidth;
65
- function transEnd() {
66
- setTimeout(() => {
67
- if ((sectionDiv === null || sectionDiv === void 0 ? void 0 : sectionDiv.style.width) === `${contentWidth}px`)
68
- sectionDiv.style.width = "";
69
- }, 100);
70
- if (sectionDiv)
71
- sectionDiv.removeEventListener("transitionend", transEnd);
72
- }
73
- sectionDiv.addEventListener("transitionend", transEnd);
74
- }
75
- }
76
- }
77
- }, 100);
78
- }, [children.key]);
79
- return (react_1.default.createElement(react_1.default.Fragment, null,
80
- react_1.default.createElement(Button_1.default, Object.assign({ className: `${AdaptiveButton_module_scss_1.default.resetButton} ${className}`, ref: buttonRef }, buttonProps),
81
- react_1.default.createElement(UncontrolledTransition_1.default, { ref: uncontrolledRef, transitionType: Transition_1.TransitionAnimationTypes.CUSTOM, lockTransitionWidth: false, config: {
82
- backward: {
83
- elementExiting: AdaptiveButton_module_scss_1.default.fadeOutAbsolute,
84
- elementEntering: AdaptiveButton_module_scss_1.default.fadeInDelayed,
85
- },
86
- forward: {
87
- elementExiting: AdaptiveButton_module_scss_1.default.fadeOutAbsolute,
88
- elementEntering: AdaptiveButton_module_scss_1.default.fadeInDelayed,
89
- },
90
- }, className: AdaptiveButton_module_scss_1.default.resetSection }, children))));
25
+ return (react_1.default.createElement(AdaptiveContainer_1.default, Object.assign({ containerElement: Button_1.default, className: className }, buttonProps), children));
91
26
  }
92
27
  exports.default = AdaptiveButton;
93
28
  //# sourceMappingURL=AdaptiveButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AdaptiveButton.js","sourceRoot":"","sources":["../../../src/components/AdaptiveButton/AdaptiveButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAMe;AACf,uDAA+B;AAC/B,8CAAyD;AACzD,uFAA+D;AAC/D,8FAAkD;AAElD;;IAEI;AACJ,SAAwB,cAAc,CAAC,EAMN;QANM,EACrC,QAAQ,EACR,SAAS,GAAG,EAAE,OAIiB,EAH5B,WAAW,cAHuB,yBAItC,CADe;IAId,MAAM,eAAe,GACnB,IAAA,cAAM,EAA4C,IAAI,CAAC,CAAC;IAC1D,MAAM,SAAS,GAAG,IAAA,cAAM,EAAoB,IAAI,CAAC,CAAC;IAElD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,UAAU,GAAG,eAAe,CAAC,OAAQ,CAAC,UAAU,CAAC,OAAO,CAAC;QAC/D,IAAI,UAAU;YAAE,UAAU,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,UAAU,CAAC,WAAW,IAAI,CAAC;QACvE,UAAU,CAAC,GAAG,EAAE;YACd,IAAI,eAAe,CAAC,OAAO,EAAE;gBAC3B,MAAM,UAAU,GAAG,eAAe,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC;gBAC9D,IAAI,UAAU,EAAE;oBACd,MAAM,SAAS,GAAG,UAAU,CAAC,SAA2B,CAAC;oBACzD,IAAI,SAAS,EAAE;wBACb,MAAM,YAAY,GAAG,SAAS,CAAC,WAAW,CAAC;wBAC3C,MAAM,WAAW,GAAG,GAAG,YAAY,IAAI,CAAC;wBACxC,UAAU,CAAC,KAAK,CAAC,KAAK,GAAG,WAAW,CAAC;wBACrC,SAAS,QAAQ;4BACf,UAAU,CAAC,GAAG,EAAE;gCACd,IAAI,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,KAAK,CAAC,KAAK,MAAK,GAAG,YAAY,IAAI;oCACjD,UAAW,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC;4BACjC,CAAC,EAAE,GAAG,CAAC,CAAC;4BAER,IAAI,UAAU;gCACZ,UAAU,CAAC,mBAAmB,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;wBAC9D,CAAC;wBACD,UAAU,CAAC,gBAAgB,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;qBACxD;iBACF;aACF;QACH,CAAC,EAAE,GAAG,CAAC,CAAC;IACV,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAEnB,OAAO,CACL;QACE,8BAAC,gBAAM,kBACL,SAAS,EAAE,GAAG,oCAAM,CAAC,WAAW,IAAI,SAAS,EAAE,EAC/C,GAAG,EAAE,SAAS,IACV,WAAW;YAEf,8BAAC,gCAAsB,IACrB,GAAG,EAAE,eAAe,EACpB,cAAc,EAAE,qCAAwB,CAAC,MAAM,EAC/C,mBAAmB,EAAE,KAAK,EAC1B,MAAM,EAAE;oBACN,QAAQ,EAAE;wBACR,cAAc,EAAE,oCAAM,CAAC,eAAe;wBACtC,eAAe,EAAE,oCAAM,CAAC,aAAa;qBACtC;oBACD,OAAO,EAAE;wBACP,cAAc,EAAE,oCAAM,CAAC,eAAe;wBACtC,eAAe,EAAE,oCAAM,CAAC,aAAa;qBACtC;iBACF,EACD,SAAS,EAAE,oCAAM,CAAC,YAAY,IAE7B,QAAQ,CACc,CAClB,CACR,CACJ,CAAC;AACJ,CAAC;AAnED,iCAmEC"}
1
+ {"version":3,"file":"AdaptiveButton.js","sourceRoot":"","sources":["../../../src/components/AdaptiveButton/AdaptiveButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAMe;AACf,6EAAqD;AACrD,uDAA+B;AAE/B;;IAEI;AACJ,SAAwB,cAAc,CAAC,EAMN;QANM,EACrC,QAAQ,EACR,SAAS,GAAG,EAAE,OAIiB,EAH5B,WAAW,cAHuB,yBAItC,CADe;IAId,OAAO,CACL,8BAAC,2BAAiB,kBAChB,gBAAgB,EAAE,gBAAM,EACxB,SAAS,EAAE,SAAS,IAChB,WAAW,GAEd,QAAQ,CACS,CACrB,CAAC;AACJ,CAAC;AAhBD,iCAgBC"}
@@ -0,0 +1,10 @@
1
+ import { FunctionComponent, ReactElement } from "react";
2
+ /**
3
+ * A container that animates width changes across content updates
4
+ **/
5
+ export default function AdaptiveContainer({ children, className, containerElement: _Wrapper, ...otherProps }: {
6
+ containerElement?: keyof JSX.IntrinsicElements | FunctionComponent;
7
+ children: ReactElement;
8
+ } & {
9
+ [k: string]: any;
10
+ }): JSX.Element;
@@ -0,0 +1,93 @@
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 __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
+ };
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ const react_1 = __importStar(require("react"));
41
+ const Transition_1 = require("../Transition");
42
+ const UncontrolledTransition_1 = __importDefault(require("../UncontrolledTransition"));
43
+ const AdaptiveContainer_module_scss_1 = __importDefault(require("./AdaptiveContainer.module.scss"));
44
+ /**
45
+ * A container that animates width changes across content updates
46
+ **/
47
+ function AdaptiveContainer(_a) {
48
+ var { children, className = "", containerElement: _Wrapper = "div" } = _a, otherProps = __rest(_a, ["children", "className", "containerElement"]);
49
+ const uncontrolledRef = (0, react_1.useRef)(null);
50
+ const buttonRef = (0, react_1.useRef)(null);
51
+ (0, react_1.useEffect)(() => {
52
+ const sectionDiv = uncontrolledRef.current.sectionRef.current;
53
+ if (sectionDiv)
54
+ sectionDiv.style.width = `${sectionDiv.clientWidth}px`;
55
+ setTimeout(() => {
56
+ if (uncontrolledRef.current) {
57
+ const sectionDiv = uncontrolledRef.current.sectionRef.current;
58
+ if (sectionDiv) {
59
+ const lastChild = sectionDiv.lastChild;
60
+ if (lastChild) {
61
+ const contentWidth = lastChild.clientWidth;
62
+ const targetWidth = `${contentWidth}px`;
63
+ sectionDiv.style.width = targetWidth;
64
+ function transEnd() {
65
+ setTimeout(() => {
66
+ if ((sectionDiv === null || sectionDiv === void 0 ? void 0 : sectionDiv.style.width) === `${contentWidth}px`)
67
+ sectionDiv.style.width = "";
68
+ }, 100);
69
+ if (sectionDiv)
70
+ sectionDiv.removeEventListener("transitionend", transEnd);
71
+ }
72
+ sectionDiv.addEventListener("transitionend", transEnd);
73
+ }
74
+ }
75
+ }
76
+ }, 100);
77
+ }, [children.key]);
78
+ const Wrapper = _Wrapper;
79
+ return (react_1.default.createElement(react_1.default.Fragment, null,
80
+ react_1.default.createElement(Wrapper, Object.assign({ className: `${AdaptiveContainer_module_scss_1.default.resetButton} ${className}`, ref: buttonRef }, otherProps),
81
+ react_1.default.createElement(UncontrolledTransition_1.default, { ref: uncontrolledRef, transitionType: Transition_1.TransitionAnimationTypes.CUSTOM, lockTransitionWidth: false, config: {
82
+ backward: {
83
+ elementExiting: AdaptiveContainer_module_scss_1.default.fadeOutAbsolute,
84
+ elementEntering: AdaptiveContainer_module_scss_1.default.fadeInDelayed,
85
+ },
86
+ forward: {
87
+ elementExiting: AdaptiveContainer_module_scss_1.default.fadeOutAbsolute,
88
+ elementEntering: AdaptiveContainer_module_scss_1.default.fadeInDelayed,
89
+ },
90
+ }, className: AdaptiveContainer_module_scss_1.default.resetSection }, children))));
91
+ }
92
+ exports.default = AdaptiveContainer;
93
+ //# sourceMappingURL=AdaptiveContainer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdaptiveContainer.js","sourceRoot":"","sources":["../../../src/components/AdaptiveContainer/AdaptiveContainer.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAOe;AAEf,8CAAyD;AACzD,uFAA+D;AAC/D,oGAAqD;AAErD;;IAEI;AACJ,SAAwB,iBAAiB,CAAC,EAUzC;QAVyC,EACxC,QAAQ,EACR,SAAS,GAAG,EAAE,EACd,gBAAgB,EAAE,QAAQ,GAAG,KAAK,OAOnC,EANI,UAAU,cAJ2B,6CAKzC,CADc;IAOb,MAAM,eAAe,GACnB,IAAA,cAAM,EAA4C,IAAI,CAAC,CAAC;IAC1D,MAAM,SAAS,GAAG,IAAA,cAAM,EAAc,IAAI,CAAC,CAAC;IAE5C,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,UAAU,GAAG,eAAe,CA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CAAsB,IACrB,GAAG,EAAE,eAAe,EACpB,cAAc,EAAE,qCAAwB,CAAC,MAAM,EAC/C,mBAAmB,EAAE,KAAK,EAC1B,MAAM,EAAE;oBACN,QAAQ,EAAE;wBACR,cAAc,EAAE,uCAAM,CAAC,eAAe;wBACtC,eAAe,EAAE,uCAAM,CAAC,aAAa;qBACtC;oBACD,OAAO,EAAE;wBACP,cAAc,EAAE,uCAAM,CAAC,eAAe;wBACtC,eAAe,EAAE,uCAAM,CAAC,aAAa;qBACtC;iBACF,EACD,SAAS,EAAE,uCAAM,CAAC,YAAY,IAE7B,QAAQ,CACc,CACjB,CACT,CACJ,CAAC;AACJ,CAAC;AAxED,oCAwEC"}
@@ -0,0 +1,51 @@
1
+ .resetSection {
2
+ min-height: 0px;
3
+ transition: width 400ms;
4
+ transition-timing-function: linear;
5
+ overflow: hidden;
6
+ > * {
7
+ min-width: auto !important;
8
+ }
9
+ }
10
+
11
+ .resetButton {
12
+ min-width: 0px !important;
13
+ white-space: nowrap;
14
+ display: flex;
15
+ align-items: center;
16
+ text-align: center;
17
+ }
18
+
19
+ @keyframes fadeInDelayed {
20
+ 0% {
21
+ opacity: 0;
22
+ }
23
+ 50% {
24
+ opacity: 0.1;
25
+ }
26
+ 100% {
27
+ opacity: 1;
28
+ }
29
+ }
30
+ @keyframes fadeOutDelayed {
31
+ 0% {
32
+ opacity: 1;
33
+ }
34
+ 50% {
35
+ opacity: 0.1;
36
+ }
37
+ 100% {
38
+ opacity: 0;
39
+ }
40
+ }
41
+
42
+ .fadeInDelayed {
43
+ animation-name: fadeInDelayed;
44
+ animation-duration: 500ms !important;
45
+ }
46
+
47
+ .fadeOutAbsolute {
48
+ position: absolute;
49
+ animation-name: fadeOutDelayed;
50
+ animation-duration: 500ms !important;
51
+ }
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ import AdaptiveContainer from "./AdaptiveContainer";
3
+ declare const _default: {
4
+ component: typeof AdaptiveContainer;
5
+ title: string;
6
+ };
7
+ export default _default;
8
+ export declare const InitialImplementation: {
9
+ (args: any): JSX.Element;
10
+ args: Partial<{
11
+ containerElement?: keyof JSX.IntrinsicElements | React.FunctionComponent<{}> | undefined;
12
+ children: React.ReactElement<any, string | React.JSXElementConstructor<any>>;
13
+ } & {
14
+ [k: string]: any;
15
+ }>;
16
+ };
17
+ export declare const TargetUsage: () => JSX.Element;
@@ -0,0 +1,82 @@
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.TargetUsage = exports.InitialImplementation = void 0;
30
+ const react_1 = __importStar(require("react"));
31
+ const Loader_1 = __importDefault(require("../Loader"));
32
+ const MutableHamburgerButton_1 = __importDefault(require("../MutableHamburgerButton"));
33
+ const Tabs_1 = __importDefault(require("../Tabs"));
34
+ const Text_1 = __importDefault(require("../Text"));
35
+ const AdaptiveContainer_1 = __importDefault(require("./AdaptiveContainer"));
36
+ exports.default = {
37
+ component: AdaptiveContainer_1.default,
38
+ title: "Adaptive Container",
39
+ };
40
+ const InitialImplementation = (args) => (react_1.default.createElement(AdaptiveContainer_1.default, Object.assign({}, args)));
41
+ exports.InitialImplementation = InitialImplementation;
42
+ var Example;
43
+ (function (Example) {
44
+ Example[Example["Loading"] = 0] = "Loading";
45
+ Example[Example["Error"] = 1] = "Error";
46
+ Example[Example["Content"] = 2] = "Content";
47
+ Example[Example["Success"] = 3] = "Success";
48
+ })(Example || (Example = {}));
49
+ const TargetUsage = () => {
50
+ const [s, ss] = (0, react_1.useState)(Example.Error);
51
+ const child = (0, react_1.useMemo)(() => {
52
+ switch (s) {
53
+ case Example.Content:
54
+ return react_1.default.createElement(react_1.default.Fragment, { key: s }, "Example button");
55
+ case Example.Error:
56
+ return react_1.default.createElement(MutableHamburgerButton_1.default, { key: s, size: 24, state: "closed" });
57
+ case Example.Success:
58
+ return react_1.default.createElement(MutableHamburgerButton_1.default, { key: s, size: 24, state: "arrow-up" });
59
+ case Example.Loading:
60
+ return react_1.default.createElement(Loader_1.default, { key: s });
61
+ }
62
+ }, [s]);
63
+ (0, react_1.useEffect)(() => {
64
+ setInterval(() => {
65
+ // ss((pv) => (pv === 3 ? 0 : pv + 1));
66
+ }, 10000);
67
+ }, []);
68
+ return (react_1.default.createElement(react_1.default.Fragment, null,
69
+ react_1.default.createElement(Tabs_1.default, { options: Object.keys(Example)
70
+ .map((k) => ({
71
+ id: Example[k],
72
+ label: k,
73
+ }))
74
+ .filter((e) => parseInt(e.id, 10) >= 0), onSelect: ss, selected: s }),
75
+ react_1.default.createElement(AdaptiveContainer_1.default, { variant: "outline" }, child)));
76
+ };
77
+ exports.TargetUsage = TargetUsage;
78
+ exports.InitialImplementation.args = {
79
+ variant: "filled",
80
+ children: (react_1.default.createElement(Text_1.default, { key: "example", type: "highlight" }, "Some content to the button")),
81
+ };
82
+ //# sourceMappingURL=AdaptiveContainer.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdaptiveContainer.stories.js","sourceRoot":"","sources":["../../../src/components/AdaptiveContainer/AdaptiveContainer.stories.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA4D;AAC5D,uDAA+B;AAC/B,uFAA+D;AAC/D,mDAA2B;AAC3B,mDAA2B;AAC3B,4EAAoD;AAEpD,kBAAe;IACb,SAAS,EAAE,2BAAiB;IAC5B,KAAK,EAAE,oBAAoB;CAC5B,CAAC;AAEK,MAAM,qBAAqB,GAAG,CAAC,IAAS,EAAE,EAAE,CAAC,CAClD,8BAAC,2BAAiB,oBAAK,IAAI,EAAI,CAChC,CAAC;AAFW,QAAA,qBAAqB,yBAEhC;AACF,IAAK,OAKJ;AALD,WAAK,OAAO;IACV,2CAAO,CAAA;IACP,uCAAK,CAAA;IACL,2CAAO,CAAA;IACP,2CAAO,CAAA;AACT,CAAC,EALI,OAAO,KAAP,OAAO,QAKX;AACM,MAAM,WAAW,GAAG,GAAG,EAAE;IAC9B,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,IAAA,gBAAQ,EAAU,OAAO,CAAC,KAAK,CAAC,CAAC;IAEjD,MAAM,KAAK,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QACzB,QAAQ,CAAC,EAAE;YACT,KAAK,OAAO,CAAC,OAAO;gBAClB,OAAO,8BAAC,eAAK,CAAC,QAAQ,IAAC,GAAG,EAAE,CAAC,qBAAiC,CAAC;YACjE,KAAK,OAAO,CAAC,KAAK;gBAChB,OAAO,8BAAC,gCAAsB,IAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,GAAI,CAAC;YACvE,KAAK,OAAO,CAAC,OAAO;gBAClB,OAAO,8BAAC,gCAAsB,IAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,UAAU,GAAI,CAAC;YACzE,KAAK,OAAO,CAAC,OAAO;gBAClB,OAAO,8BAAC,gBAAM,IAAC,GAAG,EAAE,CAAC,GAAI,CAAC;SAC7B;IACH,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAER,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,WAAW,CAAC,GAAG,EAAE;YACf,yCAAyC;QAC3C,CAAC,EAAE,KAAK,CAAC,CAAC;IACZ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL;QACE,8BAAC,cAAI,IACH,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;iBAC1B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACX,EAAE,EAAE,OAAO,CAAC,CAAQ,CAAC;gBACrB,KAAK,EAAE,CAAC;aACT,CAAC,CAAC;iBACF,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,EACzC,QAAQ,EAAE,EAAS,EACnB,QAAQ,EAAE,CAAQ,GAClB;QACF,8BAAC,2BAAiB,IAAC,OAAO,EAAC,SAAS,IAAE,KAAK,CAAqB,CAC/D,CACJ,CAAC;AACJ,CAAC,CAAC;AArCW,QAAA,WAAW,eAqCtB;AACF,6BAAqB,CAAC,IAAI,GAAG;IAC3B,OAAO,EAAE,QAAQ;IACjB,QAAQ,EAAE,CACR,8BAAC,cAAI,IAAC,GAAG,EAAC,SAAS,EAAC,IAAI,EAAC,WAAW,iCAE7B,CACR;CACyD,CAAC"}
@@ -0,0 +1 @@
1
+ export { default } from './AdaptiveContainer';
@@ -0,0 +1,9 @@
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 AdaptiveContainer_1 = require("./AdaptiveContainer");
8
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(AdaptiveContainer_1).default; } });
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/AdaptiveContainer/index.tsx"],"names":[],"mappings":";;;;;;AAAA,yDAA8C;AAArC,6HAAA,OAAO,OAAA"}
@@ -1,5 +1,5 @@
1
- import { PropsWithChildren } from "react";
1
+ import React, { PropsWithChildren } from "react";
2
2
  /**
3
3
  * Use this component when you would like to freeze some child when this child can assume undefined in the next 'frame'
4
4
  **/
5
- export default function Freeze({ children }: PropsWithChildren<{}>): any;
5
+ export default function Freeze({ children }: PropsWithChildren<{}>): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const react_1 = require("react");
6
+ const useFreeze_1 = __importDefault(require("../../hooks/useFreeze"));
4
7
  /**
5
8
  * Use this component when you would like to freeze some child when this child can assume undefined in the next 'frame'
6
9
  **/
7
10
  function Freeze({ children }) {
8
- const currChildOrPrev = (0, react_1.useRef)();
9
- currChildOrPrev.current = children || currChildOrPrev.current;
10
- return currChildOrPrev.current || null;
11
+ return (0, useFreeze_1.default)(children);
11
12
  }
12
13
  exports.default = Freeze;
13
14
  //# sourceMappingURL=Freeze.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Freeze.js","sourceRoot":"","sources":["../../../src/components/Freeze/Freeze.tsx"],"names":[],"mappings":";;AAAA,iCAAyD;AAEzD;;IAEI;AACJ,SAAwB,MAAM,CAAC,EAAE,QAAQ,EAAyB;IAChE,MAAM,eAAe,GAAG,IAAA,cAAM,GAAO,CAAC;IACtC,eAAe,CAAC,OAAO,GAAG,QAAQ,IAAI,eAAe,CAAC,OAAO,CAAC;IAC9D,OAAO,eAAe,CAAC,OAAO,IAAI,IAAI,CAAC;AACzC,CAAC;AAJD,yBAIC"}
1
+ {"version":3,"file":"Freeze.js","sourceRoot":"","sources":["../../../src/components/Freeze/Freeze.tsx"],"names":[],"mappings":";;;;;AACA,sEAA8C;AAE9C;;IAEI;AACJ,SAAwB,MAAM,CAAC,EAAE,QAAQ,EAAyB;IAChE,OAAO,IAAA,mBAAS,EAAC,QAAQ,CAAiB,CAAC;AAC7C,CAAC;AAFD,yBAEC"}
@@ -1,5 +1,8 @@
1
- export default function HSForms({ region, partialId, formId, }: {
1
+ export default function HSForms({ region, partialId, formId, className, onFormReady, onFormSubmitted, }: {
2
2
  region: "na1";
3
3
  partialId: string;
4
4
  formId: string;
5
+ className?: string;
6
+ onFormReady?: (div: HTMLDivElement, form: any) => void;
7
+ onFormSubmitted?: () => void;
5
8
  }): JSX.Element | null;
@@ -24,28 +24,48 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  const react_1 = __importStar(require("react"));
27
- function HSForms({ region, partialId, formId, }) {
27
+ function HSForms({ region, partialId, formId, className, onFormReady, onFormSubmitted, }) {
28
28
  if (window.PRERENDER)
29
29
  return null;
30
30
  const container = (0, react_1.useRef)(null);
31
31
  (0, react_1.useEffect)(() => {
32
- const script = document.createElement("script");
33
- script.setAttribute("src", "https://js.hsforms.net/forms/v2.js");
34
- script.setAttribute("type", "text/javascript");
35
- script.setAttribute("charset", "utf-8");
36
- script.onload = () => {
37
- const createFormScript = document.createElement("script");
38
- createFormScript.setAttribute("type", "text/javascript");
39
- createFormScript.innerHTML = `hbspt.forms.create({
40
- region: "${region}",
41
- portalId: "${partialId}",
42
- formId: "${formId}",
43
- });`;
44
- container.current.appendChild(createFormScript);
45
- };
46
- document.head.appendChild(script);
32
+ Promise.resolve().then(() => __importStar(require("jquery"))).then((jqueryModule) => {
33
+ const funcId = String(Math.round(Math.random() * 999999));
34
+ const idx = `onLoad${funcId}`;
35
+ const idx2 = `onSubmit${funcId}`;
36
+ window[idx] = function (form) {
37
+ if (onFormReady)
38
+ onFormReady(container.current, form);
39
+ };
40
+ window[idx2] = function () {
41
+ if (onFormSubmitted)
42
+ onFormSubmitted();
43
+ };
44
+ window.jQuery = jqueryModule.default;
45
+ const script = document.createElement("script");
46
+ script.setAttribute("src", "https://js.hsforms.net/forms/v2.js");
47
+ script.setAttribute("type", "text/javascript");
48
+ script.setAttribute("charset", "utf-8");
49
+ script.onload = () => {
50
+ const createFormScript = document.createElement("script");
51
+ createFormScript.setAttribute("type", "text/javascript");
52
+ createFormScript.innerHTML = `hbspt.forms.create({
53
+ region: "${region}",
54
+ portalId: "${partialId}",
55
+ formId: "${formId}",
56
+ submitButtonClass: '#',
57
+ css: ' ',
58
+ cssClass: '#',
59
+ onFormReady: ${idx},
60
+ onFormSubmitted: ${idx2},
61
+ formInstanceId: ${funcId}
62
+ });`;
63
+ container.current.appendChild(createFormScript);
64
+ };
65
+ document.head.appendChild(script);
66
+ });
47
67
  }, [region, partialId, formId]);
48
- return react_1.default.createElement("div", { ref: container });
68
+ return react_1.default.createElement("div", { ref: container, className: className });
49
69
  }
50
70
  exports.default = HSForms;
51
71
  //# sourceMappingURL=HSForms.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"HSForms.js","sourceRoot":"","sources":["../../../src/components/HSForms/HSForms.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiD;AAEjD,SAAwB,OAAO,CAAC,EAC9B,MAAM,EACN,SAAS,EACT,MAAM,GAKP;IACC,IAAK,MAAc,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IAC3C,MAAM,SAAS,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAC;IAC/C,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,M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AAM,CAAC,CAAC,CAAC;IAChC,OAAO,uCAAK,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,GAAQ,CAAC;AAC3D,CAAC;AAtDD,0BAsDC"}
@@ -0,0 +1,37 @@
1
+ import React, { PropsWithChildren, ReactElement, RefObject } from "react";
2
+ declare type ReactElementWithState = ReactElement & {
3
+ status: "loading" | "succeded" | "failed";
4
+ };
5
+ /**
6
+ * This propagates the utilitary functions
7
+ */
8
+ export declare function AsyncProcessQueueProvider({ children }: PropsWithChildren<{}>): JSX.Element;
9
+ export declare function useAsyncProcessQueueContext(): {
10
+ targetElRef: React.RefObject<HTMLElement>;
11
+ pendingTransactions: {
12
+ count: number;
13
+ setCounter: React.Dispatch<React.SetStateAction<number>>;
14
+ increment: () => void;
15
+ decrement: () => void;
16
+ reset: () => void;
17
+ };
18
+ UIs: ReactElementWithState[];
19
+ setUIs: (func: (prev: ReactElementWithState[]) => ReactElementWithState[]) => void;
20
+ };
21
+ declare type AsyncProcessStatuses = "loading" | "succeded" | "failed";
22
+ export interface UIStateFactory {
23
+ (status: AsyncProcessStatuses, error?: Error, dismiss?: () => void, retry?: () => void): ReactElement;
24
+ }
25
+ /**
26
+ * This function wraps other async functions and decides when the ongoing promise should be put on the queue or not
27
+ */
28
+ export declare function useAsyncProcessQueue<T extends {
29
+ [k: string]: (...args: any[]) => Promise<any>;
30
+ }>(functionsToQueue: T, UIFactory: (functionName: keyof T) => UIStateFactory): T & {
31
+ elToTransitionToQueue: RefObject<HTMLElement>;
32
+ /**
33
+ * Function that wraps the current running actions and animates to the target queue element
34
+ */
35
+ wrapQueue: () => void;
36
+ };
37
+ export {};
@@ -0,0 +1,160 @@
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.useAsyncProcessQueueContext = exports.AsyncProcessQueueProvider = void 0;
27
+ const react_1 = __importStar(require("react"));
28
+ const Context = (0, react_1.createContext)(null);
29
+ function useCounter() {
30
+ const [count, setCounter] = (0, react_1.useState)(0);
31
+ return {
32
+ count,
33
+ setCounter,
34
+ increment: () => setCounter((prev) => prev + 1),
35
+ decrement: () => setCounter((prev) => prev - 1),
36
+ reset: () => setCounter(0),
37
+ };
38
+ }
39
+ /**
40
+ * This propagates the utilitary functions
41
+ */
42
+ function AsyncProcessQueueProvider({ children }) {
43
+ const targetRef = (0, react_1.useRef)(null);
44
+ const pendingCounter = useCounter();
45
+ const [UIs, setUIs] = (0, react_1.useState)([]);
46
+ return (react_1.default.createElement(Context.Provider, { value: {
47
+ targetElRef: targetRef,
48
+ pendingTransactions: pendingCounter,
49
+ setUIs,
50
+ UIs,
51
+ } }, children));
52
+ }
53
+ exports.AsyncProcessQueueProvider = AsyncProcessQueueProvider;
54
+ function useAsyncProcessQueueContext() {
55
+ return (0, react_1.useContext)(Context);
56
+ }
57
+ exports.useAsyncProcessQueueContext = useAsyncProcessQueueContext;
58
+ function calculateCenter(el) {
59
+ const boundsOnViewport = el.getBoundingClientRect();
60
+ return {
61
+ x: boundsOnViewport.x + boundsOnViewport.width / 2,
62
+ y: boundsOnViewport.y + boundsOnViewport.height / 2,
63
+ };
64
+ }
65
+ /**
66
+ * This function wraps other async functions and decides when the ongoing promise should be put on the queue or not
67
+ */
68
+ function useAsyncProcessQueue(functionsToQueue, UIFactory) {
69
+ const loadingRef = (0, react_1.useRef)(null);
70
+ const wrapped = (0, react_1.useRef)(false);
71
+ const elToTransitionToQueue = (0, react_1.useRef)(null);
72
+ const { targetElRef: targetEl, setUIs } = (0, react_1.useContext)(Context);
73
+ const initialCenter = (0, react_1.useRef)();
74
+ (0, react_1.useEffect)(() => {
75
+ initialCenter.current = {
76
+ center: calculateCenter(targetEl.current),
77
+ dimensions: [
78
+ targetEl.current.clientWidth,
79
+ targetEl.current.clientHeight,
80
+ ],
81
+ };
82
+ }, []);
83
+ const wrapQueue = (0, react_1.useCallback)(() => {
84
+ if (wrapped.current || !loadingRef.current)
85
+ return;
86
+ const wrapUI = loadingRef.current;
87
+ wrapped.current = true;
88
+ const clone = elToTransitionToQueue.current.cloneNode(true);
89
+ const currPositionOnViewport = elToTransitionToQueue.current.getBoundingClientRect();
90
+ const currPosCenter = calculateCenter(elToTransitionToQueue.current);
91
+ const targetCenter = targetEl.current
92
+ ? calculateCenter(targetEl.current)
93
+ : initialCenter.current.center;
94
+ clone.style.position = "fixed";
95
+ clone.style.top = `${currPositionOnViewport.top}px`;
96
+ clone.style.left = `${currPositionOnViewport.left}px`;
97
+ clone.style.width = `${currPositionOnViewport.width}px`;
98
+ clone.style.height = `${currPositionOnViewport.height}px`;
99
+ clone.style.transition = `transform 250ms ease-out, opacity 250ms ease-in`;
100
+ clone.style.opacity = "1";
101
+ clone.ontransitionend = ({ target, currentTarget }) => {
102
+ if (target === currentTarget)
103
+ wrapUI();
104
+ };
105
+ const targetHeight = Math.min(targetEl.current
106
+ ? targetEl.current.clientHeight
107
+ : initialCenter.current.dimensions[1], elToTransitionToQueue.current.clientHeight);
108
+ const targetWidth = Math.min(targetHeight, targetEl.current
109
+ ? targetEl.current.clientWidth
110
+ : initialCenter.current.dimensions[0], elToTransitionToQueue.current.clientWidth);
111
+ const targetScaleX = targetWidth / elToTransitionToQueue.current.clientWidth;
112
+ const targetScaleY = targetHeight / elToTransitionToQueue.current.clientHeight;
113
+ document.body.appendChild(clone);
114
+ setTimeout(() => {
115
+ clone.style.opacity = "0";
116
+ clone.style.transform = `translateX(${targetCenter.x - currPosCenter.x}px) translateY(${targetCenter.y - currPosCenter.y}px) scaleX(${targetScaleX}) scaleY(${targetScaleY})`;
117
+ clone.addEventListener("transitionend", ({ target, currentTarget }) => {
118
+ if (target === currentTarget)
119
+ clone.remove();
120
+ });
121
+ }, 100);
122
+ }, []);
123
+ return Object.entries(functionsToQueue).reduce((r, [k, v]) => {
124
+ const process = (...args) => {
125
+ const promise = v(...args);
126
+ loadingRef.current = function () {
127
+ // Write the loading UI
128
+ const LoadingUIInstance = Object.assign(Object.assign({}, UIFactory(k)("loading")), { status: "loading" });
129
+ setUIs((prev) => [
130
+ ...prev.filter((a) => a.key !== LoadingUIInstance.key),
131
+ LoadingUIInstance,
132
+ ]);
133
+ promise.then((result) => {
134
+ const UIInstance = UIFactory(k)("succeded");
135
+ // Write success UI
136
+ setUIs((prev) => prev.map((a) => a === LoadingUIInstance
137
+ ? Object.assign(Object.assign({}, UIInstance), { status: "succeded" }) : a));
138
+ return result;
139
+ });
140
+ promise.catch((error) => {
141
+ const UIInstance = UIFactory(k)("failed", error, () => setUIs((prev) => prev.filter((ui) => ui !== UIInstance)), () => {
142
+ process(...args);
143
+ loadingRef.current();
144
+ });
145
+ // Write success UI
146
+ setUIs((prev) => prev.map((a) => a === LoadingUIInstance
147
+ ? Object.assign(Object.assign({}, UIInstance), { status: "failed" }) : a));
148
+ throw error;
149
+ });
150
+ return promise;
151
+ };
152
+ promise.finally(() => {
153
+ loadingRef.current = null;
154
+ });
155
+ };
156
+ return Object.assign(Object.assign({}, r), { [k]: process });
157
+ }, { elToTransitionToQueue, wrapQueue });
158
+ }
159
+ exports.useAsyncProcessQueue = useAsyncProcessQueue;
160
+ //# sourceMappingURL=AsyncProcessQueue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AsyncProcessQueue.js","sourceRoot":"","sources":["../../src/context/AsyncProcessQueue.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAUe;AAMf,MAAM,OAAO,GAAG,IAAA,qBAAa,EAO1B,IAAW,CAAC,CAAC;AAEhB,SAAS,UAAU;IACjB,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAC,CAAC,CAAC,CAAC;IAExC,OAAO;QACL,KAAK;QACL,UAAU;QACV,SAAS,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC;QAC/C,SAAS,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC;QAC/C,KAAK,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;KAC3B,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,yBAAyB,CAAC,EAAE,QAAQ,EAAyB;IAC3E,MAAM,SAAS,GAAG,IAAA,cAAM,EAAc,IAAI,CAAC,CAAC;IAC5C,MAAM,cAAc,GAAG,UAAU,EAAE,CAAC;IACpC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,IAAA,gBAAQ,EAA0B,EAAE,CAAC,CAAC;IAE5D,OAAO,CACL,8BAAC,OAAO,CAAC,QAAQ,IACf,KAAK,EAAE;YACL,WAAW,EAAE,SAAS;YACtB,mBAAmB,EAAE,cAAc;YACnC,MAAM;YACN,GAAG;SACJ,IAEA,QAAQ,CACQ,CACpB,CAAC;AACJ,CAAC;AAjBD,8DAiBC;AAED,SAAgB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AmB;oBACnB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CACd,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACb,CAAC,KAAK,iBAAiB;wBACrB,CAAC,iCAAM,UAAU,KAAE,MAAM,EAAE,QAAQ,IACnC,CAAC,CAAC,CAAC,CACN,CACF,CAAC;oBAEF,MAAM,KAAK,CAAC;gBACd,CAAC,CAAC,CAAC;gBACH,OAAO,OAAO,CAAC;YACjB,CAAC,CAAC;YACF,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE;gBACnB,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;YAC5B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QACF,uCACK,CAAC,KACJ,CAAC,CAAC,CAAC,EAAE,OAAO,IACZ;IACJ,CAAC,EACD,EAAE,qBAAqB,EAAE,SAAS,EAMjC,CACF,CAAC;AACJ,CAAC;AA/JD,oDA+JC"}
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- export default function useAsyncControl<E, F = any>(functionsToWrap?: F): {
2
+ export default function useAsyncControl<E = any, F = any>(functionsToWrap?: F): {
3
3
  process: (asyncFn: () => Promise<any>) => Promise<any>;
4
4
  loading: boolean;
5
5
  error: Error | E | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"useAsyncControl.js","sourceRoot":"","sources":["../../src/hooks/useAsyncControl.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iCAA8C;AAG9C,SAAwB,eAAe,CAAa,eAAmB;IACrE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,GAAa,CAAC;IAChD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAU,KAAK,CAAC,CAAC;IAEvD,MAAM,QAAQ,GAAG,IAAA,mBAAW,EAAC,CAAO,OAA2B,EAAE,EAAE;QACjE,IAAI;YACF,UAAU,CAAC,IAAI,CAAC,CAAC;YACjB,QAAQ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,CAAC,CAAC;YACpB,OAAO,MAAM,OAAO,EAAE,CAAC;SACxB;QAAC,OAAO,CAAC,EAAE;YACV,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa;gBAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC7D,QAAQ,CAAC,CAAM,CAAC,CAAC;YACjB,MAAM,CAAC,CAAC;SACT;gBAAS;YACR,UAAU,CAAC,KAAK,CAAC,CAAC;SACnB;IACH,CAAC,CAAA,EAAE,EAAE,CAAC,CAAC;IAEP,uBACE,OAAO,EAAE,QAAQ,EACjB,OAAO;QACP,KAAK;QACL,QAAQ;QACR,UAAU,IACP,MAAM,CAAC,OAAO,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE;QAC/D,uCACK,CAAC,KACJ,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,IAAW,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAE,IAAY,CAAC,GAAG,IAAI,CAAC,CAAC,IAChE;IACH,CAAC,EAAE,EAAO,CAAM,EAChB;AACJ,CAAC;AA/BD,kCA+BC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * This hook pipes a data and when it is set to a falsy value ("", undefined, null, 0),
3
+ * it returns the previous valid value
4
+ */
5
+ export default function useFreeze<T>(something: T): T | null;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_1 = require("react");
4
+ /**
5
+ * This hook pipes a data and when it is set to a falsy value ("", undefined, null, 0),
6
+ * it returns the previous valid value
7
+ */
8
+ function useFreeze(something) {
9
+ const currChildOrPrev = (0, react_1.useRef)();
10
+ currChildOrPrev.current = something || currChildOrPrev.current;
11
+ return currChildOrPrev.current || null;
12
+ }
13
+ exports.default = useFreeze;
14
+ //# sourceMappingURL=useFreeze.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFreeze.js","sourceRoot":"","sources":["../../src/hooks/useFreeze.ts"],"names":[],"mappings":";;AAAA,iCAA+B;AAE/B;;;GAGG;AACH,SAAwB,SAAS,CAAI,SAAY;IAC7C,MAAM,eAAe,GAAG,IAAA,cAAM,GAAK,CAAC;IACpC,eAAe,CAAC,OAAO,GAAG,SAAS,IAAI,eAAe,CAAC,OAAO,CAAC;IAC/D,OAAO,eAAe,CAAC,OAAO,IAAI,IAAI,CAAC;AAC3C,CAAC;AAJD,4BAIC"}
@@ -6,15 +6,18 @@ declare type ExtractMethods<A extends AllABIs[number]> = A extends {
6
6
  declare type ExtractEvents<A extends AllABIs[number]> = A extends {
7
7
  type: "event";
8
8
  } ? A["name"] : never;
9
- declare type MapTypeToJS<L> = L extends "string" ? string : L extends "address" ? string : L extends "uint256" ? string : L extends "uint8" ? string : L extends "bool" ? boolean : unknown;
9
+ declare type TypeOrInternalType<T> = T['internalType'] extends unknown ? T['type'] : T['internalType'];
10
+ declare type MapTypeToJS<L, C> = L extends "address" | "uint256" | "uint128" | "uint8" | "string" | "bytes32" ? string : L extends "bool" ? boolean : L extends 'tuple' ? TuplifyUnion<C[number], C[number]['name']> : unknown;
10
11
  declare type ExtractFromObj<R extends (AllABIs[number] & {
11
12
  type: "function";
12
13
  })> = {
13
- [K in R["outputs"][number]["name"]]: MapTypeToJS<(R["outputs"][number] & {
14
+ [K in R["outputs"][number]["name"]]: MapTypeToJS<TypeOrInternalType<(R["outputs"][number] & {
14
15
  name: K;
15
- })["type"]>;
16
+ })>, (R["outputs"][number] & {
17
+ name: K;
18
+ })["components"]>;
16
19
  };
17
- declare type ExtractMethodDefinition<A extends AllABIs, N extends (AllABIs[number] & {
20
+ export declare type ExtractMethodDefinition<A extends AllABIs, N extends (AllABIs[number] & {
18
21
  type: "function";
19
22
  })["name"], R = A[number] & {
20
23
  type: "function";
@@ -30,7 +33,7 @@ declare type ExtractMethodDefinition<A extends AllABIs, N extends (AllABIs[numbe
30
33
  outputs: {
31
34
  length: 1;
32
35
  };
33
- } ? MapTypeToJS<R["outputs"][0]["type"]> : R extends {
36
+ } ? MapTypeToJS<TypeOrInternalType<R["outputs"][0]>, R["outputs"][0]['components']> : R extends {
34
37
  outputs: any;
35
38
  } ? ExtractFromObj<R> : void>;
36
39
  send: (prop: {
@@ -43,9 +46,11 @@ declare type ExtractMethodDefinition<A extends AllABIs, N extends (AllABIs[numbe
43
46
  declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
44
47
  declare type LastOf<T> = UnionToIntersection<T extends any ? () => T : never> extends () => infer R ? R : never;
45
48
  declare type Push<T extends any[], V> = [...T, V];
46
- declare type TuplifyUnion<FUNCS, T, L = LastOf<T>, N = [T] extends [never] ? true : false> = true extends N ? [] : Push<TuplifyUnion<FUNCS, Exclude<T, L>>, MapTypeToJS<(FUNCS & {
49
+ export declare type TuplifyUnion<FUNCS, T, L = LastOf<T>, N = [T] extends [never] ? true : false> = true extends N ? [] : Push<TuplifyUnion<FUNCS, Exclude<T, L>>, MapTypeToJS<TypeOrInternalType<(FUNCS & {
50
+ name: L;
51
+ })>, (FUNCS & {
47
52
  name: L;
48
- })['internalType']>>;
53
+ })['components']>>;
49
54
  export default class GenericContract<A extends AllABIs = AllABIs, E extends string = ExtractEvents<A[number]> | "allEvents"> extends Contract {
50
55
  events: Exclude<E, "allEvents">;
51
56
  constructor(jsonInterface: A, address?: string, options?: ContractOptions);
@@ -69,6 +74,6 @@ declare type GenericEvent<ABI extends AllABIs, E extends string = ExtractEvents<
69
74
  };
70
75
  declare type ExtractReturnValues<E extends ABIEvent> = ExtractInputType<E["inputs"][number]>;
71
76
  declare type ExtractInputType<I extends ABIEvent["inputs"][number]> = {
72
- [k in I["name"]]: MapTypeToJS<I["internalType"]>;
77
+ [k in I["name"]]: MapTypeToJS<TypeOrInternalType<I>, I['components']>;
73
78
  };
74
79
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"GenericContract.js","sourceRoot":"","sources":["../../src/models/GenericContract.ts"],"names":[],"mappings":";;AAAA,cAAc;AACd,yDAK2B;AAyF3B,MAAqB,eAGjB,SAAQ,4BAAQ;IAElB,YAAY,aAAgB,EAAE,OAAgB,EAAE,OAAyB;QACvE,KAAK,CAAC,aAAqC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACjE,CAAC;IAkBQ,aAAa,CACpB,KAAU,EACV,OAAa,EACb,QAAc;QAEd,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAQ,CAAC;IAC9D,CAAC;CACF;AAhCD,kCAgCC"}
1
+ {"version":3,"file":"GenericContract.js","sourceRoot":"","sources":["../../src/models/GenericContract.ts"],"names":[],"mappings":";;AAAA,cAAc;AACd,yDAK2B;AAsG3B,MAAqB,eAGjB,SAAQ,4BAAQ;IAElB,YAAY,aAAgB,EAAE,OAAgB,EAAE,OAAyB;QACvE,KAAK,CAAC,aAAqC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACjE,CAAC;IAkBQ,aAAa,CACpB,KAAU,EACV,OAAa,EACb,QAAc;QAEd,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAQ,CAAC;IAC9D,CAAC;CACF;AAhCD,kCAgCC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onepercentio/one-ui",
3
- "version": "0.7.1",
3
+ "version": "0.7.4",
4
4
  "description": "A set of reusable components created through the development of Onepercent projects",
5
5
  "files": [
6
6
  "dist",
@@ -19,7 +19,7 @@
19
19
  "@babel/core": "^7.16.0",
20
20
  "@cypress/react": "^5.12.5",
21
21
  "@firebase/rules-unit-testing": "^2.0.2",
22
- "@muritavo/cypress-toolkit": "^0.1.0",
22
+ "@muritavo/cypress-toolkit": "^0.7.1",
23
23
  "@muritavo/webpack-microfrontend-scripts": "^0.0.22",
24
24
  "@storybook/addon-actions": "^6.4.18",
25
25
  "@storybook/addon-essentials": "^6.4.18",
@@ -48,6 +48,7 @@
48
48
  "https-browserify": "^1.0.0",
49
49
  "inquirer": "^8.2.4",
50
50
  "jest": "^27.3.1",
51
+ "jquery": "^3.6.0",
51
52
  "node-fetch": "^2",
52
53
  "os-browserify": "^0.3.0",
53
54
  "react": "^18.0.0",