@eztrak/shared 0.16.3 → 0.16.6
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-S7ZLXOPF.mjs → chunk-SS3J2WBE.mjs} +149 -50
- package/dist/chunk-SS3J2WBE.mjs.map +1 -0
- package/dist/components/index.d.mts +8 -1
- package/dist/components/index.d.ts +8 -1
- package/dist/components/index.js +135 -39
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +1 -1
- package/dist/index.js +135 -39
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-S7ZLXOPF.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1839,7 +1839,35 @@ function Header({
|
|
|
1839
1839
|
var import_react8 = require("react");
|
|
1840
1840
|
var import_react_router_dom5 = require("react-router-dom");
|
|
1841
1841
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1842
|
-
var
|
|
1842
|
+
var DEFAULT_BACKGROUND = "#F7F7F5";
|
|
1843
|
+
var DEFAULT_INACTIVE = "#6B7280";
|
|
1844
|
+
var DEFAULT_ACTIVE = "#111111";
|
|
1845
|
+
var DEFAULT_SEPARATOR = "#9CA3AF";
|
|
1846
|
+
var CRUMB_LAYOUT = "inline-flex items-center gap-1.5 whitespace-nowrap leading-5 rounded-sm";
|
|
1847
|
+
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]";
|
|
1848
|
+
function BreadcrumbChevron() {
|
|
1849
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1850
|
+
"svg",
|
|
1851
|
+
{
|
|
1852
|
+
width: "12",
|
|
1853
|
+
height: "12",
|
|
1854
|
+
viewBox: "0 0 12 12",
|
|
1855
|
+
fill: "none",
|
|
1856
|
+
"aria-hidden": "true",
|
|
1857
|
+
className: "shrink-0",
|
|
1858
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1859
|
+
"path",
|
|
1860
|
+
{
|
|
1861
|
+
d: "M4.5 2.5L8 6L4.5 9.5",
|
|
1862
|
+
stroke: "currentColor",
|
|
1863
|
+
strokeWidth: "1.5",
|
|
1864
|
+
strokeLinecap: "round",
|
|
1865
|
+
strokeLinejoin: "round"
|
|
1866
|
+
}
|
|
1867
|
+
)
|
|
1868
|
+
}
|
|
1869
|
+
);
|
|
1870
|
+
}
|
|
1843
1871
|
function asTitleMap(customTitles) {
|
|
1844
1872
|
if (Object.prototype.toString.call(customTitles) !== "[object Object]") {
|
|
1845
1873
|
return {};
|
|
@@ -1869,73 +1897,141 @@ function Breadcrumbs({
|
|
|
1869
1897
|
containerClassName,
|
|
1870
1898
|
linkClassName = "",
|
|
1871
1899
|
separatorClassName = "",
|
|
1872
|
-
separator
|
|
1873
|
-
activeClassName = "font-
|
|
1900
|
+
separator,
|
|
1901
|
+
activeClassName = "font-semibold",
|
|
1874
1902
|
customTitles = {},
|
|
1875
1903
|
customIcons = {},
|
|
1876
1904
|
prefix,
|
|
1877
1905
|
suffix,
|
|
1878
|
-
nonClickablePaths = []
|
|
1906
|
+
nonClickablePaths = [],
|
|
1907
|
+
backgroundColor = DEFAULT_BACKGROUND,
|
|
1908
|
+
inactiveColor = DEFAULT_INACTIVE,
|
|
1909
|
+
activeColor = DEFAULT_ACTIVE,
|
|
1910
|
+
separatorColor = DEFAULT_SEPARATOR,
|
|
1911
|
+
iconColor,
|
|
1912
|
+
iconClassName,
|
|
1913
|
+
showHome = false
|
|
1879
1914
|
}) {
|
|
1880
1915
|
const location = (0, import_react_router_dom5.useLocation)();
|
|
1881
1916
|
const pathnames = location.pathname.split("/").filter((segment) => segment);
|
|
1882
1917
|
const titles = asTitleMap(customTitles);
|
|
1883
|
-
const inactiveLinkClassName = cn(INACTIVE_LINK_CLASS, linkClassName);
|
|
1884
1918
|
const getTitle = (pathname) => {
|
|
1885
1919
|
const match = findRoute(pathname, routes);
|
|
1886
1920
|
if (match && match.title) {
|
|
1887
1921
|
return match.title;
|
|
1888
1922
|
}
|
|
1889
|
-
const titleKeys = Object.keys(titles);
|
|
1890
|
-
const paramMatch = pathname.split("/").find((segment) => titleKeys.includes(segment)) || "";
|
|
1891
|
-
if (paramMatch && titles[paramMatch]) {
|
|
1892
|
-
return titles[paramMatch];
|
|
1893
|
-
}
|
|
1894
1923
|
const lastParamPath = getLastParam(pathname);
|
|
1924
|
+
if (lastParamPath && titles[lastParamPath]) {
|
|
1925
|
+
return titles[lastParamPath];
|
|
1926
|
+
}
|
|
1895
1927
|
if (lastParamPath) {
|
|
1896
1928
|
return lastParamPath;
|
|
1897
1929
|
}
|
|
1898
1930
|
return pathname;
|
|
1899
1931
|
};
|
|
1900
1932
|
const getIcon = (pathname) => {
|
|
1901
|
-
const
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
return customIcons[matchedSegment];
|
|
1933
|
+
const segment = getLastParam(pathname);
|
|
1934
|
+
if (segment && customIcons[segment]) {
|
|
1935
|
+
return customIcons[segment];
|
|
1905
1936
|
}
|
|
1906
1937
|
return null;
|
|
1907
1938
|
};
|
|
1939
|
+
const crumbs = [];
|
|
1940
|
+
if (showHome) {
|
|
1941
|
+
crumbs.push({
|
|
1942
|
+
key: "home",
|
|
1943
|
+
to: "/",
|
|
1944
|
+
title: titles.home || "Home",
|
|
1945
|
+
icon: customIcons.home ?? null,
|
|
1946
|
+
isCurrent: pathnames.length === 0,
|
|
1947
|
+
isLink: pathnames.length > 0
|
|
1948
|
+
});
|
|
1949
|
+
}
|
|
1950
|
+
pathnames.forEach((segment, index) => {
|
|
1951
|
+
const to = `/${pathnames.slice(0, index + 1).join("/")}`;
|
|
1952
|
+
const isCurrent = index === pathnames.length - 1;
|
|
1953
|
+
const isNonClickable = nonClickablePaths.some(
|
|
1954
|
+
(token) => to.includes(token) || segment === token
|
|
1955
|
+
);
|
|
1956
|
+
crumbs.push({
|
|
1957
|
+
key: to,
|
|
1958
|
+
to,
|
|
1959
|
+
title: getTitle(to),
|
|
1960
|
+
icon: getIcon(to),
|
|
1961
|
+
isCurrent,
|
|
1962
|
+
isLink: !isCurrent && !isNonClickable
|
|
1963
|
+
});
|
|
1964
|
+
});
|
|
1965
|
+
const navStyle = {
|
|
1966
|
+
backgroundColor,
|
|
1967
|
+
"--bc-inactive": inactiveColor
|
|
1968
|
+
};
|
|
1969
|
+
const inactiveClassName = cn(CRUMB_LAYOUT, LINK_INTERACTION, linkClassName);
|
|
1970
|
+
const staticInactiveClassName = cn(CRUMB_LAYOUT, "font-normal", linkClassName);
|
|
1971
|
+
const currentClassName = cn(CRUMB_LAYOUT, activeClassName);
|
|
1972
|
+
const renderCrumb = (crumb) => {
|
|
1973
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
1974
|
+
crumb.icon ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1975
|
+
"span",
|
|
1976
|
+
{
|
|
1977
|
+
className: cn("inline-flex shrink-0 items-center", iconClassName),
|
|
1978
|
+
style: iconColor ? { color: iconColor } : void 0,
|
|
1979
|
+
children: crumb.icon
|
|
1980
|
+
}
|
|
1981
|
+
) : null,
|
|
1982
|
+
crumb.title
|
|
1983
|
+
] });
|
|
1984
|
+
if (crumb.isCurrent) {
|
|
1985
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1986
|
+
"span",
|
|
1987
|
+
{
|
|
1988
|
+
className: currentClassName,
|
|
1989
|
+
style: { color: activeColor },
|
|
1990
|
+
"aria-current": "page",
|
|
1991
|
+
children: content
|
|
1992
|
+
}
|
|
1993
|
+
);
|
|
1994
|
+
}
|
|
1995
|
+
if (crumb.isLink) {
|
|
1996
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1997
|
+
import_react_router_dom5.Link,
|
|
1998
|
+
{
|
|
1999
|
+
to: crumb.to,
|
|
2000
|
+
className: inactiveClassName,
|
|
2001
|
+
style: { color: inactiveColor },
|
|
2002
|
+
children: content
|
|
2003
|
+
}
|
|
2004
|
+
);
|
|
2005
|
+
}
|
|
2006
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: staticInactiveClassName, style: { color: inactiveColor }, children: content });
|
|
2007
|
+
};
|
|
1908
2008
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1909
|
-
"
|
|
2009
|
+
"nav",
|
|
1910
2010
|
{
|
|
2011
|
+
"aria-label": "Breadcrumb",
|
|
1911
2012
|
className: cn(
|
|
1912
|
-
"flex flex-row gap-2
|
|
2013
|
+
"flex w-full flex-row items-center gap-2 overflow-x-auto px-4 py-3 text-sm leading-5",
|
|
1913
2014
|
containerClassName
|
|
1914
2015
|
),
|
|
2016
|
+
style: navStyle,
|
|
1915
2017
|
children: [
|
|
1916
|
-
prefix
|
|
1917
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react8.Fragment, { children: [
|
|
1934
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: separatorClassName, children: separator }),
|
|
1935
|
-
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 })
|
|
1936
|
-
] }, to);
|
|
1937
|
-
}),
|
|
1938
|
-
suffix && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "breadcrumb-suffix", children: suffix })
|
|
2018
|
+
prefix ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "breadcrumb-prefix", children: prefix }) : null,
|
|
2019
|
+
/* @__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: [
|
|
2020
|
+
index > 0 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2021
|
+
"span",
|
|
2022
|
+
{
|
|
2023
|
+
"aria-hidden": "true",
|
|
2024
|
+
className: cn(
|
|
2025
|
+
"inline-flex shrink-0 items-center",
|
|
2026
|
+
separatorClassName
|
|
2027
|
+
),
|
|
2028
|
+
style: { color: separatorColor },
|
|
2029
|
+
children: separator === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(BreadcrumbChevron, {}) : (0, import_react8.isValidElement)(separator) ? (0, import_react8.cloneElement)(separator) : separator
|
|
2030
|
+
}
|
|
2031
|
+
) : null,
|
|
2032
|
+
renderCrumb(crumb)
|
|
2033
|
+
] }, crumb.key)) }),
|
|
2034
|
+
suffix ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "breadcrumb-suffix", children: suffix }) : null
|
|
1939
2035
|
]
|
|
1940
2036
|
}
|
|
1941
2037
|
);
|