@lifi/widget 3.27.6 → 3.29.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/esm/components/ActiveTransactions/ActiveTransactionItem.js +1 -0
- package/dist/esm/components/ActiveTransactions/ActiveTransactionItem.js.map +1 -1
- package/dist/esm/components/Skeleton/WidgetSkeleton.js +2 -2
- package/dist/esm/components/Step/CircularProgress.js +2 -1
- package/dist/esm/components/Step/CircularProgress.js.map +1 -1
- package/dist/esm/components/Step/CircularProgress.style.js +7 -1
- package/dist/esm/components/Step/CircularProgress.style.js.map +1 -1
- package/dist/esm/components/Timer/StepTimer.js +2 -1
- package/dist/esm/components/Timer/StepTimer.js.map +1 -1
- package/dist/esm/components/Tools/ToolItem.d.ts +8 -0
- package/dist/esm/components/Tools/ToolItem.js +16 -0
- package/dist/esm/components/Tools/ToolItem.js.map +1 -0
- package/dist/esm/components/Tools/Tools.d.ts +8 -0
- package/dist/esm/components/Tools/Tools.js +32 -0
- package/dist/esm/components/Tools/Tools.js.map +1 -0
- package/dist/esm/config/version.d.ts +1 -1
- package/dist/esm/config/version.js +1 -1
- package/dist/esm/config/version.js.map +1 -1
- package/dist/esm/hooks/useProcessMessage.js +2 -5
- package/dist/esm/hooks/useProcessMessage.js.map +1 -1
- package/dist/esm/hooks/useRouteExecution.js +4 -2
- package/dist/esm/hooks/useRouteExecution.js.map +1 -1
- package/dist/esm/hooks/useTokens.js +2 -0
- package/dist/esm/hooks/useTokens.js.map +1 -1
- package/dist/esm/i18n/en.json +2 -4
- package/dist/esm/pages/SelectEnabledToolsPage.js +25 -35
- package/dist/esm/pages/SelectEnabledToolsPage.js.map +1 -1
- package/dist/esm/stores/routes/createRouteExecutionStore.js +0 -13
- package/dist/esm/stores/routes/createRouteExecutionStore.js.map +1 -1
- package/dist/esm/stores/routes/types.d.ts +0 -1
- package/dist/esm/stores/routes/types.js.map +1 -1
- package/dist/esm/themes/createTheme.js +10 -0
- package/dist/esm/themes/createTheme.js.map +1 -1
- package/dist/esm/themes/windows95.js +17 -1
- package/dist/esm/themes/windows95.js.map +1 -1
- package/dist/esm/types/widget.d.ts +1 -1
- package/dist/esm/types/widget.js.map +1 -1
- package/package.json +5 -5
- package/package.json.tmp +4 -4
- package/src/components/ActiveTransactions/ActiveTransactionItem.tsx +1 -0
- package/src/components/Skeleton/WidgetSkeleton.tsx +3 -3
- package/src/components/Step/CircularProgress.style.tsx +7 -3
- package/src/components/Step/CircularProgress.tsx +2 -1
- package/src/components/Timer/StepTimer.tsx +2 -1
- package/src/components/Tools/ToolItem.tsx +42 -0
- package/src/components/Tools/Tools.tsx +61 -0
- package/src/config/version.ts +1 -1
- package/src/hooks/useProcessMessage.ts +2 -5
- package/src/hooks/useRouteExecution.ts +4 -4
- package/src/hooks/useTokens.ts +2 -0
- package/src/i18n/en.json +2 -4
- package/src/pages/SelectEnabledToolsPage.tsx +75 -112
- package/src/stores/routes/createRouteExecutionStore.ts +0 -13
- package/src/stores/routes/types.ts +0 -1
- package/src/themes/createTheme.ts +10 -0
- package/src/themes/windows95.ts +17 -1
- package/src/types/widget.ts +1 -0
|
@@ -1,25 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import CheckBoxOutlineBlankOutlined from '@mui/icons-material/CheckBoxOutlineBlankOutlined'
|
|
4
|
-
import CheckBoxOutlined from '@mui/icons-material/CheckBoxOutlined'
|
|
5
|
-
import IndeterminateCheckBoxOutlined from '@mui/icons-material/IndeterminateCheckBoxOutlined'
|
|
1
|
+
import { Checkbox, debounce, Tooltip } from '@mui/material'
|
|
2
|
+
import type { ChangeEvent } from 'react'
|
|
6
3
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} from '@mui/material'
|
|
14
|
-
import type { MouseEventHandler } from 'react'
|
|
15
|
-
import { type FormEventHandler, useMemo, useState } from 'react'
|
|
4
|
+
type FormEventHandler,
|
|
5
|
+
memo,
|
|
6
|
+
useCallback,
|
|
7
|
+
useMemo,
|
|
8
|
+
useState,
|
|
9
|
+
} from 'react'
|
|
16
10
|
import { useTranslation } from 'react-i18next'
|
|
17
11
|
import { FullPageContainer } from '../components/FullPageContainer.js'
|
|
18
|
-
import { ListItemText } from '../components/ListItemText.js'
|
|
19
12
|
import { StickySearchInput } from '../components/Search/SearchInput.js'
|
|
20
|
-
import {
|
|
21
|
-
import { SearchNotFound } from '../components/Search/SearchNotFound.js'
|
|
22
|
-
import { SettingsListItemButton } from '../components/SettingsListItemButton.js'
|
|
13
|
+
import { type ToolCollectionTypes, Tools } from '../components/Tools/Tools.js'
|
|
23
14
|
import { useDefaultElementId } from '../hooks/useDefaultElementId.js'
|
|
24
15
|
import { useHeader } from '../hooks/useHeader.js'
|
|
25
16
|
import { useScrollableContainer } from '../hooks/useScrollableContainer.js'
|
|
@@ -29,63 +20,73 @@ import { useSettingsStore } from '../stores/settings/useSettingsStore.js'
|
|
|
29
20
|
|
|
30
21
|
interface SelectAllCheckboxProps {
|
|
31
22
|
allCheckboxesSelected: boolean
|
|
32
|
-
onClick:
|
|
23
|
+
onClick: (event: ChangeEvent<HTMLInputElement>, checked: boolean) => void
|
|
33
24
|
anyCheckboxesSelected: boolean
|
|
34
25
|
noCheckboxesAvailable: boolean
|
|
35
26
|
}
|
|
36
27
|
|
|
37
|
-
const SelectAllCheckbox
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<Tooltip title={tooltipTitle}>
|
|
53
|
-
<IconButton
|
|
54
|
-
size="medium"
|
|
55
|
-
edge={theme?.navigation?.edge ? 'end' : false}
|
|
56
|
-
onClick={onClick}
|
|
57
|
-
>
|
|
58
|
-
{allCheckboxesSelected ? (
|
|
59
|
-
<CheckBoxOutlined />
|
|
60
|
-
) : anyCheckboxesSelected ? (
|
|
61
|
-
<IndeterminateCheckBoxOutlined />
|
|
62
|
-
) : (
|
|
63
|
-
<CheckBoxOutlineBlankOutlined />
|
|
64
|
-
)}
|
|
65
|
-
</IconButton>
|
|
66
|
-
</Tooltip>
|
|
67
|
-
)
|
|
68
|
-
}
|
|
28
|
+
const SelectAllCheckbox = memo<SelectAllCheckboxProps>(
|
|
29
|
+
({
|
|
30
|
+
allCheckboxesSelected,
|
|
31
|
+
anyCheckboxesSelected,
|
|
32
|
+
noCheckboxesAvailable,
|
|
33
|
+
onClick,
|
|
34
|
+
}) => {
|
|
35
|
+
const { t } = useTranslation()
|
|
36
|
+
const tooltipTitle = noCheckboxesAvailable
|
|
37
|
+
? undefined
|
|
38
|
+
: allCheckboxesSelected
|
|
39
|
+
? t('tooltip.deselectAll')
|
|
40
|
+
: t('tooltip.selectAll')
|
|
69
41
|
|
|
70
|
-
|
|
42
|
+
return (
|
|
43
|
+
<Tooltip title={tooltipTitle}>
|
|
44
|
+
<Checkbox
|
|
45
|
+
id="select-all"
|
|
46
|
+
checked={allCheckboxesSelected}
|
|
47
|
+
indeterminate={anyCheckboxesSelected && !allCheckboxesSelected}
|
|
48
|
+
onChange={onClick}
|
|
49
|
+
disabled={noCheckboxesAvailable}
|
|
50
|
+
sx={{ mr: -1.5 }}
|
|
51
|
+
/>
|
|
52
|
+
</Tooltip>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
)
|
|
71
56
|
|
|
72
57
|
export const SelectEnabledToolsPage: React.FC<{
|
|
73
58
|
type: 'Bridges' | 'Exchanges'
|
|
74
59
|
}> = ({ type }) => {
|
|
75
60
|
const typeKey = type.toLowerCase() as 'bridges' | 'exchanges'
|
|
76
61
|
const { tools } = useTools()
|
|
77
|
-
const {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
state[`disabled${type}`],
|
|
81
|
-
])
|
|
62
|
+
const { toggleToolKeys } = useSettingsActions()
|
|
63
|
+
|
|
64
|
+
const disabledTools = useSettingsStore((state) => state[`disabled${type}`])
|
|
82
65
|
|
|
83
66
|
const { t } = useTranslation()
|
|
84
67
|
const elementId = useDefaultElementId()
|
|
85
68
|
const scrollableContainer = useScrollableContainer(elementId)
|
|
86
|
-
const [
|
|
87
|
-
|
|
88
|
-
)
|
|
69
|
+
const [searchValue, setSearchValue] = useState('')
|
|
70
|
+
|
|
71
|
+
const filteredTools = useMemo(() => {
|
|
72
|
+
const toolsList = tools?.[typeKey] ?? []
|
|
73
|
+
|
|
74
|
+
if (!searchValue) {
|
|
75
|
+
return toolsList
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const lowerSearchValue = searchValue.toLowerCase()
|
|
79
|
+
return toolsList.filter((tool) =>
|
|
80
|
+
tool.name.toLowerCase().includes(lowerSearchValue)
|
|
81
|
+
) as ToolCollectionTypes
|
|
82
|
+
}, [tools, typeKey, searchValue])
|
|
83
|
+
|
|
84
|
+
const handleSelectAll = useCallback(() => {
|
|
85
|
+
toggleToolKeys(
|
|
86
|
+
type,
|
|
87
|
+
filteredTools.map((tool) => tool.key)
|
|
88
|
+
)
|
|
89
|
+
}, [toggleToolKeys, type, filteredTools])
|
|
89
90
|
|
|
90
91
|
const headerAction = useMemo(
|
|
91
92
|
() => (
|
|
@@ -99,42 +100,26 @@ export const SelectEnabledToolsPage: React.FC<{
|
|
|
99
100
|
filteredTools.some((tool) => disabledTools.includes(tool.key))
|
|
100
101
|
}
|
|
101
102
|
noCheckboxesAvailable={!filteredTools.length}
|
|
102
|
-
onClick={
|
|
103
|
-
toggleToolKeys(
|
|
104
|
-
type,
|
|
105
|
-
filteredTools.map((tool) => tool.key)
|
|
106
|
-
)
|
|
107
|
-
}
|
|
103
|
+
onClick={handleSelectAll}
|
|
108
104
|
/>
|
|
109
105
|
),
|
|
110
|
-
[disabledTools,
|
|
106
|
+
[disabledTools, handleSelectAll, filteredTools]
|
|
111
107
|
)
|
|
112
108
|
|
|
113
109
|
useHeader(t(`settings.enabled${type}`), headerAction)
|
|
114
110
|
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
111
|
+
const handleSearchInputChange: FormEventHandler<HTMLInputElement> =
|
|
112
|
+
useCallback(
|
|
113
|
+
(e) => {
|
|
114
|
+
const value = (e.target as HTMLInputElement).value
|
|
115
|
+
setSearchValue(value)
|
|
118
116
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
setFilteredTools(
|
|
126
|
-
(tools?.[typeKey]
|
|
127
|
-
? tools[typeKey].filter((tool) =>
|
|
128
|
-
tool.name.toLowerCase().includes(value.toLowerCase())
|
|
129
|
-
)
|
|
130
|
-
: []) as ToolCollectionTypes
|
|
131
|
-
)
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (scrollableContainer) {
|
|
135
|
-
scrollableContainer.scrollTop = 0
|
|
136
|
-
}
|
|
137
|
-
}
|
|
117
|
+
if (scrollableContainer) {
|
|
118
|
+
scrollableContainer.scrollTop = 0
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
[scrollableContainer]
|
|
122
|
+
)
|
|
138
123
|
|
|
139
124
|
const debouncedSearchInputChange = debounce(handleSearchInputChange, 250)
|
|
140
125
|
|
|
@@ -144,29 +129,7 @@ export const SelectEnabledToolsPage: React.FC<{
|
|
|
144
129
|
onChange={debouncedSearchInputChange}
|
|
145
130
|
placeholder={t(`main.search${type}`)}
|
|
146
131
|
/>
|
|
147
|
-
{filteredTools
|
|
148
|
-
<SearchList className="long-list" data-testid={`${typeKey}-list`}>
|
|
149
|
-
{filteredTools.map((tool) => (
|
|
150
|
-
<SettingsListItemButton
|
|
151
|
-
key={tool.name}
|
|
152
|
-
onClick={() => handleClick(tool.key)}
|
|
153
|
-
>
|
|
154
|
-
<ListItemAvatar>
|
|
155
|
-
<Avatar src={tool.logoURI} alt={tool.name}>
|
|
156
|
-
{tool.name[0]}
|
|
157
|
-
</Avatar>
|
|
158
|
-
</ListItemAvatar>
|
|
159
|
-
<ListItemText primary={tool.name} />
|
|
160
|
-
{enabledTools[tool.key] && <Check color="primary" />}
|
|
161
|
-
</SettingsListItemButton>
|
|
162
|
-
))}
|
|
163
|
-
</SearchList>
|
|
164
|
-
) : (
|
|
165
|
-
<SearchNotFound
|
|
166
|
-
message={t(`info.message.empty${type}List`)}
|
|
167
|
-
adjustForStickySearchInput
|
|
168
|
-
/>
|
|
169
|
-
)}
|
|
132
|
+
<Tools filteredTools={filteredTools} type={type} />
|
|
170
133
|
</FullPageContainer>
|
|
171
134
|
)
|
|
172
135
|
}
|
|
@@ -86,19 +86,6 @@ export const createRouteExecutionStore = ({ namePrefix }: PersistStoreProps) =>
|
|
|
86
86
|
})
|
|
87
87
|
}
|
|
88
88
|
},
|
|
89
|
-
restartRoute: (routeId: string) => {
|
|
90
|
-
if (get().routes[routeId]) {
|
|
91
|
-
set((state: RouteExecutionState) => ({
|
|
92
|
-
routes: {
|
|
93
|
-
...state.routes,
|
|
94
|
-
[routeId]: {
|
|
95
|
-
...state.routes[routeId]!,
|
|
96
|
-
status: RouteExecutionStatus.Pending,
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
}))
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
89
|
deleteRoute: (routeId: string) => {
|
|
103
90
|
if (get().routes[routeId]) {
|
|
104
91
|
set((state: RouteExecutionState) => {
|
|
@@ -9,7 +9,6 @@ export interface RouteExecutionState {
|
|
|
9
9
|
routes: Partial<Record<string, RouteExecution>>
|
|
10
10
|
setExecutableRoute: (route: Route, observableRouteIds?: string[]) => void
|
|
11
11
|
updateRoute: (route: Route) => void
|
|
12
|
-
restartRoute: (routeId: string) => void
|
|
13
12
|
deleteRoute: (routeId: string) => void
|
|
14
13
|
deleteRoutes: (type: 'completed' | 'active') => void
|
|
15
14
|
}
|
|
@@ -475,6 +475,16 @@ export const createTheme = (widgetTheme: WidgetTheme = {}) => {
|
|
|
475
475
|
MuiNavigationTab: {
|
|
476
476
|
...widgetTheme.components?.MuiNavigationTab,
|
|
477
477
|
},
|
|
478
|
+
MuiCheckbox: {
|
|
479
|
+
styleOverrides: {
|
|
480
|
+
root: {
|
|
481
|
+
'&:hover': {
|
|
482
|
+
backgroundColor: 'transparent',
|
|
483
|
+
},
|
|
484
|
+
},
|
|
485
|
+
},
|
|
486
|
+
...widgetTheme.components?.MuiCheckbox,
|
|
487
|
+
},
|
|
478
488
|
},
|
|
479
489
|
})
|
|
480
490
|
|
package/src/themes/windows95.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { tabsClasses } from '@mui/material'
|
|
1
|
+
import { checkboxClasses, tabsClasses } from '@mui/material'
|
|
2
2
|
import type { WidgetTheme } from '../types/widget.js'
|
|
3
3
|
|
|
4
4
|
export const windows95Theme: WidgetTheme = {
|
|
@@ -113,5 +113,21 @@ export const windows95Theme: WidgetTheme = {
|
|
|
113
113
|
},
|
|
114
114
|
},
|
|
115
115
|
},
|
|
116
|
+
MuiCheckbox: {
|
|
117
|
+
styleOverrides: {
|
|
118
|
+
root: {
|
|
119
|
+
color: '#0a0a0a',
|
|
120
|
+
'&:hover': {
|
|
121
|
+
backgroundColor: 'transparent',
|
|
122
|
+
},
|
|
123
|
+
[`&.${checkboxClasses.checked}`]: {
|
|
124
|
+
color: '#0a0a0a',
|
|
125
|
+
},
|
|
126
|
+
[`&.${checkboxClasses.indeterminate}`]: {
|
|
127
|
+
color: '#0a0a0a',
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
116
132
|
},
|
|
117
133
|
}
|