@veracity/vui 1.1.0 → 1.1.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.
- package/README.md +15 -0
- package/dist/cjs/core/styled.d.ts +6 -6
- package/dist/cjs/core/vuiProvider/vuiProvider.js +5 -4
- package/dist/cjs/icons/baseIcons/fal/falFileSignature.d.ts +4 -0
- package/dist/cjs/icons/baseIcons/fal/falFileSignature.d.ts.map +1 -0
- package/dist/cjs/icons/baseIcons/fal/falFileSignature.js +7 -0
- package/dist/cjs/icons/baseIcons/fal/falPaperclip.d.ts +4 -0
- package/dist/cjs/icons/baseIcons/fal/falPaperclip.d.ts.map +1 -0
- package/dist/cjs/icons/baseIcons/fal/falPaperclip.js +7 -0
- package/dist/cjs/icons/baseIcons/icons.d.ts +5 -3
- package/dist/cjs/icons/baseIcons/icons.d.ts.map +1 -1
- package/dist/cjs/icons/baseIcons/icons.js +14 -10
- package/dist/cjs/icons/baseIcons/types.d.ts +1 -1
- package/dist/cjs/icons/baseIcons/types.d.ts.map +1 -1
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/progress/index.d.ts +4 -0
- package/dist/cjs/progress/index.d.ts.map +1 -0
- package/dist/cjs/progress/index.js +24 -0
- package/dist/cjs/progress/progress.d.ts +6 -0
- package/dist/cjs/progress/progress.d.ts.map +1 -0
- package/dist/cjs/progress/progress.js +59 -0
- package/dist/cjs/progress/progress.types.d.ts +8 -0
- package/dist/cjs/progress/progress.types.d.ts.map +1 -0
- package/dist/cjs/progress/progress.types.js +2 -0
- package/dist/cjs/progress/theme.d.ts +47 -0
- package/dist/cjs/progress/theme.d.ts.map +1 -0
- package/dist/cjs/progress/theme.js +51 -0
- package/dist/cjs/tabs/index.d.ts +5 -0
- package/dist/cjs/tabs/index.d.ts.map +1 -0
- package/dist/cjs/tabs/index.js +25 -0
- package/dist/cjs/tabs/tab.d.ts +8 -0
- package/dist/cjs/tabs/tab.d.ts.map +1 -0
- package/dist/cjs/tabs/tab.js +20 -0
- package/dist/cjs/tabs/tabs.d.ts +14 -0
- package/dist/cjs/tabs/tabs.d.ts.map +1 -0
- package/dist/cjs/tabs/tabs.js +94 -0
- package/dist/cjs/tabs/tabs.types.d.ts +28 -0
- package/dist/cjs/tabs/tabs.types.d.ts.map +1 -0
- package/dist/cjs/tabs/tabs.types.js +2 -0
- package/dist/cjs/tabs/tabsNavBar.d.ts +4 -0
- package/dist/cjs/tabs/tabsNavBar.d.ts.map +1 -0
- package/dist/cjs/tabs/tabsNavBar.js +19 -0
- package/dist/cjs/tabs/theme.d.ts +14 -0
- package/dist/cjs/tabs/theme.d.ts.map +1 -0
- package/dist/cjs/tabs/theme.js +19 -0
- package/dist/cjs/tabs/useTabsState.d.ts +11 -0
- package/dist/cjs/tabs/useTabsState.d.ts.map +1 -0
- package/dist/cjs/tabs/useTabsState.js +11 -0
- package/dist/cjs/theme/components.d.ts +57 -0
- package/dist/cjs/theme/components.d.ts.map +1 -1
- package/dist/cjs/theme/components.js +22 -18
- package/dist/cjs/theme/defaultTheme.d.ts +57 -0
- package/dist/cjs/theme/defaultTheme.d.ts.map +1 -1
- package/dist/cjs/tooltip/tooltip.d.ts.map +1 -1
- package/dist/cjs/tooltip/tooltip.js +2 -2
- package/dist/cjs/tooltip/tooltip.types.d.ts +2 -0
- package/dist/cjs/tooltip/tooltip.types.d.ts.map +1 -1
- package/dist/esm/core/styled.d.ts +6 -6
- package/dist/esm/core/vuiProvider/vuiProvider.js +5 -4
- package/dist/esm/icons/baseIcons/fal/falFileSignature.d.ts +4 -0
- package/dist/esm/icons/baseIcons/fal/falFileSignature.d.ts.map +1 -0
- package/dist/esm/icons/baseIcons/fal/falFileSignature.js +5 -0
- package/dist/esm/icons/baseIcons/fal/falPaperclip.d.ts +4 -0
- package/dist/esm/icons/baseIcons/fal/falPaperclip.d.ts.map +1 -0
- package/dist/esm/icons/baseIcons/fal/falPaperclip.js +5 -0
- package/dist/esm/icons/baseIcons/icons.d.ts +5 -3
- package/dist/esm/icons/baseIcons/icons.d.ts.map +1 -1
- package/dist/esm/icons/baseIcons/icons.js +5 -3
- package/dist/esm/icons/baseIcons/types.d.ts +1 -1
- package/dist/esm/icons/baseIcons/types.d.ts.map +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/progress/index.d.ts +4 -0
- package/dist/esm/progress/index.d.ts.map +1 -0
- package/dist/esm/progress/index.js +3 -0
- package/dist/esm/progress/progress.d.ts +6 -0
- package/dist/esm/progress/progress.d.ts.map +1 -0
- package/dist/esm/progress/progress.js +22 -0
- package/dist/esm/progress/progress.types.d.ts +8 -0
- package/dist/esm/progress/progress.types.d.ts.map +1 -0
- package/dist/esm/progress/progress.types.js +1 -0
- package/dist/esm/progress/theme.d.ts +47 -0
- package/dist/esm/progress/theme.d.ts.map +1 -0
- package/dist/esm/progress/theme.js +49 -0
- package/dist/esm/tabs/index.d.ts +5 -0
- package/dist/esm/tabs/index.d.ts.map +1 -0
- package/dist/esm/tabs/index.js +4 -0
- package/dist/esm/tabs/tab.d.ts +8 -0
- package/dist/esm/tabs/tab.d.ts.map +1 -0
- package/dist/esm/tabs/tab.js +14 -0
- package/dist/esm/tabs/tabs.d.ts +14 -0
- package/dist/esm/tabs/tabs.d.ts.map +1 -0
- package/dist/esm/tabs/tabs.js +52 -0
- package/dist/esm/tabs/tabs.types.d.ts +28 -0
- package/dist/esm/tabs/tabs.types.d.ts.map +1 -0
- package/dist/esm/tabs/tabs.types.js +1 -0
- package/dist/esm/tabs/tabsNavBar.d.ts +4 -0
- package/dist/esm/tabs/tabsNavBar.d.ts.map +1 -0
- package/dist/esm/tabs/tabsNavBar.js +12 -0
- package/dist/esm/tabs/theme.d.ts +14 -0
- package/dist/esm/tabs/theme.d.ts.map +1 -0
- package/dist/esm/tabs/theme.js +17 -0
- package/dist/esm/tabs/useTabsState.d.ts +11 -0
- package/dist/esm/tabs/useTabsState.d.ts.map +1 -0
- package/dist/esm/tabs/useTabsState.js +7 -0
- package/dist/esm/theme/components.d.ts +57 -0
- package/dist/esm/theme/components.d.ts.map +1 -1
- package/dist/esm/theme/components.js +4 -0
- package/dist/esm/theme/defaultTheme.d.ts +57 -0
- package/dist/esm/theme/defaultTheme.d.ts.map +1 -1
- package/dist/esm/tooltip/tooltip.d.ts.map +1 -1
- package/dist/esm/tooltip/tooltip.js +2 -2
- package/dist/esm/tooltip/tooltip.types.d.ts +2 -0
- package/dist/esm/tooltip/tooltip.types.d.ts.map +1 -1
- package/package.json +8 -6
- package/src/core/vuiProvider/vuiProvider.tsx +6 -6
- package/src/icons/baseIcons/fal/falFileSignature.ts +8 -0
- package/src/icons/baseIcons/fal/falPaperclip.ts +8 -0
- package/src/icons/baseIcons/icons.ts +5 -3
- package/src/icons/baseIcons/types.ts +5 -3
- package/src/index.ts +2 -0
- package/src/progress/index.ts +3 -0
- package/src/progress/progress.tsx +54 -0
- package/src/progress/progress.types.ts +9 -0
- package/src/progress/theme.ts +53 -0
- package/src/tabs/index.ts +4 -0
- package/src/tabs/tab.tsx +23 -0
- package/src/tabs/tabs.tsx +88 -0
- package/src/tabs/tabs.types.ts +34 -0
- package/src/tabs/tabsNavBar.tsx +53 -0
- package/src/tabs/theme.ts +22 -0
- package/src/tabs/useTabsState.ts +11 -0
- package/src/theme/components.ts +4 -0
- package/src/tooltip/tooltip.tsx +2 -1
- package/src/tooltip/tooltip.types.ts +2 -0
|
@@ -84,12 +84,12 @@ export type BaseIcon =
|
|
|
84
84
|
| 'falArrowFromTop'
|
|
85
85
|
| 'falArrowLeft'
|
|
86
86
|
| 'falArrowRight'
|
|
87
|
+
| 'falArrows'
|
|
87
88
|
| 'falArrowToBottom'
|
|
88
89
|
| 'falArrowToLeft'
|
|
89
90
|
| 'falArrowToRight'
|
|
90
91
|
| 'falArrowToTop'
|
|
91
92
|
| 'falArrowUp'
|
|
92
|
-
| 'falArrows'
|
|
93
93
|
| 'falAward'
|
|
94
94
|
| 'falBan'
|
|
95
95
|
| 'falBars'
|
|
@@ -176,6 +176,7 @@ export type BaseIcon =
|
|
|
176
176
|
| 'falFilePdf'
|
|
177
177
|
| 'falFilePlus'
|
|
178
178
|
| 'falFilePowerpoint'
|
|
179
|
+
| 'falFileSignature'
|
|
179
180
|
| 'falFileSpreadsheet'
|
|
180
181
|
| 'falFileVideo'
|
|
181
182
|
| 'falFileWord'
|
|
@@ -210,6 +211,7 @@ export type BaseIcon =
|
|
|
210
211
|
| 'falMapMarkerCheck'
|
|
211
212
|
| 'falMapMarkerExclamation'
|
|
212
213
|
| 'falMinus'
|
|
214
|
+
| 'falPaperclip'
|
|
213
215
|
| 'falPause'
|
|
214
216
|
| 'falPauseCircle'
|
|
215
217
|
| 'falPen'
|
|
@@ -272,10 +274,10 @@ export type BaseIcon =
|
|
|
272
274
|
| 'falUserEdit'
|
|
273
275
|
| 'falUserFriends'
|
|
274
276
|
| 'falUserPlus'
|
|
275
|
-
| 'falUserShield'
|
|
276
|
-
| 'falUserTimes'
|
|
277
277
|
| 'falUsers'
|
|
278
278
|
| 'falUsersClass'
|
|
279
|
+
| 'falUserShield'
|
|
280
|
+
| 'falUserTimes'
|
|
279
281
|
| 'falWater'
|
|
280
282
|
| 'falWind'
|
|
281
283
|
| 'falWindTurbine'
|
package/src/index.ts
CHANGED
|
@@ -25,6 +25,7 @@ export * from './pagination'
|
|
|
25
25
|
export * from './panel'
|
|
26
26
|
export * from './popover'
|
|
27
27
|
export * from './portal'
|
|
28
|
+
export * from './progress'
|
|
28
29
|
export * from './radio'
|
|
29
30
|
export * from './select'
|
|
30
31
|
export * from './skeleton'
|
|
@@ -36,6 +37,7 @@ export * from './t'
|
|
|
36
37
|
export * from './toast'
|
|
37
38
|
export * from './tooltip'
|
|
38
39
|
export * from './table'
|
|
40
|
+
export * from './tabs'
|
|
39
41
|
export * from './tag'
|
|
40
42
|
export * from './textarea'
|
|
41
43
|
export * from './theme'
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import { Box } from '../box'
|
|
4
|
+
import { styled, useStyleConfig, vui } from '../core'
|
|
5
|
+
import { cs } from '../utils'
|
|
6
|
+
import { ProgressProps } from './progress.types'
|
|
7
|
+
|
|
8
|
+
export const ProgressBase = styled.divBox`
|
|
9
|
+
display: flex;
|
|
10
|
+
width: 100%;
|
|
11
|
+
`
|
|
12
|
+
|
|
13
|
+
const minPercentageDisplay = 3
|
|
14
|
+
|
|
15
|
+
/** Indicates a process progress. */
|
|
16
|
+
export const Progress = vui<'div', ProgressProps>((props, ref) => {
|
|
17
|
+
const { className, size = 'md', value = 0, max = 100, showPercentage, ...rest } = props
|
|
18
|
+
|
|
19
|
+
const [width, setWidth] = useState(0)
|
|
20
|
+
|
|
21
|
+
const styles = useStyleConfig('Progress', props)
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const w = !value ? 0 : Math.ceil((value / max) * 100)
|
|
25
|
+
setWidth(w > 100 ? 100 : w)
|
|
26
|
+
}, [value, max])
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<ProgressBase
|
|
30
|
+
className={cs('vui-progress', className)}
|
|
31
|
+
ref={ref}
|
|
32
|
+
{...styles.container}
|
|
33
|
+
{...rest}
|
|
34
|
+
bg="grey.10"
|
|
35
|
+
borderRadius="sm"
|
|
36
|
+
h={1}
|
|
37
|
+
>
|
|
38
|
+
<Box
|
|
39
|
+
bg="prussian.80"
|
|
40
|
+
borderRadius="sm"
|
|
41
|
+
position="relative"
|
|
42
|
+
textAlign="right"
|
|
43
|
+
transition="width 0.4s ease-in-out;"
|
|
44
|
+
w={`${width}%`}
|
|
45
|
+
>
|
|
46
|
+
{showPercentage && value >= minPercentageDisplay && (
|
|
47
|
+
<Box {...styles.percentage} position="absolute" right="0">{`${width}%`}</Box>
|
|
48
|
+
)}
|
|
49
|
+
</Box>
|
|
50
|
+
</ProgressBase>
|
|
51
|
+
)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
export default Progress
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const baseStyle = {}
|
|
2
|
+
|
|
3
|
+
const defaultProps = {
|
|
4
|
+
size: 'md'
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const sizes = {
|
|
8
|
+
sm: {
|
|
9
|
+
container: {
|
|
10
|
+
minH: '4px'
|
|
11
|
+
},
|
|
12
|
+
percentage: {
|
|
13
|
+
fontSize: '80%',
|
|
14
|
+
top: '-16px'
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
md: {
|
|
18
|
+
container: {
|
|
19
|
+
minH: '8px'
|
|
20
|
+
},
|
|
21
|
+
percentage: {
|
|
22
|
+
fontSize: '100%',
|
|
23
|
+
top: '-20px'
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
lg: {
|
|
27
|
+
container: {
|
|
28
|
+
minH: '12px'
|
|
29
|
+
},
|
|
30
|
+
percentage: {
|
|
31
|
+
fontSize: '110%',
|
|
32
|
+
top: '-22px'
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
xl: {
|
|
36
|
+
container: {
|
|
37
|
+
minH: '16px'
|
|
38
|
+
},
|
|
39
|
+
percentage: {
|
|
40
|
+
fontSize: '120%',
|
|
41
|
+
top: '-24px'
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const variants = {}
|
|
47
|
+
|
|
48
|
+
export default {
|
|
49
|
+
baseStyle,
|
|
50
|
+
defaultProps,
|
|
51
|
+
sizes,
|
|
52
|
+
variants
|
|
53
|
+
}
|
package/src/tabs/tab.tsx
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { styled, vui } from '../core'
|
|
4
|
+
import { cs } from '../utils'
|
|
5
|
+
import { TabProps } from './tabs.types'
|
|
6
|
+
|
|
7
|
+
export const TabBase = styled.divBox`
|
|
8
|
+
width: 100%;
|
|
9
|
+
`
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Implements a Tab component
|
|
13
|
+
*/
|
|
14
|
+
export const Tab = vui<'div', TabProps>((props, ref) => {
|
|
15
|
+
const { children, className } = props
|
|
16
|
+
return (
|
|
17
|
+
<TabBase className={cs('vui-tab', className)} ref={ref}>
|
|
18
|
+
{children}
|
|
19
|
+
</TabBase>
|
|
20
|
+
)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
export default Tab
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React, { ReactElement, useEffect } from 'react'
|
|
2
|
+
|
|
3
|
+
import { styled, useStyleConfig, vui } from '../core'
|
|
4
|
+
import { P } from '../p'
|
|
5
|
+
import { Panel } from '../panel'
|
|
6
|
+
import { cs } from '../utils'
|
|
7
|
+
import Tab from './tab'
|
|
8
|
+
import { TabProps, TabsProps } from './tabs.types'
|
|
9
|
+
import TabsNavBar from './tabsNavBar'
|
|
10
|
+
import { useTabsState } from './useTabsState'
|
|
11
|
+
|
|
12
|
+
export const TabsBase = styled.divBox<TabsProps>`
|
|
13
|
+
width: 100%;
|
|
14
|
+
`
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Implements Tabs navigation to switch between views.
|
|
18
|
+
*/
|
|
19
|
+
export const Tabs = vui<'div', TabsProps>((props, ref) => {
|
|
20
|
+
const { activeTabId, children, className, size, withPanel, onTabClick, ...rest } = props
|
|
21
|
+
const styles = useStyleConfig('Tabs', props)
|
|
22
|
+
const { tabs, setTabs, activeTabIndex, setActiveTabIndex, animationDirection, setAnimationDirection } = useTabsState(
|
|
23
|
+
'fadeIn',
|
|
24
|
+
activeTabId
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const t: TabProps[] = []
|
|
29
|
+
if (children) {
|
|
30
|
+
;(children as ReactElement[]).forEach((child: ReactElement<TabProps>, index: number) => {
|
|
31
|
+
if (child?.props?.title) {
|
|
32
|
+
t.push({
|
|
33
|
+
id: index,
|
|
34
|
+
title: child.props.title,
|
|
35
|
+
children: child.props.children,
|
|
36
|
+
disabled: child.props.disabled,
|
|
37
|
+
onClick: child.props.onClick
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
setTabs(t)
|
|
43
|
+
if (activeTabId !== undefined && tabs?.[activeTabId]) {
|
|
44
|
+
setActiveTabIndex(activeTabId)
|
|
45
|
+
}
|
|
46
|
+
}, [children, activeTabId])
|
|
47
|
+
|
|
48
|
+
const onNavItemClick = (id: number) => {
|
|
49
|
+
setAnimationDirection(id < activeTabIndex ? 'fadeLeft' : 'fadeRight')
|
|
50
|
+
setActiveTabIndex(id)
|
|
51
|
+
onTabClick?.(id)
|
|
52
|
+
tabs.find(t => t.id === id)?.onClick?.()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const activeTab = tabs?.[activeTabIndex]
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<TabsBase className={cs('vui-tabs', className)} ref={ref} {...styles.container} {...rest}>
|
|
59
|
+
{!!tabs?.length && (
|
|
60
|
+
<TabsNavBar
|
|
61
|
+
activeNavItem={activeTabIndex}
|
|
62
|
+
animationDirection={animationDirection}
|
|
63
|
+
onNavItemClick={onNavItemClick}
|
|
64
|
+
size={size}
|
|
65
|
+
tabs={tabs}
|
|
66
|
+
withPanel={withPanel}
|
|
67
|
+
/>
|
|
68
|
+
)}
|
|
69
|
+
{tabs?.length ? (
|
|
70
|
+
withPanel ? (
|
|
71
|
+
<Panel display="block" variant="outlined" w="100%">
|
|
72
|
+
<Tab onClick={activeTab?.onClick} title={activeTab?.title}>
|
|
73
|
+
{!activeTab?.disabled && activeTab?.children}
|
|
74
|
+
</Tab>
|
|
75
|
+
</Panel>
|
|
76
|
+
) : (
|
|
77
|
+
<Tab onClick={activeTab?.onClick} title={activeTab?.title}>
|
|
78
|
+
{!activeTab?.disabled && activeTab?.children}
|
|
79
|
+
</Tab>
|
|
80
|
+
)
|
|
81
|
+
) : (
|
|
82
|
+
<P p={2}>Please specify Tabs.</P>
|
|
83
|
+
)}
|
|
84
|
+
</TabsBase>
|
|
85
|
+
)
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
export default Tabs
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
import { SystemProps } from '../system'
|
|
4
|
+
import { ThemingProps } from '../theme'
|
|
5
|
+
|
|
6
|
+
export type AnimationDirection = 'fadeLeft' | 'fadeRight' | 'fadeIn'
|
|
7
|
+
|
|
8
|
+
export type TabsSize = 'md' | 'sm' | 'lg' | 'xl'
|
|
9
|
+
|
|
10
|
+
export type TabsProps = SystemProps &
|
|
11
|
+
ThemingProps<'Tabs'> & {
|
|
12
|
+
activeTabId?: number
|
|
13
|
+
children?: ReactNode | ReactNode[]
|
|
14
|
+
/** Wraps up the tab content with an outlined panel. */
|
|
15
|
+
withPanel?: boolean
|
|
16
|
+
onTabClick?: (id: number) => void
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type TabProps = SystemProps & {
|
|
20
|
+
id?: number
|
|
21
|
+
title: ReactNode
|
|
22
|
+
children?: ReactNode
|
|
23
|
+
disabled?: boolean
|
|
24
|
+
onClick?: () => void
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type TabNavBarProps = {
|
|
28
|
+
tabs: TabProps[]
|
|
29
|
+
onNavItemClick: (id: number) => void
|
|
30
|
+
activeNavItem?: number
|
|
31
|
+
animationDirection?: AnimationDirection
|
|
32
|
+
size?: TabsSize
|
|
33
|
+
withPanel?: boolean
|
|
34
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import Box from '../box'
|
|
4
|
+
import { vui } from '../core'
|
|
5
|
+
import { List, ListItem } from '../list'
|
|
6
|
+
import { cs } from '../utils'
|
|
7
|
+
import { TabNavBarProps } from './tabs.types'
|
|
8
|
+
|
|
9
|
+
export const TabsNavBar = vui<'div', TabNavBarProps>((props, ref) => {
|
|
10
|
+
const { tabs, onNavItemClick, activeNavItem, animationDirection, size, withPanel } = props
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<List
|
|
14
|
+
borderBottom={withPanel ? 'none' : '1px solid grey.40'}
|
|
15
|
+
className={cs('vui-tabsNavBar')}
|
|
16
|
+
display="flex"
|
|
17
|
+
isInteractive
|
|
18
|
+
mb={withPanel ? 0 : 2}
|
|
19
|
+
ml={withPanel ? 1 : 0}
|
|
20
|
+
ref={ref}
|
|
21
|
+
size={size}
|
|
22
|
+
w={1}
|
|
23
|
+
>
|
|
24
|
+
{tabs?.map?.(tab => (
|
|
25
|
+
<ListItem
|
|
26
|
+
className={`vui-tabsNavBarItem vui-tabsNavBarItem-${tab?.id}`}
|
|
27
|
+
disabled={tab.disabled}
|
|
28
|
+
display="inline-flex"
|
|
29
|
+
key={tab.id}
|
|
30
|
+
onClick={() => tab?.id !== undefined && onNavItemClick(tab.id)}
|
|
31
|
+
position="relative"
|
|
32
|
+
>
|
|
33
|
+
{tab.title}
|
|
34
|
+
{!tab.disabled && tab.id === activeNavItem && (
|
|
35
|
+
<Box
|
|
36
|
+
animation={animationDirection}
|
|
37
|
+
bg="prussian.80"
|
|
38
|
+
bottom={withPanel ? 0 : '-1px'}
|
|
39
|
+
h={`${size === 'sm' ? 2 : 4}px`}
|
|
40
|
+
left={0}
|
|
41
|
+
position="absolute"
|
|
42
|
+
w={1}
|
|
43
|
+
>
|
|
44
|
+
|
|
45
|
+
</Box>
|
|
46
|
+
)}
|
|
47
|
+
</ListItem>
|
|
48
|
+
))}
|
|
49
|
+
</List>
|
|
50
|
+
)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
export default TabsNavBar
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const baseStyle = {}
|
|
2
|
+
|
|
3
|
+
const defaultProps = {}
|
|
4
|
+
|
|
5
|
+
const parts = ['container', 'tabsNavBar', 'tab']
|
|
6
|
+
|
|
7
|
+
const sizes = {
|
|
8
|
+
sm: {},
|
|
9
|
+
md: {},
|
|
10
|
+
lg: {},
|
|
11
|
+
xl: {}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const variants = {}
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
baseStyle,
|
|
18
|
+
defaultProps,
|
|
19
|
+
parts,
|
|
20
|
+
sizes,
|
|
21
|
+
variants
|
|
22
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import { AnimationDirection, TabProps } from './tabs.types'
|
|
4
|
+
|
|
5
|
+
export const useTabsState = (initialAnimation: AnimationDirection, activeTabId?: number) => {
|
|
6
|
+
const [tabs, setTabs] = useState<TabProps[]>([])
|
|
7
|
+
const [activeTabIndex, setActiveTabIndex] = useState<number>(activeTabId ?? 0)
|
|
8
|
+
const [animationDirection, setAnimationDirection] = useState<AnimationDirection>(initialAnimation)
|
|
9
|
+
|
|
10
|
+
return { tabs, setTabs, activeTabIndex, setActiveTabIndex, animationDirection, setAnimationDirection }
|
|
11
|
+
}
|
package/src/theme/components.ts
CHANGED
|
@@ -21,6 +21,7 @@ import P from '../p/theme'
|
|
|
21
21
|
import Pagination from '../pagination/theme'
|
|
22
22
|
import Panel from '../panel/theme'
|
|
23
23
|
import Popover from '../popover/theme'
|
|
24
|
+
import Progress from '../progress/theme'
|
|
24
25
|
import Radio from '../radio/theme'
|
|
25
26
|
import Select from '../select/theme'
|
|
26
27
|
import Skeleton from '../skeleton/theme'
|
|
@@ -28,6 +29,7 @@ import Spinner from '../spinner/theme'
|
|
|
28
29
|
import Switch from '../switch/theme'
|
|
29
30
|
import T from '../t/theme'
|
|
30
31
|
import Table from '../table/theme'
|
|
32
|
+
import Tabs from '../tabs/theme'
|
|
31
33
|
import Tag from '../tag/theme'
|
|
32
34
|
import Textarea from '../textarea/theme'
|
|
33
35
|
|
|
@@ -54,6 +56,7 @@ export default {
|
|
|
54
56
|
P,
|
|
55
57
|
Pagination,
|
|
56
58
|
Panel,
|
|
59
|
+
Progress,
|
|
57
60
|
Popover,
|
|
58
61
|
Radio,
|
|
59
62
|
Select,
|
|
@@ -62,6 +65,7 @@ export default {
|
|
|
62
65
|
Switch,
|
|
63
66
|
T,
|
|
64
67
|
Table,
|
|
68
|
+
Tabs,
|
|
65
69
|
Tag,
|
|
66
70
|
Textarea
|
|
67
71
|
}
|
package/src/tooltip/tooltip.tsx
CHANGED
|
@@ -12,7 +12,7 @@ import { TooltipProps } from './tooltip.types'
|
|
|
12
12
|
*
|
|
13
13
|
* */
|
|
14
14
|
export const Tooltip = (props: TooltipProps) => {
|
|
15
|
-
const { children, text = 'demo', placement = 'top', isAnimated = false } = props
|
|
15
|
+
const { children, maxWidth = '400px', text = 'demo', placement = 'top', isAnimated = false } = props
|
|
16
16
|
|
|
17
17
|
return (
|
|
18
18
|
<Popover placement={placement} trigger="mouseenter">
|
|
@@ -24,6 +24,7 @@ export const Tooltip = (props: TooltipProps) => {
|
|
|
24
24
|
bg={color}
|
|
25
25
|
color="white"
|
|
26
26
|
m={1}
|
|
27
|
+
maxW={maxWidth}
|
|
27
28
|
p={1}
|
|
28
29
|
pl={2}
|
|
29
30
|
pr={2}
|
|
@@ -7,5 +7,7 @@ export type TooltipProps = {
|
|
|
7
7
|
placement?: 'top' | 'left' | 'bottom' | 'right'
|
|
8
8
|
/** Displays the tooltip with animation, without the arrow pointer. */
|
|
9
9
|
isAnimated?: boolean
|
|
10
|
+
/** Sets maximum width to the tooltip body. */
|
|
11
|
+
maxWidth?: string
|
|
10
12
|
children?: ReactNode
|
|
11
13
|
}
|