@fixefy/fixefy-ui-components 0.0.36 → 0.0.38
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/.prettierrc.json +10 -0
- package/.swcrc +20 -0
- package/build/FxTag/FxTag.js +41 -0
- package/build/FxTag/fxtag_types.d.js +4 -0
- package/build/FxTag/index.js +20 -0
- package/build/FxTag/styles/tag.styles.js +94 -0
- package/package.json +7 -9
- package/src/FxActionsTray/FxActionsTray.tsx +293 -0
- package/src/FxActionsTray/actions_tray_types.d.ts +15 -0
- package/src/FxActionsTray/index.ts +3 -0
- package/src/FxActionsTray/styles/actions_tray.styles.tsx +90 -0
- package/src/FxAggregationsBar/FxAggregations.tsx +32 -0
- package/src/FxAggregationsBar/aggregations_types.d.ts +21 -0
- package/src/FxAggregationsBar/helpers/structureReader.tsx +66 -0
- package/src/FxAggregationsBar/index.ts +2 -0
- package/src/FxAggregationsBar/operations/query.ts +64 -0
- package/src/FxAsyncDropdown/FxAsyncDropdown.tsx +362 -0
- package/src/FxAsyncDropdown/async_dropdown_types.d.ts +40 -0
- package/src/FxAsyncDropdown/helpers/helpers.ts +105 -0
- package/src/FxAsyncDropdown/index.ts +2 -0
- package/src/FxAsyncDropdown/styles/dropdown.styles.tsx +162 -0
- package/src/FxAvatar/FxAvatar.tsx +50 -0
- package/src/FxAvatar/avatar_types.d.ts +11 -0
- package/src/FxAvatar/helpers/stringToColor.ts +16 -0
- package/src/FxAvatar/index.ts +2 -0
- package/src/FxAvatar/styles/avatar.styles.tsx +82 -0
- package/src/FxButton/FxButton.tsx +11 -0
- package/src/FxButton/index.ts +2 -0
- package/src/FxButton/styles/button.styles.jsx +16 -0
- package/src/FxButton/styles/button.styles.tsx +14 -0
- package/src/FxChip/FxChip.tsx +14 -0
- package/src/FxChip/chip_types.d.ts +34 -0
- package/src/FxChip/index.ts +2 -0
- package/src/FxChip/styles/chip.styles.tsx +51 -0
- package/src/FxIcon/FxIcon.tsx +34 -0
- package/src/FxIcon/content/dynamic_icon.tsx +3 -0
- package/src/FxIcon/content/index.ts +2 -0
- package/src/FxIcon/content/lazy_icon.tsx +48 -0
- package/src/FxIcon/icon_types.d.ts +10 -0
- package/src/FxIcon/index.ts +2 -0
- package/src/FxModal/FxModal.tsx +44 -0
- package/src/FxModal/index.ts +2 -0
- package/src/FxModal/modal_types.d.ts +10 -0
- package/src/FxModal/styles/modal.style.tsx +40 -0
- package/src/FxNotes/FxNotes.tsx +165 -0
- package/src/FxNotes/helpers/stringToColor.ts +19 -0
- package/src/FxNotes/index.ts +2 -0
- package/src/FxNotes/note_types.d.ts +12 -0
- package/src/FxNotes/operations/queries.ts +21 -0
- package/src/FxNotes/styles/notes.styles.tsx +135 -0
- package/src/FxNumberField/FxNumberField.tsx +37 -0
- package/src/FxNumberField/index.ts +2 -0
- package/src/FxNumberField/number_field_types.d.ts +7 -0
- package/src/FxNumberField/styles/number_field.styles.ts +85 -0
- package/src/FxProgressCircle/FxProgressCircle.tsx +40 -0
- package/src/FxProgressCircle/index.ts +2 -0
- package/src/FxProgressCircle/progress_circle_types.d.ts +9 -0
- package/src/FxProgressCircle/styles/progress_circle.styles.tsx +33 -0
- package/src/FxProgressCounter/ProgressCounter.tsx +81 -0
- package/src/FxProgressCounter/index.ts +2 -0
- package/src/FxProgressCounter/progress_counter_types.d.ts +10 -0
- package/src/FxProgressCounter/styles/progress_counter.styles.ts +40 -0
- package/src/FxScore/FxScore.tsx +75 -0
- package/src/FxScore/index.ts +2 -0
- package/src/FxScore/score_types.d.ts +16 -0
- package/src/FxScore/styles/score.styles.ts +42 -0
- package/src/FxShowMore/FxShowMore.tsx +60 -0
- package/src/FxShowMore/index.ts +2 -0
- package/src/FxShowMore/show_more_types.d.ts +8 -0
- package/src/FxShowMore/styles/show_more.styles.ts +67 -0
- package/src/FxSlider/FxSlider.tsx +8 -0
- package/src/FxSlider/index.ts +2 -0
- package/src/FxSlider/slider_types.d.ts +3 -0
- package/src/FxStatisticsBar/FxStatisticsBar.tsx +112 -0
- package/src/FxStatisticsBar/index.ts +2 -0
- package/src/FxStatisticsBar/statistics_bar_types.d.ts +8 -0
- package/src/FxStatisticsBar/styles/statistics.styles.ts +41 -0
- package/src/FxStatusBar/FxStatusBar.tsx +66 -0
- package/src/FxStatusBar/helpers/constants.ts +12 -0
- package/src/FxStatusBar/index.ts +2 -0
- package/src/FxStatusBar/status_bar_types.d.ts +14 -0
- package/src/FxStatusBar/styles/statusBar.styles.tsx +67 -0
- package/src/FxStyledComponents/index.tsx +196 -0
- package/src/FxTag/FxTag.tsx +14 -0
- package/src/FxTag/fxtag_types.d.ts +4 -0
- package/src/FxTag/index.ts +2 -0
- package/src/FxTag/styles/tag.styles.tsx +24 -0
- package/src/FxTextField/FxTextField.tsx +117 -0
- package/src/FxTextField/index.ts +2 -0
- package/src/FxTextField/text_field_types.d.ts +20 -0
- package/src/FxTodo/FxTodo.tsx +58 -0
- package/src/FxTodo/index.ts +2 -0
- package/src/FxTodo/styles/todo.styles.tsx +113 -0
- package/src/FxTodo/todo_types.d.ts +19 -0
- package/src/FxWizard/FxWizard.tsx +56 -0
- package/src/FxWizard/WizardContext.tsx +108 -0
- package/src/FxWizard/index.ts +3 -0
- package/src/FxWizard/styles/wizard.styles.tsx +22 -0
- package/src/FxWizard/wizard_types.d.ts +37 -0
- package/src/index.ts +23 -0
- package/tsconfig.json +22 -0
- package/webpack.config.js +35 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { styled } from '@mui/material/styles'
|
|
2
|
+
import { Dialog, DialogActions, DialogTitle } from '@mui/material'
|
|
3
|
+
|
|
4
|
+
export const FxDialog = styled(Dialog)(() => ({
|
|
5
|
+
'& .MuiDialog-paper': {
|
|
6
|
+
borderRadius: 8,
|
|
7
|
+
padding: '24px',
|
|
8
|
+
// minWidth: "370px",
|
|
9
|
+
maxWidth: 'fit-content',
|
|
10
|
+
// height: "262px",
|
|
11
|
+
},
|
|
12
|
+
'& .MuiDialogContent-root': {
|
|
13
|
+
padding: 0,
|
|
14
|
+
},
|
|
15
|
+
// "& .MuiDialogTitle-root": {
|
|
16
|
+
// margin: "8px 0",
|
|
17
|
+
// },
|
|
18
|
+
'& .MuiDialogActions-root': {
|
|
19
|
+
margin: '24px 0 0 0',
|
|
20
|
+
padding: 0,
|
|
21
|
+
},
|
|
22
|
+
}))
|
|
23
|
+
|
|
24
|
+
export const StyledDialogTitle = styled(DialogTitle)(() => ({
|
|
25
|
+
fontSize: 14,
|
|
26
|
+
fontWeight: 900,
|
|
27
|
+
margin: '8px 0',
|
|
28
|
+
}))
|
|
29
|
+
|
|
30
|
+
export const StyledInlineDialogTitle = styled(DialogTitle)(() => ({
|
|
31
|
+
fontSize: 19,
|
|
32
|
+
fontWeight: 600,
|
|
33
|
+
color: '#568793',
|
|
34
|
+
margin: '8px 16px',
|
|
35
|
+
padding: 0,
|
|
36
|
+
}))
|
|
37
|
+
|
|
38
|
+
export const DialogActionsStyled = styled(DialogActions)(({}) => ({
|
|
39
|
+
justifyContent: 'flex-start',
|
|
40
|
+
}))
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import React, { useEffect, useState, useRef } from 'react'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
StyledAvatar,
|
|
5
|
+
CommentWrapper,
|
|
6
|
+
CommentInput,
|
|
7
|
+
CommentsWrapper,
|
|
8
|
+
UserComment,
|
|
9
|
+
CommentUserTitle,
|
|
10
|
+
CommentDate,
|
|
11
|
+
CommentDesc,
|
|
12
|
+
CommentsContainer,
|
|
13
|
+
UserCommentWrapper,
|
|
14
|
+
CommentsScrollWrapper,
|
|
15
|
+
} from './styles/notes.styles'
|
|
16
|
+
|
|
17
|
+
import { ME } from './operations/queries'
|
|
18
|
+
import { useQuery } from '@apollo/client'
|
|
19
|
+
import { NotesPropsType } from './note_types'
|
|
20
|
+
import { stringToColor } from './helpers/stringToColor'
|
|
21
|
+
import { normalizeTimestamp, titleCase } from '@fixefy/fixefy-ui-utils'
|
|
22
|
+
|
|
23
|
+
type BackgroundColorsType = {
|
|
24
|
+
[key: string]: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const FxNotes = ({ notes, onChange, onSend }: NotesPropsType) => {
|
|
28
|
+
const [comment, setComment] = useState('')
|
|
29
|
+
const [backgroundcolors, setBackgroundColors] = useState({} as BackgroundColorsType)
|
|
30
|
+
// const [anchorEl] = React.useState<HTMLButtonElement | null>(null)
|
|
31
|
+
|
|
32
|
+
const inputRef: HTMLInputElement | any = useRef()
|
|
33
|
+
|
|
34
|
+
const { data } = useQuery(ME)
|
|
35
|
+
const { me } = data
|
|
36
|
+
|
|
37
|
+
// const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
38
|
+
// setAnchorEl(event.currentTarget)
|
|
39
|
+
// }
|
|
40
|
+
|
|
41
|
+
// const handleClose = () => {
|
|
42
|
+
// setAnchorEl(null)
|
|
43
|
+
// }
|
|
44
|
+
|
|
45
|
+
const handleEnterKeyPressed = () => {
|
|
46
|
+
setComment((prevState) => {
|
|
47
|
+
if (prevState) {
|
|
48
|
+
onSend &&
|
|
49
|
+
onSend({
|
|
50
|
+
created_at: new Date().getTime(),
|
|
51
|
+
created_by: me.username,
|
|
52
|
+
text: prevState,
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return ''
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
onChange && onChange(comment)
|
|
62
|
+
}, [comment])
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (inputRef.current) {
|
|
66
|
+
inputRef.current.addEventListener('keyup', (event: any) => {
|
|
67
|
+
if (event.keyCode === 13) {
|
|
68
|
+
event.preventDefault()
|
|
69
|
+
handleEnterKeyPressed()
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return inputRef && inputRef.current && inputRef.current.removeEventListener('keyup', handleEnterKeyPressed)
|
|
75
|
+
}, [])
|
|
76
|
+
|
|
77
|
+
// const open = Boolean(anchorEl)
|
|
78
|
+
// const id = open ? 'simple-popover' : undefined
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<CommentsContainer>
|
|
82
|
+
{/* <StyledPopover
|
|
83
|
+
id={id}
|
|
84
|
+
open={open}
|
|
85
|
+
anchorEl={anchorEl}
|
|
86
|
+
onClose={handleClose}
|
|
87
|
+
anchorOrigin={{
|
|
88
|
+
vertical: 'bottom',
|
|
89
|
+
horizontal: 'left',
|
|
90
|
+
}}>
|
|
91
|
+
<span>asd</span>
|
|
92
|
+
<span>asd</span>
|
|
93
|
+
<span>asd</span>
|
|
94
|
+
<span>asd</span>
|
|
95
|
+
</StyledPopover> */}
|
|
96
|
+
<CommentWrapper>
|
|
97
|
+
<StyledAvatar
|
|
98
|
+
sx={{
|
|
99
|
+
backgroundColor: backgroundcolors[me.username]
|
|
100
|
+
? backgroundcolors[me.username]
|
|
101
|
+
: stringToColor(me.username, (color) => {
|
|
102
|
+
setBackgroundColors({
|
|
103
|
+
...backgroundcolors,
|
|
104
|
+
[me.username]: color,
|
|
105
|
+
})
|
|
106
|
+
}),
|
|
107
|
+
}}
|
|
108
|
+
src={me && me.image_url}
|
|
109
|
+
>
|
|
110
|
+
{me && titleCase(me.username.slice(0, 1))}
|
|
111
|
+
</StyledAvatar>
|
|
112
|
+
<CommentInput
|
|
113
|
+
type='text'
|
|
114
|
+
value={comment}
|
|
115
|
+
ref={inputRef}
|
|
116
|
+
onChange={(e: React.FormEvent<HTMLInputElement>) => {
|
|
117
|
+
setComment(e.currentTarget.value)
|
|
118
|
+
}}
|
|
119
|
+
/>
|
|
120
|
+
{/* <Button aria-describedby={id} onClick={handleClick}>
|
|
121
|
+
asd
|
|
122
|
+
</Button> */}
|
|
123
|
+
</CommentWrapper>
|
|
124
|
+
{notes && notes.length ? (
|
|
125
|
+
<CommentsWrapper>
|
|
126
|
+
<CommentsScrollWrapper>
|
|
127
|
+
{notes
|
|
128
|
+
.slice()
|
|
129
|
+
.reverse()
|
|
130
|
+
.map((comment, index) => {
|
|
131
|
+
return (
|
|
132
|
+
<UserCommentWrapper key={index}>
|
|
133
|
+
<StyledAvatar
|
|
134
|
+
sx={{
|
|
135
|
+
backgroundColor: backgroundcolors[comment.created_by]
|
|
136
|
+
? backgroundcolors[comment.created_by]
|
|
137
|
+
: stringToColor(comment.created_by, (color) => {
|
|
138
|
+
setBackgroundColors({
|
|
139
|
+
...backgroundcolors,
|
|
140
|
+
[comment.created_by]: color,
|
|
141
|
+
})
|
|
142
|
+
}),
|
|
143
|
+
}}
|
|
144
|
+
// src={comment.image_url}
|
|
145
|
+
>
|
|
146
|
+
{titleCase(comment.created_by.slice(0, 1))}
|
|
147
|
+
</StyledAvatar>
|
|
148
|
+
<UserComment>
|
|
149
|
+
<CommentUserTitle>{comment.created_by}</CommentUserTitle>
|
|
150
|
+
<CommentDate>
|
|
151
|
+
{normalizeTimestamp(comment.created_at, {
|
|
152
|
+
dateOnly: true,
|
|
153
|
+
})}
|
|
154
|
+
</CommentDate>
|
|
155
|
+
<CommentDesc>{comment.text}</CommentDesc>
|
|
156
|
+
</UserComment>
|
|
157
|
+
</UserCommentWrapper>
|
|
158
|
+
)
|
|
159
|
+
})}
|
|
160
|
+
</CommentsScrollWrapper>
|
|
161
|
+
</CommentsWrapper>
|
|
162
|
+
) : null}
|
|
163
|
+
</CommentsContainer>
|
|
164
|
+
)
|
|
165
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const stringToColor = (string: string, callBack?: (color: string) => void) => {
|
|
2
|
+
let hash = 0
|
|
3
|
+
let color = '#'
|
|
4
|
+
if (!string) {
|
|
5
|
+
return '#000'
|
|
6
|
+
}
|
|
7
|
+
/* eslint-disable no-bitwise */
|
|
8
|
+
for (let i = 0; i < string.length; i += 1) {
|
|
9
|
+
hash = string.charCodeAt(i) + ((hash << 5) - hash)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
for (let i = 0; i < 3; i += 1) {
|
|
13
|
+
const value = (hash >> (i * 8)) & 0xff
|
|
14
|
+
color += `00${value.toString(16)}`.substr(-2)
|
|
15
|
+
}
|
|
16
|
+
/* eslint-enable no-bitwise */
|
|
17
|
+
callBack && callBack(color)
|
|
18
|
+
return color
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type NoteCreateInput = {
|
|
2
|
+
created_at: number
|
|
3
|
+
created_by: string
|
|
4
|
+
text: string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type NotesPropsType = {
|
|
8
|
+
notes?: NoteCreateInput[]
|
|
9
|
+
onChange?: (comment: string) => void
|
|
10
|
+
onSend?: (noteCreateInput: NoteCreateInput) => void
|
|
11
|
+
sendOnEnter?: boolean
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import gql from 'graphql-tag'
|
|
2
|
+
|
|
3
|
+
export const ME = gql`
|
|
4
|
+
query ME {
|
|
5
|
+
me {
|
|
6
|
+
_id
|
|
7
|
+
username
|
|
8
|
+
first_name
|
|
9
|
+
last_name
|
|
10
|
+
email
|
|
11
|
+
workspaces {
|
|
12
|
+
...InsideWorkspace
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
fragment InsideWorkspace on Workspace {
|
|
18
|
+
_id
|
|
19
|
+
title
|
|
20
|
+
}
|
|
21
|
+
`
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import Popover from '@mui/material/Popover'
|
|
2
|
+
|
|
3
|
+
import { styled } from '@mui/material/styles'
|
|
4
|
+
import { Avatar as _Avatar } from '@mui/material'
|
|
5
|
+
|
|
6
|
+
import '@fixefy/fixefy-ui-utils'
|
|
7
|
+
|
|
8
|
+
export const CommentsContainer: any = styled('div')(() => ({
|
|
9
|
+
display: 'flex',
|
|
10
|
+
flexDirection: 'column',
|
|
11
|
+
marginTop: 16,
|
|
12
|
+
justifyContent: 'space-between',
|
|
13
|
+
alignItems: 'flex-start',
|
|
14
|
+
}))
|
|
15
|
+
|
|
16
|
+
export const CommentsWrapper: any = styled('div')(({}) => ({
|
|
17
|
+
display: 'flex',
|
|
18
|
+
alignItems: 'flex-start',
|
|
19
|
+
flexDirection: 'column',
|
|
20
|
+
justifyContent: 'center',
|
|
21
|
+
width: '100%',
|
|
22
|
+
}))
|
|
23
|
+
|
|
24
|
+
export const CommentsScrollWrapper: any = styled('div')(({}) => ({
|
|
25
|
+
maxHeight: 170,
|
|
26
|
+
overflow: 'auto',
|
|
27
|
+
width: '100%',
|
|
28
|
+
}))
|
|
29
|
+
|
|
30
|
+
export const UserCommentWrapper: any = styled('div')(({}) => ({
|
|
31
|
+
display: 'flex',
|
|
32
|
+
alignItems: 'flex-start',
|
|
33
|
+
marginTop: 16,
|
|
34
|
+
'&:first-of-type': {
|
|
35
|
+
marginTop: 0,
|
|
36
|
+
},
|
|
37
|
+
}))
|
|
38
|
+
|
|
39
|
+
export const CommentWrapper: any = styled('div')(({}) => ({
|
|
40
|
+
display: 'flex',
|
|
41
|
+
alignItems: 'center',
|
|
42
|
+
width: '100%',
|
|
43
|
+
marginBottom: 16,
|
|
44
|
+
}))
|
|
45
|
+
|
|
46
|
+
export const CommentInput: any = styled('input')(({ theme }) => ({
|
|
47
|
+
background: theme.palette.common.white,
|
|
48
|
+
border: '1px solid #F0F0F0',
|
|
49
|
+
borderRadius: '4px',
|
|
50
|
+
height: 36,
|
|
51
|
+
padding: '0 16px',
|
|
52
|
+
|
|
53
|
+
fontStyle: 'normal',
|
|
54
|
+
fontWeight: 'normal',
|
|
55
|
+
fontSize: 14,
|
|
56
|
+
lineHeight: '20px',
|
|
57
|
+
letterSpacing: '0.15px',
|
|
58
|
+
color: '#172326',
|
|
59
|
+
|
|
60
|
+
width: '100%',
|
|
61
|
+
|
|
62
|
+
'&::focus-visible': {
|
|
63
|
+
outline: 'unset',
|
|
64
|
+
},
|
|
65
|
+
}))
|
|
66
|
+
|
|
67
|
+
export const StyledAvatar: any = styled(_Avatar)(({ theme }) => ({
|
|
68
|
+
width: 32,
|
|
69
|
+
height: 32,
|
|
70
|
+
border: `2px solid ${theme.palette.common.white}`,
|
|
71
|
+
marginRight: '8px',
|
|
72
|
+
|
|
73
|
+
fontFamily: 'Open Sans',
|
|
74
|
+
fontStyle: 'normal',
|
|
75
|
+
fontWeight: 'normal',
|
|
76
|
+
fontSize: 14,
|
|
77
|
+
lineHeight: '20px',
|
|
78
|
+
letterSpacing: '0.15px',
|
|
79
|
+
}))
|
|
80
|
+
|
|
81
|
+
export const UserComment: any = styled('div')(({ theme }) => ({
|
|
82
|
+
background: theme.palette.greyscale.contrastText,
|
|
83
|
+
border: '1px solid #F0F0F0',
|
|
84
|
+
borderRadius: '4px',
|
|
85
|
+
padding: '8px 16px',
|
|
86
|
+
minWidth: 300,
|
|
87
|
+
|
|
88
|
+
display: 'flex',
|
|
89
|
+
alignItems: 'flex-start',
|
|
90
|
+
flexDirection: 'column',
|
|
91
|
+
justifyContent: 'center',
|
|
92
|
+
}))
|
|
93
|
+
|
|
94
|
+
export const CommentUserTitle: any = styled('div')(({}) => ({
|
|
95
|
+
fontStyle: 'normal',
|
|
96
|
+
fontWeight: 'normal',
|
|
97
|
+
fontSize: 11,
|
|
98
|
+
lineHeight: '16px',
|
|
99
|
+
letterSpacing: '0.15px',
|
|
100
|
+
color: '#172326',
|
|
101
|
+
}))
|
|
102
|
+
|
|
103
|
+
export const CommentDate: any = styled('div')(({}) => ({
|
|
104
|
+
fontStyle: 'normal',
|
|
105
|
+
fontWeight: 'normal',
|
|
106
|
+
fontSize: 11,
|
|
107
|
+
lineHeight: '16px',
|
|
108
|
+
letterSpacing: '0.15px',
|
|
109
|
+
color: '#898989',
|
|
110
|
+
}))
|
|
111
|
+
|
|
112
|
+
export const CommentDesc: any = styled('div')(({}) => ({
|
|
113
|
+
fontStyle: 'normal',
|
|
114
|
+
fontWeight: 'normal',
|
|
115
|
+
fontSize: 14,
|
|
116
|
+
lineHeight: '20px',
|
|
117
|
+
letterSpacing: '0.15px',
|
|
118
|
+
color: '#172326',
|
|
119
|
+
}))
|
|
120
|
+
|
|
121
|
+
export const StyledPopover: any = styled(Popover)(({ theme }) => ({
|
|
122
|
+
position: 'absolute',
|
|
123
|
+
right: 12,
|
|
124
|
+
width: 80,
|
|
125
|
+
height: 16,
|
|
126
|
+
background: '#F7F7F7',
|
|
127
|
+
borderRadius: 4,
|
|
128
|
+
fontFamily: 'Open Sans',
|
|
129
|
+
fontStyle: 'normal',
|
|
130
|
+
fontWeight: 'normal',
|
|
131
|
+
fontSize: 11,
|
|
132
|
+
lineHeight: '16px',
|
|
133
|
+
letterSpacing: '0.1px',
|
|
134
|
+
color: theme.palette.primary.light,
|
|
135
|
+
}))
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
|
+
import { useStyles } from './styles/number_field.styles'
|
|
3
|
+
import { NumberfieldPropsType } from './number_field_types'
|
|
4
|
+
|
|
5
|
+
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight'
|
|
6
|
+
|
|
7
|
+
export function FxNumberField({ placeholder, defaultValue, label, hint, onChange }: NumberfieldPropsType) {
|
|
8
|
+
const _classes = useStyles()
|
|
9
|
+
const [value, setValue] = useState(defaultValue || 0)
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
onChange && onChange(value)
|
|
13
|
+
}, [value])
|
|
14
|
+
return (
|
|
15
|
+
<div className={_classes.container}>
|
|
16
|
+
{label && <span className={_classes.label}>{label}</span>}
|
|
17
|
+
<div className={_classes.inputWrapper}>
|
|
18
|
+
<input
|
|
19
|
+
type="number"
|
|
20
|
+
placeholder={placeholder}
|
|
21
|
+
value={value}
|
|
22
|
+
//@ts-ignore
|
|
23
|
+
onChange={(e) => setValue(e.target.value)}
|
|
24
|
+
/>
|
|
25
|
+
<div className={_classes.inputActions}>
|
|
26
|
+
<button className={_classes.inputActionsPlus} onClick={() => setValue(value + 1)}>
|
|
27
|
+
<KeyboardArrowRightIcon />
|
|
28
|
+
</button>
|
|
29
|
+
<button className={_classes.inputActionsMinus} onClick={() => setValue(value - 1)}>
|
|
30
|
+
<KeyboardArrowRightIcon />
|
|
31
|
+
</button>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
{hint && <span className={_classes.hint}>{hint}</span>}
|
|
35
|
+
</div>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { makeStyles } from '@mui/styles'
|
|
2
|
+
|
|
3
|
+
export const useStyles = makeStyles(() => ({
|
|
4
|
+
container: {},
|
|
5
|
+
label: {
|
|
6
|
+
fontFamily: 'Open Sans',
|
|
7
|
+
fontStyle: 'normal',
|
|
8
|
+
fontWeight: 'normal',
|
|
9
|
+
fontSize: 11,
|
|
10
|
+
lineHeight: '16px',
|
|
11
|
+
letterSpacing: 0.1,
|
|
12
|
+
color: '#505050',
|
|
13
|
+
},
|
|
14
|
+
hint: {
|
|
15
|
+
fontStyle: 'normal',
|
|
16
|
+
fontWeight: 'normal',
|
|
17
|
+
fontSize: 11,
|
|
18
|
+
lineHeight: '16px',
|
|
19
|
+
display: 'flex',
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
letterSpacing: 0.1,
|
|
22
|
+
color: '#8A8A8A',
|
|
23
|
+
},
|
|
24
|
+
inputWrapper: {
|
|
25
|
+
background: '#FFFFFF',
|
|
26
|
+
border: '1px solid #EEEEEE',
|
|
27
|
+
borderRadius: 5,
|
|
28
|
+
height: 40,
|
|
29
|
+
display: 'flex',
|
|
30
|
+
width: 'fit-content',
|
|
31
|
+
['& input']: {
|
|
32
|
+
border: 'none',
|
|
33
|
+
paddingLeft: 10,
|
|
34
|
+
borderRadius: 5,
|
|
35
|
+
['&:focus-visible']: {
|
|
36
|
+
outline: 'none',
|
|
37
|
+
},
|
|
38
|
+
['&::-webkit-inner-spin-button']: {
|
|
39
|
+
'-webkit-appearance': 'none',
|
|
40
|
+
},
|
|
41
|
+
['&::-webkit-outer-spin-button']: {
|
|
42
|
+
'-webkit-appearance': 'none',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
inputActions: {
|
|
47
|
+
display: 'flex',
|
|
48
|
+
flexDirection: 'column',
|
|
49
|
+
alignItems: 'center',
|
|
50
|
+
justifyContent: 'center',
|
|
51
|
+
},
|
|
52
|
+
inputActionsPlus: {
|
|
53
|
+
cursor: 'pointer',
|
|
54
|
+
background: '#FFFFFF',
|
|
55
|
+
height: '50%',
|
|
56
|
+
padding: 0,
|
|
57
|
+
width: 36,
|
|
58
|
+
border: 'none',
|
|
59
|
+
borderLeft: '1px solid #EEEEEE',
|
|
60
|
+
borderBottom: '1px solid #EEEEEE',
|
|
61
|
+
borderRadius: '0 5px 0 0',
|
|
62
|
+
color: '#568793',
|
|
63
|
+
['& svg']: {
|
|
64
|
+
transform: 'rotate(270deg)',
|
|
65
|
+
width: 20,
|
|
66
|
+
height: 20,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
inputActionsMinus: {
|
|
70
|
+
cursor: 'pointer',
|
|
71
|
+
background: '#FFFFFF',
|
|
72
|
+
height: '50%',
|
|
73
|
+
padding: 0,
|
|
74
|
+
width: 36,
|
|
75
|
+
border: 'none',
|
|
76
|
+
borderLeft: '1px solid #EEEEEE',
|
|
77
|
+
borderRadius: '0 0 5px 0',
|
|
78
|
+
color: '#568793',
|
|
79
|
+
['& svg']: {
|
|
80
|
+
transform: 'rotate(90deg)',
|
|
81
|
+
width: 20,
|
|
82
|
+
height: 20,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
}))
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Container, Label, Slider, SliderCircle, SliderBar } from './styles/progress_circle.styles'
|
|
3
|
+
import { ProgressCirclePropsType } from './progress_circle_types'
|
|
4
|
+
|
|
5
|
+
export const FxProgressCircle = ({ radius = 70, border = 70, value, hasLabel = true, max = 100, color, type = 'progress' }: ProgressCirclePropsType) => {
|
|
6
|
+
const _value = value ? value / max : 0
|
|
7
|
+
const p = 2 * Math.PI * (radius - border / 2)
|
|
8
|
+
|
|
9
|
+
const strokeWidth = border
|
|
10
|
+
const strokeDashoffset = p * (1 - _value)
|
|
11
|
+
const strokeDasharray = p
|
|
12
|
+
|
|
13
|
+
const label = type === 'progress' ? `${value}/${max}` : `${value.toFixed()}%`
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Container>
|
|
17
|
+
{hasLabel && type === 'progress' && <Label>{label}</Label>}
|
|
18
|
+
<Slider
|
|
19
|
+
// ref={(potar) => (potar = potar)}
|
|
20
|
+
viewBox={`0 0 ${radius * 2} ${radius * 2}`}
|
|
21
|
+
// onMouseDown={this.handleMouseDown}
|
|
22
|
+
>
|
|
23
|
+
<SliderCircle style={{ strokeWidth }} r={radius - border / 2} cx={radius} cy={radius} color={color} />
|
|
24
|
+
|
|
25
|
+
<SliderBar
|
|
26
|
+
style={{
|
|
27
|
+
strokeWidth,
|
|
28
|
+
strokeDashoffset,
|
|
29
|
+
strokeDasharray,
|
|
30
|
+
}}
|
|
31
|
+
r={radius - border / 2}
|
|
32
|
+
cx={radius}
|
|
33
|
+
cy={radius}
|
|
34
|
+
color={color}
|
|
35
|
+
/>
|
|
36
|
+
</Slider>
|
|
37
|
+
{hasLabel && type === 'percentage' && <Label sx={{ ml: 1 }}>{label}</Label>}
|
|
38
|
+
</Container>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { styled } from "@mui/material/styles";
|
|
2
|
+
|
|
3
|
+
export const Container = styled("div")(({ }) => ({
|
|
4
|
+
display: "flex",
|
|
5
|
+
alignItems: "center",
|
|
6
|
+
justifyContent: "center",
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
export const Label = styled("span")(({ theme }) => ({
|
|
10
|
+
...theme.typography.body1,
|
|
11
|
+
color: theme.palette.typography.title,
|
|
12
|
+
marginRight: 8,
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
export const Slider = styled("svg")(({ }) => ({
|
|
16
|
+
display: "block",
|
|
17
|
+
width: 22,
|
|
18
|
+
height: 22,
|
|
19
|
+
transform: "rotate(-90deg)",
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
export const SliderCircle = styled("circle")(({ theme, color }) => ({
|
|
23
|
+
fill: "transparent",
|
|
24
|
+
stroke: color ?? theme.palette.green2scale.main,
|
|
25
|
+
opacity: 0.1,
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
export const SliderBar = styled("circle")(({ theme, color }) => ({
|
|
29
|
+
fill: "transparent",
|
|
30
|
+
stroke: color ?? theme.palette.green2scale.main,
|
|
31
|
+
strokeDashoffset: 0,
|
|
32
|
+
strokeDasharray: 0,
|
|
33
|
+
}));
|