@bolttech/ob-atoms-breadcrumbs 1.0.1 → 1.0.2
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/index.cjs.js +59 -81
- package/package.json +1 -1
- package/src/index.d.ts +1 -0
- package/src/lib/breadcrumbs.d.ts +3 -0
- package/src/lib/breadcrumbs.interface.d.ts +25 -0
- package/src/lib/breadcrumbs.stories.d.ts +24 -0
package/index.cjs.js
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
3
4
|
var react = require('react');
|
|
4
5
|
var uiUtils = require('@bolttech/ui-utils');
|
|
5
6
|
var obAtomsIcon = require('@bolttech/ob-atoms-icon');
|
|
6
|
-
var jsxDevRuntime = require('react/jsx-dev-runtime');
|
|
7
|
-
|
|
8
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
9
|
-
if (null == r) return {};
|
|
10
|
-
var t = {};
|
|
11
|
-
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
12
|
-
if (-1 !== e.indexOf(n)) continue;
|
|
13
|
-
t[n] = r[n];
|
|
14
|
-
}
|
|
15
|
-
return t;
|
|
16
|
-
}
|
|
17
7
|
|
|
18
8
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
19
9
|
|
|
@@ -1963,16 +1953,48 @@ for (var COLLECTION_NAME in DOMIterables) {
|
|
|
1963
1953
|
|
|
1964
1954
|
handlePrototype(DOMTokenListPrototype, 'DOMTokenList');
|
|
1965
1955
|
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1956
|
+
/******************************************************************************
|
|
1957
|
+
Copyright (c) Microsoft Corporation.
|
|
1958
|
+
|
|
1959
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
1960
|
+
purpose with or without fee is hereby granted.
|
|
1961
|
+
|
|
1962
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1963
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1964
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1965
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1966
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1967
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1968
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
1969
|
+
***************************************************************************** */
|
|
1970
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
1971
|
+
|
|
1972
|
+
|
|
1973
|
+
function __rest(s, e) {
|
|
1974
|
+
var t = {};
|
|
1975
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
1976
|
+
t[p] = s[p];
|
|
1977
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
1978
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
1979
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
1980
|
+
t[p[i]] = s[p[i]];
|
|
1981
|
+
}
|
|
1982
|
+
return t;
|
|
1983
|
+
}
|
|
1984
|
+
|
|
1985
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
1986
|
+
var e = new Error(message);
|
|
1987
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1988
|
+
};
|
|
1989
|
+
|
|
1990
|
+
const Breadcrumbs = /*#__PURE__*/react.forwardRef((_a, ref) => {
|
|
1991
|
+
var {
|
|
1970
1992
|
id = 'breadcrumbs-id',
|
|
1971
1993
|
dataTestId = 'breadcrumbs-data-testid',
|
|
1972
1994
|
items,
|
|
1973
1995
|
ariaLabel = 'Show complete navigation.'
|
|
1974
|
-
} =
|
|
1975
|
-
props =
|
|
1996
|
+
} = _a,
|
|
1997
|
+
props = __rest(_a, ["id", "dataTestId", "items", "ariaLabel"]);
|
|
1976
1998
|
const [expanded, setExpanded] = react.useState(false);
|
|
1977
1999
|
const shouldShrink = items.length > 5;
|
|
1978
2000
|
const filteredItems = react.useMemo(() => {
|
|
@@ -1987,54 +2009,34 @@ const Breadcrumbs = /*#__PURE__*/react.forwardRef((_ref, ref) => {
|
|
|
1987
2009
|
return filteredItems.map((item, index) => {
|
|
1988
2010
|
// Last item
|
|
1989
2011
|
if (index === items.length - 1 || shouldShrink && index === filteredItems.length - 1) {
|
|
1990
|
-
return
|
|
2012
|
+
return jsxRuntime.jsx("li", {
|
|
1991
2013
|
className: "flex items-center",
|
|
1992
2014
|
"aria-current": "page",
|
|
1993
2015
|
children: item.label
|
|
1994
|
-
}, index
|
|
1995
|
-
fileName: _jsxFileName,
|
|
1996
|
-
lineNumber: 39,
|
|
1997
|
-
columnNumber: 13
|
|
1998
|
-
}, undefined);
|
|
2016
|
+
}, index);
|
|
1999
2017
|
}
|
|
2000
2018
|
if (shouldShrink && index === 1) {
|
|
2001
|
-
return [
|
|
2019
|
+
return [jsxRuntime.jsx("li", {
|
|
2002
2020
|
className: "flex items-center",
|
|
2003
|
-
children:
|
|
2021
|
+
children: jsxRuntime.jsx("button", {
|
|
2004
2022
|
type: "button",
|
|
2005
2023
|
className: "cursor-pointer",
|
|
2006
2024
|
onClick: item.onClick,
|
|
2007
2025
|
"aria-expanded": "false",
|
|
2008
2026
|
"aria-label": ariaLabel,
|
|
2009
2027
|
children: item.label
|
|
2010
|
-
}
|
|
2011
|
-
|
|
2012
|
-
lineNumber: 48,
|
|
2013
|
-
columnNumber: 15
|
|
2014
|
-
}, undefined)
|
|
2015
|
-
}, index, false, {
|
|
2016
|
-
fileName: _jsxFileName,
|
|
2017
|
-
lineNumber: 47,
|
|
2018
|
-
columnNumber: 13
|
|
2019
|
-
}, undefined), /*#__PURE__*/jsxDevRuntime.jsxDEV("li", {
|
|
2028
|
+
})
|
|
2029
|
+
}, index), jsxRuntime.jsx("li", {
|
|
2020
2030
|
className: "flex items-center",
|
|
2021
2031
|
"aria-hidden": true,
|
|
2022
|
-
children:
|
|
2032
|
+
children: jsxRuntime.jsx(obAtomsIcon.Icon, {
|
|
2023
2033
|
icon: "chevron_right"
|
|
2024
|
-
}
|
|
2025
|
-
|
|
2026
|
-
lineNumber: 63,
|
|
2027
|
-
columnNumber: 15
|
|
2028
|
-
}, undefined)
|
|
2029
|
-
}, `divider-${index}`, false, {
|
|
2030
|
-
fileName: _jsxFileName,
|
|
2031
|
-
lineNumber: 58,
|
|
2032
|
-
columnNumber: 13
|
|
2033
|
-
}, undefined)];
|
|
2034
|
+
})
|
|
2035
|
+
}, `divider-${index}`)];
|
|
2034
2036
|
}
|
|
2035
|
-
return [
|
|
2037
|
+
return [jsxRuntime.jsx("li", {
|
|
2036
2038
|
className: "flex items-center",
|
|
2037
|
-
children:
|
|
2039
|
+
children: jsxRuntime.jsx("a", {
|
|
2038
2040
|
href: item.href,
|
|
2039
2041
|
onClick: event => {
|
|
2040
2042
|
if (item && item.onClick) {
|
|
@@ -2044,52 +2046,28 @@ const Breadcrumbs = /*#__PURE__*/react.forwardRef((_ref, ref) => {
|
|
|
2044
2046
|
},
|
|
2045
2047
|
"aria-current": "page",
|
|
2046
2048
|
children: item.label
|
|
2047
|
-
}
|
|
2048
|
-
|
|
2049
|
-
lineNumber: 70,
|
|
2050
|
-
columnNumber: 13
|
|
2051
|
-
}, undefined)
|
|
2052
|
-
}, index, false, {
|
|
2053
|
-
fileName: _jsxFileName,
|
|
2054
|
-
lineNumber: 69,
|
|
2055
|
-
columnNumber: 11
|
|
2056
|
-
}, undefined), /*#__PURE__*/jsxDevRuntime.jsxDEV("li", {
|
|
2049
|
+
})
|
|
2050
|
+
}, index), jsxRuntime.jsx("li", {
|
|
2057
2051
|
className: "flex items-center",
|
|
2058
2052
|
"aria-hidden": true,
|
|
2059
|
-
children:
|
|
2053
|
+
children: jsxRuntime.jsx(obAtomsIcon.Icon, {
|
|
2060
2054
|
icon: "chevron_right"
|
|
2061
|
-
}
|
|
2062
|
-
|
|
2063
|
-
lineNumber: 88,
|
|
2064
|
-
columnNumber: 13
|
|
2065
|
-
}, undefined)
|
|
2066
|
-
}, `divider-${index}`, false, {
|
|
2067
|
-
fileName: _jsxFileName,
|
|
2068
|
-
lineNumber: 83,
|
|
2069
|
-
columnNumber: 11
|
|
2070
|
-
}, undefined)];
|
|
2055
|
+
})
|
|
2056
|
+
}, `divider-${index}`)];
|
|
2071
2057
|
});
|
|
2072
2058
|
}, [ariaLabel, filteredItems, items.length, shouldShrink]);
|
|
2073
|
-
return
|
|
2059
|
+
return jsxRuntime.jsx("nav", Object.assign({
|
|
2074
2060
|
ref: ref,
|
|
2075
2061
|
"aria-label": "Breadcrumb",
|
|
2076
2062
|
id: id,
|
|
2077
2063
|
className: "breadcrumb-container",
|
|
2078
2064
|
"data-testid": dataTestId
|
|
2079
2065
|
}, uiUtils.applyDataAttributes(props), {
|
|
2080
|
-
children:
|
|
2066
|
+
children: jsxRuntime.jsx("ol", {
|
|
2081
2067
|
className: "flex flex-row items-center min-w-max gap-(--breadcrumb-cotent-gap)",
|
|
2082
2068
|
children: renderLinks()
|
|
2083
|
-
}
|
|
2084
|
-
|
|
2085
|
-
lineNumber: 103,
|
|
2086
|
-
columnNumber: 9
|
|
2087
|
-
}, undefined)
|
|
2088
|
-
}), void 0, false, {
|
|
2089
|
-
fileName: _jsxFileName,
|
|
2090
|
-
lineNumber: 95,
|
|
2091
|
-
columnNumber: 7
|
|
2092
|
-
}, undefined);
|
|
2069
|
+
})
|
|
2070
|
+
}));
|
|
2093
2071
|
});
|
|
2094
2072
|
|
|
2095
2073
|
exports.Breadcrumbs = Breadcrumbs;
|
package/package.json
CHANGED
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/breadcrumbs';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DefaultProps } from '@bolttech/ui-utils';
|
|
2
|
+
/**
|
|
3
|
+
* @type {BreadcrumbItem}
|
|
4
|
+
* @property {string} label Label that should be displayed on the Breadcrumb Item
|
|
5
|
+
* @property {string} href Url of each Breadcrumb Item
|
|
6
|
+
* @property {Function} onClick (Optional) On Click event for each Breadcrumb Item
|
|
7
|
+
*/
|
|
8
|
+
export type BreadcrumbItem = {
|
|
9
|
+
label: string;
|
|
10
|
+
href?: string;
|
|
11
|
+
onClick?: () => void;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* @interface IBreadcrumbProps
|
|
15
|
+
* @member {string} id A unique identifier for the Breadcrumb component, used for identifying specific instances.
|
|
16
|
+
* @member {string} dataTestId A data-testid attribute for testing purposes, making the component easy to target in tests.
|
|
17
|
+
* @member {Array<BreadcrumbItem>} items A required array of breadcrumb items. Each item should be an object containing label and href properties.
|
|
18
|
+
* @member {string} ariaLabel Optional parameter for accessibility purposes. This should be used for the expand item, providing a description for this action.
|
|
19
|
+
*/
|
|
20
|
+
export interface IBreadcrumbProps extends DefaultProps {
|
|
21
|
+
id?: string;
|
|
22
|
+
dataTestId?: string;
|
|
23
|
+
items: BreadcrumbItem[];
|
|
24
|
+
ariaLabel?: string;
|
|
25
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type StoryObj } from '@storybook/react-vite';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: import("react").ForwardRefExoticComponent<import("./breadcrumbs.interface").IBreadcrumbProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
5
|
+
argTypes: {
|
|
6
|
+
id: {
|
|
7
|
+
type: "string";
|
|
8
|
+
description: string;
|
|
9
|
+
};
|
|
10
|
+
dataTestId: {
|
|
11
|
+
type: "string";
|
|
12
|
+
description: string;
|
|
13
|
+
};
|
|
14
|
+
items: {
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
ariaLabel: {
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export default meta;
|
|
23
|
+
type Story = StoryObj<typeof meta>;
|
|
24
|
+
export declare const Default: Story;
|