elseware-ui 2.33.0 → 2.34.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/LICENSE +20 -20
- package/README.md +98 -98
- package/dist/index.d.mts +2198 -2077
- package/dist/index.d.ts +2198 -2077
- package/dist/index.js +339 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +324 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +111 -111
package/dist/index.js
CHANGED
|
@@ -188,6 +188,326 @@ function resolveAppearanceStyles({
|
|
|
188
188
|
return solid[variant];
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
+
|
|
192
|
+
// src/utils/configurator/errors.ts
|
|
193
|
+
var ConfiguratorError = class extends Error {
|
|
194
|
+
constructor(message, cause) {
|
|
195
|
+
super(message);
|
|
196
|
+
this.name = "ConfiguratorError";
|
|
197
|
+
this.cause = cause;
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
function formatIssue(issue) {
|
|
201
|
+
const path = issue.path?.join(".") || "config";
|
|
202
|
+
return `${path} : ${issue.message ?? "Invalid value"}`;
|
|
203
|
+
}
|
|
204
|
+
function formatConfigError(error) {
|
|
205
|
+
const maybeZodError = error;
|
|
206
|
+
if (Array.isArray(maybeZodError.issues)) {
|
|
207
|
+
return maybeZodError.issues.map(formatIssue).join("\n");
|
|
208
|
+
}
|
|
209
|
+
if (maybeZodError?.message) {
|
|
210
|
+
return maybeZodError.message;
|
|
211
|
+
}
|
|
212
|
+
return "Invalid configuration";
|
|
213
|
+
}
|
|
214
|
+
function toConfiguratorError(error, fallbackMessage) {
|
|
215
|
+
if (error instanceof ConfiguratorError) {
|
|
216
|
+
return error;
|
|
217
|
+
}
|
|
218
|
+
if (error instanceof Error) {
|
|
219
|
+
return new ConfiguratorError(error.message || fallbackMessage, error);
|
|
220
|
+
}
|
|
221
|
+
return new ConfiguratorError(fallbackMessage, error);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// src/utils/configurator/Configurator.ts
|
|
225
|
+
var Configurator = class {
|
|
226
|
+
constructor(options) {
|
|
227
|
+
this.initialized = false;
|
|
228
|
+
this.config = null;
|
|
229
|
+
this.configError = null;
|
|
230
|
+
this.name = options.name ?? "config";
|
|
231
|
+
this.source = options.env;
|
|
232
|
+
this.schema = options.schema;
|
|
233
|
+
this.transform = options.transform;
|
|
234
|
+
if (options.validateOnCreate !== false) {
|
|
235
|
+
this.reload();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
get isValid() {
|
|
239
|
+
this.ensureInitialized();
|
|
240
|
+
return !this.configError;
|
|
241
|
+
}
|
|
242
|
+
get error() {
|
|
243
|
+
this.ensureInitialized();
|
|
244
|
+
return this.configError;
|
|
245
|
+
}
|
|
246
|
+
get value() {
|
|
247
|
+
this.ensureInitialized();
|
|
248
|
+
if (this.configError) {
|
|
249
|
+
throw this.configError;
|
|
250
|
+
}
|
|
251
|
+
return this.config;
|
|
252
|
+
}
|
|
253
|
+
get optionalValue() {
|
|
254
|
+
this.ensureInitialized();
|
|
255
|
+
return this.config;
|
|
256
|
+
}
|
|
257
|
+
reload(env = this.source) {
|
|
258
|
+
this.source = env;
|
|
259
|
+
this.initialized = true;
|
|
260
|
+
const result = this.schema.safeParse(env);
|
|
261
|
+
if (!result.success) {
|
|
262
|
+
this.config = null;
|
|
263
|
+
this.configError = toConfiguratorError(
|
|
264
|
+
result.error,
|
|
265
|
+
formatConfigError(result.error)
|
|
266
|
+
);
|
|
267
|
+
return {
|
|
268
|
+
success: false,
|
|
269
|
+
config: null,
|
|
270
|
+
error: this.configError
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
try {
|
|
274
|
+
this.config = this.transform ? this.transform(result.data, { name: this.name }) : result.data;
|
|
275
|
+
this.configError = null;
|
|
276
|
+
return {
|
|
277
|
+
success: true,
|
|
278
|
+
config: this.config,
|
|
279
|
+
error: null
|
|
280
|
+
};
|
|
281
|
+
} catch (error) {
|
|
282
|
+
this.config = null;
|
|
283
|
+
this.configError = toConfiguratorError(
|
|
284
|
+
error,
|
|
285
|
+
`Failed to transform ${this.name}`
|
|
286
|
+
);
|
|
287
|
+
return {
|
|
288
|
+
success: false,
|
|
289
|
+
config: null,
|
|
290
|
+
error: this.configError
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
get(key) {
|
|
295
|
+
this.ensureInitialized();
|
|
296
|
+
if (!this.config) {
|
|
297
|
+
return void 0;
|
|
298
|
+
}
|
|
299
|
+
return this.config[key];
|
|
300
|
+
}
|
|
301
|
+
getRequired(key) {
|
|
302
|
+
const value = this.get(key);
|
|
303
|
+
if (value === void 0 || value === null) {
|
|
304
|
+
throw new Error(`Missing required config value: ${String(key)}`);
|
|
305
|
+
}
|
|
306
|
+
return value;
|
|
307
|
+
}
|
|
308
|
+
getPath(path, fallback) {
|
|
309
|
+
this.ensureInitialized();
|
|
310
|
+
if (!this.config) {
|
|
311
|
+
return fallback;
|
|
312
|
+
}
|
|
313
|
+
const value = path.split(".").reduce((current, key) => {
|
|
314
|
+
if (!current || typeof current !== "object") {
|
|
315
|
+
return void 0;
|
|
316
|
+
}
|
|
317
|
+
return current[key];
|
|
318
|
+
}, this.config);
|
|
319
|
+
return value === void 0 ? fallback : value;
|
|
320
|
+
}
|
|
321
|
+
getPathRequired(path) {
|
|
322
|
+
const value = this.getPath(path);
|
|
323
|
+
if (value === void 0 || value === null) {
|
|
324
|
+
throw new Error(`Missing required config value: ${path}`);
|
|
325
|
+
}
|
|
326
|
+
return value;
|
|
327
|
+
}
|
|
328
|
+
ensureInitialized() {
|
|
329
|
+
if (!this.initialized) {
|
|
330
|
+
this.reload();
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
// src/utils/configurator/createConfigurator.ts
|
|
336
|
+
function createConfigurator(options) {
|
|
337
|
+
return new Configurator(options);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// src/utils/configurator/helpers/browser.ts
|
|
341
|
+
function getBrowserOrigin() {
|
|
342
|
+
if (typeof window === "undefined") {
|
|
343
|
+
return "";
|
|
344
|
+
}
|
|
345
|
+
return window.location.origin;
|
|
346
|
+
}
|
|
347
|
+
function getBrowserHref() {
|
|
348
|
+
if (typeof window === "undefined") {
|
|
349
|
+
return "";
|
|
350
|
+
}
|
|
351
|
+
return window.location.href;
|
|
352
|
+
}
|
|
353
|
+
function getBrowserRedirectURL(options = {}) {
|
|
354
|
+
const {
|
|
355
|
+
queryParam = "redirect_uri",
|
|
356
|
+
fallbackPath = "/",
|
|
357
|
+
currentHref = getBrowserHref(),
|
|
358
|
+
referrerMode = "path"
|
|
359
|
+
} = options;
|
|
360
|
+
try {
|
|
361
|
+
if (currentHref) {
|
|
362
|
+
const currentURL = new URL(currentHref);
|
|
363
|
+
const redirectUri = currentURL.searchParams.get(queryParam);
|
|
364
|
+
if (redirectUri) {
|
|
365
|
+
return redirectUri;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
if (typeof document !== "undefined" && document.referrer) {
|
|
369
|
+
const referrerURL = new URL(document.referrer);
|
|
370
|
+
if (referrerMode === "full") {
|
|
371
|
+
return referrerURL.toString();
|
|
372
|
+
}
|
|
373
|
+
return `${referrerURL.pathname}${referrerURL.search}${referrerURL.hash}`;
|
|
374
|
+
}
|
|
375
|
+
return fallbackPath;
|
|
376
|
+
} catch {
|
|
377
|
+
return fallbackPath;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// src/utils/configurator/helpers/json.ts
|
|
382
|
+
function isRecord(value) {
|
|
383
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
384
|
+
}
|
|
385
|
+
function parseJson(value, key = "JSON value") {
|
|
386
|
+
if (isRecord(value) || Array.isArray(value)) {
|
|
387
|
+
return value;
|
|
388
|
+
}
|
|
389
|
+
if (typeof value !== "string") {
|
|
390
|
+
throw new ConfiguratorError(`${key} must be a JSON string`);
|
|
391
|
+
}
|
|
392
|
+
try {
|
|
393
|
+
return JSON.parse(value);
|
|
394
|
+
} catch {
|
|
395
|
+
throw new ConfiguratorError(`Invalid ${key} JSON`);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
function parseJsonRecord(value, key = "JSON record", validateValue) {
|
|
399
|
+
const parsed = parseJson(value, key);
|
|
400
|
+
if (!isRecord(parsed)) {
|
|
401
|
+
throw new ConfiguratorError(`${key} must be a JSON object`);
|
|
402
|
+
}
|
|
403
|
+
return Object.entries(parsed).reduce(
|
|
404
|
+
(acc, [name, item]) => {
|
|
405
|
+
acc[name] = validateValue ? validateValue(name, item) : item;
|
|
406
|
+
return acc;
|
|
407
|
+
},
|
|
408
|
+
{}
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// src/utils/configurator/helpers/url.ts
|
|
413
|
+
function assertAbsoluteURL(value, key = "URL") {
|
|
414
|
+
if (typeof value !== "string") {
|
|
415
|
+
throw new ConfiguratorError(`${key} must be a string URL`);
|
|
416
|
+
}
|
|
417
|
+
try {
|
|
418
|
+
const url = new URL(value);
|
|
419
|
+
if (!["http:", "https:"].includes(url.protocol)) {
|
|
420
|
+
throw new Error();
|
|
421
|
+
}
|
|
422
|
+
return url.toString();
|
|
423
|
+
} catch {
|
|
424
|
+
throw new ConfiguratorError(`${key} must be a valid http/https URL`);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
function parseUrlMap(value, key = "URL map") {
|
|
428
|
+
return parseJsonRecord(
|
|
429
|
+
value,
|
|
430
|
+
key,
|
|
431
|
+
(name, item) => assertAbsoluteURL(item, `${key}.${name}`)
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
function buildURL(base, path = "", params = {}) {
|
|
435
|
+
const url = new URL(assertAbsoluteURL(base, "base URL"));
|
|
436
|
+
if (path) {
|
|
437
|
+
const currentPath = url.pathname.replace(/\/$/, "");
|
|
438
|
+
const nextPath = path.replace(/^\/+/, "");
|
|
439
|
+
url.pathname = `${currentPath}/${nextPath}`;
|
|
440
|
+
}
|
|
441
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
442
|
+
if (value !== void 0 && value !== null) {
|
|
443
|
+
url.searchParams.set(key, String(value));
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
return url.toString();
|
|
447
|
+
}
|
|
448
|
+
function resolveURLMap(source) {
|
|
449
|
+
return typeof source === "function" ? source() : source;
|
|
450
|
+
}
|
|
451
|
+
function createURLResolver(source, options = {}) {
|
|
452
|
+
const { label = "URL" } = options;
|
|
453
|
+
return (tag, path = "", params = {}) => {
|
|
454
|
+
const map = resolveURLMap(source) ?? {};
|
|
455
|
+
const base = map[tag];
|
|
456
|
+
if (!base) {
|
|
457
|
+
throw new ConfiguratorError(`${label} not configured for tag: ${tag}`);
|
|
458
|
+
}
|
|
459
|
+
return buildURL(base, path, params);
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
function getAllowedOrigins(options = {}) {
|
|
463
|
+
const {
|
|
464
|
+
urls = [],
|
|
465
|
+
maps = [],
|
|
466
|
+
includeCurrentOrigin = true,
|
|
467
|
+
currentOrigin = getBrowserOrigin()
|
|
468
|
+
} = options;
|
|
469
|
+
const origins = /* @__PURE__ */ new Set();
|
|
470
|
+
if (includeCurrentOrigin && currentOrigin) {
|
|
471
|
+
origins.add(currentOrigin);
|
|
472
|
+
}
|
|
473
|
+
urls.forEach((url) => {
|
|
474
|
+
origins.add(new URL(assertAbsoluteURL(url)).origin);
|
|
475
|
+
});
|
|
476
|
+
maps.forEach((map) => {
|
|
477
|
+
Object.values(map ?? {}).forEach((url) => {
|
|
478
|
+
origins.add(new URL(assertAbsoluteURL(url)).origin);
|
|
479
|
+
});
|
|
480
|
+
});
|
|
481
|
+
return Array.from(origins);
|
|
482
|
+
}
|
|
483
|
+
function getSafeRedirect(options = {}) {
|
|
484
|
+
const {
|
|
485
|
+
redirectUri,
|
|
486
|
+
fallback = "/",
|
|
487
|
+
allowedOrigins = [],
|
|
488
|
+
currentOrigin = getBrowserOrigin(),
|
|
489
|
+
allowedProtocols = ["http:", "https:"]
|
|
490
|
+
} = options;
|
|
491
|
+
try {
|
|
492
|
+
if (!redirectUri) {
|
|
493
|
+
return fallback;
|
|
494
|
+
}
|
|
495
|
+
const url = new URL(redirectUri, currentOrigin || fallback);
|
|
496
|
+
if (!allowedProtocols.includes(url.protocol)) {
|
|
497
|
+
return fallback;
|
|
498
|
+
}
|
|
499
|
+
const allowed = new Set(allowedOrigins);
|
|
500
|
+
if (currentOrigin) {
|
|
501
|
+
allowed.add(currentOrigin);
|
|
502
|
+
}
|
|
503
|
+
if (!allowed.has(url.origin)) {
|
|
504
|
+
return fallback;
|
|
505
|
+
}
|
|
506
|
+
return url.toString();
|
|
507
|
+
} catch {
|
|
508
|
+
return fallback;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
191
511
|
var EUIContext = React3.createContext(null);
|
|
192
512
|
var EUIProvider = ({
|
|
193
513
|
config,
|
|
@@ -5300,7 +5620,7 @@ var ShapeSwitch = () => {
|
|
|
5300
5620
|
{
|
|
5301
5621
|
value: currentShape,
|
|
5302
5622
|
onChange: handleChange,
|
|
5303
|
-
className: "\n px-3 py-2 rounded-md border border-gray-300\n bg-white dark:bg-gray-800\n text-sm shadow-sm\n focus:outline-none\n ",
|
|
5623
|
+
className: "\r\n px-3 py-2 rounded-md border border-gray-300\r\n bg-white dark:bg-gray-800\r\n text-sm shadow-sm\r\n focus:outline-none\r\n ",
|
|
5304
5624
|
children: Object.keys(Shape).map((shape) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: shape, children: shape }, shape))
|
|
5305
5625
|
}
|
|
5306
5626
|
) });
|
|
@@ -18294,7 +18614,7 @@ function MarkdownTOC({ title = "Table of Contents" }) {
|
|
|
18294
18614
|
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
18295
18615
|
"h2",
|
|
18296
18616
|
{
|
|
18297
|
-
className: "\n text-sm\n font-semibold\n uppercase\n tracking-wide\n text-gray-900\n dark:text-gray-100\n ",
|
|
18617
|
+
className: "\r\n text-sm\r\n font-semibold\r\n uppercase\r\n tracking-wide\r\n text-gray-900\r\n dark:text-gray-100\r\n ",
|
|
18298
18618
|
children: title
|
|
18299
18619
|
}
|
|
18300
18620
|
) }),
|
|
@@ -19624,7 +19944,7 @@ var GlowWrapper = ({
|
|
|
19624
19944
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
19625
19945
|
"span",
|
|
19626
19946
|
{
|
|
19627
|
-
className: "\n pointer-events-none absolute inset-0 opacity-0 \n group-hover:opacity-100 transition-opacity duration-300\n ",
|
|
19947
|
+
className: "\r\n pointer-events-none absolute inset-0 opacity-0 \r\n group-hover:opacity-100 transition-opacity duration-300\r\n ",
|
|
19628
19948
|
style: { background: "var(--glow-bg)" }
|
|
19629
19949
|
}
|
|
19630
19950
|
),
|
|
@@ -21326,6 +21646,8 @@ exports.CloudinaryProvider = CloudinaryProvider;
|
|
|
21326
21646
|
exports.CloudinaryVideo = CloudinaryVideo_default;
|
|
21327
21647
|
exports.Code = Code;
|
|
21328
21648
|
exports.CommentThread = CommentThread_default;
|
|
21649
|
+
exports.Configurator = Configurator;
|
|
21650
|
+
exports.ConfiguratorError = ConfiguratorError;
|
|
21329
21651
|
exports.Content = Content;
|
|
21330
21652
|
exports.ContentArea = ContentArea_default;
|
|
21331
21653
|
exports.DEFAULT_GRAPH_THEME = DEFAULT_GRAPH_THEME;
|
|
@@ -21479,15 +21801,25 @@ exports.WorldMapCountryTable = WorldMapCountryTable;
|
|
|
21479
21801
|
exports.YoutubeVideoPlayer = YoutubeVideo_default;
|
|
21480
21802
|
exports.addReplyToCache = addReplyToCache;
|
|
21481
21803
|
exports.applyReactionState = applyReactionState;
|
|
21804
|
+
exports.assertAbsoluteURL = assertAbsoluteURL;
|
|
21805
|
+
exports.buildURL = buildURL;
|
|
21482
21806
|
exports.cn = cn;
|
|
21807
|
+
exports.createConfigurator = createConfigurator;
|
|
21483
21808
|
exports.createInitialGraphState = createInitialGraphState;
|
|
21809
|
+
exports.createURLResolver = createURLResolver;
|
|
21484
21810
|
exports.decrementReplyCount = decrementReplyCount;
|
|
21485
21811
|
exports.enumValues = enumValues;
|
|
21486
21812
|
exports.formatCommentDate = formatCommentDate;
|
|
21813
|
+
exports.formatConfigError = formatConfigError;
|
|
21487
21814
|
exports.formatGraphValue = formatGraphValue;
|
|
21815
|
+
exports.getAllowedOrigins = getAllowedOrigins;
|
|
21816
|
+
exports.getBrowserHref = getBrowserHref;
|
|
21817
|
+
exports.getBrowserOrigin = getBrowserOrigin;
|
|
21818
|
+
exports.getBrowserRedirectURL = getBrowserRedirectURL;
|
|
21488
21819
|
exports.getCurrencySymbol = getCurrencySymbol;
|
|
21489
21820
|
exports.getOptimisticDislikeState = getOptimisticDislikeState;
|
|
21490
21821
|
exports.getOptimisticLikeState = getOptimisticLikeState;
|
|
21822
|
+
exports.getSafeRedirect = getSafeRedirect;
|
|
21491
21823
|
exports.graphReducer = graphReducer;
|
|
21492
21824
|
exports.incrementReplyCount = incrementReplyCount;
|
|
21493
21825
|
exports.isMatch = isMatch;
|
|
@@ -21496,6 +21828,9 @@ exports.limitRealtimePoints = limitRealtimePoints;
|
|
|
21496
21828
|
exports.normalize = normalize;
|
|
21497
21829
|
exports.normalizeGraphData = normalizeGraphData;
|
|
21498
21830
|
exports.normalizeGraphDataPoint = normalizeGraphDataPoint;
|
|
21831
|
+
exports.parseJson = parseJson;
|
|
21832
|
+
exports.parseJsonRecord = parseJsonRecord;
|
|
21833
|
+
exports.parseUrlMap = parseUrlMap;
|
|
21499
21834
|
exports.removeComment = removeComment;
|
|
21500
21835
|
exports.removeCommentTreeFromCache = removeCommentTreeFromCache;
|
|
21501
21836
|
exports.replaceRealtimePoints = replaceRealtimePoints;
|
|
@@ -21504,6 +21839,7 @@ exports.resolveGraphColor = resolveGraphColor;
|
|
|
21504
21839
|
exports.resolveGraphColors = resolveGraphColors;
|
|
21505
21840
|
exports.resolveWithGlobal = resolveWithGlobal;
|
|
21506
21841
|
exports.sendToast = sendToast;
|
|
21842
|
+
exports.toConfiguratorError = toConfiguratorError;
|
|
21507
21843
|
exports.updateComment = updateComment;
|
|
21508
21844
|
exports.updateReplyCacheComment = updateReplyCacheComment;
|
|
21509
21845
|
exports.useClickOutside = useClickOutside;
|