@eztrak/shared 0.16.5 → 0.17.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 +119 -3
- package/dist/{chunk-EIX5CUQF.mjs → chunk-A5BBQ7X5.mjs} +224 -20
- package/dist/chunk-A5BBQ7X5.mjs.map +1 -0
- package/dist/{chunk-WZVYTP6G.mjs → chunk-HAW3AKJP.mjs} +2 -2
- package/dist/{chunk-S7ZLXOPF.mjs → chunk-KJWCRX6F.mjs} +150 -51
- package/dist/chunk-KJWCRX6F.mjs.map +1 -0
- package/dist/components/index.d.mts +10 -2
- package/dist/components/index.d.ts +10 -2
- package/dist/components/index.js +357 -58
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +2 -2
- package/dist/{handleApiError-CwVIJOqO.d.mts → handleApiError-SHMjCJHj.d.mts} +25 -1
- package/dist/{handleApiError-CwVIJOqO.d.ts → handleApiError-SHMjCJHj.d.ts} +25 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +359 -58
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -3
- package/dist/utils/index.d.mts +2 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +224 -19
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +4 -2
- package/package.json +1 -1
- package/dist/chunk-EIX5CUQF.mjs.map +0 -1
- package/dist/chunk-S7ZLXOPF.mjs.map +0 -1
- /package/dist/{chunk-WZVYTP6G.mjs.map → chunk-HAW3AKJP.mjs.map} +0 -0
package/dist/components/index.js
CHANGED
|
@@ -318,7 +318,138 @@ function classifyError(error) {
|
|
|
318
318
|
};
|
|
319
319
|
}
|
|
320
320
|
var BRAND_ORANGE = "#FF7335";
|
|
321
|
-
var
|
|
321
|
+
var DANGER_RED = "#DC2626";
|
|
322
|
+
var DANGER_ICON_BG = "#FEE2E2";
|
|
323
|
+
var CANCEL_BG = "#ffffff";
|
|
324
|
+
var CANCEL_TEXT = "#374151";
|
|
325
|
+
var CONFIRM_STYLE_ID = "eztrak-confirm-alert-styles";
|
|
326
|
+
function cssSize(value, fallback) {
|
|
327
|
+
if (value === void 0) return fallback;
|
|
328
|
+
return typeof value === "number" ? `${value}px` : value;
|
|
329
|
+
}
|
|
330
|
+
var DEFAULT_CONFIRM_ICONS = {
|
|
331
|
+
warning: `
|
|
332
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
333
|
+
<path d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z" />
|
|
334
|
+
</svg>
|
|
335
|
+
`.trim()
|
|
336
|
+
};
|
|
337
|
+
var VARIANT_DEFAULTS = {
|
|
338
|
+
brand: {
|
|
339
|
+
confirmButtonText: "Yes",
|
|
340
|
+
confirmButtonColor: BRAND_ORANGE,
|
|
341
|
+
confirmButtonTextColor: "#ffffff",
|
|
342
|
+
cancelButtonColor: CANCEL_BG,
|
|
343
|
+
cancelButtonTextColor: CANCEL_TEXT,
|
|
344
|
+
iconColor: BRAND_ORANGE,
|
|
345
|
+
iconBgColor: "#FFEDD5",
|
|
346
|
+
iconHtml: DEFAULT_CONFIRM_ICONS.warning,
|
|
347
|
+
icon: "warning"
|
|
348
|
+
},
|
|
349
|
+
danger: {
|
|
350
|
+
title: "Delete this item",
|
|
351
|
+
confirmButtonText: "Yes, delete it!",
|
|
352
|
+
confirmButtonColor: DANGER_RED,
|
|
353
|
+
confirmButtonTextColor: "#ffffff",
|
|
354
|
+
cancelButtonColor: CANCEL_BG,
|
|
355
|
+
cancelButtonTextColor: CANCEL_TEXT,
|
|
356
|
+
iconColor: DANGER_RED,
|
|
357
|
+
iconBgColor: DANGER_ICON_BG,
|
|
358
|
+
iconHtml: DEFAULT_CONFIRM_ICONS.warning,
|
|
359
|
+
icon: "warning",
|
|
360
|
+
showLoaderOnConfirm: true
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
function ensureConfirmAlertStyles() {
|
|
364
|
+
if (typeof document === "undefined") return;
|
|
365
|
+
if (document.getElementById(CONFIRM_STYLE_ID)) return;
|
|
366
|
+
const style = document.createElement("style");
|
|
367
|
+
style.id = CONFIRM_STYLE_ID;
|
|
368
|
+
style.textContent = `
|
|
369
|
+
.ez-confirm-popup {
|
|
370
|
+
border-radius: var(--ez-confirm-radius, 1rem) !important;
|
|
371
|
+
padding: 1.5rem !important;
|
|
372
|
+
max-width: 24rem !important;
|
|
373
|
+
width: var(--ez-confirm-width, 100%) !important;
|
|
374
|
+
box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25) !important;
|
|
375
|
+
}
|
|
376
|
+
.ez-confirm-title {
|
|
377
|
+
font-size: 1.125rem !important;
|
|
378
|
+
font-weight: 600 !important;
|
|
379
|
+
color: #111827 !important;
|
|
380
|
+
margin: 0 0 0.25rem !important;
|
|
381
|
+
padding: 0 !important;
|
|
382
|
+
}
|
|
383
|
+
.ez-confirm-html {
|
|
384
|
+
font-size: 0.875rem !important;
|
|
385
|
+
color: #6b7280 !important;
|
|
386
|
+
margin: 0 0 1.5rem !important;
|
|
387
|
+
}
|
|
388
|
+
.ez-confirm-icon {
|
|
389
|
+
border: none !important;
|
|
390
|
+
background: var(--ez-confirm-icon-bg, #fee2e2) !important;
|
|
391
|
+
color: var(--ez-confirm-icon-color, #dc2626) !important;
|
|
392
|
+
width: 3rem !important;
|
|
393
|
+
height: 3rem !important;
|
|
394
|
+
margin: 0 auto 1rem !important;
|
|
395
|
+
border-radius: 9999px !important;
|
|
396
|
+
}
|
|
397
|
+
.ez-confirm-icon .swal2-icon-content {
|
|
398
|
+
font-size: inherit !important;
|
|
399
|
+
display: flex !important;
|
|
400
|
+
align-items: center !important;
|
|
401
|
+
justify-content: center !important;
|
|
402
|
+
color: inherit !important;
|
|
403
|
+
}
|
|
404
|
+
.ez-confirm-actions {
|
|
405
|
+
width: 100% !important;
|
|
406
|
+
margin: 0 !important;
|
|
407
|
+
gap: 0.75rem !important;
|
|
408
|
+
}
|
|
409
|
+
.ez-confirm-confirm,
|
|
410
|
+
.ez-confirm-cancel {
|
|
411
|
+
flex: 1 1 0 !important;
|
|
412
|
+
margin: 0 !important;
|
|
413
|
+
border-radius: var(--ez-confirm-btn-radius, 0.5rem) !important;
|
|
414
|
+
font-size: 0.875rem !important;
|
|
415
|
+
font-weight: 500 !important;
|
|
416
|
+
padding: 0.625rem 1rem !important;
|
|
417
|
+
box-shadow: none !important;
|
|
418
|
+
}
|
|
419
|
+
.ez-confirm-confirm {
|
|
420
|
+
background: var(--ez-confirm-confirm-bg, #ff7335) !important;
|
|
421
|
+
color: var(--ez-confirm-confirm-fg, #fff) !important;
|
|
422
|
+
border: none !important;
|
|
423
|
+
}
|
|
424
|
+
.ez-confirm-confirm:hover {
|
|
425
|
+
filter: brightness(0.95);
|
|
426
|
+
}
|
|
427
|
+
.ez-confirm-cancel {
|
|
428
|
+
background: var(--ez-confirm-cancel-bg, #fff) !important;
|
|
429
|
+
color: var(--ez-confirm-cancel-fg, #374151) !important;
|
|
430
|
+
border: 1px solid #d1d5db !important;
|
|
431
|
+
}
|
|
432
|
+
.ez-confirm-cancel:hover {
|
|
433
|
+
background: #f9fafb !important;
|
|
434
|
+
}
|
|
435
|
+
`;
|
|
436
|
+
document.head.appendChild(style);
|
|
437
|
+
}
|
|
438
|
+
function pick(explicit, fromVariant, fallback) {
|
|
439
|
+
if (explicit !== void 0) return explicit;
|
|
440
|
+
if (fromVariant !== void 0) return fromVariant;
|
|
441
|
+
return fallback;
|
|
442
|
+
}
|
|
443
|
+
function mergeCustomClass(base, extra) {
|
|
444
|
+
if (!extra || typeof extra !== "object") return base;
|
|
445
|
+
const merged = { ...base };
|
|
446
|
+
for (const [key, value] of Object.entries(extra)) {
|
|
447
|
+
if (typeof value === "string" && value) {
|
|
448
|
+
merged[key] = merged[key] ? `${merged[key]} ${value}` : value;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
return merged;
|
|
452
|
+
}
|
|
322
453
|
function getConfirmErrorMessage(error) {
|
|
323
454
|
if (error && typeof error === "object") {
|
|
324
455
|
const err = error;
|
|
@@ -327,23 +458,59 @@ function getConfirmErrorMessage(error) {
|
|
|
327
458
|
return "Something went wrong. Please try again.";
|
|
328
459
|
}
|
|
329
460
|
function confirmationAlert(onConfirm, options = {}) {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
icon = "warning",
|
|
335
|
-
confirmButtonText = "Yes",
|
|
336
|
-
cancelButtonText = "Cancel",
|
|
337
|
-
confirmButtonColor = BRAND_ORANGE,
|
|
338
|
-
cancelButtonColor = CANCEL_RED,
|
|
339
|
-
showLoaderOnConfirm = false,
|
|
340
|
-
inputExpectedValue,
|
|
341
|
-
inputPlaceholder = "Type confirmation text to proceed",
|
|
342
|
-
reverseButtons,
|
|
343
|
-
focusCancel,
|
|
344
|
-
zIndex
|
|
345
|
-
} = options;
|
|
461
|
+
ensureConfirmAlertStyles();
|
|
462
|
+
const variant = options.variant ?? "brand";
|
|
463
|
+
const vd = VARIANT_DEFAULTS[variant];
|
|
464
|
+
const inputExpectedValue = options.inputExpectedValue;
|
|
346
465
|
const hasInput = Boolean(inputExpectedValue);
|
|
466
|
+
const title = pick(
|
|
467
|
+
options.title,
|
|
468
|
+
vd.title,
|
|
469
|
+
hasInput ? "Confirmation Required" : "Delete this item"
|
|
470
|
+
);
|
|
471
|
+
const text = options.text;
|
|
472
|
+
const html = options.html;
|
|
473
|
+
const icon = pick(options.icon, vd.icon, "warning");
|
|
474
|
+
const iconHtml = pick(options.iconHtml, vd.iconHtml, void 0);
|
|
475
|
+
const iconColor = pick(options.iconColor, vd.iconColor, BRAND_ORANGE);
|
|
476
|
+
const iconBgColor = pick(options.iconBgColor, vd.iconBgColor, "#FFEDD5");
|
|
477
|
+
const showIcon = options.showIcon !== false;
|
|
478
|
+
const confirmButtonText = pick(options.confirmButtonText, vd.confirmButtonText, "Yes");
|
|
479
|
+
const cancelButtonText = options.cancelButtonText ?? "Cancel";
|
|
480
|
+
const confirmButtonColor = pick(
|
|
481
|
+
options.confirmButtonColor,
|
|
482
|
+
vd.confirmButtonColor,
|
|
483
|
+
BRAND_ORANGE
|
|
484
|
+
);
|
|
485
|
+
const cancelButtonColor = pick(
|
|
486
|
+
options.cancelButtonColor,
|
|
487
|
+
vd.cancelButtonColor,
|
|
488
|
+
CANCEL_BG
|
|
489
|
+
);
|
|
490
|
+
const confirmButtonTextColor = pick(
|
|
491
|
+
options.confirmButtonTextColor,
|
|
492
|
+
vd.confirmButtonTextColor,
|
|
493
|
+
"#ffffff"
|
|
494
|
+
);
|
|
495
|
+
const cancelButtonTextColor = pick(
|
|
496
|
+
options.cancelButtonTextColor,
|
|
497
|
+
vd.cancelButtonTextColor,
|
|
498
|
+
CANCEL_TEXT
|
|
499
|
+
);
|
|
500
|
+
const showCancelButton = options.showCancelButton !== false;
|
|
501
|
+
const showLoaderOnConfirm = pick(
|
|
502
|
+
options.showLoaderOnConfirm,
|
|
503
|
+
vd.showLoaderOnConfirm,
|
|
504
|
+
false
|
|
505
|
+
);
|
|
506
|
+
const inputPlaceholder = options.inputPlaceholder ?? "Type confirmation text to proceed";
|
|
507
|
+
const reverseButtons = options.reverseButtons ?? false;
|
|
508
|
+
const focusCancel = options.focusCancel;
|
|
509
|
+
const zIndex = options.zIndex;
|
|
510
|
+
const width = options.width;
|
|
511
|
+
const borderRadius = cssSize(options.borderRadius, "1rem");
|
|
512
|
+
const buttonBorderRadius = cssSize(options.buttonBorderRadius, "0.5rem");
|
|
513
|
+
const onCancel = options.onCancel;
|
|
347
514
|
const useLoader = showLoaderOnConfirm || hasInput;
|
|
348
515
|
const inputHtml = html ?? (hasInput ? `
|
|
349
516
|
${text ? `<p style="margin-bottom: 15px;">${text}</p>` : ""}
|
|
@@ -351,24 +518,56 @@ function confirmationAlert(onConfirm, options = {}) {
|
|
|
351
518
|
Please type "<span style="color: ${BRAND_ORANGE}; font-weight: bold;">${inputExpectedValue}</span>" to confirm:
|
|
352
519
|
</p>
|
|
353
520
|
` : void 0);
|
|
521
|
+
const baseCustomClass = {
|
|
522
|
+
popup: "ez-confirm-popup",
|
|
523
|
+
title: "ez-confirm-title",
|
|
524
|
+
htmlContainer: "ez-confirm-html",
|
|
525
|
+
actions: "ez-confirm-actions",
|
|
526
|
+
confirmButton: "ez-confirm-confirm",
|
|
527
|
+
cancelButton: "ez-confirm-cancel",
|
|
528
|
+
icon: "ez-confirm-icon"
|
|
529
|
+
};
|
|
354
530
|
const swalOptions = {
|
|
355
531
|
title,
|
|
356
|
-
|
|
357
|
-
showCancelButton: true,
|
|
532
|
+
showCancelButton,
|
|
358
533
|
confirmButtonText,
|
|
359
534
|
cancelButtonText,
|
|
360
535
|
confirmButtonColor,
|
|
361
536
|
cancelButtonColor,
|
|
362
537
|
reverseButtons,
|
|
363
538
|
focusCancel,
|
|
539
|
+
customClass: mergeCustomClass(baseCustomClass, options.customClass),
|
|
364
540
|
allowOutsideClick: () => !import_sweetalert2.default.isLoading(),
|
|
365
541
|
allowEscapeKey: () => !import_sweetalert2.default.isLoading(),
|
|
366
542
|
didOpen: () => {
|
|
543
|
+
const popup = import_sweetalert2.default.getPopup();
|
|
544
|
+
if (popup) {
|
|
545
|
+
popup.style.setProperty("--ez-confirm-confirm-bg", confirmButtonColor);
|
|
546
|
+
popup.style.setProperty("--ez-confirm-confirm-fg", confirmButtonTextColor);
|
|
547
|
+
popup.style.setProperty("--ez-confirm-cancel-bg", cancelButtonColor);
|
|
548
|
+
popup.style.setProperty("--ez-confirm-cancel-fg", cancelButtonTextColor);
|
|
549
|
+
popup.style.setProperty("--ez-confirm-icon-color", iconColor);
|
|
550
|
+
popup.style.setProperty("--ez-confirm-icon-bg", iconBgColor);
|
|
551
|
+
popup.style.setProperty("--ez-confirm-radius", borderRadius);
|
|
552
|
+
popup.style.setProperty("--ez-confirm-btn-radius", buttonBorderRadius);
|
|
553
|
+
if (width != null) {
|
|
554
|
+
popup.style.setProperty(
|
|
555
|
+
"--ez-confirm-width",
|
|
556
|
+
typeof width === "number" ? `${width}px` : String(width)
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
367
560
|
if (zIndex == null) return;
|
|
368
561
|
const container = import_sweetalert2.default.getContainer();
|
|
369
562
|
if (container) container.style.zIndex = String(zIndex);
|
|
370
563
|
}
|
|
371
564
|
};
|
|
565
|
+
if (showIcon) {
|
|
566
|
+
swalOptions.icon = icon;
|
|
567
|
+
if (iconHtml) {
|
|
568
|
+
swalOptions.iconHtml = iconHtml;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
372
571
|
if (hasInput) {
|
|
373
572
|
swalOptions.html = inputHtml;
|
|
374
573
|
swalOptions.input = "text";
|
|
@@ -403,6 +602,10 @@ function confirmationAlert(onConfirm, options = {}) {
|
|
|
403
602
|
void import_sweetalert2.default.fire(swalOptions).then((result) => {
|
|
404
603
|
if (result.isConfirmed && !useLoader) {
|
|
405
604
|
void Promise.resolve(onConfirm());
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
if (result.isDismissed) {
|
|
608
|
+
onCancel?.();
|
|
406
609
|
}
|
|
407
610
|
});
|
|
408
611
|
}
|
|
@@ -1411,7 +1614,35 @@ function Header({
|
|
|
1411
1614
|
var import_react6 = require("react");
|
|
1412
1615
|
var import_react_router_dom5 = require("react-router-dom");
|
|
1413
1616
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1414
|
-
var
|
|
1617
|
+
var DEFAULT_BACKGROUND = "#F7F7F5";
|
|
1618
|
+
var DEFAULT_INACTIVE = "#6B7280";
|
|
1619
|
+
var DEFAULT_ACTIVE = "#111111";
|
|
1620
|
+
var DEFAULT_SEPARATOR = "#9CA3AF";
|
|
1621
|
+
var CRUMB_LAYOUT = "inline-flex items-center gap-1.5 whitespace-nowrap leading-5 rounded-sm";
|
|
1622
|
+
var LINK_INTERACTION = "font-normal transition-colors duration-200 motion-reduce:transition-none hover:!text-[color-mix(in_srgb,var(--bc-inactive)_65%,#111111)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#111111]";
|
|
1623
|
+
function BreadcrumbChevron() {
|
|
1624
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1625
|
+
"svg",
|
|
1626
|
+
{
|
|
1627
|
+
width: "12",
|
|
1628
|
+
height: "12",
|
|
1629
|
+
viewBox: "0 0 12 12",
|
|
1630
|
+
fill: "none",
|
|
1631
|
+
"aria-hidden": "true",
|
|
1632
|
+
className: "shrink-0",
|
|
1633
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1634
|
+
"path",
|
|
1635
|
+
{
|
|
1636
|
+
d: "M4.5 2.5L8 6L4.5 9.5",
|
|
1637
|
+
stroke: "currentColor",
|
|
1638
|
+
strokeWidth: "1.5",
|
|
1639
|
+
strokeLinecap: "round",
|
|
1640
|
+
strokeLinejoin: "round"
|
|
1641
|
+
}
|
|
1642
|
+
)
|
|
1643
|
+
}
|
|
1644
|
+
);
|
|
1645
|
+
}
|
|
1415
1646
|
function asTitleMap(customTitles) {
|
|
1416
1647
|
if (Object.prototype.toString.call(customTitles) !== "[object Object]") {
|
|
1417
1648
|
return {};
|
|
@@ -1441,73 +1672,141 @@ function Breadcrumbs({
|
|
|
1441
1672
|
containerClassName,
|
|
1442
1673
|
linkClassName = "",
|
|
1443
1674
|
separatorClassName = "",
|
|
1444
|
-
separator
|
|
1445
|
-
activeClassName = "font-
|
|
1675
|
+
separator,
|
|
1676
|
+
activeClassName = "font-semibold",
|
|
1446
1677
|
customTitles = {},
|
|
1447
1678
|
customIcons = {},
|
|
1448
1679
|
prefix,
|
|
1449
1680
|
suffix,
|
|
1450
|
-
nonClickablePaths = []
|
|
1681
|
+
nonClickablePaths = [],
|
|
1682
|
+
backgroundColor = DEFAULT_BACKGROUND,
|
|
1683
|
+
inactiveColor = DEFAULT_INACTIVE,
|
|
1684
|
+
activeColor = DEFAULT_ACTIVE,
|
|
1685
|
+
separatorColor = DEFAULT_SEPARATOR,
|
|
1686
|
+
iconColor,
|
|
1687
|
+
iconClassName,
|
|
1688
|
+
showHome = false
|
|
1451
1689
|
}) {
|
|
1452
1690
|
const location = (0, import_react_router_dom5.useLocation)();
|
|
1453
1691
|
const pathnames = location.pathname.split("/").filter((segment) => segment);
|
|
1454
1692
|
const titles = asTitleMap(customTitles);
|
|
1455
|
-
const inactiveLinkClassName = cn(INACTIVE_LINK_CLASS, linkClassName);
|
|
1456
1693
|
const getTitle = (pathname) => {
|
|
1457
1694
|
const match = findRoute(pathname, routes);
|
|
1458
1695
|
if (match && match.title) {
|
|
1459
1696
|
return match.title;
|
|
1460
1697
|
}
|
|
1461
|
-
const titleKeys = Object.keys(titles);
|
|
1462
|
-
const paramMatch = pathname.split("/").find((segment) => titleKeys.includes(segment)) || "";
|
|
1463
|
-
if (paramMatch && titles[paramMatch]) {
|
|
1464
|
-
return titles[paramMatch];
|
|
1465
|
-
}
|
|
1466
1698
|
const lastParamPath = getLastParam(pathname);
|
|
1699
|
+
if (lastParamPath && titles[lastParamPath]) {
|
|
1700
|
+
return titles[lastParamPath];
|
|
1701
|
+
}
|
|
1467
1702
|
if (lastParamPath) {
|
|
1468
1703
|
return lastParamPath;
|
|
1469
1704
|
}
|
|
1470
1705
|
return pathname;
|
|
1471
1706
|
};
|
|
1472
1707
|
const getIcon = (pathname) => {
|
|
1473
|
-
const
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
return customIcons[matchedSegment];
|
|
1708
|
+
const segment = getLastParam(pathname);
|
|
1709
|
+
if (segment && customIcons[segment]) {
|
|
1710
|
+
return customIcons[segment];
|
|
1477
1711
|
}
|
|
1478
1712
|
return null;
|
|
1479
1713
|
};
|
|
1714
|
+
const crumbs = [];
|
|
1715
|
+
if (showHome) {
|
|
1716
|
+
crumbs.push({
|
|
1717
|
+
key: "home",
|
|
1718
|
+
to: "/",
|
|
1719
|
+
title: titles.home || "Home",
|
|
1720
|
+
icon: customIcons.home ?? null,
|
|
1721
|
+
isCurrent: pathnames.length === 0,
|
|
1722
|
+
isLink: pathnames.length > 0
|
|
1723
|
+
});
|
|
1724
|
+
}
|
|
1725
|
+
pathnames.forEach((segment, index) => {
|
|
1726
|
+
const to = `/${pathnames.slice(0, index + 1).join("/")}`;
|
|
1727
|
+
const isCurrent = index === pathnames.length - 1;
|
|
1728
|
+
const isNonClickable = nonClickablePaths.some(
|
|
1729
|
+
(token) => to.includes(token) || segment === token
|
|
1730
|
+
);
|
|
1731
|
+
crumbs.push({
|
|
1732
|
+
key: to,
|
|
1733
|
+
to,
|
|
1734
|
+
title: getTitle(to),
|
|
1735
|
+
icon: getIcon(to),
|
|
1736
|
+
isCurrent,
|
|
1737
|
+
isLink: !isCurrent && !isNonClickable
|
|
1738
|
+
});
|
|
1739
|
+
});
|
|
1740
|
+
const navStyle = {
|
|
1741
|
+
backgroundColor,
|
|
1742
|
+
"--bc-inactive": inactiveColor
|
|
1743
|
+
};
|
|
1744
|
+
const inactiveClassName = cn(CRUMB_LAYOUT, LINK_INTERACTION, linkClassName);
|
|
1745
|
+
const staticInactiveClassName = cn(CRUMB_LAYOUT, "font-normal", linkClassName);
|
|
1746
|
+
const currentClassName = cn(CRUMB_LAYOUT, activeClassName);
|
|
1747
|
+
const renderCrumb = (crumb) => {
|
|
1748
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
1749
|
+
crumb.icon ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1750
|
+
"span",
|
|
1751
|
+
{
|
|
1752
|
+
className: cn("inline-flex shrink-0 items-center", iconClassName),
|
|
1753
|
+
style: iconColor ? { color: iconColor } : void 0,
|
|
1754
|
+
children: crumb.icon
|
|
1755
|
+
}
|
|
1756
|
+
) : null,
|
|
1757
|
+
crumb.title
|
|
1758
|
+
] });
|
|
1759
|
+
if (crumb.isCurrent) {
|
|
1760
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1761
|
+
"span",
|
|
1762
|
+
{
|
|
1763
|
+
className: currentClassName,
|
|
1764
|
+
style: { color: activeColor },
|
|
1765
|
+
"aria-current": "page",
|
|
1766
|
+
children: content
|
|
1767
|
+
}
|
|
1768
|
+
);
|
|
1769
|
+
}
|
|
1770
|
+
if (crumb.isLink) {
|
|
1771
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1772
|
+
import_react_router_dom5.Link,
|
|
1773
|
+
{
|
|
1774
|
+
to: crumb.to,
|
|
1775
|
+
className: inactiveClassName,
|
|
1776
|
+
style: { color: inactiveColor },
|
|
1777
|
+
children: content
|
|
1778
|
+
}
|
|
1779
|
+
);
|
|
1780
|
+
}
|
|
1781
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: staticInactiveClassName, style: { color: inactiveColor }, children: content });
|
|
1782
|
+
};
|
|
1480
1783
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1481
|
-
"
|
|
1784
|
+
"nav",
|
|
1482
1785
|
{
|
|
1786
|
+
"aria-label": "Breadcrumb",
|
|
1483
1787
|
className: cn(
|
|
1484
|
-
"flex flex-row gap-2
|
|
1788
|
+
"flex w-full flex-row items-center gap-2 overflow-x-auto px-4 py-3 text-sm leading-5",
|
|
1485
1789
|
containerClassName
|
|
1486
1790
|
),
|
|
1791
|
+
style: navStyle,
|
|
1487
1792
|
children: [
|
|
1488
|
-
prefix
|
|
1489
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react6.Fragment, { children: [
|
|
1506
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: separatorClassName, children: separator }),
|
|
1507
|
-
isLast || isNonClickable ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: isLast ? activeClassName : linkClassName, children: crumb }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_router_dom5.Link, { to, className: inactiveLinkClassName, children: crumb })
|
|
1508
|
-
] }, to);
|
|
1509
|
-
}),
|
|
1510
|
-
suffix && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "breadcrumb-suffix", children: suffix })
|
|
1793
|
+
prefix ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "breadcrumb-prefix", children: prefix }) : null,
|
|
1794
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("ol", { className: "flex min-w-0 flex-row flex-nowrap items-center gap-2", children: crumbs.map((crumb, index) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("li", { className: "inline-flex items-center gap-2", children: [
|
|
1795
|
+
index > 0 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1796
|
+
"span",
|
|
1797
|
+
{
|
|
1798
|
+
"aria-hidden": "true",
|
|
1799
|
+
className: cn(
|
|
1800
|
+
"inline-flex shrink-0 items-center",
|
|
1801
|
+
separatorClassName
|
|
1802
|
+
),
|
|
1803
|
+
style: { color: separatorColor },
|
|
1804
|
+
children: separator === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(BreadcrumbChevron, {}) : (0, import_react6.isValidElement)(separator) ? (0, import_react6.cloneElement)(separator) : separator
|
|
1805
|
+
}
|
|
1806
|
+
) : null,
|
|
1807
|
+
renderCrumb(crumb)
|
|
1808
|
+
] }, crumb.key)) }),
|
|
1809
|
+
suffix ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "breadcrumb-suffix", children: suffix }) : null
|
|
1511
1810
|
]
|
|
1512
1811
|
}
|
|
1513
1812
|
);
|