@workday/canvas-kit-preview-react 8.0.0-alpha.194-next.2 → 8.0.0-alpha.199-next.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.
Files changed (138) hide show
  1. package/dist/commonjs/form-field/lib/FormField.d.ts +1 -1
  2. package/dist/commonjs/form-field/lib/FormFieldHint.d.ts +1 -1
  3. package/dist/commonjs/index.d.ts +0 -1
  4. package/dist/commonjs/index.d.ts.map +1 -1
  5. package/dist/commonjs/index.js +0 -2
  6. package/dist/commonjs/text-area/lib/TextArea.d.ts +1 -1
  7. package/dist/commonjs/text-input/lib/TextInput.d.ts +1 -1
  8. package/dist/es6/form-field/lib/FormField.d.ts +1 -1
  9. package/dist/es6/form-field/lib/FormFieldHint.d.ts +1 -1
  10. package/dist/es6/index.d.ts +0 -1
  11. package/dist/es6/index.d.ts.map +1 -1
  12. package/dist/es6/index.js +0 -2
  13. package/dist/es6/text-area/lib/TextArea.d.ts +1 -1
  14. package/dist/es6/text-input/lib/TextInput.d.ts +1 -1
  15. package/index.ts +0 -3
  16. package/package.json +4 -4
  17. package/breadcrumbs/LICENSE +0 -52
  18. package/breadcrumbs/README.md +0 -7
  19. package/breadcrumbs/index.ts +0 -1
  20. package/breadcrumbs/lib/Breadcrumbs/Dropdown/Button.tsx +0 -85
  21. package/breadcrumbs/lib/Breadcrumbs/Dropdown/Menu.tsx +0 -152
  22. package/breadcrumbs/lib/Breadcrumbs/Dropdown/MenuItemLink.tsx +0 -63
  23. package/breadcrumbs/lib/Breadcrumbs/Dropdown/hooks.ts +0 -109
  24. package/breadcrumbs/lib/Breadcrumbs/Dropdown/index.tsx +0 -38
  25. package/breadcrumbs/lib/Breadcrumbs/List/Collapsible.tsx +0 -66
  26. package/breadcrumbs/lib/Breadcrumbs/List/CurrentItem.tsx +0 -64
  27. package/breadcrumbs/lib/Breadcrumbs/List/Link.tsx +0 -88
  28. package/breadcrumbs/lib/Breadcrumbs/List/ListItem.tsx +0 -30
  29. package/breadcrumbs/lib/Breadcrumbs/List/hooks.ts +0 -114
  30. package/breadcrumbs/lib/Breadcrumbs/List/index.tsx +0 -26
  31. package/breadcrumbs/lib/Breadcrumbs/List/styles.ts +0 -12
  32. package/breadcrumbs/lib/Breadcrumbs/Nav.tsx +0 -14
  33. package/breadcrumbs/lib/Breadcrumbs/hooks.ts +0 -13
  34. package/breadcrumbs/lib/Breadcrumbs/index.tsx +0 -15
  35. package/breadcrumbs/lib/Breadcrumbs/types.ts +0 -7
  36. package/breadcrumbs/package.json +0 -6
  37. package/dist/commonjs/breadcrumbs/index.d.ts +0 -2
  38. package/dist/commonjs/breadcrumbs/index.d.ts.map +0 -1
  39. package/dist/commonjs/breadcrumbs/index.js +0 -13
  40. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/Dropdown/Button.d.ts +0 -20
  41. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/Dropdown/Button.d.ts.map +0 -1
  42. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/Dropdown/Button.js +0 -69
  43. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/Dropdown/Menu.d.ts +0 -38
  44. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/Dropdown/Menu.d.ts.map +0 -1
  45. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/Dropdown/Menu.js +0 -94
  46. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/Dropdown/MenuItemLink.d.ts +0 -14
  47. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/Dropdown/MenuItemLink.d.ts.map +0 -1
  48. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/Dropdown/MenuItemLink.js +0 -73
  49. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/Dropdown/hooks.d.ts +0 -13
  50. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/Dropdown/hooks.d.ts.map +0 -1
  51. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/Dropdown/hooks.js +0 -77
  52. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/Dropdown/index.d.ts +0 -8
  53. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/Dropdown/index.d.ts.map +0 -1
  54. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/Dropdown/index.js +0 -37
  55. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/List/Collapsible.d.ts +0 -16
  56. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/List/Collapsible.d.ts.map +0 -1
  57. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/List/Collapsible.js +0 -78
  58. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/List/CurrentItem.d.ts +0 -11
  59. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/List/CurrentItem.d.ts.map +0 -1
  60. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/List/CurrentItem.js +0 -49
  61. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/List/Link.d.ts +0 -19
  62. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/List/Link.d.ts.map +0 -1
  63. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/List/Link.js +0 -66
  64. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/List/ListItem.d.ts +0 -4
  65. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/List/ListItem.d.ts.map +0 -1
  66. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/List/ListItem.js +0 -43
  67. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/List/hooks.d.ts +0 -19
  68. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/List/hooks.d.ts.map +0 -1
  69. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/List/hooks.js +0 -116
  70. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/List/index.d.ts +0 -4
  71. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/List/index.d.ts.map +0 -1
  72. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/List/index.js +0 -26
  73. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/List/styles.d.ts +0 -3
  74. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/List/styles.d.ts.map +0 -1
  75. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/List/styles.js +0 -16
  76. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/Nav.d.ts +0 -11
  77. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/Nav.d.ts.map +0 -1
  78. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/Nav.js +0 -34
  79. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/hooks.d.ts +0 -5
  80. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/hooks.d.ts.map +0 -1
  81. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/hooks.js +0 -12
  82. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/index.d.ts +0 -9
  83. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/index.d.ts.map +0 -1
  84. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/index.js +0 -17
  85. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/types.d.ts +0 -8
  86. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/types.d.ts.map +0 -1
  87. package/dist/commonjs/breadcrumbs/lib/Breadcrumbs/types.js +0 -2
  88. package/dist/es6/breadcrumbs/index.d.ts +0 -2
  89. package/dist/es6/breadcrumbs/index.d.ts.map +0 -1
  90. package/dist/es6/breadcrumbs/index.js +0 -1
  91. package/dist/es6/breadcrumbs/lib/Breadcrumbs/Dropdown/Button.d.ts +0 -20
  92. package/dist/es6/breadcrumbs/lib/Breadcrumbs/Dropdown/Button.d.ts.map +0 -1
  93. package/dist/es6/breadcrumbs/lib/Breadcrumbs/Dropdown/Button.js +0 -63
  94. package/dist/es6/breadcrumbs/lib/Breadcrumbs/Dropdown/Menu.d.ts +0 -38
  95. package/dist/es6/breadcrumbs/lib/Breadcrumbs/Dropdown/Menu.d.ts.map +0 -1
  96. package/dist/es6/breadcrumbs/lib/Breadcrumbs/Dropdown/Menu.js +0 -87
  97. package/dist/es6/breadcrumbs/lib/Breadcrumbs/Dropdown/MenuItemLink.d.ts +0 -14
  98. package/dist/es6/breadcrumbs/lib/Breadcrumbs/Dropdown/MenuItemLink.d.ts.map +0 -1
  99. package/dist/es6/breadcrumbs/lib/Breadcrumbs/Dropdown/MenuItemLink.js +0 -51
  100. package/dist/es6/breadcrumbs/lib/Breadcrumbs/Dropdown/hooks.d.ts +0 -13
  101. package/dist/es6/breadcrumbs/lib/Breadcrumbs/Dropdown/hooks.d.ts.map +0 -1
  102. package/dist/es6/breadcrumbs/lib/Breadcrumbs/Dropdown/hooks.js +0 -72
  103. package/dist/es6/breadcrumbs/lib/Breadcrumbs/Dropdown/index.d.ts +0 -8
  104. package/dist/es6/breadcrumbs/lib/Breadcrumbs/Dropdown/index.d.ts.map +0 -1
  105. package/dist/es6/breadcrumbs/lib/Breadcrumbs/Dropdown/index.js +0 -30
  106. package/dist/es6/breadcrumbs/lib/Breadcrumbs/List/Collapsible.d.ts +0 -16
  107. package/dist/es6/breadcrumbs/lib/Breadcrumbs/List/Collapsible.d.ts.map +0 -1
  108. package/dist/es6/breadcrumbs/lib/Breadcrumbs/List/Collapsible.js +0 -55
  109. package/dist/es6/breadcrumbs/lib/Breadcrumbs/List/CurrentItem.d.ts +0 -11
  110. package/dist/es6/breadcrumbs/lib/Breadcrumbs/List/CurrentItem.d.ts.map +0 -1
  111. package/dist/es6/breadcrumbs/lib/Breadcrumbs/List/CurrentItem.js +0 -42
  112. package/dist/es6/breadcrumbs/lib/Breadcrumbs/List/Link.d.ts +0 -19
  113. package/dist/es6/breadcrumbs/lib/Breadcrumbs/List/Link.d.ts.map +0 -1
  114. package/dist/es6/breadcrumbs/lib/Breadcrumbs/List/Link.js +0 -59
  115. package/dist/es6/breadcrumbs/lib/Breadcrumbs/List/ListItem.d.ts +0 -4
  116. package/dist/es6/breadcrumbs/lib/Breadcrumbs/List/ListItem.d.ts.map +0 -1
  117. package/dist/es6/breadcrumbs/lib/Breadcrumbs/List/ListItem.js +0 -36
  118. package/dist/es6/breadcrumbs/lib/Breadcrumbs/List/hooks.d.ts +0 -19
  119. package/dist/es6/breadcrumbs/lib/Breadcrumbs/List/hooks.d.ts.map +0 -1
  120. package/dist/es6/breadcrumbs/lib/Breadcrumbs/List/hooks.js +0 -91
  121. package/dist/es6/breadcrumbs/lib/Breadcrumbs/List/index.d.ts +0 -4
  122. package/dist/es6/breadcrumbs/lib/Breadcrumbs/List/index.d.ts.map +0 -1
  123. package/dist/es6/breadcrumbs/lib/Breadcrumbs/List/index.js +0 -20
  124. package/dist/es6/breadcrumbs/lib/Breadcrumbs/List/styles.d.ts +0 -3
  125. package/dist/es6/breadcrumbs/lib/Breadcrumbs/List/styles.d.ts.map +0 -1
  126. package/dist/es6/breadcrumbs/lib/Breadcrumbs/List/styles.js +0 -12
  127. package/dist/es6/breadcrumbs/lib/Breadcrumbs/Nav.d.ts +0 -11
  128. package/dist/es6/breadcrumbs/lib/Breadcrumbs/Nav.d.ts.map +0 -1
  129. package/dist/es6/breadcrumbs/lib/Breadcrumbs/Nav.js +0 -27
  130. package/dist/es6/breadcrumbs/lib/Breadcrumbs/hooks.d.ts +0 -5
  131. package/dist/es6/breadcrumbs/lib/Breadcrumbs/hooks.d.ts.map +0 -1
  132. package/dist/es6/breadcrumbs/lib/Breadcrumbs/hooks.js +0 -8
  133. package/dist/es6/breadcrumbs/lib/Breadcrumbs/index.d.ts +0 -9
  134. package/dist/es6/breadcrumbs/lib/Breadcrumbs/index.d.ts.map +0 -1
  135. package/dist/es6/breadcrumbs/lib/Breadcrumbs/index.js +0 -14
  136. package/dist/es6/breadcrumbs/lib/Breadcrumbs/types.d.ts +0 -8
  137. package/dist/es6/breadcrumbs/lib/Breadcrumbs/types.d.ts.map +0 -1
  138. package/dist/es6/breadcrumbs/lib/Breadcrumbs/types.js +0 -1
@@ -1,109 +0,0 @@
1
- import {useState, useLayoutEffect} from 'react';
2
- import {useUniqueId, changeFocus} from '@workday/canvas-kit-react/common';
3
- import {
4
- useCloseOnOutsideClick,
5
- useCloseOnEscape,
6
- usePopupModel,
7
- useReturnFocus,
8
- usePopupTarget,
9
- usePopupPopper,
10
- } from '@workday/canvas-kit-react/popup';
11
-
12
- import {DropdownButtonProps} from './Button';
13
- import {DropdownMenuProps} from './Menu';
14
- import {Breadcrumb} from '../types';
15
-
16
- export const useFocusActiveItemElement = <E extends HTMLElement>(
17
- activeDropdownItemRef: React.RefObject<E>
18
- ) => {
19
- useLayoutEffect(() => {
20
- if (activeDropdownItemRef.current) {
21
- return activeDropdownItemRef.current.focus();
22
- }
23
- });
24
- };
25
-
26
- const initialActiveItem = {
27
- index: 0,
28
- link: '',
29
- text: '',
30
- width: 0,
31
- } as Breadcrumb;
32
-
33
- interface UseDropdown {
34
- dropdownButtonProps: Omit<DropdownButtonProps, 'aria-label'>;
35
- dropdownMenuProps: DropdownMenuProps;
36
- popperProps: ReturnType<typeof usePopupPopper>;
37
- }
38
-
39
- export const useDropdown = (
40
- activeDropdownItemRef: React.RefObject<HTMLAnchorElement>,
41
- items: Breadcrumb[],
42
- buttonId?: string
43
- ): UseDropdown => {
44
- // state
45
- const [activeDropdownItem, setActiveDropdownItem] = useState(initialActiveItem);
46
- // behaviors
47
- const model = usePopupModel({
48
- initialFocusRef: activeDropdownItemRef,
49
- });
50
-
51
- useCloseOnOutsideClick(model);
52
- useCloseOnEscape(model);
53
- useReturnFocus(model);
54
- useFocusActiveItemElement(activeDropdownItemRef);
55
-
56
- const handleButtonKeyUp = (e: React.KeyboardEvent<HTMLButtonElement>) => {
57
- if (e.key === 'Enter') {
58
- setActiveDropdownItem(items[0]);
59
- }
60
- };
61
-
62
- const resetMenuFocus = () => {
63
- model.events.hide();
64
- changeFocus(model.state.targetRef.current);
65
- };
66
-
67
- const findActiveDropdownItemByIndex = (index: number) => {
68
- return items.filter(item => item.index === index)[0];
69
- };
70
-
71
- const toggleActiveItemUp = () => {
72
- const previousItem = findActiveDropdownItemByIndex(activeDropdownItem.index - 1);
73
- if (!previousItem) {
74
- return resetMenuFocus();
75
- }
76
- return setActiveDropdownItem(previousItem);
77
- };
78
-
79
- const toggleActiveItemDown = () => {
80
- const nextItem = findActiveDropdownItemByIndex(activeDropdownItem.index + 1);
81
- if (!nextItem) {
82
- return setActiveDropdownItem(items[0]);
83
- }
84
- return setActiveDropdownItem(nextItem);
85
- };
86
-
87
- const uniqueButtonId = useUniqueId(buttonId);
88
-
89
- const dropdownButtonProps = usePopupTarget(model, {
90
- id: uniqueButtonId,
91
- toggled: model.state.visibility !== 'hidden',
92
- onKeyUp: handleButtonKeyUp,
93
- });
94
-
95
- const dropdownMenuProps = {
96
- 'aria-labelledby': uniqueButtonId,
97
- dropdownItems: items,
98
- activeDropdownItem,
99
- activeDropdownItemRef,
100
- setActiveDropdownItem,
101
- resetFocus: resetMenuFocus,
102
- toggleActiveItemUp,
103
- toggleActiveItemDown,
104
- };
105
-
106
- const popperProps = usePopupPopper(model);
107
-
108
- return {dropdownButtonProps, dropdownMenuProps, popperProps};
109
- };
@@ -1,38 +0,0 @@
1
- import React from 'react';
2
- import {Breadcrumb} from '../types';
3
- import {Popper} from '@workday/canvas-kit-react/popup';
4
-
5
- import {useRTL} from '../hooks';
6
- import {useDropdown} from './hooks';
7
- import {DropdownButton, DropdownButtonProps} from './Button';
8
- import {DropdownMenu} from './Menu';
9
-
10
- export interface DropdownProps extends Pick<DropdownButtonProps, 'buttonIcon'> {
11
- buttonAriaLabel: string;
12
- items?: Breadcrumb[];
13
- }
14
-
15
- export const Dropdown = ({buttonAriaLabel, buttonIcon, items = []}: DropdownProps) => {
16
- // refs
17
- const activeDropdownItemRef = React.useRef<HTMLAnchorElement>(null);
18
- // behaviors
19
- const {dropdownButtonProps, dropdownMenuProps, popperProps} = useDropdown(
20
- activeDropdownItemRef,
21
- items
22
- );
23
- const {shouldUseRTL} = useRTL();
24
- const placement = shouldUseRTL ? 'bottom-end' : 'bottom-start';
25
-
26
- return (
27
- <>
28
- <DropdownButton
29
- aria-label={buttonAriaLabel}
30
- buttonIcon={buttonIcon}
31
- {...dropdownButtonProps}
32
- />
33
- <Popper placement={placement} {...popperProps}>
34
- <DropdownMenu {...dropdownMenuProps} />
35
- </Popper>
36
- </>
37
- );
38
- };
@@ -1,66 +0,0 @@
1
- import React, {Children, useRef} from 'react';
2
- // local components
3
- import {Dropdown} from '../Dropdown';
4
- import {BreadcrumbsListItem} from './ListItem';
5
- import {BreadcrumbsList} from './index';
6
- // hooks
7
- import {useBuildCollapsedList, useCollapse} from './hooks';
8
- import {DropdownButtonProps} from '../Dropdown/Button';
9
-
10
- const parseListItems = (children: React.ReactNode) => {
11
- const childArray = Children.toArray(children);
12
- const {0: rootItem, length, [length - 1]: currentItem} = childArray;
13
- const collapsibleItems = childArray.slice(1, -1);
14
- return {rootItem, collapsibleItems, currentItem};
15
- };
16
-
17
- export interface CollapsibleListProps
18
- extends React.HTMLAttributes<HTMLUListElement>,
19
- Pick<DropdownButtonProps, 'buttonIcon'> {
20
- /**
21
- * The accessibility label for the dropdown menu button.
22
- *
23
- * Suggested value: "more links"
24
- */
25
- buttonAriaLabel: string;
26
- /**
27
- * The max-width before the list should collapse and render a dropdown menu
28
- */
29
- maxWidth: number;
30
- }
31
-
32
- export const CollapsibleList = ({
33
- children,
34
- buttonIcon,
35
- buttonAriaLabel,
36
- maxWidth,
37
- ...props
38
- }: CollapsibleListProps) => {
39
- // refs
40
- const listRef = useRef<HTMLUListElement>(null);
41
- // behaviors
42
- const {shouldCollapseList} = useCollapse(listRef, maxWidth);
43
- const {collapsedItems, collapsedItemIndices} = useBuildCollapsedList(listRef, children, maxWidth);
44
- const {rootItem, collapsibleItems, currentItem} = parseListItems(children);
45
- return (
46
- <BreadcrumbsList ref={listRef} {...props}>
47
- {rootItem}
48
- {shouldCollapseList && (
49
- <BreadcrumbsListItem>
50
- <Dropdown
51
- buttonAriaLabel={buttonAriaLabel}
52
- buttonIcon={buttonIcon}
53
- items={collapsedItems}
54
- />
55
- </BreadcrumbsListItem>
56
- )}
57
- {collapsibleItems.map((item, i) => {
58
- if (collapsedItemIndices.indexOf(i + 1) !== -1) {
59
- return;
60
- }
61
- return item;
62
- })}
63
- {currentItem}
64
- </BreadcrumbsList>
65
- );
66
- };
@@ -1,64 +0,0 @@
1
- import React from 'react';
2
- import {styled} from '@workday/canvas-kit-react/common';
3
- import {type} from '@workday/canvas-kit-react/tokens';
4
- import {TooltipContainer} from '@workday/canvas-kit-react/tooltip';
5
- import {Popper} from '@workday/canvas-kit-react/popup';
6
-
7
- import {useTruncateTooltip} from './hooks';
8
- import {truncateStyles} from './styles';
9
-
10
- export interface CurrentItemProps extends React.HTMLAttributes<HTMLLIElement> {
11
- /**
12
- * The max-width of the text
13
- *
14
- * @default 350px
15
- */
16
- maxWidth?: number;
17
- }
18
-
19
- const ListItem = styled('li')(
20
- {
21
- display: 'flex',
22
- alignItems: 'center',
23
- flexDirection: 'column',
24
- textAlign: 'left',
25
- ...type.levels.subtext.large,
26
- fontWeight: 500,
27
- },
28
-
29
- ({maxWidth}: CurrentItemProps) => ({
30
- ...truncateStyles(maxWidth),
31
- })
32
- );
33
-
34
- export const CurrentItem = ({children, maxWidth, ...elemProps}: CurrentItemProps) => {
35
- const ref = React.useRef<HTMLLIElement>(null);
36
-
37
- const {
38
- isTooltipOpen,
39
- openTooltip,
40
- closeTooltip,
41
- shouldShowTooltip,
42
- tooltipProps,
43
- } = useTruncateTooltip(ref);
44
-
45
- return (
46
- <>
47
- <ListItem
48
- ref={ref}
49
- maxWidth={maxWidth}
50
- onMouseEnter={openTooltip}
51
- onMouseLeave={closeTooltip}
52
- onFocus={openTooltip}
53
- onBlur={closeTooltip}
54
- {...(shouldShowTooltip && {tabIndex: 0})}
55
- {...elemProps}
56
- >
57
- {children}
58
- </ListItem>
59
- <Popper open={isTooltipOpen} anchorElement={ref} placement="top">
60
- <TooltipContainer {...tooltipProps}>{children}</TooltipContainer>
61
- </Popper>
62
- </>
63
- );
64
- };
@@ -1,88 +0,0 @@
1
- import React from 'react';
2
- import {styled} from '@workday/canvas-kit-react/common';
3
- import {Hyperlink} from '@workday/canvas-kit-react/button';
4
- import {type} from '@workday/canvas-kit-react/tokens';
5
- import {TooltipContainer} from '@workday/canvas-kit-react/tooltip';
6
- import {Popper} from '@workday/canvas-kit-react/popup';
7
-
8
- import {useTruncateTooltip} from './hooks';
9
- import {truncateStyles} from './styles';
10
-
11
- export interface BreadcrumbLinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
12
- /**
13
- * The href url of the anchor tag
14
- */
15
- href: string;
16
- /**
17
- * The max-width of the link text
18
- *
19
- * @default 350px
20
- */
21
- maxWidth?: number;
22
- /**
23
- * A handler function for overriding hard-redirects with links
24
- */
25
- onAction?: (href: string) => void;
26
- }
27
-
28
- type StyledLinkProps = Pick<BreadcrumbLinkProps, 'maxWidth' | 'href'>;
29
-
30
- const {color, ...subtextLargeStyles} = type.levels.subtext.large;
31
-
32
- const StyledLink = styled(Hyperlink)(
33
- {
34
- ...subtextLargeStyles,
35
- },
36
- ({maxWidth}: StyledLinkProps) => ({
37
- ...truncateStyles(maxWidth),
38
- })
39
- );
40
-
41
- export const BreadcrumbLink = ({
42
- maxWidth,
43
- onAction,
44
- onClick,
45
- href,
46
- children,
47
- ...props
48
- }: BreadcrumbLinkProps) => {
49
- const ref = React.useRef<HTMLAnchorElement>(null);
50
- const {isTooltipOpen, openTooltip, closeTooltip, tooltipProps} = useTruncateTooltip(ref);
51
-
52
- const handleClick = (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
53
- event.preventDefault();
54
- // allow an override to the hard redirect
55
- if (onAction) {
56
- onAction(href);
57
- } else {
58
- // default to hard redirecting
59
- window.location.href = href;
60
- }
61
- // don't block the onClick event if it's provided
62
- if (onClick) {
63
- onClick(event);
64
- }
65
- };
66
-
67
- return (
68
- <React.Fragment>
69
- <StyledLink
70
- ref={ref}
71
- maxWidth={maxWidth}
72
- onMouseEnter={openTooltip}
73
- onMouseLeave={closeTooltip}
74
- onFocus={openTooltip}
75
- onBlur={closeTooltip}
76
- href={href}
77
- role="link"
78
- onClick={handleClick}
79
- {...props}
80
- >
81
- {children}
82
- </StyledLink>
83
- <Popper open={isTooltipOpen} anchorElement={ref} placement="top">
84
- <TooltipContainer {...tooltipProps}>{children}</TooltipContainer>
85
- </Popper>
86
- </React.Fragment>
87
- );
88
- };
@@ -1,30 +0,0 @@
1
- import React from 'react';
2
- import {SystemIcon} from '@workday/canvas-kit-react/icon';
3
- import {chevronLeftSmallIcon, chevronRightSmallIcon} from '@workday/canvas-system-icons-web';
4
- import {colors} from '@workday/canvas-kit-react/tokens';
5
-
6
- import {useRTL} from '../hooks';
7
- import {Flex} from '@workday/canvas-kit-react/layout';
8
-
9
- export type ListItemProps = React.HTMLAttributes<HTMLLIElement>;
10
-
11
- export const BreadcrumbsListItem = ({children, ...props}: ListItemProps) => {
12
- const {shouldUseRTL} = useRTL();
13
- const icon = shouldUseRTL ? chevronLeftSmallIcon : chevronRightSmallIcon;
14
-
15
- return (
16
- <Flex as="li" alignItems="center" {...props}>
17
- {children}
18
- <SystemIcon
19
- icon={icon}
20
- color={colors.licorice200}
21
- colorHover={colors.licorice200}
22
- size={20}
23
- height={32}
24
- width={32}
25
- styles={{justifyContent: 'center', alignItems: 'center', display: 'inline-flex'}}
26
- aria-hidden
27
- />
28
- </Flex>
29
- );
30
- };
@@ -1,114 +0,0 @@
1
- import React, {Children, useLayoutEffect, useState, useEffect} from 'react';
2
-
3
- import {BreadcrumbLink} from './Link';
4
- import {Breadcrumb} from '../types';
5
-
6
- export const useCollapse = <E extends HTMLElement>(listEl: React.RefObject<E>, maxWidth = 0) => {
7
- const [shouldCollapseList, setShouldCollapseList] = useState<boolean>(false);
8
-
9
- useLayoutEffect(() => {
10
- const listWidth = listEl.current?.clientWidth || 0;
11
- setShouldCollapseList(listWidth > maxWidth);
12
- }, [listEl, maxWidth]);
13
-
14
- return {shouldCollapseList};
15
- };
16
-
17
- const getBreadcrumbLink = (breadcrumb: React.ReactElement) => {
18
- return Children.toArray(breadcrumb.props.children).filter(child => {
19
- return React.isValidElement(child) && child.type === BreadcrumbLink;
20
- })[0] as React.ReactElement;
21
- };
22
-
23
- const buildCollapsedList = (
24
- list: Breadcrumb[],
25
- containerWidth: number,
26
- maxWidth: number,
27
- collapsedList: Breadcrumb[] = []
28
- ): Breadcrumb[] => {
29
- // TODO: Calculate expander width dynamically
30
- const EXPANDER_WIDTH = 66;
31
- // recurse over the breadcrumb items until the containerWidth is less than or equal to the maxWidth
32
- if (!list.length || containerWidth + EXPANDER_WIDTH <= maxWidth) {
33
- return collapsedList;
34
- }
35
-
36
- const [firstCrumb, ...restList] = list;
37
- const updatedCollapsedList = collapsedList.concat(firstCrumb);
38
- const adjustedWidth = containerWidth - firstCrumb.width;
39
- return buildCollapsedList(restList, adjustedWidth, maxWidth, updatedCollapsedList);
40
- };
41
-
42
- export const useBuildCollapsedList = <E extends HTMLElement>(
43
- listEl: React.RefObject<E>,
44
- children: React.ReactNode,
45
- maxWidth: number
46
- ) => {
47
- const [collapsedItems, setCollapsedItems] = useState<Breadcrumb[]>([]);
48
-
49
- useLayoutEffect(() => {
50
- const listItemNodes = listEl.current ? listEl.current.querySelectorAll('li') : [];
51
- const containerWidth = listEl.current ? listEl.current.clientWidth : 0;
52
- const listItems: Breadcrumb[] = [];
53
- Children.forEach(children, (child, index) => {
54
- if (!React.isValidElement(child)) {
55
- return;
56
- }
57
- const breadcrumbLink = getBreadcrumbLink(child);
58
- // We should make this match work better
59
- const listItemNode = listItemNodes[index];
60
-
61
- // We might need to allow folks to spread more props from the link
62
- listItems.push({
63
- index: index, // TODO: use unique identifiers instead of indices
64
- link: breadcrumbLink?.props?.href || '',
65
- text: listItemNode ? listItemNode.innerText : '',
66
- width: listItemNode ? listItemNode.clientWidth : 0,
67
- onAction: breadcrumbLink?.props?.onAction,
68
- } as Breadcrumb);
69
- });
70
-
71
- // don't collapse the root breadcrumb
72
- const collapsibleListItems = listItems.slice(1);
73
- const collapsedList = buildCollapsedList(collapsibleListItems, containerWidth, maxWidth);
74
- setCollapsedItems(collapsedList);
75
- // eslint-disable-next-line react-hooks/exhaustive-deps
76
- }, [maxWidth]);
77
-
78
- const collapsedItemIndices = collapsedItems.map(child => child.index);
79
- return {collapsedItems, collapsedItemIndices};
80
- };
81
-
82
- export const useTruncateTooltip = (ref?: React.RefObject<HTMLSpanElement>) => {
83
- const [isTooltipOpen, setIsTooltipOpen] = useState(false);
84
- const [shouldShowTooltip, setShouldShowTooltip] = useState(false);
85
- useEffect(() => {
86
- if (ref?.current) {
87
- setShouldShowTooltip(ref.current.scrollWidth > ref.current.clientWidth);
88
- }
89
- }, [ref]);
90
-
91
- const openTooltip = (event: React.MouseEvent | React.FocusEvent) => {
92
- const {currentTarget} = event;
93
- // if the target is truncated, show the tooltip
94
- if (currentTarget.scrollWidth > currentTarget.clientWidth) {
95
- setIsTooltipOpen(true);
96
- }
97
- };
98
-
99
- const closeTooltip = () => {
100
- setIsTooltipOpen(false);
101
- };
102
-
103
- const tooltipProps = {
104
- role: 'tooltip',
105
- };
106
-
107
- return {
108
- isTooltipOpen,
109
- openTooltip,
110
- closeTooltip,
111
- shouldShowTooltip,
112
- tooltipProps,
113
- };
114
- };
@@ -1,26 +0,0 @@
1
- import React from 'react';
2
- import {createComponent} from '@workday/canvas-kit-react/common';
3
- import {Flex} from '@workday/canvas-kit-react/layout';
4
-
5
- export type BreadcrumbsListProps = React.HTMLAttributes<HTMLUListElement>;
6
-
7
- export const BreadcrumbsList = createComponent('ul')({
8
- displayName: 'BreadcrumbsList',
9
- Component: (elemProps: BreadcrumbsListProps, ref, Element) => {
10
- return (
11
- <Flex
12
- as={Element}
13
- padding="zero"
14
- margin="zero"
15
- display="inline-flex"
16
- alignItems="center"
17
- minHeight={40}
18
- listStyle="none"
19
- style={{boxSizing: 'border-box'}}
20
- role="list"
21
- ref={ref}
22
- {...elemProps}
23
- />
24
- );
25
- },
26
- });
@@ -1,12 +0,0 @@
1
- import {CSSObject} from '@emotion/styled';
2
-
3
- // default max-width for truncating text
4
- const DEFAULT_MAX_WIDTH = 350;
5
-
6
- export const truncateStyles = (maxWidth: number = DEFAULT_MAX_WIDTH): CSSObject => ({
7
- display: 'inline-block',
8
- maxWidth,
9
- overflow: 'hidden',
10
- textOverflow: 'ellipsis',
11
- whiteSpace: 'nowrap',
12
- });
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
-
3
- export interface BreadcrumbsNavProps extends React.HTMLAttributes<HTMLElement> {
4
- /**
5
- * The accessibility label to indicate the type of navigation.
6
- *
7
- * Suggested value: "breadcrumb"
8
- */
9
- 'aria-label': string;
10
- }
11
-
12
- export const BreadcrumbsNav = ({'aria-label': ariaLabel, ...elemProps}: BreadcrumbsNavProps) => {
13
- return <nav role="navigation" aria-label={ariaLabel} {...elemProps} />;
14
- };
@@ -1,13 +0,0 @@
1
- import {
2
- useTheme,
3
- PartialEmotionCanvasTheme,
4
- ContentDirection,
5
- } from '@workday/canvas-kit-react/common';
6
-
7
- export const useRTL = (partialTheme?: PartialEmotionCanvasTheme) => {
8
- const theme = useTheme(partialTheme);
9
- const shouldUseRTL = theme.canvas.direction === ContentDirection.RTL;
10
- return {
11
- shouldUseRTL,
12
- };
13
- };
@@ -1,15 +0,0 @@
1
- import {CurrentItem} from './List/CurrentItem';
2
- import {BreadcrumbLink} from './List/Link';
3
- import {BreadcrumbsNav} from './Nav';
4
- import {CollapsibleList} from './List/Collapsible';
5
- import {BreadcrumbsListItem} from './List/ListItem';
6
- import {BreadcrumbsList} from './List';
7
-
8
- export const Breadcrumbs = {
9
- Nav: BreadcrumbsNav,
10
- CollapsibleList,
11
- List: BreadcrumbsList,
12
- ListItem: BreadcrumbsListItem,
13
- Link: BreadcrumbLink,
14
- CurrentItem,
15
- };
@@ -1,7 +0,0 @@
1
- export interface Breadcrumb extends React.HTMLAttributes<HTMLAnchorElement> {
2
- index: number;
3
- link: string;
4
- text: string;
5
- width: number;
6
- onAction?: (href: string) => void;
7
- }
@@ -1,6 +0,0 @@
1
- {
2
- "main": "../dist/commonjs/breadcrumbs",
3
- "module": "../dist/es6/breadcrumbs",
4
- "sideEffects": false,
5
- "types": "../dist/es6/breadcrumbs"
6
- }
@@ -1,2 +0,0 @@
1
- export * from './lib/Breadcrumbs';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../breadcrumbs/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
@@ -1,13 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./lib/Breadcrumbs"), exports);
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- import { CanvasSystemIcon } from '@workday/design-assets-types';
3
- export interface DropdownButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
4
- /**
5
- * The accessibility label for the button
6
- */
7
- 'aria-label': string;
8
- /**
9
- * The Canvas System Icon for the button
10
- *
11
- * @default relatedActionsIcon
12
- */
13
- buttonIcon?: CanvasSystemIcon;
14
- /**
15
- * The boolean to determine whether the button should be in a 'toggled' state
16
- */
17
- toggled: boolean;
18
- }
19
- export declare const DropdownButton: import("@workday/canvas-kit-react/common").ElementComponent<"button", DropdownButtonProps>;
20
- //# sourceMappingURL=Button.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../../../breadcrumbs/lib/Breadcrumbs/Dropdown/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAI9D,MAAM,WAAW,mBAAoB,SAAQ,KAAK,CAAC,cAAc,CAAC,iBAAiB,CAAC;IAClF;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,eAAO,MAAM,cAAc,4FA2BzB,CAAC"}