@chem-po/react-web 0.0.8 → 0.0.10

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 (81) hide show
  1. package/dist/index.cjs +2 -2
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +48 -50
  4. package/dist/index.d.ts +48 -50
  5. package/dist/index.js +2 -2
  6. package/dist/index.js.map +1 -1
  7. package/package.json +22 -37
  8. package/src/components/auth/SignIn.tsx +1 -1
  9. package/src/components/box/CollapseHorizontal.tsx +1 -0
  10. package/src/components/box/ContentBox.tsx +1 -1
  11. package/src/components/box/ExpandOnMount.tsx +1 -1
  12. package/src/components/box/Expandable.tsx +6 -6
  13. package/src/components/box/FullSizeContainer.tsx +3 -3
  14. package/src/components/box/MobileFrame/index.tsx +1 -1
  15. package/src/components/button/DeleteButton.tsx +1 -1
  16. package/src/components/button/Toggle.tsx +1 -1
  17. package/src/components/button/ViewButton.tsx +1 -1
  18. package/src/components/feed/FeedContentPane.tsx +1 -1
  19. package/src/components/feed/MediaFeedBackground.tsx +1 -1
  20. package/src/components/feed/MediaFeedRefresh.tsx +1 -1
  21. package/src/components/feed/MediaFeedSwipeUp.tsx +1 -0
  22. package/src/components/feed/context.tsx +1 -1
  23. package/src/components/form/Condition.tsx +1 -1
  24. package/src/components/form/Field.tsx +1 -1
  25. package/src/components/form/Form.tsx +9 -6
  26. package/src/components/form/FormFooter.tsx +4 -3
  27. package/src/components/form/UploadProgress/index.tsx +1 -1
  28. package/src/components/form/input/Editable.tsx +62 -70
  29. package/src/components/form/input/InputSlider.tsx +1 -0
  30. package/src/components/form/input/OptionalTag.tsx +1 -1
  31. package/src/components/form/input/StandaloneInput.tsx +1 -1
  32. package/src/components/form/input/boolean/index.tsx +1 -1
  33. package/src/components/form/input/color/index.tsx +1 -1
  34. package/src/components/form/input/date/index.tsx +1 -1
  35. package/src/components/form/input/datetime/index.tsx +1 -1
  36. package/src/components/form/input/file.tsx +4 -4
  37. package/src/components/form/input/input.tsx +10 -6
  38. package/src/components/form/input/multipleSelect/index.tsx +3 -3
  39. package/src/components/form/input/number/index.tsx +1 -1
  40. package/src/components/form/input/select/index.tsx +10 -4
  41. package/src/components/form/input/socialMedia/index.tsx +8 -1
  42. package/src/components/form/input/text/index.tsx +1 -1
  43. package/src/components/form/input/text/textarea.tsx +1 -1
  44. package/src/components/form/input/time/index.tsx +1 -1
  45. package/src/components/form/view/file.tsx +1 -1
  46. package/src/components/form/view/index.tsx +1 -1
  47. package/src/components/form/view/multipleSelect.tsx +3 -3
  48. package/src/components/form/view/select.tsx +14 -7
  49. package/src/components/list/Body/InfiniteScrollGridBody.tsx +1 -1
  50. package/src/components/list/Body/InfiniteScrollListBody.tsx +1 -1
  51. package/src/components/list/Body/ListBody.tsx +1 -0
  52. package/src/components/list/Body/PagedGridBody.tsx +1 -1
  53. package/src/components/list/Body/PagedListBody.tsx +1 -1
  54. package/src/components/list/DataList.tsx +1 -0
  55. package/src/components/list/ListContainer.tsx +1 -0
  56. package/src/components/list/ListContent.tsx +1 -1
  57. package/src/components/list/ListCreate.tsx +1 -1
  58. package/src/components/list/ListFilters.tsx +1 -1
  59. package/src/components/list/ListFooter.tsx +1 -1
  60. package/src/components/list/ListHeader.tsx +1 -1
  61. package/src/components/list/ListItem/ListCell.tsx +7 -6
  62. package/src/components/list/ListItem/ListRow.tsx +7 -1
  63. package/src/components/list/ListItemView.tsx +1 -1
  64. package/src/components/list/ListSort.tsx +1 -1
  65. package/src/components/list/NoItems.tsx +1 -1
  66. package/src/components/loading/CircularProgress.tsx +1 -0
  67. package/src/components/loading/Loading.tsx +1 -1
  68. package/src/components/loading/LoadingImage.tsx +1 -1
  69. package/src/components/loading/LoadingSwitch.tsx +1 -1
  70. package/src/components/media/PlayButton.tsx +1 -0
  71. package/src/components/modal/DefaultModal.tsx +1 -1
  72. package/src/components/modal/DesktopModal.tsx +1 -0
  73. package/src/components/modal/MobileModal.tsx +1 -1
  74. package/src/components/nav/NavBar.tsx +1 -1
  75. package/src/components/overlay/ImageViewOverlay.tsx +1 -1
  76. package/src/components/overlay/MobileOverlay.tsx +1 -0
  77. package/src/components/text/GradientText/index.tsx +1 -0
  78. package/src/components/text/NumberTicker.tsx +1 -1
  79. package/src/components/theme/colorMode/DarkModeToggle.tsx +1 -1
  80. package/src/components/view/ErrorView.tsx +1 -0
  81. package/src/components/view/RedirectView.tsx +1 -1
package/package.json CHANGED
@@ -1,23 +1,13 @@
1
1
  {
2
2
  "name": "@chem-po/react-web",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "type": "module",
5
- "source": "./src/index.ts",
6
- "main": "./dist/index.js",
7
- "module": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "types": "./dist/index.d.ts",
12
- "import": "./dist/index.js",
13
- "require": "./dist/index.js"
14
- },
15
- "./package.json": "./package.json"
16
- },
17
- "sideEffects": false,
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
18
7
  "publishConfig": {
19
8
  "access": "public"
20
9
  },
10
+ "sideEffects": false,
21
11
  "files": [
22
12
  "dist",
23
13
  "src"
@@ -26,10 +16,6 @@
26
16
  "author": "",
27
17
  "license": "ISC",
28
18
  "dependencies": {
29
- "@chem-po/react": "0.0.8",
30
- "@chem-po/core": "0.0.8"
31
- },
32
- "peerDependencies": {
33
19
  "@chakra-ui/anatomy": "^2.2.2",
34
20
  "@chakra-ui/icons": "^2.1.1",
35
21
  "@chakra-ui/react": "^2.10.3",
@@ -42,42 +28,34 @@
42
28
  "howler": "^2.2.4",
43
29
  "lottie-react": "^2.4.0",
44
30
  "nested-property": "^4.0.0",
45
- "react": "^18.0.0",
46
- "react-dom": "^18.0.0",
47
31
  "react-currency-input-field": "^3.8.0",
48
32
  "react-day-picker": "^9.0.9",
49
33
  "react-error-boundary": "^4.0.13",
50
34
  "react-hook-form": "^7.55.0",
51
- "react-router": "^6.26.2",
52
- "react-router-dom": "^6.26.2",
35
+ "react-router": "^7.6.1",
36
+ "react-router-dom": "^7.6.1",
53
37
  "react-textarea-autosize": "^8.5.3",
54
38
  "react-transition-group": "^4.4.5",
55
39
  "react-window": "^1.8.10",
56
40
  "react-window-infinite-loader": "^1.0.9",
57
- "@hello-pangea/dnd": "^17.0.0",
58
- "zustand": "^4.3.3"
41
+ "@hello-pangea/dnd": "^18.0.1",
42
+ "zustand": "^4.3.3",
43
+ "@chem-po/core": "0.0.10",
44
+ "@chem-po/react": "0.0.10"
45
+ },
46
+ "peerDependencies": {
47
+ "react": "^19.0.0",
48
+ "react-dom": "^19.0.0"
59
49
  },
60
50
  "devDependencies": {
61
51
  "@types/howler": "^2.2.11",
62
- "@types/react": "^18.3.1",
52
+ "@types/react": "~19.0.10",
63
53
  "@types/react-beautiful-dnd": "^13.1.8",
64
54
  "@types/react-transition-group": "^4.4.11",
65
55
  "@types/react-window": "^1.8.8",
66
56
  "@types/react-window-infinite-loader": "^1.0.9",
67
57
  "replace-in-file": "^8.1.0",
68
- "typescript": "^5.7.2",
69
58
  "vite": "^5.4.6",
70
- "typescript-eslint": "^8.11.0",
71
- "@eslint/js": "^9.13.0",
72
- "@types/eslint__js": "^8.42.3",
73
- "@typescript-eslint/parser": "8.12.2",
74
- "eslint": "^9.13.0",
75
- "eslint-config-prettier": "^9.1.0",
76
- "eslint-import-resolver-typescript": "^3.6.3",
77
- "eslint-plugin-import": "^2.31.0",
78
- "eslint-plugin-prettier": "^5.2.1",
79
- "eslint-plugin-react-hooks": "^5.0.0",
80
- "prettier": "^3.2.5",
81
59
  "tsup": "^8.3.0"
82
60
  },
83
61
  "description": "",
@@ -88,5 +66,12 @@
88
66
  "dev": "tsup --watch",
89
67
  "clean": "rm -rf dist",
90
68
  "prebuild": "pnpm lint"
69
+ },
70
+ "module": "dist/index.js",
71
+ "exports": {
72
+ ".": {
73
+ "import": "./dist/index.js",
74
+ "require": "./dist/index.js"
75
+ }
91
76
  }
92
77
  }
@@ -1,6 +1,6 @@
1
1
  import { Button, Flex, Portal, Text } from '@chakra-ui/react'
2
2
  import { useAuth, useBackendBase } from '@chem-po/react'
3
-
3
+ import React from 'react'
4
4
  interface SignInProps {
5
5
  // authProviders: Array<AuthProviderData<FC<{ noText?: boolean }>>>
6
6
  layout?: 'row' | 'column'
@@ -1,4 +1,5 @@
1
1
  import { Center, CenterProps } from '@chakra-ui/react'
2
+ import React from 'react'
2
3
 
3
4
  export const CollapseHorizontal = ({
4
5
  width,
@@ -1,5 +1,5 @@
1
1
  import { Flex, FlexProps } from '@chakra-ui/react'
2
- import { ForwardedRef, forwardRef } from 'react'
2
+ import React, { ForwardedRef, forwardRef } from 'react'
3
3
 
4
4
  const ContentBoxBase = (props: FlexProps, ref: ForwardedRef<HTMLDivElement>) => {
5
5
  return (
@@ -1,7 +1,7 @@
1
1
  import { Box, BoxProps } from '@chakra-ui/react'
2
2
  import { useMounted } from '@chem-po/react'
3
3
  import useResizeObserver from '@react-hook/resize-observer'
4
- import { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react'
4
+ import React, { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react'
5
5
 
6
6
  export const ExpandOnMount: FC<
7
7
  BoxProps & { in?: boolean; animateOpacity?: boolean; duration?: number; onExited?: () => void }
@@ -13,14 +13,14 @@ import { useBorderColor } from '../../hooks/ui/useBorderColor'
13
13
  import { ViewButton } from '../button/ViewButton'
14
14
 
15
15
  export const Expandable = ({
16
- header,
16
+ header: Header,
17
17
  children,
18
18
  initExpanded = false,
19
19
  nested,
20
20
  alwaysExpanded,
21
21
  headerProps,
22
22
  iconColor,
23
- footer,
23
+ footer: Footer,
24
24
  isOpen: isOpenProp,
25
25
  onClose: onCloseProp,
26
26
  onOpen: onOpenProp,
@@ -73,12 +73,12 @@ export const Expandable = ({
73
73
  aria-label="expand/hide"
74
74
  align="center"
75
75
  flex={1}>
76
- {typeof header === 'string' ? (
76
+ {typeof Header === 'string' ? (
77
77
  <Text fontWeight={600} color="gray.500" flex={1}>
78
- {header}
78
+ {Header}
79
79
  </Text>
80
80
  ) : (
81
- header({ isOpen, onClose })
81
+ <Header isOpen={isOpen} onClose={onClose} />
82
82
  )}
83
83
  </Flex>
84
84
  {alwaysExpanded ? null : (
@@ -90,7 +90,7 @@ export const Expandable = ({
90
90
  {children as any}
91
91
  </Collapse>
92
92
  </Box>
93
- {footer ? footer({ isOpen, onClose }) : null}
93
+ {Footer ? <Footer isOpen={isOpen} onClose={onClose} /> : null}
94
94
  </VStack>
95
95
  )
96
96
  }
@@ -1,10 +1,10 @@
1
1
  import { Box, BoxProps } from '@chakra-ui/react'
2
2
  import { FullSizeContext } from '@chem-po/react'
3
3
  import useResizeObserver from '@react-hook/resize-observer'
4
- import { FC, useCallback, useMemo, useRef, useState } from 'react'
4
+ import React, { FC, useCallback, useMemo, useRef, useState } from 'react'
5
5
 
6
6
  export const FullSizeContainer = ({
7
- children,
7
+ children: Children,
8
8
  ...props
9
9
  }: Omit<BoxProps, 'children'> & { children: FC<{ width: number; height: number }> }) => {
10
10
  const [width, setWidth] = useState(0)
@@ -21,7 +21,7 @@ export const FullSizeContainer = ({
21
21
 
22
22
  return (
23
23
  <Box ref={ref} {...props} width="100%" height="100%">
24
- {children({ width, height })}
24
+ <Children width={width} height={height} />
25
25
  </Box>
26
26
  )
27
27
  }
@@ -2,7 +2,7 @@ import { Box, Center, Flex, useColorModeValue } from '@chakra-ui/react'
2
2
  import { cssGradients } from '@chem-po/core'
3
3
  import { MobileFrameProvider, useScreen, useViews, View, ViewsProvider } from '@chem-po/react'
4
4
  import { AnimatePresence, motion } from 'framer-motion'
5
- import { PropsWithChildren, ReactNode, useMemo, useRef } from 'react'
5
+ import React, { PropsWithChildren, ReactNode, useMemo, useRef } from 'react'
6
6
  import { ErrorBoundary } from 'react-error-boundary'
7
7
  import { matchRoutes, useLocation, useOutlet } from 'react-router-dom'
8
8
  import { CSSTransition, SwitchTransition } from 'react-transition-group'
@@ -85,7 +85,7 @@ export const DeleteButton: React.FC<
85
85
  > = ({ onDelete, itemName, noConfirm, alertBody, text, actionName = 'Delete', ...props }) => {
86
86
  const [deleteLoading, setDeleteLoading] = useState(false)
87
87
  const [confirmActive, setConfirmActive] = useState(false)
88
- const confirmTimer = useRef<any>()
88
+ const confirmTimer = useRef<ReturnType<typeof setTimeout> | null>(null)
89
89
  const isMounted = useRef(true)
90
90
  useEffect(() => {
91
91
  isMounted.current = true
@@ -1,5 +1,5 @@
1
1
  import { Box, Flex, IconButton, IconButtonProps, Tooltip } from '@chakra-ui/react'
2
- import { JSX } from 'react'
2
+ import React, { JSX } from 'react'
3
3
  import { useBorderColor } from '../../hooks'
4
4
 
5
5
  export interface ToggleOption<Option extends string = string> {
@@ -1,6 +1,6 @@
1
1
  import { ChevronDownIcon, ChevronUpIcon } from '@chakra-ui/icons'
2
2
  import { IconButton } from '@chakra-ui/react'
3
- import { FC, MouseEvent } from 'react'
3
+ import React, { FC, MouseEvent } from 'react'
4
4
 
5
5
  export const ViewButton: FC<{
6
6
  onClick: (e: MouseEvent) => void
@@ -1,7 +1,7 @@
1
1
  import { AnyObject, WithId } from '@chem-po/core'
2
2
  import { MobileFrameContextData, useDocument, useMobileFrame } from '@chem-po/react'
3
3
  import { motion, MotionValue, useMotionValue, useSpring, useTransform } from 'framer-motion'
4
- import { JSX, useEffect, useMemo, useRef } from 'react'
4
+ import React, { JSX, useEffect, useMemo, useRef } from 'react'
5
5
  import { springConfig } from './constants'
6
6
  import { PanelStatus } from './types'
7
7
 
@@ -1,7 +1,7 @@
1
1
  import { Center, CenterProps } from '@chakra-ui/react'
2
2
  import { AnyObject, WithId } from '@chem-po/core'
3
3
  import { useObjectUrl } from '@chem-po/react'
4
- import { useEffect, useMemo, useRef, useState } from 'react'
4
+ import React, { useEffect, useMemo, useRef, useState } from 'react'
5
5
  import { LoadingLogo } from '../loading'
6
6
  import { GetBackgroundUrl, GetBackgroundValue } from './types'
7
7
 
@@ -1,7 +1,7 @@
1
1
  import { RepeatIcon } from '@chakra-ui/icons'
2
2
  import { Center } from '@chakra-ui/react'
3
3
  import { motion, MotionValue, useSpring, useTransform } from 'framer-motion'
4
- import { useEffect } from 'react'
4
+ import React, { useEffect } from 'react'
5
5
  import { CircularProgress } from '../loading/CircularProgress'
6
6
  import { REFRESH_THRESHOLD, SWIPE_THRESHOLD } from './constants'
7
7
 
@@ -1,6 +1,7 @@
1
1
  import { ChevronUpIcon } from '@chakra-ui/icons'
2
2
  import { Center } from '@chakra-ui/react'
3
3
  import { motion, MotionValue, useTransform } from 'framer-motion'
4
+ import React from 'react'
4
5
 
5
6
  export const MediaFeedSwipeUp = ({ offsetY }: { offsetY: MotionValue<number> }) => {
6
7
  const progress = useTransform(offsetY, v => {
@@ -1,5 +1,5 @@
1
1
  import { AnyObject, WithId } from '@chem-po/core'
2
- import { createContext, PropsWithChildren, useContext, useMemo } from 'react'
2
+ import React, { createContext, PropsWithChildren, useContext, useMemo } from 'react'
3
3
 
4
4
  interface MediaFeedContextValue<T extends AnyObject = AnyObject> {
5
5
  curr: WithId<T> | null
@@ -1,4 +1,4 @@
1
- import { PropsWithChildren, useMemo } from 'react'
1
+ import React, { PropsWithChildren, useMemo } from 'react'
2
2
  import { useWatch } from 'react-hook-form'
3
3
  import { ExpandOnMount } from '../box'
4
4
 
@@ -1,5 +1,5 @@
1
1
  import { InputRef } from '@chem-po/core'
2
- import { ForwardedRef, forwardRef } from 'react'
2
+ import React, { ForwardedRef, forwardRef } from 'react'
3
3
 
4
4
  import { Field, useField } from '@chem-po/react'
5
5
  import { ChangeHandler, Controller } from 'react-hook-form'
@@ -18,15 +18,17 @@ import {
18
18
  FieldFormProps,
19
19
  FieldMap,
20
20
  FieldMapFormProps,
21
+ FormOnSubmit,
21
22
  FormProps,
22
23
  IFormElement,
23
24
  ListField,
24
25
  useDataView,
25
26
  useFormSubmit,
26
27
  UseFormSubmitProps,
28
+ useGetItemField,
27
29
  } from '@chem-po/react'
28
30
  import { DragDropContext, Draggable, Droppable, DropResult } from '@hello-pangea/dnd'
29
- import { FC, useMemo, useState } from 'react'
31
+ import React, { FC, useMemo, useState } from 'react'
30
32
  import { useFieldArray, UseFieldArrayMove, useFormContext } from 'react-hook-form'
31
33
  import { useBorderColor } from '../../hooks'
32
34
  import { Expandable } from '../box'
@@ -208,8 +210,9 @@ const ListFieldView = ({
208
210
  value: any[]
209
211
  path: string
210
212
  }) => {
211
- const { itemField, placeholder } = field
213
+ const { placeholder } = field
212
214
  const borderColor = useBorderColor()
215
+ const getItemField = useGetItemField(field)
213
216
  return (
214
217
  <Box w="100%" p={1}>
215
218
  <Expandable
@@ -227,7 +230,7 @@ const ListFieldView = ({
227
230
  borderRadius={3}>
228
231
  <FormElementView
229
232
  path={`${path}.${index}`}
230
- field={{ ...itemField, placeholder: `${placeholder} ${index + 1}` }}
233
+ field={getItemField(index)}
231
234
  value={item}
232
235
  />
233
236
  </Box>
@@ -413,12 +416,12 @@ export const FieldForm = <F extends Field | ListField>({
413
416
  )
414
417
  }
415
418
 
416
- export const Form = <F extends IFormElement>({ field, ...props }: FormProps<F>) => {
419
+ export const Form = <F extends IFormElement>({ field, onSubmit, ...props }: FormProps<F>) => {
417
420
  const body =
418
421
  isField(field) || isListField(field) ? (
419
- <FieldForm field={field} {...props} />
422
+ <FieldForm field={field} onSubmit={onSubmit as FormOnSubmit<Field | ListField>} {...props} />
420
423
  ) : (
421
- <FieldMapForm field={field} {...props} />
424
+ <FieldMapForm field={field} onSubmit={onSubmit as FormOnSubmit<FieldMap>} {...props} />
422
425
  )
423
426
 
424
427
  return <ChempoFormProvider>{body}</ChempoFormProvider>
@@ -1,4 +1,5 @@
1
1
  import { Button, ButtonProps, Collapse, Flex, HStack, Progress, Text } from '@chakra-ui/react'
2
+ import React from 'react'
2
3
 
3
4
  import { FC, PropsWithChildren } from 'react'
4
5
 
@@ -47,7 +48,7 @@ const FormErrorView = () => {
47
48
  }
48
49
 
49
50
  export const FormFooter = <F extends IFormElement>({
50
- renderFooter,
51
+ renderFooter: RenderFooter,
51
52
  ...props
52
53
  }: Pick<FormProps<F>, 'renderFooter' | 'onBack' | 'buttonText'> &
53
54
  Pick<UseFormSubmit, 'uploads'> & {
@@ -62,8 +63,8 @@ export const FormFooter = <F extends IFormElement>({
62
63
  </Collapse>
63
64
  <UploadProgress uploads={uploads} />
64
65
  <FormErrorView />
65
- {renderFooter ? (
66
- renderFooter(props)
66
+ {RenderFooter ? (
67
+ <RenderFooter {...props} />
67
68
  ) : (
68
69
  <HStack py={2} borderTop="1px solid" borderColor="background.200" px={3} w="100%">
69
70
  {onBack ? <CancelButton onBack={onBack}>Cancel</CancelButton> : null}
@@ -1,6 +1,6 @@
1
1
  import { Center, Flex, Progress, Text } from '@chakra-ui/react'
2
2
  import { UploadsState } from '@chem-po/core'
3
- import { useMemo } from 'react'
3
+ import React, { useMemo } from 'react'
4
4
  import { TransitionGroup } from 'react-transition-group'
5
5
  import { ExpandOnMount } from '../../box'
6
6
  import './styles.css'
@@ -1,14 +1,8 @@
1
1
  import { CheckIcon, CloseIcon, EditIcon } from '@chakra-ui/icons'
2
2
  import { Flex, IconButton } from '@chakra-ui/react'
3
3
  import { palette } from '@chem-po/core'
4
- import {
5
- ChempoFormProvider,
6
- EditableProps,
7
- Field,
8
- useColorModeValue,
9
- useEditable,
10
- } from '@chem-po/react'
11
- import { CSSProperties, useEffect, useMemo } from 'react'
4
+ import { EditableProps, Field, useColorModeValue, useEditable } from '@chem-po/react'
5
+ import React, { CSSProperties, useEffect, useMemo } from 'react'
12
6
  import { LoadingOverlay } from '../../loading/Loading'
13
7
  import { UploadProgress } from '../UploadProgress'
14
8
  import { FieldView } from '../view'
@@ -56,74 +50,72 @@ export const Editable = <T extends Field>({
56
50
  const editingBorderColor = useColorModeValue('#00000055', '#ffffff55')
57
51
 
58
52
  return (
59
- <ChempoFormProvider>
60
- <Flex
61
- borderRadius={4}
62
- border={`1px dashed ${editHovered && !isEditing ? editingBorderColor : 'transparent'}`}
63
- flexFlow="column"
64
- w="100%">
65
- <Flex align="center" px={1} position="relative" w="100%">
66
- <Flex
67
- opacity={isLoading ? 0 : 1}
68
- transition="all 300ms"
69
- mr={1}
70
- border={`1px dashed ${isEditing ? editingBorderColor : 'transparent'}`}
71
- flex={1}
72
- minW="0">
73
- {isEditing || alwaysEditing ? (
74
- <StandaloneInput
75
- ref={inputRef}
76
- value={formattedValue}
77
- inEditable
78
- field={field}
79
- style={{ padding: 0, ...style }}
80
- onChange={alwaysEditing ? v => submitValue(parse(v)) : v => setValue(parse(v))}
81
- />
82
- ) : (
83
- <FieldView style={style} field={field} value={value} />
84
- )}
85
- </Flex>
86
- {alwaysEditing ? null : (
87
- <>
53
+ <Flex
54
+ borderRadius={4}
55
+ border={`1px dashed ${editHovered && !isEditing ? editingBorderColor : 'transparent'}`}
56
+ flexFlow="column"
57
+ w="100%">
58
+ <Flex align="center" px={1} position="relative" w="100%">
59
+ <Flex
60
+ opacity={isLoading ? 0 : 1}
61
+ transition="all 300ms"
62
+ mr={1}
63
+ border={`1px dashed ${isEditing ? editingBorderColor : 'transparent'}`}
64
+ flex={1}
65
+ minW="0">
66
+ {isEditing || alwaysEditing ? (
67
+ <StandaloneInput
68
+ ref={inputRef}
69
+ value={formattedValue}
70
+ inEditable
71
+ field={field}
72
+ style={{ padding: 0, ...style }}
73
+ onChange={alwaysEditing ? v => submitValue(parse(v)) : v => setValue(parse(v))}
74
+ />
75
+ ) : (
76
+ <FieldView style={style} field={field} value={value} />
77
+ )}
78
+ </Flex>
79
+ {alwaysEditing ? null : (
80
+ <>
81
+ <IconButton
82
+ aria-label="Edit"
83
+ size="xs"
84
+ icon={isEditing ? <CloseIcon width={3} /> : <EditIcon />}
85
+ onMouseEnter={() => setEditHovered(true)}
86
+ onMouseLeave={() => setEditHovered(false)}
87
+ onClick={() => {
88
+ if (isEditing) {
89
+ setValue(value)
90
+ handleEditClose()
91
+ } else handleEditOpen()
92
+ }}
93
+ />
94
+ <Flex
95
+ transition="all 300ms"
96
+ justify="flex-end"
97
+ opacity={isEditing ? 1 : 0}
98
+ overflow="hidden"
99
+ w={isEditing ? '30px' : '0px'}>
88
100
  <IconButton
89
101
  aria-label="Edit"
90
102
  size="xs"
91
- icon={isEditing ? <CloseIcon width={3} /> : <EditIcon />}
92
- onMouseEnter={() => setEditHovered(true)}
93
- onMouseLeave={() => setEditHovered(false)}
103
+ bg={palette.cyan.light}
104
+ _dark={{ bg: palette.cyan.light, _hover: { bg: palette.cyan.lighter } }}
105
+ _hover={{
106
+ bg: palette.cyan.medium,
107
+ }}
108
+ icon={<CheckIcon filter="drop-shadow(1px 1px 3px #000000aa)" />}
94
109
  onClick={() => {
95
- if (isEditing) {
96
- setValue(value)
97
- handleEditClose()
98
- } else handleEditOpen()
110
+ submit()
99
111
  }}
100
112
  />
101
- <Flex
102
- transition="all 300ms"
103
- justify="flex-end"
104
- opacity={isEditing ? 1 : 0}
105
- overflow="hidden"
106
- w={isEditing ? '30px' : '0px'}>
107
- <IconButton
108
- aria-label="Edit"
109
- size="xs"
110
- bg={palette.cyan.light}
111
- _dark={{ bg: palette.cyan.light, _hover: { bg: palette.cyan.lighter } }}
112
- _hover={{
113
- bg: palette.cyan.medium,
114
- }}
115
- icon={<CheckIcon filter="drop-shadow(1px 1px 3px #000000aa)" />}
116
- onClick={() => {
117
- submit()
118
- }}
119
- />
120
- </Flex>
121
- </>
122
- )}
123
- <LoadingOverlay isLoading={isLoading} />
124
- </Flex>
125
- <UploadProgress uploads={uploads} />
113
+ </Flex>
114
+ </>
115
+ )}
116
+ <LoadingOverlay isLoading={isLoading} />
126
117
  </Flex>
127
- </ChempoFormProvider>
118
+ <UploadProgress uploads={uploads} />
119
+ </Flex>
128
120
  )
129
121
  }
@@ -10,6 +10,7 @@ import {
10
10
  Tooltip,
11
11
  } from '@chakra-ui/react'
12
12
  import { Gradient, gradientToCssGradientProp } from '@chem-po/core'
13
+ import React from 'react'
13
14
  import { GradientText } from '../../text/GradientText'
14
15
 
15
16
  export const InputSlider = ({
@@ -1,6 +1,6 @@
1
1
  import { Flex, Text } from '@chakra-ui/react'
2
2
  import { Field } from '@chem-po/react'
3
- import { useMemo } from 'react'
3
+ import React, { useMemo } from 'react'
4
4
 
5
5
  export const OptionalTag = <T extends Field>({
6
6
  value,
@@ -1,6 +1,6 @@
1
1
  import { InputRef } from '@chem-po/core'
2
2
  import { Field, useStandaloneInput } from '@chem-po/react'
3
- import { CSSProperties, ForwardedRef, forwardRef } from 'react'
3
+ import React, { CSSProperties, ForwardedRef, forwardRef } from 'react'
4
4
  import { Input } from './input'
5
5
 
6
6
  const StandaloneInputBase = (
@@ -1,7 +1,7 @@
1
1
  import { Checkbox, Flex, Switch, Text } from '@chakra-ui/react'
2
2
  import { InputRef } from '@chem-po/core'
3
3
  import { BooleanField } from '@chem-po/react'
4
- import { ForwardedRef, forwardRef, useImperativeHandle } from 'react'
4
+ import React, { ForwardedRef, forwardRef, useImperativeHandle } from 'react'
5
5
  import { FieldProps } from '../types'
6
6
 
7
7
  const BaseCheckboxComponent = (
@@ -2,7 +2,7 @@ import { Box, Center, HStack, SliderProps, StackProps, Text, VStack } from '@cha
2
2
 
3
3
  import { colorValueToHex, Gradient, gradients, InputRef } from '@chem-po/core'
4
4
  import { ColorField } from '@chem-po/react'
5
- import { forwardRef, useCallback, useMemo } from 'react'
5
+ import React, { forwardRef, useCallback, useMemo } from 'react'
6
6
  import { useInputImperativeHandle } from '../hooks/useInputImperativeHandle'
7
7
  import { InputSlider } from '../InputSlider'
8
8
  import { FieldProps } from '../types'
@@ -8,7 +8,7 @@ import {
8
8
  Portal,
9
9
  Text,
10
10
  } from '@chakra-ui/react'
11
- import { forwardRef, useImperativeHandle, useMemo } from 'react'
11
+ import React, { forwardRef, useImperativeHandle, useMemo } from 'react'
12
12
  import { DayPicker } from 'react-day-picker'
13
13
  // import 'react-day-picker/dist/style.css'
14
14
  import { getDateString, InputRef } from '@chem-po/core'
@@ -1,7 +1,7 @@
1
1
  import { HStack } from '@chakra-ui/react'
2
2
  import { InputRef } from '@chem-po/core'
3
3
  import { DateTimeField, FieldMeta } from '@chem-po/react'
4
- import { forwardRef, useCallback, useImperativeHandle, useMemo, useState } from 'react'
4
+ import React, { forwardRef, useCallback, useImperativeHandle, useMemo, useState } from 'react'
5
5
  import { DateInput, parseDate } from '../date'
6
6
  import '../input.css'
7
7
  import { TimeInput } from '../time'
@@ -9,10 +9,7 @@ import {
9
9
  useColorModeValue,
10
10
  VStack,
11
11
  } from '@chakra-ui/react'
12
-
13
- import { FileValue, generateId, ImageViewOptions, InputRef, WithId } from '@chem-po/core'
14
- import { FileField, useImageSize, useObjectUrl } from '@chem-po/react'
15
- import {
12
+ import React, {
16
13
  ChangeEventHandler,
17
14
  forwardRef,
18
15
  useCallback,
@@ -21,6 +18,9 @@ import {
21
18
  useRef,
22
19
  useState,
23
20
  } from 'react'
21
+
22
+ import { FileValue, generateId, ImageViewOptions, InputRef, WithId } from '@chem-po/core'
23
+ import { FileField, useImageSize, useObjectUrl } from '@chem-po/react'
24
24
  import { useBorderColor } from '../../../hooks'
25
25
  import { LoadingImage } from '../../loading/LoadingImage'
26
26
  import { PlayButton } from '../../media/PlayButton'