@dtdot/lego 0.17.3 → 0.17.4
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.
|
@@ -69,6 +69,9 @@ const LiveList = ({ value: inputValue, name, onChange: propsOnChange }) => {
|
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
71
|
const focusedIndex = value.findIndex((val) => val.id === focusedId);
|
|
72
|
+
if (focusedIndex === 0) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
72
75
|
const prevId = focusedIndex > 0 ? value[focusedIndex - 1].id : undefined;
|
|
73
76
|
wrappedOnChange(value.filter((val) => val.id !== focusedId));
|
|
74
77
|
if (prevId) {
|
|
@@ -3,5 +3,6 @@ import { Meta } from '@storybook/react/types-6-0';
|
|
|
3
3
|
export declare const Standard: () => JSX.Element;
|
|
4
4
|
export declare const InForm: () => JSX.Element;
|
|
5
5
|
export declare const WithValidation: () => JSX.Element;
|
|
6
|
+
export declare const EmptyList: () => JSX.Element;
|
|
6
7
|
declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
|
|
7
8
|
export default _default;
|
|
@@ -44,6 +44,13 @@ export const WithValidation = () => {
|
|
|
44
44
|
React.createElement(Button, { onClick: clear }, "Clear"),
|
|
45
45
|
React.createElement(Button, { onClick: validate }, "Set Errors"))));
|
|
46
46
|
};
|
|
47
|
+
export const EmptyList = () => {
|
|
48
|
+
const [value, setValue] = useState({});
|
|
49
|
+
return (React.createElement(React.Fragment, null,
|
|
50
|
+
React.createElement(Heading.FormHeading, null, "Ingredients"),
|
|
51
|
+
React.createElement(Spacer, { size: '1x' }),
|
|
52
|
+
React.createElement(LiveList, { value: value, onChange: setValue })));
|
|
53
|
+
};
|
|
47
54
|
export default {
|
|
48
55
|
title: 'Components/LiveList',
|
|
49
56
|
component: LiveList,
|
|
@@ -60,7 +60,7 @@ const LiveListRow = ({ id, value, error, onChange, onRemove }) => {
|
|
|
60
60
|
onBlur(id);
|
|
61
61
|
};
|
|
62
62
|
return (React.createElement(InputContainer, { whileHover: 'hover' },
|
|
63
|
-
React.createElement(Input, { onFocus: handleFocus, onBlur: handleBlur, ref: inputRef, value: value, error: error, onChange: handleChange }),
|
|
63
|
+
React.createElement(Input, { onFocus: handleFocus, onBlur: handleBlur, ref: inputRef, value: value || '', error: error, onChange: handleChange }),
|
|
64
64
|
React.createElement(RemoveContainer, { animate: isFocused ? 'focus' : undefined, style: { opacity: 0 }, variants: removeVariants, transition: { type: 'spring', duration: 0.3 } },
|
|
65
65
|
React.createElement(RemoveInner, { onClick: onRemove },
|
|
66
66
|
React.createElement(FontAwesomeIcon, { icon: faTimes })))));
|