@veracity/vui 2.17.2-beta.0 → 2.17.2-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/footer/footer.js +1 -1
- package/dist/cjs/tabs/tab.d.ts.map +1 -1
- package/dist/cjs/tabs/tabs.d.ts +2 -2
- package/dist/cjs/tabs/tabs.d.ts.map +1 -1
- package/dist/cjs/tabs/tabs.js +18 -14
- package/dist/cjs/tabs/tabs.types.d.ts +9 -6
- package/dist/cjs/tabs/tabs.types.d.ts.map +1 -1
- package/dist/cjs/tabs/tabsNavBar.d.ts.map +1 -1
- package/dist/cjs/tabs/tabsNavBar.js +2 -2
- package/dist/cjs/tabs/useTabsState.d.ts +4 -4
- package/dist/cjs/tabs/useTabsState.d.ts.map +1 -1
- package/dist/cjs/tabs/useTabsState.js +2 -2
- package/dist/esm/footer/footer.js +1 -1
- package/dist/esm/tabs/tab.d.ts.map +1 -1
- package/dist/esm/tabs/tabs.d.ts +2 -2
- package/dist/esm/tabs/tabs.d.ts.map +1 -1
- package/dist/esm/tabs/tabs.js +18 -14
- package/dist/esm/tabs/tabs.types.d.ts +9 -6
- package/dist/esm/tabs/tabs.types.d.ts.map +1 -1
- package/dist/esm/tabs/tabsNavBar.d.ts.map +1 -1
- package/dist/esm/tabs/tabsNavBar.js +2 -2
- package/dist/esm/tabs/useTabsState.d.ts +4 -4
- package/dist/esm/tabs/useTabsState.d.ts.map +1 -1
- package/dist/esm/tabs/useTabsState.js +2 -2
- package/package.json +1 -1
- package/src/footer/footer.tsx +1 -1
- package/src/tabs/tab.tsx +0 -2
- package/src/tabs/tabs.tsx +18 -15
- package/src/tabs/tabs.types.ts +10 -7
- package/src/tabs/tabsNavBar.tsx +5 -5
- package/src/tabs/useTabsState.ts +4 -4
|
@@ -70,7 +70,7 @@ exports.Footer = (0, core_1.vui)((props, ref) => {
|
|
|
70
70
|
});
|
|
71
71
|
const downMd = (0, core_1.useDown)('md');
|
|
72
72
|
const downLg = (0, core_1.useDown)('lg');
|
|
73
|
-
return ((0, jsx_runtime_1.jsx)(context_1.FooterProvider, { value: context, children: (0, jsx_runtime_1.jsxs)(exports.FooterBase, Object.assign({ className: (0, utils_1.cs)('vui-footer', isApplication ? 'vui-footer-app' : '', className), px: isApplication ? '40px' : 3, py: isSlim ? (downMd ? '16px' : '9px') : 5, role: "contentinfo" }, styles.container, { ref: ref }, rest, { children: [isApplication && ((0, jsx_runtime_1.jsx)(footerContent_1.default, { alignContent: "center", alignItems: "center", maxW: "100%", children: (0, jsx_runtime_1.jsxs)(footerRow_1.default, { alignContent: "space-between", w: 1, children: [(0, jsx_runtime_1.jsx)(box_1.Box, { alignItems: "self-start", columnGap: 3, flex: { xs: '0 0 100%', sm: '0 0 100%', md: '0 0 100%', lg: '0 0 50%' }, py: { xs: 1, sm: 1, md: 1.25, lg: 1.5 }, wrap: true, children: applicationLinks === null || applicationLinks === void 0 ? void 0 : applicationLinks.map((link, index) => ((0, jsx_runtime_1.jsxs)(box_1.Box, { flex: { xs: '0 0 50%', sm: '0 0 auto' }, children: [link.items && ((0, jsx_runtime_1.jsxs)(menu_1.default, Object.assign({ isLazy: false, offset: [-16, 9], placement: "top-start", size: "lg" }, rest, { children: [(0, jsx_runtime_1.jsx)(menu_1.default.Button, Object.assign({ as: link_1.Link, className: "vui-footerLink-trigger", pt: "3px", role: "button", text: link.text, title: link.text }, styles.link, rest)), (0, jsx_runtime_1.jsx)(menu_1.default.List, Object.assign({ maxH: 400, right: 0, w: 320 }, styles.list, { children: link.items.map(({ text, url }, index) => ((0, jsx_runtime_1.jsx)(menu_1.default.Item, Object.assign({ isTruncated: true, linkProps: { href: url }, text: text, title: text }, styles.item), index))) }))] }))), !link.items && (0, jsx_runtime_1.jsx)(footerLink_1.default, Object.assign({}, link, { href: link.url }))] }, index))) }), downLg && (0, jsx_runtime_1.jsx)(divider_1.Divider, { borderColor: "sandstone.main", mb: 0.5, mt: 1, w: 1 }), (0, jsx_runtime_1.jsxs)(box_1.Box, { centerV: true, columnGap: 3, flex: { xs: '0 0 100%', sm: '0 0 100%', md: '0 0 100%', lg: '0 0 50%' }, justifyContent: { sm: 'center', lg: 'flex-end' }, py: { xs: 1, sm: 1, md: 1.25, lg: 1.5 }, wrap: true, children: [applicationStaticItems === null || applicationStaticItems === void 0 ? void 0 : applicationStaticItems.map((text, index) => ((0, jsx_runtime_1.jsx)(box_1.Box, { children: (0, jsx_runtime_1.jsx)(t_1.T, { size: "sm", children: text }) }, index))), isDNV ? ((0, jsx_runtime_1.jsx)(box_1.Box, { children: (0, jsx_runtime_1.jsx)(t_1.T, { size: "sm", children: "
|
|
73
|
+
return ((0, jsx_runtime_1.jsx)(context_1.FooterProvider, { value: context, children: (0, jsx_runtime_1.jsxs)(exports.FooterBase, Object.assign({ className: (0, utils_1.cs)('vui-footer', isApplication ? 'vui-footer-app' : '', className), px: isApplication ? '40px' : 3, py: isSlim ? (downMd ? '16px' : '9px') : 5, role: "contentinfo" }, styles.container, { ref: ref }, rest, { children: [isApplication && ((0, jsx_runtime_1.jsx)(footerContent_1.default, { alignContent: "center", alignItems: "center", maxW: "100%", children: (0, jsx_runtime_1.jsxs)(footerRow_1.default, { alignContent: "space-between", w: 1, children: [(0, jsx_runtime_1.jsx)(box_1.Box, { alignItems: "self-start", columnGap: 3, flex: { xs: '0 0 100%', sm: '0 0 100%', md: '0 0 100%', lg: '0 0 50%' }, py: { xs: 1, sm: 1, md: 1.25, lg: 1.5 }, wrap: true, children: applicationLinks === null || applicationLinks === void 0 ? void 0 : applicationLinks.map((link, index) => ((0, jsx_runtime_1.jsxs)(box_1.Box, { flex: { xs: '0 0 50%', sm: '0 0 auto' }, children: [link.items && ((0, jsx_runtime_1.jsxs)(menu_1.default, Object.assign({ isLazy: false, offset: [-16, 9], placement: "top-start", size: "lg" }, rest, { children: [(0, jsx_runtime_1.jsx)(menu_1.default.Button, Object.assign({ as: link_1.Link, className: "vui-footerLink-trigger", pt: "3px", role: "button", text: link.text, title: link.text }, styles.link, rest)), (0, jsx_runtime_1.jsx)(menu_1.default.List, Object.assign({ maxH: 400, right: 0, w: 320 }, styles.list, { children: link.items.map(({ text, url }, index) => ((0, jsx_runtime_1.jsx)(menu_1.default.Item, Object.assign({ isTruncated: true, linkProps: { href: url }, text: text, title: text }, styles.item), index))) }))] }))), !link.items && (0, jsx_runtime_1.jsx)(footerLink_1.default, Object.assign({}, link, { href: link.url }))] }, index))) }), downLg && (0, jsx_runtime_1.jsx)(divider_1.Divider, { borderColor: "sandstone.main", mb: 0.5, mt: 1, w: 1 }), (0, jsx_runtime_1.jsxs)(box_1.Box, { centerV: true, columnGap: 3, flex: { xs: '0 0 100%', sm: '0 0 100%', md: '0 0 100%', lg: '0 0 50%' }, justifyContent: { sm: 'center', lg: 'flex-end' }, py: { xs: 1, sm: 1, md: 1.25, lg: 1.5 }, wrap: true, children: [applicationStaticItems === null || applicationStaticItems === void 0 ? void 0 : applicationStaticItems.map((text, index) => ((0, jsx_runtime_1.jsx)(box_1.Box, { children: (0, jsx_runtime_1.jsx)(t_1.T, { size: "sm", children: text }) }, index))), isDNV ? ((0, jsx_runtime_1.jsx)(box_1.Box, { children: (0, jsx_runtime_1.jsx)(t_1.T, { size: "sm", children: "\u00A9 DNV AS 2021" }) })) : ((0, jsx_runtime_1.jsx)(box_1.Box, { children: (0, jsx_runtime_1.jsxs)(t_1.T, { size: "sm", children: [(0, jsx_runtime_1.jsx)(t_1.T, { weight: "demi", children: "Veracity by DNV" }), ", DNV AS"] }) })), (0, jsx_runtime_1.jsxs)(box_1.Box, { children: [applicationSocialLinks === null || applicationSocialLinks === void 0 ? void 0 : applicationSocialLinks.map((link, index) => ((0, jsx_runtime_1.jsx)(link_1.Link, Object.assign({ "aria-label": link.text, fontWeight: "demi", href: link.url, iconLeft: (0, jsx_runtime_1.jsx)(link_1.Link.Icon, { name: `cubCircle${link.text}`, radius: "50%", size: "xs" }), isExternal: true, mr: 1, size: { _: 'sm', md: 'md' } }, styles.link), index))), (0, jsx_runtime_1.jsx)(link_1.Link, Object.assign({ fontWeight: "demi", href: linkedIn !== null && linkedIn !== void 0 ? linkedIn : footerTrademark_1.defaultLinkedInUrl, isExternal: true, size: { _: 'sm', md: 'md' } }, styles.link, { children: (0, jsx_runtime_1.jsx)(footerHeading_1.default, { fontSize: "16px", mb: 0, text: "Follow us" }) }))] })] })] }) })), !isApplication && isSlim && ((0, jsx_runtime_1.jsx)(footerContent_1.default, { alignContent: "center", alignItems: "center", maxW: { xs: 343, sm: 305, md: 720, lg: 975 }, children: (0, jsx_runtime_1.jsxs)(footerRow_1.default, { children: [slimLinks.map((link, index) => {
|
|
74
74
|
/** if the screen is small drop one specific link */
|
|
75
75
|
if (downLg && (link === null || link === void 0 ? void 0 : link.id) === 'support')
|
|
76
76
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tab.d.ts","sourceRoot":"","sources":["../../../src/tabs/tab.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tab.d.ts","sourceRoot":"","sources":["../../../src/tabs/tab.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEvC,eAAO,MAAM,OAAO,+HAEnB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,GAAG,iDAId,CAAA;AAIF,eAAe,GAAG,CAAA"}
|
package/dist/cjs/tabs/tabs.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import { TabsProps } from './tabs.types';
|
|
3
3
|
export declare const TabsBase: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("..").AnimationProps & import("..").BackgroundColorProps & import("..").BorderProps & import("..").BorderTopProps & import("..").BorderRightProps & import("..").BorderBottomProps & import("..").BorderLeftProps & import("..").BorderColorProps & import("..").BorderTopColorProps & import("..").BorderRightColorProps & import("..").BorderBottomColorProps & import("..").BorderLeftColorProps & import("..").BorderWidthProps & import("..").BorderTopWidthProps & import("..").BorderRightWidthProps & import("..").BorderBottomWidthProps & import("..").BorderLeftWidthProps & import("..").BorderStyleProps & import("..").BorderRadiusProps & import("..").OutlineProps & import("..").OutlineColorProps & import("..").OutlineWidthProps & import("..").OutlineStyleProps & import("..").DivideXProps & import("..").DivideYProps & import("..").DivideXReverseProps & import("..").DivideYReverseProps & import("..").DivideColorProps & import("..").DivideStyleProps & import("..").RingProps & import("..").RingColorProps & import("..").OpacityProps & import("..").BoxShadowProps & import("..").TextShadowProps & import("..").DisplayProps & import("..").AlignItemsProps & import("..").AlignContentProps & import("..").JustifyContentProps & import("..").JustifyItemsProps & import("..").FlexWrapProps & import("..").FlexGrowProps & import("..").FlexShrinkProps & import("..").FlexBasisProps & import("..").FlexDirectionProps & import("..").FlexProps & import("..").JustifySelfProps & import("..").AlignSelfProps & import("..").OrderProps & import("../system/flexboxGrids").RowProps & import("../system/flexboxGrids").ColProps & import("../system/grids").GapProps & import("../system/grids").ColumnGapProps & import("../system/grids").RowGapProps & import("../system/grids").GridColumnProps & import("../system/grids").GridRowProps & import("../system/grids").GridAutoFlowProps & import("../system/grids").GridAutoColumnsProps & import("../system/grids").GridAutoRowsProps & import("../system/grids").GridTemplateColumnsProps & import("../system/grids").GridTemplateRowsProps & import("../system/grids").GridTemplateAreasProps & import("../system/grids").GridAreaProps & import("..").AppearanceProps & import("..").CursorProps & import("..").PointerEventsProps & import("..").ResizeProps & import("..").UserSelectProps & import("..").IsTruncatedProps & import("..").FloatProps & import("..").BoxSizingProps & import("..").OverflowProps & import("..").OverflowXProps & import("..").OverflowYProps & import("..").PositionProps & import("..").ZIndexProps & import("..").TopProps & import("..").RightProps & import("..").BottomProps & import("..").LeftProps & import("..").VisibilityProps & import("..").OverscrollBehaviorProps & import("..").ObjectFitProps & import("..").MaxLinesProps & import("..").WidthProps & import("..").HeightProps & import("..").MaxWidthProps & import("..").MaxHeightProps & import("..").MinWidthProps & import("..").MinHeightProps & import("..").MarginProps & import("..").MarginTopProps & import("..").MarginRightProps & import("..").MarginBottomProps & import("..").MarginLeftProps & import("..").MarginXProps & import("..").MarginYProps & import("..").PaddingProps & import("..").PaddingTopProps & import("..").PaddingRightProps & import("..").PaddingBottomProps & import("..").PaddingLeftProps & import("..").PaddingXProps & import("..").PaddingYProps & import("..").SpaceXProps & import("..").SpaceYProps & import("..").SpaceXReverseProps & import("..").SpaceYReverseProps & import("../system/tables").BorderCollapseProps & import("../system/tables").TableLayoutProps & import("..").TransformProps & import("..").TransformOriginProps & import("..").TranslateXProps & import("..").TranslateYProps & import("..").RotateProps & import("..").SkewXProps & import("..").SkewYProps & import("..").ScaleProps & import("..").ScaleXProps & import("..").ScaleYProps & import("..").TransitionProps & import("..").TransitionPropertyProps & import("..").TransitionDurationProps & import("..").TransitionTimingFunctionProps & import("..").TransitionDelayProps & import("..").FontFamilyProps & import("..").FontSizeProps & import("..").FontStyleProps & import("..").FontWeightProps & import("..").LineHeightProps & import("..").ColorProps & import("..").TextTransformProps & import("..").TextDecorationProps & import("..").TextAlignProps & import("..").VerticalAlignProps & import("..").LetterSpacingProps & import("..").WhiteSpaceProps & import("..").TextOverflowProps & import("..").ListStyleTypeProps & import("..").ListStylePositionProps & import("..").WordBreakProps & import("..").ThemingProps<"Tabs"> & import("../core").ChildrenProp & {
|
|
4
4
|
actions?: React.ReactNode;
|
|
5
|
-
activeTabId?: number | undefined;
|
|
5
|
+
activeTabId?: string | number | undefined;
|
|
6
6
|
showBorder?: boolean | undefined;
|
|
7
|
-
onTabClick?: ((id
|
|
7
|
+
onTabClick?: ((id?: string | number | undefined) => void) | undefined;
|
|
8
8
|
}, never>;
|
|
9
9
|
/**
|
|
10
10
|
* Implements Tabs navigation to switch between views. Implements Tabs navigation to switch between views. **Do not use as a top menu in a page!**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../../src/tabs/tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4C,MAAM,OAAO,CAAA;AAMhE,OAAO,
|
|
1
|
+
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../../src/tabs/tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4C,MAAM,OAAO,CAAA;AAMhE,OAAO,EAA2B,SAAS,EAAE,MAAM,cAAc,CAAA;AAIjE,eAAO,MAAM,QAAQ;;;;;SAEpB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,IAAI,kDAmEf,CAAA;AAIF,eAAe,IAAI,CAAA"}
|
package/dist/cjs/tabs/tabs.js
CHANGED
|
@@ -32,18 +32,20 @@ exports.TabsBase = core_1.styled.divBox `
|
|
|
32
32
|
exports.Tabs = (0, core_1.vui)((props, ref) => {
|
|
33
33
|
const { actions, activeTabId, showBorder = true, children, className, size, onTabClick } = props, rest = __rest(props, ["actions", "activeTabId", "showBorder", "children", "className", "size", "onTabClick"]);
|
|
34
34
|
const styles = (0, core_1.useStyleConfig)('Tabs', props);
|
|
35
|
-
const { tabs, setTabs, activeTabIndex, setActiveTabIndex, animationDirection, setAnimationDirection } = (0, useTabsState_1.useTabsState)('fadeIn',
|
|
35
|
+
const { tabs, setTabs, activeTabIndex, setActiveTabIndex, animationDirection, setAnimationDirection } = (0, useTabsState_1.useTabsState)('fadeIn', 0);
|
|
36
36
|
(0, react_1.useEffect)(() => {
|
|
37
|
-
const
|
|
37
|
+
const _tabs = [];
|
|
38
38
|
if (children) {
|
|
39
39
|
;
|
|
40
40
|
react_1.Children.toArray(children).forEach((child, index) => {
|
|
41
41
|
var _a;
|
|
42
42
|
if ((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.title)
|
|
43
|
-
|
|
44
|
-
id:
|
|
43
|
+
_tabs.push({
|
|
44
|
+
id: child.props.id,
|
|
45
|
+
index: index,
|
|
45
46
|
title: child.props.title,
|
|
46
47
|
icon: child.props.icon,
|
|
48
|
+
className: child.props.className,
|
|
47
49
|
children: child.props.children,
|
|
48
50
|
disabled: child.props.disabled,
|
|
49
51
|
onClick: child.props.onClick,
|
|
@@ -51,23 +53,25 @@ exports.Tabs = (0, core_1.vui)((props, ref) => {
|
|
|
51
53
|
});
|
|
52
54
|
});
|
|
53
55
|
}
|
|
54
|
-
setTabs(
|
|
55
|
-
if (activeTabId !== undefined
|
|
56
|
-
|
|
56
|
+
setTabs(_tabs);
|
|
57
|
+
if (activeTabId !== undefined) {
|
|
58
|
+
const tab = _tabs.find((t) => (t === null || t === void 0 ? void 0 : t.id) === activeTabId || (t === null || t === void 0 ? void 0 : t.index) === activeTabId);
|
|
59
|
+
if (tab === null || tab === void 0 ? void 0 : tab.index)
|
|
60
|
+
setActiveTabIndex(tab.index);
|
|
57
61
|
}
|
|
58
62
|
}, [children, activeTabId]);
|
|
59
|
-
const onNavItemClick = (
|
|
63
|
+
const onNavItemClick = (tabIndex, e) => {
|
|
60
64
|
var _a;
|
|
61
|
-
const tab = tabs.find(t => t.
|
|
62
|
-
if ((tab === null || tab === void 0 ? void 0 : tab.children) !== undefined) {
|
|
63
|
-
setAnimationDirection(
|
|
64
|
-
setActiveTabIndex(
|
|
65
|
-
onTabClick === null || onTabClick === void 0 ? void 0 : onTabClick(id);
|
|
65
|
+
const tab = tabs.find(t => t.index === tabIndex);
|
|
66
|
+
if ((tab === null || tab === void 0 ? void 0 : tab.children) !== undefined && (tab === null || tab === void 0 ? void 0 : tab.index) !== undefined) {
|
|
67
|
+
setAnimationDirection(tab.index < activeTabIndex ? 'fadeLeft' : 'fadeRight');
|
|
68
|
+
setActiveTabIndex(tab.index);
|
|
69
|
+
onTabClick === null || onTabClick === void 0 ? void 0 : onTabClick(tab.id || tab.index);
|
|
66
70
|
}
|
|
67
71
|
(_a = tab === null || tab === void 0 ? void 0 : tab.onClick) === null || _a === void 0 ? void 0 : _a.call(tab, e);
|
|
68
72
|
};
|
|
69
73
|
const activeTab = tabs === null || tabs === void 0 ? void 0 : tabs[activeTabIndex];
|
|
70
|
-
return ((0, jsx_runtime_1.jsxs)(exports.TabsBase, Object.assign({ className: (0, utils_1.cs)('vui-tabs', className), ref: ref }, styles.container, rest, { children: [!!(tabs === null || tabs === void 0 ? void 0 : tabs.length) && ((0, jsx_runtime_1.jsx)(tabsNavBar_1.default, { actions: actions, activeNavItem: activeTabIndex, animationDirection: animationDirection, onNavItemClick: (
|
|
74
|
+
return ((0, jsx_runtime_1.jsxs)(exports.TabsBase, Object.assign({ className: (0, utils_1.cs)('vui-tabs', className), ref: ref }, styles.container, rest, { children: [!!(tabs === null || tabs === void 0 ? void 0 : tabs.length) && ((0, jsx_runtime_1.jsx)(tabsNavBar_1.default, { actions: actions, activeNavItem: activeTabIndex, animationDirection: animationDirection, onNavItemClick: (tabIndex, e) => onNavItemClick(tabIndex, e), showBorder: showBorder, size: size, tabs: tabs })), (tabs === null || tabs === void 0 ? void 0 : tabs.length) ? ((0, jsx_runtime_1.jsx)(tab_1.default, { onClick: activeTab === null || activeTab === void 0 ? void 0 : activeTab.onClick, title: activeTab === null || activeTab === void 0 ? void 0 : activeTab.title, children: !(activeTab === null || activeTab === void 0 ? void 0 : activeTab.disabled) && (activeTab === null || activeTab === void 0 ? void 0 : activeTab.children) })) : ((0, jsx_runtime_1.jsx)(p_1.P, { p: 2, children: "Please specify Tabs." }))] })));
|
|
71
75
|
});
|
|
72
76
|
exports.Tabs.displayName = 'Tabs';
|
|
73
77
|
exports.default = exports.Tabs;
|
|
@@ -8,13 +8,13 @@ export type TabsSize = 'md' | 'sm' | 'lg' | 'xl' | 'xxl';
|
|
|
8
8
|
export type NavBarIconSize = 'md' | 'xs' | 'sm' | 'lg' | 'xl' | undefined;
|
|
9
9
|
export type TabsProps = SystemProps & ThemingProps<'Tabs'> & ChildrenProp & {
|
|
10
10
|
actions?: ReactNode;
|
|
11
|
-
activeTabId?: number;
|
|
11
|
+
activeTabId?: number | string;
|
|
12
12
|
showBorder?: boolean;
|
|
13
|
-
onTabClick?: (id
|
|
13
|
+
onTabClick?: (id?: number | string) => void;
|
|
14
14
|
};
|
|
15
15
|
export type TabProps = SystemProps & ChildrenProp & {
|
|
16
16
|
icon?: IconProp;
|
|
17
|
-
id?: number;
|
|
17
|
+
id?: number | string;
|
|
18
18
|
title: ReactNode;
|
|
19
19
|
disabled?: boolean;
|
|
20
20
|
className?: string;
|
|
@@ -22,11 +22,14 @@ export type TabProps = SystemProps & ChildrenProp & {
|
|
|
22
22
|
/** If provided, displays a remove button with this function as onClick. */
|
|
23
23
|
onDelete?: (nativeEvent?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
24
24
|
};
|
|
25
|
+
export type TabIndexProps = TabProps & {
|
|
26
|
+
index?: number;
|
|
27
|
+
};
|
|
25
28
|
export type TabNavBarProps = {
|
|
26
29
|
actions?: ReactNode;
|
|
27
|
-
tabs:
|
|
28
|
-
onNavItemClick: (
|
|
29
|
-
activeNavItem?: number;
|
|
30
|
+
tabs: TabIndexProps[];
|
|
31
|
+
onNavItemClick: (tabIndex: number, e: React.MouseEvent<HTMLLIElement, MouseEvent>) => void;
|
|
32
|
+
activeNavItem?: number | string;
|
|
30
33
|
animationDirection?: AnimationDirection;
|
|
31
34
|
showBorder?: boolean;
|
|
32
35
|
size?: TabsSize;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.types.d.ts","sourceRoot":"","sources":["../../../src/tabs/tabs.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAEvC,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"tabs.types.d.ts","sourceRoot":"","sources":["../../../src/tabs/tabs.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAEvC,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAA;AACpE,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAA;AACxD,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,CAAA;AAEzE,MAAM,MAAM,SAAS,GAAG,WAAW,GACjC,YAAY,CAAC,MAAM,CAAC,GACpB,YAAY,GAAG;IACb,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CAAA;CAC5C,CAAA;AAEH,MAAM,MAAM,QAAQ,GAAG,WAAW,GAChC,YAAY,GAAG;IACb,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,KAAK,EAAE,SAAS,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,EAAE,UAAU,CAAC,KAAK,IAAI,CAAA;IAC7E,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,UAAU,CAAC,KAAK,IAAI,CAAA;CACnF,CAAA;AAEH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG;IACrC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB,IAAI,EAAE,aAAa,EAAE,CAAA;IACrB,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,EAAE,UAAU,CAAC,KAAK,IAAI,CAAA;IAC1F,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC/B,kBAAkB,CAAC,EAAE,kBAAkB,CAAA;IACvC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabsNavBar.d.ts","sourceRoot":"","sources":["../../../src/tabs/tabsNavBar.tsx"],"names":[],"mappings":"AASA,OAAO,
|
|
1
|
+
{"version":3,"file":"tabsNavBar.d.ts","sourceRoot":"","sources":["../../../src/tabs/tabsNavBar.tsx"],"names":[],"mappings":"AASA,OAAO,EAAiC,cAAc,EAAE,MAAM,cAAc,CAAA;AAK5E,eAAO,MAAM,UAAU,uDAgFrB,CAAA;AAIF,eAAe,UAAU,CAAA"}
|
|
@@ -24,8 +24,8 @@ exports.TabsNavBar = (0, core_1.vui)((props, ref) => {
|
|
|
24
24
|
const borderWidth = sizes[size !== null && size !== void 0 ? size : 'md'].tabsNavBar.borderWidth;
|
|
25
25
|
const py = sizes[size !== null && size !== void 0 ? size : 'md'].tabsNavBar.py;
|
|
26
26
|
const iconMarginRight = size === 'xxl' ? '16px' : '8px';
|
|
27
|
-
const isActive = (tab) => !tab.disabled && tab.
|
|
28
|
-
return ((0, jsx_runtime_1.jsxs)(list_1.List, { alignItems: "end", borderBottom: showBorder ? `1px solid ${border}` : 'none', className: (0, utils_1.cs)('vui-tabsNavBar'), display: "flex", isInteractive: true, mb: "20px", ref: ref, w: 1, children: [(_b = tabs === null || tabs === void 0 ? void 0 : tabs.map) === null || _b === void 0 ? void 0 : _b.call(tabs, tab => ((0, jsx_runtime_1.jsxs)(list_1.ListItem, { activeBg: tab.disabled ? undefined : activeBg, bg: "white", className: `vui-tabsNavBarItem vui-tabsNavBarItem-${tab === null || tab === void 0 ? void 0 : tab.id}`, color: isActive(tab) ? main : color, disabled: tab.disabled, display: "inline-flex", fontSize: fontSize, fontWeight: 500, h: h, hoverBg: tab.disabled ? undefined : hover, onClick: e => onNavItemClick === null || onNavItemClick === void 0 ? void 0 : onNavItemClick(tab.
|
|
27
|
+
const isActive = (tab) => !tab.disabled && (tab === null || tab === void 0 ? void 0 : tab.index) === activeNavItem;
|
|
28
|
+
return ((0, jsx_runtime_1.jsxs)(list_1.List, { alignItems: "end", borderBottom: showBorder ? `1px solid ${border}` : 'none', className: (0, utils_1.cs)('vui-tabsNavBar'), display: "flex", isInteractive: true, mb: "20px", ref: ref, w: 1, children: [(_b = tabs === null || tabs === void 0 ? void 0 : tabs.map) === null || _b === void 0 ? void 0 : _b.call(tabs, tab => ((0, jsx_runtime_1.jsxs)(list_1.ListItem, { activeBg: tab.disabled ? undefined : activeBg, bg: "white", className: `vui-tabsNavBarItem vui-tabsNavBarItem-${tab === null || tab === void 0 ? void 0 : tab.id}`, color: isActive(tab) ? main : color, disabled: tab.disabled, display: "inline-flex", fontSize: fontSize, fontWeight: 500, h: h, hoverBg: tab.disabled ? undefined : hover, onClick: e => onNavItemClick === null || onNavItemClick === void 0 ? void 0 : onNavItemClick(tab.index || 0, e), position: "relative", px: "16px", py: py, children: [(0, jsx_runtime_1.jsxs)(box_1.default, { alignItems: "center", children: [!!tab.icon && (0, jsx_runtime_1.jsx)(icon_1.Icon, { mr: iconMarginRight, name: tab.icon, size: iconSize }), tab.title] }), !!tab.onDelete && ((0, jsx_runtime_1.jsx)(tag_1.TagButton, { disabled: tab.disabled, hoverBg: "skyBlue.80", hoverColor: "seaBlue.main", isRound: false, ml: 1, onClick: e => { var _a; return (_a = tab === null || tab === void 0 ? void 0 : tab.onDelete) === null || _a === void 0 ? void 0 : _a.call(tab, e); }, title: "Delete" })), isActive(tab) && ((0, jsx_runtime_1.jsx)(box_1.default, { animation: animationDirection, bg: main, bottom: "-1px", h: borderWidth, left: 0, position: "absolute", w: 1, children: "\u00A0" }))] }, tab.index))), !!actions && ((0, jsx_runtime_1.jsx)(box_1.default, { ml: "auto", px: 0.75, py: 0.5, children: actions }))] }));
|
|
29
29
|
});
|
|
30
30
|
exports.TabsNavBar.displayName = 'TabsNavBar';
|
|
31
31
|
exports.default = exports.TabsNavBar;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { AnimationDirection,
|
|
3
|
-
export declare const useTabsState: (initialAnimation: AnimationDirection,
|
|
4
|
-
tabs:
|
|
5
|
-
setTabs: import("react").Dispatch<import("react").SetStateAction<
|
|
2
|
+
import { AnimationDirection, TabIndexProps } from './tabs.types';
|
|
3
|
+
export declare const useTabsState: (initialAnimation: AnimationDirection, tabIndex?: number) => {
|
|
4
|
+
tabs: TabIndexProps[];
|
|
5
|
+
setTabs: import("react").Dispatch<import("react").SetStateAction<TabIndexProps[]>>;
|
|
6
6
|
activeTabIndex: number;
|
|
7
7
|
setActiveTabIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
8
8
|
animationDirection: AnimationDirection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTabsState.d.ts","sourceRoot":"","sources":["../../../src/tabs/useTabsState.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"useTabsState.d.ts","sourceRoot":"","sources":["../../../src/tabs/useTabsState.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEhE,eAAO,MAAM,YAAY,qBAAsB,kBAAkB,aAAa,MAAM;;;;;;;CAMnF,CAAA"}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useTabsState = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const useTabsState = (initialAnimation,
|
|
5
|
+
const useTabsState = (initialAnimation, tabIndex) => {
|
|
6
6
|
const [tabs, setTabs] = (0, react_1.useState)([]);
|
|
7
|
-
const [activeTabIndex, setActiveTabIndex] = (0, react_1.useState)(
|
|
7
|
+
const [activeTabIndex, setActiveTabIndex] = (0, react_1.useState)(tabIndex !== null && tabIndex !== void 0 ? tabIndex : 0);
|
|
8
8
|
const [animationDirection, setAnimationDirection] = (0, react_1.useState)(initialAnimation);
|
|
9
9
|
return { tabs, setTabs, activeTabIndex, setActiveTabIndex, animationDirection, setAnimationDirection };
|
|
10
10
|
};
|
|
@@ -52,7 +52,7 @@ export const Footer = vui((props, ref) => {
|
|
|
52
52
|
});
|
|
53
53
|
const downMd = useDown('md');
|
|
54
54
|
const downLg = useDown('lg');
|
|
55
|
-
return (_jsx(FooterProvider, { value: context, children: _jsxs(FooterBase, { className: cs('vui-footer', isApplication ? 'vui-footer-app' : '', className), px: isApplication ? '40px' : 3, py: isSlim ? (downMd ? '16px' : '9px') : 5, role: "contentinfo", ...styles.container, ref: ref, ...rest, children: [isApplication && (_jsx(FooterContent, { alignContent: "center", alignItems: "center", maxW: "100%", children: _jsxs(FooterRow, { alignContent: "space-between", w: 1, children: [_jsx(Box, { alignItems: "self-start", columnGap: 3, flex: { xs: '0 0 100%', sm: '0 0 100%', md: '0 0 100%', lg: '0 0 50%' }, py: { xs: 1, sm: 1, md: 1.25, lg: 1.5 }, wrap: true, children: applicationLinks?.map((link, index) => (_jsxs(Box, { flex: { xs: '0 0 50%', sm: '0 0 auto' }, children: [link.items && (_jsxs(Menu, { isLazy: false, offset: [-16, 9], placement: "top-start", size: "lg", ...rest, children: [_jsx(Menu.Button, { as: Link, className: "vui-footerLink-trigger", pt: "3px", role: "button", text: link.text, title: link.text, ...styles.link, ...rest }), _jsx(Menu.List, { maxH: 400, right: 0, w: 320, ...styles.list, children: link.items.map(({ text, url }, index) => (_jsx(Menu.Item, { isTruncated: true, linkProps: { href: url }, text: text, title: text, ...styles.item }, index))) })] })), !link.items && _jsx(FooterLink, { ...link, href: link.url })] }, index))) }), downLg && _jsx(Divider, { borderColor: "sandstone.main", mb: 0.5, mt: 1, w: 1 }), _jsxs(Box, { centerV: true, columnGap: 3, flex: { xs: '0 0 100%', sm: '0 0 100%', md: '0 0 100%', lg: '0 0 50%' }, justifyContent: { sm: 'center', lg: 'flex-end' }, py: { xs: 1, sm: 1, md: 1.25, lg: 1.5 }, wrap: true, children: [applicationStaticItems?.map((text, index) => (_jsx(Box, { children: _jsx(T, { size: "sm", children: text }) }, index))), isDNV ? (_jsx(Box, { children: _jsx(T, { size: "sm", children: "
|
|
55
|
+
return (_jsx(FooterProvider, { value: context, children: _jsxs(FooterBase, { className: cs('vui-footer', isApplication ? 'vui-footer-app' : '', className), px: isApplication ? '40px' : 3, py: isSlim ? (downMd ? '16px' : '9px') : 5, role: "contentinfo", ...styles.container, ref: ref, ...rest, children: [isApplication && (_jsx(FooterContent, { alignContent: "center", alignItems: "center", maxW: "100%", children: _jsxs(FooterRow, { alignContent: "space-between", w: 1, children: [_jsx(Box, { alignItems: "self-start", columnGap: 3, flex: { xs: '0 0 100%', sm: '0 0 100%', md: '0 0 100%', lg: '0 0 50%' }, py: { xs: 1, sm: 1, md: 1.25, lg: 1.5 }, wrap: true, children: applicationLinks?.map((link, index) => (_jsxs(Box, { flex: { xs: '0 0 50%', sm: '0 0 auto' }, children: [link.items && (_jsxs(Menu, { isLazy: false, offset: [-16, 9], placement: "top-start", size: "lg", ...rest, children: [_jsx(Menu.Button, { as: Link, className: "vui-footerLink-trigger", pt: "3px", role: "button", text: link.text, title: link.text, ...styles.link, ...rest }), _jsx(Menu.List, { maxH: 400, right: 0, w: 320, ...styles.list, children: link.items.map(({ text, url }, index) => (_jsx(Menu.Item, { isTruncated: true, linkProps: { href: url }, text: text, title: text, ...styles.item }, index))) })] })), !link.items && _jsx(FooterLink, { ...link, href: link.url })] }, index))) }), downLg && _jsx(Divider, { borderColor: "sandstone.main", mb: 0.5, mt: 1, w: 1 }), _jsxs(Box, { centerV: true, columnGap: 3, flex: { xs: '0 0 100%', sm: '0 0 100%', md: '0 0 100%', lg: '0 0 50%' }, justifyContent: { sm: 'center', lg: 'flex-end' }, py: { xs: 1, sm: 1, md: 1.25, lg: 1.5 }, wrap: true, children: [applicationStaticItems?.map((text, index) => (_jsx(Box, { children: _jsx(T, { size: "sm", children: text }) }, index))), isDNV ? (_jsx(Box, { children: _jsx(T, { size: "sm", children: "\u00A9 DNV AS 2021" }) })) : (_jsx(Box, { children: _jsxs(T, { size: "sm", children: [_jsx(T, { weight: "demi", children: "Veracity by DNV" }), ", DNV AS"] }) })), _jsxs(Box, { children: [applicationSocialLinks?.map((link, index) => (_jsx(Link, { "aria-label": link.text, fontWeight: "demi", href: link.url, iconLeft: _jsx(Link.Icon, { name: `cubCircle${link.text}`, radius: "50%", size: "xs" }), isExternal: true, mr: 1, size: { _: 'sm', md: 'md' }, ...styles.link }, index))), _jsx(Link, { fontWeight: "demi", href: linkedIn ?? defaultLinkedInUrl, isExternal: true, size: { _: 'sm', md: 'md' }, ...styles.link, children: _jsx(FooterHeading, { fontSize: "16px", mb: 0, text: "Follow us" }) })] })] })] }) })), !isApplication && isSlim && (_jsx(FooterContent, { alignContent: "center", alignItems: "center", maxW: { xs: 343, sm: 305, md: 720, lg: 975 }, children: _jsxs(FooterRow, { children: [slimLinks.map((link, index) => {
|
|
56
56
|
/** if the screen is small drop one specific link */
|
|
57
57
|
if (downLg && link?.id === 'support')
|
|
58
58
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tab.d.ts","sourceRoot":"","sources":["../../../src/tabs/tab.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tab.d.ts","sourceRoot":"","sources":["../../../src/tabs/tab.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEvC,eAAO,MAAM,OAAO,+HAEnB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,GAAG,iDAId,CAAA;AAIF,eAAe,GAAG,CAAA"}
|
package/dist/esm/tabs/tabs.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import { TabsProps } from './tabs.types';
|
|
3
3
|
export declare const TabsBase: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("..").AnimationProps & import("..").BackgroundColorProps & import("..").BorderProps & import("..").BorderTopProps & import("..").BorderRightProps & import("..").BorderBottomProps & import("..").BorderLeftProps & import("..").BorderColorProps & import("..").BorderTopColorProps & import("..").BorderRightColorProps & import("..").BorderBottomColorProps & import("..").BorderLeftColorProps & import("..").BorderWidthProps & import("..").BorderTopWidthProps & import("..").BorderRightWidthProps & import("..").BorderBottomWidthProps & import("..").BorderLeftWidthProps & import("..").BorderStyleProps & import("..").BorderRadiusProps & import("..").OutlineProps & import("..").OutlineColorProps & import("..").OutlineWidthProps & import("..").OutlineStyleProps & import("..").DivideXProps & import("..").DivideYProps & import("..").DivideXReverseProps & import("..").DivideYReverseProps & import("..").DivideColorProps & import("..").DivideStyleProps & import("..").RingProps & import("..").RingColorProps & import("..").OpacityProps & import("..").BoxShadowProps & import("..").TextShadowProps & import("..").DisplayProps & import("..").AlignItemsProps & import("..").AlignContentProps & import("..").JustifyContentProps & import("..").JustifyItemsProps & import("..").FlexWrapProps & import("..").FlexGrowProps & import("..").FlexShrinkProps & import("..").FlexBasisProps & import("..").FlexDirectionProps & import("..").FlexProps & import("..").JustifySelfProps & import("..").AlignSelfProps & import("..").OrderProps & import("../system/flexboxGrids").RowProps & import("../system/flexboxGrids").ColProps & import("../system/grids").GapProps & import("../system/grids").ColumnGapProps & import("../system/grids").RowGapProps & import("../system/grids").GridColumnProps & import("../system/grids").GridRowProps & import("../system/grids").GridAutoFlowProps & import("../system/grids").GridAutoColumnsProps & import("../system/grids").GridAutoRowsProps & import("../system/grids").GridTemplateColumnsProps & import("../system/grids").GridTemplateRowsProps & import("../system/grids").GridTemplateAreasProps & import("../system/grids").GridAreaProps & import("..").AppearanceProps & import("..").CursorProps & import("..").PointerEventsProps & import("..").ResizeProps & import("..").UserSelectProps & import("..").IsTruncatedProps & import("..").FloatProps & import("..").BoxSizingProps & import("..").OverflowProps & import("..").OverflowXProps & import("..").OverflowYProps & import("..").PositionProps & import("..").ZIndexProps & import("..").TopProps & import("..").RightProps & import("..").BottomProps & import("..").LeftProps & import("..").VisibilityProps & import("..").OverscrollBehaviorProps & import("..").ObjectFitProps & import("..").MaxLinesProps & import("..").WidthProps & import("..").HeightProps & import("..").MaxWidthProps & import("..").MaxHeightProps & import("..").MinWidthProps & import("..").MinHeightProps & import("..").MarginProps & import("..").MarginTopProps & import("..").MarginRightProps & import("..").MarginBottomProps & import("..").MarginLeftProps & import("..").MarginXProps & import("..").MarginYProps & import("..").PaddingProps & import("..").PaddingTopProps & import("..").PaddingRightProps & import("..").PaddingBottomProps & import("..").PaddingLeftProps & import("..").PaddingXProps & import("..").PaddingYProps & import("..").SpaceXProps & import("..").SpaceYProps & import("..").SpaceXReverseProps & import("..").SpaceYReverseProps & import("../system/tables").BorderCollapseProps & import("../system/tables").TableLayoutProps & import("..").TransformProps & import("..").TransformOriginProps & import("..").TranslateXProps & import("..").TranslateYProps & import("..").RotateProps & import("..").SkewXProps & import("..").SkewYProps & import("..").ScaleProps & import("..").ScaleXProps & import("..").ScaleYProps & import("..").TransitionProps & import("..").TransitionPropertyProps & import("..").TransitionDurationProps & import("..").TransitionTimingFunctionProps & import("..").TransitionDelayProps & import("..").FontFamilyProps & import("..").FontSizeProps & import("..").FontStyleProps & import("..").FontWeightProps & import("..").LineHeightProps & import("..").ColorProps & import("..").TextTransformProps & import("..").TextDecorationProps & import("..").TextAlignProps & import("..").VerticalAlignProps & import("..").LetterSpacingProps & import("..").WhiteSpaceProps & import("..").TextOverflowProps & import("..").ListStyleTypeProps & import("..").ListStylePositionProps & import("..").WordBreakProps & import("..").ThemingProps<"Tabs"> & import("../core").ChildrenProp & {
|
|
4
4
|
actions?: React.ReactNode;
|
|
5
|
-
activeTabId?: number | undefined;
|
|
5
|
+
activeTabId?: string | number | undefined;
|
|
6
6
|
showBorder?: boolean | undefined;
|
|
7
|
-
onTabClick?: ((id
|
|
7
|
+
onTabClick?: ((id?: string | number | undefined) => void) | undefined;
|
|
8
8
|
}, never>;
|
|
9
9
|
/**
|
|
10
10
|
* Implements Tabs navigation to switch between views. Implements Tabs navigation to switch between views. **Do not use as a top menu in a page!**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../../src/tabs/tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4C,MAAM,OAAO,CAAA;AAMhE,OAAO,
|
|
1
|
+
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../../src/tabs/tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4C,MAAM,OAAO,CAAA;AAMhE,OAAO,EAA2B,SAAS,EAAE,MAAM,cAAc,CAAA;AAIjE,eAAO,MAAM,QAAQ;;;;;SAEpB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,IAAI,kDAmEf,CAAA;AAIF,eAAe,IAAI,CAAA"}
|
package/dist/esm/tabs/tabs.js
CHANGED
|
@@ -15,17 +15,19 @@ export const TabsBase = styled.divBox `
|
|
|
15
15
|
export const Tabs = vui((props, ref) => {
|
|
16
16
|
const { actions, activeTabId, showBorder = true, children, className, size, onTabClick, ...rest } = props;
|
|
17
17
|
const styles = useStyleConfig('Tabs', props);
|
|
18
|
-
const { tabs, setTabs, activeTabIndex, setActiveTabIndex, animationDirection, setAnimationDirection } = useTabsState('fadeIn',
|
|
18
|
+
const { tabs, setTabs, activeTabIndex, setActiveTabIndex, animationDirection, setAnimationDirection } = useTabsState('fadeIn', 0);
|
|
19
19
|
useEffect(() => {
|
|
20
|
-
const
|
|
20
|
+
const _tabs = [];
|
|
21
21
|
if (children) {
|
|
22
22
|
;
|
|
23
23
|
Children.toArray(children).forEach((child, index) => {
|
|
24
24
|
if (child?.props?.title)
|
|
25
|
-
|
|
26
|
-
id:
|
|
25
|
+
_tabs.push({
|
|
26
|
+
id: child.props.id,
|
|
27
|
+
index: index,
|
|
27
28
|
title: child.props.title,
|
|
28
29
|
icon: child.props.icon,
|
|
30
|
+
className: child.props.className,
|
|
29
31
|
children: child.props.children,
|
|
30
32
|
disabled: child.props.disabled,
|
|
31
33
|
onClick: child.props.onClick,
|
|
@@ -33,22 +35,24 @@ export const Tabs = vui((props, ref) => {
|
|
|
33
35
|
});
|
|
34
36
|
});
|
|
35
37
|
}
|
|
36
|
-
setTabs(
|
|
37
|
-
if (activeTabId !== undefined
|
|
38
|
-
|
|
38
|
+
setTabs(_tabs);
|
|
39
|
+
if (activeTabId !== undefined) {
|
|
40
|
+
const tab = _tabs.find((t) => t?.id === activeTabId || t?.index === activeTabId);
|
|
41
|
+
if (tab?.index)
|
|
42
|
+
setActiveTabIndex(tab.index);
|
|
39
43
|
}
|
|
40
44
|
}, [children, activeTabId]);
|
|
41
|
-
const onNavItemClick = (
|
|
42
|
-
const tab = tabs.find(t => t.
|
|
43
|
-
if (tab?.children !== undefined) {
|
|
44
|
-
setAnimationDirection(
|
|
45
|
-
setActiveTabIndex(
|
|
46
|
-
onTabClick?.(id);
|
|
45
|
+
const onNavItemClick = (tabIndex, e) => {
|
|
46
|
+
const tab = tabs.find(t => t.index === tabIndex);
|
|
47
|
+
if (tab?.children !== undefined && tab?.index !== undefined) {
|
|
48
|
+
setAnimationDirection(tab.index < activeTabIndex ? 'fadeLeft' : 'fadeRight');
|
|
49
|
+
setActiveTabIndex(tab.index);
|
|
50
|
+
onTabClick?.(tab.id || tab.index);
|
|
47
51
|
}
|
|
48
52
|
tab?.onClick?.(e);
|
|
49
53
|
};
|
|
50
54
|
const activeTab = tabs?.[activeTabIndex];
|
|
51
|
-
return (_jsxs(TabsBase, { className: cs('vui-tabs', className), ref: ref, ...styles.container, ...rest, children: [!!tabs?.length && (_jsx(TabsNavBar, { actions: actions, activeNavItem: activeTabIndex, animationDirection: animationDirection, onNavItemClick: (
|
|
55
|
+
return (_jsxs(TabsBase, { className: cs('vui-tabs', className), ref: ref, ...styles.container, ...rest, children: [!!tabs?.length && (_jsx(TabsNavBar, { actions: actions, activeNavItem: activeTabIndex, animationDirection: animationDirection, onNavItemClick: (tabIndex, e) => onNavItemClick(tabIndex, e), showBorder: showBorder, size: size, tabs: tabs })), tabs?.length ? (_jsx(Tab, { onClick: activeTab?.onClick, title: activeTab?.title, children: !activeTab?.disabled && activeTab?.children })) : (_jsx(P, { p: 2, children: "Please specify Tabs." }))] }));
|
|
52
56
|
});
|
|
53
57
|
Tabs.displayName = 'Tabs';
|
|
54
58
|
export default Tabs;
|
|
@@ -8,13 +8,13 @@ export type TabsSize = 'md' | 'sm' | 'lg' | 'xl' | 'xxl';
|
|
|
8
8
|
export type NavBarIconSize = 'md' | 'xs' | 'sm' | 'lg' | 'xl' | undefined;
|
|
9
9
|
export type TabsProps = SystemProps & ThemingProps<'Tabs'> & ChildrenProp & {
|
|
10
10
|
actions?: ReactNode;
|
|
11
|
-
activeTabId?: number;
|
|
11
|
+
activeTabId?: number | string;
|
|
12
12
|
showBorder?: boolean;
|
|
13
|
-
onTabClick?: (id
|
|
13
|
+
onTabClick?: (id?: number | string) => void;
|
|
14
14
|
};
|
|
15
15
|
export type TabProps = SystemProps & ChildrenProp & {
|
|
16
16
|
icon?: IconProp;
|
|
17
|
-
id?: number;
|
|
17
|
+
id?: number | string;
|
|
18
18
|
title: ReactNode;
|
|
19
19
|
disabled?: boolean;
|
|
20
20
|
className?: string;
|
|
@@ -22,11 +22,14 @@ export type TabProps = SystemProps & ChildrenProp & {
|
|
|
22
22
|
/** If provided, displays a remove button with this function as onClick. */
|
|
23
23
|
onDelete?: (nativeEvent?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
24
24
|
};
|
|
25
|
+
export type TabIndexProps = TabProps & {
|
|
26
|
+
index?: number;
|
|
27
|
+
};
|
|
25
28
|
export type TabNavBarProps = {
|
|
26
29
|
actions?: ReactNode;
|
|
27
|
-
tabs:
|
|
28
|
-
onNavItemClick: (
|
|
29
|
-
activeNavItem?: number;
|
|
30
|
+
tabs: TabIndexProps[];
|
|
31
|
+
onNavItemClick: (tabIndex: number, e: React.MouseEvent<HTMLLIElement, MouseEvent>) => void;
|
|
32
|
+
activeNavItem?: number | string;
|
|
30
33
|
animationDirection?: AnimationDirection;
|
|
31
34
|
showBorder?: boolean;
|
|
32
35
|
size?: TabsSize;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.types.d.ts","sourceRoot":"","sources":["../../../src/tabs/tabs.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAEvC,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"tabs.types.d.ts","sourceRoot":"","sources":["../../../src/tabs/tabs.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAEvC,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAA;AACpE,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAA;AACxD,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,CAAA;AAEzE,MAAM,MAAM,SAAS,GAAG,WAAW,GACjC,YAAY,CAAC,MAAM,CAAC,GACpB,YAAY,GAAG;IACb,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CAAA;CAC5C,CAAA;AAEH,MAAM,MAAM,QAAQ,GAAG,WAAW,GAChC,YAAY,GAAG;IACb,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,KAAK,EAAE,SAAS,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,EAAE,UAAU,CAAC,KAAK,IAAI,CAAA;IAC7E,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,UAAU,CAAC,KAAK,IAAI,CAAA;CACnF,CAAA;AAEH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG;IACrC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB,IAAI,EAAE,aAAa,EAAE,CAAA;IACrB,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,EAAE,UAAU,CAAC,KAAK,IAAI,CAAA;IAC1F,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC/B,kBAAkB,CAAC,EAAE,kBAAkB,CAAA;IACvC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabsNavBar.d.ts","sourceRoot":"","sources":["../../../src/tabs/tabsNavBar.tsx"],"names":[],"mappings":"AASA,OAAO,
|
|
1
|
+
{"version":3,"file":"tabsNavBar.d.ts","sourceRoot":"","sources":["../../../src/tabs/tabsNavBar.tsx"],"names":[],"mappings":"AASA,OAAO,EAAiC,cAAc,EAAE,MAAM,cAAc,CAAA;AAK5E,eAAO,MAAM,UAAU,uDAgFrB,CAAA;AAIF,eAAe,UAAU,CAAA"}
|
|
@@ -17,8 +17,8 @@ export const TabsNavBar = vui((props, ref) => {
|
|
|
17
17
|
const borderWidth = sizes[size ?? 'md'].tabsNavBar.borderWidth;
|
|
18
18
|
const py = sizes[size ?? 'md'].tabsNavBar.py;
|
|
19
19
|
const iconMarginRight = size === 'xxl' ? '16px' : '8px';
|
|
20
|
-
const isActive = (tab) => !tab.disabled && tab
|
|
21
|
-
return (_jsxs(List, { alignItems: "end", borderBottom: showBorder ? `1px solid ${border}` : 'none', className: cs('vui-tabsNavBar'), display: "flex", isInteractive: true, mb: "20px", ref: ref, w: 1, children: [tabs?.map?.(tab => (_jsxs(ListItem, { activeBg: tab.disabled ? undefined : activeBg, bg: "white", className: `vui-tabsNavBarItem vui-tabsNavBarItem-${tab?.id}`, color: isActive(tab) ? main : color, disabled: tab.disabled, display: "inline-flex", fontSize: fontSize, fontWeight: 500, h: h, hoverBg: tab.disabled ? undefined : hover, onClick: e => onNavItemClick?.(tab.
|
|
20
|
+
const isActive = (tab) => !tab.disabled && tab?.index === activeNavItem;
|
|
21
|
+
return (_jsxs(List, { alignItems: "end", borderBottom: showBorder ? `1px solid ${border}` : 'none', className: cs('vui-tabsNavBar'), display: "flex", isInteractive: true, mb: "20px", ref: ref, w: 1, children: [tabs?.map?.(tab => (_jsxs(ListItem, { activeBg: tab.disabled ? undefined : activeBg, bg: "white", className: `vui-tabsNavBarItem vui-tabsNavBarItem-${tab?.id}`, color: isActive(tab) ? main : color, disabled: tab.disabled, display: "inline-flex", fontSize: fontSize, fontWeight: 500, h: h, hoverBg: tab.disabled ? undefined : hover, onClick: e => onNavItemClick?.(tab.index || 0, e), position: "relative", px: "16px", py: py, children: [_jsxs(Box, { alignItems: "center", children: [!!tab.icon && _jsx(Icon, { mr: iconMarginRight, name: tab.icon, size: iconSize }), tab.title] }), !!tab.onDelete && (_jsx(TagButton, { disabled: tab.disabled, hoverBg: "skyBlue.80", hoverColor: "seaBlue.main", isRound: false, ml: 1, onClick: e => tab?.onDelete?.(e), title: "Delete" })), isActive(tab) && (_jsx(Box, { animation: animationDirection, bg: main, bottom: "-1px", h: borderWidth, left: 0, position: "absolute", w: 1, children: "\u00A0" }))] }, tab.index))), !!actions && (_jsx(Box, { ml: "auto", px: 0.75, py: 0.5, children: actions }))] }));
|
|
22
22
|
});
|
|
23
23
|
TabsNavBar.displayName = 'TabsNavBar';
|
|
24
24
|
export default TabsNavBar;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { AnimationDirection,
|
|
3
|
-
export declare const useTabsState: (initialAnimation: AnimationDirection,
|
|
4
|
-
tabs:
|
|
5
|
-
setTabs: import("react").Dispatch<import("react").SetStateAction<
|
|
2
|
+
import { AnimationDirection, TabIndexProps } from './tabs.types';
|
|
3
|
+
export declare const useTabsState: (initialAnimation: AnimationDirection, tabIndex?: number) => {
|
|
4
|
+
tabs: TabIndexProps[];
|
|
5
|
+
setTabs: import("react").Dispatch<import("react").SetStateAction<TabIndexProps[]>>;
|
|
6
6
|
activeTabIndex: number;
|
|
7
7
|
setActiveTabIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
8
8
|
animationDirection: AnimationDirection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTabsState.d.ts","sourceRoot":"","sources":["../../../src/tabs/useTabsState.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"useTabsState.d.ts","sourceRoot":"","sources":["../../../src/tabs/useTabsState.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEhE,eAAO,MAAM,YAAY,qBAAsB,kBAAkB,aAAa,MAAM;;;;;;;CAMnF,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
export const useTabsState = (initialAnimation,
|
|
2
|
+
export const useTabsState = (initialAnimation, tabIndex) => {
|
|
3
3
|
const [tabs, setTabs] = useState([]);
|
|
4
|
-
const [activeTabIndex, setActiveTabIndex] = useState(
|
|
4
|
+
const [activeTabIndex, setActiveTabIndex] = useState(tabIndex ?? 0);
|
|
5
5
|
const [animationDirection, setAnimationDirection] = useState(initialAnimation);
|
|
6
6
|
return { tabs, setTabs, activeTabIndex, setActiveTabIndex, animationDirection, setAnimationDirection };
|
|
7
7
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veracity/vui",
|
|
3
|
-
"version": "2.17.2-beta.
|
|
3
|
+
"version": "2.17.2-beta.2",
|
|
4
4
|
"description": "Veracity UI is a React component library crafted for use within Veracity applications and pages. Based on Styled Components and @xstyled.",
|
|
5
5
|
"module": "./dist/esm/index.js",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
package/src/footer/footer.tsx
CHANGED
package/src/tabs/tab.tsx
CHANGED
package/src/tabs/tabs.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import { styled, useStyleConfig, vui } from '../core'
|
|
|
4
4
|
import { P } from '../p'
|
|
5
5
|
import { cs } from '../utils'
|
|
6
6
|
import Tab from './tab'
|
|
7
|
-
import { TabProps, TabsProps } from './tabs.types'
|
|
7
|
+
import { TabIndexProps, TabProps, TabsProps } from './tabs.types'
|
|
8
8
|
import TabsNavBar from './tabsNavBar'
|
|
9
9
|
import { useTabsState } from './useTabsState'
|
|
10
10
|
|
|
@@ -20,18 +20,20 @@ export const Tabs = vui<'div', TabsProps>((props, ref) => {
|
|
|
20
20
|
const styles = useStyleConfig('Tabs', props)
|
|
21
21
|
const { tabs, setTabs, activeTabIndex, setActiveTabIndex, animationDirection, setAnimationDirection } = useTabsState(
|
|
22
22
|
'fadeIn',
|
|
23
|
-
|
|
23
|
+
0
|
|
24
24
|
)
|
|
25
25
|
|
|
26
26
|
useEffect(() => {
|
|
27
|
-
const
|
|
27
|
+
const _tabs: TabIndexProps[] = []
|
|
28
28
|
if (children) {
|
|
29
29
|
;(Children.toArray(children) as ReactElement[]).forEach((child: ReactElement<TabProps>, index: number) => {
|
|
30
30
|
if (child?.props?.title)
|
|
31
|
-
|
|
32
|
-
id:
|
|
31
|
+
_tabs.push({
|
|
32
|
+
id: child.props.id,
|
|
33
|
+
index: index,
|
|
33
34
|
title: child.props.title,
|
|
34
35
|
icon: child.props.icon,
|
|
36
|
+
className: child.props.className,
|
|
35
37
|
children: child.props.children,
|
|
36
38
|
disabled: child.props.disabled,
|
|
37
39
|
onClick: child.props.onClick,
|
|
@@ -39,18 +41,19 @@ export const Tabs = vui<'div', TabsProps>((props, ref) => {
|
|
|
39
41
|
})
|
|
40
42
|
})
|
|
41
43
|
}
|
|
42
|
-
setTabs(
|
|
43
|
-
if (activeTabId !== undefined
|
|
44
|
-
|
|
44
|
+
setTabs(_tabs)
|
|
45
|
+
if (activeTabId !== undefined) {
|
|
46
|
+
const tab = _tabs.find((t: TabIndexProps) => t?.id === activeTabId || t?.index === activeTabId)
|
|
47
|
+
if (tab?.index) setActiveTabIndex(tab.index)
|
|
45
48
|
}
|
|
46
49
|
}, [children, activeTabId])
|
|
47
50
|
|
|
48
|
-
const onNavItemClick = (
|
|
49
|
-
const tab = tabs.find(t => t.
|
|
50
|
-
if (tab?.children !== undefined) {
|
|
51
|
-
setAnimationDirection(
|
|
52
|
-
setActiveTabIndex(
|
|
53
|
-
onTabClick?.(id)
|
|
51
|
+
const onNavItemClick = (tabIndex: number, e: React.MouseEvent<HTMLLIElement, MouseEvent>) => {
|
|
52
|
+
const tab = tabs.find(t => t.index === tabIndex)
|
|
53
|
+
if (tab?.children !== undefined && tab?.index !== undefined) {
|
|
54
|
+
setAnimationDirection(tab.index < activeTabIndex ? 'fadeLeft' : 'fadeRight')
|
|
55
|
+
setActiveTabIndex(tab.index)
|
|
56
|
+
onTabClick?.(tab.id || tab.index)
|
|
54
57
|
}
|
|
55
58
|
tab?.onClick?.(e)
|
|
56
59
|
}
|
|
@@ -64,7 +67,7 @@ export const Tabs = vui<'div', TabsProps>((props, ref) => {
|
|
|
64
67
|
actions={actions}
|
|
65
68
|
activeNavItem={activeTabIndex}
|
|
66
69
|
animationDirection={animationDirection}
|
|
67
|
-
onNavItemClick={(
|
|
70
|
+
onNavItemClick={(tabIndex, e) => onNavItemClick(tabIndex, e)}
|
|
68
71
|
showBorder={showBorder}
|
|
69
72
|
size={size}
|
|
70
73
|
tabs={tabs}
|
package/src/tabs/tabs.types.ts
CHANGED
|
@@ -6,7 +6,6 @@ import { SystemProps } from '../system'
|
|
|
6
6
|
import { ThemingProps } from '../theme'
|
|
7
7
|
|
|
8
8
|
export type AnimationDirection = 'fadeLeft' | 'fadeRight' | 'fadeIn'
|
|
9
|
-
|
|
10
9
|
export type TabsSize = 'md' | 'sm' | 'lg' | 'xl' | 'xxl'
|
|
11
10
|
export type NavBarIconSize = 'md' | 'xs' | 'sm' | 'lg' | 'xl' | undefined
|
|
12
11
|
|
|
@@ -14,15 +13,15 @@ export type TabsProps = SystemProps &
|
|
|
14
13
|
ThemingProps<'Tabs'> &
|
|
15
14
|
ChildrenProp & {
|
|
16
15
|
actions?: ReactNode
|
|
17
|
-
activeTabId?: number
|
|
16
|
+
activeTabId?: number | string
|
|
18
17
|
showBorder?: boolean
|
|
19
|
-
onTabClick?: (id
|
|
18
|
+
onTabClick?: (id?: number | string) => void
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
export type TabProps = SystemProps &
|
|
23
22
|
ChildrenProp & {
|
|
24
23
|
icon?: IconProp
|
|
25
|
-
id?: number
|
|
24
|
+
id?: number | string
|
|
26
25
|
title: ReactNode
|
|
27
26
|
disabled?: boolean
|
|
28
27
|
className?: string
|
|
@@ -31,11 +30,15 @@ export type TabProps = SystemProps &
|
|
|
31
30
|
onDelete?: (nativeEvent?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void
|
|
32
31
|
}
|
|
33
32
|
|
|
33
|
+
export type TabIndexProps = TabProps & {
|
|
34
|
+
index?: number
|
|
35
|
+
}
|
|
36
|
+
|
|
34
37
|
export type TabNavBarProps = {
|
|
35
38
|
actions?: ReactNode
|
|
36
|
-
tabs:
|
|
37
|
-
onNavItemClick: (
|
|
38
|
-
activeNavItem?: number
|
|
39
|
+
tabs: TabIndexProps[]
|
|
40
|
+
onNavItemClick: (tabIndex: number, e: React.MouseEvent<HTMLLIElement, MouseEvent>) => void
|
|
41
|
+
activeNavItem?: number | string
|
|
39
42
|
animationDirection?: AnimationDirection
|
|
40
43
|
showBorder?: boolean
|
|
41
44
|
size?: TabsSize
|
package/src/tabs/tabsNavBar.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import { List, ListItem } from '../list'
|
|
|
7
7
|
import { TagButton } from '../tag'
|
|
8
8
|
import { cs, Dict } from '../utils'
|
|
9
9
|
import { colors, iconSizeMapper } from './consts'
|
|
10
|
-
import { NavBarIconSize,
|
|
10
|
+
import { NavBarIconSize, TabIndexProps, TabNavBarProps } from './tabs.types'
|
|
11
11
|
import theme from './theme'
|
|
12
12
|
|
|
13
13
|
const { activeBg, border, color, hover, main } = colors
|
|
@@ -24,7 +24,7 @@ export const TabsNavBar = vui<'div', TabNavBarProps>((props, ref) => {
|
|
|
24
24
|
const py = sizes[size ?? 'md'].tabsNavBar.py
|
|
25
25
|
const iconMarginRight = size === 'xxl' ? '16px' : '8px'
|
|
26
26
|
|
|
27
|
-
const isActive = (tab:
|
|
27
|
+
const isActive = (tab: TabIndexProps) => !tab.disabled && tab?.index === activeNavItem
|
|
28
28
|
|
|
29
29
|
return (
|
|
30
30
|
<List
|
|
@@ -49,8 +49,8 @@ export const TabsNavBar = vui<'div', TabNavBarProps>((props, ref) => {
|
|
|
49
49
|
fontWeight={500}
|
|
50
50
|
h={h}
|
|
51
51
|
hoverBg={tab.disabled ? undefined : hover}
|
|
52
|
-
key={tab.
|
|
53
|
-
onClick={e => onNavItemClick?.(tab.
|
|
52
|
+
key={tab.index}
|
|
53
|
+
onClick={e => onNavItemClick?.(tab.index || 0, e)}
|
|
54
54
|
position="relative"
|
|
55
55
|
px="16px"
|
|
56
56
|
py={py}
|
|
@@ -86,7 +86,7 @@ export const TabsNavBar = vui<'div', TabNavBarProps>((props, ref) => {
|
|
|
86
86
|
</ListItem>
|
|
87
87
|
))}
|
|
88
88
|
{!!actions && (
|
|
89
|
-
<Box ml="auto"
|
|
89
|
+
<Box ml="auto" px={0.75} py={0.5}>
|
|
90
90
|
{actions}
|
|
91
91
|
</Box>
|
|
92
92
|
)}
|
package/src/tabs/useTabsState.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useState } from 'react'
|
|
2
2
|
|
|
3
|
-
import { AnimationDirection,
|
|
3
|
+
import { AnimationDirection, TabIndexProps } from './tabs.types'
|
|
4
4
|
|
|
5
|
-
export const useTabsState = (initialAnimation: AnimationDirection,
|
|
6
|
-
const [tabs, setTabs] = useState<
|
|
7
|
-
const [activeTabIndex, setActiveTabIndex] = useState<number>(
|
|
5
|
+
export const useTabsState = (initialAnimation: AnimationDirection, tabIndex?: number) => {
|
|
6
|
+
const [tabs, setTabs] = useState<TabIndexProps[]>([])
|
|
7
|
+
const [activeTabIndex, setActiveTabIndex] = useState<number>(tabIndex ?? 0)
|
|
8
8
|
const [animationDirection, setAnimationDirection] = useState<AnimationDirection>(initialAnimation)
|
|
9
9
|
|
|
10
10
|
return { tabs, setTabs, activeTabIndex, setActiveTabIndex, animationDirection, setAnimationDirection }
|