@mrshmllw/smores-react 2.11.0 → 2.12.1
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/CheckBox/CheckBox.d.ts +2 -2
- package/dist/CheckBox/CheckBox.js +4 -4
- package/dist/CheckBox/CheckBox.js.map +1 -1
- package/dist/CheckBox/CheckBox.stories.d.ts +1 -1
- package/dist/Field/Field.d.ts +12 -0
- package/dist/Field/Field.js +84 -0
- package/dist/Field/Field.js.map +1 -0
- package/dist/Field/index.d.ts +3 -0
- package/dist/Field/index.js +2 -0
- package/dist/Field/index.js.map +1 -0
- package/dist/Field/types/commonFieldTypes.d.ts +11 -0
- package/dist/Field/types/commonFieldTypes.js +2 -0
- package/dist/Field/types/commonFieldTypes.js.map +1 -0
- package/dist/Fieldset/Fieldset.d.ts +9 -0
- package/dist/Fieldset/Fieldset.js +27 -0
- package/dist/Fieldset/Fieldset.js.map +1 -0
- package/dist/Fieldset/index.d.ts +1 -0
- package/dist/Fieldset/index.js +2 -0
- package/dist/Fieldset/index.js.map +1 -0
- package/dist/RadioGroup/RadioElement.d.ts +5 -7
- package/dist/RadioGroup/RadioElement.js +4 -4
- package/dist/RadioGroup/RadioElement.js.map +1 -1
- package/dist/RadioGroup/RadioGroup.d.ts +14 -2
- package/dist/RadioGroup/RadioGroup.js +22 -3
- package/dist/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/RadioGroup/RadioGroup.stories.d.ts +11 -3
- package/dist/RadioGroup/RadioItem.d.ts +5 -5
- package/dist/RadioGroup/RadioItem.js +4 -4
- package/dist/RadioGroup/RadioItem.js.map +1 -1
- package/dist/SearchInput/SearchInput.d.ts +2 -2
- package/dist/SearchInput/SearchInput.js +4 -4
- package/dist/SearchInput/SearchInput.js.map +1 -1
- package/dist/SearchInput/SearchInput.stories.d.ts +1 -1
- package/dist/SearchInput/__tests__/SearchInput.d.ts +1 -0
- package/dist/SearchInput/__tests__/SearchInput.js +32 -0
- package/dist/SearchInput/__tests__/SearchInput.js.map +1 -0
- package/dist/Textarea/__tests__/Textarea.d.ts +1 -0
- package/dist/Textarea/__tests__/Textarea.js +17 -0
- package/dist/Textarea/__tests__/Textarea.js.map +1 -0
- package/package.json +1 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import React, { ReactNode } from 'react';
|
2
2
|
export type CheckBoxProps = {
|
3
3
|
id?: string;
|
4
4
|
checked: boolean;
|
@@ -7,4 +7,4 @@ export type CheckBoxProps = {
|
|
7
7
|
error?: boolean;
|
8
8
|
errorMsg?: string;
|
9
9
|
};
|
10
|
-
export declare const CheckBox:
|
10
|
+
export declare const CheckBox: React.ForwardRefExoticComponent<CheckBoxProps & React.RefAttributes<HTMLInputElement>>;
|
@@ -1,18 +1,18 @@
|
|
1
|
-
import React from 'react';
|
1
|
+
import React, { forwardRef } from 'react';
|
2
2
|
import styled from 'styled-components';
|
3
3
|
import { focusOutline } from '../utils/focusOutline';
|
4
4
|
import { Text } from '../Text';
|
5
5
|
import { theme } from '../theme';
|
6
6
|
import { useUniqueId } from '../utils/id';
|
7
|
-
export const CheckBox = ({ id: idProp, checked, children, toggle, error, errorMsg,
|
7
|
+
export const CheckBox = forwardRef(function CheckBox({ id: idProp, checked, children, toggle, error, errorMsg }, ref) {
|
8
8
|
const id = useUniqueId(idProp);
|
9
9
|
return (React.createElement(React.Fragment, null,
|
10
10
|
React.createElement(BoxContainer, { id: id },
|
11
11
|
React.createElement(Text, { tag: "span", typo: "base", color: error ? 'error' : 'secondary' }, children),
|
12
|
-
React.createElement("input", { type: "checkbox", checked: checked, onChange: toggle }),
|
12
|
+
React.createElement("input", { ref: ref, type: "checkbox", checked: checked, onChange: toggle }),
|
13
13
|
React.createElement(Checkmark, { error: error })),
|
14
14
|
error && errorMsg && React.createElement(ErrorBox, null, errorMsg)));
|
15
|
-
};
|
15
|
+
});
|
16
16
|
const Checkmark = styled.span `
|
17
17
|
position: absolute;
|
18
18
|
left: 0;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CheckBox.js","sourceRoot":"","sources":["../../src/CheckBox/CheckBox.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"CheckBox.js","sourceRoot":"","sources":["../../src/CheckBox/CheckBox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAa,MAAM,OAAO,CAAA;AACpD,OAAO,MAAM,MAAM,mBAAmB,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEpD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAWzC,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAChC,SAAS,QAAQ,CACf,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,EAC1D,GAAG;IAEH,MAAM,EAAE,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;IAC9B,OAAO,CACL;QACE,oBAAC,YAAY,IAAC,EAAE,EAAE,EAAE;YAClB,oBAAC,IAAI,IAAC,GAAG,EAAC,MAAM,EAAC,IAAI,EAAC,MAAM,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,IAC9D,QAAQ,CACJ;YAEP,+BACE,GAAG,EAAE,GAAG,EACR,IAAI,EAAC,UAAU,EACf,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,GAChB;YACF,oBAAC,SAAS,IAAC,KAAK,EAAE,KAAK,GAAI,CACd;QACd,KAAK,IAAI,QAAQ,IAAI,oBAAC,QAAQ,QAAE,QAAQ,CAAY,CACpD,CACJ,CAAA;AACH,CAAC,CACF,CAAA;AAED,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAqB;;;;;YAKtC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CACtB,KAAK;IACH,CAAC,CAAC,aAAa,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE;IACnC,CAAC,CAAC,aAAa,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE;;;;;;;;;;;;;;;;;;CAkB5C,CAAA;AAED,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAA;;;;;;;;;;;;;kBAaf,SAAS;0BACD,KAAK,CAAC,MAAM,CAAC,SAAS;0BACtB,KAAK,CAAC,MAAM,CAAC,SAAS;;;kBAG9B,SAAS;;;;MAIrB,YAAY,CAAC,EAAE,QAAQ,EAAE,qBAAqB,SAAS,EAAE,EAAE,CAAC;;;;MAI5D,SAAS;0BACW,KAAK,CAAC,MAAM,CAAC,UAAU;0BACvB,KAAK,CAAC,MAAM,CAAC,SAAS;;;;;;;CAO/C,CAAA;AAED,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAA;;;WAGjB,KAAK,CAAC,MAAM,CAAC,KAAK;CAC5B,CAAA"}
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
2
2
|
import { CheckBoxProps } from './CheckBox';
|
3
3
|
declare const _default: {
|
4
4
|
title: string;
|
5
|
-
component: React.
|
5
|
+
component: React.ForwardRefExoticComponent<CheckBoxProps & React.RefAttributes<HTMLInputElement>>;
|
6
6
|
};
|
7
7
|
export default _default;
|
8
8
|
export declare const Default: any;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { CommonFieldTypes } from './types/commonFieldTypes';
|
3
|
+
interface FieldProps extends CommonFieldTypes {
|
4
|
+
children: React.ReactElement;
|
5
|
+
showCaret?: boolean;
|
6
|
+
value: string;
|
7
|
+
trailingIcon?: string;
|
8
|
+
dropdownKey?: string;
|
9
|
+
fullHeight?: boolean;
|
10
|
+
}
|
11
|
+
export declare const Field: ({ children, renderAsTitle, className, error, id, label, outlined, value, trailingIcon, errorMsg, dropdownKey, required, showCaret, fullHeight, ...marginProps }: FieldProps) => JSX.Element;
|
12
|
+
export {};
|
@@ -0,0 +1,84 @@
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
2
|
+
var t = {};
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
4
|
+
t[p] = s[p];
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
8
|
+
t[p[i]] = s[p[i]];
|
9
|
+
}
|
10
|
+
return t;
|
11
|
+
};
|
12
|
+
import React from 'react';
|
13
|
+
import styled from 'styled-components';
|
14
|
+
import { darken } from 'polished';
|
15
|
+
import { Icon } from '../Icon';
|
16
|
+
import { Text } from '../Text';
|
17
|
+
import { Box } from '../Box';
|
18
|
+
import { theme } from '../theme';
|
19
|
+
export const Field = (_a) => {
|
20
|
+
var { children, renderAsTitle, className = '', error, id, label, outlined = false, value, trailingIcon, errorMsg, dropdownKey, required, showCaret, fullHeight = false } = _a, marginProps = __rest(_a, ["children", "renderAsTitle", "className", "error", "id", "label", "outlined", "value", "trailingIcon", "errorMsg", "dropdownKey", "required", "showCaret", "fullHeight"]);
|
21
|
+
return (React.createElement(Container, Object.assign({ className: className }, marginProps),
|
22
|
+
label && (React.createElement(Box, { mb: { custom: outlined ? 4 : 0 } }, renderAsTitle ? (React.createElement(Title, { htmlFor: id }, label)) : (React.createElement(Text, { tag: "label", color: "subtext", typo: "label", htmlFor: id },
|
23
|
+
label,
|
24
|
+
required && React.createElement(Asterisk, null, "*"))))),
|
25
|
+
React.createElement(Content, { fullHeight: fullHeight, value: value, outlined: outlined, error: error, key: dropdownKey !== null && dropdownKey !== void 0 ? dropdownKey : null },
|
26
|
+
children,
|
27
|
+
showCaret && (React.createElement(Caret, { outlined: outlined },
|
28
|
+
React.createElement(Icon, { render: "caret", color: "subtext", size: 24 })))),
|
29
|
+
trailingIcon && React.createElement(Icon, { render: trailingIcon, color: "subtext" }),
|
30
|
+
error && React.createElement(ErrorBox, null, errorMsg)));
|
31
|
+
};
|
32
|
+
const Container = styled(Box) `
|
33
|
+
display: flex;
|
34
|
+
flex-direction: column;
|
35
|
+
position: relative;
|
36
|
+
width: 100%;
|
37
|
+
`;
|
38
|
+
const Content = styled.div `
|
39
|
+
position: relative;
|
40
|
+
border-color: ${({ error }) => theme.colors[`${error ? 'error' : 'outline'}`]};
|
41
|
+
background-color: ${({ outlined }) => !outlined ? 'transparent' : theme.colors['white']};
|
42
|
+
height: ${({ fullHeight }) => (fullHeight ? `100%` : `32px`)};
|
43
|
+
|
44
|
+
&:hover,
|
45
|
+
&:focus-within {
|
46
|
+
border-color: ${({ error }) => error ? theme.colors.error : darken(0.1, theme.colors.outline)};
|
47
|
+
}
|
48
|
+
|
49
|
+
${({ outlined }) => outlined &&
|
50
|
+
`
|
51
|
+
border-radius: 8px;
|
52
|
+
height: auto;
|
53
|
+
`}
|
54
|
+
|
55
|
+
${({ value }) => value &&
|
56
|
+
value != '' &&
|
57
|
+
`
|
58
|
+
border-color: ${theme.colors.outline};
|
59
|
+
`}
|
60
|
+
`;
|
61
|
+
const ErrorBox = styled.span `
|
62
|
+
margin-top: 7px;
|
63
|
+
color: ${theme.colors.error};
|
64
|
+
font-size: 12px;
|
65
|
+
`;
|
66
|
+
const Title = styled.label `
|
67
|
+
font-size: 20px;
|
68
|
+
line-height: 26px;
|
69
|
+
font-weight: 500;
|
70
|
+
padding-bottom: 8px;
|
71
|
+
`;
|
72
|
+
const Caret = styled.div `
|
73
|
+
position: absolute;
|
74
|
+
top: 50%;
|
75
|
+
z-index: 1;
|
76
|
+
right: ${({ outlined }) => (outlined ? '15px' : '0')};
|
77
|
+
pointer-events: none;
|
78
|
+
transform: translateY(-50%);
|
79
|
+
`;
|
80
|
+
const Asterisk = styled.span `
|
81
|
+
font-size: 14px;
|
82
|
+
color: ${theme.colors.error};
|
83
|
+
`;
|
84
|
+
//# sourceMappingURL=Field.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Field.js","sourceRoot":"","sources":["../../src/Field/Field.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,MAAM,MAAM,mBAAmB,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAYhC,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EAgBT,EAAE,EAAE;QAhBK,EACpB,QAAQ,EACR,aAAa,EACb,SAAS,GAAG,EAAE,EACd,KAAK,EACL,EAAE,EACF,KAAK,EACL,QAAQ,GAAG,KAAK,EAChB,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,SAAS,EACT,UAAU,GAAG,KAAK,OAEP,EADR,WAAW,cAfM,yKAgBrB,CADe;IAEd,OAAO,CACL,oBAAC,SAAS,kBAAC,SAAS,EAAE,SAAS,IAAM,WAAW;QAC7C,KAAK,IAAI,CACR,oBAAC,GAAG,IAAC,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAClC,aAAa,CAAC,CAAC,CAAC,CACf,oBAAC,KAAK,IAAC,OAAO,EAAE,EAAE,IAAG,KAAK,CAAS,CACpC,CAAC,CAAC,CAAC,CACF,oBAAC,IAAI,IAAC,GAAG,EAAC,OAAO,EAAC,KAAK,EAAC,SAAS,E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E,CAC5B,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC;;;IAGhE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CACjB,QAAQ;IACR;;;KAGC;;IAED,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CACd,KAAK;IACL,KAAK,IAAI,EAAE;IACX;oBACgB,KAAK,CAAC,MAAM,CAAC,OAAO;KACnC;CACJ,CAAA;AAED,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAA;;WAEjB,KAAK,CAAC,MAAM,CAAC,KAAK;;CAE5B,CAAA;AAED,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA;;;;;CAKzB,CAAA;AAED,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAuB;;;;WAIpC,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;;WAEjB,KAAK,CAAC,MAAM,CAAC,KAAK;CAC5B,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Field/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { MarginProps } from '../../utils/space';
|
2
|
+
export interface CommonFieldTypes extends MarginProps {
|
3
|
+
label?: string;
|
4
|
+
id?: string;
|
5
|
+
error?: boolean;
|
6
|
+
errorMsg?: string;
|
7
|
+
required?: boolean;
|
8
|
+
renderAsTitle?: boolean;
|
9
|
+
className?: string;
|
10
|
+
outlined?: boolean;
|
11
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"commonFieldTypes.js","sourceRoot":"","sources":["../../../src/Field/types/commonFieldTypes.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { MarginProps } from '../utils/space';
|
3
|
+
declare type FieldSetProps = {
|
4
|
+
children: React.ReactChild;
|
5
|
+
label: string;
|
6
|
+
outlined?: boolean;
|
7
|
+
} & MarginProps;
|
8
|
+
export declare const Fieldset: ({ children, label, outlined, ...marginProps }: FieldSetProps) => JSX.Element;
|
9
|
+
export {};
|
@@ -0,0 +1,27 @@
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
2
|
+
var t = {};
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
4
|
+
t[p] = s[p];
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
8
|
+
t[p[i]] = s[p[i]];
|
9
|
+
}
|
10
|
+
return t;
|
11
|
+
};
|
12
|
+
import React from 'react';
|
13
|
+
import styled from 'styled-components';
|
14
|
+
import { Box } from '../Box';
|
15
|
+
export const Fieldset = (_a) => {
|
16
|
+
var { children, label, outlined = false } = _a, marginProps = __rest(_a, ["children", "label", "outlined"]);
|
17
|
+
return (React.createElement(Box, Object.assign({ as: "fieldset" }, marginProps),
|
18
|
+
React.createElement(Box, { mb: { custom: outlined ? 4 : 0 } },
|
19
|
+
React.createElement(Legend, null, label)),
|
20
|
+
children));
|
21
|
+
};
|
22
|
+
const Legend = styled.legend `
|
23
|
+
font-size: 16px;
|
24
|
+
font-weight: bold;
|
25
|
+
padding-bottom: 8px;
|
26
|
+
`;
|
27
|
+
//# sourceMappingURL=Fieldset.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Fieldset.js","sourceRoot":"","sources":["../../src/Fieldset/Fieldset.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAGtC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAQ5B,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EAKT,EAAE,EAAE;QALK,EACvB,QAAQ,EACR,KAAK,EACL,QAAQ,GAAG,KAAK,OAEF,EADX,WAAW,cAJS,iCAKxB,CADe;IAEd,OAAO,CACL,oBAAC,GAAG,kBAAC,EAAE,EAAC,UAAU,IAAK,WAAW;QAChC,oBAAC,GAAG,IAAC,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;YACnC,oBAAC,MAAM,QAAE,KAAK,CAAU,CACpB;QAEL,QAAQ,CACL,CACP,CAAA;AACH,CAAC,CAAA;AAED,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;;;;CAI3B,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export { Fieldset } from './Fieldset';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Fieldset/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA"}
|
@@ -1,13 +1,11 @@
|
|
1
|
-
|
1
|
+
import React from 'react';
|
2
2
|
import { MarginProps } from '../utils/space';
|
3
3
|
import { BaseValueType } from './types';
|
4
|
-
|
4
|
+
export declare const RadioElement: React.ForwardRefExoticComponent<{
|
5
5
|
name: string;
|
6
6
|
id: string;
|
7
|
-
value:
|
7
|
+
value: BaseValueType;
|
8
8
|
checked: boolean;
|
9
|
-
onChange: (value:
|
9
|
+
onChange: (value: BaseValueType) => void;
|
10
10
|
isError: boolean;
|
11
|
-
} & MarginProps
|
12
|
-
export declare const RadioElement: <Value extends BaseValueType>({ name, id, value, checked, onChange, isError, ...marginProps }: RadioElementProps<Value>) => JSX.Element;
|
13
|
-
export {};
|
11
|
+
} & MarginProps & React.RefAttributes<HTMLInputElement>>;
|
@@ -9,18 +9,18 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
9
9
|
}
|
10
10
|
return t;
|
11
11
|
};
|
12
|
-
import React from 'react';
|
12
|
+
import React, { forwardRef } from 'react';
|
13
13
|
import styled from 'styled-components';
|
14
14
|
import { theme } from '../theme';
|
15
15
|
import { visuallyHidden } from '../utils/visuallyHidden';
|
16
16
|
import { focusOutline } from '../utils/focusOutline';
|
17
17
|
import { Box } from '../Box';
|
18
|
-
export const RadioElement = (_a)
|
18
|
+
export const RadioElement = forwardRef(function RadioElement(_a, ref) {
|
19
19
|
var { name, id, value, checked, onChange, isError } = _a, marginProps = __rest(_a, ["name", "id", "value", "checked", "onChange", "isError"]);
|
20
20
|
return (React.createElement(React.Fragment, null,
|
21
|
-
React.createElement(StyledInput, { type: "radio", name: name, id: id, value: `${value}`, checked: checked, onChange: () => onChange(value) }),
|
21
|
+
React.createElement(StyledInput, { ref: ref, type: "radio", name: name, id: id, value: `${value}`, checked: checked, onChange: () => onChange(value) }),
|
22
22
|
React.createElement(RadioCircle, Object.assign({ isError: isError, checked: checked }, marginProps))));
|
23
|
-
};
|
23
|
+
});
|
24
24
|
const StyledInput = styled.input `
|
25
25
|
${visuallyHidden}
|
26
26
|
`;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"RadioElement.js","sourceRoot":"","sources":["../../src/RadioGroup/RadioElement.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
1
|
+
{"version":3,"file":"RadioElement.js","sourceRoot":"","sources":["../../src/RadioGroup/RadioElement.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,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AC;;IAExE,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CACzB,CAAC,OAAO;IACR,CAAC,OAAO;IACR;;0BAEsB,KAAK,CAAC,MAAM,CAAC,SAAS;;GAE7C;;IAEC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CACzB,OAAO;IACP,qBACE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,SAC9C,GAAG;;IAEH,YAAY,CAAC,EAAE,QAAQ,EAAE,GAAG,WAAW,oBAAoB,EAAE,CAAC;CACjE,CAAA"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
import React, { ReactElement } from 'react';
|
2
2
|
import { CommonFieldProps } from '../fields/commonFieldTypes';
|
3
3
|
import { BaseValueType, DisplayType } from './types';
|
4
4
|
export type RadioGroupProps<Value extends BaseValueType = BaseValueType> = {
|
@@ -11,4 +11,16 @@ export type RadioGroupProps<Value extends BaseValueType = BaseValueType> = {
|
|
11
11
|
value: Value;
|
12
12
|
displayType?: DisplayType;
|
13
13
|
} & CommonFieldProps;
|
14
|
-
export
|
14
|
+
export type RadioGroupElement = {
|
15
|
+
focus: VoidFunction;
|
16
|
+
};
|
17
|
+
export declare const RadioGroup: <Value extends BaseValueType = BaseValueType>(p: {
|
18
|
+
options: {
|
19
|
+
visual?: string | undefined;
|
20
|
+
label: string;
|
21
|
+
value: Value;
|
22
|
+
}[];
|
23
|
+
onChange: (value: Value) => void;
|
24
|
+
value: Value;
|
25
|
+
displayType?: DisplayType | undefined;
|
26
|
+
} & CommonFieldProps & React.RefAttributes<HTMLInputElement>) => ReactElement | null;
|
@@ -9,18 +9,37 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
9
9
|
}
|
10
10
|
return t;
|
11
11
|
};
|
12
|
-
import React from 'react';
|
12
|
+
import React, { forwardRef, useImperativeHandle, useRef, } from 'react';
|
13
13
|
import styled from 'styled-components';
|
14
14
|
import { useUniqueId } from '../utils/id';
|
15
15
|
import { Fieldset } from '../fields/Fieldset';
|
16
16
|
import { RadioItem } from './RadioItem';
|
17
17
|
import { ITEM_GAP } from './constants';
|
18
|
-
|
18
|
+
const RadioGroupComponent = (_a, ref) => {
|
19
19
|
var { options, onChange, value, displayType = 'normal', renderAsTitle = false, error = false } = _a, fieldProps = __rest(_a, ["options", "onChange", "value", "displayType", "renderAsTitle", "error"]);
|
20
20
|
const name = useUniqueId();
|
21
|
+
const optionRefs = useRef([]);
|
22
|
+
useImperativeHandle(ref, () => {
|
23
|
+
return {
|
24
|
+
focus: () => {
|
25
|
+
var _a;
|
26
|
+
const selectedIndex = options.findIndex((item) => item.value === value);
|
27
|
+
const elementToFocus = selectedIndex === -1 ? 0 : selectedIndex;
|
28
|
+
(_a = optionRefs.current[elementToFocus].current) === null || _a === void 0 ? void 0 : _a.focus();
|
29
|
+
},
|
30
|
+
};
|
31
|
+
});
|
21
32
|
return (React.createElement(Fieldset, Object.assign({ renderAsTitle: renderAsTitle, error: error }, fieldProps),
|
22
|
-
React.createElement(RadioItemList, { displayType: displayType }, options.map((option) =>
|
33
|
+
React.createElement(RadioItemList, { displayType: displayType }, options.map((option, index) => {
|
34
|
+
const isSelected = option.value === value;
|
35
|
+
return (React.createElement(RadioItem, { ref: (radioOptionRef) => {
|
36
|
+
optionRefs.current[index] = {
|
37
|
+
current: radioOptionRef,
|
38
|
+
};
|
39
|
+
}, key: `${option.value}`, name: name, visual: option.visual, label: option.label, value: option.value, checked: isSelected, onChange: onChange, displayType: displayType, isError: error }));
|
40
|
+
}))));
|
23
41
|
};
|
42
|
+
export const RadioGroup = forwardRef(RadioGroupComponent);
|
24
43
|
const RadioItemList = styled.div `
|
25
44
|
display: flex;
|
26
45
|
gap: ${ITEM_GAP}px;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"RadioGroup.js","sourceRoot":"","sources":["../../src/RadioGroup/RadioGroup.ts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;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,CACL,oBAAC,QAAQ,kBAAC,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,IAAM,UAAU;QAClE,oBAAC,aAAa,IAAC,WAAW,EAAE,WAAW,IACpC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YAC7B,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,KAAK,KAAK,CAAA;YAEzC,OAAO,CACL,oBAAC,SAAS,IACR,GAAG,EAAE,CAAC,cAAc,EAAE,EAAE;oBACtB,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG;wBAC1B,OAAO,EAAE,cAAc;qBACxB,CAAA;gBACH,CAAC,EACD,GAAG,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,EACtB,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,CAAC,MAAM,EACrB,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,OAAO,EAAE,UAAU,EACnB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,KAAK,GACd,CACH,CAAA;QACH,CAAC,CAAC,CACY,CACP,CACZ,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAC,mBAAmB,CAIhC,CAAA;AAExB,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAsC;;SAE7D,QAAQ;;IAEb,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE;IACpB,IAAI,WAAW,KAAK,iBAAiB,EAAE;QACrC,OAAO;;;OAGN,CAAA;KACF;IAED,OAAO,yBAAyB,CAAA;AAClC,CAAC;CACF,CAAA"}
|
@@ -1,8 +1,16 @@
|
|
1
|
-
|
2
|
-
import { RadioGroupProps } from './RadioGroup';
|
1
|
+
import React from 'react';
|
3
2
|
declare const _default: {
|
4
3
|
title: string;
|
5
|
-
component: <Value extends import("./types").BaseValueType>(
|
4
|
+
component: <Value extends import("./types").BaseValueType = import("./types").BaseValueType>(p: {
|
5
|
+
options: {
|
6
|
+
visual?: string | undefined;
|
7
|
+
label: string;
|
8
|
+
value: Value;
|
9
|
+
}[];
|
10
|
+
onChange: (value: Value) => void;
|
11
|
+
value: Value;
|
12
|
+
displayType?: import("./types").DisplayType | undefined;
|
13
|
+
} & import("../fields/commonFieldTypes").CommonFieldProps & React.RefAttributes<HTMLInputElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
|
6
14
|
argTypes: {
|
7
15
|
onChange: {
|
8
16
|
action: string;
|
@@ -1,14 +1,14 @@
|
|
1
|
-
|
1
|
+
import React from 'react';
|
2
2
|
import { BaseValueType, DisplayType } from './types';
|
3
|
-
type RadioItemProps
|
3
|
+
type RadioItemProps = {
|
4
4
|
name: string;
|
5
5
|
visual?: string;
|
6
|
-
value:
|
6
|
+
value: BaseValueType;
|
7
7
|
label: string;
|
8
8
|
checked: boolean;
|
9
|
-
onChange: (value:
|
9
|
+
onChange: (value: BaseValueType) => void;
|
10
10
|
displayType: DisplayType;
|
11
11
|
isError: boolean;
|
12
12
|
};
|
13
|
-
export declare const RadioItem: <
|
13
|
+
export declare const RadioItem: React.ForwardRefExoticComponent<RadioItemProps & React.RefAttributes<HTMLInputElement>>;
|
14
14
|
export {};
|
@@ -1,19 +1,19 @@
|
|
1
|
-
import React from 'react';
|
1
|
+
import React, { forwardRef } from 'react';
|
2
2
|
import styled, { css } from 'styled-components';
|
3
3
|
import { useUniqueId } from '../utils/id';
|
4
4
|
import { theme } from '../theme';
|
5
5
|
import { RadioElement } from './RadioElement';
|
6
6
|
import { ITEM_GAP } from './constants';
|
7
7
|
import { Box } from '../Box';
|
8
|
-
export const RadioItem = ({ name, visual, label, value, checked, onChange, displayType, isError,
|
8
|
+
export const RadioItem = forwardRef(function RadioItem({ name, visual, label, value, checked, onChange, displayType, isError }, ref) {
|
9
9
|
const id = useUniqueId();
|
10
10
|
return (React.createElement(Wrapper, { htmlFor: id, checked: checked, displayType: displayType, "data-testid": value },
|
11
11
|
visual && (React.createElement(VisualWrapper, null,
|
12
12
|
React.createElement(Visual, { visualUrl: visual }))),
|
13
13
|
React.createElement(Box, { flex: true, direction: "row", alignItems: "flex-start" },
|
14
|
-
React.createElement(RadioElement, { name: name, id: id, value: value, checked: checked, onChange: onChange, isError: isError, mr: "8px" }),
|
14
|
+
React.createElement(RadioElement, { ref: ref, name: name, id: id, value: value, checked: checked, onChange: onChange, isError: isError, mr: "8px" }),
|
15
15
|
React.createElement(RadioText, { isError: isError }, label))));
|
16
|
-
};
|
16
|
+
});
|
17
17
|
const VisualWrapper = styled.div `
|
18
18
|
width: 100%;
|
19
19
|
max-width: 120px;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"RadioItem.js","sourceRoot":"","sources":["../../src/RadioGroup/RadioItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
1
|
+
{"version":3,"file":"RadioItem.js","sourceRoot":"","sources":["../../src/RadioGroup/RadioItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAEhC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAa5B,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CACjC,SAAS,SAAS,CAChB,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW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AClC,OAAO,IAAI,qBAAqB,KAAK,CAAC,MAAM,CAAC,SAAS,GAAG;OAC5D;QACC,WAAW,KAAK,iBAAiB;IACnC,GAAG,CAAA;;;;8BAIqB,QAAQ,GAAG,CAAC;;;;;;OAMnC;KACF;CACJ,CAAA;AAED,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAsB;;;iBAGlC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM;WAC9B,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CACvB,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS;;CAExD,CAAA"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import React, { FocusEvent } from 'react';
|
2
2
|
import { CommonFieldProps } from '../fields/commonFieldTypes';
|
3
3
|
export type SearchInputItem = {
|
4
4
|
label: string;
|
@@ -15,4 +15,4 @@ export interface SearchInputProps extends CommonFieldProps {
|
|
15
15
|
outlined?: boolean;
|
16
16
|
value?: string;
|
17
17
|
}
|
18
|
-
export declare const SearchInput:
|
18
|
+
export declare const SearchInput: React.ForwardRefExoticComponent<SearchInputProps & React.RefAttributes<HTMLInputElement>>;
|
@@ -9,7 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
9
9
|
}
|
10
10
|
return t;
|
11
11
|
};
|
12
|
-
import React, { useMemo, useState } from 'react';
|
12
|
+
import React, { forwardRef, useMemo, useState, } from 'react';
|
13
13
|
import styled from 'styled-components';
|
14
14
|
import { darken } from 'polished';
|
15
15
|
import { theme } from '../theme';
|
@@ -18,7 +18,7 @@ import { Field } from '../fields/Field';
|
|
18
18
|
import { useUniqueId } from '../utils/id';
|
19
19
|
import { useControllableState } from '../utils/useControlledState';
|
20
20
|
import { SearchOptions } from './SearchOptions';
|
21
|
-
export const SearchInput = (_a)
|
21
|
+
export const SearchInput = forwardRef(function SearchInput(_a, ref) {
|
22
22
|
var { id: idProp, name = 'search_input', className = '', placeholder, searchList, onFound, resultsRelativePosition = false, outlined = false, showIcon = false, renderAsTitle = false, onBlur, value } = _a, otherProps = __rest(_a, ["id", "name", "className", "placeholder", "searchList", "onFound", "resultsRelativePosition", "outlined", "showIcon", "renderAsTitle", "onBlur", "value"]);
|
23
23
|
const id = useUniqueId(idProp);
|
24
24
|
const [showOptions, setShowOptions] = useState(false);
|
@@ -66,9 +66,9 @@ export const SearchInput = (_a) => {
|
|
66
66
|
return (React.createElement(Field, Object.assign({ className: className, renderAsTitle: renderAsTitle, htmlFor: id, outlined: outlined }, otherProps),
|
67
67
|
React.createElement(StyledInputBox, { outlined: outlined, selected: isSelected },
|
68
68
|
showIcon && React.createElement(SearchIcon, { size: 24, render: "search", color: "subtext" }),
|
69
|
-
React.createElement(StyledInput, { id: id, type: "text", name: name, placeholder: placeholder, autoComplete: "off", value: displayedInputText, onChange: handleInputChange, outlined: outlined, selected: isSelected, onBlur: onBlur })),
|
69
|
+
React.createElement(StyledInput, { ref: ref, id: id, type: "text", name: name, placeholder: placeholder, autoComplete: "off", value: displayedInputText, onChange: handleInputChange, outlined: outlined, selected: isSelected, onBlur: onBlur })),
|
70
70
|
showOptions && (React.createElement(SearchOptions, { displayedList: filteredList, onSelect: handleSelect, outlined: outlined, positionRelative: resultsRelativePosition }))));
|
71
|
-
};
|
71
|
+
});
|
72
72
|
const StyledInputBox = styled.div `
|
73
73
|
display: flex;
|
74
74
|
align-items: center;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SearchInput.js","sourceRoot":"","sources":["../../src/SearchInput/SearchInput.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,
|
1
|
+
{"version":3,"file":"SearchInput.js","sourceRoot":"","sources":["../../src/SearchInput/SearchInput.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAGZ,UAAU,EACV,OAAO,EACP,QAAQ,GACT,MAA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O;;;GAGzC;aACU,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC;;;;;oBAKjD,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC;;;IAGjD,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CACjB,QAAQ;IACR;oBACgB,KAAK,CAAC,MAAM,CAAC,OAAO;GACrC;WACQ,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CACxB,QAAQ,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE;CACrE,CAAA;AASD,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAO;;;;;;;;;aAS1B,KAAK,CAAC,MAAM,CAAC,OAAO;;;IAG7B,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CACjB,QAAQ;IACR;;GAED;CACF,CAAA;AAED,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;CAE9B,CAAA"}
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
2
2
|
import { SearchInputProps } from './SearchInput';
|
3
3
|
declare const _default: {
|
4
4
|
title: string;
|
5
|
-
component: React.
|
5
|
+
component: React.ForwardRefExoticComponent<SearchInputProps & React.RefAttributes<HTMLInputElement>>;
|
6
6
|
};
|
7
7
|
export default _default;
|
8
8
|
export declare const Default: any;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { render } from '@testing-library/react';
|
3
|
+
import 'jest-styled-components';
|
4
|
+
import { SearchInput } from '../SearchInput';
|
5
|
+
const list = [
|
6
|
+
{
|
7
|
+
label: 'Monday',
|
8
|
+
},
|
9
|
+
{
|
10
|
+
label: 'Tuesday',
|
11
|
+
},
|
12
|
+
{
|
13
|
+
label: 'Wednesday',
|
14
|
+
},
|
15
|
+
{
|
16
|
+
label: 'Thursday',
|
17
|
+
},
|
18
|
+
{
|
19
|
+
label: 'Friday',
|
20
|
+
},
|
21
|
+
{
|
22
|
+
label: 'Saturday',
|
23
|
+
},
|
24
|
+
{
|
25
|
+
label: 'Sunday',
|
26
|
+
},
|
27
|
+
];
|
28
|
+
test('renders', () => {
|
29
|
+
const { container } = render(React.createElement(SearchInput, { id: "days", label: "Days", searchList: list, onFound: () => { } }));
|
30
|
+
expect(container.firstChild).toMatchSnapshot();
|
31
|
+
});
|
32
|
+
//# sourceMappingURL=SearchInput.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"SearchInput.js","sourceRoot":"","sources":["../../../src/SearchInput/__tests__/SearchInput.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAC;AAC9C,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAE3C,MAAM,IAAI,GAAG;IACX;QACE,KAAK,EAAE,QAAQ;KAChB;IACD;QACE,KAAK,EAAE,SAAS;KACjB;IACD;QACE,KAAK,EAAE,WAAW;KACnB;IACD;QACE,KAAK,EAAE,UAAU;KAClB;IACD;QACE,KAAK,EAAE,QAAQ;KAChB;IACD;QACE,KAAK,EAAE,UAAU;KAClB;IACD;QACE,KAAK,EAAE,QAAQ;KAChB;CACF,CAAC;AAEF,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;IACnB,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CACxB,oBAAC,WAAW,IAAC,EAAE,EAAC,MAAM,EAAC,KAAK,EAAC,MAAM,EAAC,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC,GAAI,CAC5E,CAAC;IACF,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,eAAe,EAAE,CAAC;AACjD,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { render } from '@testing-library/react';
|
3
|
+
import 'jest-styled-components';
|
4
|
+
import { Textarea } from '../Textarea';
|
5
|
+
test('renders', () => {
|
6
|
+
const { container } = render(React.createElement(Textarea, { id: "textarea_id", label: "Textarea label", value: "", onChange: str => { }, resize: "both", disabled: false, placeholder: "Placeholder text!", className: "Textarea" }));
|
7
|
+
expect(container.firstChild).toMatchSnapshot();
|
8
|
+
});
|
9
|
+
test('disabled', () => {
|
10
|
+
const { container } = render(React.createElement(Textarea, { id: "textarea_id", label: "Textarea label", value: "", onChange: str => { }, resize: "both", disabled: true, placeholder: "Placeholder text!" }));
|
11
|
+
expect(container.firstChild).toMatchSnapshot();
|
12
|
+
});
|
13
|
+
test('renders with error', () => {
|
14
|
+
const { container } = render(React.createElement(Textarea, { id: "textarea_id", label: "Textarea label", value: "", onChange: str => { }, resize: "both", disabled: false, error: true, errorMsg: "Something really quite terrible has gone wrong here!", placeholder: "Placeholder text!" }));
|
15
|
+
expect(container.firstChild).toMatchSnapshot();
|
16
|
+
});
|
17
|
+
//# sourceMappingURL=Textarea.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Textarea.js","sourceRoot":"","sources":["../../../src/Textarea/__tests__/Textarea.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAC;AAC9C,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AAErC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;IACnB,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CACxB,oBAAC,QAAQ,IACP,EAAE,EAAC,aAAa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