@elliemae/ds-breadcrumb 3.47.1 → 3.48.1
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/dist/cjs/DSBreadcrumb.js +18 -11
- package/dist/cjs/DSBreadcrumb.js.map +2 -2
- package/dist/cjs/DSBreadcrumbItem.js +31 -13
- package/dist/cjs/DSBreadcrumbItem.js.map +3 -3
- package/dist/cjs/hooks/useKeyboardNavigation.js +18 -12
- package/dist/cjs/hooks/useKeyboardNavigation.js.map +2 -2
- package/dist/cjs/react-desc-prop-types.js.map +1 -1
- package/dist/cjs/styles.js +12 -5
- package/dist/cjs/styles.js.map +2 -2
- package/dist/cjs/typescript-testing/typescript-breadcrumb-valid.js.map +2 -2
- package/dist/esm/DSBreadcrumb.js +18 -11
- package/dist/esm/DSBreadcrumb.js.map +2 -2
- package/dist/esm/DSBreadcrumbItem.js +31 -13
- package/dist/esm/DSBreadcrumbItem.js.map +3 -3
- package/dist/esm/hooks/useKeyboardNavigation.js +18 -12
- package/dist/esm/hooks/useKeyboardNavigation.js.map +2 -2
- package/dist/esm/react-desc-prop-types.js.map +1 -1
- package/dist/esm/styles.js +12 -5
- package/dist/esm/styles.js.map +2 -2
- package/dist/esm/typescript-testing/typescript-breadcrumb-valid.js.map +2 -2
- package/dist/types/DSBreadcrumb.d.ts +1 -1
- package/dist/types/hooks/useKeyboardNavigation.d.ts +3 -1
- package/dist/types/react-desc-prop-types.d.ts +3 -3
- package/package.json +5 -5
package/dist/cjs/DSBreadcrumb.js
CHANGED
|
@@ -42,21 +42,30 @@ var import_DSBreadcrumbItem = __toESM(require("./DSBreadcrumbItem.js"));
|
|
|
42
42
|
var import_useKeyboardNavigation = require("./hooks/useKeyboardNavigation.js");
|
|
43
43
|
var import_react_desc_prop_types = require("./react-desc-prop-types.js");
|
|
44
44
|
var import_styles = require("./styles.js");
|
|
45
|
-
const htmlElements = ["nav", "div"
|
|
45
|
+
const htmlElements = ["nav", "div"];
|
|
46
|
+
const NavContainer = (props2) => {
|
|
47
|
+
const { label, containerProps, as, children, ...rest } = props2;
|
|
48
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledContainer, { "aria-label": label, ...rest, ...containerProps, as, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledList, { "data-testid": "list-container", children }) });
|
|
49
|
+
};
|
|
50
|
+
const DivContainer = (props2) => {
|
|
51
|
+
const { label, containerProps, as, children, ...rest } = props2;
|
|
52
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledContainer, { ...rest, ...containerProps, as, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledList, { "data-testid": "list-container", "aria-label": label, children }) });
|
|
53
|
+
};
|
|
46
54
|
const DSBreadcrumb = (props2) => {
|
|
47
55
|
const propsWithDefaults = (0, import_ds_props_helpers.useMemoMergePropsWithDefault)(props2, import_react_desc_prop_types.defaultProps);
|
|
48
56
|
const { containerProps, as, label, trailingSlash, isTitle, children, ...rest } = propsWithDefaults;
|
|
49
|
-
const [addRef, onKeyDown] = (0, import_useKeyboardNavigation.useKeyboardNavigation)();
|
|
57
|
+
const [addRef, onKeyDown] = (0, import_useKeyboardNavigation.useKeyboardNavigation)({ isTitle });
|
|
50
58
|
const safeElement = (0, import_react.useMemo)(() => htmlElements.indexOf(as) > -1 ? as : "nav", [as]);
|
|
59
|
+
const Container = as === "nav" ? NavContainer : DivContainer;
|
|
51
60
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
52
|
-
|
|
61
|
+
Container,
|
|
53
62
|
{
|
|
54
63
|
"data-testid": "breadcrumb-nav-container",
|
|
55
|
-
|
|
64
|
+
label,
|
|
56
65
|
...rest,
|
|
57
|
-
|
|
66
|
+
containerProps,
|
|
58
67
|
as: safeElement,
|
|
59
|
-
children:
|
|
68
|
+
children: import_react.default.Children.map(
|
|
60
69
|
children,
|
|
61
70
|
(child, childIndex) => childIndex < children.length - 1 ? (0, import_react.cloneElement)(child, {
|
|
62
71
|
childIndex,
|
|
@@ -69,7 +78,7 @@ const DSBreadcrumb = (props2) => {
|
|
|
69
78
|
trailingSlash,
|
|
70
79
|
isTitle
|
|
71
80
|
})
|
|
72
|
-
)
|
|
81
|
+
)
|
|
73
82
|
}
|
|
74
83
|
);
|
|
75
84
|
};
|
|
@@ -79,11 +88,9 @@ const props = {
|
|
|
79
88
|
containerProps: import_ds_props_helpers.PropTypes.object.description("props injected to breadcrumb wrapper"),
|
|
80
89
|
/**
|
|
81
90
|
* Type of element you want the main container to be:
|
|
82
|
-
* 'nav', 'div'
|
|
91
|
+
* 'nav', 'div'
|
|
83
92
|
*/
|
|
84
|
-
as: import_ds_props_helpers.PropTypes.
|
|
85
|
-
"Type of element you want the main container to be: 'nav', 'div', 'header', 'footer', 'main'"
|
|
86
|
-
),
|
|
93
|
+
as: import_ds_props_helpers.PropTypes.oneOf(["nav", "div"]).description("Type of element you want the main container to be: 'nav' or 'div'. Defaults to 'nav'.").defaultValue("nav"),
|
|
87
94
|
/**
|
|
88
95
|
* Whether to show the last element of the breadcrumb as a title
|
|
89
96
|
* Also removes trailing slash to show last element as title
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/DSBreadcrumb.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React, {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["import React, { cloneElement, useMemo } from 'react';\nimport { PropTypes, describe, useMemoMergePropsWithDefault, type ValidationMap } from '@elliemae/ds-props-helpers';\nimport DSBreadcrumbItem from './DSBreadcrumbItem.js';\nimport { useKeyboardNavigation } from './hooks/useKeyboardNavigation.js';\nimport type { DSBreadcrumbT } from './react-desc-prop-types.js';\nimport { defaultProps } from './react-desc-prop-types.js';\nimport { StyledContainer, StyledList } from './styles.js';\n\nconst htmlElements = ['nav', 'div'] as const;\n\ntype ContainerProps = Omit<DSBreadcrumbT.InternalProps, 'isTitle' | 'trailingSlash'>;\n\nconst NavContainer = (props: ContainerProps) => {\n const { label, containerProps, as, children, ...rest } = props;\n return (\n <StyledContainer aria-label={label} {...rest} {...containerProps} as={as}>\n <StyledList data-testid=\"list-container\">{children}</StyledList>\n </StyledContainer>\n );\n};\n\nconst DivContainer = (props: ContainerProps) => {\n const { label, containerProps, as, children, ...rest } = props;\n return (\n <StyledContainer {...rest} {...containerProps} as={as}>\n <StyledList data-testid=\"list-container\" aria-label={label}>\n {children}\n </StyledList>\n </StyledContainer>\n );\n};\n\nconst DSBreadcrumb = (props: DSBreadcrumbT.Props) => {\n const propsWithDefaults = useMemoMergePropsWithDefault<DSBreadcrumbT.InternalProps>(props, defaultProps);\n const { containerProps, as, label, trailingSlash, isTitle, children, ...rest } = propsWithDefaults;\n const [addRef, onKeyDown] = useKeyboardNavigation({ isTitle });\n\n const safeElement = useMemo(() => (htmlElements.indexOf(as) > -1 ? as : 'nav'), [as]);\n\n const Container = as === 'nav' ? NavContainer : DivContainer;\n\n return (\n <Container\n data-testid=\"breadcrumb-nav-container\"\n label={label}\n {...rest}\n containerProps={containerProps}\n as={safeElement}\n >\n {React.Children.map(children, (child: React.ReactElement, childIndex) =>\n childIndex < children.length - 1\n ? cloneElement(child, {\n childIndex,\n addRef,\n onKeyDown,\n })\n : cloneElement(child, {\n childIndex,\n addRef,\n onKeyDown,\n trailingSlash,\n isTitle,\n }),\n )}\n </Container>\n );\n};\n\nDSBreadcrumb.Item = DSBreadcrumbItem;\n\nconst props = {\n /** props injected to breadcrumb wrapper */\n containerProps: PropTypes.object.description('props injected to breadcrumb wrapper'),\n /**\n * Type of element you want the main container to be:\n * 'nav', 'div'\n */\n as: PropTypes.oneOf(['nav', 'div'])\n .description(\"Type of element you want the main container to be: 'nav' or 'div'. Defaults to 'nav'.\")\n .defaultValue('nav'),\n /**\n * Whether to show the last element of the breadcrumb as a title\n * Also removes trailing slash to show last element as title\n */\n isTitle: PropTypes.bool.description(\n 'Whether to show the last element of the breadcrumb as a title. Also removes trailing slash to show last element as title',\n ),\n /** breadcrumb label */\n label: PropTypes.string.description('breadcrumb label'),\n /**\n * Container items to wrap\n */\n children: PropTypes.arrayOf(PropTypes.element).isRequired.description('Container items to wrap'),\n};\n\nDSBreadcrumb.displayName = 'DSBreadcrumb';\nconst DSBreadcrumbWithSchema = describe(DSBreadcrumb);\nDSBreadcrumbWithSchema.propTypes = props as ValidationMap<unknown>;\n\nexport { DSBreadcrumb, DSBreadcrumbWithSchema, htmlElements };\nexport default DSBreadcrumb;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADgBjB;AAhBN,mBAA6C;AAC7C,8BAAsF;AACtF,8BAA6B;AAC7B,mCAAsC;AAEtC,mCAA6B;AAC7B,oBAA4C;AAE5C,MAAM,eAAe,CAAC,OAAO,KAAK;AAIlC,MAAM,eAAe,CAACA,WAA0B;AAC9C,QAAM,EAAE,OAAO,gBAAgB,IAAI,UAAU,GAAG,KAAK,IAAIA;AACzD,SACE,4CAAC,iCAAgB,cAAY,OAAQ,GAAG,MAAO,GAAG,gBAAgB,IAChE,sDAAC,4BAAW,eAAY,kBAAkB,UAAS,GACrD;AAEJ;AAEA,MAAM,eAAe,CAACA,WAA0B;AAC9C,QAAM,EAAE,OAAO,gBAAgB,IAAI,UAAU,GAAG,KAAK,IAAIA;AACzD,SACE,4CAAC,iCAAiB,GAAG,MAAO,GAAG,gBAAgB,IAC7C,sDAAC,4BAAW,eAAY,kBAAiB,cAAY,OAClD,UACH,GACF;AAEJ;AAEA,MAAM,eAAe,CAACA,WAA+B;AACnD,QAA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C,IAAO,uBAAQ;",
|
|
6
6
|
"names": ["props", "React", "DSBreadcrumbItem"]
|
|
7
7
|
}
|
|
@@ -35,29 +35,44 @@ __export(DSBreadcrumbItem_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(DSBreadcrumbItem_exports);
|
|
36
36
|
var React = __toESM(require("react"));
|
|
37
37
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
38
|
+
var import_react = __toESM(require("react"));
|
|
38
39
|
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
39
40
|
var import_react_desc_prop_types = require("./react-desc-prop-types.js");
|
|
40
41
|
var import_styles = require("./styles.js");
|
|
41
42
|
const DSBreadcrumbItem = (props2) => {
|
|
42
43
|
const propsWithDefaults = (0, import_ds_props_helpers.useMemoMergePropsWithDefault)(props2, import_react_desc_prop_types.defaultItemProps);
|
|
43
44
|
const { as, active, href, onClick, onKeyDown, addRef, isTitle, trailingSlash, label, childIndex, color, ...rest } = propsWithDefaults;
|
|
45
|
+
const ariaCurrent = import_react.default.useMemo(() => {
|
|
46
|
+
if (active) {
|
|
47
|
+
return as === "button" ? "step" : "page";
|
|
48
|
+
}
|
|
49
|
+
return void 0;
|
|
50
|
+
}, [active, as]);
|
|
51
|
+
const handleOnClick = import_react.default.useCallback(
|
|
52
|
+
(e) => {
|
|
53
|
+
if (isTitle) return;
|
|
54
|
+
onClick(e);
|
|
55
|
+
},
|
|
56
|
+
[isTitle, onClick]
|
|
57
|
+
);
|
|
44
58
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
45
59
|
import_styles.StyledCrumbWrapper,
|
|
46
60
|
{
|
|
47
|
-
"aria-current":
|
|
61
|
+
"aria-current": ariaCurrent,
|
|
48
62
|
"data-testid": "breadcrumb-item-container",
|
|
49
63
|
isTitle,
|
|
50
64
|
trailingSlash,
|
|
51
65
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
52
66
|
import_styles.StyledLink,
|
|
53
67
|
{
|
|
68
|
+
"data-testid": "breadcrumb-item-content",
|
|
54
69
|
variant: "link",
|
|
55
70
|
component: as,
|
|
56
71
|
href,
|
|
57
|
-
onClick,
|
|
58
|
-
tabIndex: 0,
|
|
72
|
+
onClick: handleOnClick,
|
|
73
|
+
tabIndex: isTitle ? -1 : 0,
|
|
59
74
|
active,
|
|
60
|
-
onKeyDown: (e) => onKeyDown(e, childIndex ?? -1,
|
|
75
|
+
onKeyDown: (e) => onKeyDown(e, childIndex ?? -1, handleOnClick),
|
|
61
76
|
isTitle,
|
|
62
77
|
color,
|
|
63
78
|
innerRef: addRef,
|
|
@@ -69,22 +84,25 @@ const DSBreadcrumbItem = (props2) => {
|
|
|
69
84
|
);
|
|
70
85
|
};
|
|
71
86
|
const props = {
|
|
72
|
-
/**
|
|
73
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Type of element you want the item to be:
|
|
89
|
+
* 'a', 'button'
|
|
90
|
+
*/
|
|
91
|
+
as: import_ds_props_helpers.PropTypes.oneOf(["a", "button"]).description('Type of element you want the item to be: "a" or "button". Defaults to "a"').defaultValue("a"),
|
|
74
92
|
/** active item */
|
|
75
|
-
active: import_ds_props_helpers.PropTypes.bool.description("
|
|
93
|
+
active: import_ds_props_helpers.PropTypes.bool.description("Active item"),
|
|
76
94
|
/** href link */
|
|
77
|
-
href: import_ds_props_helpers.PropTypes.string.description("
|
|
95
|
+
href: import_ds_props_helpers.PropTypes.string.description("Href link"),
|
|
78
96
|
/** on click handler */
|
|
79
|
-
onClick: import_ds_props_helpers.PropTypes.func.description("
|
|
97
|
+
onClick: import_ds_props_helpers.PropTypes.func.description("On click handler"),
|
|
80
98
|
/** style item as title */
|
|
81
|
-
isTitle: import_ds_props_helpers.PropTypes.bool.description("
|
|
99
|
+
isTitle: import_ds_props_helpers.PropTypes.bool.description("Style item as title"),
|
|
82
100
|
/** add trailing slash */
|
|
83
|
-
trailingSlash: import_ds_props_helpers.PropTypes.bool.description("
|
|
101
|
+
trailingSlash: import_ds_props_helpers.PropTypes.bool.description("Add trailing slash"),
|
|
84
102
|
/** item label */
|
|
85
|
-
label: import_ds_props_helpers.PropTypes.string.description("
|
|
103
|
+
label: import_ds_props_helpers.PropTypes.string.description("Item label"),
|
|
86
104
|
/** link color */
|
|
87
|
-
color: import_ds_props_helpers.PropTypes.string.description("
|
|
105
|
+
color: import_ds_props_helpers.PropTypes.string.description("Link color")
|
|
88
106
|
};
|
|
89
107
|
DSBreadcrumbItem.displayName = "DSBreadcrumbItem";
|
|
90
108
|
const DSBreadcrumbItemWithSchema = (0, import_ds_props_helpers.describe)(DSBreadcrumbItem);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/DSBreadcrumbItem.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
6
|
-
"names": ["props"]
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { PropTypes, describe, useMemoMergePropsWithDefault, type ValidationMap } from '@elliemae/ds-props-helpers';\nimport type { DSBreadcrumbItemT } from './react-desc-prop-types.js';\nimport { defaultItemProps } from './react-desc-prop-types.js';\n\nimport { StyledLink, StyledCrumbWrapper } from './styles.js';\n\nconst DSBreadcrumbItem = (props: DSBreadcrumbItemT.Props) => {\n const propsWithDefaults = useMemoMergePropsWithDefault<DSBreadcrumbItemT.InternalProps>(props, defaultItemProps);\n const { as, active, href, onClick, onKeyDown, addRef, isTitle, trailingSlash, label, childIndex, color, ...rest } =\n propsWithDefaults;\n\n const ariaCurrent = React.useMemo(() => {\n if (active) {\n return as === 'button' ? 'step' : 'page';\n }\n return undefined;\n }, [active, as]);\n\n const handleOnClick = React.useCallback(\n (e: React.MouseEvent) => {\n if (isTitle) return;\n onClick(e);\n },\n [isTitle, onClick],\n );\n\n return (\n <StyledCrumbWrapper\n aria-current={ariaCurrent}\n data-testid=\"breadcrumb-item-container\"\n isTitle={isTitle}\n trailingSlash={trailingSlash}\n >\n <StyledLink\n data-testid=\"breadcrumb-item-content\"\n variant=\"link\"\n component={as}\n href={href}\n onClick={handleOnClick}\n tabIndex={isTitle ? -1 : 0}\n active={active}\n onKeyDown={(e: React.KeyboardEvent) => onKeyDown(e, childIndex ?? -1, handleOnClick)}\n isTitle={isTitle}\n color={color}\n innerRef={addRef}\n {...rest}\n >\n {label}\n </StyledLink>\n </StyledCrumbWrapper>\n );\n};\n\nconst props = {\n /**\n * Type of element you want the item to be:\n * 'a', 'button'\n */\n as: PropTypes.oneOf(['a', 'button'])\n .description('Type of element you want the item to be: \"a\" or \"button\". Defaults to \"a\"')\n .defaultValue('a'),\n /** active item */\n active: PropTypes.bool.description('Active item'),\n /** href link */\n href: PropTypes.string.description('Href link'),\n /** on click handler */\n onClick: PropTypes.func.description('On click handler'),\n /** style item as title */\n isTitle: PropTypes.bool.description('Style item as title'),\n /** add trailing slash */\n trailingSlash: PropTypes.bool.description('Add trailing slash'),\n /** item label */\n label: PropTypes.string.description('Item label'),\n /** link color */\n color: PropTypes.string.description('Link color'),\n};\n\nDSBreadcrumbItem.displayName = 'DSBreadcrumbItem';\nconst DSBreadcrumbItemWithSchema = describe(DSBreadcrumbItem);\nDSBreadcrumbItemWithSchema.propTypes = props as ValidationMap<unknown>;\n\nexport { DSBreadcrumbItem, DSBreadcrumbItemWithSchema };\nexport default DSBreadcrumbItem;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADkCjB;AAlCN,mBAAkB;AAClB,8BAAsF;AAEtF,mCAAiC;AAEjC,oBAA+C;AAE/C,MAAM,mBAAmB,CAACA,WAAmC;AAC3D,QAAM,wBAAoB,sDAA8DA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AoB;AAAA;AAAA,EAE9D,OAAO,kCAAU,OAAO,YAAY,YAAY;AAAA;AAAA,EAEhD,OAAO,kCAAU,OAAO,YAAY,YAAY;AAClD;AAEA,iBAAiB,cAAc;AAC/B,MAAM,iCAA6B,kCAAS,gBAAgB;AAC5D,2BAA2B,YAAY;AAGvC,IAAO,2BAAQ;",
|
|
6
|
+
"names": ["props", "React"]
|
|
7
7
|
}
|
|
@@ -33,24 +33,30 @@ __export(useKeyboardNavigation_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(useKeyboardNavigation_exports);
|
|
34
34
|
var React = __toESM(require("react"));
|
|
35
35
|
var import_react = require("react");
|
|
36
|
-
const useKeyboardNavigation = () => {
|
|
36
|
+
const useKeyboardNavigation = ({ isTitle }) => {
|
|
37
37
|
const componentsRef = (0, import_react.useRef)([]);
|
|
38
38
|
const addRef = (0, import_react.useCallback)((ref) => {
|
|
39
39
|
if (ref && !componentsRef.current.includes(ref)) {
|
|
40
40
|
componentsRef.current.push(ref);
|
|
41
41
|
}
|
|
42
42
|
}, []);
|
|
43
|
-
const onKeyDown = (0, import_react.useCallback)(
|
|
44
|
-
|
|
45
|
-
componentsRef.current[componentRefIndex + 1]
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
const onKeyDown = (0, import_react.useCallback)(
|
|
44
|
+
(e, componentRefIndex, callback) => {
|
|
45
|
+
if (e.key === "ArrowDown" && componentsRef.current[componentRefIndex + 1]) {
|
|
46
|
+
if (isTitle && componentRefIndex + 1 === componentsRef.current.length - 1) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
componentsRef.current[componentRefIndex + 1].focus();
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
} else if (e.key === "ArrowUp" && componentRefIndex !== 0) {
|
|
52
|
+
componentsRef.current[componentRefIndex - 1].focus();
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
} else if (e.key === "Enter" || e.ctrlKey && e.altKey && e.code === "Space") {
|
|
55
|
+
callback(e);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
[isTitle]
|
|
59
|
+
);
|
|
54
60
|
return [addRef, onKeyDown];
|
|
55
61
|
};
|
|
56
62
|
//# sourceMappingURL=useKeyboardNavigation.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useKeyboardNavigation.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable complexity */\n/* eslint-disable max-params */\nimport type React from 'react';\nimport { useRef, useCallback } from 'react';\n\nexport const useKeyboardNavigation = ({ isTitle }: { isTitle: boolean }) => {\n const componentsRef = useRef<HTMLAnchorElement[]>([]);\n\n const addRef = useCallback((ref: HTMLAnchorElement) => {\n if (ref && !componentsRef.current.includes(ref)) {\n componentsRef.current.push(ref);\n }\n }, []);\n\n const onKeyDown = useCallback(\n (\n e: React.KeyboardEvent,\n componentRefIndex: number,\n callback: (e: React.MouseEvent | React.KeyboardEvent) => void,\n ) => {\n if (e.key === 'ArrowDown' && componentsRef.current[componentRefIndex + 1]) {\n if (isTitle && componentRefIndex + 1 === componentsRef.current.length - 1) {\n // If the 'isTitle' flag is set to true, the last link is not an interactive link so we do not focus it\n return;\n }\n componentsRef.current[componentRefIndex + 1].focus();\n e.preventDefault();\n } else if (e.key === 'ArrowUp' && componentRefIndex !== 0) {\n componentsRef.current[componentRefIndex - 1].focus();\n e.preventDefault();\n } else if (e.key === 'Enter' || (e.ctrlKey && e.altKey && e.code === 'Space')) {\n callback(e);\n }\n },\n [isTitle],\n );\n\n return [addRef, onKeyDown];\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,mBAAoC;AAE7B,MAAM,wBAAwB,CAAC,EAAE,QAAQ,MAA4B;AAC1E,QAAM,oBAAgB,qBAA4B,CAAC,CAAC;AAEpD,QAAM,aAAS,0BAAY,CAAC,QAA2B;AACrD,QAAI,OAAO,CAAC,cAAc,QAAQ,SAAS,GAAG,GAAG;AAC/C,oBAAc,QAAQ,KAAK,GAAG;AAAA,IAChC;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,QAAM,gBAAY;AAAA,IAChB,CACE,GACA,mBACA,aACG;AACH,UAAI,EAAE,QAAQ,eAAe,cAAc,QAAQ,oBAAoB,CAAC,GAAG;AACzE,YAAI,WAAW,oBAAoB,MAAM,cAAc,QAAQ,SAAS,GAAG;AAEzE;AAAA,QACF;AACA,sBAAc,QAAQ,oBAAoB,CAAC,EAAE,MAAM;AACnD,UAAE,eAAe;AAAA,MACnB,WAAW,EAAE,QAAQ,aAAa,sBAAsB,GAAG;AACzD,sBAAc,QAAQ,oBAAoB,CAAC,EAAE,MAAM;AACnD,UAAE,eAAe;AAAA,MACnB,WAAW,EAAE,QAAQ,WAAY,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,SAAU;AAC7E,iBAAS,CAAC;AAAA,MACZ;AAAA,IACF;AAAA,IACA,CAAC,OAAO;AAAA,EACV;AAEA,SAAO,CAAC,QAAQ,SAAS;AAC3B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/react-desc-prop-types.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import type { GlobalAttributesT, XstyledProps } from '@elliemae/ds-props-helpers';\nimport type React from 'react';\nimport type { htmlElements } from './DSBreadcrumb.js';\ntype SafeComponentsT = (typeof htmlElements)[number];\n\ntype SafeItemComponentT = 'a' | 'button'
|
|
4
|
+
"sourcesContent": ["import type { GlobalAttributesT, XstyledProps } from '@elliemae/ds-props-helpers';\nimport type React from 'react';\nimport type { htmlElements } from './DSBreadcrumb.js';\ntype SafeComponentsT = (typeof htmlElements)[number];\n\ntype SafeItemComponentT = 'a' | 'button';\n\nexport const defaultProps: DSBreadcrumbT.DefaultProps = {\n containerProps: {},\n as: 'nav',\n label: 'Breadcrumb',\n isTitle: false,\n trailingSlash: true,\n};\n\nexport const defaultItemProps: DSBreadcrumbItemT.DefaultProps = {\n active: false,\n as: 'a',\n onKeyDown: () => null,\n onClick: () => null,\n label: '',\n childIndex: -1,\n};\n\ndeclare namespace DSBreadcrumbT {\n export interface DefaultProps {\n containerProps: Record<string, unknown>;\n as: SafeComponentsT;\n label: string;\n isTitle: boolean;\n trailingSlash: boolean;\n }\n\n export interface RequiredProps {\n children: React.ReactElement[];\n }\n\n export interface Props\n extends Partial<DefaultProps>,\n RequiredProps,\n Omit<GlobalAttributesT, keyof DefaultProps | keyof RequiredProps>,\n XstyledProps {}\n\n export interface InternalProps\n extends DefaultProps,\n RequiredProps,\n Omit<GlobalAttributesT, keyof DefaultProps | keyof RequiredProps>,\n XstyledProps {}\n}\n\ndeclare namespace DSBreadcrumbItemT {\n export interface DefaultProps {\n active: boolean;\n as: SafeItemComponentT;\n onKeyDown: (e: React.KeyboardEvent, componentRefIndex: number, onClick: (e: React.MouseEvent) => void) => void;\n onClick: (e: React.MouseEvent) => void;\n label: string;\n childIndex: number;\n }\n\n export interface OptionalProps {\n addRef?: React.MutableRefObject<HTMLDivElement | null> | React.RefCallback<HTMLDivElement>;\n color?: string;\n href?: string;\n isTitle?: boolean;\n trailingSlash?: boolean;\n }\n\n export interface Props\n extends Partial<DefaultProps>,\n OptionalProps,\n Omit<GlobalAttributesT, keyof DefaultProps | keyof OptionalProps>,\n XstyledProps {}\n\n export interface InternalProps\n extends DefaultProps,\n OptionalProps,\n Omit<GlobalAttributesT, keyof DefaultProps | keyof OptionalProps>,\n XstyledProps {}\n}\n\nexport type { DSBreadcrumbItemT, DSBreadcrumbT, SafeComponentsT, SafeItemComponentT };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADOhB,MAAM,eAA2C;AAAA,EACtD,gBAAgB,CAAC;AAAA,EACjB,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,SAAS;AAAA,EACT,eAAe;AACjB;AAEO,MAAM,mBAAmD;AAAA,EAC9D,QAAQ;AAAA,EACR,IAAI;AAAA,EACJ,WAAW,MAAM;AAAA,EACjB,SAAS,MAAM;AAAA,EACf,OAAO;AAAA,EACP,YAAY;AACd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/styles.js
CHANGED
|
@@ -97,13 +97,20 @@ const StyledLink = (0, import_ds_system.styled)(import_ds_typography.DSTypograph
|
|
|
97
97
|
font-weight: ${({ theme }) => theme.fontWeights.regular};
|
|
98
98
|
color: ${({ theme, active, color = "", isTitle }) => handleColor(theme, !!active, color, !!isTitle)};
|
|
99
99
|
&:hover {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
${({ theme, color, isTitle }) => isTitle ? `
|
|
101
|
+
color: ${theme.colors.neutral[700]};
|
|
102
|
+
cursor: default;` : `
|
|
103
|
+
color: ${color || theme.colors.brand[800]};
|
|
104
|
+
cursor: pointer;
|
|
105
|
+
-webkit-text-stroke: 0.4px ${color || theme.colors.brand[800]};
|
|
106
|
+
`}
|
|
103
107
|
}
|
|
104
108
|
&:focus {
|
|
105
|
-
${({ theme }) =>
|
|
106
|
-
|
|
109
|
+
${({ theme, isTitle }) => isTitle ? `
|
|
110
|
+
color: ${theme.colors.neutral[700]};` : `
|
|
111
|
+
border: 2px solid ${theme.colors.brand[700]};
|
|
112
|
+
border-radius: 2px;
|
|
113
|
+
`}
|
|
107
114
|
}
|
|
108
115
|
`;
|
|
109
116
|
//# sourceMappingURL=styles.js.map
|
package/dist/cjs/styles.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/styles.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable max-params */\nimport type { Theme } from '@elliemae/pui-theme';\nimport { styled } from '@elliemae/ds-system';\nimport { DSTypography } from '@elliemae/ds-typography';\nimport type { DSBreadcrumbItemT } from './react-desc-prop-types.js';\n\nconst handleColor = (theme: Theme, isActive: boolean, color: string, isTitle: boolean): string => {\n if (isActive) return theme.colors.neutral[800];\n if (color) return color;\n if (isTitle) return theme.colors.neutral[700];\n return theme.colors.brand[600];\n};\n\nconst StyledList = styled.ol`\n width: 100%;\n list-style: none;\n display: flex;\n padding: 0;\n margin: 0;\n li:first-child * {\n margin-left: 0;\n }\n`;\n\nconst StyledCrumbWrapper = styled.li<Partial<DSBreadcrumbItemT.Props>>`\n display: inline-flex;\n align-items: center;\n flex-shrink: 20;\n transition: flex-shrink 0.1s cubic-bezier(0.64, 0, 0.35, 1);\n min-height: 1.231rem;\n min-width: 10px;\n &:focus-within {\n flex-shrink: 0;\n }\n &:hover {\n flex-shrink: 0;\n }\n ${({ theme, isTitle, trailingSlash }) =>\n isTitle || !trailingSlash\n ? `&:not(:last-child):after {\n display: inline-block;\n content: '/';\n color: ${theme.colors.neutral[700]};\n }\n `\n : `&:after {\n display: inline-block;\n content: '/';\n color: ${theme.colors.neutral[700]};\n }\n `}\n`;\n\nconst StyledContainer = styled.nav`\n display: flex;\n align-items: center;\n padding: 0;\n`;\n\nconst StyledLink = styled(DSTypography)<Partial<DSBreadcrumbItemT.Props>>`\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n text-decoration: none;\n outline: none;\n margin: 0 2px;\n border: 2px solid transparent;\n -webkit-text-stroke: 0.4px transparent;\n line-height: 1.5385rem;\n background: transparent;\n font-weight: ${({ theme }) => theme.fontWeights.regular};\n color: ${({ theme, active, color = '', isTitle }) => handleColor(theme, !!active, color, !!isTitle)};\n &:hover {\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,uBAAuB;AACvB,2BAA6B;AAG7B,MAAM,cAAc,CAAC,OAAc,UAAmB,OAAe,YAA6B;AAChG,MAAI,SAAU,QAAO,MAAM,OAAO,QAAQ,GAAG;AAC7C,MAAI,MAAO,QAAO;AAClB,MAAI,QAAS,QAAO,MAAM,OAAO,QAAQ,GAAG;AAC5C,SAAO,MAAM,OAAO,MAAM,GAAG;AAC/B;AAEA,MAAM,aAAa,wBAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAW1B,MAAM,qBAAqB,wBAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAa9B,CAAC,EAAE,OAAO,SAAS,cAAc,MACjC,WAAW,CAAC,gBACR;AAAA;AAAA;AAAA,aAGK,MAAM,OAAO,QAAQ,GAAG,CAAC;AAAA;AAAA,MAG9B;AAAA;AAAA;AAAA,aAGK,MAAM,OAAO,QAAQ,GAAG,CAAC;AAAA;AAAA,GAEnC;AAAA;AAGH,MAAM,kBAAkB,wBAAO;AAAA;AAAA;AAAA;AAAA;AAM/B,MAAM,iBAAa,yBAAO,iCAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAWrB,CAAC,EAAE,MAAM,MAAM,MAAM,YAAY,OAAO;AAAA,WAC9C,CAAC,EAAE,OAAO,QAAQ,QAAQ,IAAI,QAAQ,MAAM,YAAY,OAAO,CAAC,CAAC,QAAQ,OAAO,CAAC,CAAC,OAAO,CAAC;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-params */\nimport type { Theme } from '@elliemae/pui-theme';\nimport { styled } from '@elliemae/ds-system';\nimport { DSTypography } from '@elliemae/ds-typography';\nimport type { DSBreadcrumbItemT } from './react-desc-prop-types.js';\n\nconst handleColor = (theme: Theme, isActive: boolean, color: string, isTitle: boolean): string => {\n if (isActive) return theme.colors.neutral[800];\n if (color) return color;\n if (isTitle) return theme.colors.neutral[700];\n return theme.colors.brand[600];\n};\n\nconst StyledList = styled.ol`\n width: 100%;\n list-style: none;\n display: flex;\n padding: 0;\n margin: 0;\n li:first-child * {\n margin-left: 0;\n }\n`;\n\nconst StyledCrumbWrapper = styled.li<Partial<DSBreadcrumbItemT.Props>>`\n display: inline-flex;\n align-items: center;\n flex-shrink: 20;\n transition: flex-shrink 0.1s cubic-bezier(0.64, 0, 0.35, 1);\n min-height: 1.231rem;\n min-width: 10px;\n &:focus-within {\n flex-shrink: 0;\n }\n &:hover {\n flex-shrink: 0;\n }\n ${({ theme, isTitle, trailingSlash }) =>\n isTitle || !trailingSlash\n ? `&:not(:last-child):after {\n display: inline-block;\n content: '/';\n color: ${theme.colors.neutral[700]};\n }\n `\n : `&:after {\n display: inline-block;\n content: '/';\n color: ${theme.colors.neutral[700]};\n }\n `}\n`;\n\nconst StyledContainer = styled.nav`\n display: flex;\n align-items: center;\n padding: 0;\n`;\n\nconst StyledLink = styled(DSTypography)<Partial<DSBreadcrumbItemT.Props>>`\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n text-decoration: none;\n outline: none;\n margin: 0 2px;\n border: 2px solid transparent;\n -webkit-text-stroke: 0.4px transparent;\n line-height: 1.5385rem;\n background: transparent;\n font-weight: ${({ theme }) => theme.fontWeights.regular};\n color: ${({ theme, active, color = '', isTitle }) => handleColor(theme, !!active, color, !!isTitle)};\n &:hover {\n ${({ theme, color, isTitle }) =>\n isTitle\n ? `\n color: ${theme.colors.neutral[700]};\n cursor: default;`\n : `\n color: ${color || theme.colors.brand[800]};\n cursor: pointer;\n -webkit-text-stroke: 0.4px ${color || theme.colors.brand[800]};\n `}\n }\n &:focus {\n ${({ theme, isTitle }) =>\n isTitle\n ? `\n color: ${theme.colors.neutral[700]};`\n : `\n border: 2px solid ${theme.colors.brand[700]};\n border-radius: 2px;\n `}\n }\n`;\n\nexport { StyledList, StyledCrumbWrapper, StyledContainer, StyledLink };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,uBAAuB;AACvB,2BAA6B;AAG7B,MAAM,cAAc,CAAC,OAAc,UAAmB,OAAe,YAA6B;AAChG,MAAI,SAAU,QAAO,MAAM,OAAO,QAAQ,GAAG;AAC7C,MAAI,MAAO,QAAO;AAClB,MAAI,QAAS,QAAO,MAAM,OAAO,QAAQ,GAAG;AAC5C,SAAO,MAAM,OAAO,MAAM,GAAG;AAC/B;AAEA,MAAM,aAAa,wBAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAW1B,MAAM,qBAAqB,wBAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAa9B,CAAC,EAAE,OAAO,SAAS,cAAc,MACjC,WAAW,CAAC,gBACR;AAAA;AAAA;AAAA,aAGK,MAAM,OAAO,QAAQ,GAAG,CAAC;AAAA;AAAA,MAG9B;AAAA;AAAA;AAAA,aAGK,MAAM,OAAO,QAAQ,GAAG,CAAC;AAAA;AAAA,GAEnC;AAAA;AAGH,MAAM,kBAAkB,wBAAO;AAAA;AAAA;AAAA;AAAA;AAM/B,MAAM,iBAAa,yBAAO,iCAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAWrB,CAAC,EAAE,MAAM,MAAM,MAAM,YAAY,OAAO;AAAA,WAC9C,CAAC,EAAE,OAAO,QAAQ,QAAQ,IAAI,QAAQ,MAAM,YAAY,OAAO,CAAC,CAAC,QAAQ,OAAO,CAAC,CAAC,OAAO,CAAC;AAAA;AAAA,MAE/F,CAAC,EAAE,OAAO,OAAO,QAAQ,MACzB,UACI;AAAA,mBACS,MAAM,OAAO,QAAQ,GAAG,CAAC;AAAA,8BAElC;AAAA,mBACS,SAAS,MAAM,OAAO,MAAM,GAAG,CAAC;AAAA;AAAA,uCAEZ,SAAS,MAAM,OAAO,MAAM,GAAG,CAAC;AAAA,KAClE;AAAA;AAAA;AAAA,MAGC,CAAC,EAAE,OAAO,QAAQ,MAClB,UACI;AAAA,kBACQ,MAAM,OAAO,QAAQ,GAAG,CAAC,MACjC;AAAA,4BACkB,MAAM,OAAO,MAAM,GAAG,CAAC;AAAA;AAAA,KAE9C;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/typescript-testing/typescript-breadcrumb-valid.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport { DSBreadcrumb, DSBreadcrumbItem } from '../index.js';\nimport type { DSBreadcrumbT, DSBreadcrumbItemT } from '../index.js';\n\n// test we expose the namespace and the namespace follows our deliverable conventions\ntype ComponentPropsForApp = DSBreadcrumbT.Props;\ntype ComponentPropsInternals = DSBreadcrumbT.InternalProps;\ntype ComponentPropsDefaultProps = DSBreadcrumbT.DefaultProps;\ntype ComponentPropsRequiredProps = DSBreadcrumbT.RequiredProps;\n\nconst testRequiredProps: ComponentPropsRequiredProps = {\n children: [],\n};\n\n// difference Props and InternalProps is that InternalProps has all the default props filled in\n// Props allows for partial defaults\nconst testPartialDefaults: Partial<ComponentPropsDefaultProps> = {\n as: 'nav',\n label: 'Breadcrumb',\n isTitle: false,\n};\n\nconst testProps: ComponentPropsForApp = {\n ...testRequiredProps,\n ...testPartialDefaults,\n};\nconst testPropsAsSyntax = {\n ...testRequiredProps,\n ...testPartialDefaults,\n} as ComponentPropsForApp;\n// InternalProps requires all defaults to be filled in\nconst testCompleteDefaults: Required<ComponentPropsDefaultProps> = {\n as: 'nav',\n label: 'Breadcrumb',\n isTitle: false,\n trailingSlash: true,\n containerProps: {},\n};\nconst testInternalProps: ComponentPropsInternals = {\n ...testRequiredProps,\n ...testCompleteDefaults,\n};\nconst testInternalPropsAsSyntax = {\n ...testRequiredProps,\n ...testCompleteDefaults,\n} as ComponentPropsInternals;\n\n// using the explicit type definition, if there is an error, it will be marked on the key that is wrong\nconst testExplicitDefinition: ComponentPropsForApp = {\n children: [],\n as: 'nav',\n label: 'Breadcrumb',\n isTitle: false,\n trailingSlash: true,\n containerProps: {},\n};\n\n// using the \"as\" syntax, if there is an error, it will be marking the whole object as wrong because it is not compatible with the type\nconst testInferedTypeCompatibility = {\n children: [],\n as: 'nav',\n label: 'Breadcrumb',\n isTitle: false,\n trailingSlash: true,\n containerProps: {},\n} as ComponentPropsForApp;\n\nconst ExampleUsageComponent = () => (\n <>\n {/* works with explicitly casted props, all syntaxes */}\n <DSBreadcrumb {...testExplicitDefinition} />\n <DSBreadcrumb {...testInferedTypeCompatibility} />\n {/* works with inline values */}\n <DSBreadcrumb as=\"nav\" label=\"Breadcrumb\" isTitle={false} trailingSlash
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAuB;ACoErB;AAnEF,eAA+C;AAS/C,MAAM,oBAAiD;AAAA,EACrD,UAAU,CAAC;AACb;AAIA,MAAM,sBAA2D;AAAA,EAC/D,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,SAAS;AACX;AAEA,MAAM,YAAkC;AAAA,EACtC,GAAG;AAAA,EACH,GAAG;AACL;AACA,MAAM,oBAAoB;AAAA,EACxB,GAAG;AAAA,EACH,GAAG;AACL;AAEA,MAAM,uBAA6D;AAAA,EACjE,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,SAAS;AAAA,EACT,eAAe;AAAA,EACf,gBAAgB,CAAC;AACnB;AACA,MAAM,oBAA6C;AAAA,EACjD,GAAG;AAAA,EACH,GAAG;AACL;AACA,MAAM,4BAA4B;AAAA,EAChC,GAAG;AAAA,EACH,GAAG;AACL;AAGA,MAAM,yBAA+C;AAAA,EACnD,UAAU,CAAC;AAAA,EACX,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,SAAS;AAAA,EACT,eAAe;AAAA,EACf,gBAAgB,CAAC;AACnB;AAGA,MAAM,+BAA+B;AAAA,EACnC,UAAU,CAAC;AAAA,EACX,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,SAAS;AAAA,EACT,eAAe;AAAA,EACf,gBAAgB,CAAC;AACnB;AAEA,MAAM,wBAAwB,MAC5B,4EAEE;AAAA,8CAAC,yBAAc,GAAG,wBAAwB;AAAA,EAC1C,4CAAC,yBAAc,GAAG,8BAA8B;AAAA,EAEhD,6CAAC,yBAAa,IAAG,OAAM,OAAM,cAAa,SAAS,OAAO,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport { DSBreadcrumb, DSBreadcrumbItem } from '../index.js';\nimport type { DSBreadcrumbT, DSBreadcrumbItemT } from '../index.js';\n\n// test we expose the namespace and the namespace follows our deliverable conventions\ntype ComponentPropsForApp = DSBreadcrumbT.Props;\ntype ComponentPropsInternals = DSBreadcrumbT.InternalProps;\ntype ComponentPropsDefaultProps = DSBreadcrumbT.DefaultProps;\ntype ComponentPropsRequiredProps = DSBreadcrumbT.RequiredProps;\n\nconst testRequiredProps: ComponentPropsRequiredProps = {\n children: [],\n};\n\n// difference Props and InternalProps is that InternalProps has all the default props filled in\n// Props allows for partial defaults\nconst testPartialDefaults: Partial<ComponentPropsDefaultProps> = {\n as: 'nav',\n label: 'Breadcrumb',\n isTitle: false,\n};\n\nconst testProps: ComponentPropsForApp = {\n ...testRequiredProps,\n ...testPartialDefaults,\n};\nconst testPropsAsSyntax = {\n ...testRequiredProps,\n ...testPartialDefaults,\n} as ComponentPropsForApp;\n// InternalProps requires all defaults to be filled in\nconst testCompleteDefaults: Required<ComponentPropsDefaultProps> = {\n as: 'nav',\n label: 'Breadcrumb',\n isTitle: false,\n trailingSlash: true,\n containerProps: {},\n};\nconst testInternalProps: ComponentPropsInternals = {\n ...testRequiredProps,\n ...testCompleteDefaults,\n};\nconst testInternalPropsAsSyntax = {\n ...testRequiredProps,\n ...testCompleteDefaults,\n} as ComponentPropsInternals;\n\n// using the explicit type definition, if there is an error, it will be marked on the key that is wrong\nconst testExplicitDefinition: ComponentPropsForApp = {\n children: [],\n as: 'nav',\n label: 'Breadcrumb',\n isTitle: false,\n trailingSlash: true,\n containerProps: {},\n};\n\n// using the \"as\" syntax, if there is an error, it will be marking the whole object as wrong because it is not compatible with the type\nconst testInferedTypeCompatibility = {\n children: [],\n as: 'nav',\n label: 'Breadcrumb',\n isTitle: false,\n trailingSlash: true,\n containerProps: {},\n} as ComponentPropsForApp;\n\nconst ExampleUsageComponent = () => (\n <>\n {/* works with explicitly casted props, all syntaxes */}\n <DSBreadcrumb {...testExplicitDefinition} />\n <DSBreadcrumb {...testInferedTypeCompatibility} />\n {/* works with inline values */}\n <DSBreadcrumb as=\"nav\" label=\"Breadcrumb\" isTitle={false} trailingSlash containerProps={{}}>\n <DSBreadcrumbItem href=\"/\" label=\"Home\" />\n <DSBreadcrumbItem href=\"/home\" label=\"Home2\" />\n </DSBreadcrumb>\n </>\n);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAuB;ACoErB;AAnEF,eAA+C;AAS/C,MAAM,oBAAiD;AA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boardNavigation } from "./hooks/useKeyboardNavigation.js";
|
|
7
7
|
import { defaultProps } from "./react-desc-prop-types.js";
|
|
8
8
|
import { StyledContainer, StyledList } from "./styles.js";
|
|
9
|
-
const htmlElements = ["nav", "div"
|
|
9
|
+
const htmlElements = ["nav", "div"];
|
|
10
|
+
const NavContainer = (props2) => {
|
|
11
|
+
const { label, containerProps, as, children, ...rest } = props2;
|
|
12
|
+
return /* @__PURE__ */ jsx(StyledContainer, { "aria-label": label, ...rest, ...containerProps, as, children: /* @__PURE__ */ jsx(StyledList, { "data-testid": "list-container", children }) });
|
|
13
|
+
};
|
|
14
|
+
const DivContainer = (props2) => {
|
|
15
|
+
const { label, containerProps, as, children, ...rest } = props2;
|
|
16
|
+
return /* @__PURE__ */ jsx(StyledContainer, { ...rest, ...containerProps, as, children: /* @__PURE__ */ jsx(StyledList, { "data-testid": "list-container", "aria-label": label, children }) });
|
|
17
|
+
};
|
|
10
18
|
const DSBreadcrumb = (props2) => {
|
|
11
19
|
const propsWithDefaults = useMemoMergePropsWithDefault(props2, defaultProps);
|
|
12
20
|
const { containerProps, as, label, trailingSlash, isTitle, children, ...rest } = propsWithDefaults;
|
|
13
|
-
const [addRef, onKeyDown] = useKeyboardNavigation();
|
|
21
|
+
const [addRef, onKeyDown] = useKeyboardNavigation({ isTitle });
|
|
14
22
|
const safeElement = useMemo(() => htmlElements.indexOf(as) > -1 ? as : "nav", [as]);
|
|
23
|
+
const Container = as === "nav" ? NavContainer : DivContainer;
|
|
15
24
|
return /* @__PURE__ */ jsx(
|
|
16
|
-
|
|
25
|
+
Container,
|
|
17
26
|
{
|
|
18
27
|
"data-testid": "breadcrumb-nav-container",
|
|
19
|
-
|
|
28
|
+
label,
|
|
20
29
|
...rest,
|
|
21
|
-
|
|
30
|
+
containerProps,
|
|
22
31
|
as: safeElement,
|
|
23
|
-
children:
|
|
32
|
+
children: React2.Children.map(
|
|
24
33
|
children,
|
|
25
34
|
(child, childIndex) => childIndex < children.length - 1 ? cloneElement(child, {
|
|
26
35
|
childIndex,
|
|
@@ -33,7 +42,7 @@ const DSBreadcrumb = (props2) => {
|
|
|
33
42
|
trailingSlash,
|
|
34
43
|
isTitle
|
|
35
44
|
})
|
|
36
|
-
)
|
|
45
|
+
)
|
|
37
46
|
}
|
|
38
47
|
);
|
|
39
48
|
};
|
|
@@ -43,11 +52,9 @@ const props = {
|
|
|
43
52
|
containerProps: PropTypes.object.description("props injected to breadcrumb wrapper"),
|
|
44
53
|
/**
|
|
45
54
|
* Type of element you want the main container to be:
|
|
46
|
-
* 'nav', 'div'
|
|
55
|
+
* 'nav', 'div'
|
|
47
56
|
*/
|
|
48
|
-
as: PropTypes.
|
|
49
|
-
"Type of element you want the main container to be: 'nav', 'div', 'header', 'footer', 'main'"
|
|
50
|
-
),
|
|
57
|
+
as: PropTypes.oneOf(["nav", "div"]).description("Type of element you want the main container to be: 'nav' or 'div'. Defaults to 'nav'.").defaultValue("nav"),
|
|
51
58
|
/**
|
|
52
59
|
* Whether to show the last element of the breadcrumb as a title
|
|
53
60
|
* Also removes trailing slash to show last element as title
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/DSBreadcrumb.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, {
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { cloneElement, useMemo } from 'react';\nimport { PropTypes, describe, useMemoMergePropsWithDefault, type ValidationMap } from '@elliemae/ds-props-helpers';\nimport DSBreadcrumbItem from './DSBreadcrumbItem.js';\nimport { useKeyboardNavigation } from './hooks/useKeyboardNavigation.js';\nimport type { DSBreadcrumbT } from './react-desc-prop-types.js';\nimport { defaultProps } from './react-desc-prop-types.js';\nimport { StyledContainer, StyledList } from './styles.js';\n\nconst htmlElements = ['nav', 'div'] as const;\n\ntype ContainerProps = Omit<DSBreadcrumbT.InternalProps, 'isTitle' | 'trailingSlash'>;\n\nconst NavContainer = (props: ContainerProps) => {\n const { label, containerProps, as, children, ...rest } = props;\n return (\n <StyledContainer aria-label={label} {...rest} {...containerProps} as={as}>\n <StyledList data-testid=\"list-container\">{children}</StyledList>\n </StyledContainer>\n );\n};\n\nconst DivContainer = (props: ContainerProps) => {\n const { label, containerProps, as, children, ...rest } = props;\n return (\n <StyledContainer {...rest} {...containerProps} as={as}>\n <StyledList data-testid=\"list-container\" aria-label={label}>\n {children}\n </StyledList>\n </StyledContainer>\n );\n};\n\nconst DSBreadcrumb = (props: DSBreadcrumbT.Props) => {\n const propsWithDefaults = useMemoMergePropsWithDefault<DSBreadcrumbT.InternalProps>(props, defaultProps);\n const { containerProps, as, label, trailingSlash, isTitle, children, ...rest } = propsWithDefaults;\n const [addRef, onKeyDown] = useKeyboardNavigation({ isTitle });\n\n const safeElement = useMemo(() => (htmlElements.indexOf(as) > -1 ? as : 'nav'), [as]);\n\n const Container = as === 'nav' ? NavContainer : DivContainer;\n\n return (\n <Container\n data-testid=\"breadcrumb-nav-container\"\n label={label}\n {...rest}\n containerProps={containerProps}\n as={safeElement}\n >\n {React.Children.map(children, (child: React.ReactElement, childIndex) =>\n childIndex < children.length - 1\n ? cloneElement(child, {\n childIndex,\n addRef,\n onKeyDown,\n })\n : cloneElement(child, {\n childIndex,\n addRef,\n onKeyDown,\n trailingSlash,\n isTitle,\n }),\n )}\n </Container>\n );\n};\n\nDSBreadcrumb.Item = DSBreadcrumbItem;\n\nconst props = {\n /** props injected to breadcrumb wrapper */\n containerProps: PropTypes.object.description('props injected to breadcrumb wrapper'),\n /**\n * Type of element you want the main container to be:\n * 'nav', 'div'\n */\n as: PropTypes.oneOf(['nav', 'div'])\n .description(\"Type of element you want the main container to be: 'nav' or 'div'. Defaults to 'nav'.\")\n .defaultValue('nav'),\n /**\n * Whether to show the last element of the breadcrumb as a title\n * Also removes trailing slash to show last element as title\n */\n isTitle: PropTypes.bool.description(\n 'Whether to show the last element of the breadcrumb as a title. Also removes trailing slash to show last element as title',\n ),\n /** breadcrumb label */\n label: PropTypes.string.description('breadcrumb label'),\n /**\n * Container items to wrap\n */\n children: PropTypes.arrayOf(PropTypes.element).isRequired.description('Container items to wrap'),\n};\n\nDSBreadcrumb.displayName = 'DSBreadcrumb';\nconst DSBreadcrumbWithSchema = describe(DSBreadcrumb);\nDSBreadcrumbWithSchema.propTypes = props as ValidationMap<unknown>;\n\nexport { DSBreadcrumb, DSBreadcrumbWithSchema, htmlElements };\nexport default DSBreadcrumb;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACgBjB;AAhBN,OAAOA,UAAS,cAAc,eAAe;AAC7C,SAAS,WAAW,UAAU,oCAAwD;AACtF,OAAO,sBAAsB;AAC7B,SAAS,6BAA6B;AAEtC,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB,kBAAkB;AAE5C,MAAM,eAAe,CAAC,OAAO,KAAK;AAIlC,MAAM,eAAe,CAACC,WAA0B;AAC9C,QAAM,EAAE,OAAO,gBAAgB,IAAI,UAAU,GAAG,KAAK,IAAIA;AACzD,SACE,oBAAC,mBAAgB,cAAY,OAAQ,GAAG,MAAO,GAAG,gBAAgB,IAChE,8BAAC,cAAW,eAAY,kBAAkB,UAAS,GACrD;AAEJ;AAEA,MAAM,eAAe,CAACA,WAA0B;AAC9C,QAAM,EAAE,OAAO,gBAAgB,IAAI,UAAU,GAAG,KAAK,IAAIA;AACzD,SACE,oBAAC,mBAAiB,GAAG,MAAO,GAAG,gBAAgB,IAC7C,8BAAC,cAAW,eAAY,kBAAiB,cAAY,OAClD,UACH,GACF;AAEJ;AAEA,MAAM,eAAe,CAACA,WAA+B;AACnD,QAAM,oBAAoB,6BAA0DA,QAAO,YAAY;AACvG,QAAM,EAAE,gBAAgB,IAAI,OAAO,eAAe,SAAS,UAAU,GAAG,KAAK,IAAI;AACjF,QAAM,CAAC,QAAQ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
import React2 from "react";
|
|
3
4
|
import { PropTypes, describe, useMemoMergePropsWithDefault } from "@elliemae/ds-props-helpers";
|
|
4
5
|
import { defaultItemProps } from "./react-desc-prop-types.js";
|
|
5
6
|
import { StyledLink, StyledCrumbWrapper } from "./styles.js";
|
|
6
7
|
const DSBreadcrumbItem = (props2) => {
|
|
7
8
|
const propsWithDefaults = useMemoMergePropsWithDefault(props2, defaultItemProps);
|
|
8
9
|
const { as, active, href, onClick, onKeyDown, addRef, isTitle, trailingSlash, label, childIndex, color, ...rest } = propsWithDefaults;
|
|
10
|
+
const ariaCurrent = React2.useMemo(() => {
|
|
11
|
+
if (active) {
|
|
12
|
+
return as === "button" ? "step" : "page";
|
|
13
|
+
}
|
|
14
|
+
return void 0;
|
|
15
|
+
}, [active, as]);
|
|
16
|
+
const handleOnClick = React2.useCallback(
|
|
17
|
+
(e) => {
|
|
18
|
+
if (isTitle) return;
|
|
19
|
+
onClick(e);
|
|
20
|
+
},
|
|
21
|
+
[isTitle, onClick]
|
|
22
|
+
);
|
|
9
23
|
return /* @__PURE__ */ jsx(
|
|
10
24
|
StyledCrumbWrapper,
|
|
11
25
|
{
|
|
12
|
-
"aria-current":
|
|
26
|
+
"aria-current": ariaCurrent,
|
|
13
27
|
"data-testid": "breadcrumb-item-container",
|
|
14
28
|
isTitle,
|
|
15
29
|
trailingSlash,
|
|
16
30
|
children: /* @__PURE__ */ jsx(
|
|
17
31
|
StyledLink,
|
|
18
32
|
{
|
|
33
|
+
"data-testid": "breadcrumb-item-content",
|
|
19
34
|
variant: "link",
|
|
20
35
|
component: as,
|
|
21
36
|
href,
|
|
22
|
-
onClick,
|
|
23
|
-
tabIndex: 0,
|
|
37
|
+
onClick: handleOnClick,
|
|
38
|
+
tabIndex: isTitle ? -1 : 0,
|
|
24
39
|
active,
|
|
25
|
-
onKeyDown: (e) => onKeyDown(e, childIndex ?? -1,
|
|
40
|
+
onKeyDown: (e) => onKeyDown(e, childIndex ?? -1, handleOnClick),
|
|
26
41
|
isTitle,
|
|
27
42
|
color,
|
|
28
43
|
innerRef: addRef,
|
|
@@ -34,22 +49,25 @@ const DSBreadcrumbItem = (props2) => {
|
|
|
34
49
|
);
|
|
35
50
|
};
|
|
36
51
|
const props = {
|
|
37
|
-
/**
|
|
38
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Type of element you want the item to be:
|
|
54
|
+
* 'a', 'button'
|
|
55
|
+
*/
|
|
56
|
+
as: PropTypes.oneOf(["a", "button"]).description('Type of element you want the item to be: "a" or "button". Defaults to "a"').defaultValue("a"),
|
|
39
57
|
/** active item */
|
|
40
|
-
active: PropTypes.bool.description("
|
|
58
|
+
active: PropTypes.bool.description("Active item"),
|
|
41
59
|
/** href link */
|
|
42
|
-
href: PropTypes.string.description("
|
|
60
|
+
href: PropTypes.string.description("Href link"),
|
|
43
61
|
/** on click handler */
|
|
44
|
-
onClick: PropTypes.func.description("
|
|
62
|
+
onClick: PropTypes.func.description("On click handler"),
|
|
45
63
|
/** style item as title */
|
|
46
|
-
isTitle: PropTypes.bool.description("
|
|
64
|
+
isTitle: PropTypes.bool.description("Style item as title"),
|
|
47
65
|
/** add trailing slash */
|
|
48
|
-
trailingSlash: PropTypes.bool.description("
|
|
66
|
+
trailingSlash: PropTypes.bool.description("Add trailing slash"),
|
|
49
67
|
/** item label */
|
|
50
|
-
label: PropTypes.string.description("
|
|
68
|
+
label: PropTypes.string.description("Item label"),
|
|
51
69
|
/** link color */
|
|
52
|
-
color: PropTypes.string.description("
|
|
70
|
+
color: PropTypes.string.description("Link color")
|
|
53
71
|
};
|
|
54
72
|
DSBreadcrumbItem.displayName = "DSBreadcrumbItem";
|
|
55
73
|
const DSBreadcrumbItemWithSchema = describe(DSBreadcrumbItem);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/DSBreadcrumbItem.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
6
|
-
"names": ["props"]
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { PropTypes, describe, useMemoMergePropsWithDefault, type ValidationMap } from '@elliemae/ds-props-helpers';\nimport type { DSBreadcrumbItemT } from './react-desc-prop-types.js';\nimport { defaultItemProps } from './react-desc-prop-types.js';\n\nimport { StyledLink, StyledCrumbWrapper } from './styles.js';\n\nconst DSBreadcrumbItem = (props: DSBreadcrumbItemT.Props) => {\n const propsWithDefaults = useMemoMergePropsWithDefault<DSBreadcrumbItemT.InternalProps>(props, defaultItemProps);\n const { as, active, href, onClick, onKeyDown, addRef, isTitle, trailingSlash, label, childIndex, color, ...rest } =\n propsWithDefaults;\n\n const ariaCurrent = React.useMemo(() => {\n if (active) {\n return as === 'button' ? 'step' : 'page';\n }\n return undefined;\n }, [active, as]);\n\n const handleOnClick = React.useCallback(\n (e: React.MouseEvent) => {\n if (isTitle) return;\n onClick(e);\n },\n [isTitle, onClick],\n );\n\n return (\n <StyledCrumbWrapper\n aria-current={ariaCurrent}\n data-testid=\"breadcrumb-item-container\"\n isTitle={isTitle}\n trailingSlash={trailingSlash}\n >\n <StyledLink\n data-testid=\"breadcrumb-item-content\"\n variant=\"link\"\n component={as}\n href={href}\n onClick={handleOnClick}\n tabIndex={isTitle ? -1 : 0}\n active={active}\n onKeyDown={(e: React.KeyboardEvent) => onKeyDown(e, childIndex ?? -1, handleOnClick)}\n isTitle={isTitle}\n color={color}\n innerRef={addRef}\n {...rest}\n >\n {label}\n </StyledLink>\n </StyledCrumbWrapper>\n );\n};\n\nconst props = {\n /**\n * Type of element you want the item to be:\n * 'a', 'button'\n */\n as: PropTypes.oneOf(['a', 'button'])\n .description('Type of element you want the item to be: \"a\" or \"button\". Defaults to \"a\"')\n .defaultValue('a'),\n /** active item */\n active: PropTypes.bool.description('Active item'),\n /** href link */\n href: PropTypes.string.description('Href link'),\n /** on click handler */\n onClick: PropTypes.func.description('On click handler'),\n /** style item as title */\n isTitle: PropTypes.bool.description('Style item as title'),\n /** add trailing slash */\n trailingSlash: PropTypes.bool.description('Add trailing slash'),\n /** item label */\n label: PropTypes.string.description('Item label'),\n /** link color */\n color: PropTypes.string.description('Link color'),\n};\n\nDSBreadcrumbItem.displayName = 'DSBreadcrumbItem';\nconst DSBreadcrumbItemWithSchema = describe(DSBreadcrumbItem);\nDSBreadcrumbItemWithSchema.propTypes = props as ValidationMap<unknown>;\n\nexport { DSBreadcrumbItem, DSBreadcrumbItemWithSchema };\nexport default DSBreadcrumbItem;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACkCjB;AAlCN,OAAOA,YAAW;AAClB,SAAS,WAAW,UAAU,oCAAwD;AAEtF,SAAS,wBAAwB;AAEjC,SAAS,YAAY,0BAA0B;AAE/C,MAAM,mBAAmB,CAACC,WAAmC;AAC3D,QAAM,oBAAoB,6BAA8DA,QAAO,gBAAgB;AAC/G,QAAM,EAAE,IAAI,QAAQ,MAAM,SAAS,WAAW,QAAQ,SAAS,eAAe,OAAO,YAAY,OAAO,GAAG,KAAK,IAC9G;AAEF,QAAM,cAAcD,OAAM,QAAQ,MAAM;AACtC,QAAI,QAAQ;AACV,aAAO,OAAO,WAAW,SAAS;AAAA,IACpC;AACA,WAAO;AAAA,EACT,GAAG,CAAC,QAAQ,EAAE,CAAC;AAEf,QAAM,gBAAgBA,OAAM;AAAA,IAC1B,CAAC,MAAwB;AACvB,UAAI,QAAS;AACb,cAAQ,CAAC;AAAA,IACX;AAAA,IACA,CAAC,SAAS,OAAO;AAAA,EACnB;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,gBAAc;AAAA,MACd,eAAY;AAAA,MACZ;AAAA,MACA;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACC,eAAY;AAAA,UACZ,SAAQ;AAAA,UACR,WAAW;AAAA,UACX;AAAA,UACA,SAAS;AAAA,UACT,UAAU,UAAU,KAAK;AAAA,UACzB;AAAA,UACA,WAAW,CAAC,MAA2B,UAAU,GAAG,cAAc,IAAI,aAAa;AAAA,UACnF;AAAA,UACA;AAAA,UACA,UAAU;AAAA,UACT,GAAG;AAAA,UAEH;AAAA;AAAA,MACH;AAAA;AAAA,EACF;AAEJ;AAEA,MAAM,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA,EAKZ,IAAI,UAAU,MAAM,CAAC,KAAK,QAAQ,CAAC,EAChC,YAAY,2EAA2E,EACvF,aAAa,GAAG;AAAA;AAAA,EAEnB,QAAQ,UAAU,KAAK,YAAY,aAAa;AAAA;AAAA,EAEhD,MAAM,UAAU,OAAO,YAAY,WAAW;AAAA;AAAA,EAE9C,SAAS,UAAU,KAAK,YAAY,kBAAkB;AAAA;AAAA,EAEtD,SAAS,UAAU,KAAK,YAAY,qBAAqB;AAAA;AAAA,EAEzD,eAAe,UAAU,KAAK,YAAY,oBAAoB;AAAA;AAAA,EAE9D,OAAO,UAAU,OAAO,YAAY,YAAY;AAAA;AAAA,EAEhD,OAAO,UAAU,OAAO,YAAY,YAAY;AAClD;AAEA,iBAAiB,cAAc;AAC/B,MAAM,6BAA6B,SAAS,gBAAgB;AAC5D,2BAA2B,YAAY;AAGvC,IAAO,2BAAQ;",
|
|
6
|
+
"names": ["React", "props"]
|
|
7
7
|
}
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { useRef, useCallback } from "react";
|
|
3
|
-
const useKeyboardNavigation = () => {
|
|
3
|
+
const useKeyboardNavigation = ({ isTitle }) => {
|
|
4
4
|
const componentsRef = useRef([]);
|
|
5
5
|
const addRef = useCallback((ref) => {
|
|
6
6
|
if (ref && !componentsRef.current.includes(ref)) {
|
|
7
7
|
componentsRef.current.push(ref);
|
|
8
8
|
}
|
|
9
9
|
}, []);
|
|
10
|
-
const onKeyDown = useCallback(
|
|
11
|
-
|
|
12
|
-
componentsRef.current[componentRefIndex + 1]
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
const onKeyDown = useCallback(
|
|
11
|
+
(e, componentRefIndex, callback) => {
|
|
12
|
+
if (e.key === "ArrowDown" && componentsRef.current[componentRefIndex + 1]) {
|
|
13
|
+
if (isTitle && componentRefIndex + 1 === componentsRef.current.length - 1) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
componentsRef.current[componentRefIndex + 1].focus();
|
|
17
|
+
e.preventDefault();
|
|
18
|
+
} else if (e.key === "ArrowUp" && componentRefIndex !== 0) {
|
|
19
|
+
componentsRef.current[componentRefIndex - 1].focus();
|
|
20
|
+
e.preventDefault();
|
|
21
|
+
} else if (e.key === "Enter" || e.ctrlKey && e.altKey && e.code === "Space") {
|
|
22
|
+
callback(e);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
[isTitle]
|
|
26
|
+
);
|
|
21
27
|
return [addRef, onKeyDown];
|
|
22
28
|
};
|
|
23
29
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useKeyboardNavigation.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\n/* eslint-disable max-params */\nimport type React from 'react';\nimport { useRef, useCallback } from 'react';\n\nexport const useKeyboardNavigation = ({ isTitle }: { isTitle: boolean }) => {\n const componentsRef = useRef<HTMLAnchorElement[]>([]);\n\n const addRef = useCallback((ref: HTMLAnchorElement) => {\n if (ref && !componentsRef.current.includes(ref)) {\n componentsRef.current.push(ref);\n }\n }, []);\n\n const onKeyDown = useCallback(\n (\n e: React.KeyboardEvent,\n componentRefIndex: number,\n callback: (e: React.MouseEvent | React.KeyboardEvent) => void,\n ) => {\n if (e.key === 'ArrowDown' && componentsRef.current[componentRefIndex + 1]) {\n if (isTitle && componentRefIndex + 1 === componentsRef.current.length - 1) {\n // If the 'isTitle' flag is set to true, the last link is not an interactive link so we do not focus it\n return;\n }\n componentsRef.current[componentRefIndex + 1].focus();\n e.preventDefault();\n } else if (e.key === 'ArrowUp' && componentRefIndex !== 0) {\n componentsRef.current[componentRefIndex - 1].focus();\n e.preventDefault();\n } else if (e.key === 'Enter' || (e.ctrlKey && e.altKey && e.code === 'Space')) {\n callback(e);\n }\n },\n [isTitle],\n );\n\n return [addRef, onKeyDown];\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACGvB,SAAS,QAAQ,mBAAmB;AAE7B,MAAM,wBAAwB,CAAC,EAAE,QAAQ,MAA4B;AAC1E,QAAM,gBAAgB,OAA4B,CAAC,CAAC;AAEpD,QAAM,SAAS,YAAY,CAAC,QAA2B;AACrD,QAAI,OAAO,CAAC,cAAc,QAAQ,SAAS,GAAG,GAAG;AAC/C,oBAAc,QAAQ,KAAK,GAAG;AAAA,IAChC;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,QAAM,YAAY;AAAA,IAChB,CACE,GACA,mBACA,aACG;AACH,UAAI,EAAE,QAAQ,eAAe,cAAc,QAAQ,oBAAoB,CAAC,GAAG;AACzE,YAAI,WAAW,oBAAoB,MAAM,cAAc,QAAQ,SAAS,GAAG;AAEzE;AAAA,QACF;AACA,sBAAc,QAAQ,oBAAoB,CAAC,EAAE,MAAM;AACnD,UAAE,eAAe;AAAA,MACnB,WAAW,EAAE,QAAQ,aAAa,sBAAsB,GAAG;AACzD,sBAAc,QAAQ,oBAAoB,CAAC,EAAE,MAAM;AACnD,UAAE,eAAe;AAAA,MACnB,WAAW,EAAE,QAAQ,WAAY,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,SAAU;AAC7E,iBAAS,CAAC;AAAA,MACZ;AAAA,IACF;AAAA,IACA,CAAC,OAAO;AAAA,EACV;AAEA,SAAO,CAAC,QAAQ,SAAS;AAC3B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/react-desc-prop-types.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { GlobalAttributesT, XstyledProps } from '@elliemae/ds-props-helpers';\nimport type React from 'react';\nimport type { htmlElements } from './DSBreadcrumb.js';\ntype SafeComponentsT = (typeof htmlElements)[number];\n\ntype SafeItemComponentT = 'a' | 'button'
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { GlobalAttributesT, XstyledProps } from '@elliemae/ds-props-helpers';\nimport type React from 'react';\nimport type { htmlElements } from './DSBreadcrumb.js';\ntype SafeComponentsT = (typeof htmlElements)[number];\n\ntype SafeItemComponentT = 'a' | 'button';\n\nexport const defaultProps: DSBreadcrumbT.DefaultProps = {\n containerProps: {},\n as: 'nav',\n label: 'Breadcrumb',\n isTitle: false,\n trailingSlash: true,\n};\n\nexport const defaultItemProps: DSBreadcrumbItemT.DefaultProps = {\n active: false,\n as: 'a',\n onKeyDown: () => null,\n onClick: () => null,\n label: '',\n childIndex: -1,\n};\n\ndeclare namespace DSBreadcrumbT {\n export interface DefaultProps {\n containerProps: Record<string, unknown>;\n as: SafeComponentsT;\n label: string;\n isTitle: boolean;\n trailingSlash: boolean;\n }\n\n export interface RequiredProps {\n children: React.ReactElement[];\n }\n\n export interface Props\n extends Partial<DefaultProps>,\n RequiredProps,\n Omit<GlobalAttributesT, keyof DefaultProps | keyof RequiredProps>,\n XstyledProps {}\n\n export interface InternalProps\n extends DefaultProps,\n RequiredProps,\n Omit<GlobalAttributesT, keyof DefaultProps | keyof RequiredProps>,\n XstyledProps {}\n}\n\ndeclare namespace DSBreadcrumbItemT {\n export interface DefaultProps {\n active: boolean;\n as: SafeItemComponentT;\n onKeyDown: (e: React.KeyboardEvent, componentRefIndex: number, onClick: (e: React.MouseEvent) => void) => void;\n onClick: (e: React.MouseEvent) => void;\n label: string;\n childIndex: number;\n }\n\n export interface OptionalProps {\n addRef?: React.MutableRefObject<HTMLDivElement | null> | React.RefCallback<HTMLDivElement>;\n color?: string;\n href?: string;\n isTitle?: boolean;\n trailingSlash?: boolean;\n }\n\n export interface Props\n extends Partial<DefaultProps>,\n OptionalProps,\n Omit<GlobalAttributesT, keyof DefaultProps | keyof OptionalProps>,\n XstyledProps {}\n\n export interface InternalProps\n extends DefaultProps,\n OptionalProps,\n Omit<GlobalAttributesT, keyof DefaultProps | keyof OptionalProps>,\n XstyledProps {}\n}\n\nexport type { DSBreadcrumbItemT, DSBreadcrumbT, SafeComponentsT, SafeItemComponentT };\n"],
|
|
5
5
|
"mappings": "AAAA,YAAY,WAAW;ACOhB,MAAM,eAA2C;AAAA,EACtD,gBAAgB,CAAC;AAAA,EACjB,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,SAAS;AAAA,EACT,eAAe;AACjB;AAEO,MAAM,mBAAmD;AAAA,EAC9D,QAAQ;AAAA,EACR,IAAI;AAAA,EACJ,WAAW,MAAM;AAAA,EACjB,SAAS,MAAM;AAAA,EACf,OAAO;AAAA,EACP,YAAY;AACd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/styles.js
CHANGED
|
@@ -61,13 +61,20 @@ const StyledLink = styled(DSTypography)`
|
|
|
61
61
|
font-weight: ${({ theme }) => theme.fontWeights.regular};
|
|
62
62
|
color: ${({ theme, active, color = "", isTitle }) => handleColor(theme, !!active, color, !!isTitle)};
|
|
63
63
|
&:hover {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
${({ theme, color, isTitle }) => isTitle ? `
|
|
65
|
+
color: ${theme.colors.neutral[700]};
|
|
66
|
+
cursor: default;` : `
|
|
67
|
+
color: ${color || theme.colors.brand[800]};
|
|
68
|
+
cursor: pointer;
|
|
69
|
+
-webkit-text-stroke: 0.4px ${color || theme.colors.brand[800]};
|
|
70
|
+
`}
|
|
67
71
|
}
|
|
68
72
|
&:focus {
|
|
69
|
-
${({ theme }) =>
|
|
70
|
-
|
|
73
|
+
${({ theme, isTitle }) => isTitle ? `
|
|
74
|
+
color: ${theme.colors.neutral[700]};` : `
|
|
75
|
+
border: 2px solid ${theme.colors.brand[700]};
|
|
76
|
+
border-radius: 2px;
|
|
77
|
+
`}
|
|
71
78
|
}
|
|
72
79
|
`;
|
|
73
80
|
export {
|
package/dist/esm/styles.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/styles.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-params */\nimport type { Theme } from '@elliemae/pui-theme';\nimport { styled } from '@elliemae/ds-system';\nimport { DSTypography } from '@elliemae/ds-typography';\nimport type { DSBreadcrumbItemT } from './react-desc-prop-types.js';\n\nconst handleColor = (theme: Theme, isActive: boolean, color: string, isTitle: boolean): string => {\n if (isActive) return theme.colors.neutral[800];\n if (color) return color;\n if (isTitle) return theme.colors.neutral[700];\n return theme.colors.brand[600];\n};\n\nconst StyledList = styled.ol`\n width: 100%;\n list-style: none;\n display: flex;\n padding: 0;\n margin: 0;\n li:first-child * {\n margin-left: 0;\n }\n`;\n\nconst StyledCrumbWrapper = styled.li<Partial<DSBreadcrumbItemT.Props>>`\n display: inline-flex;\n align-items: center;\n flex-shrink: 20;\n transition: flex-shrink 0.1s cubic-bezier(0.64, 0, 0.35, 1);\n min-height: 1.231rem;\n min-width: 10px;\n &:focus-within {\n flex-shrink: 0;\n }\n &:hover {\n flex-shrink: 0;\n }\n ${({ theme, isTitle, trailingSlash }) =>\n isTitle || !trailingSlash\n ? `&:not(:last-child):after {\n display: inline-block;\n content: '/';\n color: ${theme.colors.neutral[700]};\n }\n `\n : `&:after {\n display: inline-block;\n content: '/';\n color: ${theme.colors.neutral[700]};\n }\n `}\n`;\n\nconst StyledContainer = styled.nav`\n display: flex;\n align-items: center;\n padding: 0;\n`;\n\nconst StyledLink = styled(DSTypography)<Partial<DSBreadcrumbItemT.Props>>`\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n text-decoration: none;\n outline: none;\n margin: 0 2px;\n border: 2px solid transparent;\n -webkit-text-stroke: 0.4px transparent;\n line-height: 1.5385rem;\n background: transparent;\n font-weight: ${({ theme }) => theme.fontWeights.regular};\n color: ${({ theme, active, color = '', isTitle }) => handleColor(theme, !!active, color, !!isTitle)};\n &:hover {\n
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACEvB,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAG7B,MAAM,cAAc,CAAC,OAAc,UAAmB,OAAe,YAA6B;AAChG,MAAI,SAAU,QAAO,MAAM,OAAO,QAAQ,GAAG;AAC7C,MAAI,MAAO,QAAO;AAClB,MAAI,QAAS,QAAO,MAAM,OAAO,QAAQ,GAAG;AAC5C,SAAO,MAAM,OAAO,MAAM,GAAG;AAC/B;AAEA,MAAM,aAAa,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAW1B,MAAM,qBAAqB,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAa9B,CAAC,EAAE,OAAO,SAAS,cAAc,MACjC,WAAW,CAAC,gBACR;AAAA;AAAA;AAAA,aAGK,MAAM,OAAO,QAAQ,GAAG,CAAC;AAAA;AAAA,MAG9B;AAAA;AAAA;AAAA,aAGK,MAAM,OAAO,QAAQ,GAAG,CAAC;AAAA;AAAA,GAEnC;AAAA;AAGH,MAAM,kBAAkB,OAAO;AAAA;AAAA;AAAA;AAAA;AAM/B,MAAM,aAAa,OAAO,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAWrB,CAAC,EAAE,MAAM,MAAM,MAAM,YAAY,OAAO;AAAA,WAC9C,CAAC,EAAE,OAAO,QAAQ,QAAQ,IAAI,QAAQ,MAAM,YAAY,OAAO,CAAC,CAAC,QAAQ,OAAO,CAAC,CAAC,OAAO,CAAC;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-params */\nimport type { Theme } from '@elliemae/pui-theme';\nimport { styled } from '@elliemae/ds-system';\nimport { DSTypography } from '@elliemae/ds-typography';\nimport type { DSBreadcrumbItemT } from './react-desc-prop-types.js';\n\nconst handleColor = (theme: Theme, isActive: boolean, color: string, isTitle: boolean): string => {\n if (isActive) return theme.colors.neutral[800];\n if (color) return color;\n if (isTitle) return theme.colors.neutral[700];\n return theme.colors.brand[600];\n};\n\nconst StyledList = styled.ol`\n width: 100%;\n list-style: none;\n display: flex;\n padding: 0;\n margin: 0;\n li:first-child * {\n margin-left: 0;\n }\n`;\n\nconst StyledCrumbWrapper = styled.li<Partial<DSBreadcrumbItemT.Props>>`\n display: inline-flex;\n align-items: center;\n flex-shrink: 20;\n transition: flex-shrink 0.1s cubic-bezier(0.64, 0, 0.35, 1);\n min-height: 1.231rem;\n min-width: 10px;\n &:focus-within {\n flex-shrink: 0;\n }\n &:hover {\n flex-shrink: 0;\n }\n ${({ theme, isTitle, trailingSlash }) =>\n isTitle || !trailingSlash\n ? `&:not(:last-child):after {\n display: inline-block;\n content: '/';\n color: ${theme.colors.neutral[700]};\n }\n `\n : `&:after {\n display: inline-block;\n content: '/';\n color: ${theme.colors.neutral[700]};\n }\n `}\n`;\n\nconst StyledContainer = styled.nav`\n display: flex;\n align-items: center;\n padding: 0;\n`;\n\nconst StyledLink = styled(DSTypography)<Partial<DSBreadcrumbItemT.Props>>`\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n text-decoration: none;\n outline: none;\n margin: 0 2px;\n border: 2px solid transparent;\n -webkit-text-stroke: 0.4px transparent;\n line-height: 1.5385rem;\n background: transparent;\n font-weight: ${({ theme }) => theme.fontWeights.regular};\n color: ${({ theme, active, color = '', isTitle }) => handleColor(theme, !!active, color, !!isTitle)};\n &:hover {\n ${({ theme, color, isTitle }) =>\n isTitle\n ? `\n color: ${theme.colors.neutral[700]};\n cursor: default;`\n : `\n color: ${color || theme.colors.brand[800]};\n cursor: pointer;\n -webkit-text-stroke: 0.4px ${color || theme.colors.brand[800]};\n `}\n }\n &:focus {\n ${({ theme, isTitle }) =>\n isTitle\n ? `\n color: ${theme.colors.neutral[700]};`\n : `\n border: 2px solid ${theme.colors.brand[700]};\n border-radius: 2px;\n `}\n }\n`;\n\nexport { StyledList, StyledCrumbWrapper, StyledContainer, StyledLink };\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACEvB,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAG7B,MAAM,cAAc,CAAC,OAAc,UAAmB,OAAe,YAA6B;AAChG,MAAI,SAAU,QAAO,MAAM,OAAO,QAAQ,GAAG;AAC7C,MAAI,MAAO,QAAO;AAClB,MAAI,QAAS,QAAO,MAAM,OAAO,QAAQ,GAAG;AAC5C,SAAO,MAAM,OAAO,MAAM,GAAG;AAC/B;AAEA,MAAM,aAAa,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAW1B,MAAM,qBAAqB,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAa9B,CAAC,EAAE,OAAO,SAAS,cAAc,MACjC,WAAW,CAAC,gBACR;AAAA;AAAA;AAAA,aAGK,MAAM,OAAO,QAAQ,GAAG,CAAC;AAAA;AAAA,MAG9B;AAAA;AAAA;AAAA,aAGK,MAAM,OAAO,QAAQ,GAAG,CAAC;AAAA;AAAA,GAEnC;AAAA;AAGH,MAAM,kBAAkB,OAAO;AAAA;AAAA;AAAA;AAAA;AAM/B,MAAM,aAAa,OAAO,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAWrB,CAAC,EAAE,MAAM,MAAM,MAAM,YAAY,OAAO;AAAA,WAC9C,CAAC,EAAE,OAAO,QAAQ,QAAQ,IAAI,QAAQ,MAAM,YAAY,OAAO,CAAC,CAAC,QAAQ,OAAO,CAAC,CAAC,OAAO,CAAC;AAAA;AAAA,MAE/F,CAAC,EAAE,OAAO,OAAO,QAAQ,MACzB,UACI;AAAA,mBACS,MAAM,OAAO,QAAQ,GAAG,CAAC;AAAA,8BAElC;AAAA,mBACS,SAAS,MAAM,OAAO,MAAM,GAAG,CAAC;AAAA;AAAA,uCAEZ,SAAS,MAAM,OAAO,MAAM,GAAG,CAAC;AAAA,KAClE;AAAA;AAAA;AAAA,MAGC,CAAC,EAAE,OAAO,QAAQ,MAClB,UACI;AAAA,kBACQ,MAAM,OAAO,QAAQ,GAAG,CAAC,MACjC;AAAA,4BACkB,MAAM,OAAO,MAAM,GAAG,CAAC;AAAA;AAAA,KAE9C;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/typescript-testing/typescript-breadcrumb-valid.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport { DSBreadcrumb, DSBreadcrumbItem } from '../index.js';\nimport type { DSBreadcrumbT, DSBreadcrumbItemT } from '../index.js';\n\n// test we expose the namespace and the namespace follows our deliverable conventions\ntype ComponentPropsForApp = DSBreadcrumbT.Props;\ntype ComponentPropsInternals = DSBreadcrumbT.InternalProps;\ntype ComponentPropsDefaultProps = DSBreadcrumbT.DefaultProps;\ntype ComponentPropsRequiredProps = DSBreadcrumbT.RequiredProps;\n\nconst testRequiredProps: ComponentPropsRequiredProps = {\n children: [],\n};\n\n// difference Props and InternalProps is that InternalProps has all the default props filled in\n// Props allows for partial defaults\nconst testPartialDefaults: Partial<ComponentPropsDefaultProps> = {\n as: 'nav',\n label: 'Breadcrumb',\n isTitle: false,\n};\n\nconst testProps: ComponentPropsForApp = {\n ...testRequiredProps,\n ...testPartialDefaults,\n};\nconst testPropsAsSyntax = {\n ...testRequiredProps,\n ...testPartialDefaults,\n} as ComponentPropsForApp;\n// InternalProps requires all defaults to be filled in\nconst testCompleteDefaults: Required<ComponentPropsDefaultProps> = {\n as: 'nav',\n label: 'Breadcrumb',\n isTitle: false,\n trailingSlash: true,\n containerProps: {},\n};\nconst testInternalProps: ComponentPropsInternals = {\n ...testRequiredProps,\n ...testCompleteDefaults,\n};\nconst testInternalPropsAsSyntax = {\n ...testRequiredProps,\n ...testCompleteDefaults,\n} as ComponentPropsInternals;\n\n// using the explicit type definition, if there is an error, it will be marked on the key that is wrong\nconst testExplicitDefinition: ComponentPropsForApp = {\n children: [],\n as: 'nav',\n label: 'Breadcrumb',\n isTitle: false,\n trailingSlash: true,\n containerProps: {},\n};\n\n// using the \"as\" syntax, if there is an error, it will be marking the whole object as wrong because it is not compatible with the type\nconst testInferedTypeCompatibility = {\n children: [],\n as: 'nav',\n label: 'Breadcrumb',\n isTitle: false,\n trailingSlash: true,\n containerProps: {},\n} as ComponentPropsForApp;\n\nconst ExampleUsageComponent = () => (\n <>\n {/* works with explicitly casted props, all syntaxes */}\n <DSBreadcrumb {...testExplicitDefinition} />\n <DSBreadcrumb {...testInferedTypeCompatibility} />\n {/* works with inline values */}\n <DSBreadcrumb as=\"nav\" label=\"Breadcrumb\" isTitle={false} trailingSlash
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACoErB,mBAEE,KAGA,YALF;AAnEF,SAAS,cAAc,wBAAwB;AAS/C,MAAM,oBAAiD;AAAA,EACrD,UAAU,CAAC;AACb;AAIA,MAAM,sBAA2D;AAAA,EAC/D,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,SAAS;AACX;AAEA,MAAM,YAAkC;AAAA,EACtC,GAAG;AAAA,EACH,GAAG;AACL;AACA,MAAM,oBAAoB;AAAA,EACxB,GAAG;AAAA,EACH,GAAG;AACL;AAEA,MAAM,uBAA6D;AAAA,EACjE,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,SAAS;AAAA,EACT,eAAe;AAAA,EACf,gBAAgB,CAAC;AACnB;AACA,MAAM,oBAA6C;AAAA,EACjD,GAAG;AAAA,EACH,GAAG;AACL;AACA,MAAM,4BAA4B;AAAA,EAChC,GAAG;AAAA,EACH,GAAG;AACL;AAGA,MAAM,yBAA+C;AAAA,EACnD,UAAU,CAAC;AAAA,EACX,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,SAAS;AAAA,EACT,eAAe;AAAA,EACf,gBAAgB,CAAC;AACnB;AAGA,MAAM,+BAA+B;AAAA,EACnC,UAAU,CAAC;AAAA,EACX,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,SAAS;AAAA,EACT,eAAe;AAAA,EACf,gBAAgB,CAAC;AACnB;AAEA,MAAM,wBAAwB,MAC5B,iCAEE;AAAA,sBAAC,gBAAc,GAAG,wBAAwB;AAAA,EAC1C,oBAAC,gBAAc,GAAG,8BAA8B;AAAA,EAEhD,qBAAC,gBAAa,IAAG,OAAM,OAAM,cAAa,SAAS,OAAO,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport { DSBreadcrumb, DSBreadcrumbItem } from '../index.js';\nimport type { DSBreadcrumbT, DSBreadcrumbItemT } from '../index.js';\n\n// test we expose the namespace and the namespace follows our deliverable conventions\ntype ComponentPropsForApp = DSBreadcrumbT.Props;\ntype ComponentPropsInternals = DSBreadcrumbT.InternalProps;\ntype ComponentPropsDefaultProps = DSBreadcrumbT.DefaultProps;\ntype ComponentPropsRequiredProps = DSBreadcrumbT.RequiredProps;\n\nconst testRequiredProps: ComponentPropsRequiredProps = {\n children: [],\n};\n\n// difference Props and InternalProps is that InternalProps has all the default props filled in\n// Props allows for partial defaults\nconst testPartialDefaults: Partial<ComponentPropsDefaultProps> = {\n as: 'nav',\n label: 'Breadcrumb',\n isTitle: false,\n};\n\nconst testProps: ComponentPropsForApp = {\n ...testRequiredProps,\n ...testPartialDefaults,\n};\nconst testPropsAsSyntax = {\n ...testRequiredProps,\n ...testPartialDefaults,\n} as ComponentPropsForApp;\n// InternalProps requires all defaults to be filled in\nconst testCompleteDefaults: Required<ComponentPropsDefaultProps> = {\n as: 'nav',\n label: 'Breadcrumb',\n isTitle: false,\n trailingSlash: true,\n containerProps: {},\n};\nconst testInternalProps: ComponentPropsInternals = {\n ...testRequiredProps,\n ...testCompleteDefaults,\n};\nconst testInternalPropsAsSyntax = {\n ...testRequiredProps,\n ...testCompleteDefaults,\n} as ComponentPropsInternals;\n\n// using the explicit type definition, if there is an error, it will be marked on the key that is wrong\nconst testExplicitDefinition: ComponentPropsForApp = {\n children: [],\n as: 'nav',\n label: 'Breadcrumb',\n isTitle: false,\n trailingSlash: true,\n containerProps: {},\n};\n\n// using the \"as\" syntax, if there is an error, it will be marking the whole object as wrong because it is not compatible with the type\nconst testInferedTypeCompatibility = {\n children: [],\n as: 'nav',\n label: 'Breadcrumb',\n isTitle: false,\n trailingSlash: true,\n containerProps: {},\n} as ComponentPropsForApp;\n\nconst ExampleUsageComponent = () => (\n <>\n {/* works with explicitly casted props, all syntaxes */}\n <DSBreadcrumb {...testExplicitDefinition} />\n <DSBreadcrumb {...testInferedTypeCompatibility} />\n {/* works with inline values */}\n <DSBreadcrumb as=\"nav\" label=\"Breadcrumb\" isTitle={false} trailingSlash containerProps={{}}>\n <DSBreadcrumbItem href=\"/\" label=\"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Q,OAAM,SAAQ;AAAA,KAC/C;AAAA,GACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DSBreadcrumbT } from './react-desc-prop-types.js';
|
|
2
|
-
declare const htmlElements: readonly ["nav", "div"
|
|
2
|
+
declare const htmlElements: readonly ["nav", "div"];
|
|
3
3
|
declare const DSBreadcrumb: {
|
|
4
4
|
(props: DSBreadcrumbT.Props): import("react/jsx-runtime.js").JSX.Element;
|
|
5
5
|
Item: {
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
export declare const useKeyboardNavigation: (
|
|
2
|
+
export declare const useKeyboardNavigation: ({ isTitle }: {
|
|
3
|
+
isTitle: boolean;
|
|
4
|
+
}) => (((ref: HTMLAnchorElement) => void) | ((e: React.KeyboardEvent, componentRefIndex: number, callback: (e: React.MouseEvent | React.KeyboardEvent) => void) => void))[];
|
|
@@ -2,7 +2,7 @@ import type { GlobalAttributesT, XstyledProps } from '@elliemae/ds-props-helpers
|
|
|
2
2
|
import type React from 'react';
|
|
3
3
|
import type { htmlElements } from './DSBreadcrumb.js';
|
|
4
4
|
type SafeComponentsT = (typeof htmlElements)[number];
|
|
5
|
-
type SafeItemComponentT = 'a' | 'button'
|
|
5
|
+
type SafeItemComponentT = 'a' | 'button';
|
|
6
6
|
export declare const defaultProps: DSBreadcrumbT.DefaultProps;
|
|
7
7
|
export declare const defaultItemProps: DSBreadcrumbItemT.DefaultProps;
|
|
8
8
|
declare namespace DSBreadcrumbT {
|
|
@@ -25,8 +25,8 @@ declare namespace DSBreadcrumbItemT {
|
|
|
25
25
|
interface DefaultProps {
|
|
26
26
|
active: boolean;
|
|
27
27
|
as: SafeItemComponentT;
|
|
28
|
-
onKeyDown: (e: React.KeyboardEvent, componentRefIndex: number, onClick: () => void) => void;
|
|
29
|
-
onClick: () => void;
|
|
28
|
+
onKeyDown: (e: React.KeyboardEvent, componentRefIndex: number, onClick: (e: React.MouseEvent) => void) => void;
|
|
29
|
+
onClick: (e: React.MouseEvent) => void;
|
|
30
30
|
label: string;
|
|
31
31
|
childIndex: number;
|
|
32
32
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-breadcrumb",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.48.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Breadcrumb",
|
|
6
6
|
"files": [
|
|
@@ -52,15 +52,15 @@
|
|
|
52
52
|
"indent": 4
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@elliemae/ds-props-helpers": "3.
|
|
56
|
-
"@elliemae/ds-
|
|
57
|
-
"@elliemae/ds-
|
|
55
|
+
"@elliemae/ds-props-helpers": "3.48.1",
|
|
56
|
+
"@elliemae/ds-system": "3.48.1",
|
|
57
|
+
"@elliemae/ds-typography": "3.48.1"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@elliemae/pui-cli": "9.0.0-next.50",
|
|
61
61
|
"@elliemae/pui-theme": "~2.10.0",
|
|
62
62
|
"styled-components": "~5.3.9",
|
|
63
|
-
"@elliemae/ds-monorepo-devops": "3.
|
|
63
|
+
"@elliemae/ds-monorepo-devops": "3.48.1"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"@elliemae/pui-theme": "~2.10.0",
|