@mrshmllw/smores-react 1.2.10 → 1.2.15
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/dist/ConfirmationRadioButtons/Confirmation.d.ts +11 -0
- package/dist/ConfirmationRadioButtons/Confirmation.js +63 -0
- package/dist/ConfirmationRadioButtons/Confirmation.js.map +1 -0
- package/dist/ConfirmationRadioButtons/Confirmation.stories.d.ts +14 -0
- package/dist/ConfirmationRadioButtons/Confirmation.stories.js +28 -0
- package/dist/ConfirmationRadioButtons/Confirmation.stories.js.map +1 -0
- package/dist/ConfirmationRadioButtons/Container.d.ts +2 -0
- package/dist/ConfirmationRadioButtons/Container.js +8 -0
- package/dist/ConfirmationRadioButtons/Container.js.map +1 -0
- package/dist/ConfirmationRadioButtons/RadioButtonStyled.d.ts +14 -0
- package/dist/ConfirmationRadioButtons/RadioButtonStyled.js +41 -0
- package/dist/ConfirmationRadioButtons/RadioButtonStyled.js.map +1 -0
- package/dist/ConfirmationRadioButtons/__tests__/Confirmation.d.ts +1 -0
- package/dist/ConfirmationRadioButtons/__tests__/Confirmation.js +8 -0
- package/dist/ConfirmationRadioButtons/__tests__/Confirmation.js.map +1 -0
- package/dist/ConfirmationRadioButtons/index.d.ts +1 -0
- package/dist/ConfirmationRadioButtons/index.js +2 -0
- package/dist/ConfirmationRadioButtons/index.js.map +1 -0
- package/dist/Dropdown/Dropdown.d.ts +27 -4
- package/dist/Dropdown/Dropdown.js +25 -4
- package/dist/Dropdown/Dropdown.js.map +1 -1
- package/dist/Dropdown/Dropdown.stories.d.ts +2 -0
- package/dist/Dropdown/Dropdown.stories.js +20 -0
- package/dist/Dropdown/Dropdown.stories.js.map +1 -1
- package/dist/Textarea/Textarea.d.ts +19 -4
- package/dist/Textarea/Textarea.js +7 -2
- package/dist/Textarea/Textarea.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/ActionDropdown/__tests__/__snapshots__/ActionDropdown.js.snap +0 -167
- package/dist/Box/__tests__/__snapshots__/Box.js.snap +0 -20
- package/dist/Button/__tests__/__snapshots__/Button.js.snap +0 -46
- package/dist/Card/__tests__/__snapshots__/Card.js.snap +0 -24
- package/dist/CheckBox/__tests__/__snapshots__/CheckBox.js.snap +0 -20
- package/dist/Dropdown/__tests__/__snapshots__/Dropdown.js.snap +0 -168
- package/dist/Emoji/__tests__/__snapshots__/Emoji.js.snap +0 -20
- package/dist/Icon/__tests__/__snapshots__/Icon.js.snap +0 -47
- package/dist/IconWrapper/__tests__/__snapshots__/IconWrapper.js.snap +0 -121
- package/dist/LabelledText/__tests__/__snapshots__/LabelledText.js.snap +0 -57
- package/dist/Loader/__tests__/__snapshots__/Loader.js.snap +0 -53
- package/dist/Message/__tests__/__snapshots__/Message.js.snap +0 -278
- package/dist/Modal/__tests__/__snapshots__/Modal.js.snap +0 -208
- package/dist/NumberInput/__tests__/__snapshots__/NumberInput.js.snap +0 -1348
- package/dist/Pagination/__tests__/__snapshots__/Pagination.js.snap +0 -273
- package/dist/RadioButton/__tests__/__snapshots__/RadioButton.js.snap +0 -146
- package/dist/Row/__tests__/__snapshots__/Row.js.snap +0 -96
- package/dist/SearchInput/__tests__/__snapshots__/SearchInput.js.snap +0 -153
- package/dist/Tag/__tests__/__snapshots__/Tag.js.snap +0 -54
- package/dist/Text/__tests__/__snapshots__/Text.js.snap +0 -34
- package/dist/TextInput/__tests__/__snapshots__/TextInput.js.snap +0 -75
- package/dist/Textarea/__tests__/__snapshots__/Textarea.js.snap +0 -271
- package/dist/Toggle/__tests__/__snapshots__/Toggle.js.snap +0 -70
@@ -0,0 +1,11 @@
|
|
1
|
+
import { FC } from 'react';
|
2
|
+
declare type ConfirmationProps = {
|
3
|
+
onChange(value?: boolean): void;
|
4
|
+
checked?: boolean;
|
5
|
+
id: string;
|
6
|
+
error?: boolean;
|
7
|
+
errorMsg?: string;
|
8
|
+
label: string;
|
9
|
+
};
|
10
|
+
export declare const Confirmation: FC<ConfirmationProps>;
|
11
|
+
export {};
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import styled from 'styled-components';
|
3
|
+
import { theme } from '../theme';
|
4
|
+
import { Box } from '../Box';
|
5
|
+
import { Text } from '../Text';
|
6
|
+
import { RadioButton } from './RadioButtonStyled';
|
7
|
+
export const Confirmation = ({ checked, onChange, id, error = false, errorMsg = '', label, }) => {
|
8
|
+
return (React.createElement(ConfirmationWrapper, null,
|
9
|
+
React.createElement(SectionHeadingText, { tag: "h3" }, label),
|
10
|
+
React.createElement(RadioButtonGroupWrapper, null,
|
11
|
+
React.createElement(RadioButtonGroup, null,
|
12
|
+
React.createElement(RadioButtonWrapper, { checked: checked === true, error: error },
|
13
|
+
React.createElement(RadioButton, { id: id, label: "Yes", checked: checked === true, onChange: () => onChange(true), value: id })),
|
14
|
+
React.createElement(RadioButtonWrapper, { checked: checked === false, error: error },
|
15
|
+
React.createElement(RadioButton, { id: `${id}-1`, label: "No", checked: checked === false, onChange: () => onChange(false), value: `${id}-1` }))),
|
16
|
+
error && React.createElement(ErrorBox, null, errorMsg))));
|
17
|
+
};
|
18
|
+
const RadioButtonGroupWrapper = styled.div `
|
19
|
+
display: flex;
|
20
|
+
flex-direction: column;
|
21
|
+
`;
|
22
|
+
const RadioButtonGroup = styled.div `
|
23
|
+
display: flex;
|
24
|
+
flex-direction: row;
|
25
|
+
`;
|
26
|
+
const getColor = (checked, error) => {
|
27
|
+
if (error) {
|
28
|
+
return `2px solid ${theme.colors.red7}`;
|
29
|
+
}
|
30
|
+
else if (checked) {
|
31
|
+
return `2px solid ${theme.colors.blue7}`;
|
32
|
+
}
|
33
|
+
else {
|
34
|
+
return 'none';
|
35
|
+
}
|
36
|
+
};
|
37
|
+
const RadioButtonWrapper = styled.div `
|
38
|
+
background-color: ${({ checked }) => !checked && `${theme.colors.bg4}`};
|
39
|
+
border: ${({ checked, error }) => getColor(checked, error)};
|
40
|
+
margin: 0px 10px;
|
41
|
+
width: 139px;
|
42
|
+
display: flex;
|
43
|
+
align-items: center;
|
44
|
+
height: 49px;
|
45
|
+
padding-left: 12px;
|
46
|
+
border-radius: 5px;
|
47
|
+
font-weight: bold;
|
48
|
+
`;
|
49
|
+
const ErrorBox = styled.span `
|
50
|
+
margin-top: 7px;
|
51
|
+
margin-left: 12px;
|
52
|
+
font-size: 12px;
|
53
|
+
color: ${theme.colors.red7};
|
54
|
+
`;
|
55
|
+
const ConfirmationWrapper = styled(Box) `
|
56
|
+
display: grid;
|
57
|
+
grid-template-columns: 2fr 1fr 1fr;
|
58
|
+
`;
|
59
|
+
const SectionHeadingText = styled(Text) `
|
60
|
+
font-weight: bold;
|
61
|
+
padding-bottom: 8px;
|
62
|
+
`;
|
63
|
+
//# sourceMappingURL=Confirmation.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Confirmation.js","sourceRoot":"","sources":["../../src/ConfirmationRadioButtons/Confirmation.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAa,MAAM,OAAO,CAAA;AACjC,OAAO,MAAM,MAAM,mBAAmB,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAa,MAAM,qBAAqB,CAAA;AAW5D,MAAM,CAAC,MAAM,YAAY,GAA0B,CAAC,EAClD,OAAO,EACP,QAAQ,EACR,EAAE,EACF,KAAK,GAAG,KAAK,EACb,QAAQ,GAAG,EAAE,EACb,KAAK,GACa,EAAE,EAAE;IACtB,OAAO,CACL,oBAAC,mBAAmB;QAClB,oBAAC,kBAAkB,IAAC,GAAG,EAAC,IAAI,IAAE,KAAK,CAAsB;QACzD,oBAAC,uBAAuB;YACtB,oBAAC,gBAAgB;gBACf,oBAAC,kBAAkB,I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AAC,GAAG,EAAE;YACzB,CAAC,EAAE,OAAO,EAAE,KAAK,EAAa,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;;;;;;;;;CAStE,CAAA;AAED,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAA;;;;WAIjB,KAAK,CAAC,MAAM,CAAC,IAAI;CAC3B,CAAA;AAED,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;;;CAGtC,CAAA;AAED,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;;CAGtC,CAAA"}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
declare namespace _default {
|
2
|
+
export const title: string;
|
3
|
+
export { Confirmation as component };
|
4
|
+
export namespace argTypes {
|
5
|
+
namespace onChange {
|
6
|
+
const action: string;
|
7
|
+
}
|
8
|
+
}
|
9
|
+
}
|
10
|
+
export default _default;
|
11
|
+
export const Default: any;
|
12
|
+
export const WithError: any;
|
13
|
+
export const WorkingExample: any;
|
14
|
+
import { Confirmation } from "./Confirmation";
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { Confirmation } from './Confirmation';
|
3
|
+
import { Container } from './Container';
|
4
|
+
export default {
|
5
|
+
title: 'Confirmation Radio Buttons',
|
6
|
+
component: Confirmation,
|
7
|
+
argTypes: { onChange: { action: 'clicked' } },
|
8
|
+
};
|
9
|
+
const Template = (args) => React.createElement(Confirmation, Object.assign({}, args));
|
10
|
+
export const Default = Template.bind({});
|
11
|
+
Default.args = {
|
12
|
+
id: 'radioButton',
|
13
|
+
onChange: () => { },
|
14
|
+
checked: false,
|
15
|
+
label: 'Do you like marshmallows?',
|
16
|
+
};
|
17
|
+
export const WithError = Template.bind({});
|
18
|
+
WithError.args = {
|
19
|
+
id: 'radioButton',
|
20
|
+
onChange: () => { },
|
21
|
+
checked: undefined,
|
22
|
+
label: 'Do you like marshmallows?',
|
23
|
+
error: true,
|
24
|
+
errorMsg: 'This field is required.',
|
25
|
+
};
|
26
|
+
const ContainerTemplate = (args) => React.createElement(Container, Object.assign({}, args));
|
27
|
+
export const WorkingExample = ContainerTemplate.bind({});
|
28
|
+
//# sourceMappingURL=Confirmation.stories.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Confirmation.stories.js","sourceRoot":"","sources":["../../src/ConfirmationRadioButtons/Confirmation.stories.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,eAAe;IACb,KAAK,EAAE,4BAA4B;IACnC,SAAS,EAAE,YAAY;IACvB,QAAQ,EAAE,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE;CAC9C,CAAA;AAED,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAC,YAAY,oBAAK,IAAI,EAAI,CAAA;AAErD,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAExC,OAAO,CAAC,IAAI,GAAG;IACb,EAAE,EAAE,aAAa;IACjB,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;IAClB,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,2BAA2B;CACnC,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAE1C,SAAS,CAAC,IAAI,GAAG;IACf,EAAE,EAAE,aAAa;IACjB,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;IAClB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,2BAA2B;IAClC,KAAK,EAAE,IAAI;IACX,QAAQ,EAAE,yBAAyB;CACpC,CAAA;AAED,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAC,SAAS,oBAAK,IAAI,EAAI,CAAA;AAE3D,MAAM,CAAC,MAAM,cAAc,GAAG,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import React, { useState } from 'react';
|
2
|
+
import { Confirmation } from './Confirmation';
|
3
|
+
export const Container = () => {
|
4
|
+
const [checked, setChecked] = useState(undefined);
|
5
|
+
return (React.createElement("form", null,
|
6
|
+
React.createElement(Confirmation, { id: "radioButton", onChange: (selection) => setChecked(selection), checked: checked, label: 'Do you like marshmallows?', error: checked === undefined, errorMsg: "This field is required." })));
|
7
|
+
};
|
8
|
+
//# sourceMappingURL=Container.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Container.js","sourceRoot":"","sources":["../../src/ConfirmationRadioButtons/Container.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE;IAC5B,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAsB,SAAS,CAAC,CAAA;IAEtE,OAAO,CACL;QACE,oBAAC,YAAY,IACX,EAAE,EAAC,aAAa,EAChB,QAAQ,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAC9C,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,2BAA2B,EAClC,KAAK,EAAE,OAAO,KAAK,SAAS,EAC5B,QAAQ,EAAC,yBAAyB,GAClC,CACG,CACR,CAAA;AACH,CAAC,CAAA"}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { FC, ChangeEvent } from 'react';
|
2
|
+
export interface FakeInput {
|
3
|
+
checked?: boolean;
|
4
|
+
error?: boolean;
|
5
|
+
}
|
6
|
+
declare type RadioButtonProps = {
|
7
|
+
id: string;
|
8
|
+
label: string;
|
9
|
+
checked?: boolean;
|
10
|
+
value: string;
|
11
|
+
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
12
|
+
};
|
13
|
+
export declare const RadioButton: FC<RadioButtonProps>;
|
14
|
+
export {};
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import styled from 'styled-components';
|
3
|
+
import { theme } from '../theme';
|
4
|
+
import { Box } from '../Box';
|
5
|
+
export const RadioButton = ({ id, label, checked, value, onChange, }) => (React.createElement(Box, { flex: true, alignItems: "center" },
|
6
|
+
React.createElement(RadioInput, { id: id, type: "radio", checked: checked, value: value, onChange: onChange }),
|
7
|
+
React.createElement(RadioLabel, { htmlFor: id },
|
8
|
+
React.createElement(FakeInput, { checked: checked }),
|
9
|
+
React.createElement(Text, null, label))));
|
10
|
+
const FakeInput = styled.div `
|
11
|
+
width: 24px;
|
12
|
+
height: 24px;
|
13
|
+
border-radius: 50%;
|
14
|
+
background-color: ${theme.colors.white};
|
15
|
+
margin-right: 10px;
|
16
|
+
border: ${({ checked }) => checked
|
17
|
+
? `8px solid ${theme.colors.blue7}`
|
18
|
+
: `1px solid ${theme.colors.blue7}`};
|
19
|
+
`;
|
20
|
+
const RadioInput = styled.input `
|
21
|
+
position: absolute;
|
22
|
+
opacity: 0;
|
23
|
+
height: 0;
|
24
|
+
width: 0;
|
25
|
+
`;
|
26
|
+
const RadioLabel = styled.label `
|
27
|
+
font-family: 'Gordita', sans-serif;
|
28
|
+
text-transform: none;
|
29
|
+
font-size: 16px;
|
30
|
+
line-height: 17px;
|
31
|
+
color: ${theme.colors.blue7};
|
32
|
+
margin-bottom: 0;
|
33
|
+
display: flex;
|
34
|
+
cursor: pointer;
|
35
|
+
`;
|
36
|
+
// needed because the text is top aligned in its viewbox
|
37
|
+
const Text = styled.span `
|
38
|
+
position: relative;
|
39
|
+
bottom: -5px;
|
40
|
+
`;
|
41
|
+
//# sourceMappingURL=RadioButtonStyled.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"RadioButtonStyled.js","sourceRoot":"","sources":["../../src/ConfirmationRadioButtons/RadioButtonStyled.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0B,MAAM,OAAO,CAAA;AAC9C,OAAO,MAAM,MAAM,mBAAmB,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAe5B,MAAM,CAAC,MAAM,WAAW,GAAyB,CAAC,EAChD,EAAE,EACF,KAAK,EACL,OAAO,EACP,KAAK,EACL,QAAQ,GACS,EAAE,EAAE,CAAC,CACtB,oBAAC,GAAG,IAAC,IAAI,QAAC,UAAU,EAAC,QAAQ;IAC3B,oBAAC,UAAU,IACT,EAAE,EAAE,EAAE,EACN,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,GAClB;IACF,oBAAC,UAAU,IAAC,OAAO,EAAE,EAAE;QACrB,oBAAC,SAAS,IAAC,OAAO,EAAE,OAAO,GAAI;QAC/B,oBAAC,IAAI,QAAE,KAAK,CAAQ,CACT,CACT,CACP,CAAA;AAED,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAW;;;;sBAIjB,KAAK,CAAC,MAAM,CAAC,KAAK;;YAE5B,CAAC,EAAE,OAAO,EAAa,EAAE,EAAE,CACnC,OAAO;IACL,CAAC,CAAC,aAAa,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE;IACnC,CAAC,CAAC,aAAa,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE;CACxC,CAAA;AAED,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAA;;;;;CAK9B,CAAA;AAED,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAA;;;;;WAKpB,KAAK,CAAC,MAAM,CAAC,KAAK;;;;CAI5B,CAAA;AAED,wDAAwD;AACxD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;;;CAGvB,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { render } from '@testing-library/react';
|
3
|
+
import { Confirmation } from '../Confirmation';
|
4
|
+
test('renders', () => {
|
5
|
+
const { container } = render(React.createElement(Confirmation, null));
|
6
|
+
expect(container.firstChild).toMatchSnapshot();
|
7
|
+
});
|
8
|
+
//# sourceMappingURL=Confirmation.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Confirmation.js","sourceRoot":"","sources":["../../../src/ConfirmationRadioButtons/__tests__/Confirmation.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;IACnB,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,oBAAC,YAAY,OAAG,CAAC,CAAA;IAC9C,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,eAAe,EAAE,CAAA;AAChD,CAAC,CAAC,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export { Confirmation } from './Confirmation';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ConfirmationRadioButtons/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA"}
|
@@ -1,19 +1,29 @@
|
|
1
|
-
import { FC } from 'react';
|
1
|
+
import { FC, FormEvent, RefObject } from 'react';
|
2
2
|
export declare type DropdownItem = {
|
3
3
|
label: string;
|
4
4
|
value: string;
|
5
5
|
};
|
6
|
-
declare type
|
6
|
+
declare type DefaultProps = {
|
7
7
|
/** ID, usually used for tests */
|
8
8
|
id: string;
|
9
9
|
/** className attribute to apply classes from props */
|
10
10
|
className?: string;
|
11
|
-
/**
|
12
|
-
|
11
|
+
/** ref attribute for select input */
|
12
|
+
ref?: RefObject<HTMLSelectElement>;
|
13
13
|
/** Placeholder (initial state) */
|
14
14
|
placeholder?: string;
|
15
|
+
/** label displayed above the dropdown */
|
16
|
+
label?: string;
|
17
|
+
/** used for label - input connection */
|
18
|
+
name?: string;
|
19
|
+
/** input value */
|
20
|
+
value: string;
|
15
21
|
/** Default value */
|
16
22
|
defaultValue?: string;
|
23
|
+
/** conditionally renders error message below dropdown */
|
24
|
+
error?: boolean;
|
25
|
+
/** error message to be displayed */
|
26
|
+
errorMsg?: string;
|
17
27
|
/** Disabled flag */
|
18
28
|
disabled?: boolean;
|
19
29
|
/** list of items for the dropdown list */
|
@@ -22,6 +32,19 @@ declare type Props = {
|
|
22
32
|
onSelect: (element: string) => void;
|
23
33
|
/** Displays border */
|
24
34
|
outlined?: boolean;
|
35
|
+
/** onBlur listener */
|
36
|
+
onBlur?: (e: FormEvent<HTMLSelectElement>) => void;
|
37
|
+
};
|
38
|
+
/** on change or on input required */
|
39
|
+
declare type TruncateProps = {
|
40
|
+
/** on change is required and on input optional */
|
41
|
+
onSelect: (e: string) => void;
|
42
|
+
onInputChange?: (e: FormEvent<HTMLSelectElement>) => void;
|
43
|
+
} | {
|
44
|
+
/** on input is required and on change optional */
|
45
|
+
onSelect?: (e: string) => void;
|
46
|
+
onInputChange: (e: FormEvent<HTMLSelectElement>) => void;
|
25
47
|
};
|
48
|
+
declare type Props = DefaultProps & TruncateProps;
|
26
49
|
export declare const Dropdown: FC<Props>;
|
27
50
|
export {};
|
@@ -4,7 +4,7 @@ import { Text } from '../Text';
|
|
4
4
|
import { Icon } from '../Icon';
|
5
5
|
import { Box } from '../Box';
|
6
6
|
import { theme } from '../theme';
|
7
|
-
export const Dropdown = ({ id, className = '', label, placeholder, defaultValue, disabled = false, list, onSelect, outlined = false, }) => {
|
7
|
+
export const Dropdown = ({ id, className = '', ref, label, placeholder, name, value, defaultValue, disabled = false, list, onSelect, outlined = false, error = false, errorMsg = '', onInputChange, onBlur, }) => {
|
8
8
|
const [key, setKey] = useState('');
|
9
9
|
useEffect(() => {
|
10
10
|
if (list.length === 1) {
|
@@ -22,12 +22,16 @@ export const Dropdown = ({ id, className = '', label, placeholder, defaultValue,
|
|
22
22
|
: defaultValue
|
23
23
|
? defaultValue
|
24
24
|
: placeholder, disabled: disabled || list.length < 1, onChange: (e) => {
|
25
|
-
onSelect(e.currentTarget.value);
|
26
|
-
|
25
|
+
onSelect && onSelect(e.currentTarget.value);
|
26
|
+
onInputChange && onInputChange(e);
|
27
|
+
}, required: true, outlined: outlined, error: error, ref: ref, onBlur: (e) => {
|
28
|
+
onBlur && onBlur(e);
|
29
|
+
}, name: name, value: value },
|
27
30
|
React.createElement("option", { value: "", hidden: true }, placeholder),
|
28
31
|
list.map((el, i) => (React.createElement("option", { key: i, value: el.value }, el.label)))),
|
29
32
|
React.createElement(Caret, { outlined: outlined },
|
30
|
-
React.createElement(Icon, { render: "caret", color: "grey4", size: 24 })))
|
33
|
+
React.createElement(Icon, { render: "caret", color: "grey4", size: 24 }))),
|
34
|
+
error && React.createElement(ErrorBox, null, errorMsg)));
|
31
35
|
};
|
32
36
|
const Container = styled.div `
|
33
37
|
display: flex;
|
@@ -41,6 +45,17 @@ const Content = styled.div `
|
|
41
45
|
width: 100%;
|
42
46
|
position: relative;
|
43
47
|
`;
|
48
|
+
const getErrorOutline = (outlined, error) => {
|
49
|
+
if (error && outlined) {
|
50
|
+
return `border: 2px solid ${theme.colors.red7}`;
|
51
|
+
}
|
52
|
+
else if (error && !outlined) {
|
53
|
+
return `border-bottom: 2px solid ${theme.colors.red7}`;
|
54
|
+
}
|
55
|
+
else {
|
56
|
+
return;
|
57
|
+
}
|
58
|
+
};
|
44
59
|
const Select = styled.select `
|
45
60
|
width: 100%;
|
46
61
|
height: 32px;
|
@@ -61,6 +76,7 @@ const Select = styled.select `
|
|
61
76
|
box-sizing: border-box;
|
62
77
|
height: auto;
|
63
78
|
`}
|
79
|
+
${({ error, outlined }) => getErrorOutline(outlined, error)};
|
64
80
|
|
65
81
|
&:disabled {
|
66
82
|
cursor: not-allowed;
|
@@ -88,4 +104,9 @@ const Caret = styled.div `
|
|
88
104
|
pointer-events: none;
|
89
105
|
transform: translateY(-50%);
|
90
106
|
`;
|
107
|
+
const ErrorBox = styled.span `
|
108
|
+
margin-top: 7px;
|
109
|
+
font-size: 12px;
|
110
|
+
color: ${theme.colors.red7};
|
111
|
+
`;
|
91
112
|
//# sourceMappingURL=Dropdown.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Dropdown.js","sourceRoot":"","sources":["../../src/Dropdown/Dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAM,SAAS,EAAE,QAAQ,
|
1
|
+
{"version":3,"file":"Dropdown.js","sourceRoot":"","sources":["../../src/Dropdown/Dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAM,SAAS,EAAE,QAAQ,EAAwB,MAAM,OAAO,CAAA;AAC5E,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAEtC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAE5B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AA4DhC,MAAM,CAAC,MAAM,QAAQ,GAAc,CAAC,EAClC,EAAE,EACF,SAAS,GAAG,EAAE,EACd,GAAG,EACH,KAAK,EACL,WAAW,EACX,IAAI,EACJ,KAAK,EACL,YAAY,EACZ,QAAQ,GAAG,KAAK,EAChB,IAAI,EACJ,QAAQ,EACR,QAAQ,GAAG,KAAK,EAChB,KAAK,GAAG,KAAK,EAC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CAAC,IAAI,EAAE,CAAA;KACvD;SAAM;QACL,OAAM;KACP;AACH,CAAC,CAAA;AAED,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAc;;;;sBAIpB,KAAK,CAAC,MAAM,CAAC,KAAK;;mBAErB,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAChC,CAAC,QAAQ,IAAI,aAAa,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE;;;;;;IAM9C,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CACjB,QAAQ;IACR;wBACoB,KAAK,CAAC,MAAM,CAAC,KAAK;;;;;GAKvC;IACC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,CAAC;;;;;;;;aAQhD,KAAK,CAAC,MAAM,CAAC,KAAK;;;;;;;;;oBASX,KAAK,CAAC,MAAM,CAAC,KAAK;;CAErC,CAAA;AAED,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAc;;;;WAI3B,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;;;CAGrD,CAAA;AAED,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAA;;;WAGjB,KAAK,CAAC,MAAM,CAAC,IAAI;CAC3B,CAAA"}
|
@@ -14,5 +14,7 @@ export const Disabled: any;
|
|
14
14
|
export const SingleListItem: any;
|
15
15
|
export const EmptyList: any;
|
16
16
|
export const WithOutline: any;
|
17
|
+
export const OutlineWithError: any;
|
18
|
+
export const WithError: any;
|
17
19
|
export const DateSelectorExample: any;
|
18
20
|
import { Dropdown } from "./Dropdown";
|
@@ -77,6 +77,26 @@ WithOutline.args = {
|
|
77
77
|
placeholder: 'Select Day',
|
78
78
|
outlined: true,
|
79
79
|
};
|
80
|
+
export const OutlineWithError = Template.bind({});
|
81
|
+
OutlineWithError.args = {
|
82
|
+
id: 'days',
|
83
|
+
list: days,
|
84
|
+
placeholder: 'Select',
|
85
|
+
outlined: true,
|
86
|
+
error: true,
|
87
|
+
errorMsg: 'This field is required',
|
88
|
+
label: 'Select day',
|
89
|
+
};
|
90
|
+
export const WithError = Template.bind({});
|
91
|
+
WithError.args = {
|
92
|
+
id: 'days',
|
93
|
+
list: days,
|
94
|
+
placeholder: 'Select',
|
95
|
+
outlined: false,
|
96
|
+
error: true,
|
97
|
+
errorMsg: 'This field is required',
|
98
|
+
label: 'Select day',
|
99
|
+
};
|
80
100
|
const DateSelectorExampleTemplate = (args) => React.createElement(Container, Object.assign({}, args));
|
81
101
|
export const DateSelectorExample = DateSelectorExampleTemplate.bind({});
|
82
102
|
DateSelectorExample.args = {};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Dropdown.stories.js","sourceRoot":"","sources":["../../src/Dropdown/Dropdown.stories.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,MAAM,IAAI,GAAG;IACX;QACE,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,QAAQ;KAChB;IACD;QACE,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,SAAS;KACjB;IACD;QACE,KAAK,EAAE,WAAW;QAClB,KAAK,EAAE,WAAW;KACnB;IACD;QACE,KAAK,EAAE,UAAU;QACjB,KAAK,EAAE,UAAU;KAClB;IACD;QACE,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,QAAQ;KAChB;IACD;QACE,KAAK,EAAE,UAAU;QACjB,KAAK,EAAE,UAAU;KAClB;IACD;QACE,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,QAAQ;KAChB;CACF,CAAA;AAED,eAAe;IACb,KAAK,EAAE,UAAU;IACjB,SAAS,EAAE,QAAQ;IACnB,QAAQ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AW,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAE5C,WAAW,CAAC,IAAI,GAAG;IACjB,EAAE,EAAE,MAAM;IACV,IAAI,EAAE,IAAI;IACV,WAAW,EAAE,YAAY;IACzB,QAAQ,EAAE,IAAI;CACf,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAEjD,gBAAgB,CAAC,IAAI,GAAG;IACtB,EAAE,EAAE,MAAM;IACV,IAAI,EAAE,IAAI;IACV,WAAW,EAAE,QAAQ;IACrB,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE,IAAI;IACX,QAAQ,EAAE,wBAAwB;IAClC,KAAK,EAAE,YAAY;CACpB,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAE1C,SAAS,CAAC,IAAI,GAAG;IACf,EAAE,EAAE,MAAM;IACV,IAAI,EAAE,IAAI;IACV,WAAW,EAAE,QAAQ;IACrB,QAAQ,EAAE,KAAK;IACf,KAAK,EAAE,IAAI;IACX,QAAQ,EAAE,wBAAwB;IAClC,KAAK,EAAE,YAAY;CACpB,CAAA;AAED,MAAM,2BAA2B,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAC,SAAS,oBAAK,IAAI,EAAI,CAAA;AAErE,MAAM,CAAC,MAAM,mBAAmB,GAAG,2BAA2B,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAEvE,mBAAmB,CAAC,IAAI,GAAG,EAAE,CAAA"}
|
@@ -1,9 +1,11 @@
|
|
1
|
-
import { FC } from 'react';
|
1
|
+
import { FC, FormEvent, RefObject } from 'react';
|
2
2
|
declare type TextareaProps = {
|
3
3
|
/** ID, usually used for tests */
|
4
4
|
id: string;
|
5
5
|
/** className attribute to apply classses from props */
|
6
6
|
className?: string;
|
7
|
+
/** ref attribute for input */
|
8
|
+
ref?: RefObject<HTMLTextAreaElement>;
|
7
9
|
/** Placeholder */
|
8
10
|
placeholder?: string;
|
9
11
|
/** label displayed above the input */
|
@@ -18,12 +20,25 @@ declare type TextareaProps = {
|
|
18
20
|
errorMsg?: string;
|
19
21
|
/** Allow user to resize the textarea vertically and horizontally or not */
|
20
22
|
resize?: 'none' | 'both';
|
21
|
-
/** onChange listener */
|
22
|
-
onChange: (e: string) => void;
|
23
23
|
/** Disabled flag */
|
24
24
|
disabled?: boolean;
|
25
25
|
/** maxLength property */
|
26
26
|
maxLength?: number;
|
27
|
+
/** onBlur listener */
|
28
|
+
onBlur?: (e: FormEvent<HTMLTextAreaElement>) => void;
|
29
|
+
/** number of rows of input */
|
30
|
+
rows?: number;
|
31
|
+
};
|
32
|
+
/** on change or on input required */
|
33
|
+
declare type TruncateProps = {
|
34
|
+
/** on change is required and on input optional */
|
35
|
+
onChange: (e: string) => void;
|
36
|
+
onInputChange?: (e: FormEvent<HTMLTextAreaElement>) => void;
|
37
|
+
} | {
|
38
|
+
/** on input is required and on change optional */
|
39
|
+
onChange?: (e: string) => void;
|
40
|
+
onInputChange: (e: FormEvent<HTMLTextAreaElement>) => void;
|
27
41
|
};
|
28
|
-
|
42
|
+
declare type Props = TextareaProps & TruncateProps;
|
43
|
+
export declare const Textarea: FC<Props>;
|
29
44
|
export {};
|
@@ -3,11 +3,16 @@ import styled from 'styled-components';
|
|
3
3
|
import { Text } from '../Text';
|
4
4
|
import { Box } from '../Box';
|
5
5
|
import { theme } from '../theme';
|
6
|
-
export const Textarea = ({ id, name, label, value, onChange, className, resize = 'none', error = false, errorMsg, placeholder, disabled = false, maxLength, }) => (React.createElement(Box, { flex: true, direction: "column", className: className },
|
6
|
+
export const Textarea = ({ id, name, label, value, onChange, onInputChange, className, resize = 'none', error = false, errorMsg, placeholder, disabled = false, maxLength, onBlur, ref, rows = 4, }) => (React.createElement(Box, { flex: true, direction: "column", className: className },
|
7
7
|
label && (React.createElement(Box, { mb: "4px" },
|
8
8
|
React.createElement(Text, { tag: "label", color: "grey8", typo: "label" }, label))),
|
9
9
|
React.createElement(Box, { flex: true, direction: "column" },
|
10
|
-
React.createElement(Field, { error: error, id: id, name: name, disabled: disabled, resize: resize, placeholder: placeholder, value: value, onChange: (e) =>
|
10
|
+
React.createElement(Field, { error: error, id: id, name: name, disabled: disabled, resize: resize, placeholder: placeholder, value: value, onChange: (e) => {
|
11
|
+
onChange && onChange(e.currentTarget.value);
|
12
|
+
onInputChange && onInputChange(e);
|
13
|
+
}, maxLength: maxLength, ref: ref, onBlur: (e) => {
|
14
|
+
onBlur && onBlur(e);
|
15
|
+
}, rows: rows })),
|
11
16
|
error && React.createElement(ErrorBox, null, errorMsg)));
|
12
17
|
const Field = styled.textarea `
|
13
18
|
font-size: 16px;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Textarea.js","sourceRoot":"","sources":["../../src/Textarea/Textarea.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"Textarea.js","sourceRoot":"","sources":["../../src/Textarea/Textarea.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmC,MAAM,OAAO,CAAA;AACvD,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAEtC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAE5B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAgDhC,MAAM,CAAC,MAAM,QAAQ,GAAc,CAAC,EAClC,EAAE,EACF,IAAI,EACJ,KAAK,EACL,KAAK,EACL,QAAQ,EACR,aAAa,EACb,SAAS,EACT,MAAM,GAAG,MAAM,EACf,KAAK,GAAG,KAAK,EACb,QAAQ,EACR,WAAW,EACX,QAAQ,GAAG,KAAK,EAChB,SAAS,EACT,MAAM,EACN,GAAG,EACH,IAAI,GAAG,CAAC,GACT,EAAE,EAAE,CAAC,CACJ,oBAAC,GAAG,IAAC,IAAI,QA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M,CAAC;aACpD,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;kBACrC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;;;;;;oBAMxD,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;;;IAG1E,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CACd,KAAK;IACL,KAAK,IAAI,EAAE;IACX;sBACkB,KAAK,CAAC,MAAM,CAAC,KAAK;KACnC;CACJ,CAAA;AAED,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAA;;;WAGjB,KAAK,CAAC,MAAM,CAAC,IAAI;CAC3B,CAAA"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,OAAO,CAAA;AACrB,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,QAAQ,CAAA;AACtB,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,OAAO,CAAA;AACrB,cAAc,eAAe,CAAA;AAC7B,cAAc,OAAO,CAAA;AACrB,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,OAAO,CAAA;AACrB,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,QAAQ,CAAA;AACtB,cAAc,4BAA4B,CAAA;AAC1C,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,OAAO,CAAA;AACrB,cAAc,eAAe,CAAA;AAC7B,cAAc,OAAO,CAAA;AACrB,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@mrshmllw/smores-react",
|
3
|
-
"version": "1.2.
|
3
|
+
"version": "1.2.15",
|
4
4
|
"main": "./dist/index.js",
|
5
5
|
"description": "Collection of React components used by Marshmallow Technology",
|
6
6
|
"keywords": [
|
@@ -50,7 +50,7 @@
|
|
50
50
|
"babel-loader": "^8.1.0",
|
51
51
|
"eslint": "^7.9.0",
|
52
52
|
"eslint-config-prettier": "^8.2.0",
|
53
|
-
"eslint-plugin-jest": "^
|
53
|
+
"eslint-plugin-jest": "^25.0.1",
|
54
54
|
"eslint-plugin-react": "^7.23.2",
|
55
55
|
"eslint-plugin-react-hooks": "^4.1.2",
|
56
56
|
"husky": "^7.0.0",
|