@elliemae/ds-breadcrumb 3.0.0-next.2 → 3.0.0-next.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.
Files changed (44) hide show
  1. package/dist/cjs/DSBreadcrumb.js +121 -0
  2. package/dist/cjs/DSBreadcrumb.js.map +7 -0
  3. package/dist/cjs/DSBreadcrumbItem.js +123 -0
  4. package/dist/cjs/DSBreadcrumbItem.js.map +7 -0
  5. package/dist/cjs/hooks/useKeyboardNavigation.js +57 -0
  6. package/dist/cjs/hooks/useKeyboardNavigation.js.map +7 -0
  7. package/dist/cjs/index.d.js +27 -0
  8. package/dist/cjs/index.d.js.map +7 -0
  9. package/dist/cjs/index.js +37 -0
  10. package/dist/cjs/index.js.map +7 -0
  11. package/dist/cjs/styles.js +107 -0
  12. package/dist/cjs/styles.js.map +7 -0
  13. package/dist/esm/DSBreadcrumb.js +94 -0
  14. package/dist/esm/DSBreadcrumb.js.map +7 -0
  15. package/dist/esm/DSBreadcrumbItem.js +96 -0
  16. package/dist/esm/DSBreadcrumbItem.js.map +7 -0
  17. package/{esm → dist/esm}/hooks/useKeyboardNavigation.js +11 -9
  18. package/dist/esm/hooks/useKeyboardNavigation.js.map +7 -0
  19. package/dist/esm/index.d.js +2 -0
  20. package/dist/esm/index.d.js.map +7 -0
  21. package/dist/esm/index.js +8 -0
  22. package/dist/esm/index.js.map +7 -0
  23. package/dist/esm/styles.js +78 -0
  24. package/dist/esm/styles.js.map +7 -0
  25. package/package.json +35 -26
  26. package/cjs/DSBreadcrumb.js +0 -102
  27. package/cjs/DSBreadcrumbItem.js +0 -98
  28. package/cjs/hooks/useKeyboardNavigation.js +0 -30
  29. package/cjs/index.d.js +0 -2
  30. package/cjs/index.js +0 -15
  31. package/cjs/styles.js +0 -68
  32. package/esm/DSBreadcrumb.js +0 -88
  33. package/esm/DSBreadcrumbItem.js +0 -87
  34. package/esm/index.d.js +0 -1
  35. package/esm/index.js +0 -2
  36. package/esm/styles.js +0 -57
  37. package/types/DSBreadcrumb.d.ts +0 -56
  38. package/types/DSBreadcrumbItem.d.ts +0 -78
  39. package/types/hooks/useKeyboardNavigation.d.ts +0 -2
  40. package/types/index.d.d.ts +0 -27
  41. package/types/index.d.ts +0 -3
  42. package/types/styles.d.ts +0 -6
  43. package/types/tests/DSBreadcrumb.test.d.ts +0 -1
  44. package/types/tests/DSBreadcrumbItem.test.d.ts +0 -1
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSBreadcrumb.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { cloneElement, useMemo } from 'react';\nimport { PropTypes, describe } from 'react-desc';\nimport DSBreadcrumbItem from './DSBreadcrumbItem';\nimport { useKeyboardNavigation } from './hooks/useKeyboardNavigation';\nimport type { DSBreadcrumbPropsT } from './index.d';\nimport { StyledContainer, StyledList } from './styles';\n\nconst htmlElements = ['nav', 'div', 'header', 'footer', 'main'] as const;\n\nconst DSBreadcrumb = ({\n containerProps = {},\n as = 'nav',\n label = 'Breadcrumb',\n isTitle = false,\n children,\n trailingSlash = true,\n ...rest\n}: DSBreadcrumbPropsT): React.ReactElement => {\n const [addRef, onKeyDown] = useKeyboardNavigation();\n\n const safeElement = useMemo(\n () => (htmlElements.indexOf(as) > -1 ? as : 'nav'),\n [as],\n );\n\n return (\n <StyledContainer\n aria-label={label}\n data-testid=\"breadcrumb-nav-container\"\n {...rest}\n {...containerProps}\n as={safeElement}\n >\n <StyledList data-testid=\"list-container\">\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 </StyledList>\n </StyledContainer>\n );\n};\n\nDSBreadcrumb.Item = DSBreadcrumbItem;\n\nconst props = {\n /** props injected to breadcrumb wrapper */\n containerProps: PropTypes.object.description(\n 'props injected to breadcrumb wrapper',\n ),\n /**\n * Type of element you want the main container to be:\n * 'nav', 'div', 'header', 'footer', 'main'\n */\n as: PropTypes.string.description(\n \"Type of element you want the main container to be: 'nav', 'div', 'header', 'footer', 'main'\",\n ),\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(DSBreadcrumbItem).isRequired.description(\n 'Container items to wrap',\n ),\n};\n\nDSBreadcrumb.propTypes = props;\n\nconst DSBreadcrumbWithSchema = describe(DSBreadcrumb);\nDSBreadcrumbWithSchema.propTypes = props;\n\nexport { DSBreadcrumb, DSBreadcrumbWithSchema, htmlElements };\nexport default DSBreadcrumb;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA;AACA;AACA;AACA;AAEA;AAEA,MAAM,eAAe,CAAC,OAAO,OAAO,UAAU,UAAU;AAExD,MAAM,eAAe,CAAC,OAQwB;AARxB,eACpB;AAAA,qBAAiB;AAAA,IACjB,KAAK;AAAA,IACL,QAAQ;AAAA,IACR,UAAU;AAAA,IACV;AAAA,IACA,gBAAgB;AAAA,MANI,IAOjB,iBAPiB,IAOjB;AAAA,IANH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAGA,QAAM,CAAC,QAAQ,aAAa;AAE5B,QAAM,cAAc,QAClB,MAAO,aAAa,QAAQ,MAAM,KAAK,KAAK,OAC5C,CAAC;AAGH,SACE,qCAAC,iBAAD;AAAA,IACE,cAAY;AAAA,IACZ,eAAY;AAAA,KACR,OACA,iBAJN;AAAA,IAKE,IAAI;AAAA,MAEJ,qCAAC,YAAD;AAAA,IAAY,eAAY;AAAA,KACrB,OAAM,SAAS,IAAI,UAAU,CAAC,OAA2B,eACxD,aAAa,SAAS,SAAS,IAC3B,aAAa,OAAO;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,OAEF,aAAa,OAAO;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAQhB,aAAa,OAAO;AAEpB,MAAM,QAAQ;AAAA,EAEZ,gBAAgB,UAAU,OAAO,YAC/B;AAAA,EAMF,IAAI,UAAU,OAAO,YACnB;AAAA,EAMF,SAAS,UAAU,KAAK,YACtB;AAAA,EAGF,OAAO,UAAU,OAAO,YAAY;AAAA,EAIpC,UAAU,UAAU,QAAQ,kBAAkB,WAAW,YACvD;AAAA;AAIJ,aAAa,YAAY;AAEzB,MAAM,yBAAyB,SAAS;AACxC,uBAAuB,YAAY;AAGnC,IAAO,uBAAQ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,96 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ var __objRest = (source, exclude) => {
18
+ var target = {};
19
+ for (var prop in source)
20
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
21
+ target[prop] = source[prop];
22
+ if (source != null && __getOwnPropSymbols)
23
+ for (var prop of __getOwnPropSymbols(source)) {
24
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
25
+ target[prop] = source[prop];
26
+ }
27
+ return target;
28
+ };
29
+ import * as React from "react";
30
+ import React2 from "react";
31
+ import { PropTypes, describe } from "react-desc";
32
+ import { StyledLink, StyledCrumbWrapper } from "./styles";
33
+ function DSBreadcrumbItem(_a) {
34
+ var _b = _a, {
35
+ active = false,
36
+ as = "a",
37
+ href = void 0,
38
+ isTitle,
39
+ onClick = () => null,
40
+ label = "",
41
+ color = null,
42
+ addRef,
43
+ childIndex,
44
+ trailingSlash,
45
+ onKeyDown = () => null
46
+ } = _b, rest = __objRest(_b, [
47
+ "active",
48
+ "as",
49
+ "href",
50
+ "isTitle",
51
+ "onClick",
52
+ "label",
53
+ "color",
54
+ "addRef",
55
+ "childIndex",
56
+ "trailingSlash",
57
+ "onKeyDown"
58
+ ]);
59
+ return /* @__PURE__ */ React2.createElement(StyledCrumbWrapper, __spreadValues({
60
+ "aria-current": active ? "page" : void 0,
61
+ "data-testid": "breadcrumb-item-container",
62
+ isTitle,
63
+ trailingSlash
64
+ }, rest), /* @__PURE__ */ React2.createElement(StyledLink, {
65
+ as,
66
+ href,
67
+ onClick,
68
+ ref: addRef,
69
+ tabIndex: 0,
70
+ isActive: active,
71
+ onKeyDown: (e) => onKeyDown(e, childIndex, onClick),
72
+ isTitle,
73
+ color
74
+ }, label));
75
+ }
76
+ const props = {
77
+ containerComponent: PropTypes.string.description("inject props to wrapper"),
78
+ as: PropTypes.string.description("render as any html node"),
79
+ active: PropTypes.bool.description("active item"),
80
+ href: PropTypes.string.description("href link"),
81
+ onClick: PropTypes.func.description("on click handler"),
82
+ isTitle: PropTypes.bool.description("style item as title"),
83
+ trailingSlash: PropTypes.bool.description("add trailing slash"),
84
+ label: PropTypes.string.description("item label"),
85
+ color: PropTypes.string.description("link color")
86
+ };
87
+ DSBreadcrumbItem.propTypes = props;
88
+ const DSBreadcrumbItemWithSchema = describe(DSBreadcrumbItem);
89
+ DSBreadcrumbItemWithSchema.propTypes = props;
90
+ var DSBreadcrumbItem_default = DSBreadcrumbItem;
91
+ export {
92
+ DSBreadcrumbItem,
93
+ DSBreadcrumbItemWithSchema,
94
+ DSBreadcrumbItem_default as default
95
+ };
96
+ //# sourceMappingURL=DSBreadcrumbItem.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSBreadcrumbItem.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { PropTypes, describe } from 'react-desc';\nimport type { DSBreadcrumbItemPropsT } from './index.d';\nimport { StyledLink, StyledCrumbWrapper } from './styles';\n\nfunction DSBreadcrumbItem({\n active = false,\n as = 'a',\n href = undefined,\n isTitle,\n onClick = () => null,\n label = '',\n color = null,\n addRef,\n childIndex,\n trailingSlash,\n onKeyDown = () => null,\n ...rest\n}: DSBreadcrumbItemPropsT): React.ReactElement {\n return (\n <StyledCrumbWrapper\n aria-current={active ? 'page' : undefined}\n data-testid=\"breadcrumb-item-container\"\n isTitle={isTitle}\n trailingSlash={trailingSlash}\n {...rest}\n >\n <StyledLink\n as={as}\n href={href}\n onClick={onClick}\n ref={addRef}\n tabIndex={0}\n isActive={active}\n onKeyDown={(e: React.KeyboardEvent) =>\n onKeyDown(e, childIndex, onClick)\n }\n isTitle={isTitle}\n color={color}\n >\n {label}\n </StyledLink>\n </StyledCrumbWrapper>\n );\n}\n\nconst props = {\n /** inject props to wrapper */\n containerComponent: PropTypes.string.description('inject props to wrapper'),\n /** render as any html node */\n as: PropTypes.string.description('render as any html node'),\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.propTypes = props;\n\nconst DSBreadcrumbItemWithSchema = describe(DSBreadcrumbItem);\nDSBreadcrumbItemWithSchema.propTypes = props;\n\nexport { DSBreadcrumbItem, DSBreadcrumbItemWithSchema };\nexport default DSBreadcrumbItem;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA;AACA;AAEA;AAEA,0BAA0B,IAaqB;AAbrB,eACxB;AAAA,aAAS;AAAA,IACT,KAAK;AAAA,IACL,OAAO;AAAA,IACP;AAAA,IACA,UAAU,MAAM;AAAA,IAChB,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY,MAAM;AAAA,MAXM,IAYrB,iBAZqB,IAYrB;AAAA,IAXH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAGA,SACE,qCAAC,oBAAD;AAAA,IACE,gBAAc,SAAS,SAAS;AAAA,IAChC,eAAY;AAAA,IACZ;AAAA,IACA;AAAA,KACI,OAEJ,qCAAC,YAAD;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA,KAAK;AAAA,IACL,UAAU;AAAA,IACV,UAAU;AAAA,IACV,WAAW,CAAC,MACV,UAAU,GAAG,YAAY;AAAA,IAE3B;AAAA,IACA;AAAA,KAEC;AAAA;AAMT,MAAM,QAAQ;AAAA,EAEZ,oBAAoB,UAAU,OAAO,YAAY;AAAA,EAEjD,IAAI,UAAU,OAAO,YAAY;AAAA,EAEjC,QAAQ,UAAU,KAAK,YAAY;AAAA,EAEnC,MAAM,UAAU,OAAO,YAAY;AAAA,EAEnC,SAAS,UAAU,KAAK,YAAY;AAAA,EAEpC,SAAS,UAAU,KAAK,YAAY;AAAA,EAEpC,eAAe,UAAU,KAAK,YAAY;AAAA,EAE1C,OAAO,UAAU,OAAO,YAAY;AAAA,EAEpC,OAAO,UAAU,OAAO,YAAY;AAAA;AAGtC,iBAAiB,YAAY;AAE7B,MAAM,6BAA6B,SAAS;AAC5C,2BAA2B,YAAY;AAGvC,IAAO,2BAAQ;",
6
+ "names": []
7
+ }
@@ -1,26 +1,28 @@
1
- import { useRef, useCallback } from 'react';
2
-
1
+ import * as React from "react";
2
+ import { useRef, useCallback } from "react";
3
3
  const useKeyboardNavigation = () => {
4
4
  const componentsRef = useRef([]);
5
- const addRef = useCallback(ref => {
5
+ const addRef = useCallback((ref) => {
6
6
  if (ref && !componentsRef.current.includes(ref)) {
7
7
  componentsRef.current.push(ref);
8
8
  }
9
9
  }, []);
10
10
  const onKeyDown = useCallback((e, componentRefIndex, callback) => {
11
- if (e.key === 'ArrowDown' && componentsRef.current[componentRefIndex + 1]) {
11
+ if (e.key === "ArrowDown" && componentsRef.current[componentRefIndex + 1]) {
12
12
  componentsRef.current[componentRefIndex + 1].focus();
13
13
  e.preventDefault();
14
- } else if (e.key === 'ArrowUp' && componentRefIndex !== 0) {
14
+ } else if (e.key === "ArrowUp" && componentRefIndex !== 0) {
15
15
  componentsRef.current[componentRefIndex - 1].focus();
16
16
  e.preventDefault();
17
- } else if (e.key === 'Enter') {
17
+ } else if (e.key === "Enter") {
18
18
  callback();
19
- } else if (e.ctrlKey && e.altKey && e.key === ' ') {
19
+ } else if (e.ctrlKey && e.altKey && e.key === " ") {
20
20
  componentsRef.current[componentRefIndex].click();
21
21
  }
22
22
  }, []);
23
23
  return [addRef, onKeyDown];
24
24
  };
25
-
26
- export { useKeyboardNavigation };
25
+ export {
26
+ useKeyboardNavigation
27
+ };
28
+ //# sourceMappingURL=useKeyboardNavigation.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useKeyboardNavigation.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useRef, useCallback } from 'react';\n\nexport const useKeyboardNavigation = () => {\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 (e: React.KeyboardEvent, componentRefIndex, callback) => {\n if (\n e.key === 'ArrowDown' &&\n componentsRef.current[componentRefIndex + 1]\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') {\n callback();\n } else if (e.ctrlKey && e.altKey && e.key === ' ') {\n componentsRef.current[componentRefIndex].click();\n }\n },\n [],\n );\n\n return [addRef, onKeyDown];\n};\n"],
5
+ "mappings": "AAAA;ACAA;AAEO,MAAM,wBAAwB,MAAM;AACzC,QAAM,gBAAgB,OAA4B;AAElD,QAAM,SAAS,YAAY,CAAC,QAA2B;AACrD,QAAI,OAAO,CAAC,cAAc,QAAQ,SAAS,MAAM;AAC/C,oBAAc,QAAQ,KAAK;AAAA;AAAA,KAE5B;AAEH,QAAM,YAAY,YAChB,CAAC,GAAwB,mBAAmB,aAAa;AACvD,QACE,EAAE,QAAQ,eACV,cAAc,QAAQ,oBAAoB,IAC1C;AACA,oBAAc,QAAQ,oBAAoB,GAAG;AAC7C,QAAE;AAAA,eACO,EAAE,QAAQ,aAAa,sBAAsB,GAAG;AACzD,oBAAc,QAAQ,oBAAoB,GAAG;AAC7C,QAAE;AAAA,eACO,EAAE,QAAQ,SAAS;AAC5B;AAAA,eACS,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,KAAK;AACjD,oBAAc,QAAQ,mBAAmB;AAAA;AAAA,KAG7C;AAGF,SAAO,CAAC,QAAQ;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ import * as React from "react";
2
+ //# sourceMappingURL=index.d.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": "AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ export * from "./DSBreadcrumb";
3
+ export * from "./DSBreadcrumbItem";
4
+ import { default as default2 } from "./DSBreadcrumb";
5
+ export {
6
+ default2 as default
7
+ };
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './DSBreadcrumb';\nexport * from './DSBreadcrumbItem';\nexport { default } from './DSBreadcrumb';\n"],
5
+ "mappings": "AAAA;ACAA;AACA;AACA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,78 @@
1
+ import * as React from "react";
2
+ import styled from "styled-components";
3
+ const handleColor = (theme, isActive, color, isTitle) => {
4
+ if (isActive)
5
+ return theme.colors.neutral[800];
6
+ else if (color)
7
+ return color;
8
+ else if (isTitle)
9
+ return theme.colors.neutral[700];
10
+ else
11
+ return theme.colors.brand[600];
12
+ };
13
+ const StyledList = styled.ol`
14
+ width: 100%;
15
+ list-style: none;
16
+ display: flex;
17
+ padding: 0;
18
+ margin: 0;
19
+ li:first-child * {
20
+ margin-left: 0;
21
+ }
22
+ `;
23
+ const StyledCrumbWrapper = styled.li`
24
+ display: inline-flex;
25
+ align-items: center;
26
+ flex-shrink: 20;
27
+ transition: flex-shrink 0.1s cubic-bezier(0.64, 0, 0.35, 1);
28
+ height: 16px;
29
+ min-width: 10px;
30
+ &:hover {
31
+ flex-shrink: 0;
32
+ }
33
+ ${({ theme, isTitle, trailingSlash }) => isTitle || !trailingSlash ? `&:not(:last-child):after {
34
+ display: inline-block;
35
+ content: '/';
36
+ color: ${theme.colors.neutral[700]};
37
+ }
38
+ ` : `&:after {
39
+ display: inline-block;
40
+ content: '/';
41
+ color: ${theme.colors.neutral[700]};
42
+ }
43
+ `}
44
+ `;
45
+ const StyledContainer = styled.nav`
46
+ display: flex;
47
+ align-items: center;
48
+ padding: 0;
49
+ `;
50
+ const StyledLink = styled.a`
51
+ white-space: nowrap;
52
+ overflow: hidden;
53
+ text-overflow: ellipsis;
54
+ text-decoration: none;
55
+ font-size: 12px;
56
+ outline: none;
57
+ margin: 0 2px;
58
+ border: 2px solid transparent;
59
+ -webkit-text-stroke: 0.4px transparent;
60
+ font-weight: ${({ theme }) => theme.fontWeights.regular};
61
+ color: ${({ theme, isActive, color, isTitle }) => handleColor(theme, isActive, color, isTitle)};
62
+ &:hover {
63
+ color: ${({ theme, color }) => color ? color : theme.colors.brand[800]};
64
+ cursor: pointer;
65
+ ${({ theme, color }) => `-webkit-text-stroke: 0.4px ${color ? color : theme.colors.brand[800]}`};
66
+ }
67
+ &:focus {
68
+ ${({ theme }) => `border: 2px solid ${theme.colors.brand[700]};`}
69
+ border-radius: 2px;
70
+ }
71
+ `;
72
+ export {
73
+ StyledContainer,
74
+ StyledCrumbWrapper,
75
+ StyledLink,
76
+ StyledList
77
+ };
78
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/styles.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { Theme } from '@elliemae/pui-theme';\nimport styled from 'styled-components';\nimport type { DSBreadcrumbItemPropsT } from './index.d';\n\nconst handleColor = (theme: Theme, isActive: boolean, color: string, isTitle: boolean): string => {\n if (isActive) return theme.colors.neutral[800];\n else if (color) return color;\n else if (isTitle) return theme.colors.neutral[700];\n else 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<DSBreadcrumbItemPropsT>>`\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 height: 16px;\n min-width: 10px;\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.a<Partial<DSBreadcrumbItemPropsT>>`\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n text-decoration: none;\n font-size: 12px;\n outline: none;\n margin: 0 2px;\n border: 2px solid transparent;\n -webkit-text-stroke: 0.4px transparent;\n font-weight: ${({ theme }) => theme.fontWeights.regular};\n color: ${({ theme, isActive, color, isTitle }) => handleColor(theme, isActive, color, isTitle)};\n &:hover {\n color: ${({ theme, color }) => (color ? color : theme.colors.brand[800])};\n cursor: pointer;\n ${({ theme, color }) => `-webkit-text-stroke: 0.4px ${color ? color : theme.colors.brand[800]}`};\n }\n &:focus {\n ${({ theme }) => `border: 2px solid ${theme.colors.brand[700]};`}\n border-radius: 2px;\n }\n`;\n\nexport { StyledList, StyledCrumbWrapper, StyledContainer, StyledLink };\n"],
5
+ "mappings": "AAAA;ACCA;AAGA,MAAM,cAAc,CAAC,OAAc,UAAmB,OAAe,YAA6B;AAChG,MAAI;AAAU,WAAO,MAAM,OAAO,QAAQ;AAAA,WACjC;AAAO,WAAO;AAAA,WACd;AAAS,WAAO,MAAM,OAAO,QAAQ;AAAA;AACzC,WAAO,MAAM,OAAO,MAAM;AAAA;AAGjC,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,IAU9B,CAAC,EAAE,OAAO,SAAS,oBACnB,WAAW,CAAC,gBACR;AAAA;AAAA;AAAA,aAGK,MAAM,OAAO,QAAQ;AAAA;AAAA,MAG1B;AAAA;AAAA;AAAA,aAGK,MAAM,OAAO,QAAQ;AAAA;AAAA;AAAA;AAKlC,MAAM,kBAAkB,OAAO;AAAA;AAAA;AAAA;AAAA;AAM/B,MAAM,aAAa,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAUT,CAAC,EAAE,YAAY,MAAM,YAAY;AAAA,WACvC,CAAC,EAAE,OAAO,UAAU,OAAO,cAAc,YAAY,OAAO,UAAU,OAAO;AAAA;AAAA,aAE3E,CAAC,EAAE,OAAO,YAAa,QAAQ,QAAQ,MAAM,OAAO,MAAM;AAAA;AAAA,MAEjE,CAAC,EAAE,OAAO,YAAY,8BAA8B,QAAQ,QAAQ,MAAM,OAAO,MAAM;AAAA;AAAA;AAAA,MAGvF,CAAC,EAAE,YAAY,qBAAqB,MAAM,OAAO,MAAM;AAAA;AAAA;AAAA;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,31 +1,34 @@
1
1
  {
2
2
  "name": "@elliemae/ds-breadcrumb",
3
- "version": "3.0.0-next.2",
3
+ "version": "3.0.0-next.6",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Breadcrumb",
6
- "module": "./esm/index.js",
7
- "main": "./cjs/index.js",
8
- "types": "./types/index.d.ts",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "module": "./dist/esm/index.js",
10
+ "main": "./dist/cjs/index.js",
11
+ "types": "./dist/types/index.d.ts",
9
12
  "exports": {
10
13
  ".": {
11
- "import": "./esm/index.js",
12
- "require": "./cjs/index.js"
14
+ "import": "./dist/esm/index.js",
15
+ "require": "./dist/cjs/index.js"
13
16
  },
14
17
  "./styles": {
15
- "import": "./esm/styles.js",
16
- "require": "./cjs/styles.js"
18
+ "import": "./dist/esm/styles.js",
19
+ "require": "./dist/cjs/styles.js"
17
20
  },
18
21
  "./hooks/useKeyboardNavigation": {
19
- "import": "./esm/hooks/useKeyboardNavigation.js",
20
- "require": "./cjs/hooks/useKeyboardNavigation.js"
22
+ "import": "./dist/esm/hooks/useKeyboardNavigation.js",
23
+ "require": "./dist/cjs/hooks/useKeyboardNavigation.js"
21
24
  },
22
25
  "./DSBreadcrumbItem": {
23
- "import": "./esm/DSBreadcrumbItem.js",
24
- "require": "./cjs/DSBreadcrumbItem.js"
26
+ "import": "./dist/esm/DSBreadcrumbItem.js",
27
+ "require": "./dist/cjs/DSBreadcrumbItem.js"
25
28
  },
26
29
  "./DSBreadcrumb": {
27
- "import": "./esm/DSBreadcrumb.js",
28
- "require": "./cjs/DSBreadcrumb.js"
30
+ "import": "./dist/esm/DSBreadcrumb.js",
31
+ "require": "./dist/cjs/DSBreadcrumb.js"
29
32
  }
30
33
  },
31
34
  "sideEffects": [
@@ -37,23 +40,23 @@
37
40
  "url": "https://git.elliemae.io/platform-ui/dimsum.git"
38
41
  },
39
42
  "engines": {
40
- "npm": ">=7",
41
- "node": ">=14"
43
+ "pnpm": ">=6",
44
+ "node": ">=16"
42
45
  },
43
46
  "author": "ICE MT",
44
- "scripts": {
45
- "dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
46
- "prebuild": "exit 0",
47
- "predev": "exit 0",
48
- "build": "node ../../scripts/build/build.js"
47
+ "jestSonar": {
48
+ "sonar56x": true,
49
+ "reportPath": "reports",
50
+ "reportFile": "tests.xml",
51
+ "indent": 4
49
52
  },
50
53
  "dependencies": {
51
- "@elliemae/ds-system": "3.0.0-next.2",
54
+ "@elliemae/ds-system": "3.0.0-next.6",
52
55
  "react-desc": "~4.1.3"
53
56
  },
54
57
  "devDependencies": {
55
- "@elliemae/pui-theme": "~2.2.5",
56
- "@testing-library/jest-dom": "~5.15.0",
58
+ "@elliemae/pui-theme": "~2.3.0",
59
+ "@testing-library/jest-dom": "~5.15.1",
57
60
  "@testing-library/react": "~12.1.2",
58
61
  "@testing-library/user-event": "~13.5.0",
59
62
  "styled-components": "~5.3.3"
@@ -66,7 +69,13 @@
66
69
  },
67
70
  "publishConfig": {
68
71
  "access": "public",
69
- "directory": "dist",
70
- "generateSubmodules": true
72
+ "typeSafety": false
73
+ },
74
+ "scripts": {
75
+ "dev": "cross-env NODE_ENV=development node ../../scripts/build/build.mjs --watch",
76
+ "test": "node ../../scripts/testing/test.mjs",
77
+ "lint": "node ../../scripts/lint.mjs",
78
+ "dts": "node ../../scripts/dts.mjs",
79
+ "build": "cross-env NODE_ENV=production node ../../scripts/build/build.mjs"
71
80
  }
72
81
  }
@@ -1,102 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
6
- var _jsx = require('@babel/runtime/helpers/jsx');
7
- var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
8
- require('core-js/modules/web.dom-collections.iterator.js');
9
- require('core-js/modules/esnext.async-iterator.map.js');
10
- require('core-js/modules/esnext.iterator.map.js');
11
- require('core-js/modules/esnext.async-iterator.filter.js');
12
- require('core-js/modules/esnext.iterator.constructor.js');
13
- require('core-js/modules/esnext.iterator.filter.js');
14
- require('core-js/modules/esnext.async-iterator.for-each.js');
15
- require('core-js/modules/esnext.iterator.for-each.js');
16
- var React = require('react');
17
- var reactDesc = require('react-desc');
18
- var DSBreadcrumbItem = require('./DSBreadcrumbItem.js');
19
- var useKeyboardNavigation = require('./hooks/useKeyboardNavigation.js');
20
- var styles = require('./styles.js');
21
- var jsxRuntime = require('react/jsx-runtime');
22
-
23
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
24
-
25
- var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
26
- var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
27
- var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
28
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
29
-
30
- const _excluded = ["containerProps", "as", "label", "isTitle", "children", "trailingSlash"];
31
-
32
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
33
-
34
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
35
- const htmlElements = ['nav', 'div', 'header', 'footer', 'main'];
36
-
37
- const DSBreadcrumb = _ref => {
38
- let {
39
- containerProps = {},
40
- as = 'nav',
41
- label = 'Breadcrumb',
42
- isTitle = false,
43
- children,
44
- trailingSlash = true
45
- } = _ref,
46
- rest = _objectWithoutProperties__default["default"](_ref, _excluded);
47
-
48
- const [addRef, onKeyDown] = useKeyboardNavigation.useKeyboardNavigation();
49
- const safeElement = React.useMemo(() => htmlElements.indexOf(as) > -1 ? as : 'nav', [as]);
50
- return /*#__PURE__*/jsxRuntime.jsx(styles.StyledContainer, _objectSpread(_objectSpread(_objectSpread({
51
- "aria-label": label,
52
- "data-testid": "breadcrumb-nav-container"
53
- }, rest), containerProps), {}, {
54
- as: safeElement,
55
- children: /*#__PURE__*/_jsx__default["default"](styles.StyledList, {
56
- "data-testid": "list-container"
57
- }, void 0, React__default["default"].Children.map(children, (child, childIndex) => childIndex < children.length - 1 ? /*#__PURE__*/React.cloneElement(child, {
58
- childIndex,
59
- addRef,
60
- onKeyDown
61
- }) : /*#__PURE__*/React.cloneElement(child, {
62
- childIndex,
63
- addRef,
64
- onKeyDown,
65
- trailingSlash,
66
- isTitle
67
- })))
68
- }));
69
- };
70
-
71
- DSBreadcrumb.Item = DSBreadcrumbItem.DSBreadcrumbItem;
72
- const props = {
73
- /** props injected to breadcrumb wrapper */
74
- containerProps: reactDesc.PropTypes.object.description('props injected to breadcrumb wrapper'),
75
-
76
- /**
77
- * Type of element you want the main container to be:
78
- * 'nav', 'div', 'header', 'footer', 'main'
79
- */
80
- as: reactDesc.PropTypes.string.description("Type of element you want the main container to be: 'nav', 'div', 'header', 'footer', 'main'"),
81
-
82
- /**
83
- * Whether to show the last element of the breadcrumb as a title
84
- * Also removes trailing slash to show last element as title
85
- */
86
- isTitle: reactDesc.PropTypes.bool.description('Whether to show the last element of the breadcrumb as a title. Also removes trailing slash to show last element as title'),
87
-
88
- /** breadcrumb label */
89
- label: reactDesc.PropTypes.string.description('breadcrumb label'),
90
-
91
- /**
92
- * Container items to wrap
93
- */
94
- children: reactDesc.PropTypes.arrayOf(DSBreadcrumbItem.DSBreadcrumbItem).isRequired.description('Container items to wrap')
95
- };
96
- const DSBreadcrumbWithSchema = reactDesc.describe(DSBreadcrumb);
97
- DSBreadcrumbWithSchema.propTypes = props;
98
-
99
- exports.DSBreadcrumb = DSBreadcrumb;
100
- exports.DSBreadcrumbWithSchema = DSBreadcrumbWithSchema;
101
- exports["default"] = DSBreadcrumb;
102
- exports.htmlElements = htmlElements;
@@ -1,98 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- require('core-js/modules/esnext.async-iterator.filter.js');
6
- require('core-js/modules/esnext.iterator.constructor.js');
7
- require('core-js/modules/esnext.iterator.filter.js');
8
- require('core-js/modules/esnext.async-iterator.for-each.js');
9
- require('core-js/modules/esnext.iterator.for-each.js');
10
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
11
- var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
12
- require('react');
13
- var reactDesc = require('react-desc');
14
- var styles = require('./styles.js');
15
- var jsxRuntime = require('react/jsx-runtime');
16
-
17
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
-
19
- var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
20
- var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
21
-
22
- const _excluded = ["active", "as", "href", "isTitle", "onClick", "label", "color", "addRef", "childIndex", "trailingSlash", "onKeyDown"];
23
-
24
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
-
26
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
27
-
28
- function DSBreadcrumbItem(_ref) {
29
- let {
30
- active = false,
31
- as = 'a',
32
- href = undefined,
33
- isTitle,
34
- onClick = () => null,
35
- label = '',
36
- color = null,
37
- addRef,
38
- childIndex,
39
- trailingSlash,
40
- onKeyDown = () => null
41
- } = _ref,
42
- rest = _objectWithoutProperties__default["default"](_ref, _excluded);
43
-
44
- return /*#__PURE__*/jsxRuntime.jsx(styles.StyledCrumbWrapper, _objectSpread(_objectSpread({
45
- "aria-current": active ? 'page' : undefined,
46
- "data-testid": "breadcrumb-item-container",
47
- isTitle: isTitle,
48
- trailingSlash: trailingSlash
49
- }, rest), {}, {
50
- children: /*#__PURE__*/jsxRuntime.jsx(styles.StyledLink, {
51
- as: as,
52
- href: href,
53
- onClick: onClick,
54
- ref: addRef,
55
- tabIndex: 0,
56
- isActive: active,
57
- onKeyDown: e => onKeyDown(e, childIndex, onClick),
58
- isTitle: isTitle,
59
- color: color,
60
- children: label
61
- })
62
- }));
63
- }
64
-
65
- const props = {
66
- /** inject props to wrapper */
67
- containerComponent: reactDesc.PropTypes.string.description('inject props to wrapper'),
68
-
69
- /** render as any html node */
70
- as: reactDesc.PropTypes.string.description('render as any html node'),
71
-
72
- /** active item */
73
- active: reactDesc.PropTypes.bool.description('active item'),
74
-
75
- /** href link */
76
- href: reactDesc.PropTypes.string.description('href link'),
77
-
78
- /** on click handler */
79
- onClick: reactDesc.PropTypes.func.description('on click handler'),
80
-
81
- /** style item as title */
82
- isTitle: reactDesc.PropTypes.bool.description('style item as title'),
83
-
84
- /** add trailing slash */
85
- trailingSlash: reactDesc.PropTypes.bool.description('add trailing slash'),
86
-
87
- /** item label */
88
- label: reactDesc.PropTypes.string.description('item label'),
89
-
90
- /** link color */
91
- color: reactDesc.PropTypes.string.description('link color')
92
- };
93
- const DSBreadcrumbItemWithSchema = reactDesc.describe(DSBreadcrumbItem);
94
- DSBreadcrumbItemWithSchema.propTypes = props;
95
-
96
- exports.DSBreadcrumbItem = DSBreadcrumbItem;
97
- exports.DSBreadcrumbItemWithSchema = DSBreadcrumbItemWithSchema;
98
- exports["default"] = DSBreadcrumbItem;
@@ -1,30 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var React = require('react');
6
-
7
- const useKeyboardNavigation = () => {
8
- const componentsRef = React.useRef([]);
9
- const addRef = React.useCallback(ref => {
10
- if (ref && !componentsRef.current.includes(ref)) {
11
- componentsRef.current.push(ref);
12
- }
13
- }, []);
14
- const onKeyDown = React.useCallback((e, componentRefIndex, callback) => {
15
- if (e.key === 'ArrowDown' && componentsRef.current[componentRefIndex + 1]) {
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') {
22
- callback();
23
- } else if (e.ctrlKey && e.altKey && e.key === ' ') {
24
- componentsRef.current[componentRefIndex].click();
25
- }
26
- }, []);
27
- return [addRef, onKeyDown];
28
- };
29
-
30
- exports.useKeyboardNavigation = useKeyboardNavigation;
package/cjs/index.d.js DELETED
@@ -1,2 +0,0 @@
1
- 'use strict';
2
-
package/cjs/index.js DELETED
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var DSBreadcrumb = require('./DSBreadcrumb.js');
6
- var DSBreadcrumbItem = require('./DSBreadcrumbItem.js');
7
-
8
-
9
-
10
- exports.DSBreadcrumb = DSBreadcrumb.DSBreadcrumb;
11
- exports.DSBreadcrumbWithSchema = DSBreadcrumb.DSBreadcrumbWithSchema;
12
- exports["default"] = DSBreadcrumb.DSBreadcrumb;
13
- exports.htmlElements = DSBreadcrumb.htmlElements;
14
- exports.DSBreadcrumbItem = DSBreadcrumbItem.DSBreadcrumbItem;
15
- exports.DSBreadcrumbItemWithSchema = DSBreadcrumbItem.DSBreadcrumbItemWithSchema;