@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.
Files changed (127) hide show
  1. package/package.json +4 -5
  2. package/src/components/auth/SignIn.tsx +0 -43
  3. package/src/components/auth/index.ts +0 -1
  4. package/src/components/box/CollapseHorizontal.tsx +0 -19
  5. package/src/components/box/ContentBox.tsx +0 -17
  6. package/src/components/box/ExpandOnMount.tsx +0 -48
  7. package/src/components/box/Expandable.tsx +0 -96
  8. package/src/components/box/FullSizeContainer.tsx +0 -50
  9. package/src/components/box/MobileFrame/index.tsx +0 -146
  10. package/src/components/box/MobileFrame/styles.css +0 -35
  11. package/src/components/box/index.ts +0 -6
  12. package/src/components/button/DeleteButton.tsx +0 -178
  13. package/src/components/button/Toggle.tsx +0 -88
  14. package/src/components/button/ViewButton.tsx +0 -30
  15. package/src/components/button/index.ts +0 -3
  16. package/src/components/feed/FeedContentPane.tsx +0 -111
  17. package/src/components/feed/MediaFeed.tsx +0 -200
  18. package/src/components/feed/MediaFeedBackground.tsx +0 -127
  19. package/src/components/feed/MediaFeedRefresh.tsx +0 -78
  20. package/src/components/feed/MediaFeedSwipeUp.tsx +0 -35
  21. package/src/components/feed/constants.ts +0 -11
  22. package/src/components/feed/context.tsx +0 -19
  23. package/src/components/feed/hooks.ts +0 -290
  24. package/src/components/feed/index.ts +0 -2
  25. package/src/components/feed/types.ts +0 -50
  26. package/src/components/form/Condition.tsx +0 -26
  27. package/src/components/form/Field.tsx +0 -39
  28. package/src/components/form/Form.tsx +0 -428
  29. package/src/components/form/FormFooter.tsx +0 -90
  30. package/src/components/form/UploadProgress/index.tsx +0 -38
  31. package/src/components/form/UploadProgress/styles.css +0 -23
  32. package/src/components/form/index.ts +0 -4
  33. package/src/components/form/input/Editable.tsx +0 -155
  34. package/src/components/form/input/InputSlider.tsx +0 -76
  35. package/src/components/form/input/OptionalTag.tsx +0 -33
  36. package/src/components/form/input/StandaloneInput.tsx +0 -41
  37. package/src/components/form/input/boolean/index.tsx +0 -53
  38. package/src/components/form/input/color/index.tsx +0 -126
  39. package/src/components/form/input/date/index.tsx +0 -122
  40. package/src/components/form/input/datetime/index.tsx +0 -93
  41. package/src/components/form/input/file.tsx +0 -379
  42. package/src/components/form/input/hooks/index.ts +0 -2
  43. package/src/components/form/input/hooks/useInputImperativeHandle.ts +0 -16
  44. package/src/components/form/input/hooks/useInputStyles.ts +0 -125
  45. package/src/components/form/input/index.ts +0 -2
  46. package/src/components/form/input/input.css +0 -44
  47. package/src/components/form/input/input.tsx +0 -134
  48. package/src/components/form/input/multipleSelect/index.tsx +0 -89
  49. package/src/components/form/input/number/index.tsx +0 -87
  50. package/src/components/form/input/number/styles.css +0 -8
  51. package/src/components/form/input/select/index.tsx +0 -109
  52. package/src/components/form/input/shared/InputContainer.tsx +0 -13
  53. package/src/components/form/input/socialMedia/index.tsx +0 -165
  54. package/src/components/form/input/text/index.tsx +0 -78
  55. package/src/components/form/input/text/textarea.tsx +0 -43
  56. package/src/components/form/input/time/index.tsx +0 -33
  57. package/src/components/form/input/type.ts +0 -0
  58. package/src/components/form/input/types.ts +0 -4
  59. package/src/components/form/view/file.tsx +0 -36
  60. package/src/components/form/view/index.tsx +0 -52
  61. package/src/components/form/view/multipleSelect.tsx +0 -51
  62. package/src/components/form/view/select.tsx +0 -50
  63. package/src/components/form/view/types.ts +0 -11
  64. package/src/components/index.ts +0 -14
  65. package/src/components/list/Body/InfiniteScrollGridBody.tsx +0 -177
  66. package/src/components/list/Body/InfiniteScrollListBody.tsx +0 -114
  67. package/src/components/list/Body/ListBody.tsx +0 -24
  68. package/src/components/list/Body/PagedGridBody.tsx +0 -104
  69. package/src/components/list/Body/PagedListBody.tsx +0 -92
  70. package/src/components/list/Body/hooks.ts +0 -84
  71. package/src/components/list/DataList.tsx +0 -33
  72. package/src/components/list/ListContainer.tsx +0 -21
  73. package/src/components/list/ListContent.tsx +0 -54
  74. package/src/components/list/ListCreate.tsx +0 -57
  75. package/src/components/list/ListFilters.tsx +0 -182
  76. package/src/components/list/ListFooter.tsx +0 -458
  77. package/src/components/list/ListHeader.tsx +0 -180
  78. package/src/components/list/ListItem/ListCell.tsx +0 -49
  79. package/src/components/list/ListItem/ListRow.tsx +0 -44
  80. package/src/components/list/ListItemView.tsx +0 -53
  81. package/src/components/list/ListSort.tsx +0 -84
  82. package/src/components/list/NoItems.tsx +0 -33
  83. package/src/components/list/constants.ts +0 -1
  84. package/src/components/list/index.ts +0 -4
  85. package/src/components/list/types.ts +0 -26
  86. package/src/components/list/utils.ts +0 -63
  87. package/src/components/loading/CircularProgress.tsx +0 -12
  88. package/src/components/loading/Loading.tsx +0 -160
  89. package/src/components/loading/LoadingImage.tsx +0 -128
  90. package/src/components/loading/LoadingSwitch.tsx +0 -78
  91. package/src/components/loading/index.ts +0 -4
  92. package/src/components/media/PlayButton.tsx +0 -95
  93. package/src/components/media/index.ts +0 -1
  94. package/src/components/modal/DefaultModal.tsx +0 -18
  95. package/src/components/modal/DesktopModal.tsx +0 -16
  96. package/src/components/modal/ForceMobile.tsx +0 -7
  97. package/src/components/modal/MobileModal.tsx +0 -89
  98. package/src/components/modal/index.ts +0 -3
  99. package/src/components/modal/type.ts +0 -7
  100. package/src/components/nav/NavBar.tsx +0 -102
  101. package/src/components/nav/index.ts +0 -1
  102. package/src/components/overlay/ImageViewOverlay.tsx +0 -88
  103. package/src/components/overlay/MobileOverlay.tsx +0 -23
  104. package/src/components/overlay/index.ts +0 -2
  105. package/src/components/text/GradientText/index.tsx +0 -17
  106. package/src/components/text/GradientText/styles.css +0 -5
  107. package/src/components/text/NumberTicker.tsx +0 -28
  108. package/src/components/text/index.ts +0 -1
  109. package/src/components/theme/colorMode/DarkModeToggle.tsx +0 -40
  110. package/src/components/theme/colorMode/index.ts +0 -1
  111. package/src/components/theme/index.ts +0 -1
  112. package/src/components/view/ErrorView.tsx +0 -14
  113. package/src/components/view/RedirectView.tsx +0 -43
  114. package/src/components/view/index.ts +0 -2
  115. package/src/contexts/index.ts +0 -2
  116. package/src/contexts/theme.ts +0 -316
  117. package/src/contexts/view.tsx +0 -26
  118. package/src/custom.d.ts +0 -4
  119. package/src/hooks/index.ts +0 -1
  120. package/src/hooks/ui/index.ts +0 -1
  121. package/src/hooks/ui/useBorderColor.ts +0 -4
  122. package/src/index.ts +0 -5
  123. package/src/store/index.ts +0 -1
  124. package/src/store/usePlayer.ts +0 -75
  125. package/src/store/useScreen.ts +0 -22
  126. package/src/types/forms.ts +0 -5
  127. package/src/types/index.ts +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chem-po/react-web",
3
- "version": "0.0.51",
3
+ "version": "0.0.53",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,8 +9,7 @@
9
9
  },
10
10
  "sideEffects": false,
11
11
  "files": [
12
- "dist",
13
- "src"
12
+ "dist"
14
13
  ],
15
14
  "keywords": [],
16
15
  "author": "",
@@ -40,8 +39,8 @@
40
39
  "react-window-infinite-loader": "^1.0.9",
41
40
  "@hello-pangea/dnd": "^18.0.1",
42
41
  "zustand": "^4.3.3",
43
- "@chem-po/core": "0.0.51",
44
- "@chem-po/react": "0.0.51"
42
+ "@chem-po/core": "0.0.53",
43
+ "@chem-po/react": "0.0.53"
45
44
  },
46
45
  "peerDependencies": {
47
46
  "react": "~19.1.0",
@@ -1,43 +0,0 @@
1
- import { Button, Flex, Portal, Text } from '@chakra-ui/react'
2
- import { useAuth, useBackendBase } from '@chem-po/react'
3
- import React from 'react'
4
- interface SignInProps {
5
- // authProviders: Array<AuthProviderData<FC<{ noText?: boolean }>>>
6
- layout?: 'row' | 'column'
7
- }
8
-
9
- export const SignIn = ({ layout = 'row' }: SignInProps) => {
10
- const {
11
- adapter: { auth },
12
- } = useBackendBase()
13
-
14
- const user = useAuth(s => s.user)
15
- return (
16
- <Flex gap={[1, 1, 2]} align="center" flexFlow={['column', 'column', 'row']}>
17
- {user ? (
18
- <Button
19
- size="sm"
20
- onClick={() => {
21
- auth.logout()
22
- }}>
23
- SIGN OUT
24
- </Button>
25
- ) : (
26
- <>
27
- <Text whiteSpace="nowrap" textAlign="center" opacity={0.8} fontWeight={600} fontSize="sm">
28
- SIGN IN
29
- </Text>
30
- <Flex flexFlow={layout} gap={2} w="100%"></Flex>
31
- </>
32
- )}
33
- </Flex>
34
- )
35
- }
36
-
37
- export const AbsoluteLogin = (props: SignInProps) => (
38
- <Portal>
39
- <Flex position="fixed" bottom={4} left={4}>
40
- <SignIn {...props} />
41
- </Flex>
42
- </Portal>
43
- )
@@ -1 +0,0 @@
1
- export * from './SignIn'
@@ -1,19 +0,0 @@
1
- import { Center, CenterProps } from '@chakra-ui/react'
2
- import React from 'react'
3
-
4
- export const CollapseHorizontal = ({
5
- width,
6
- children,
7
- active,
8
- duration = 400,
9
- ...props
10
- }: CenterProps & { width: number; active: boolean; duration?: number }) => (
11
- <Center
12
- width={`${active ? width : 0}px`}
13
- opacity={active ? 1 : 0}
14
- transition={`all ${duration}ms ease-in-out`}
15
- overflow="hidden"
16
- {...props}>
17
- {children}
18
- </Center>
19
- )
@@ -1,17 +0,0 @@
1
- import { Flex, FlexProps } from '@chakra-ui/react'
2
- import React, { ForwardedRef, forwardRef } from 'react'
3
-
4
- const ContentBoxBase = (props: FlexProps, ref: ForwardedRef<HTMLDivElement>) => {
5
- return (
6
- <Flex
7
- ref={ref}
8
- bg="background.100"
9
- p={3}
10
- borderRadius={6}
11
- boxShadow="1px 1px 4px #00000066"
12
- {...props}
13
- />
14
- )
15
- }
16
-
17
- export const ContentBox = forwardRef<HTMLDivElement, FlexProps>(ContentBoxBase)
@@ -1,48 +0,0 @@
1
- import { Box, BoxProps } from '@chakra-ui/react'
2
- import { useMounted } from '@chem-po/react'
3
- import useResizeObserver from '@react-hook/resize-observer'
4
- import React, { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react'
5
-
6
- export const ExpandOnMount: FC<
7
- BoxProps & { in?: boolean; animateOpacity?: boolean; duration?: number; onExited?: () => void }
8
- > = ({ animateOpacity, duration = 300, children, in: isIn = true, onExited, ...props }) => {
9
- const mounted = useMounted()
10
-
11
- const [bodyHeight, setBodyHeight] = useState<number>(0)
12
- const bodyRef = useRef<HTMLDivElement | null>(null)
13
-
14
- const [isAnimating, setIsAnimating] = useState(false)
15
- const expanded = useMemo(() => mounted && isIn, [isIn, mounted])
16
- const height = useMemo(() => (expanded ? bodyHeight : 0), [bodyHeight, expanded])
17
- const handleBodyResize = useCallback((e: ResizeObserverEntry) => {
18
- setBodyHeight(e.target.scrollHeight)
19
- }, [])
20
-
21
- useResizeObserver(bodyRef, handleBodyResize)
22
-
23
- const animatingTimeout = useRef<ReturnType<typeof setTimeout> | null>(null)
24
- useEffect(() => {
25
- if (animatingTimeout.current) {
26
- clearTimeout(animatingTimeout.current)
27
- animatingTimeout.current = null
28
- }
29
- setIsAnimating(true)
30
- animatingTimeout.current = setTimeout(() => {
31
- setIsAnimating(false)
32
- if (onExited && !expanded) onExited()
33
- }, duration)
34
- }, [expanded, duration, onExited])
35
- const transition = useMemo(() => {
36
- if (!isAnimating && expanded) return 'height 0ms'
37
- if (!animateOpacity) return `height ${duration}ms`
38
- return `height ${duration}ms, opacity ${duration}ms ease ${expanded ? duration : 0}ms`
39
- }, [animateOpacity, duration, expanded, isAnimating])
40
-
41
- return (
42
- <Box overflow="hidden" w="100%" transition={transition} height={`${height}px`} {...props}>
43
- <Box ref={bodyRef} w="100%" {...props}>
44
- {children}
45
- </Box>
46
- </Box>
47
- )
48
- }
@@ -1,96 +0,0 @@
1
- import {
2
- Box,
3
- Collapse,
4
- Flex,
5
- HStack,
6
- StackProps,
7
- Text,
8
- useDisclosure,
9
- VStack,
10
- } from '@chakra-ui/react'
11
- import React, { FC, PropsWithChildren, useCallback } from 'react'
12
- import { useBorderColor } from '../../hooks/ui/useBorderColor'
13
- import { ViewButton } from '../button/ViewButton'
14
-
15
- export const Expandable = ({
16
- header: Header,
17
- children,
18
- initExpanded = false,
19
- nested,
20
- alwaysExpanded,
21
- headerProps,
22
- iconColor,
23
- footer: Footer,
24
- isOpen: isOpenProp,
25
- onClose: onCloseProp,
26
- onOpen: onOpenProp,
27
- ...stackProps
28
- }: PropsWithChildren<
29
- StackProps & {
30
- header: string | FC<{ isOpen: boolean; onClose: () => void }>
31
- footer?: FC<{ isOpen: boolean; onClose: () => void }>
32
- headerProps?: StackProps
33
- nested?: boolean
34
- alwaysExpanded?: boolean
35
- initExpanded?: boolean
36
- isOpen?: boolean
37
- onClose?: () => void
38
- iconColor?: string
39
- onOpen?: () => void
40
- }
41
- >) => {
42
- const { isOpen, onClose, onOpen } = useDisclosure({
43
- defaultIsOpen: alwaysExpanded ?? initExpanded,
44
- isOpen: isOpenProp,
45
- onClose: onCloseProp,
46
- onOpen: onOpenProp,
47
- })
48
-
49
- const handleOpenClick = useCallback(
50
- (e: React.MouseEvent) => {
51
- e.stopPropagation()
52
- if (alwaysExpanded) return
53
- if (isOpen) {
54
- onClose()
55
- return
56
- }
57
- onOpen()
58
- },
59
- [alwaysExpanded, onOpen, onClose, isOpen],
60
- )
61
- const borderColor = useBorderColor()
62
- return (
63
- <VStack spacing={0} borderColor={borderColor} w="100%" {...stackProps}>
64
- <HStack
65
- borderBottom={isOpen ? `1px solid ${borderColor}` : undefined}
66
- px={2}
67
- spacing={0}
68
- w="100%"
69
- {...headerProps}>
70
- <Flex
71
- onClick={handleOpenClick}
72
- cursor="pointer"
73
- aria-label="expand/hide"
74
- align="center"
75
- flex={1}>
76
- {typeof Header === 'string' ? (
77
- <Text fontWeight={600} color="gray.500" flex={1}>
78
- {Header}
79
- </Text>
80
- ) : (
81
- <Header isOpen={isOpen} onClose={onClose} />
82
- )}
83
- </Flex>
84
- {alwaysExpanded ? null : (
85
- <ViewButton color={iconColor} onClick={handleOpenClick} isOpen={isOpen} />
86
- )}
87
- </HStack>
88
- <Box w="100%" borderLeft={nested ? '4px solid #00000033' : undefined}>
89
- <Collapse unmountOnExit style={{ width: '100%' }} in={isOpen}>
90
- {children as any}
91
- </Collapse>
92
- </Box>
93
- {Footer ? <Footer isOpen={isOpen} onClose={onClose} /> : null}
94
- </VStack>
95
- )
96
- }
@@ -1,50 +0,0 @@
1
- import { Box, BoxProps } from '@chakra-ui/react'
2
- import { FullSizeContext } from '@chem-po/react'
3
- import useResizeObserver from '@react-hook/resize-observer'
4
- import React, { FC, useCallback, useMemo, useRef, useState } from 'react'
5
-
6
- export const FullSizeContainer = ({
7
- children: Children,
8
- ...props
9
- }: Omit<BoxProps, 'children'> & { children: FC<{ width: number; height: number }> }) => {
10
- const [width, setWidth] = useState(0)
11
- const [height, setHeight] = useState(0)
12
-
13
- const ref = useRef<HTMLDivElement>(null)
14
- const handleResize = useCallback((entry: ResizeObserverEntry) => {
15
- // const rect = entry.target.getBoundingClientRect()
16
- setWidth(entry.target.scrollWidth)
17
- setHeight(entry.target.scrollHeight)
18
- }, [])
19
-
20
- useResizeObserver(ref, handleResize)
21
-
22
- return (
23
- <Box ref={ref} {...props} width="100%" height="100%">
24
- <Children width={width} height={height} />
25
- </Box>
26
- )
27
- }
28
-
29
- // same as FullSizeContainer, but provides the width and height in a context instead of a render prop
30
- export const FullSizeProvider = ({ children, ...props }: BoxProps) => {
31
- const [width, setWidth] = useState(0)
32
- const [height, setHeight] = useState(0)
33
-
34
- const ref = useRef<HTMLDivElement>(null)
35
- const handleResize = useCallback((entry: ResizeObserverEntry) => {
36
- // const rect = entry.target.getBoundingClientRect()
37
- setWidth(entry.target.scrollWidth)
38
- setHeight(entry.target.scrollHeight)
39
- }, [])
40
-
41
- useResizeObserver(ref, handleResize)
42
-
43
- const contextValue = useMemo(() => ({ width, height }), [width, height])
44
-
45
- return (
46
- <Box ref={ref} {...props} width="100%" height="100%">
47
- <FullSizeContext.Provider value={contextValue}>{children}</FullSizeContext.Provider>
48
- </Box>
49
- )
50
- }
@@ -1,146 +0,0 @@
1
- import { Box, Center, Flex, useColorModeValue } from '@chakra-ui/react'
2
- import { cssGradients } from '@chem-po/core'
3
- import { MobileFrameProvider, useScreen, View } from '@chem-po/react'
4
- import { AnimatePresence, motion } from 'framer-motion'
5
- import React, { PropsWithChildren, ReactNode, useMemo, useRef } from 'react'
6
- import { ErrorBoundary } from 'react-error-boundary'
7
- import { matchRoutes, useLocation, useOutlet } from 'react-router-dom'
8
- import { CSSTransition, SwitchTransition } from 'react-transition-group'
9
- import { useViews, ViewsProvider } from '../../../contexts/view'
10
- import { ForceMobile } from '../../modal/ForceMobile'
11
- import { NAV_BAR_HEIGHT, NavBar } from '../../nav/NavBar'
12
- import { ErrorView } from '../../view/ErrorView'
13
- import { RedirectView } from '../../view/RedirectView'
14
- import './styles.css'
15
-
16
- const IPHONE_12_WIDTH = 390
17
- const IPHONE_12_HEIGHT = 844
18
- const IPHONE_12_ASPECT = IPHONE_12_WIDTH / IPHONE_12_HEIGHT
19
-
20
- const MobileFrameBody = ({
21
- children,
22
- navBarChildren,
23
- }: PropsWithChildren<{ navBarChildren?: ReactNode }>) => {
24
- const { isMobile, height: screenHeight, width: screenWidth } = useScreen()
25
-
26
- // const contentHeight = useMemo(() => (isMobile ? screenHeight : IPHONE_12_HEIGHT), [isMobile, screenHeight])
27
- // const contentWidth = useMemo(() => (isMobile ? screenWidth : IPHONE_12_WIDTH), [isMobile, screenWidth])
28
- // should be constrained to the screen size
29
- const { contentHeight, contentWidth } = useMemo(() => {
30
- let h = isMobile ? screenHeight : IPHONE_12_HEIGHT
31
- let w = isMobile ? screenWidth : IPHONE_12_WIDTH
32
- if (isMobile) return { contentHeight: h, contentWidth: w }
33
- const cappedHeight = Math.floor(screenHeight * 0.9)
34
- const cappedWidth = Math.floor(screenWidth * 0.9)
35
- if (h > cappedHeight) {
36
- w = Math.floor(cappedHeight * IPHONE_12_ASPECT)
37
- h = cappedHeight
38
- } else if (w > cappedWidth) {
39
- h = Math.floor(cappedWidth / IPHONE_12_ASPECT)
40
- w = cappedWidth
41
- }
42
- return { contentHeight: h, contentWidth: w }
43
- }, [isMobile, screenHeight, screenWidth])
44
-
45
- const outerBg = useColorModeValue(cssGradients.accentGray, cssGradients.darkGray)
46
- const location = useLocation()
47
- const currentOutlet = useOutlet()
48
- const views = useViews()
49
- const view = useMemo(() => views.find(v => !!matchRoutes(v.routes, location)), [views, location])
50
- const viewKey = useMemo(() => {
51
- if (!view) return '404'
52
- return typeof view.view.path === 'string' ? view.view.path : view.view.path[0]
53
- }, [view])
54
- const overlayRef = useRef<HTMLDivElement>(null)
55
- const nodeRef = useRef<HTMLDivElement>(null)
56
- const absoluteNavBar = useMemo(() => !!view?.view?.navBar?.absolute, [view])
57
- const bodyHeight = useMemo(
58
- () => contentHeight - (absoluteNavBar ? 0 : NAV_BAR_HEIGHT),
59
- [contentHeight, absoluteNavBar],
60
- )
61
- const contextData = useMemo(
62
- () => ({
63
- overlayRef,
64
- height: contentHeight,
65
- width: contentWidth,
66
- absoluteNavBar,
67
- bodyHeight,
68
- }),
69
- [overlayRef, contentHeight, contentWidth, absoluteNavBar, bodyHeight],
70
- )
71
- return (
72
- <ForceMobile>
73
- <MobileFrameProvider value={contextData}>
74
- <Center position="relative" bg={outerBg} w="100%" height="100%">
75
- <Flex
76
- bg="background.100"
77
- // ref={frameRef}
78
- position="relative"
79
- style={{ height: `${contentHeight}px`, width: `${contentWidth}px` }}
80
- boxShadow={isMobile ? 'none' : '1px 1px 4px rgba(0,0,0,0.4)'}
81
- borderRadius={isMobile ? 0 : 10}
82
- overflow="hidden"
83
- direction="column"
84
- maxH={contentHeight}>
85
- <AnimatePresence>
86
- <SwitchTransition>
87
- <CSSTransition
88
- key={viewKey}
89
- nodeRef={nodeRef}
90
- unmountOnExit
91
- classNames="page"
92
- timeout={300}>
93
- {() => (
94
- <motion.div
95
- style={{
96
- position: 'relative',
97
- width: '100%',
98
- overflow: 'hidden',
99
- }}
100
- animate={{
101
- height: bodyHeight,
102
- opacity: 1,
103
- dur: 0.5,
104
- scale: 1,
105
- }}
106
- initial={{ opacity: 0, scale: 0.9, height: bodyHeight }}
107
- exit={{ opacity: 0 }}>
108
- <ErrorBoundary FallbackComponent={() => <ErrorView />}>
109
- {view ? currentOutlet : <RedirectView />}
110
- </ErrorBoundary>
111
- {children ? (
112
- <Box
113
- height="100%"
114
- w="100%"
115
- position="absolute"
116
- top={0}
117
- left={0}
118
- pointerEvents="none">
119
- {children}
120
- </Box>
121
- ) : null}
122
- </motion.div>
123
- )}
124
- </CSSTransition>
125
- </SwitchTransition>
126
- </AnimatePresence>
127
- <NavBar selectedView={view?.view}>{navBarChildren}</NavBar>
128
- <Flex pos="absolute" pointerEvents="none" bottom={0} w="100%" h="100%">
129
- <Flex ref={overlayRef} w="100%" h="100%" pos="relative" />
130
- </Flex>
131
- </Flex>
132
- </Center>
133
- </MobileFrameProvider>
134
- </ForceMobile>
135
- )
136
- }
137
-
138
- export const MobileFrame = ({
139
- children,
140
- navBarChildren,
141
- views,
142
- }: PropsWithChildren<{ views: View[]; navBarChildren?: ReactNode }>) => (
143
- <ViewsProvider views={views}>
144
- <MobileFrameBody navBarChildren={navBarChildren}>{children}</MobileFrameBody>
145
- </ViewsProvider>
146
- )
@@ -1,35 +0,0 @@
1
- .page {
2
- display: flex;
3
- align-items: center;
4
- flex-direction: column;
5
- position: relative;
6
- overflow: hidden;
7
- width: 100%;
8
- min-height: 0;
9
- flex: 1;
10
- }
11
-
12
- .page-enter {
13
- opacity: 0;
14
- transform: scale(1.05);
15
- overflow: hidden;
16
- }
17
-
18
- .page-enter-active {
19
- opacity: 1;
20
- transform: scale(1);
21
- overflow: hidden !important;
22
- transition: opacity 300ms, transform 300ms;
23
- }
24
-
25
- .page-exit {
26
- opacity: 1;
27
- transform: scale(1);
28
- }
29
-
30
- .page-exit-active {
31
- opacity: 0;
32
- overflow: hidden !important;
33
- /* transform: scale(0.95); */
34
- transition: opacity 300ms, transform 300ms;
35
- }
@@ -1,6 +0,0 @@
1
- export * from './CollapseHorizontal'
2
- export * from './ContentBox'
3
- export * from './Expandable'
4
- export * from './ExpandOnMount'
5
- export * from './FullSizeContainer'
6
- export * from './MobileFrame'
@@ -1,178 +0,0 @@
1
- import { DeleteIcon } from '@chakra-ui/icons'
2
- import {
3
- AlertDialog,
4
- AlertDialogBody,
5
- AlertDialogContent,
6
- AlertDialogOverlay,
7
- Button,
8
- Flex,
9
- HStack,
10
- IconButton,
11
- IconButtonProps,
12
- Text,
13
- useToast,
14
- VStack,
15
- } from '@chakra-ui/react'
16
- import React, { ReactNode, useCallback, useEffect, useRef, useState } from 'react'
17
-
18
- const defaultAlertBodyText = "Are you sure? You can't undo this action afterwards."
19
- export const DeleteConfirmAlert = ({
20
- confirmActive,
21
- onCancel,
22
- onConfirm,
23
- body = defaultAlertBodyText,
24
- actionName = 'Delete',
25
- actionLoading,
26
- itemName,
27
- }: {
28
- confirmActive: boolean
29
- onCancel: () => void
30
- onConfirm: () => void
31
- body?: string | ReactNode
32
- actionLoading?: boolean
33
- actionName?: string
34
- itemName: string
35
- }) => {
36
- const cancelRef = useRef<HTMLButtonElement>(null)
37
- return (
38
- <AlertDialog
39
- isCentered
40
- isOpen={confirmActive}
41
- leastDestructiveRef={cancelRef}
42
- onClose={() => onCancel()}>
43
- <AlertDialogOverlay>
44
- <AlertDialogContent gap={0}>
45
- <AlertDialogBody>
46
- <VStack align="flex-start" py={1}>
47
- <Text fontSize="lg" fontWeight={500}>
48
- {actionName} {itemName}?
49
- </Text>
50
- {typeof body === 'string' ? <Text fontSize="md">{body}</Text> : body}
51
- <HStack justify="flex-end" w="100%">
52
- <Button size="sm" ref={cancelRef} onClick={onCancel}>
53
- Cancel
54
- </Button>
55
- <Button
56
- size="sm"
57
- isLoading={actionLoading}
58
- color="white"
59
- textShadow="1px 1px 3px #00000077"
60
- bg="red.500"
61
- _dark={{
62
- bg: 'red.500',
63
- }}
64
- onClick={onConfirm}>
65
- {actionName}
66
- </Button>
67
- </HStack>
68
- </VStack>
69
- </AlertDialogBody>
70
- </AlertDialogContent>
71
- </AlertDialogOverlay>
72
- </AlertDialog>
73
- )
74
- }
75
-
76
- export const DeleteButton: React.FC<
77
- Partial<IconButtonProps> & {
78
- onDelete: (() => Promise<any>) | (() => void)
79
- itemName: string
80
- actionName?: string
81
- noConfirm?: boolean
82
- text?: string
83
- alertBody?: string | ReactNode
84
- }
85
- > = ({ onDelete, itemName, noConfirm, alertBody, text, actionName = 'Delete', ...props }) => {
86
- const [deleteLoading, setDeleteLoading] = useState(false)
87
- const [confirmActive, setConfirmActive] = useState(false)
88
- const confirmTimer = useRef<ReturnType<typeof setTimeout> | null>(null)
89
- const isMounted = useRef(true)
90
- useEffect(() => {
91
- isMounted.current = true
92
-
93
- return () => {
94
- isMounted.current = false
95
- }
96
- }, [])
97
-
98
- const toast = useToast()
99
- const handleDelete = useCallback(async () => {
100
- if (confirmTimer.current) clearTimeout(confirmTimer.current)
101
- setConfirmActive(false)
102
- if (onDelete) {
103
- setDeleteLoading(true)
104
- try {
105
- await onDelete()
106
- } catch (err: any) {
107
- console.error(err)
108
- toast({
109
- title: 'Error',
110
- description: err.message ?? 'An error occurred',
111
- status: 'error',
112
- duration: 5000,
113
- isClosable: true,
114
- })
115
- }
116
- if (isMounted.current) {
117
- setDeleteLoading(false)
118
- }
119
- } else {
120
- console.error('No delete function')
121
- }
122
- }, [onDelete, toast])
123
-
124
- return (
125
- <>
126
- {text ? (
127
- <Button
128
- variant="ghost"
129
- size={props.size ?? 'md'}
130
- aria-label="delete"
131
- _hover={{ color: 'red.600', bg: 'red.200' }}
132
- color="red.600"
133
- onClick={e => {
134
- e.stopPropagation()
135
- if (noConfirm) handleDelete()
136
- else setConfirmActive(true)
137
- }}
138
- isLoading={deleteLoading}
139
- {...props}>
140
- <Flex align="center" gap={1}>
141
- <DeleteIcon />
142
- <Text>{text}</Text>
143
- </Flex>
144
- </Button>
145
- ) : (
146
- <IconButton
147
- variant="ghost"
148
- size={props.size ?? 'sm'}
149
- aria-label={actionName}
150
- _hover={{ color: 'red.600', bg: 'red.200' }}
151
- color="red.500"
152
- borderRadius="full"
153
- icon={<DeleteIcon />}
154
- onClick={e => {
155
- e.stopPropagation()
156
- if (noConfirm) handleDelete()
157
- else setConfirmActive(true)
158
- }}
159
- isLoading={deleteLoading}
160
- {...props}
161
- />
162
- )}
163
- {noConfirm ? null : (
164
- <DeleteConfirmAlert
165
- confirmActive={confirmActive}
166
- onCancel={() => setConfirmActive(false)}
167
- actionLoading={deleteLoading}
168
- onConfirm={() => {
169
- handleDelete()
170
- }}
171
- actionName={actionName}
172
- body={alertBody}
173
- itemName={itemName}
174
- />
175
- )}
176
- </>
177
- )
178
- }