@e1011/es-kit 1.1.14 → 1.1.16
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/dist/hooks/esm/index.css +56 -56
- package/dist/hooks/index.css +56 -56
- package/dist/lib/cjs/src/core/ui/components/container/lazyComponent/LazyComponent.js +1 -1
- package/dist/lib/cjs/src/core/ui/components/container/lazyComponent/LazyComponent.js.map +1 -1
- package/dist/lib/esm/src/core/ui/components/container/lazyComponent/LazyComponent.js +1 -1
- package/dist/lib/esm/src/core/ui/components/container/lazyComponent/LazyComponent.js.map +1 -1
- package/dist/lib/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/core/ui/components/container/lazyComponent/LazyComponent.d.ts.map +1 -1
- package/dist/ui/esm/src/core/ui/components/container/lazyComponent/LazyComponent.js +1 -1
- package/dist/ui/esm/src/core/ui/components/container/lazyComponent/LazyComponent.js.map +1 -1
- package/dist/ui/src/core/ui/components/container/lazyComponent/LazyComponent.js +1 -1
- package/dist/ui/src/core/ui/components/container/lazyComponent/LazyComponent.js.map +1 -1
- package/dist/utils/esm/index.css +56 -56
- package/dist/utils/index.css +56 -56
- package/package.json +1 -1
package/dist/hooks/esm/index.css
CHANGED
|
@@ -1,30 +1,35 @@
|
|
|
1
|
-
.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
background-color: var(--color);
|
|
6
|
-
opacity: var(--opacity);
|
|
1
|
+
.CollapsibleContainer-module_collapsible-container__u0Jmm {
|
|
2
|
+
transform-origin: 0% 0%;
|
|
3
|
+
opacity: 0;
|
|
4
|
+
overflow: clip;
|
|
7
5
|
}
|
|
8
|
-
.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
width: var(--width);
|
|
12
|
-
margin: var(--margin);
|
|
6
|
+
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_vertical__w7MVN {
|
|
7
|
+
transition: opacity 0.2s ease-in-out, height 0.2s ease-in-out, max-height 0.2s ease-in-out;
|
|
8
|
+
will-change: opacity, height, max-height;
|
|
13
9
|
}
|
|
14
|
-
.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
margin: var(--margin);
|
|
10
|
+
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_vertical__w7MVN.CollapsibleContainer-module_collapsed__q8fs8 {
|
|
11
|
+
height: 0;
|
|
12
|
+
max-height: 0;
|
|
13
|
+
opacity: 0;
|
|
19
14
|
}
|
|
20
|
-
.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_vertical__w7MVN.CollapsibleContainer-module_expanded__O6Vh8 {
|
|
16
|
+
height: var(--prop-value);
|
|
17
|
+
max-height: var(--prop-value);
|
|
18
|
+
opacity: 1;
|
|
24
19
|
}
|
|
25
|
-
|
|
26
|
-
.
|
|
27
|
-
|
|
20
|
+
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_horizontal__QJWI- {
|
|
21
|
+
transition: opacity 0.2s ease-in-out, width 0.2s ease-in-out, max-width 0.2s ease-in-out;
|
|
22
|
+
will-change: opacity, width, max-width;
|
|
23
|
+
}
|
|
24
|
+
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_horizontal__QJWI-.CollapsibleContainer-module_collapsed__q8fs8 {
|
|
25
|
+
width: 0;
|
|
26
|
+
max-width: 0;
|
|
27
|
+
opacity: 0;
|
|
28
|
+
}
|
|
29
|
+
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_horizontal__QJWI-.CollapsibleContainer-module_expanded__O6Vh8 {
|
|
30
|
+
width: var(--prop-value);
|
|
31
|
+
max-width: var(--prop-value);
|
|
32
|
+
opacity: 1;
|
|
28
33
|
}
|
|
29
34
|
.icon-module_icon-base-parent__nOMvW {
|
|
30
35
|
line-height: 1px !important;
|
|
@@ -56,39 +61,6 @@
|
|
|
56
61
|
width: var(--height);
|
|
57
62
|
height: var(--width);
|
|
58
63
|
}
|
|
59
|
-
.CollapsibleContainer-module_collapsible-container__u0Jmm {
|
|
60
|
-
transform-origin: 0% 0%;
|
|
61
|
-
opacity: 0;
|
|
62
|
-
overflow: clip;
|
|
63
|
-
}
|
|
64
|
-
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_vertical__w7MVN {
|
|
65
|
-
transition: opacity 0.2s ease-in-out, height 0.2s ease-in-out, max-height 0.2s ease-in-out;
|
|
66
|
-
will-change: opacity, height, max-height;
|
|
67
|
-
}
|
|
68
|
-
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_vertical__w7MVN.CollapsibleContainer-module_collapsed__q8fs8 {
|
|
69
|
-
height: 0;
|
|
70
|
-
max-height: 0;
|
|
71
|
-
opacity: 0;
|
|
72
|
-
}
|
|
73
|
-
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_vertical__w7MVN.CollapsibleContainer-module_expanded__O6Vh8 {
|
|
74
|
-
height: var(--prop-value);
|
|
75
|
-
max-height: var(--prop-value);
|
|
76
|
-
opacity: 1;
|
|
77
|
-
}
|
|
78
|
-
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_horizontal__QJWI- {
|
|
79
|
-
transition: opacity 0.2s ease-in-out, width 0.2s ease-in-out, max-width 0.2s ease-in-out;
|
|
80
|
-
will-change: opacity, width, max-width;
|
|
81
|
-
}
|
|
82
|
-
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_horizontal__QJWI-.CollapsibleContainer-module_collapsed__q8fs8 {
|
|
83
|
-
width: 0;
|
|
84
|
-
max-width: 0;
|
|
85
|
-
opacity: 0;
|
|
86
|
-
}
|
|
87
|
-
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_horizontal__QJWI-.CollapsibleContainer-module_expanded__O6Vh8 {
|
|
88
|
-
width: var(--prop-value);
|
|
89
|
-
max-width: var(--prop-value);
|
|
90
|
-
opacity: 1;
|
|
91
|
-
}
|
|
92
64
|
.field-module_field__UfKm3 {
|
|
93
65
|
opacity: 1;
|
|
94
66
|
pointer-events: auto;
|
|
@@ -163,6 +135,34 @@
|
|
|
163
135
|
.field-module_field__UfKm3 label {
|
|
164
136
|
text-align: left;
|
|
165
137
|
}
|
|
138
|
+
.errorBoundary-module_errorBoundary__gk9ps {
|
|
139
|
+
background: #EFEFEF;
|
|
140
|
+
width: 100%;
|
|
141
|
+
height: 100%;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.errorBoundary-module_StyledIcon__IYHiU {
|
|
145
|
+
margin-right: 10px;
|
|
146
|
+
}
|
|
147
|
+
.divider-module_divider-line__6CesR {
|
|
148
|
+
position: relative;
|
|
149
|
+
display: block;
|
|
150
|
+
transition: opacity, width, height 250ms ease-in-out;
|
|
151
|
+
background-color: var(--color);
|
|
152
|
+
opacity: var(--opacity);
|
|
153
|
+
}
|
|
154
|
+
.divider-module_divider-line__6CesR.divider-module_vertical__qSVWD {
|
|
155
|
+
height: var(--length);
|
|
156
|
+
left: var(--left);
|
|
157
|
+
width: var(--width);
|
|
158
|
+
margin: var(--margin);
|
|
159
|
+
}
|
|
160
|
+
.divider-module_divider-line__6CesR.divider-module_horizontal__Gz-Oj {
|
|
161
|
+
width: var(--length);
|
|
162
|
+
left: var(--left);
|
|
163
|
+
height: var(--height);
|
|
164
|
+
margin: var(--margin);
|
|
165
|
+
}
|
|
166
166
|
.layoutBox-module_layout-box__ZIID8 {
|
|
167
167
|
display: flex;
|
|
168
168
|
position: relative;
|
package/dist/hooks/index.css
CHANGED
|
@@ -1,30 +1,35 @@
|
|
|
1
|
-
.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
background-color: var(--color);
|
|
6
|
-
opacity: var(--opacity);
|
|
1
|
+
.CollapsibleContainer-module_collapsible-container__u0Jmm {
|
|
2
|
+
transform-origin: 0% 0%;
|
|
3
|
+
opacity: 0;
|
|
4
|
+
overflow: clip;
|
|
7
5
|
}
|
|
8
|
-
.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
width: var(--width);
|
|
12
|
-
margin: var(--margin);
|
|
6
|
+
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_vertical__w7MVN {
|
|
7
|
+
transition: opacity 0.2s ease-in-out, height 0.2s ease-in-out, max-height 0.2s ease-in-out;
|
|
8
|
+
will-change: opacity, height, max-height;
|
|
13
9
|
}
|
|
14
|
-
.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
margin: var(--margin);
|
|
10
|
+
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_vertical__w7MVN.CollapsibleContainer-module_collapsed__q8fs8 {
|
|
11
|
+
height: 0;
|
|
12
|
+
max-height: 0;
|
|
13
|
+
opacity: 0;
|
|
19
14
|
}
|
|
20
|
-
.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_vertical__w7MVN.CollapsibleContainer-module_expanded__O6Vh8 {
|
|
16
|
+
height: var(--prop-value);
|
|
17
|
+
max-height: var(--prop-value);
|
|
18
|
+
opacity: 1;
|
|
24
19
|
}
|
|
25
|
-
|
|
26
|
-
.
|
|
27
|
-
|
|
20
|
+
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_horizontal__QJWI- {
|
|
21
|
+
transition: opacity 0.2s ease-in-out, width 0.2s ease-in-out, max-width 0.2s ease-in-out;
|
|
22
|
+
will-change: opacity, width, max-width;
|
|
23
|
+
}
|
|
24
|
+
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_horizontal__QJWI-.CollapsibleContainer-module_collapsed__q8fs8 {
|
|
25
|
+
width: 0;
|
|
26
|
+
max-width: 0;
|
|
27
|
+
opacity: 0;
|
|
28
|
+
}
|
|
29
|
+
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_horizontal__QJWI-.CollapsibleContainer-module_expanded__O6Vh8 {
|
|
30
|
+
width: var(--prop-value);
|
|
31
|
+
max-width: var(--prop-value);
|
|
32
|
+
opacity: 1;
|
|
28
33
|
}
|
|
29
34
|
.icon-module_icon-base-parent__nOMvW {
|
|
30
35
|
line-height: 1px !important;
|
|
@@ -56,39 +61,6 @@
|
|
|
56
61
|
width: var(--height);
|
|
57
62
|
height: var(--width);
|
|
58
63
|
}
|
|
59
|
-
.CollapsibleContainer-module_collapsible-container__u0Jmm {
|
|
60
|
-
transform-origin: 0% 0%;
|
|
61
|
-
opacity: 0;
|
|
62
|
-
overflow: clip;
|
|
63
|
-
}
|
|
64
|
-
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_vertical__w7MVN {
|
|
65
|
-
transition: opacity 0.2s ease-in-out, height 0.2s ease-in-out, max-height 0.2s ease-in-out;
|
|
66
|
-
will-change: opacity, height, max-height;
|
|
67
|
-
}
|
|
68
|
-
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_vertical__w7MVN.CollapsibleContainer-module_collapsed__q8fs8 {
|
|
69
|
-
height: 0;
|
|
70
|
-
max-height: 0;
|
|
71
|
-
opacity: 0;
|
|
72
|
-
}
|
|
73
|
-
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_vertical__w7MVN.CollapsibleContainer-module_expanded__O6Vh8 {
|
|
74
|
-
height: var(--prop-value);
|
|
75
|
-
max-height: var(--prop-value);
|
|
76
|
-
opacity: 1;
|
|
77
|
-
}
|
|
78
|
-
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_horizontal__QJWI- {
|
|
79
|
-
transition: opacity 0.2s ease-in-out, width 0.2s ease-in-out, max-width 0.2s ease-in-out;
|
|
80
|
-
will-change: opacity, width, max-width;
|
|
81
|
-
}
|
|
82
|
-
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_horizontal__QJWI-.CollapsibleContainer-module_collapsed__q8fs8 {
|
|
83
|
-
width: 0;
|
|
84
|
-
max-width: 0;
|
|
85
|
-
opacity: 0;
|
|
86
|
-
}
|
|
87
|
-
.CollapsibleContainer-module_collapsible-container__u0Jmm.CollapsibleContainer-module_horizontal__QJWI-.CollapsibleContainer-module_expanded__O6Vh8 {
|
|
88
|
-
width: var(--prop-value);
|
|
89
|
-
max-width: var(--prop-value);
|
|
90
|
-
opacity: 1;
|
|
91
|
-
}
|
|
92
64
|
.field-module_field__UfKm3 {
|
|
93
65
|
opacity: 1;
|
|
94
66
|
pointer-events: auto;
|
|
@@ -163,6 +135,34 @@
|
|
|
163
135
|
.field-module_field__UfKm3 label {
|
|
164
136
|
text-align: left;
|
|
165
137
|
}
|
|
138
|
+
.errorBoundary-module_errorBoundary__gk9ps {
|
|
139
|
+
background: #EFEFEF;
|
|
140
|
+
width: 100%;
|
|
141
|
+
height: 100%;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.errorBoundary-module_StyledIcon__IYHiU {
|
|
145
|
+
margin-right: 10px;
|
|
146
|
+
}
|
|
147
|
+
.divider-module_divider-line__6CesR {
|
|
148
|
+
position: relative;
|
|
149
|
+
display: block;
|
|
150
|
+
transition: opacity, width, height 250ms ease-in-out;
|
|
151
|
+
background-color: var(--color);
|
|
152
|
+
opacity: var(--opacity);
|
|
153
|
+
}
|
|
154
|
+
.divider-module_divider-line__6CesR.divider-module_vertical__qSVWD {
|
|
155
|
+
height: var(--length);
|
|
156
|
+
left: var(--left);
|
|
157
|
+
width: var(--width);
|
|
158
|
+
margin: var(--margin);
|
|
159
|
+
}
|
|
160
|
+
.divider-module_divider-line__6CesR.divider-module_horizontal__Gz-Oj {
|
|
161
|
+
width: var(--length);
|
|
162
|
+
left: var(--left);
|
|
163
|
+
height: var(--height);
|
|
164
|
+
margin: var(--margin);
|
|
165
|
+
}
|
|
166
166
|
.layoutBox-module_layout-box__ZIID8 {
|
|
167
167
|
display: flex;
|
|
168
168
|
position: relative;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("../../../../../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../../error/ErrorBoundary.js"),n=require("./lazyComponent.module.scss.js");const a={},o=e=>{let r,t="pending";const n=("function"==typeof e?e():e).then((e=>{t="success",r=e}),(e=>{t="error",r=e}));return{read(){if("pending"===t)throw n;if("error"===t)throw r;if("success"===t)return r}}},l=React.createElement("div",{className:n.default.loader},React.createElement("svg",{className:"spinner",viewBox:"0 0 50 50"},React.createElement("circle",{className:"path",cx:"25",cy:"25",r:"20",fill:"none",strokeWidth:"5"})))
|
|
1
|
+
"use strict";var e=require("../../../../../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../../error/ErrorBoundary.js"),n=require("./lazyComponent.module.scss.js");const a={},o=e=>{let r,t="pending";const n=("function"==typeof e?e():e).then((e=>{t="success",r=e}),(e=>{t="error",r=e}));return{read(){if("pending"===t)throw n;if("error"===t)throw r;if("success"===t)return r}}},l=r.memo((e=>{let{children:a,Component:o,LoaderJSX:l,...c}=e;return React.createElement(t.ErrorBoundary,null,React.createElement(r.Suspense,{fallback:l||React.createElement("div",{className:n.default.loader},React.createElement("svg",{className:"spinner",viewBox:"0 0 50 50"},React.createElement("circle",{className:"path",cx:"25",cy:"25",r:"20",fill:"none",strokeWidth:"5"})))},o&&React.createElement(o,c),a&&a))}));l.displayName="LazyComponent";const c=r.memo((e=>{let{pendingPromise:t,promise:n,fallback:a,children:c}=e;const s=r.useRef(t||n&&o(n)),i=r.useMemo((()=>e=>{let{children:r}=e;const t=s.current?.read?.();return t?.then?null:r}),[]);return React.createElement(l,{LoaderJSX:a},React.createElement(i,null,c))}));c.displayName="PendingBoundary";exports.LazyComponent=l,exports.PendingBoundary=c,exports.createLazyModule=function(t,n){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!a[n]){const c=r.lazy(t);a[n]=r.memo((r=>React.createElement(l,e.extends({Component:c},o,r)))),a[n].displayName=n}return a[n]},exports.createLazyModuleWithStore=(t,n,o)=>c=>{if(!a[n]){const s=r.lazy((()=>t(c)));a[n]=r.memo((r=>React.createElement(l,e.extends({Component:s},o,r)))),a[n].displayName=n}return a[n]},exports.wrapPromise=o;
|
|
2
2
|
//# sourceMappingURL=LazyComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LazyComponent.js","sources":["../../../../../../../../../src/core/ui/components/container/lazyComponent/LazyComponent.tsx"],"sourcesContent":["/* eslint-disable react/display-name */\nimport { FC, memo, Suspense, lazy, ComponentType, PropsWithChildren, useRef, useMemo } from 'react'\n\nimport { ErrorBoundary } from '../../error/ErrorBoundary'\n\nimport classes from './lazyComponent.module.scss'\n\n\n// not always necessary, since createLayzModule is called once per module,\n// but when nesting, inside loaded modules...\nconst map: Record<string, FC<any>> = {}\n\ntype ReactModule = {\n default: ComponentType<any>\n}\n\nexport type LazyComponentProps = PropsWithChildren<any> & {\n PropsWithChildren?: ComponentType<any>\n LoaderJSX?: JSX.Element\n}\n\nexport type wrapPromiseType = (promise: (() => Promise<any>) | Promise<any>) => { read: () => Promise<unknown> }\n\nexport const wrapPromise: wrapPromiseType = (promise: (() => Promise<any>) | Promise<any>) => {\n let status = 'pending'\n let result: any\n const suspend = (typeof promise === 'function' ? promise() : promise).then(\n (res) => {\n status = 'success'\n result = res\n },\n (err) => {\n status = 'error'\n result = err\n },\n )\n\n return {\n // eslint-disable-next-line consistent-return\n read(): any {\n if (status === 'pending') {\n throw suspend\n } else if (status === 'error') {\n throw result\n } else if (status === 'success') {\n return result\n }\n },\n }\n}\n\nconst
|
|
1
|
+
{"version":3,"file":"LazyComponent.js","sources":["../../../../../../../../../src/core/ui/components/container/lazyComponent/LazyComponent.tsx"],"sourcesContent":["/* eslint-disable react/display-name */\nimport { FC, memo, Suspense, lazy, ComponentType, PropsWithChildren, useRef, useMemo, ReactNode } from 'react'\n\nimport { ErrorBoundary } from '../../error/ErrorBoundary'\n\nimport classes from './lazyComponent.module.scss'\n\n\n// not always necessary, since createLayzModule is called once per module,\n// but when nesting, inside loaded modules...\nconst map: Record<string, FC<any>> = {}\n\ntype ReactModule = {\n default: ComponentType<any>\n}\n\nexport type LazyComponentProps = PropsWithChildren<any> & {\n PropsWithChildren?: ComponentType<any>\n LoaderJSX?: JSX.Element\n}\n\nexport type wrapPromiseType = (promise: (() => Promise<any>) | Promise<any>) => { read: () => Promise<unknown> }\n\nexport const wrapPromise: wrapPromiseType = (promise: (() => Promise<any>) | Promise<any>) => {\n let status = 'pending'\n let result: any\n const suspend = (typeof promise === 'function' ? promise() : promise).then(\n (res) => {\n status = 'success'\n result = res\n },\n (err) => {\n status = 'error'\n result = err\n },\n )\n\n return {\n // eslint-disable-next-line consistent-return\n read(): any {\n if (status === 'pending') {\n throw suspend\n } else if (status === 'error') {\n throw result\n } else if (status === 'success') {\n return result\n }\n },\n }\n}\n\nconst getDefaultLoader = (): ReactNode => (\n <div className={classes.loader}>\n <svg className='spinner' viewBox='0 0 50 50'>\n <circle className='path' cx='25' cy='25' r='20' fill='none' strokeWidth='5' />\n </svg>\n </div>\n)\n\nexport const LazyComponent: FC<LazyComponentProps>\n= memo<LazyComponentProps>(({ children, Component, LoaderJSX, ...props }: LazyComponentProps) => (\n <ErrorBoundary>\n <Suspense fallback={LoaderJSX || getDefaultLoader()}>\n {Component && <Component {...props} />}\n {children && children}\n </Suspense>\n </ErrorBoundary>\n))\n\nLazyComponent.displayName = 'LazyComponent'\n\nexport type PendingBoundaryProps = PropsWithChildren & {\n fallback?: JSX.Element\n promise?: Promise<unknown>\n pendingPromise?: { read: () => Promise<unknown> }\n}\n\nexport const PendingBoundary: FC<PendingBoundaryProps>\n= memo<PendingBoundaryProps>(({ pendingPromise, promise, fallback, children }: PendingBoundaryProps) => {\n const wrappedPromiseRef = useRef(pendingPromise || (promise && wrapPromise(promise)))\n\n const InnerComponent: FC<PropsWithChildren<any>> = useMemo(() => ({ children }: PropsWithChildren<any>) => {\n const innerPromise = wrappedPromiseRef.current?.read?.()\n\n return innerPromise?.then ? null : children\n }, [])\n\n return (\n <LazyComponent LoaderJSX={fallback}>\n <InnerComponent>{children}</InnerComponent>\n </LazyComponent>\n )\n})\n\nPendingBoundary.displayName = 'PendingBoundary'\n\n\nexport const createLazyModule = (\n lazyResolver: () => Promise<ReactModule>,\n displayName: string,\n defaultProps: Record<string, unknown> = {},\n): FC<unknown> => {\n if (!map[displayName]) {\n const Component = lazy(lazyResolver)\n\n // eslint-disable-next-line react/display-name\n map[displayName] = memo((props) => (<LazyComponent Component={Component} {...defaultProps} {...props} />))\n map[displayName].displayName = displayName\n }\n\n return map[displayName]\n}\n\n\nexport const createLazyModuleWithStore = <T, ComponentType>(\n lazyResolver: (store: T) => Promise<ReactModule>,\n displayName: string,\n defaultProps: Record<string, unknown>,\n): (store: T) => FC<ComponentType> => (store: T) => {\n if (!map[displayName]) {\n const Component = lazy(() => lazyResolver(store))\n\n // eslint-disable-next-line react/display-name\n map[displayName] = memo((props) => (<LazyComponent Component={Component} {...defaultProps} {...props} />))\n map[displayName].displayName = displayName\n }\n\n return map[displayName]\n }\n"],"names":["map","wrapPromise","promise","result","status","suspend","then","res","err","read","LazyComponent","memo","_ref","children","Component","LoaderJSX","props","React","createElement","ErrorBoundary","Suspense","fallback","className","classes","default","loader","viewBox","cx","cy","r","fill","strokeWidth","displayName","PendingBoundary","_ref2","pendingPromise","wrappedPromiseRef","useRef","InnerComponent","useMemo","_ref3","innerPromise","current","lazyResolver","defaultProps","arguments","length","undefined","lazy","_extends","createLazyModuleWithStore","store"],"mappings":"+LAUA,MAAMA,EAA+B,CAAA,EAaxBC,EAAgCC,IAC3C,IACIC,EADAC,EAAS,UAEb,MAAMC,GAA8B,mBAAZH,EAAyBA,IAAYA,GAASI,MACnEC,IACCH,EAAS,UACTD,EAASI,CAAG,IAEbC,IACCJ,EAAS,QACTD,EAASK,CAAG,IAIhB,MAAO,CAELC,IAAAA,GACE,GAAe,YAAXL,EACF,MAAMC,EACD,GAAe,UAAXD,EACT,MAAMD,EACD,GAAe,YAAXC,EACT,OAAOD,CAEX,EACD,EAWUO,EACXC,EAAIA,MAAqBC,IAAA,IAACC,SAAEA,EAAQC,UAAEA,EAASC,UAAEA,KAAcC,GAA2BJ,EAAA,OAC1FK,MAAAC,cAACC,EAAaA,mBACZF,MAAAC,cAACE,WAAQ,CAACC,SAAUN,GAVtBE,MAAAC,cAAA,MAAA,CAAKI,UAAWC,EAAOC,QAACC,QACtBR,MAAAC,cAAA,MAAA,CAAKI,UAAU,UAAUI,QAAQ,aAC/BT,MAAAC,cAAA,SAAA,CAAQI,UAAU,OAAOK,GAAG,KAAKC,GAAG,KAAKC,EAAE,KAAKC,KAAK,OAAOC,YAAY,SASvEjB,GAAaG,MAAAC,cAACJ,EAAcE,GAC5BH,GAAYA,GAED,IAGlBH,EAAcsB,YAAc,sBAQfC,EACXtB,EAAIA,MAAuBuB,IAA2E,IAA1EC,eAAEA,EAAcjC,QAAEA,EAAOmB,SAAEA,EAAQR,SAAEA,GAAgCqB,EACjG,MAAME,EAAoBC,EAAAA,OAAOF,GAAmBjC,GAAWD,EAAYC,IAErEoC,EAA6CC,WAAQ,IAAMC,IAA0C,IAAzC3B,SAAEA,GAAkC2B,EACpG,MAAMC,EAAeL,EAAkBM,SAASjC,SAEhD,OAAOgC,GAAcnC,KAAO,KAAOO,CAAQ,GAC1C,IAEH,OACEI,MAAAC,cAACR,EAAa,CAACK,UAAWM,GACxBJ,MAAAC,cAACoB,EAAgBzB,KAAAA,GACH,IAIpBoB,EAAgBD,YAAc,6FAGE,SAC9BW,EACAX,GAEgB,IADhBY,EAAqCC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,CAAA,EAExC,IAAK7C,EAAIgC,GAAc,CACrB,MAAMlB,EAAYkC,OAAKL,GAGvB3C,EAAIgC,GAAerB,QAAMK,GAAWC,MAAAC,cAACR,EAAauC,UAAA,CAACnC,UAAWA,GAAe8B,EAAkB5B,MAC/FhB,EAAIgC,GAAaA,YAAcA,CACjC,CAEA,OAAOhC,EAAIgC,EACb,oCAGyCkB,CACvCP,EACAX,EACAY,IACqCO,IACnC,IAAKnD,EAAIgC,GAAc,CACrB,MAAMlB,EAAYkC,EAAIA,MAAC,IAAML,EAAaQ,KAG1CnD,EAAIgC,GAAerB,QAAMK,GAAWC,MAAAC,cAACR,EAAauC,UAAA,CAACnC,UAAWA,GAAe8B,EAAkB5B,MAC/FhB,EAAIgC,GAAaA,YAAcA,CACjC,CAEA,OAAOhC,EAAIgC,EAAY"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{extends as e}from"../../../../../../_virtual/_rollupPluginBabelHelpers.js";import{memo as t,Suspense as r,useRef as n,useMemo as a,lazy as c}from"react";import{ErrorBoundary as o}from"../../error/ErrorBoundary.js";import l from"./lazyComponent.module.scss.js";const s={},i=e=>{let t,r="pending";const n=("function"==typeof e?e():e).then((e=>{r="success",t=e}),(e=>{r="error",t=e}));return{read(){if("pending"===r)throw n;if("error"===r)throw t;if("success"===r)return t}}},m=React.createElement("div",{className:l.loader},React.createElement("svg",{className:"spinner",viewBox:"0 0 50 50"},React.createElement("circle",{className:"path",cx:"25",cy:"25",r:"20",fill:"none",strokeWidth:"5"})))
|
|
1
|
+
import{extends as e}from"../../../../../../_virtual/_rollupPluginBabelHelpers.js";import{memo as t,Suspense as r,useRef as n,useMemo as a,lazy as c}from"react";import{ErrorBoundary as o}from"../../error/ErrorBoundary.js";import l from"./lazyComponent.module.scss.js";const s={},i=e=>{let t,r="pending";const n=("function"==typeof e?e():e).then((e=>{r="success",t=e}),(e=>{r="error",t=e}));return{read(){if("pending"===r)throw n;if("error"===r)throw t;if("success"===r)return t}}},m=t((e=>{let{children:t,Component:n,LoaderJSX:a,...c}=e;return React.createElement(o,null,React.createElement(r,{fallback:a||React.createElement("div",{className:l.loader},React.createElement("svg",{className:"spinner",viewBox:"0 0 50 50"},React.createElement("circle",{className:"path",cx:"25",cy:"25",r:"20",fill:"none",strokeWidth:"5"})))},n&&React.createElement(n,c),t&&t))}));m.displayName="LazyComponent";const d=t((e=>{let{pendingPromise:t,promise:r,fallback:c,children:o}=e;const l=n(t||r&&i(r)),s=a((()=>e=>{let{children:t}=e;const r=l.current?.read?.();return r?.then?null:t}),[]);return React.createElement(m,{LoaderJSX:c},React.createElement(s,null,o))}));d.displayName="PendingBoundary";const p=function(r,n){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!s[n]){const o=c(r);s[n]=t((t=>React.createElement(m,e({Component:o},a,t)))),s[n].displayName=n}return s[n]},u=(r,n,a)=>o=>{if(!s[n]){const l=c((()=>r(o)));s[n]=t((t=>React.createElement(m,e({Component:l},a,t)))),s[n].displayName=n}return s[n]};export{m as LazyComponent,d as PendingBoundary,p as createLazyModule,u as createLazyModuleWithStore,i as wrapPromise};
|
|
2
2
|
//# sourceMappingURL=LazyComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LazyComponent.js","sources":["../../../../../../../../../src/core/ui/components/container/lazyComponent/LazyComponent.tsx"],"sourcesContent":["/* eslint-disable react/display-name */\nimport { FC, memo, Suspense, lazy, ComponentType, PropsWithChildren, useRef, useMemo } from 'react'\n\nimport { ErrorBoundary } from '../../error/ErrorBoundary'\n\nimport classes from './lazyComponent.module.scss'\n\n\n// not always necessary, since createLayzModule is called once per module,\n// but when nesting, inside loaded modules...\nconst map: Record<string, FC<any>> = {}\n\ntype ReactModule = {\n default: ComponentType<any>\n}\n\nexport type LazyComponentProps = PropsWithChildren<any> & {\n PropsWithChildren?: ComponentType<any>\n LoaderJSX?: JSX.Element\n}\n\nexport type wrapPromiseType = (promise: (() => Promise<any>) | Promise<any>) => { read: () => Promise<unknown> }\n\nexport const wrapPromise: wrapPromiseType = (promise: (() => Promise<any>) | Promise<any>) => {\n let status = 'pending'\n let result: any\n const suspend = (typeof promise === 'function' ? promise() : promise).then(\n (res) => {\n status = 'success'\n result = res\n },\n (err) => {\n status = 'error'\n result = err\n },\n )\n\n return {\n // eslint-disable-next-line consistent-return\n read(): any {\n if (status === 'pending') {\n throw suspend\n } else if (status === 'error') {\n throw result\n } else if (status === 'success') {\n return result\n }\n },\n }\n}\n\nconst
|
|
1
|
+
{"version":3,"file":"LazyComponent.js","sources":["../../../../../../../../../src/core/ui/components/container/lazyComponent/LazyComponent.tsx"],"sourcesContent":["/* eslint-disable react/display-name */\nimport { FC, memo, Suspense, lazy, ComponentType, PropsWithChildren, useRef, useMemo, ReactNode } from 'react'\n\nimport { ErrorBoundary } from '../../error/ErrorBoundary'\n\nimport classes from './lazyComponent.module.scss'\n\n\n// not always necessary, since createLayzModule is called once per module,\n// but when nesting, inside loaded modules...\nconst map: Record<string, FC<any>> = {}\n\ntype ReactModule = {\n default: ComponentType<any>\n}\n\nexport type LazyComponentProps = PropsWithChildren<any> & {\n PropsWithChildren?: ComponentType<any>\n LoaderJSX?: JSX.Element\n}\n\nexport type wrapPromiseType = (promise: (() => Promise<any>) | Promise<any>) => { read: () => Promise<unknown> }\n\nexport const wrapPromise: wrapPromiseType = (promise: (() => Promise<any>) | Promise<any>) => {\n let status = 'pending'\n let result: any\n const suspend = (typeof promise === 'function' ? promise() : promise).then(\n (res) => {\n status = 'success'\n result = res\n },\n (err) => {\n status = 'error'\n result = err\n },\n )\n\n return {\n // eslint-disable-next-line consistent-return\n read(): any {\n if (status === 'pending') {\n throw suspend\n } else if (status === 'error') {\n throw result\n } else if (status === 'success') {\n return result\n }\n },\n }\n}\n\nconst getDefaultLoader = (): ReactNode => (\n <div className={classes.loader}>\n <svg className='spinner' viewBox='0 0 50 50'>\n <circle className='path' cx='25' cy='25' r='20' fill='none' strokeWidth='5' />\n </svg>\n </div>\n)\n\nexport const LazyComponent: FC<LazyComponentProps>\n= memo<LazyComponentProps>(({ children, Component, LoaderJSX, ...props }: LazyComponentProps) => (\n <ErrorBoundary>\n <Suspense fallback={LoaderJSX || getDefaultLoader()}>\n {Component && <Component {...props} />}\n {children && children}\n </Suspense>\n </ErrorBoundary>\n))\n\nLazyComponent.displayName = 'LazyComponent'\n\nexport type PendingBoundaryProps = PropsWithChildren & {\n fallback?: JSX.Element\n promise?: Promise<unknown>\n pendingPromise?: { read: () => Promise<unknown> }\n}\n\nexport const PendingBoundary: FC<PendingBoundaryProps>\n= memo<PendingBoundaryProps>(({ pendingPromise, promise, fallback, children }: PendingBoundaryProps) => {\n const wrappedPromiseRef = useRef(pendingPromise || (promise && wrapPromise(promise)))\n\n const InnerComponent: FC<PropsWithChildren<any>> = useMemo(() => ({ children }: PropsWithChildren<any>) => {\n const innerPromise = wrappedPromiseRef.current?.read?.()\n\n return innerPromise?.then ? null : children\n }, [])\n\n return (\n <LazyComponent LoaderJSX={fallback}>\n <InnerComponent>{children}</InnerComponent>\n </LazyComponent>\n )\n})\n\nPendingBoundary.displayName = 'PendingBoundary'\n\n\nexport const createLazyModule = (\n lazyResolver: () => Promise<ReactModule>,\n displayName: string,\n defaultProps: Record<string, unknown> = {},\n): FC<unknown> => {\n if (!map[displayName]) {\n const Component = lazy(lazyResolver)\n\n // eslint-disable-next-line react/display-name\n map[displayName] = memo((props) => (<LazyComponent Component={Component} {...defaultProps} {...props} />))\n map[displayName].displayName = displayName\n }\n\n return map[displayName]\n}\n\n\nexport const createLazyModuleWithStore = <T, ComponentType>(\n lazyResolver: (store: T) => Promise<ReactModule>,\n displayName: string,\n defaultProps: Record<string, unknown>,\n): (store: T) => FC<ComponentType> => (store: T) => {\n if (!map[displayName]) {\n const Component = lazy(() => lazyResolver(store))\n\n // eslint-disable-next-line react/display-name\n map[displayName] = memo((props) => (<LazyComponent Component={Component} {...defaultProps} {...props} />))\n map[displayName].displayName = displayName\n }\n\n return map[displayName]\n }\n"],"names":["map","wrapPromise","promise","result","status","suspend","then","res","err","read","LazyComponent","memo","_ref","children","Component","LoaderJSX","props","React","createElement","ErrorBoundary","Suspense","fallback","className","classes","loader","viewBox","cx","cy","r","fill","strokeWidth","displayName","PendingBoundary","_ref2","pendingPromise","wrappedPromiseRef","useRef","InnerComponent","useMemo","_ref3","innerPromise","current","createLazyModule","lazyResolver","defaultProps","arguments","length","undefined","lazy","_extends","createLazyModuleWithStore","store"],"mappings":"2QAUA,MAAMA,EAA+B,CAAA,EAaxBC,EAAgCC,IAC3C,IACIC,EADAC,EAAS,UAEb,MAAMC,GAA8B,mBAAZH,EAAyBA,IAAYA,GAASI,MACnEC,IACCH,EAAS,UACTD,EAASI,CAAG,IAEbC,IACCJ,EAAS,QACTD,EAASK,CAAG,IAIhB,MAAO,CAELC,IAAAA,GACE,GAAe,YAAXL,EACF,MAAMC,EACD,GAAe,UAAXD,EACT,MAAMD,EACD,GAAe,YAAXC,EACT,OAAOD,CAEX,EACD,EAWUO,EACXC,GAAyBC,IAAA,IAACC,SAAEA,EAAQC,UAAEA,EAASC,UAAEA,KAAcC,GAA2BJ,EAAA,OAC1FK,MAAAC,cAACC,OACCF,MAAAC,cAACE,EAAQ,CAACC,SAAUN,GAVtBE,MAAAC,cAAA,MAAA,CAAKI,UAAWC,EAAQC,QACtBP,MAAAC,cAAA,MAAA,CAAKI,UAAU,UAAUG,QAAQ,aAC/BR,MAAAC,cAAA,SAAA,CAAQI,UAAU,OAAOI,GAAG,KAAKC,GAAG,KAAKC,EAAE,KAAKC,KAAK,OAAOC,YAAY,SASvEhB,GAAaG,MAAAC,cAACJ,EAAcE,GAC5BH,GAAYA,GAED,IAGlBH,EAAcqB,YAAc,sBAQfC,EACXrB,GAA2BsB,IAA2E,IAA1EC,eAAEA,EAAchC,QAAEA,EAAOmB,SAAEA,EAAQR,SAAEA,GAAgCoB,EACjG,MAAME,EAAoBC,EAAOF,GAAmBhC,GAAWD,EAAYC,IAErEmC,EAA6CC,GAAQ,IAAMC,IAA0C,IAAzC1B,SAAEA,GAAkC0B,EACpG,MAAMC,EAAeL,EAAkBM,SAAShC,SAEhD,OAAO+B,GAAclC,KAAO,KAAOO,CAAQ,GAC1C,IAEH,OACEI,MAAAC,cAACR,EAAa,CAACK,UAAWM,GACxBJ,MAAAC,cAACmB,EAAgBxB,KAAAA,GACH,IAIpBmB,EAAgBD,YAAc,kBAGvB,MAAMW,EAAmB,SAC9BC,EACAZ,GAEgB,IADhBa,EAAqCC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,CAAA,EAExC,IAAK7C,EAAI+B,GAAc,CACrB,MAAMjB,EAAYkC,EAAKL,GAGvB3C,EAAI+B,GAAepB,GAAMK,GAAWC,MAAAC,cAACR,EAAauC,EAAA,CAACnC,UAAWA,GAAe8B,EAAkB5B,MAC/FhB,EAAI+B,GAAaA,YAAcA,CACjC,CAEA,OAAO/B,EAAI+B,EACb,EAGamB,EAA4BA,CACvCP,EACAZ,EACAa,IACqCO,IACnC,IAAKnD,EAAI+B,GAAc,CACrB,MAAMjB,EAAYkC,GAAK,IAAML,EAAaQ,KAG1CnD,EAAI+B,GAAepB,GAAMK,GAAWC,MAAAC,cAACR,EAAauC,EAAA,CAACnC,UAAWA,GAAe8B,EAAkB5B,MAC/FhB,EAAI+B,GAAaA,YAAcA,CACjC,CAEA,OAAO/B,EAAI+B,EAAY"}
|