@chem-po/react-web 0.0.44 → 0.0.45
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chem-po/react-web",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.45",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"react-window-infinite-loader": "^1.0.9",
|
|
41
41
|
"@hello-pangea/dnd": "^18.0.1",
|
|
42
42
|
"zustand": "^4.3.3",
|
|
43
|
-
"@chem-po/core": "0.0.
|
|
44
|
-
"@chem-po/react": "0.0.
|
|
43
|
+
"@chem-po/core": "0.0.45",
|
|
44
|
+
"@chem-po/react": "0.0.45"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "~19.1.0",
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
useColorModeValue,
|
|
9
9
|
useEditable,
|
|
10
10
|
} from '@chem-po/react'
|
|
11
|
-
import React, { CSSProperties, useCallback, useEffect
|
|
11
|
+
import React, { CSSProperties, useCallback, useEffect } from 'react'
|
|
12
12
|
import { CustomInputProps } from '../../../types/forms'
|
|
13
13
|
import { LoadingOverlay } from '../../loading/Loading'
|
|
14
14
|
import { UploadProgress } from '../UploadProgress'
|
|
@@ -30,7 +30,7 @@ export const Editable = <T extends Field>({
|
|
|
30
30
|
}: EditableProps<CSSProperties, CSSProperties, T>) => {
|
|
31
31
|
const {
|
|
32
32
|
inputRef,
|
|
33
|
-
|
|
33
|
+
onChange,
|
|
34
34
|
isLoading,
|
|
35
35
|
uploads,
|
|
36
36
|
editHovered,
|
|
@@ -39,6 +39,7 @@ export const Editable = <T extends Field>({
|
|
|
39
39
|
isEditing,
|
|
40
40
|
value,
|
|
41
41
|
setEditHovered,
|
|
42
|
+
shouldSubmitOnChange,
|
|
42
43
|
submit,
|
|
43
44
|
submitValue,
|
|
44
45
|
} = useEditable({
|
|
@@ -49,10 +50,7 @@ export const Editable = <T extends Field>({
|
|
|
49
50
|
onEditOpen,
|
|
50
51
|
onEditClose,
|
|
51
52
|
})
|
|
52
|
-
|
|
53
|
-
() => field && (field._type === 'file' || field._type === 'boolean'),
|
|
54
|
-
[field],
|
|
55
|
-
)
|
|
53
|
+
|
|
56
54
|
useEffect(() => {
|
|
57
55
|
if (isEditing) {
|
|
58
56
|
inputRef.current?.focus()
|
|
@@ -98,21 +96,21 @@ export const Editable = <T extends Field>({
|
|
|
98
96
|
border={`1px dashed ${isEditing ? editingBorderColor : 'transparent'}`}
|
|
99
97
|
flex={1}
|
|
100
98
|
minW="0">
|
|
101
|
-
{isEditing ||
|
|
99
|
+
{isEditing || shouldSubmitOnChange ? (
|
|
102
100
|
<RenderInput
|
|
103
101
|
ref={inputRef}
|
|
104
102
|
value={value}
|
|
105
103
|
inEditable
|
|
106
104
|
style={{ padding: 0, ...style }}
|
|
107
105
|
size={size}
|
|
108
|
-
onChange={
|
|
106
|
+
onChange={shouldSubmitOnChange ? v => void submitValue(v) : onChange}
|
|
109
107
|
inputStyle={style}
|
|
110
108
|
/>
|
|
111
109
|
) : (
|
|
112
110
|
<RenderView inEditable size={size} value={value} />
|
|
113
111
|
)}
|
|
114
112
|
</Flex>
|
|
115
|
-
{
|
|
113
|
+
{shouldSubmitOnChange ? null : (
|
|
116
114
|
<>
|
|
117
115
|
<IconButton
|
|
118
116
|
aria-label="Edit"
|
|
@@ -122,7 +120,7 @@ export const Editable = <T extends Field>({
|
|
|
122
120
|
onMouseLeave={() => setEditHovered(false)}
|
|
123
121
|
onClick={() => {
|
|
124
122
|
if (isEditing) {
|
|
125
|
-
|
|
123
|
+
onChange(value)
|
|
126
124
|
handleEditClose()
|
|
127
125
|
} else handleEditOpen()
|
|
128
126
|
}}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Checkbox, Flex, Switch, Text } from '@chakra-ui/react'
|
|
2
2
|
import { InputRef } from '@chem-po/core'
|
|
3
|
-
import { BooleanField } from '@chem-po/react'
|
|
3
|
+
import { BooleanField, useBooleanFieldText } from '@chem-po/react'
|
|
4
4
|
import React, { ForwardedRef, forwardRef, useImperativeHandle } from 'react'
|
|
5
5
|
import { FieldProps } from '../types'
|
|
6
6
|
|
|
@@ -8,14 +8,14 @@ const BaseCheckboxComponent = (
|
|
|
8
8
|
{ field, input: { onChange, value, ...input } }: FieldProps<BooleanField>,
|
|
9
9
|
ref: ForwardedRef<InputRef>,
|
|
10
10
|
) => {
|
|
11
|
-
const { placeholder } = field
|
|
12
11
|
useImperativeHandle(ref, () => ({
|
|
13
12
|
focus: () => {},
|
|
14
13
|
blur: () => {},
|
|
15
14
|
}))
|
|
15
|
+
const text = useBooleanFieldText(field, value)
|
|
16
16
|
return (
|
|
17
17
|
<Checkbox isChecked={value} onChange={e => onChange(e.target.checked)} {...input}>
|
|
18
|
-
{
|
|
18
|
+
{text}
|
|
19
19
|
</Checkbox>
|
|
20
20
|
)
|
|
21
21
|
}
|
|
@@ -28,16 +28,16 @@ const BaseSwitchComponent = (
|
|
|
28
28
|
{ field, input: { onChange, value, ...input } }: FieldProps<BooleanField>,
|
|
29
29
|
ref: ForwardedRef<InputRef>,
|
|
30
30
|
) => {
|
|
31
|
-
const { placeholder } = field
|
|
32
31
|
useImperativeHandle(ref, () => ({
|
|
33
32
|
focus: () => {},
|
|
34
33
|
blur: () => {},
|
|
35
34
|
}))
|
|
35
|
+
const text = useBooleanFieldText(field, value)
|
|
36
36
|
return (
|
|
37
37
|
<Flex gap={1} align="center">
|
|
38
38
|
<Switch isChecked={value} onChange={e => onChange(e.target.checked)} {...input} />
|
|
39
39
|
<Text fontWeight={600} opacity={value ? 0.9 : 0.6}>
|
|
40
|
-
{
|
|
40
|
+
{text}
|
|
41
41
|
</Text>
|
|
42
42
|
</Flex>
|
|
43
43
|
)
|