@veracity/vui 2.17.2-beta.0 → 2.17.2-beta.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.
@@ -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: "@ 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) => {
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":"AAIA,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"}
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"}
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
- import { TabsProps } from './tabs.types';
2
+ import { TabId, 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?: TabId | undefined;
6
6
  showBorder?: boolean | undefined;
7
- onTabClick?: ((id: number) => void) | undefined;
7
+ onTabClick?: ((tabId: TabId) => 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,EAAY,SAAS,EAAE,MAAM,cAAc,CAAA;AAIlD,eAAO,MAAM,QAAQ;;;;;SAEpB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,IAAI,kDAgEf,CAAA;AAIF,eAAe,IAAI,CAAA"}
1
+ {"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../../src/tabs/tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4C,MAAM,OAAO,CAAA;AAMhE,OAAO,EAAE,KAAK,EAA2B,SAAS,EAAE,MAAM,cAAc,CAAA;AAIxE,eAAO,MAAM,QAAQ;;;;;SAEpB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,IAAI,kDAmEf,CAAA;AAIF,eAAe,IAAI,CAAA"}
@@ -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', activeTabId);
35
+ const { tabs, setTabs, activeTabIndex, setActiveTabIndex, animationDirection, setAnimationDirection } = (0, useTabsState_1.useTabsState)('fadeIn', 0);
36
36
  (0, react_1.useEffect)(() => {
37
- const t = [];
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
- t.push({
44
- id: index,
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(t);
55
- if (activeTabId !== undefined && (tabs === null || tabs === void 0 ? void 0 : tabs[activeTabId])) {
56
- setActiveTabIndex(activeTabId);
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 = (id, e) => {
63
+ const onNavItemClick = (tabIndex, e) => {
60
64
  var _a;
61
- const tab = tabs.find(t => t.id === id);
62
- if ((tab === null || tab === void 0 ? void 0 : tab.children) !== undefined) {
63
- setAnimationDirection(id < activeTabIndex ? 'fadeLeft' : 'fadeRight');
64
- setActiveTabIndex(id);
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: (id, e) => onNavItemClick(id, 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." }))] })));
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;
@@ -4,17 +4,18 @@ import { IconProp } from '../icon';
4
4
  import { SystemProps } from '../system';
5
5
  import { ThemingProps } from '../theme';
6
6
  export type AnimationDirection = 'fadeLeft' | 'fadeRight' | 'fadeIn';
7
+ export type TabId = string | number;
7
8
  export type TabsSize = 'md' | 'sm' | 'lg' | 'xl' | 'xxl';
8
9
  export type NavBarIconSize = 'md' | 'xs' | 'sm' | 'lg' | 'xl' | undefined;
9
10
  export type TabsProps = SystemProps & ThemingProps<'Tabs'> & ChildrenProp & {
10
11
  actions?: ReactNode;
11
- activeTabId?: number;
12
+ activeTabId?: TabId;
12
13
  showBorder?: boolean;
13
- onTabClick?: (id: number) => void;
14
+ onTabClick?: (tabId: TabId) => void;
14
15
  };
15
16
  export type TabProps = SystemProps & ChildrenProp & {
16
17
  icon?: IconProp;
17
- id?: number;
18
+ id?: TabId;
18
19
  title: ReactNode;
19
20
  disabled?: boolean;
20
21
  className?: string;
@@ -22,11 +23,14 @@ export type TabProps = SystemProps & ChildrenProp & {
22
23
  /** If provided, displays a remove button with this function as onClick. */
23
24
  onDelete?: (nativeEvent?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
24
25
  };
26
+ export type TabIndexProps = TabProps & {
27
+ index?: number;
28
+ };
25
29
  export type TabNavBarProps = {
26
30
  actions?: ReactNode;
27
- tabs: TabProps[];
28
- onNavItemClick: (id: number, e: React.MouseEvent<HTMLLIElement, MouseEvent>) => void;
29
- activeNavItem?: number;
31
+ tabs: TabIndexProps[];
32
+ onNavItemClick: (tabIndex: number, e: React.MouseEvent<HTMLLIElement, MouseEvent>) => void;
33
+ activeNavItem?: TabId;
30
34
  animationDirection?: AnimationDirection;
31
35
  showBorder?: boolean;
32
36
  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;AAEpE,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAA;AAC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,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,KAAK,CAAA;IACrB,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,EAAkB,cAAc,EAAY,MAAM,cAAc,CAAA;AAKvE,eAAO,MAAM,UAAU,uDAgFrB,CAAA;AAIF,eAAe,UAAU,CAAA"}
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.id === 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.id || 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.id))), !!actions && ((0, jsx_runtime_1.jsx)(box_1.default, { ml: "auto", pb: 0.5, pr: 0.5, children: actions }))] }));
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, TabProps } from './tabs.types';
3
- export declare const useTabsState: (initialAnimation: AnimationDirection, activeTabId?: number) => {
4
- tabs: TabProps[];
5
- setTabs: import("react").Dispatch<import("react").SetStateAction<TabProps[]>>;
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,QAAQ,EAAE,MAAM,cAAc,CAAA;AAE3D,eAAO,MAAM,YAAY,qBAAsB,kBAAkB,gBAAgB,MAAM;;;;;;;CAMtF,CAAA"}
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, activeTabId) => {
5
+ const useTabsState = (initialAnimation, tabIndex) => {
6
6
  const [tabs, setTabs] = (0, react_1.useState)([]);
7
- const [activeTabIndex, setActiveTabIndex] = (0, react_1.useState)(activeTabId !== null && activeTabId !== void 0 ? activeTabId : 0);
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: "@ 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) => {
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":"AAIA,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"}
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"}
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
- import { TabsProps } from './tabs.types';
2
+ import { TabId, 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?: TabId | undefined;
6
6
  showBorder?: boolean | undefined;
7
- onTabClick?: ((id: number) => void) | undefined;
7
+ onTabClick?: ((tabId: TabId) => 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,EAAY,SAAS,EAAE,MAAM,cAAc,CAAA;AAIlD,eAAO,MAAM,QAAQ;;;;;SAEpB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,IAAI,kDAgEf,CAAA;AAIF,eAAe,IAAI,CAAA"}
1
+ {"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../../src/tabs/tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4C,MAAM,OAAO,CAAA;AAMhE,OAAO,EAAE,KAAK,EAA2B,SAAS,EAAE,MAAM,cAAc,CAAA;AAIxE,eAAO,MAAM,QAAQ;;;;;SAEpB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,IAAI,kDAmEf,CAAA;AAIF,eAAe,IAAI,CAAA"}
@@ -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', activeTabId);
18
+ const { tabs, setTabs, activeTabIndex, setActiveTabIndex, animationDirection, setAnimationDirection } = useTabsState('fadeIn', 0);
19
19
  useEffect(() => {
20
- const t = [];
20
+ const _tabs = [];
21
21
  if (children) {
22
22
  ;
23
23
  Children.toArray(children).forEach((child, index) => {
24
24
  if (child?.props?.title)
25
- t.push({
26
- id: index,
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(t);
37
- if (activeTabId !== undefined && tabs?.[activeTabId]) {
38
- setActiveTabIndex(activeTabId);
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 = (id, e) => {
42
- const tab = tabs.find(t => t.id === id);
43
- if (tab?.children !== undefined) {
44
- setAnimationDirection(id < activeTabIndex ? 'fadeLeft' : 'fadeRight');
45
- setActiveTabIndex(id);
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: (id, e) => onNavItemClick(id, 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." }))] }));
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;
@@ -4,17 +4,18 @@ import { IconProp } from '../icon';
4
4
  import { SystemProps } from '../system';
5
5
  import { ThemingProps } from '../theme';
6
6
  export type AnimationDirection = 'fadeLeft' | 'fadeRight' | 'fadeIn';
7
+ export type TabId = string | number;
7
8
  export type TabsSize = 'md' | 'sm' | 'lg' | 'xl' | 'xxl';
8
9
  export type NavBarIconSize = 'md' | 'xs' | 'sm' | 'lg' | 'xl' | undefined;
9
10
  export type TabsProps = SystemProps & ThemingProps<'Tabs'> & ChildrenProp & {
10
11
  actions?: ReactNode;
11
- activeTabId?: number;
12
+ activeTabId?: TabId;
12
13
  showBorder?: boolean;
13
- onTabClick?: (id: number) => void;
14
+ onTabClick?: (tabId: TabId) => void;
14
15
  };
15
16
  export type TabProps = SystemProps & ChildrenProp & {
16
17
  icon?: IconProp;
17
- id?: number;
18
+ id?: TabId;
18
19
  title: ReactNode;
19
20
  disabled?: boolean;
20
21
  className?: string;
@@ -22,11 +23,14 @@ export type TabProps = SystemProps & ChildrenProp & {
22
23
  /** If provided, displays a remove button with this function as onClick. */
23
24
  onDelete?: (nativeEvent?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
24
25
  };
26
+ export type TabIndexProps = TabProps & {
27
+ index?: number;
28
+ };
25
29
  export type TabNavBarProps = {
26
30
  actions?: ReactNode;
27
- tabs: TabProps[];
28
- onNavItemClick: (id: number, e: React.MouseEvent<HTMLLIElement, MouseEvent>) => void;
29
- activeNavItem?: number;
31
+ tabs: TabIndexProps[];
32
+ onNavItemClick: (tabIndex: number, e: React.MouseEvent<HTMLLIElement, MouseEvent>) => void;
33
+ activeNavItem?: TabId;
30
34
  animationDirection?: AnimationDirection;
31
35
  showBorder?: boolean;
32
36
  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;AAEpE,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,WAA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AAC,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,KAAK,CAAA;IACrB,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,EAAkB,cAAc,EAAY,MAAM,cAAc,CAAA;AAKvE,eAAO,MAAM,UAAU,uDAgFrB,CAAA;AAIF,eAAe,UAAU,CAAA"}
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.id === 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.id || 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.id))), !!actions && (_jsx(Box, { ml: "auto", pb: 0.5, pr: 0.5, children: actions }))] }));
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, TabProps } from './tabs.types';
3
- export declare const useTabsState: (initialAnimation: AnimationDirection, activeTabId?: number) => {
4
- tabs: TabProps[];
5
- setTabs: import("react").Dispatch<import("react").SetStateAction<TabProps[]>>;
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,QAAQ,EAAE,MAAM,cAAc,CAAA;AAE3D,eAAO,MAAM,YAAY,qBAAsB,kBAAkB,gBAAgB,MAAM;;;;;;;CAMtF,CAAA"}
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, activeTabId) => {
2
+ export const useTabsState = (initialAnimation, tabIndex) => {
3
3
  const [tabs, setTabs] = useState([]);
4
- const [activeTabIndex, setActiveTabIndex] = useState(activeTabId ?? 0);
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.0",
3
+ "version": "2.17.2-beta.1",
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",
@@ -149,7 +149,7 @@ export const Footer = vui<'div', FooterProps>((props, ref) => {
149
149
 
150
150
  {isDNV ? (
151
151
  <Box>
152
- <T size="sm">@ DNV AS 2021</T>
152
+ <T size="sm">&copy; DNV AS 2021</T>
153
153
  </Box>
154
154
  ) : (
155
155
  <Box>
package/src/tabs/tab.tsx CHANGED
@@ -1,5 +1,3 @@
1
- import React from 'react'
2
-
3
1
  import { styled, vui } from '../core'
4
2
  import { cs } from '../utils'
5
3
  import { TabProps } from './tabs.types'
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 { TabId, 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
- activeTabId
23
+ 0
24
24
  )
25
25
 
26
26
  useEffect(() => {
27
- const t: TabProps[] = []
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
- t.push({
32
- id: index,
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(t)
43
- if (activeTabId !== undefined && tabs?.[activeTabId]) {
44
- setActiveTabIndex(activeTabId)
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 = (id: number, e: React.MouseEvent<HTMLLIElement, MouseEvent>) => {
49
- const tab = tabs.find(t => t.id === id)
50
- if (tab?.children !== undefined) {
51
- setAnimationDirection(id < activeTabIndex ? 'fadeLeft' : 'fadeRight')
52
- setActiveTabIndex(id)
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={(id, e) => onNavItemClick(id, e)}
70
+ onNavItemClick={(tabIndex, e) => onNavItemClick(tabIndex, e)}
68
71
  showBorder={showBorder}
69
72
  size={size}
70
73
  tabs={tabs}
@@ -6,7 +6,7 @@ import { SystemProps } from '../system'
6
6
  import { ThemingProps } from '../theme'
7
7
 
8
8
  export type AnimationDirection = 'fadeLeft' | 'fadeRight' | 'fadeIn'
9
-
9
+ export type TabId = string | number
10
10
  export type TabsSize = 'md' | 'sm' | 'lg' | 'xl' | 'xxl'
11
11
  export type NavBarIconSize = 'md' | 'xs' | 'sm' | 'lg' | 'xl' | undefined
12
12
 
@@ -14,15 +14,15 @@ export type TabsProps = SystemProps &
14
14
  ThemingProps<'Tabs'> &
15
15
  ChildrenProp & {
16
16
  actions?: ReactNode
17
- activeTabId?: number
17
+ activeTabId?: TabId
18
18
  showBorder?: boolean
19
- onTabClick?: (id: number) => void
19
+ onTabClick?: (tabId: TabId) => void
20
20
  }
21
21
 
22
22
  export type TabProps = SystemProps &
23
23
  ChildrenProp & {
24
24
  icon?: IconProp
25
- id?: number
25
+ id?: TabId
26
26
  title: ReactNode
27
27
  disabled?: boolean
28
28
  className?: string
@@ -31,11 +31,15 @@ export type TabProps = SystemProps &
31
31
  onDelete?: (nativeEvent?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void
32
32
  }
33
33
 
34
+ export type TabIndexProps = TabProps & {
35
+ index?: number
36
+ }
37
+
34
38
  export type TabNavBarProps = {
35
39
  actions?: ReactNode
36
- tabs: TabProps[]
37
- onNavItemClick: (id: number, e: React.MouseEvent<HTMLLIElement, MouseEvent>) => void
38
- activeNavItem?: number
40
+ tabs: TabIndexProps[]
41
+ onNavItemClick: (tabIndex: number, e: React.MouseEvent<HTMLLIElement, MouseEvent>) => void
42
+ activeNavItem?: TabId
39
43
  animationDirection?: AnimationDirection
40
44
  showBorder?: boolean
41
45
  size?: TabsSize
@@ -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, TabNavBarProps, TabProps } from './tabs.types'
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: TabProps) => !tab.disabled && tab.id === activeNavItem
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.id}
53
- onClick={e => onNavItemClick?.(tab.id || 0, e)}
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" pb={0.5} pr={0.5}>
89
+ <Box ml="auto" px={0.75} py={0.5}>
90
90
  {actions}
91
91
  </Box>
92
92
  )}
@@ -1,10 +1,10 @@
1
1
  import { useState } from 'react'
2
2
 
3
- import { AnimationDirection, TabProps } from './tabs.types'
3
+ import { AnimationDirection, TabIndexProps } from './tabs.types'
4
4
 
5
- export const useTabsState = (initialAnimation: AnimationDirection, activeTabId?: number) => {
6
- const [tabs, setTabs] = useState<TabProps[]>([])
7
- const [activeTabIndex, setActiveTabIndex] = useState<number>(activeTabId ?? 0)
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 }