@chem-po/react-web 0.0.52 → 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
@@ -1,89 +0,0 @@
1
- import { Box, Button, Flex, Text, useColorMode } from '@chakra-ui/react'
2
- import { InputRef, RenderSelectOptionProps } from '@chem-po/core'
3
- import { MultipleSelectField } from '@chem-po/react'
4
- import React, { CSSProperties, forwardRef, useImperativeHandle, useMemo } from 'react'
5
- import { useInputStyles } from '../hooks/useInputStyles'
6
- import { FieldProps } from '../types'
7
-
8
- export const getRenderSelectedOptionText = (
9
- field: MultipleSelectField,
10
- textStyle: CSSProperties,
11
- ) => {
12
- return (
13
- props: RenderSelectOptionProps<
14
- MultipleSelectField['options'][number]['value'],
15
- MultipleSelectField['options'][number]
16
- >,
17
- ) => {
18
- const { renderOption: RenderOption } = field
19
- if (typeof RenderOption === 'function') {
20
- return <RenderOption {...props} />
21
- }
22
- return <Text style={textStyle}>{props.option.label}</Text>
23
- }
24
- }
25
-
26
- export const MultipleSelectComponent = forwardRef<InputRef, FieldProps<MultipleSelectField>>(
27
- ({ field, input, inEditable, formSize }, ref) => {
28
- const { options, renderOption: RenderOption } = field
29
- const { onChange, value, onFocus, onBlur } = input
30
- const { text, size } = useInputStyles(inEditable, field.size, formSize)
31
- const { colorMode } = useColorMode()
32
- useImperativeHandle(ref, () => ({
33
- focus: () => {
34
- onFocus()
35
- },
36
- blur: () => {
37
- onBlur()
38
- },
39
- }))
40
-
41
- const RenderSelectedOptionText = useMemo(
42
- () => getRenderSelectedOptionText(field, text),
43
- [field, text],
44
- )
45
- const body = (
46
- <Flex w="100%" flexFlow="row wrap">
47
- {options.map(o => (
48
- <Box key={o.value} p={0.5}>
49
- <Button
50
- w="100%"
51
- minH={0}
52
- size="xs"
53
- p={0}
54
- opacity={value?.includes(o.value) ? 1 : 0.7}
55
- variant="unstyled"
56
- onClick={e => {
57
- e.stopPropagation()
58
- onChange(
59
- value?.includes(o.value)
60
- ? value.filter(v => v !== o.value)
61
- : [...(value ?? []), o.value],
62
- )
63
- }}
64
- _hover={{ opacity: 0.8 }}>
65
- <RenderSelectedOptionText
66
- value={o.value}
67
- size={size}
68
- option={o}
69
- colorMode={colorMode}
70
- isSelected
71
- />
72
- </Button>
73
- </Box>
74
- ))}
75
- </Flex>
76
- )
77
-
78
- return inEditable ? (
79
- <Flex py={0.5} flexFlow="column" w="100%">
80
- <Text lineHeight={1} px={2} opacity={0.8} fontSize="sm" fontWeight={600}>
81
- {field.placeholder}
82
- </Text>
83
- {body}
84
- </Flex>
85
- ) : (
86
- body
87
- )
88
- },
89
- )
@@ -1,87 +0,0 @@
1
- import { useColorModeValue } from '@chakra-ui/react'
2
- import { InputRef } from '@chem-po/core'
3
- import { CurrencyAmountField, NumberField } from '@chem-po/react'
4
- import React, { ForwardedRef, forwardRef, useImperativeHandle, useRef, useState } from 'react'
5
- import CurrencyInput from 'react-currency-input-field'
6
- import { InputSlider } from '../InputSlider'
7
- import { useInputImperativeHandle } from '../hooks/useInputImperativeHandle'
8
- import { useInputStyles } from '../hooks/useInputStyles'
9
- import { InputContainer } from '../shared/InputContainer'
10
- import { FieldProps } from '../types'
11
- import './styles.css'
12
-
13
- export const NumberComponent = forwardRef<InputRef, FieldProps<NumberField> & { prefix?: string }>(
14
- (
15
- { input: { onChange, value, ...input }, field, formSize, prefix, inEditable, ...props },
16
- ref,
17
- ) => {
18
- const { type, defaultValue, placeholder, size } = field
19
- const className = useColorModeValue('number-input', 'number-input-dark')
20
- const { container, text } = useInputStyles(inEditable, size, formSize)
21
- const inputRef = useInputImperativeHandle(ref)
22
- const [endsWith, setEndsWith] = useState('')
23
- const displayed = typeof value === 'number' && !Number.isNaN(value) ? `${value}${endsWith}` : ''
24
- const body =
25
- type === 'slider' ? (
26
- <InputSlider
27
- label={placeholder}
28
- onChange={onChange}
29
- value={value}
30
- defaultValue={defaultValue}
31
- />
32
- ) : (
33
- <CurrencyInput
34
- className={className}
35
- placeholder={field.placeholder}
36
- decimalsLimit={field.precision}
37
- allowDecimals={!!field.precision}
38
- prefix={prefix}
39
- ref={inputRef}
40
- onValueChange={(v, _, values) => {
41
- if (v?.endsWith('.')) setEndsWith('.')
42
- else if (v?.includes('.') && v?.endsWith('0')) setEndsWith('0')
43
- else setEndsWith('')
44
- onChange(values?.float)
45
- }}
46
- value={displayed}
47
- {...props}
48
- style={{
49
- background: 'none',
50
- // height: 'auto',
51
- resize: 'none',
52
- fontFamily: 'Encode Sans',
53
- boxSizing: 'border-box',
54
- opacity: value ? 1 : 0.7,
55
- width: '100%',
56
- borderRadius: '4px',
57
- border: 'none',
58
- outline: 'none',
59
- ...text,
60
- ...props.style,
61
- }}
62
- {...input}
63
- />
64
- )
65
- return <InputContainer style={container}>{body}</InputContainer>
66
- },
67
- )
68
- const BaseCurrencyAmountComponent = (
69
- { field, ...props }: FieldProps<CurrencyAmountField>,
70
- ref: ForwardedRef<InputRef>,
71
- ) => {
72
- const inputRef = useRef<HTMLInputElement>(null)
73
-
74
- useImperativeHandle(ref, () => ({
75
- focus: () => {
76
- inputRef.current?.focus()
77
- },
78
- blur: () => {
79
- inputRef.current?.blur()
80
- },
81
- }))
82
- return <NumberComponent prefix="$" field={{ ...field, _type: 'number' }} {...props} />
83
- }
84
-
85
- export const CurrencyAmountComponent = forwardRef<InputRef, FieldProps<CurrencyAmountField>>(
86
- BaseCurrencyAmountComponent as any,
87
- )
@@ -1,8 +0,0 @@
1
- .number-input::placeholder {
2
- opacity: 0.7;
3
- color: #000;
4
- }
5
- .number-input-dark::placeholder {
6
- opacity: 0.7;
7
- color: white;
8
- }
@@ -1,109 +0,0 @@
1
- import {
2
- Button,
3
- Popover,
4
- PopoverBody,
5
- PopoverContent,
6
- PopoverTrigger,
7
- Text,
8
- useColorMode,
9
- } from '@chakra-ui/react'
10
- import { InputRef, RenderSelectOptionProps } from '@chem-po/core'
11
- import { SelectField, useBackgroundColor } from '@chem-po/react'
12
- import React, { forwardRef, useImperativeHandle, useMemo } from 'react'
13
- import { useInputStyles } from '../hooks/useInputStyles'
14
- import { InputContainer } from '../shared/InputContainer'
15
- import { FieldProps } from '../types'
16
-
17
- export const SelectComponent = forwardRef<InputRef, FieldProps<SelectField>>(
18
- ({ field, input, meta, inEditable, formSize }, ref) => {
19
- const { placeholder, options, renderOption: customRender } = field
20
- const { onChange, value, onFocus, onBlur } = input
21
- const { text, size, container } = useInputStyles(inEditable, field.size, formSize)
22
- const { active } = meta
23
- const selected = useMemo(() => value && options.find(o => o.value === value), [value, options])
24
- const { colorMode } = useColorMode()
25
- useImperativeHandle(ref, () => ({
26
- focus: () => {
27
- onFocus()
28
- },
29
- blur: () => {
30
- onBlur()
31
- },
32
- }))
33
- const menuBg = useBackgroundColor(150)
34
-
35
- const DefaultRenderOption = (props: RenderSelectOptionProps) => {
36
- return <Text style={text}>{props.option.label}</Text>
37
- }
38
-
39
- const RenderOption = customRender ?? DefaultRenderOption
40
-
41
- return (
42
- <Popover strategy="fixed" placement="bottom" matchWidth isOpen={active} onClose={onBlur}>
43
- <PopoverTrigger>
44
- <Button
45
- w="100%"
46
- onClick={e => {
47
- e.stopPropagation()
48
- onFocus()
49
- }}
50
- variant="unstyled"
51
- position="relative">
52
- <InputContainer style={container}>
53
- {selected ? (
54
- <RenderOption
55
- size={size}
56
- value={selected.value}
57
- option={selected}
58
- colorMode={colorMode}
59
- isSelected={true}
60
- />
61
- ) : (
62
- <Text fontWeight={400} style={text} opacity={0.6}>
63
- {placeholder}
64
- </Text>
65
- )}
66
- </InputContainer>
67
- </Button>
68
- </PopoverTrigger>
69
- <PopoverContent
70
- w="100%"
71
- overflowY="auto"
72
- maxH="300px"
73
- bg={menuBg}
74
- border="none"
75
- boxShadow="0 0 8px rgba(0, 0, 0, 0.3)">
76
- <PopoverBody p={0}>
77
- {options.map(o => (
78
- <Button
79
- key={o.value}
80
- w="100%"
81
- variant="unstyled"
82
- onClick={e => {
83
- e.stopPropagation()
84
- onChange(o.value)
85
- onBlur()
86
- }}
87
- display="flex"
88
- justifyContent="flex-start"
89
- alignItems="center"
90
- px={3}
91
- _hover={{ bg: 'blackAlpha.100' }}
92
- _dark={{
93
- _hover: { bg: 'whiteAlpha.100' },
94
- }}>
95
- <RenderOption
96
- value={o.value}
97
- option={o}
98
- size={size}
99
- colorMode={colorMode}
100
- isSelected={o.value === value}
101
- />
102
- </Button>
103
- ))}
104
- </PopoverBody>
105
- </PopoverContent>
106
- </Popover>
107
- )
108
- },
109
- )
@@ -1,13 +0,0 @@
1
- import { Flex } from '@chakra-ui/react'
2
- import React, { CSSProperties, PropsWithChildren } from 'react'
3
-
4
- export const InputContainer = ({
5
- children,
6
- style,
7
- }: PropsWithChildren<{ style: CSSProperties }>) => {
8
- return (
9
- <Flex width="100%" borderRadius={4} style={style}>
10
- {children}
11
- </Flex>
12
- )
13
- }
@@ -1,165 +0,0 @@
1
- import {
2
- Center,
3
- Collapse,
4
- HStack,
5
- Image,
6
- Input,
7
- Popover,
8
- PopoverBody,
9
- PopoverContent,
10
- PopoverTrigger,
11
- Text,
12
- VStack,
13
- } from '@chakra-ui/react'
14
-
15
- import { getHandle, InputRef, SocialMediaSites } from '@chem-po/core'
16
- import { SocialMediaField } from '@chem-po/react'
17
- import React, {
18
- FC,
19
- ForwardedRef,
20
- forwardRef,
21
- useCallback,
22
- useImperativeHandle,
23
- useMemo,
24
- } from 'react'
25
- import { FieldProps } from '../types'
26
-
27
- const facebookLogo = '/icons/facebook.svg'
28
- const instagramLogo = '/icons/instagram.svg'
29
- const soundcloudLogo = '/icons/soundcloud.svg'
30
- const twitterLogo = '/icons/twitter.svg'
31
- const youtubeLogo = '/icons/youtube.svg'
32
-
33
- const siteToIcon: Record<SocialMediaSites, any> = {
34
- facebook: facebookLogo,
35
- instagram: instagramLogo,
36
- twitter: twitterLogo,
37
- youtube: youtubeLogo,
38
- soundcloud: soundcloudLogo,
39
- }
40
-
41
- const SocialMediaSiteInput: FC<{
42
- site: SocialMediaSites
43
- value?: string
44
- onChange: (v?: string) => void
45
- }> = ({ site, value, onChange }) => {
46
- const { handle, error } = useMemo(() => {
47
- try {
48
- const h = getHandle(site, value)
49
- return { handle: h }
50
- } catch (e: any) {
51
- return { error: e?.message ?? 'Error parsing handle' }
52
- }
53
- }, [value, site])
54
- const displayedText = useMemo(
55
- () => (handle ? `${site.toUpperCase()}: ${handle}` : site.toUpperCase()),
56
- [site, handle],
57
- )
58
- return (
59
- <Popover trigger="hover">
60
- <PopoverTrigger>
61
- <Center opacity={handle ? 1 : 0.6} borderRadius="full" width="34px" height="34px">
62
- <Image
63
- cursor="pointer"
64
- filter={`grayscale(${handle ? 0 : 100}%)`}
65
- height="24px"
66
- width="24px"
67
- objectFit="contain"
68
- src={siteToIcon[site]}
69
- />
70
- </Center>
71
- </PopoverTrigger>
72
- <PopoverContent w="auto">
73
- <PopoverBody overflow="hidden" borderRadius={4} p={0} w="auto">
74
- <VStack spacing={0} p={2} w="300px" align="flex-start">
75
- <Text fontSize="md">{displayedText}</Text>
76
-
77
- <Collapse in={!!error} style={{ width: '100%' }}>
78
- <Text px={1} bg="red.500" fontSize="sm" color="white">
79
- {error}
80
- </Text>
81
- </Collapse>
82
- <Input
83
- onChange={e => onChange(e.target.value)}
84
- placeholder="Handle or URL"
85
- width="100%"
86
- value={value}
87
- size="md"
88
- />
89
- </VStack>
90
- </PopoverBody>
91
- </PopoverContent>
92
- </Popover>
93
- )
94
- }
95
- export const SocialMediaComponent = forwardRef<InputRef, FieldProps<SocialMediaField>>(
96
- (props: FieldProps<SocialMediaField>, ref: ForwardedRef<InputRef>) => {
97
- const {
98
- input: { value, onChange },
99
- field: { sites },
100
- } = props
101
- const handleChange = useCallback(
102
- (site: SocialMediaSites, v?: string) => {
103
- const { [site]: _curr, ...rest } = value ?? {}
104
- if (!v && Object.keys(rest).length === 0) {
105
- onChange({ target: { value: undefined } })
106
- }
107
- if (!v) onChange(rest)
108
- onChange({ ...rest, [site]: v })
109
- },
110
- [onChange, value],
111
- )
112
-
113
- useImperativeHandle(ref, () => ({
114
- blur: () => {},
115
- focus: () => {},
116
- }))
117
-
118
- return (
119
- <VStack w="100%" p={1}>
120
- <VStack borderRadius={4} p={2} spacing={0} w="100%">
121
- <Text fontSize="md">Links</Text>
122
- <HStack>
123
- {!sites || sites.facebook ? (
124
- <SocialMediaSiteInput
125
- onChange={v => handleChange('facebook', v)}
126
- site="facebook"
127
- value={value?.facebook}
128
- />
129
- ) : null}
130
- {!sites || sites.instagram ? (
131
- <SocialMediaSiteInput
132
- onChange={v => handleChange('instagram', v)}
133
- site="instagram"
134
- value={value?.instagram}
135
- />
136
- ) : null}
137
- {!sites || sites.twitter ? (
138
- <SocialMediaSiteInput
139
- onChange={v => handleChange('twitter', v)}
140
- site="twitter"
141
- value={value?.twitter}
142
- />
143
- ) : null}
144
- {!sites || sites.youtube ? (
145
- <SocialMediaSiteInput
146
- onChange={v => handleChange('youtube', v)}
147
- site="youtube"
148
- value={value?.youtube}
149
- />
150
- ) : null}
151
- {!sites || sites.soundcloud ? (
152
- <SocialMediaSiteInput
153
- onChange={v => handleChange('soundcloud', v)}
154
- site="soundcloud"
155
- value={value?.soundcloud}
156
- />
157
- ) : null}
158
- </HStack>
159
- </VStack>
160
- </VStack>
161
- )
162
- },
163
- )
164
-
165
- SocialMediaComponent.displayName = 'SocialMediaComponent'
@@ -1,78 +0,0 @@
1
- import { ViewIcon, ViewOffIcon } from '@chakra-ui/icons'
2
- import { IconButton, Input } from '@chakra-ui/react'
3
- import { InputRef } from '@chem-po/core'
4
- import { TextField } from '@chem-po/react'
5
- import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react'
6
- import { useInputStyles } from '../hooks'
7
- import { InputContainer } from '../shared/InputContainer'
8
- import { FieldProps } from '../types'
9
- import { TextAreaComponent } from './textarea'
10
-
11
- export const TextComponent = forwardRef<InputRef, FieldProps<TextField>>(
12
- ({ input, inEditable, meta, field, formSize }, ref) => {
13
- const { placeholder, type } = field
14
- const [isHidden, setIsHidden] = useState(type === 'password')
15
- const { text, container } = useInputStyles(inEditable, field.size, formSize)
16
- const { value } = input
17
- const inputRef = useRef<HTMLInputElement | HTMLTextAreaElement>(null)
18
-
19
- useImperativeHandle(ref, () => ({
20
- focus: () => {
21
- inputRef.current?.focus()
22
- },
23
- blur: () => {
24
- inputRef.current?.blur()
25
- },
26
- }))
27
- const body =
28
- type === 'textarea' ? (
29
- <TextAreaComponent inEditable={inEditable} field={field} input={input} meta={meta} />
30
- ) : (
31
- <Input
32
- ref={inputRef as any}
33
- border="none"
34
- _dark={{
35
- border: 'none',
36
- }}
37
- borderRadius={0}
38
- background="transparent"
39
- _focus={{
40
- border: 'none',
41
- boxShadow: 'none',
42
- }}
43
- py={0}
44
- px={0}
45
- height="auto"
46
- outline="none"
47
- type={isHidden ? 'password' : 'text'}
48
- placeholder={placeholder}
49
- style={text}
50
- {...input}
51
- onChange={e => {
52
- input.onChange({ target: { value: e.target.value } })
53
- }}
54
- value={value ?? ''}
55
- />
56
- )
57
-
58
- return (
59
- <InputContainer style={container}>
60
- {body}
61
- {type === 'password' && (
62
- <IconButton
63
- position="absolute"
64
- right={2}
65
- onClick={() => setIsHidden(!isHidden)}
66
- variant="ghost"
67
- icon={isHidden ? <ViewIcon /> : <ViewOffIcon />}
68
- aria-label={isHidden ? 'show' : 'hide'}
69
- title={isHidden ? 'Show' : 'Hide'}
70
- size="xs"
71
- />
72
- )}
73
- </InputContainer>
74
- )
75
- },
76
- )
77
-
78
- TextComponent.displayName = 'TextComponent'
@@ -1,43 +0,0 @@
1
- import { InputRef } from '@chem-po/core'
2
- import { TextField, useTextColor } from '@chem-po/react'
3
- import React, { ForwardedRef, forwardRef, useImperativeHandle, useRef } from 'react'
4
- import TextareaAutosize from 'react-textarea-autosize'
5
- import { FieldProps } from '../types'
6
-
7
- export const TextAreaComponent = forwardRef<InputRef, FieldProps<TextField>>(
8
- ({ input, field, inEditable }, ref: ForwardedRef<InputRef>) => {
9
- const textColor = useTextColor()
10
- const inputRef = useRef<HTMLTextAreaElement>(null)
11
- useImperativeHandle(ref, () => ({
12
- focus: () => {
13
- inputRef.current?.focus()
14
- },
15
- blur: () => {
16
- inputRef.current?.blur()
17
- },
18
- }))
19
- return (
20
- <TextareaAutosize
21
- placeholder={field.placeholder}
22
- minRows={2}
23
- maxRows={5}
24
- ref={inputRef}
25
- style={{
26
- // height: 'auto',
27
- resize: 'none',
28
- width: '100%',
29
- color: textColor,
30
- background: 'none',
31
- fontFamily: 'fonts.body',
32
- boxSizing: 'border-box',
33
- borderRadius: '4px',
34
- border: 'none',
35
- outline: 'none',
36
- }}
37
- {...input}
38
- />
39
- )
40
- },
41
- )
42
-
43
- TextAreaComponent.displayName = 'TextAreaComponent'
@@ -1,33 +0,0 @@
1
- import { Input } from '@chakra-ui/react'
2
- import { InputRef } from '@chem-po/core'
3
- import { TimeField } from '@chem-po/react'
4
- import React, { forwardRef, useImperativeHandle } from 'react'
5
- import { FieldProps } from '../types'
6
- // import '../input.css'
7
-
8
- export const TimeInput = forwardRef<InputRef, FieldProps<TimeField>>(
9
- ({ field, input }: FieldProps<TimeField>, ref) => {
10
- useImperativeHandle(ref, () => ({
11
- focus: () => {},
12
- blur: () => {},
13
- }))
14
- return (
15
- <Input
16
- fontFamily="Public Sans"
17
- css={`
18
- ::-webkit-calendar-picker-indicator {
19
- background: url(/svg/clock.svg) center/80% no-repeat;
20
- color: white;
21
- }
22
- `}
23
- fontSize="md"
24
- type="time"
25
- placeholder={field.placeholder}
26
- {...input}
27
- value={input.value ?? ''}
28
- />
29
- )
30
- },
31
- )
32
-
33
- TimeInput.displayName = 'TimeInput'
File without changes
@@ -1,4 +0,0 @@
1
- import { BaseFieldProps, Field } from '@chem-po/react'
2
- import { CSSProperties } from 'react'
3
-
4
- export type FieldProps<T extends Field> = BaseFieldProps<CSSProperties, CSSProperties, T>
@@ -1,36 +0,0 @@
1
- import { Box, Flex, Text } from '@chakra-ui/react'
2
- import { ImageViewOptions } from '@chem-po/core'
3
- import { FileField } from '@chem-po/react'
4
- import React, { useMemo } from 'react'
5
- import { ExpandOnMount } from '../../box/ExpandOnMount'
6
- import { FileView } from '../input/file'
7
- import { FieldViewProps } from './types'
8
-
9
- export const FileFieldView = ({ field, value, noLabel, style }: FieldViewProps<FileField>) => {
10
- const { imageOptions, placeholder } = field
11
- const options = useMemo<ImageViewOptions>(
12
- () => ({
13
- height: 150,
14
- ...imageOptions,
15
- }),
16
- [imageOptions],
17
- )
18
- return (
19
- <Flex flexFlow={value ? 'column' : 'row'} style={style}>
20
- {noLabel ? null : (
21
- <Text pr={2} opacity={0.7} fontWeight={600}>
22
- {placeholder}
23
- </Text>
24
- )}
25
- {value ? (
26
- <ExpandOnMount>
27
- <Box p={1}>
28
- <FileView imageOptions={options} value={value} />
29
- </Box>
30
- </ExpandOnMount>
31
- ) : (
32
- <Text opacity={0.7}>None</Text>
33
- )}
34
- </Flex>
35
- )
36
- }