@manuscripts/style-guide 3.6.0 → 3.6.2
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.
|
@@ -84,9 +84,13 @@ const Input = styled_components_1.default.input `
|
|
|
84
84
|
|
|
85
85
|
&::-moz-appearance: textfield;
|
|
86
86
|
`;
|
|
87
|
-
const MultiValueInput = ({ id, inputType, placeholder = '', initialValues
|
|
88
|
-
const [values, setValues] = (0, react_1.useState)(initialValues);
|
|
87
|
+
const MultiValueInput = ({ id, inputType, placeholder = '', initialValues, onChange, }) => {
|
|
88
|
+
const [values, setValues] = (0, react_1.useState)(initialValues ?? []);
|
|
89
89
|
const [currentValue, setCurrentValue] = (0, react_1.useState)('');
|
|
90
|
+
(0, react_1.useEffect)(() => {
|
|
91
|
+
setValues(initialValues ?? []);
|
|
92
|
+
setCurrentValue('');
|
|
93
|
+
}, [initialValues]);
|
|
90
94
|
const handleAddValue = (value) => {
|
|
91
95
|
if (value.trim() && !values.includes(value.trim())) {
|
|
92
96
|
const updatedValues = [...values, value.trim()];
|
|
@@ -34,7 +34,7 @@ const selectStyles = (theme, error, variant, listMaxHeight) => ({
|
|
|
34
34
|
: theme.colors.text.greyMuted || theme.colors.text.secondary,
|
|
35
35
|
backgroundColor: !state.isDisabled ? '#F2FBFC' : 'transparent',
|
|
36
36
|
},
|
|
37
|
-
padding: state.isFocused ? '0 7px' : '0 8px',
|
|
37
|
+
padding: state.isFocused ? '0 1px 0 7px' : '0 2px 0 8px',
|
|
38
38
|
backgroundColor: state.isDisabled
|
|
39
39
|
? '#F5F5F5'
|
|
40
40
|
: state.isFocused
|
|
@@ -46,7 +46,7 @@ const selectStyles = (theme, error, variant, listMaxHeight) => ({
|
|
|
46
46
|
}),
|
|
47
47
|
valueContainer: (base) => ({
|
|
48
48
|
...base,
|
|
49
|
-
padding: '0 8px',
|
|
49
|
+
padding: '0 2px 0 8px',
|
|
50
50
|
}),
|
|
51
51
|
singleValue: (base, state) => ({
|
|
52
52
|
...base,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from 'react';
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { commonStyles } from './TextField';
|
|
5
5
|
const Container = styled.div `
|
|
@@ -78,9 +78,13 @@ const Input = styled.input `
|
|
|
78
78
|
|
|
79
79
|
&::-moz-appearance: textfield;
|
|
80
80
|
`;
|
|
81
|
-
export const MultiValueInput = ({ id, inputType, placeholder = '', initialValues
|
|
82
|
-
const [values, setValues] = useState(initialValues);
|
|
81
|
+
export const MultiValueInput = ({ id, inputType, placeholder = '', initialValues, onChange, }) => {
|
|
82
|
+
const [values, setValues] = useState(initialValues ?? []);
|
|
83
83
|
const [currentValue, setCurrentValue] = useState('');
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
setValues(initialValues ?? []);
|
|
86
|
+
setCurrentValue('');
|
|
87
|
+
}, [initialValues]);
|
|
84
88
|
const handleAddValue = (value) => {
|
|
85
89
|
if (value.trim() && !values.includes(value.trim())) {
|
|
86
90
|
const updatedValues = [...values, value.trim()];
|
|
@@ -28,7 +28,7 @@ const selectStyles = (theme, error, variant, listMaxHeight) => ({
|
|
|
28
28
|
: theme.colors.text.greyMuted || theme.colors.text.secondary,
|
|
29
29
|
backgroundColor: !state.isDisabled ? '#F2FBFC' : 'transparent',
|
|
30
30
|
},
|
|
31
|
-
padding: state.isFocused ? '0 7px' : '0 8px',
|
|
31
|
+
padding: state.isFocused ? '0 1px 0 7px' : '0 2px 0 8px',
|
|
32
32
|
backgroundColor: state.isDisabled
|
|
33
33
|
? '#F5F5F5'
|
|
34
34
|
: state.isFocused
|
|
@@ -40,7 +40,7 @@ const selectStyles = (theme, error, variant, listMaxHeight) => ({
|
|
|
40
40
|
}),
|
|
41
41
|
valueContainer: (base) => ({
|
|
42
42
|
...base,
|
|
43
|
-
padding: '0 8px',
|
|
43
|
+
padding: '0 2px 0 8px',
|
|
44
44
|
}),
|
|
45
45
|
singleValue: (base, state) => ({
|
|
46
46
|
...base,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/style-guide",
|
|
3
3
|
"description": "Shared components for Manuscripts applications",
|
|
4
|
-
"version": "3.6.
|
|
4
|
+
"version": "3.6.2",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-style-guide",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|