@cyberskill/shared 1.46.0 → 1.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -18
- package/dist/_tsup-dts-rollup.d.cts +413 -31
- package/dist/_tsup-dts-rollup.d.ts +413 -31
- package/dist/cli.cjs +2136 -1
- package/dist/cli.d.cts +2 -1
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +2056 -1
- package/dist/configs/commitlint/base.cjs +64 -1
- package/dist/configs/commitlint/base.js +7 -1
- package/dist/configs/eslint/base.cjs +121 -1
- package/dist/configs/eslint/base.js +52 -1
- package/dist/configs/eslint/nestjs.cjs +155 -1
- package/dist/configs/eslint/nestjs.js +85 -1
- package/dist/configs/eslint/nextjs.cjs +155 -1
- package/dist/configs/eslint/nextjs.js +85 -1
- package/dist/configs/eslint/nodejs.cjs +156 -1
- package/dist/configs/eslint/nodejs.js +86 -1
- package/dist/configs/eslint/vite-react.cjs +159 -1
- package/dist/configs/eslint/vite-react.js +89 -1
- package/dist/configs/graphql/graphql-codegen.cjs +125 -1
- package/dist/configs/graphql/graphql-codegen.js +64 -1
- package/dist/configs/graphql/index.cjs +126 -1
- package/dist/configs/graphql/index.js +64 -1
- package/dist/configs/i18n/react/i18next.cjs +80 -1
- package/dist/configs/i18n/react/i18next.js +7 -1
- package/dist/configs/i18n/react/index.cjs +81 -1
- package/dist/configs/i18n/react/index.js +7 -1
- package/dist/configs/index.cjs +232 -1
- package/dist/configs/index.js +166 -1
- package/dist/configs/lint-staged/base.cjs +64 -1
- package/dist/configs/lint-staged/base.js +7 -1
- package/dist/configs/vitest/react/e2e.cjs +128 -1
- package/dist/configs/vitest/react/e2e.js +59 -1
- package/dist/configs/vitest/react/unit.cjs +305 -1
- package/dist/configs/vitest/react/unit.js +228 -1
- package/dist/configs/vitest/react/unit.setup.cjs +60 -1
- package/dist/configs/vitest/react/unit.setup.js +8 -1
- package/dist/constants/index.cjs +678 -1
- package/dist/constants/index.d.cts +31 -1
- package/dist/constants/index.d.ts +31 -1
- package/dist/constants/index.js +469 -1
- package/dist/constants/path.cjs +423 -1
- package/dist/constants/path.d.cts +31 -1
- package/dist/constants/path.d.ts +31 -1
- package/dist/constants/path.js +218 -1
- package/dist/constants/response-status.cjs +313 -1
- package/dist/constants/response-status.js +252 -1
- package/dist/index.cjs +4546 -1
- package/dist/index.d.cts +51 -6
- package/dist/index.d.ts +51 -6
- package/dist/index.js +4133 -1
- package/dist/nodejs/index.cjs +2138 -1
- package/dist/nodejs/index.js +2054 -1
- package/dist/nodejs/mongo.cjs +2137 -1
- package/dist/nodejs/mongo.js +2054 -1
- package/dist/react/apollo-client.cjs +177 -1
- package/dist/react/apollo-client.js +116 -1
- package/dist/react/index.cjs +990 -1
- package/dist/react/index.js +876 -1
- package/dist/react/loading.cjs +301 -1
- package/dist/react/loading.js +216 -1
- package/dist/react/next-intl.cjs +744 -1
- package/dist/react/next-intl.js +655 -1
- package/dist/react/storage.cjs +631 -1
- package/dist/react/storage.js +558 -1
- package/dist/typescript/api-response.cjs +48 -1
- package/dist/typescript/apollo.cjs +48 -1
- package/dist/typescript/command.cjs +68 -1
- package/dist/typescript/command.d.cts +4 -0
- package/dist/typescript/command.d.ts +4 -0
- package/dist/typescript/command.js +7 -1
- package/dist/typescript/config.cjs +48 -1
- package/dist/typescript/fs.cjs +48 -0
- package/dist/typescript/fs.d.cts +1 -0
- package/dist/typescript/fs.d.ts +1 -0
- package/dist/typescript/fs.js +0 -0
- package/dist/typescript/graphql-codegen.cjs +48 -1
- package/dist/typescript/index.cjs +175 -1
- package/dist/typescript/index.d.cts +5 -0
- package/dist/typescript/index.d.ts +5 -0
- package/dist/typescript/index.js +151 -1
- package/dist/typescript/loading.cjs +48 -1
- package/dist/typescript/log.cjs +48 -1
- package/dist/typescript/mongo.cjs +164 -1
- package/dist/typescript/mongo.js +145 -1
- package/dist/typescript/next-intl.cjs +48 -1
- package/dist/typescript/react.cjs +48 -1
- package/dist/typescript/serializer.cjs +48 -1
- package/dist/typescript/string.cjs +48 -1
- package/dist/utils/command.cjs +1387 -1
- package/dist/utils/command.d.cts +2 -0
- package/dist/utils/command.d.ts +2 -0
- package/dist/utils/command.js +1287 -1
- package/dist/utils/common.cjs +300 -1
- package/dist/utils/common.js +219 -1
- package/dist/utils/config.cjs +146 -1
- package/dist/utils/config.js +89 -1
- package/dist/utils/fs.cjs +118 -1
- package/dist/utils/fs.d.cts +4 -1
- package/dist/utils/fs.d.ts +4 -1
- package/dist/utils/fs.js +37 -1
- package/dist/utils/index-nodejs.cjs +1738 -1
- package/dist/utils/index-nodejs.d.cts +15 -5
- package/dist/utils/index-nodejs.d.ts +15 -5
- package/dist/utils/index-nodejs.js +1571 -1
- package/dist/utils/index.cjs +727 -1
- package/dist/utils/index.js +625 -1
- package/dist/utils/log.cjs +330 -1
- package/dist/utils/log.js +269 -1
- package/dist/utils/package.cjs +941 -0
- package/dist/utils/package.d.cts +3 -0
- package/dist/utils/package.d.ts +3 -0
- package/dist/utils/package.js +857 -0
- package/dist/utils/path.cjs +291 -0
- package/dist/utils/path.d.cts +6 -0
- package/dist/utils/path.d.ts +6 -0
- package/dist/utils/path.js +191 -0
- package/dist/utils/serializer.cjs +91 -1
- package/dist/utils/serializer.js +30 -1
- package/dist/utils/storage-client.cjs +349 -1
- package/dist/utils/storage-client.js +276 -1
- package/dist/utils/storage-server.cjs +636 -1
- package/dist/utils/storage-server.d.cts +1 -1
- package/dist/utils/storage-server.d.ts +1 -1
- package/dist/utils/storage-server.js +550 -1
- package/dist/utils/string.cjs +152 -1
- package/dist/utils/string.js +75 -1
- package/dist/utils/validate.cjs +90 -1
- package/dist/utils/validate.js +33 -1
- package/package.json +19 -16
- package/dist/utils/npm-package.cjs +0 -1
- package/dist/utils/npm-package.d.cts +0 -4
- package/dist/utils/npm-package.d.ts +0 -4
- package/dist/utils/npm-package.js +0 -1
package/dist/react/loading.cjs
CHANGED
|
@@ -1 +1,301 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
function _array_like_to_array(arr, len) {
|
|
3
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
+
return arr2;
|
|
6
|
+
}
|
|
7
|
+
function _array_with_holes(arr) {
|
|
8
|
+
if (Array.isArray(arr)) return arr;
|
|
9
|
+
}
|
|
10
|
+
function _define_property(obj, key, value) {
|
|
11
|
+
if (key in obj) {
|
|
12
|
+
Object.defineProperty(obj, key, {
|
|
13
|
+
value: value,
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true
|
|
17
|
+
});
|
|
18
|
+
} else {
|
|
19
|
+
obj[key] = value;
|
|
20
|
+
}
|
|
21
|
+
return obj;
|
|
22
|
+
}
|
|
23
|
+
function _iterable_to_array_limit(arr, i) {
|
|
24
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
25
|
+
if (_i == null) return;
|
|
26
|
+
var _arr = [];
|
|
27
|
+
var _n = true;
|
|
28
|
+
var _d = false;
|
|
29
|
+
var _s, _e;
|
|
30
|
+
try {
|
|
31
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
32
|
+
_arr.push(_s.value);
|
|
33
|
+
if (i && _arr.length === i) break;
|
|
34
|
+
}
|
|
35
|
+
} catch (err) {
|
|
36
|
+
_d = true;
|
|
37
|
+
_e = err;
|
|
38
|
+
} finally{
|
|
39
|
+
try {
|
|
40
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
41
|
+
} finally{
|
|
42
|
+
if (_d) throw _e;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return _arr;
|
|
46
|
+
}
|
|
47
|
+
function _non_iterable_rest() {
|
|
48
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
49
|
+
}
|
|
50
|
+
function _object_spread(target) {
|
|
51
|
+
for(var i = 1; i < arguments.length; i++){
|
|
52
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
53
|
+
var ownKeys = Object.keys(source);
|
|
54
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
55
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
56
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
ownKeys.forEach(function(key) {
|
|
60
|
+
_define_property(target, key, source[key]);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return target;
|
|
64
|
+
}
|
|
65
|
+
function ownKeys(object, enumerableOnly) {
|
|
66
|
+
var keys = Object.keys(object);
|
|
67
|
+
if (Object.getOwnPropertySymbols) {
|
|
68
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
69
|
+
if (enumerableOnly) {
|
|
70
|
+
symbols = symbols.filter(function(sym) {
|
|
71
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
keys.push.apply(keys, symbols);
|
|
75
|
+
}
|
|
76
|
+
return keys;
|
|
77
|
+
}
|
|
78
|
+
function _object_spread_props(target, source) {
|
|
79
|
+
source = source != null ? source : {};
|
|
80
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
81
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
82
|
+
} else {
|
|
83
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
84
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return target;
|
|
88
|
+
}
|
|
89
|
+
function _object_without_properties(source, excluded) {
|
|
90
|
+
if (source == null) return {};
|
|
91
|
+
var target = _object_without_properties_loose(source, excluded);
|
|
92
|
+
var key, i;
|
|
93
|
+
if (Object.getOwnPropertySymbols) {
|
|
94
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
95
|
+
for(i = 0; i < sourceSymbolKeys.length; i++){
|
|
96
|
+
key = sourceSymbolKeys[i];
|
|
97
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
98
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
99
|
+
target[key] = source[key];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return target;
|
|
103
|
+
}
|
|
104
|
+
function _object_without_properties_loose(source, excluded) {
|
|
105
|
+
if (source == null) return {};
|
|
106
|
+
var target = {};
|
|
107
|
+
var sourceKeys = Object.keys(source);
|
|
108
|
+
var key, i;
|
|
109
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
110
|
+
key = sourceKeys[i];
|
|
111
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
112
|
+
target[key] = source[key];
|
|
113
|
+
}
|
|
114
|
+
return target;
|
|
115
|
+
}
|
|
116
|
+
function _sliced_to_array(arr, i) {
|
|
117
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
118
|
+
}
|
|
119
|
+
function _type_of(obj) {
|
|
120
|
+
"@swc/helpers - typeof";
|
|
121
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
122
|
+
}
|
|
123
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
124
|
+
if (!o) return;
|
|
125
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
126
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
127
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
128
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
129
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
130
|
+
}
|
|
131
|
+
var __create = Object.create;
|
|
132
|
+
var __defProp = Object.defineProperty;
|
|
133
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
134
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
135
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
136
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
137
|
+
var __export = function(target, all) {
|
|
138
|
+
for(var name in all)__defProp(target, name, {
|
|
139
|
+
get: all[name],
|
|
140
|
+
enumerable: true
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
var __copyProps = function(to, from, except, desc) {
|
|
144
|
+
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
|
145
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
146
|
+
try {
|
|
147
|
+
var _loop = function() {
|
|
148
|
+
var key = _step.value;
|
|
149
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
150
|
+
get: function() {
|
|
151
|
+
return from[key];
|
|
152
|
+
},
|
|
153
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
157
|
+
} catch (err) {
|
|
158
|
+
_didIteratorError = true;
|
|
159
|
+
_iteratorError = err;
|
|
160
|
+
} finally{
|
|
161
|
+
try {
|
|
162
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
163
|
+
_iterator.return();
|
|
164
|
+
}
|
|
165
|
+
} finally{
|
|
166
|
+
if (_didIteratorError) {
|
|
167
|
+
throw _iteratorError;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return to;
|
|
173
|
+
};
|
|
174
|
+
var __toESM = function(mod, isNodeMode, target) {
|
|
175
|
+
return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
|
|
176
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
177
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
178
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
179
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
180
|
+
value: mod,
|
|
181
|
+
enumerable: true
|
|
182
|
+
}) : target, mod);
|
|
183
|
+
};
|
|
184
|
+
var __toCommonJS = function(mod) {
|
|
185
|
+
return __copyProps(__defProp({}, "__esModule", {
|
|
186
|
+
value: true
|
|
187
|
+
}), mod);
|
|
188
|
+
};
|
|
189
|
+
// src/react/loading.tsx
|
|
190
|
+
var loading_exports = {};
|
|
191
|
+
__export(loading_exports, {
|
|
192
|
+
Loading: function() {
|
|
193
|
+
return Loading;
|
|
194
|
+
},
|
|
195
|
+
LoadingContext: function() {
|
|
196
|
+
return LoadingContext;
|
|
197
|
+
},
|
|
198
|
+
LoadingProvider: function() {
|
|
199
|
+
return LoadingProvider;
|
|
200
|
+
},
|
|
201
|
+
useLoading: function() {
|
|
202
|
+
return useLoading;
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
module.exports = __toCommonJS(loading_exports);
|
|
206
|
+
var import_classnames = __toESM(require("classnames"), 1);
|
|
207
|
+
var import_react = require("react");
|
|
208
|
+
var import_loading_module = __toESM(require("./loading.module.scss"), 1);
|
|
209
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
210
|
+
var LoadingContext = (0, import_react.createContext)(void 0);
|
|
211
|
+
function useLoading() {
|
|
212
|
+
var context = (0, import_react.use)(LoadingContext);
|
|
213
|
+
if (!context) {
|
|
214
|
+
throw new Error("useLoading must be used within a LoadingProvider");
|
|
215
|
+
}
|
|
216
|
+
return context;
|
|
217
|
+
}
|
|
218
|
+
function Loading(_param) {
|
|
219
|
+
var _param_full = _param.full, full = _param_full === void 0 ? false : _param_full, _param_block = _param.block, block = _param_block === void 0 ? false : _param_block, _param_className = _param.className, className = _param_className === void 0 ? "" : _param_className, _param_message = _param.message, message = _param_message === void 0 ? "Loading" : _param_message, rest = _object_without_properties(_param, [
|
|
220
|
+
"full",
|
|
221
|
+
"block",
|
|
222
|
+
"className",
|
|
223
|
+
"message"
|
|
224
|
+
]);
|
|
225
|
+
function _renderLoading() {
|
|
226
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", _object_spread_props(_object_spread({
|
|
227
|
+
className: import_loading_module.default.container
|
|
228
|
+
}, rest), {
|
|
229
|
+
children: [
|
|
230
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
231
|
+
className: import_loading_module.default.ring
|
|
232
|
+
}),
|
|
233
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
234
|
+
className: import_loading_module.default.ring
|
|
235
|
+
}),
|
|
236
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
237
|
+
className: import_loading_module.default.ring
|
|
238
|
+
}),
|
|
239
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
240
|
+
className: import_loading_module.default.ring
|
|
241
|
+
}),
|
|
242
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
243
|
+
className: import_loading_module.default.message,
|
|
244
|
+
children: message
|
|
245
|
+
})
|
|
246
|
+
]
|
|
247
|
+
}));
|
|
248
|
+
}
|
|
249
|
+
if (full) {
|
|
250
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
251
|
+
className: (0, import_classnames.default)(import_loading_module.default.fullscreen, className),
|
|
252
|
+
children: _renderLoading()
|
|
253
|
+
});
|
|
254
|
+
} else if (block) {
|
|
255
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
256
|
+
className: (0, import_classnames.default)(import_loading_module.default.block, className),
|
|
257
|
+
children: _renderLoading()
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
return _renderLoading();
|
|
261
|
+
}
|
|
262
|
+
function LoadingProvider(param) {
|
|
263
|
+
var children = param.children;
|
|
264
|
+
var _ref = _sliced_to_array((0, import_react.useState)(false), 2), isLoading = _ref[0], setIsLoading = _ref[1];
|
|
265
|
+
var _ref1 = _sliced_to_array((0, import_react.useState)(false), 2), isGlobalLoading = _ref1[0], setIsGlobalLoading = _ref1[1];
|
|
266
|
+
var showLoading = (0, import_react.useCallback)(function() {
|
|
267
|
+
var global = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
|
|
268
|
+
setIsLoading(true);
|
|
269
|
+
setIsGlobalLoading(global);
|
|
270
|
+
}, []);
|
|
271
|
+
var hideLoading = (0, import_react.useCallback)(function() {
|
|
272
|
+
setIsLoading(false);
|
|
273
|
+
setIsGlobalLoading(false);
|
|
274
|
+
}, []);
|
|
275
|
+
var contextValue = (0, import_react.useMemo)(function() {
|
|
276
|
+
return {
|
|
277
|
+
isLoading: isLoading,
|
|
278
|
+
isGlobalLoading: isGlobalLoading,
|
|
279
|
+
showLoading: showLoading,
|
|
280
|
+
hideLoading: hideLoading
|
|
281
|
+
};
|
|
282
|
+
}, [
|
|
283
|
+
isLoading,
|
|
284
|
+
isGlobalLoading,
|
|
285
|
+
showLoading,
|
|
286
|
+
hideLoading
|
|
287
|
+
]);
|
|
288
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingContext, {
|
|
289
|
+
value: contextValue,
|
|
290
|
+
children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {
|
|
291
|
+
full: isGlobalLoading
|
|
292
|
+
}) : children
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
296
|
+
0 && (module.exports = {
|
|
297
|
+
Loading: Loading,
|
|
298
|
+
LoadingContext: LoadingContext,
|
|
299
|
+
LoadingProvider: LoadingProvider,
|
|
300
|
+
useLoading: useLoading
|
|
301
|
+
});
|
package/dist/react/loading.js
CHANGED
|
@@ -1 +1,216 @@
|
|
|
1
|
-
|
|
1
|
+
// src/react/loading.tsx
|
|
2
|
+
function _array_like_to_array(arr, len) {
|
|
3
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
+
return arr2;
|
|
6
|
+
}
|
|
7
|
+
function _array_with_holes(arr) {
|
|
8
|
+
if (Array.isArray(arr)) return arr;
|
|
9
|
+
}
|
|
10
|
+
function _define_property(obj, key, value) {
|
|
11
|
+
if (key in obj) {
|
|
12
|
+
Object.defineProperty(obj, key, {
|
|
13
|
+
value: value,
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true
|
|
17
|
+
});
|
|
18
|
+
} else {
|
|
19
|
+
obj[key] = value;
|
|
20
|
+
}
|
|
21
|
+
return obj;
|
|
22
|
+
}
|
|
23
|
+
function _iterable_to_array_limit(arr, i) {
|
|
24
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
25
|
+
if (_i == null) return;
|
|
26
|
+
var _arr = [];
|
|
27
|
+
var _n = true;
|
|
28
|
+
var _d = false;
|
|
29
|
+
var _s, _e;
|
|
30
|
+
try {
|
|
31
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
32
|
+
_arr.push(_s.value);
|
|
33
|
+
if (i && _arr.length === i) break;
|
|
34
|
+
}
|
|
35
|
+
} catch (err) {
|
|
36
|
+
_d = true;
|
|
37
|
+
_e = err;
|
|
38
|
+
} finally{
|
|
39
|
+
try {
|
|
40
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
41
|
+
} finally{
|
|
42
|
+
if (_d) throw _e;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return _arr;
|
|
46
|
+
}
|
|
47
|
+
function _non_iterable_rest() {
|
|
48
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
49
|
+
}
|
|
50
|
+
function _object_spread(target) {
|
|
51
|
+
for(var i = 1; i < arguments.length; i++){
|
|
52
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
53
|
+
var ownKeys = Object.keys(source);
|
|
54
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
55
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
56
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
ownKeys.forEach(function(key) {
|
|
60
|
+
_define_property(target, key, source[key]);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return target;
|
|
64
|
+
}
|
|
65
|
+
function ownKeys(object, enumerableOnly) {
|
|
66
|
+
var keys = Object.keys(object);
|
|
67
|
+
if (Object.getOwnPropertySymbols) {
|
|
68
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
69
|
+
if (enumerableOnly) {
|
|
70
|
+
symbols = symbols.filter(function(sym) {
|
|
71
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
keys.push.apply(keys, symbols);
|
|
75
|
+
}
|
|
76
|
+
return keys;
|
|
77
|
+
}
|
|
78
|
+
function _object_spread_props(target, source) {
|
|
79
|
+
source = source != null ? source : {};
|
|
80
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
81
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
82
|
+
} else {
|
|
83
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
84
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return target;
|
|
88
|
+
}
|
|
89
|
+
function _object_without_properties(source, excluded) {
|
|
90
|
+
if (source == null) return {};
|
|
91
|
+
var target = _object_without_properties_loose(source, excluded);
|
|
92
|
+
var key, i;
|
|
93
|
+
if (Object.getOwnPropertySymbols) {
|
|
94
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
95
|
+
for(i = 0; i < sourceSymbolKeys.length; i++){
|
|
96
|
+
key = sourceSymbolKeys[i];
|
|
97
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
98
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
99
|
+
target[key] = source[key];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return target;
|
|
103
|
+
}
|
|
104
|
+
function _object_without_properties_loose(source, excluded) {
|
|
105
|
+
if (source == null) return {};
|
|
106
|
+
var target = {};
|
|
107
|
+
var sourceKeys = Object.keys(source);
|
|
108
|
+
var key, i;
|
|
109
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
110
|
+
key = sourceKeys[i];
|
|
111
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
112
|
+
target[key] = source[key];
|
|
113
|
+
}
|
|
114
|
+
return target;
|
|
115
|
+
}
|
|
116
|
+
function _sliced_to_array(arr, i) {
|
|
117
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
118
|
+
}
|
|
119
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
120
|
+
if (!o) return;
|
|
121
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
122
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
123
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
124
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
125
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
126
|
+
}
|
|
127
|
+
import cn from "classnames";
|
|
128
|
+
import { createContext, use, useCallback, useMemo, useState } from "react";
|
|
129
|
+
import styles from "./loading.module.scss";
|
|
130
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
131
|
+
var LoadingContext = createContext(void 0);
|
|
132
|
+
function useLoading() {
|
|
133
|
+
var context = use(LoadingContext);
|
|
134
|
+
if (!context) {
|
|
135
|
+
throw new Error("useLoading must be used within a LoadingProvider");
|
|
136
|
+
}
|
|
137
|
+
return context;
|
|
138
|
+
}
|
|
139
|
+
function Loading(_param) {
|
|
140
|
+
var _param_full = _param.full, full = _param_full === void 0 ? false : _param_full, _param_block = _param.block, block = _param_block === void 0 ? false : _param_block, _param_className = _param.className, className = _param_className === void 0 ? "" : _param_className, _param_message = _param.message, message = _param_message === void 0 ? "Loading" : _param_message, rest = _object_without_properties(_param, [
|
|
141
|
+
"full",
|
|
142
|
+
"block",
|
|
143
|
+
"className",
|
|
144
|
+
"message"
|
|
145
|
+
]);
|
|
146
|
+
function _renderLoading() {
|
|
147
|
+
return /* @__PURE__ */ jsxs("div", _object_spread_props(_object_spread({
|
|
148
|
+
className: styles.container
|
|
149
|
+
}, rest), {
|
|
150
|
+
children: [
|
|
151
|
+
/* @__PURE__ */ jsx("div", {
|
|
152
|
+
className: styles.ring
|
|
153
|
+
}),
|
|
154
|
+
/* @__PURE__ */ jsx("div", {
|
|
155
|
+
className: styles.ring
|
|
156
|
+
}),
|
|
157
|
+
/* @__PURE__ */ jsx("div", {
|
|
158
|
+
className: styles.ring
|
|
159
|
+
}),
|
|
160
|
+
/* @__PURE__ */ jsx("div", {
|
|
161
|
+
className: styles.ring
|
|
162
|
+
}),
|
|
163
|
+
message && /* @__PURE__ */ jsx("div", {
|
|
164
|
+
className: styles.message,
|
|
165
|
+
children: message
|
|
166
|
+
})
|
|
167
|
+
]
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
if (full) {
|
|
171
|
+
return /* @__PURE__ */ jsx("div", {
|
|
172
|
+
className: cn(styles.fullscreen, className),
|
|
173
|
+
children: _renderLoading()
|
|
174
|
+
});
|
|
175
|
+
} else if (block) {
|
|
176
|
+
return /* @__PURE__ */ jsx("div", {
|
|
177
|
+
className: cn(styles.block, className),
|
|
178
|
+
children: _renderLoading()
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
return _renderLoading();
|
|
182
|
+
}
|
|
183
|
+
function LoadingProvider(param) {
|
|
184
|
+
var children = param.children;
|
|
185
|
+
var _useState = _sliced_to_array(useState(false), 2), isLoading = _useState[0], setIsLoading = _useState[1];
|
|
186
|
+
var _useState1 = _sliced_to_array(useState(false), 2), isGlobalLoading = _useState1[0], setIsGlobalLoading = _useState1[1];
|
|
187
|
+
var showLoading = useCallback(function() {
|
|
188
|
+
var global = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
|
|
189
|
+
setIsLoading(true);
|
|
190
|
+
setIsGlobalLoading(global);
|
|
191
|
+
}, []);
|
|
192
|
+
var hideLoading = useCallback(function() {
|
|
193
|
+
setIsLoading(false);
|
|
194
|
+
setIsGlobalLoading(false);
|
|
195
|
+
}, []);
|
|
196
|
+
var contextValue = useMemo(function() {
|
|
197
|
+
return {
|
|
198
|
+
isLoading: isLoading,
|
|
199
|
+
isGlobalLoading: isGlobalLoading,
|
|
200
|
+
showLoading: showLoading,
|
|
201
|
+
hideLoading: hideLoading
|
|
202
|
+
};
|
|
203
|
+
}, [
|
|
204
|
+
isLoading,
|
|
205
|
+
isGlobalLoading,
|
|
206
|
+
showLoading,
|
|
207
|
+
hideLoading
|
|
208
|
+
]);
|
|
209
|
+
return /* @__PURE__ */ jsx(LoadingContext, {
|
|
210
|
+
value: contextValue,
|
|
211
|
+
children: isLoading ? /* @__PURE__ */ jsx(Loading, {
|
|
212
|
+
full: isGlobalLoading
|
|
213
|
+
}) : children
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
export { Loading, LoadingContext, LoadingProvider, useLoading };
|