@jobber/components 6.36.0 → 6.37.0
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/Banner-cjs.js +1 -1
- package/dist/Banner-es.js +2 -2
- package/dist/Button/Button.d.ts +742 -6
- package/dist/Button/index.cjs +1 -1
- package/dist/Button-cjs.js +30 -13
- package/dist/Button-es.js +31 -14
- package/dist/ButtonDismiss-cjs.js +1 -1
- package/dist/ButtonDismiss-es.js +2 -2
- package/dist/Card-cjs.js +2 -2
- package/dist/Card-es.js +3 -3
- package/dist/Chip/Chip.d.ts +3 -2
- package/dist/Chip/Chip.types.d.ts +64 -0
- package/dist/Chip/index.cjs +1 -1
- package/dist/Chip-cjs.js +48 -23
- package/dist/Chip-es.js +49 -24
- package/dist/ChipDismissible-cjs.js +4 -4
- package/dist/ChipDismissible-es.js +5 -5
- package/dist/ComboboxActivator-cjs.js +1 -1
- package/dist/ComboboxActivator-es.js +3 -3
- package/dist/ComboboxContentHeader-cjs.js +1 -1
- package/dist/ComboboxContentHeader-es.js +2 -2
- package/dist/ComboboxTrigger-cjs.js +1 -1
- package/dist/ComboboxTrigger-es.js +2 -2
- package/dist/DataListActions-cjs.js +2 -2
- package/dist/DataListActions-es.js +3 -3
- package/dist/DataListEmptyState-cjs.js +1 -1
- package/dist/DataListEmptyState-es.js +2 -2
- package/dist/DataListHeader-cjs.js +1 -1
- package/dist/DataListHeader-es.js +2 -2
- package/dist/DataListItemActionsOverflow-cjs.js +1 -1
- package/dist/DataListItemActionsOverflow-es.js +2 -2
- package/dist/DataListLoadMore-cjs.js +1 -1
- package/dist/DataListLoadMore-es.js +2 -2
- package/dist/DataListSearch-cjs.js +1 -1
- package/dist/DataListSearch-es.js +2 -2
- package/dist/DataListSort-cjs.js +1 -1
- package/dist/DataListSort-es.js +2 -2
- package/dist/DataTable-cjs.js +2 -2
- package/dist/DataTable-es.js +3 -3
- package/dist/DatePicker-cjs.js +3 -3
- package/dist/DatePicker-es.js +4 -4
- package/dist/FeatureSwitch-cjs.js +1 -1
- package/dist/FeatureSwitch-es.js +2 -2
- package/dist/FormField-cjs.js +1 -1
- package/dist/FormField-es.js +2 -2
- package/dist/FormatFile-cjs.js +1 -1
- package/dist/FormatFile-es.js +2 -2
- package/dist/Gallery-cjs.js +1 -1
- package/dist/Gallery-es.js +2 -2
- package/dist/InputAvatar-cjs.js +1 -1
- package/dist/InputAvatar-es.js +2 -2
- package/dist/InputFile-cjs.js +1 -1
- package/dist/InputFile-es.js +2 -2
- package/dist/InternalChipDismissible-cjs.js +4 -4
- package/dist/InternalChipDismissible-es.js +6 -6
- package/dist/LightBox-cjs.js +2 -2
- package/dist/LightBox-es.js +3 -3
- package/dist/Menu-cjs.js +1 -1
- package/dist/Menu-es.js +2 -2
- package/dist/Modal-cjs.js +3 -3
- package/dist/Modal-es.js +4 -4
- package/dist/Page-cjs.js +2 -2
- package/dist/Page-es.js +3 -3
- package/dist/SideDrawer-cjs.js +2 -2
- package/dist/SideDrawer-es.js +3 -3
- package/dist/Tabs/Tabs.d.ts +1 -1
- package/dist/Tabs/hooks/useArrowKeyNavigation.d.ts +1 -1
- package/dist/Tabs-cjs.js +44 -10
- package/dist/Tabs-es.js +44 -10
- package/dist/index.cjs +2 -2
- package/dist/showToast-cjs.js +2 -2
- package/dist/showToast-es.js +3 -3
- package/package.json +2 -2
package/dist/Menu-es.js
CHANGED
|
@@ -7,7 +7,7 @@ import { usePopper } from 'react-popper';
|
|
|
7
7
|
import { u as useIsMounted_2 } from './useIsMounted-es.js';
|
|
8
8
|
import ReactDOM__default from 'react-dom';
|
|
9
9
|
import { u as useFocusTrap_2 } from './useFocusTrap-es.js';
|
|
10
|
-
import { B as
|
|
10
|
+
import { B as ButtonNamespace } from './Button-es.js';
|
|
11
11
|
import { T as Typography } from './Typography-es.js';
|
|
12
12
|
import { I as Icon } from './Icon-es.js';
|
|
13
13
|
import { f as formFieldFocusAttribute } from './useFormFieldFocus-es.js';
|
|
@@ -96,7 +96,7 @@ function Menu({ activator, items }) {
|
|
|
96
96
|
const positionAttributes = width >= SMALL_SCREEN_BREAKPOINT
|
|
97
97
|
? Object.assign(Object.assign({}, attributes.popper), { style: popperStyles.popper }) : {};
|
|
98
98
|
if (!activator) {
|
|
99
|
-
activator = (React__default.createElement(
|
|
99
|
+
activator = (React__default.createElement(ButtonNamespace, { fullWidth: true, label: "More Actions", icon: "more", type: "secondary" }));
|
|
100
100
|
}
|
|
101
101
|
return (React__default.createElement("div", { className: wrapperClasses, onClick: handleParentClick },
|
|
102
102
|
React__default.createElement("div", { ref: popperRef }, React__default.cloneElement(activator, {
|
package/dist/Modal-cjs.js
CHANGED
|
@@ -54,10 +54,10 @@ function Actions({ primary, secondary, tertiary }) {
|
|
|
54
54
|
}
|
|
55
55
|
return (React.createElement(React.Fragment, null, shouldShow && (React.createElement("div", { className: styles.actionBar },
|
|
56
56
|
React.createElement("div", { className: styles.rightAction },
|
|
57
|
-
primary && React.createElement(Button.
|
|
58
|
-
secondary && React.createElement(Button.
|
|
57
|
+
primary && React.createElement(Button.ButtonNamespace, Object.assign({}, primary)),
|
|
58
|
+
secondary && React.createElement(Button.ButtonNamespace, Object.assign({}, secondary))),
|
|
59
59
|
tertiary && (React.createElement("div", { className: styles.leftAction },
|
|
60
|
-
React.createElement(Button.
|
|
60
|
+
React.createElement(Button.ButtonNamespace, Object.assign({}, tertiary))))))));
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
exports.Modal = Modal;
|
package/dist/Modal-es.js
CHANGED
|
@@ -6,7 +6,7 @@ import { u as useRefocusOnActivator_2 } from './useRefocusOnActivator-es.js';
|
|
|
6
6
|
import { u as useOnKeyDown_2 } from './useOnKeyDown-es.js';
|
|
7
7
|
import { u as useFocusTrap_2 } from './useFocusTrap-es.js';
|
|
8
8
|
import { H as Heading } from './Heading-es.js';
|
|
9
|
-
import { B as
|
|
9
|
+
import { B as ButtonNamespace } from './Button-es.js';
|
|
10
10
|
import { B as ButtonDismiss } from './ButtonDismiss-es.js';
|
|
11
11
|
|
|
12
12
|
var styles = {"container":"y3M-9xoEnk0-","overlay":"zkyJp1mib-U-","modal":"gMPgiggaud8-","header":"_5sBzUnyOqD0-","closeButton":"_4gw63G7IYG0-","actionBar":"cwVJrrJkNDg-","leftAction":"MkD4pNUKeAA-","rightAction":"C-yC8JKpQLg-","spinning":"_7hYqr6OrfHs-"};
|
|
@@ -52,10 +52,10 @@ function Actions({ primary, secondary, tertiary }) {
|
|
|
52
52
|
}
|
|
53
53
|
return (React__default.createElement(React__default.Fragment, null, shouldShow && (React__default.createElement("div", { className: styles.actionBar },
|
|
54
54
|
React__default.createElement("div", { className: styles.rightAction },
|
|
55
|
-
primary && React__default.createElement(
|
|
56
|
-
secondary && React__default.createElement(
|
|
55
|
+
primary && React__default.createElement(ButtonNamespace, Object.assign({}, primary)),
|
|
56
|
+
secondary && React__default.createElement(ButtonNamespace, Object.assign({}, secondary))),
|
|
57
57
|
tertiary && (React__default.createElement("div", { className: styles.leftAction },
|
|
58
|
-
React__default.createElement(
|
|
58
|
+
React__default.createElement(ButtonNamespace, Object.assign({}, tertiary))))))));
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
export { Modal as M };
|
package/dist/Page-cjs.js
CHANGED
|
@@ -46,9 +46,9 @@ function Page({ title, titleMetaData, intro, externalIntroLinks, subtitle, child
|
|
|
46
46
|
React.createElement(Markdown.Markdown, { content: subtitle, basicUsage: true })))))),
|
|
47
47
|
showActionGroup && (React.createElement("div", { className: styles.actionGroup },
|
|
48
48
|
primaryAction && (React.createElement("div", { className: styles.primaryAction, ref: primaryAction.ref },
|
|
49
|
-
React.createElement(Button.
|
|
49
|
+
React.createElement(Button.ButtonNamespace, Object.assign({}, getActionProps(primaryAction))))),
|
|
50
50
|
secondaryAction && (React.createElement("div", { className: styles.actionButton, ref: secondaryAction.ref },
|
|
51
|
-
React.createElement(Button.
|
|
51
|
+
React.createElement(Button.ButtonNamespace, Object.assign({}, getActionProps(secondaryAction))))),
|
|
52
52
|
showMenu && (React.createElement("div", { className: styles.actionButton },
|
|
53
53
|
React.createElement(Menu.Menu, { items: moreActionsMenu })))))),
|
|
54
54
|
intro && (React.createElement(Text.Text, { size: "large" },
|
package/dist/Page-es.js
CHANGED
|
@@ -5,7 +5,7 @@ import { H as Heading } from './Heading-es.js';
|
|
|
5
5
|
import { T as Text } from './Text-es.js';
|
|
6
6
|
import { C as Content } from './Content-es.js';
|
|
7
7
|
import { M as Markdown } from './Markdown-es.js';
|
|
8
|
-
import { B as
|
|
8
|
+
import { B as ButtonNamespace } from './Button-es.js';
|
|
9
9
|
import { M as Menu } from './Menu-es.js';
|
|
10
10
|
import { E as Emphasis } from './Emphasis-es.js';
|
|
11
11
|
|
|
@@ -44,9 +44,9 @@ function Page({ title, titleMetaData, intro, externalIntroLinks, subtitle, child
|
|
|
44
44
|
React__default.createElement(Markdown, { content: subtitle, basicUsage: true })))))),
|
|
45
45
|
showActionGroup && (React__default.createElement("div", { className: styles.actionGroup },
|
|
46
46
|
primaryAction && (React__default.createElement("div", { className: styles.primaryAction, ref: primaryAction.ref },
|
|
47
|
-
React__default.createElement(
|
|
47
|
+
React__default.createElement(ButtonNamespace, Object.assign({}, getActionProps(primaryAction))))),
|
|
48
48
|
secondaryAction && (React__default.createElement("div", { className: styles.actionButton, ref: secondaryAction.ref },
|
|
49
|
-
React__default.createElement(
|
|
49
|
+
React__default.createElement(ButtonNamespace, Object.assign({}, getActionProps(secondaryAction))))),
|
|
50
50
|
showMenu && (React__default.createElement("div", { className: styles.actionButton },
|
|
51
51
|
React__default.createElement(Menu, { items: moreActionsMenu })))))),
|
|
52
52
|
intro && (React__default.createElement(Text, { size: "large" },
|
package/dist/SideDrawer-cjs.js
CHANGED
|
@@ -61,7 +61,7 @@ function SideDrawerBackButton({ onClick, }) {
|
|
|
61
61
|
}, []);
|
|
62
62
|
if (!backPortal)
|
|
63
63
|
return null;
|
|
64
|
-
return ReactDOM.createPortal(React.createElement(Button.
|
|
64
|
+
return ReactDOM.createPortal(React.createElement(Button.ButtonNamespace, { ariaLabel: "Back", icon: "longArrowLeft", variation: "subtle", type: "tertiary", onClick: onClick }), backPortal);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
function SideDrawerFooter({ children }) {
|
|
@@ -143,7 +143,7 @@ function SideDrawer({ children, onRequestClose, open, variation = "base", scroll
|
|
|
143
143
|
React.createElement("div", Object.assign({ className: classnames(styles.heading) }, slots.title.attr))),
|
|
144
144
|
React.createElement("div", { className: styles.headerActions },
|
|
145
145
|
React.createElement("div", Object.assign({ className: styles.hideWhenEmpty }, slots.actions.attr)),
|
|
146
|
-
React.createElement(Button.
|
|
146
|
+
React.createElement(Button.ButtonNamespace, { ariaLabel: "Close", icon: "cross", onClick: onRequestClose, type: "tertiary", variation: "subtle" }))),
|
|
147
147
|
React.createElement("div", Object.assign({ className: styles.hideWhenEmpty }, slots.toolbar.attr))),
|
|
148
148
|
React.createElement("div", { className: styles.content },
|
|
149
149
|
React.createElement("div", { className: styles.headerShadowListener, ref: headerShadowRef }),
|
package/dist/SideDrawer-es.js
CHANGED
|
@@ -8,7 +8,7 @@ import { u as useInView_2 } from './useInView-es.js';
|
|
|
8
8
|
import { u as useIsMounted_2 } from './useIsMounted-es.js';
|
|
9
9
|
import { tokens } from '@jobber/design';
|
|
10
10
|
import { H as Heading } from './Heading-es.js';
|
|
11
|
-
import { B as
|
|
11
|
+
import { B as ButtonNamespace } from './Button-es.js';
|
|
12
12
|
import { F as Flex } from './Flex-es.js';
|
|
13
13
|
|
|
14
14
|
const SideDrawerContext = createContext({
|
|
@@ -59,7 +59,7 @@ function SideDrawerBackButton({ onClick, }) {
|
|
|
59
59
|
}, []);
|
|
60
60
|
if (!backPortal)
|
|
61
61
|
return null;
|
|
62
|
-
return createPortal(React__default.createElement(
|
|
62
|
+
return createPortal(React__default.createElement(ButtonNamespace, { ariaLabel: "Back", icon: "longArrowLeft", variation: "subtle", type: "tertiary", onClick: onClick }), backPortal);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
function SideDrawerFooter({ children }) {
|
|
@@ -141,7 +141,7 @@ function SideDrawer({ children, onRequestClose, open, variation = "base", scroll
|
|
|
141
141
|
React__default.createElement("div", Object.assign({ className: classnames(styles.heading) }, slots.title.attr))),
|
|
142
142
|
React__default.createElement("div", { className: styles.headerActions },
|
|
143
143
|
React__default.createElement("div", Object.assign({ className: styles.hideWhenEmpty }, slots.actions.attr)),
|
|
144
|
-
React__default.createElement(
|
|
144
|
+
React__default.createElement(ButtonNamespace, { ariaLabel: "Close", icon: "cross", onClick: onRequestClose, type: "tertiary", variation: "subtle" }))),
|
|
145
145
|
React__default.createElement("div", Object.assign({ className: styles.hideWhenEmpty }, slots.toolbar.attr))),
|
|
146
146
|
React__default.createElement("div", { className: styles.content },
|
|
147
147
|
React__default.createElement("div", { className: styles.headerShadowListener, ref: headerShadowRef }),
|
package/dist/Tabs/Tabs.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactElement, ReactNode } from "react";
|
|
2
2
|
interface TabsProps {
|
|
3
|
-
readonly children: ReactElement | ReactElement
|
|
3
|
+
readonly children: ReactElement | Array<ReactElement | null | undefined | boolean>;
|
|
4
4
|
/**
|
|
5
5
|
* Specifies the index of the tab that should be active on mount
|
|
6
6
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
interface UseArrowKeyNavigationProps {
|
|
2
|
-
elementsRef: React.RefObject<
|
|
2
|
+
elementsRef: React.RefObject<Map<number, HTMLElement>>;
|
|
3
3
|
onActivate: (index: number) => void;
|
|
4
4
|
}
|
|
5
5
|
export declare const useArrowKeyNavigation: ({ elementsRef, onActivate, }: UseArrowKeyNavigationProps) => (event: React.KeyboardEvent<HTMLElement>) => void;
|
package/dist/Tabs-cjs.js
CHANGED
|
@@ -43,11 +43,11 @@ const useArrowKeyNavigation = ({ elementsRef, onActivate, }) => {
|
|
|
43
43
|
const elements = elementsRef.current;
|
|
44
44
|
if (!elements)
|
|
45
45
|
return;
|
|
46
|
-
const currentIndex = elements
|
|
46
|
+
const currentIndex = getActiveTabIndex(elements);
|
|
47
47
|
if (currentIndex === -1)
|
|
48
48
|
return;
|
|
49
49
|
const focusAndActivateTab = (index) => {
|
|
50
|
-
const element = elements
|
|
50
|
+
const element = elements.get(index);
|
|
51
51
|
if (element) {
|
|
52
52
|
element.focus();
|
|
53
53
|
onActivate(index);
|
|
@@ -55,21 +55,30 @@ const useArrowKeyNavigation = ({ elementsRef, onActivate, }) => {
|
|
|
55
55
|
};
|
|
56
56
|
if (event.key === "ArrowRight") {
|
|
57
57
|
event.preventDefault();
|
|
58
|
-
const nextIndex = (currentIndex + 1) % elements.
|
|
58
|
+
const nextIndex = (currentIndex + 1) % elements.size;
|
|
59
59
|
focusAndActivateTab(nextIndex);
|
|
60
60
|
}
|
|
61
61
|
else if (event.key === "ArrowLeft") {
|
|
62
62
|
event.preventDefault();
|
|
63
|
-
const prevIndex = (currentIndex - 1 + elements.
|
|
63
|
+
const prevIndex = (currentIndex - 1 + elements.size) % elements.size;
|
|
64
64
|
focusAndActivateTab(prevIndex);
|
|
65
65
|
}
|
|
66
66
|
}, [elementsRef, onActivate]);
|
|
67
67
|
return handleKeyDown;
|
|
68
68
|
};
|
|
69
|
+
function getActiveTabIndex(elements) {
|
|
70
|
+
const currentTab = Array.from(elements).find(([, element]) => element === document.activeElement);
|
|
71
|
+
if (!currentTab) {
|
|
72
|
+
return -1;
|
|
73
|
+
}
|
|
74
|
+
const [currentIndex] = currentTab;
|
|
75
|
+
return currentIndex;
|
|
76
|
+
}
|
|
69
77
|
|
|
70
78
|
function Tabs({ children, defaultTab = 0, activeTab: controlledActiveTab, onTabChange, }) {
|
|
71
79
|
var _a;
|
|
72
|
-
const
|
|
80
|
+
const tabChildren = getActiveTabs(children);
|
|
81
|
+
const activeTabInitialValue = defaultTab < tabChildren.length ? defaultTab : 0;
|
|
73
82
|
const [internalActiveTab, setInternalActiveTab] = React.useState(activeTabInitialValue);
|
|
74
83
|
const activeTab = controlledActiveTab !== undefined ? controlledActiveTab : internalActiveTab;
|
|
75
84
|
const { overflowRight, overflowLeft, tabRow } = useTabsOverflow();
|
|
@@ -77,7 +86,7 @@ function Tabs({ children, defaultTab = 0, activeTab: controlledActiveTab, onTabC
|
|
|
77
86
|
[styles.overflowRight]: overflowRight,
|
|
78
87
|
[styles.overflowLeft]: overflowLeft,
|
|
79
88
|
});
|
|
80
|
-
const tabRefs = React.useRef(
|
|
89
|
+
const tabRefs = React.useRef(new Map());
|
|
81
90
|
const activateTab = (index) => {
|
|
82
91
|
return () => {
|
|
83
92
|
if (controlledActiveTab === undefined) {
|
|
@@ -92,15 +101,28 @@ function Tabs({ children, defaultTab = 0, activeTab: controlledActiveTab, onTabC
|
|
|
92
101
|
elementsRef: tabRefs,
|
|
93
102
|
onActivate: index => activateTab(index)(),
|
|
94
103
|
});
|
|
95
|
-
const activeTabProps = (_a =
|
|
104
|
+
const activeTabProps = (_a = tabChildren[activeTab]) === null || _a === void 0 ? void 0 : _a.props;
|
|
96
105
|
React.useEffect(() => {
|
|
97
|
-
if (activeTab >
|
|
106
|
+
if (activeTab > tabChildren.length - 1) {
|
|
98
107
|
setInternalActiveTab(activeTabInitialValue);
|
|
99
108
|
}
|
|
100
|
-
}, [
|
|
109
|
+
}, [tabChildren.length]);
|
|
101
110
|
return (React.createElement("div", { className: styles.tabs },
|
|
102
111
|
React.createElement("div", { className: overflowClassNames },
|
|
103
|
-
React.createElement("ul", { role: "tablist", className: styles.tabRow, ref: tabRow, onKeyDown: handleKeyDown }, React.Children.map(children,
|
|
112
|
+
React.createElement("ul", { role: "tablist", className: styles.tabRow, ref: tabRow, onKeyDown: handleKeyDown }, React.Children.map(children, child => {
|
|
113
|
+
if (!isChildTab(child)) {
|
|
114
|
+
return child;
|
|
115
|
+
}
|
|
116
|
+
const index = tabChildren.findIndex(tab => tab.props.label === child.props.label);
|
|
117
|
+
return (React.createElement(InternalTab, { label: child.props.label, selected: activeTab === index, activateTab: activateTab(index), onClick: child.props.onClick, ref: el => {
|
|
118
|
+
if (el) {
|
|
119
|
+
tabRefs.current.set(index, el);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
tabRefs.current.delete(index);
|
|
123
|
+
}
|
|
124
|
+
}, tabIndex: activeTab === index ? 0 : -1 }));
|
|
125
|
+
}))),
|
|
104
126
|
React.createElement("section", { role: "tabpanel", className: styles.tabContent, "aria-label": activeTabProps === null || activeTabProps === void 0 ? void 0 : activeTabProps.label }, activeTabProps === null || activeTabProps === void 0 ? void 0 : activeTabProps.children)));
|
|
105
127
|
}
|
|
106
128
|
function Tab({ label }) {
|
|
@@ -115,6 +137,18 @@ const InternalTab = React.forwardRef(({ label, selected, activateTab, onClick, t
|
|
|
115
137
|
}, ref: ref, tabIndex: tabIndex }, typeof label === "string" ? (React.createElement(Typography.Typography, { element: "span", size: "large", fontWeight: "semiBold" }, label)) : (label))));
|
|
116
138
|
});
|
|
117
139
|
InternalTab.displayName = "InternalTab";
|
|
140
|
+
function getActiveTabs(children) {
|
|
141
|
+
const activeTabChildren = [];
|
|
142
|
+
React.Children.toArray(children).forEach(child => {
|
|
143
|
+
if (isChildTab(child)) {
|
|
144
|
+
activeTabChildren.push(child);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
return activeTabChildren;
|
|
148
|
+
}
|
|
149
|
+
function isChildTab(child) {
|
|
150
|
+
return React.isValidElement(child) && child.type === Tab;
|
|
151
|
+
}
|
|
118
152
|
|
|
119
153
|
exports.Tab = Tab;
|
|
120
154
|
exports.Tabs = Tabs;
|
package/dist/Tabs-es.js
CHANGED
|
@@ -41,11 +41,11 @@ const useArrowKeyNavigation = ({ elementsRef, onActivate, }) => {
|
|
|
41
41
|
const elements = elementsRef.current;
|
|
42
42
|
if (!elements)
|
|
43
43
|
return;
|
|
44
|
-
const currentIndex = elements
|
|
44
|
+
const currentIndex = getActiveTabIndex(elements);
|
|
45
45
|
if (currentIndex === -1)
|
|
46
46
|
return;
|
|
47
47
|
const focusAndActivateTab = (index) => {
|
|
48
|
-
const element = elements
|
|
48
|
+
const element = elements.get(index);
|
|
49
49
|
if (element) {
|
|
50
50
|
element.focus();
|
|
51
51
|
onActivate(index);
|
|
@@ -53,21 +53,30 @@ const useArrowKeyNavigation = ({ elementsRef, onActivate, }) => {
|
|
|
53
53
|
};
|
|
54
54
|
if (event.key === "ArrowRight") {
|
|
55
55
|
event.preventDefault();
|
|
56
|
-
const nextIndex = (currentIndex + 1) % elements.
|
|
56
|
+
const nextIndex = (currentIndex + 1) % elements.size;
|
|
57
57
|
focusAndActivateTab(nextIndex);
|
|
58
58
|
}
|
|
59
59
|
else if (event.key === "ArrowLeft") {
|
|
60
60
|
event.preventDefault();
|
|
61
|
-
const prevIndex = (currentIndex - 1 + elements.
|
|
61
|
+
const prevIndex = (currentIndex - 1 + elements.size) % elements.size;
|
|
62
62
|
focusAndActivateTab(prevIndex);
|
|
63
63
|
}
|
|
64
64
|
}, [elementsRef, onActivate]);
|
|
65
65
|
return handleKeyDown;
|
|
66
66
|
};
|
|
67
|
+
function getActiveTabIndex(elements) {
|
|
68
|
+
const currentTab = Array.from(elements).find(([, element]) => element === document.activeElement);
|
|
69
|
+
if (!currentTab) {
|
|
70
|
+
return -1;
|
|
71
|
+
}
|
|
72
|
+
const [currentIndex] = currentTab;
|
|
73
|
+
return currentIndex;
|
|
74
|
+
}
|
|
67
75
|
|
|
68
76
|
function Tabs({ children, defaultTab = 0, activeTab: controlledActiveTab, onTabChange, }) {
|
|
69
77
|
var _a;
|
|
70
|
-
const
|
|
78
|
+
const tabChildren = getActiveTabs(children);
|
|
79
|
+
const activeTabInitialValue = defaultTab < tabChildren.length ? defaultTab : 0;
|
|
71
80
|
const [internalActiveTab, setInternalActiveTab] = useState(activeTabInitialValue);
|
|
72
81
|
const activeTab = controlledActiveTab !== undefined ? controlledActiveTab : internalActiveTab;
|
|
73
82
|
const { overflowRight, overflowLeft, tabRow } = useTabsOverflow();
|
|
@@ -75,7 +84,7 @@ function Tabs({ children, defaultTab = 0, activeTab: controlledActiveTab, onTabC
|
|
|
75
84
|
[styles.overflowRight]: overflowRight,
|
|
76
85
|
[styles.overflowLeft]: overflowLeft,
|
|
77
86
|
});
|
|
78
|
-
const tabRefs = useRef(
|
|
87
|
+
const tabRefs = useRef(new Map());
|
|
79
88
|
const activateTab = (index) => {
|
|
80
89
|
return () => {
|
|
81
90
|
if (controlledActiveTab === undefined) {
|
|
@@ -90,15 +99,28 @@ function Tabs({ children, defaultTab = 0, activeTab: controlledActiveTab, onTabC
|
|
|
90
99
|
elementsRef: tabRefs,
|
|
91
100
|
onActivate: index => activateTab(index)(),
|
|
92
101
|
});
|
|
93
|
-
const activeTabProps = (_a =
|
|
102
|
+
const activeTabProps = (_a = tabChildren[activeTab]) === null || _a === void 0 ? void 0 : _a.props;
|
|
94
103
|
useEffect(() => {
|
|
95
|
-
if (activeTab >
|
|
104
|
+
if (activeTab > tabChildren.length - 1) {
|
|
96
105
|
setInternalActiveTab(activeTabInitialValue);
|
|
97
106
|
}
|
|
98
|
-
}, [
|
|
107
|
+
}, [tabChildren.length]);
|
|
99
108
|
return (React__default.createElement("div", { className: styles.tabs },
|
|
100
109
|
React__default.createElement("div", { className: overflowClassNames },
|
|
101
|
-
React__default.createElement("ul", { role: "tablist", className: styles.tabRow, ref: tabRow, onKeyDown: handleKeyDown }, React__default.Children.map(children,
|
|
110
|
+
React__default.createElement("ul", { role: "tablist", className: styles.tabRow, ref: tabRow, onKeyDown: handleKeyDown }, React__default.Children.map(children, child => {
|
|
111
|
+
if (!isChildTab(child)) {
|
|
112
|
+
return child;
|
|
113
|
+
}
|
|
114
|
+
const index = tabChildren.findIndex(tab => tab.props.label === child.props.label);
|
|
115
|
+
return (React__default.createElement(InternalTab, { label: child.props.label, selected: activeTab === index, activateTab: activateTab(index), onClick: child.props.onClick, ref: el => {
|
|
116
|
+
if (el) {
|
|
117
|
+
tabRefs.current.set(index, el);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
tabRefs.current.delete(index);
|
|
121
|
+
}
|
|
122
|
+
}, tabIndex: activeTab === index ? 0 : -1 }));
|
|
123
|
+
}))),
|
|
102
124
|
React__default.createElement("section", { role: "tabpanel", className: styles.tabContent, "aria-label": activeTabProps === null || activeTabProps === void 0 ? void 0 : activeTabProps.label }, activeTabProps === null || activeTabProps === void 0 ? void 0 : activeTabProps.children)));
|
|
103
125
|
}
|
|
104
126
|
function Tab({ label }) {
|
|
@@ -113,5 +135,17 @@ const InternalTab = React__default.forwardRef(({ label, selected, activateTab, o
|
|
|
113
135
|
}, ref: ref, tabIndex: tabIndex }, typeof label === "string" ? (React__default.createElement(Typography, { element: "span", size: "large", fontWeight: "semiBold" }, label)) : (label))));
|
|
114
136
|
});
|
|
115
137
|
InternalTab.displayName = "InternalTab";
|
|
138
|
+
function getActiveTabs(children) {
|
|
139
|
+
const activeTabChildren = [];
|
|
140
|
+
React__default.Children.toArray(children).forEach(child => {
|
|
141
|
+
if (isChildTab(child)) {
|
|
142
|
+
activeTabChildren.push(child);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
return activeTabChildren;
|
|
146
|
+
}
|
|
147
|
+
function isChildTab(child) {
|
|
148
|
+
return React__default.isValidElement(child) && child.type === Tab;
|
|
149
|
+
}
|
|
116
150
|
|
|
117
151
|
export { Tabs as T, Tab as a };
|
package/dist/index.cjs
CHANGED
|
@@ -197,13 +197,13 @@ exports.Icon = Icon.Icon;
|
|
|
197
197
|
exports.Avatar = Avatar.Avatar;
|
|
198
198
|
exports.Banner = Banner.Banner;
|
|
199
199
|
exports.Box = Box.Box;
|
|
200
|
-
exports.Button = Button.
|
|
200
|
+
exports.Button = Button.ButtonNamespace;
|
|
201
201
|
exports.useButtonContext = Button.useButtonContext;
|
|
202
202
|
exports.useButtonStyles = Button.useButtonStyles;
|
|
203
203
|
exports.ButtonDismiss = ButtonDismiss.ButtonDismiss;
|
|
204
204
|
exports.Card = Card.Card;
|
|
205
205
|
exports.Checkbox = Checkbox_index.Checkbox;
|
|
206
|
-
exports.Chip = Chip.
|
|
206
|
+
exports.Chip = Chip.ChipNamespace;
|
|
207
207
|
exports.ChipDismissible = ChipDismissible.ChipDismissible;
|
|
208
208
|
exports.ChipSelectable = ChipDismissible.ChipSelectable;
|
|
209
209
|
exports.Chips = Chips.Chips;
|
package/dist/showToast-cjs.js
CHANGED
|
@@ -24,9 +24,9 @@ function Toast({ message, variation = "success", action, actionLabel, }) {
|
|
|
24
24
|
React.createElement("div", { className: styles.slice },
|
|
25
25
|
React.createElement(Icon.Icon, { color: icon.color, name: icon.name }),
|
|
26
26
|
React.createElement(Typography.Typography, { element: "span", size: "large" }, message),
|
|
27
|
-
action && (React.createElement(Button.
|
|
27
|
+
action && (React.createElement(Button.ButtonNamespace, { label: `${actionLabel}`, onClick: action, type: "tertiary" })),
|
|
28
28
|
React.createElement("div", { className: styles.button },
|
|
29
|
-
React.createElement(Button.
|
|
29
|
+
React.createElement(Button.ButtonNamespace, { icon: "remove", ariaLabel: "Hide Notification", onClick: handleToastClose, type: "tertiary", variation: "subtle" })))))));
|
|
30
30
|
function startTimer() {
|
|
31
31
|
timer = setTimeout(() => handleToastClose(), getTimeout());
|
|
32
32
|
}
|
package/dist/showToast-es.js
CHANGED
|
@@ -2,7 +2,7 @@ import React__default, { useState, useEffect, forwardRef, useImperativeHandle, u
|
|
|
2
2
|
import { createRoot } from 'react-dom/client';
|
|
3
3
|
import { AnimatePresence, motion } from 'framer-motion';
|
|
4
4
|
import { I as Icon } from './Icon-es.js';
|
|
5
|
-
import { B as
|
|
5
|
+
import { B as ButtonNamespace } from './Button-es.js';
|
|
6
6
|
import 'classnames';
|
|
7
7
|
import { T as Typography } from './Typography-es.js';
|
|
8
8
|
|
|
@@ -22,9 +22,9 @@ function Toast({ message, variation = "success", action, actionLabel, }) {
|
|
|
22
22
|
React__default.createElement("div", { className: styles.slice },
|
|
23
23
|
React__default.createElement(Icon, { color: icon.color, name: icon.name }),
|
|
24
24
|
React__default.createElement(Typography, { element: "span", size: "large" }, message),
|
|
25
|
-
action && (React__default.createElement(
|
|
25
|
+
action && (React__default.createElement(ButtonNamespace, { label: `${actionLabel}`, onClick: action, type: "tertiary" })),
|
|
26
26
|
React__default.createElement("div", { className: styles.button },
|
|
27
|
-
React__default.createElement(
|
|
27
|
+
React__default.createElement(ButtonNamespace, { icon: "remove", ariaLabel: "Hide Notification", onClick: handleToastClose, type: "tertiary", variation: "subtle" })))))));
|
|
28
28
|
function startTimer() {
|
|
29
29
|
timer = setTimeout(() => handleToastClose(), getTimeout());
|
|
30
30
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.37.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -489,5 +489,5 @@
|
|
|
489
489
|
"> 1%",
|
|
490
490
|
"IE 10"
|
|
491
491
|
],
|
|
492
|
-
"gitHead": "
|
|
492
|
+
"gitHead": "0770317eea930044cc8d1999056d3466a9d4322e"
|
|
493
493
|
}
|