@chem-po/react-web 0.0.51 → 0.0.53
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/package.json +4 -5
- package/src/components/auth/SignIn.tsx +0 -43
- package/src/components/auth/index.ts +0 -1
- package/src/components/box/CollapseHorizontal.tsx +0 -19
- package/src/components/box/ContentBox.tsx +0 -17
- package/src/components/box/ExpandOnMount.tsx +0 -48
- package/src/components/box/Expandable.tsx +0 -96
- package/src/components/box/FullSizeContainer.tsx +0 -50
- package/src/components/box/MobileFrame/index.tsx +0 -146
- package/src/components/box/MobileFrame/styles.css +0 -35
- package/src/components/box/index.ts +0 -6
- package/src/components/button/DeleteButton.tsx +0 -178
- package/src/components/button/Toggle.tsx +0 -88
- package/src/components/button/ViewButton.tsx +0 -30
- package/src/components/button/index.ts +0 -3
- package/src/components/feed/FeedContentPane.tsx +0 -111
- package/src/components/feed/MediaFeed.tsx +0 -200
- package/src/components/feed/MediaFeedBackground.tsx +0 -127
- package/src/components/feed/MediaFeedRefresh.tsx +0 -78
- package/src/components/feed/MediaFeedSwipeUp.tsx +0 -35
- package/src/components/feed/constants.ts +0 -11
- package/src/components/feed/context.tsx +0 -19
- package/src/components/feed/hooks.ts +0 -290
- package/src/components/feed/index.ts +0 -2
- package/src/components/feed/types.ts +0 -50
- package/src/components/form/Condition.tsx +0 -26
- package/src/components/form/Field.tsx +0 -39
- package/src/components/form/Form.tsx +0 -428
- package/src/components/form/FormFooter.tsx +0 -90
- package/src/components/form/UploadProgress/index.tsx +0 -38
- package/src/components/form/UploadProgress/styles.css +0 -23
- package/src/components/form/index.ts +0 -4
- package/src/components/form/input/Editable.tsx +0 -155
- package/src/components/form/input/InputSlider.tsx +0 -76
- package/src/components/form/input/OptionalTag.tsx +0 -33
- package/src/components/form/input/StandaloneInput.tsx +0 -41
- package/src/components/form/input/boolean/index.tsx +0 -53
- package/src/components/form/input/color/index.tsx +0 -126
- package/src/components/form/input/date/index.tsx +0 -122
- package/src/components/form/input/datetime/index.tsx +0 -93
- package/src/components/form/input/file.tsx +0 -379
- package/src/components/form/input/hooks/index.ts +0 -2
- package/src/components/form/input/hooks/useInputImperativeHandle.ts +0 -16
- package/src/components/form/input/hooks/useInputStyles.ts +0 -125
- package/src/components/form/input/index.ts +0 -2
- package/src/components/form/input/input.css +0 -44
- package/src/components/form/input/input.tsx +0 -134
- package/src/components/form/input/multipleSelect/index.tsx +0 -89
- package/src/components/form/input/number/index.tsx +0 -87
- package/src/components/form/input/number/styles.css +0 -8
- package/src/components/form/input/select/index.tsx +0 -109
- package/src/components/form/input/shared/InputContainer.tsx +0 -13
- package/src/components/form/input/socialMedia/index.tsx +0 -165
- package/src/components/form/input/text/index.tsx +0 -78
- package/src/components/form/input/text/textarea.tsx +0 -43
- package/src/components/form/input/time/index.tsx +0 -33
- package/src/components/form/input/type.ts +0 -0
- package/src/components/form/input/types.ts +0 -4
- package/src/components/form/view/file.tsx +0 -36
- package/src/components/form/view/index.tsx +0 -52
- package/src/components/form/view/multipleSelect.tsx +0 -51
- package/src/components/form/view/select.tsx +0 -50
- package/src/components/form/view/types.ts +0 -11
- package/src/components/index.ts +0 -14
- package/src/components/list/Body/InfiniteScrollGridBody.tsx +0 -177
- package/src/components/list/Body/InfiniteScrollListBody.tsx +0 -114
- package/src/components/list/Body/ListBody.tsx +0 -24
- package/src/components/list/Body/PagedGridBody.tsx +0 -104
- package/src/components/list/Body/PagedListBody.tsx +0 -92
- package/src/components/list/Body/hooks.ts +0 -84
- package/src/components/list/DataList.tsx +0 -33
- package/src/components/list/ListContainer.tsx +0 -21
- package/src/components/list/ListContent.tsx +0 -54
- package/src/components/list/ListCreate.tsx +0 -57
- package/src/components/list/ListFilters.tsx +0 -182
- package/src/components/list/ListFooter.tsx +0 -458
- package/src/components/list/ListHeader.tsx +0 -180
- package/src/components/list/ListItem/ListCell.tsx +0 -49
- package/src/components/list/ListItem/ListRow.tsx +0 -44
- package/src/components/list/ListItemView.tsx +0 -53
- package/src/components/list/ListSort.tsx +0 -84
- package/src/components/list/NoItems.tsx +0 -33
- package/src/components/list/constants.ts +0 -1
- package/src/components/list/index.ts +0 -4
- package/src/components/list/types.ts +0 -26
- package/src/components/list/utils.ts +0 -63
- package/src/components/loading/CircularProgress.tsx +0 -12
- package/src/components/loading/Loading.tsx +0 -160
- package/src/components/loading/LoadingImage.tsx +0 -128
- package/src/components/loading/LoadingSwitch.tsx +0 -78
- package/src/components/loading/index.ts +0 -4
- package/src/components/media/PlayButton.tsx +0 -95
- package/src/components/media/index.ts +0 -1
- package/src/components/modal/DefaultModal.tsx +0 -18
- package/src/components/modal/DesktopModal.tsx +0 -16
- package/src/components/modal/ForceMobile.tsx +0 -7
- package/src/components/modal/MobileModal.tsx +0 -89
- package/src/components/modal/index.ts +0 -3
- package/src/components/modal/type.ts +0 -7
- package/src/components/nav/NavBar.tsx +0 -102
- package/src/components/nav/index.ts +0 -1
- package/src/components/overlay/ImageViewOverlay.tsx +0 -88
- package/src/components/overlay/MobileOverlay.tsx +0 -23
- package/src/components/overlay/index.ts +0 -2
- package/src/components/text/GradientText/index.tsx +0 -17
- package/src/components/text/GradientText/styles.css +0 -5
- package/src/components/text/NumberTicker.tsx +0 -28
- package/src/components/text/index.ts +0 -1
- package/src/components/theme/colorMode/DarkModeToggle.tsx +0 -40
- package/src/components/theme/colorMode/index.ts +0 -1
- package/src/components/theme/index.ts +0 -1
- package/src/components/view/ErrorView.tsx +0 -14
- package/src/components/view/RedirectView.tsx +0 -43
- package/src/components/view/index.ts +0 -2
- package/src/contexts/index.ts +0 -2
- package/src/contexts/theme.ts +0 -316
- package/src/contexts/view.tsx +0 -26
- package/src/custom.d.ts +0 -4
- package/src/hooks/index.ts +0 -1
- package/src/hooks/ui/index.ts +0 -1
- package/src/hooks/ui/useBorderColor.ts +0 -4
- package/src/index.ts +0 -5
- package/src/store/index.ts +0 -1
- package/src/store/usePlayer.ts +0 -75
- package/src/store/useScreen.ts +0 -22
- package/src/types/forms.ts +0 -5
- package/src/types/index.ts +0 -1
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { AnyObject } from '@chem-po/core'
|
|
2
|
-
import { DataList, ListGridOptions, usePaginatedList } from '@chem-po/react'
|
|
3
|
-
import { useMemo } from 'react'
|
|
4
|
-
|
|
5
|
-
// determine number of columns and rows based on data and grid options
|
|
6
|
-
// if row height and column width are both variable, throw an error
|
|
7
|
-
// if row height is variable, calculate dims based on data
|
|
8
|
-
// if column width is variable, calculate dims based on data
|
|
9
|
-
interface CellDims {
|
|
10
|
-
numRows: number
|
|
11
|
-
numCols: number
|
|
12
|
-
}
|
|
13
|
-
const getCellDims = <T extends AnyObject>(
|
|
14
|
-
data: T[],
|
|
15
|
-
grid: Required<DataList<T>>['grid'],
|
|
16
|
-
gridWidth: number,
|
|
17
|
-
): CellDims => {
|
|
18
|
-
const { rowHeight, columnWidth } = grid
|
|
19
|
-
if (typeof rowHeight !== 'number' && typeof columnWidth !== 'number') {
|
|
20
|
-
throw new Error('Cannot have both variable row height and variable column width')
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (typeof columnWidth === 'function') {
|
|
24
|
-
const numCols = Math.floor(gridWidth / columnWidth(data[0]))
|
|
25
|
-
const numRows = Math.ceil(data.length / numCols)
|
|
26
|
-
return { numRows, numCols }
|
|
27
|
-
}
|
|
28
|
-
const numCols = Math.max(1, Math.floor(gridWidth / columnWidth))
|
|
29
|
-
const numRows = Math.ceil(data.length / numCols)
|
|
30
|
-
return { numRows, numCols }
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
type CellSize = CellDims & {
|
|
34
|
-
rowHeight: number | ((idx: number) => number)
|
|
35
|
-
colWidth: number | ((idx: number) => number)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const getCellSize = <T extends AnyObject>(
|
|
39
|
-
data: T[],
|
|
40
|
-
grid: Required<DataList<T>>['grid'],
|
|
41
|
-
gridWidth: number,
|
|
42
|
-
): CellSize => {
|
|
43
|
-
const { rowHeight: preferredHeight, columnWidth: preferredWidth } = grid
|
|
44
|
-
const { numRows, numCols } = getCellDims(data, grid, gridWidth)
|
|
45
|
-
|
|
46
|
-
const colWidths =
|
|
47
|
-
typeof preferredWidth === 'number'
|
|
48
|
-
? gridWidth / numCols
|
|
49
|
-
: Array.from({ length: numCols }, (_i, i) => {
|
|
50
|
-
const col = data.filter((_j, j) => j % numCols === i)
|
|
51
|
-
return col.reduce((acc, item) => {
|
|
52
|
-
const itemWidth = preferredWidth(item)
|
|
53
|
-
return Math.max(acc, itemWidth)
|
|
54
|
-
}, 0)
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
const rowHeights =
|
|
58
|
-
typeof preferredHeight === 'number'
|
|
59
|
-
? preferredHeight
|
|
60
|
-
: Array.from({ length: numRows }, (_, i) => {
|
|
61
|
-
const row = data.slice(i * numCols, (i + 1) * numCols)
|
|
62
|
-
return row.reduce((acc, item) => {
|
|
63
|
-
const itemHeight = preferredHeight(item)
|
|
64
|
-
return Math.max(acc, itemHeight)
|
|
65
|
-
}, 0)
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
const rowHeight = Array.isArray(rowHeights) ? (idx: number) => rowHeights[idx] : rowHeights
|
|
69
|
-
const colWidth = Array.isArray(colWidths) ? (idx: number) => colWidths[idx] : colWidths
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
rowHeight,
|
|
73
|
-
colWidth,
|
|
74
|
-
numCols,
|
|
75
|
-
numRows,
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export const useGridDims = <T extends AnyObject>(grid: ListGridOptions<T>, width: number) => {
|
|
80
|
-
const {
|
|
81
|
-
data: { data },
|
|
82
|
-
} = usePaginatedList<T>()
|
|
83
|
-
return useMemo(() => getCellSize(data, grid, width), [data, grid, width])
|
|
84
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { AnyObject } from '@chem-po/core'
|
|
2
|
-
import {
|
|
3
|
-
PaginatedListProvider,
|
|
4
|
-
useBackendBase,
|
|
5
|
-
useDataListData,
|
|
6
|
-
usePaginatedQuery,
|
|
7
|
-
} from '@chem-po/react'
|
|
8
|
-
import React from 'react'
|
|
9
|
-
import { ListContainer } from './ListContainer'
|
|
10
|
-
import { ListContent } from './ListContent'
|
|
11
|
-
import { ListViewProps } from './types'
|
|
12
|
-
|
|
13
|
-
export const DataList = <T extends AnyObject>({
|
|
14
|
-
list,
|
|
15
|
-
// basePath,
|
|
16
|
-
flexProps,
|
|
17
|
-
infiniteScroll,
|
|
18
|
-
...rest
|
|
19
|
-
}: ListViewProps<T>) => {
|
|
20
|
-
const {
|
|
21
|
-
adapter: { db },
|
|
22
|
-
} = useBackendBase()
|
|
23
|
-
const { baseQuery } = list
|
|
24
|
-
const state = useDataListData(list, infiniteScroll)
|
|
25
|
-
const data = usePaginatedQuery<T>(db, baseQuery, !!infiniteScroll)
|
|
26
|
-
return (
|
|
27
|
-
<PaginatedListProvider<T> state={state} data={data}>
|
|
28
|
-
<ListContainer {...flexProps}>
|
|
29
|
-
<ListContent {...rest} />
|
|
30
|
-
</ListContainer>
|
|
31
|
-
</PaginatedListProvider>
|
|
32
|
-
)
|
|
33
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Flex, FlexProps } from '@chakra-ui/react'
|
|
2
|
-
import { useMounted } from '@chem-po/react'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
import { FullSizeProvider } from '../box'
|
|
5
|
-
|
|
6
|
-
export const ListContainer = (props: FlexProps) => {
|
|
7
|
-
const mounted = useMounted()
|
|
8
|
-
return (
|
|
9
|
-
<FullSizeProvider>
|
|
10
|
-
<Flex
|
|
11
|
-
overflow="hidden"
|
|
12
|
-
flexFlow="column"
|
|
13
|
-
h="100%"
|
|
14
|
-
w="100%"
|
|
15
|
-
opacity={mounted ? 1 : 0}
|
|
16
|
-
transition="opacity 300ms"
|
|
17
|
-
{...props}
|
|
18
|
-
/>
|
|
19
|
-
</FullSizeProvider>
|
|
20
|
-
)
|
|
21
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Box } from '@chakra-ui/react'
|
|
2
|
-
import { AnyObject } from '@chem-po/core'
|
|
3
|
-
import { useDataList, useFullSize, usePaginatedList } from '@chem-po/react'
|
|
4
|
-
import React, { useCallback, useMemo, useState } from 'react'
|
|
5
|
-
import { LoadingOverlay } from '../loading'
|
|
6
|
-
import { ListBody } from './Body/ListBody'
|
|
7
|
-
import { ListCreate } from './ListCreate'
|
|
8
|
-
import { ListFooter } from './ListFooter'
|
|
9
|
-
import { DataListHeader } from './ListHeader'
|
|
10
|
-
import { ListItemView } from './ListItemView'
|
|
11
|
-
import { ListContentProps } from './types'
|
|
12
|
-
|
|
13
|
-
export const ListContent = <T extends AnyObject>({
|
|
14
|
-
modals,
|
|
15
|
-
noFooter,
|
|
16
|
-
headerProps,
|
|
17
|
-
footerProps,
|
|
18
|
-
}: ListContentProps<T>) => {
|
|
19
|
-
const {
|
|
20
|
-
data: { isLoading, data },
|
|
21
|
-
} = usePaginatedList()
|
|
22
|
-
const { list } = useDataList<T>()
|
|
23
|
-
const { height } = useFullSize()
|
|
24
|
-
|
|
25
|
-
const [headerHeight, setHeaderHeight] = useState(0)
|
|
26
|
-
const [footerHeight, setFooterHeight] = useState(0)
|
|
27
|
-
const bodyHeight = useMemo(
|
|
28
|
-
() => height - headerHeight - footerHeight,
|
|
29
|
-
[height, headerHeight, footerHeight],
|
|
30
|
-
)
|
|
31
|
-
const handleHeaderResize = useCallback((updated: { height: number; width: number }) => {
|
|
32
|
-
setHeaderHeight(updated.height)
|
|
33
|
-
}, [])
|
|
34
|
-
|
|
35
|
-
const handleFooterResize = useCallback((size: { width: number; height: number }) => {
|
|
36
|
-
setFooterHeight(size.height)
|
|
37
|
-
}, [])
|
|
38
|
-
|
|
39
|
-
const { ItemView: ItemViewComponent, field: createField } = list
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<>
|
|
43
|
-
<DataListHeader boxProps={headerProps} onResize={handleHeaderResize} />
|
|
44
|
-
<Box h={`${bodyHeight}px`} position="relative" w="100%">
|
|
45
|
-
<ListBody height={bodyHeight} />
|
|
46
|
-
{noFooter ? <LoadingOverlay isLoading={!data.length && isLoading} /> : null}
|
|
47
|
-
</Box>
|
|
48
|
-
<ListFooter noFooter={noFooter} flexProps={footerProps} onResize={handleFooterResize} />
|
|
49
|
-
{modals ?? null}
|
|
50
|
-
{ItemViewComponent ? <ListItemView /> : null}
|
|
51
|
-
{createField ? <ListCreate field={createField} /> : null}
|
|
52
|
-
</>
|
|
53
|
-
)
|
|
54
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { CloseIcon } from '@chakra-ui/icons'
|
|
2
|
-
import { Flex, IconButton, Text } from '@chakra-ui/react'
|
|
3
|
-
import { FieldMap, useBackendBase, useDataList, usePaginatedList } from '@chem-po/react'
|
|
4
|
-
import React, { useCallback } from 'react'
|
|
5
|
-
import { Form } from '../form'
|
|
6
|
-
import { DesktopModal } from '../modal'
|
|
7
|
-
|
|
8
|
-
export const ListCreate = ({ field }: { field: FieldMap }) => {
|
|
9
|
-
const {
|
|
10
|
-
list: { baseQuery, itemName },
|
|
11
|
-
newItemOpen: isOpen,
|
|
12
|
-
setNewItemOpen: setIsOpen,
|
|
13
|
-
} = useDataList()
|
|
14
|
-
const {
|
|
15
|
-
adapter: { db },
|
|
16
|
-
} = useBackendBase()
|
|
17
|
-
const { refetch } = usePaginatedList()
|
|
18
|
-
// const collectionRef = useMemo(() => collection(db, collectionPath), [collectionPath, db])
|
|
19
|
-
// const newItemDoc = useMemo(() => (isOpen ? doc(collectionRef) : null), [collectionRef, isOpen])
|
|
20
|
-
// const newItemStoragePath = useMemo(
|
|
21
|
-
// () => (newItemDoc ? `${storagePath}/${newItemDoc.id}` : null),
|
|
22
|
-
// [storagePath, newItemDoc],
|
|
23
|
-
// )
|
|
24
|
-
const handleSubmit = useCallback(
|
|
25
|
-
async (data: object) => {
|
|
26
|
-
// if (!newItemDoc) return { [FORM_ERROR]: 'No document reference' }
|
|
27
|
-
// await setDoc(newItemDoc, data)
|
|
28
|
-
await db.createItem(baseQuery.collection, data)
|
|
29
|
-
setIsOpen(false)
|
|
30
|
-
if (refetch) refetch()
|
|
31
|
-
return undefined
|
|
32
|
-
},
|
|
33
|
-
[setIsOpen, refetch, db, baseQuery],
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<DesktopModal isOpen={isOpen} onClose={() => setIsOpen(false)}>
|
|
38
|
-
<Flex align="center" pt={3} px={3} w="100%">
|
|
39
|
-
<Text pl={1} opacity={0.7} fontWeight={600}>
|
|
40
|
-
NEW {itemName.toUpperCase()}
|
|
41
|
-
</Text>
|
|
42
|
-
<IconButton
|
|
43
|
-
size="sm"
|
|
44
|
-
borderRadius="full"
|
|
45
|
-
ml="auto"
|
|
46
|
-
h={7}
|
|
47
|
-
w={7}
|
|
48
|
-
minW={0}
|
|
49
|
-
onClick={() => setIsOpen(false)}
|
|
50
|
-
aria-label="Close"
|
|
51
|
-
icon={<CloseIcon opacity={0.8} w={3} h={3} />}
|
|
52
|
-
/>
|
|
53
|
-
</Flex>
|
|
54
|
-
<Form field={field} onSubmit={handleSubmit} />
|
|
55
|
-
</DesktopModal>
|
|
56
|
-
)
|
|
57
|
-
}
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Box,
|
|
3
|
-
Button,
|
|
4
|
-
Flex,
|
|
5
|
-
HStack,
|
|
6
|
-
IconButton,
|
|
7
|
-
Image,
|
|
8
|
-
Popover,
|
|
9
|
-
PopoverArrow,
|
|
10
|
-
PopoverBody,
|
|
11
|
-
PopoverCloseButton,
|
|
12
|
-
PopoverContent,
|
|
13
|
-
PopoverTrigger,
|
|
14
|
-
Portal,
|
|
15
|
-
Text,
|
|
16
|
-
useColorMode,
|
|
17
|
-
useColorModeValue,
|
|
18
|
-
} from '@chakra-ui/react'
|
|
19
|
-
|
|
20
|
-
import { AnyObject, isFilterGroup, QueryFilter } from '@chem-po/core'
|
|
21
|
-
import { FilterPreset, FilterPresetGroup, useDataList, useScreen } from '@chem-po/react'
|
|
22
|
-
import React, { useMemo } from 'react'
|
|
23
|
-
import { useBorderColor } from '../../hooks'
|
|
24
|
-
import { filterMatchesPreset } from './utils'
|
|
25
|
-
|
|
26
|
-
const FilterButton = <T extends AnyObject>({
|
|
27
|
-
filter,
|
|
28
|
-
filters,
|
|
29
|
-
GroupRender,
|
|
30
|
-
toggleFilter,
|
|
31
|
-
}: {
|
|
32
|
-
filter: FilterPreset<T>
|
|
33
|
-
filters: QueryFilter<T>[]
|
|
34
|
-
GroupRender?: FilterPresetGroup<T>['RenderFilter']
|
|
35
|
-
toggleFilter: (toggled: FilterPreset<T>) => void
|
|
36
|
-
}) => {
|
|
37
|
-
const { label, Render } = filter
|
|
38
|
-
const isActive = useMemo(
|
|
39
|
-
() => filters.some(f => filterMatchesPreset(f, filter)),
|
|
40
|
-
[filters, filter],
|
|
41
|
-
)
|
|
42
|
-
const { colorMode } = useColorMode()
|
|
43
|
-
const borderColor = useBorderColor()
|
|
44
|
-
const textColor = useColorModeValue('gray.700', 'gray.100')
|
|
45
|
-
const CustomRender = Render ?? GroupRender
|
|
46
|
-
return (
|
|
47
|
-
<Box p={0.5}>
|
|
48
|
-
<Button
|
|
49
|
-
onClick={() => toggleFilter(filter)}
|
|
50
|
-
variant="unstyled"
|
|
51
|
-
color={isActive && !CustomRender ? 'white' : textColor}
|
|
52
|
-
bg={isActive && !CustomRender ? 'accent.400' : 'transparent'}
|
|
53
|
-
px={CustomRender ? 0 : 2}
|
|
54
|
-
py={CustomRender ? 0 : 1}
|
|
55
|
-
transition="all 300ms"
|
|
56
|
-
border="none"
|
|
57
|
-
boxShadow={`0px 0px 1px 1px ${isActive ? 'transparent' : '#00000033'}`}
|
|
58
|
-
w="auto"
|
|
59
|
-
_dark={{
|
|
60
|
-
boxShadow: `0px 0px 1px 1px ${isActive ? 'transparent' : '#ffffff66'}`,
|
|
61
|
-
}}
|
|
62
|
-
h="auto"
|
|
63
|
-
minW="0"
|
|
64
|
-
minH="0"
|
|
65
|
-
alignItems="center"
|
|
66
|
-
justifyContent="center"
|
|
67
|
-
borderColor={isActive ? 'transparent' : borderColor}
|
|
68
|
-
size="none">
|
|
69
|
-
{CustomRender ? (
|
|
70
|
-
<CustomRender active={isActive} colorMode={colorMode} preset={filter} />
|
|
71
|
-
) : (
|
|
72
|
-
<Text textShadow={isActive ? '0 0 3px rgba(0,0,0,0.8)' : 'none'} fontSize="xs">
|
|
73
|
-
{label}
|
|
74
|
-
</Text>
|
|
75
|
-
)}
|
|
76
|
-
</Button>
|
|
77
|
-
</Box>
|
|
78
|
-
)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const FilterGroup = <T extends AnyObject>({
|
|
82
|
-
group,
|
|
83
|
-
filters,
|
|
84
|
-
toggleFilter,
|
|
85
|
-
}: {
|
|
86
|
-
group: FilterPresetGroup<T>
|
|
87
|
-
filters: QueryFilter<T>[]
|
|
88
|
-
toggleFilter: (toggled: FilterPreset<T>) => void
|
|
89
|
-
}) => {
|
|
90
|
-
const { label, filters: groupFilters } = group
|
|
91
|
-
return (
|
|
92
|
-
<Flex px={1} flexFlow="column" w="100%">
|
|
93
|
-
<Text px={1} opacity={0.8} fontSize="sm" fontWeight={600}>
|
|
94
|
-
{label}
|
|
95
|
-
</Text>
|
|
96
|
-
<Flex w="100%" flexFlow="row wrap">
|
|
97
|
-
{groupFilters.map(filter => (
|
|
98
|
-
<FilterButton
|
|
99
|
-
toggleFilter={toggleFilter}
|
|
100
|
-
GroupRender={group.RenderFilter}
|
|
101
|
-
filters={filters}
|
|
102
|
-
key={filter.label}
|
|
103
|
-
filter={filter}
|
|
104
|
-
/>
|
|
105
|
-
))}
|
|
106
|
-
</Flex>
|
|
107
|
-
</Flex>
|
|
108
|
-
)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export const PresetFilters = () => {
|
|
112
|
-
const { query, list, toggleFilter } = useDataList()
|
|
113
|
-
const isMobile = useScreen(s => s.isMobile)
|
|
114
|
-
const { filters: currentFilters = [] } = query || {}
|
|
115
|
-
const { filterPresets } = list
|
|
116
|
-
const borderColor = useBorderColor()
|
|
117
|
-
return filterPresets?.length ? (
|
|
118
|
-
<HStack spacing={1}>
|
|
119
|
-
<Popover
|
|
120
|
-
// closeOnBlur={false}
|
|
121
|
-
placement="right-start"
|
|
122
|
-
trigger={isMobile ? 'click' : 'hover'}
|
|
123
|
-
// trigger=
|
|
124
|
-
strategy="fixed">
|
|
125
|
-
<PopoverTrigger>
|
|
126
|
-
<IconButton
|
|
127
|
-
size="sm"
|
|
128
|
-
variant="ghost"
|
|
129
|
-
aria-label="Filters"
|
|
130
|
-
icon={
|
|
131
|
-
<Image
|
|
132
|
-
width="24px"
|
|
133
|
-
filter={`grayscale(${currentFilters.length ? 0 : 100}%)`}
|
|
134
|
-
src="/icons/tune.svg"
|
|
135
|
-
/>
|
|
136
|
-
}
|
|
137
|
-
/>
|
|
138
|
-
</PopoverTrigger>
|
|
139
|
-
<Portal>
|
|
140
|
-
<PopoverContent borderRadius={6} w="auto">
|
|
141
|
-
<PopoverBody w="240px" p={0}>
|
|
142
|
-
<Flex flexFlow="column" w="100%">
|
|
143
|
-
<HStack
|
|
144
|
-
py={1.5}
|
|
145
|
-
px={2}
|
|
146
|
-
w="100%"
|
|
147
|
-
spacing={1}
|
|
148
|
-
borderBottom={`1px solid ${borderColor}`}>
|
|
149
|
-
<Image width="18px" filter="grayscale(100%)" src="/icons/tune.svg" />
|
|
150
|
-
<Text opacity={0.8} fontSize="sm" fontWeight={600}>
|
|
151
|
-
FILTERS
|
|
152
|
-
</Text>
|
|
153
|
-
</HStack>
|
|
154
|
-
<Flex justify="center" w="100%" flexFlow="row wrap" py={1} px={2}>
|
|
155
|
-
{filterPresets.map(filter =>
|
|
156
|
-
isFilterGroup(filter) ? (
|
|
157
|
-
<FilterGroup
|
|
158
|
-
toggleFilter={toggleFilter}
|
|
159
|
-
filters={currentFilters}
|
|
160
|
-
key={filter.label}
|
|
161
|
-
group={filter}
|
|
162
|
-
/>
|
|
163
|
-
) : (
|
|
164
|
-
<FilterButton
|
|
165
|
-
toggleFilter={toggleFilter}
|
|
166
|
-
filters={currentFilters}
|
|
167
|
-
key={filter.label}
|
|
168
|
-
filter={filter}
|
|
169
|
-
/>
|
|
170
|
-
),
|
|
171
|
-
)}
|
|
172
|
-
</Flex>
|
|
173
|
-
</Flex>
|
|
174
|
-
</PopoverBody>
|
|
175
|
-
<PopoverArrow />
|
|
176
|
-
<PopoverCloseButton />
|
|
177
|
-
</PopoverContent>
|
|
178
|
-
</Portal>
|
|
179
|
-
</Popover>
|
|
180
|
-
</HStack>
|
|
181
|
-
) : null
|
|
182
|
-
}
|