@indico-data/design-system 2.9.0 → 2.11.0
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/lib/index.css +119 -8
- package/lib/index.d.ts +52 -8
- package/lib/index.esm.css +119 -8
- package/lib/index.esm.js +35 -19
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +36 -18
- package/lib/index.js.map +1 -1
- package/lib/src/components/forms/checkbox/Checkbox.d.ts +2 -1
- package/lib/src/components/forms/form/Form.d.ts +14 -0
- package/lib/src/components/forms/form/Form.stories.d.ts +8 -0
- package/lib/src/components/forms/input/Input.d.ts +5 -4
- package/lib/src/components/forms/passwordInput/PasswordInput.d.ts +17 -0
- package/lib/src/components/forms/passwordInput/PasswordInput.stories.d.ts +11 -0
- package/lib/src/components/forms/passwordInput/__tests__/PasswordInput.test.d.ts +1 -0
- package/lib/src/components/forms/passwordInput/index.d.ts +1 -0
- package/lib/src/components/forms/radio/Radio.d.ts +2 -1
- package/lib/src/components/forms/subcomponents/DisplayFormError.d.ts +5 -0
- package/lib/src/components/forms/textarea/Textarea.d.ts +4 -3
- package/lib/src/components/forms/toggle/Toggle.d.ts +2 -1
- package/lib/src/components/index.d.ts +2 -0
- package/lib/src/index.d.ts +2 -0
- package/package.json +5 -2
- package/src/components/forms/checkbox/Checkbox.stories.tsx +2 -2
- package/src/components/forms/checkbox/Checkbox.tsx +32 -41
- package/src/components/forms/form/Form.mdx +134 -0
- package/src/components/forms/form/Form.stories.tsx +413 -0
- package/src/components/forms/form/Form.tsx +64 -0
- package/src/components/forms/form/__tests__/Form.test.tsx +35 -0
- package/src/components/forms/form/index.ts +0 -0
- package/src/components/forms/form/styles/Form.scss +3 -0
- package/src/components/forms/input/Input.stories.tsx +0 -5
- package/src/components/forms/input/Input.tsx +67 -64
- package/src/components/forms/input/__tests__/Input.test.tsx +2 -13
- package/src/components/forms/input/styles/Input.scss +2 -8
- package/src/components/forms/passwordInput/PasswordInput.mdx +28 -0
- package/src/components/forms/passwordInput/PasswordInput.stories.tsx +268 -0
- package/src/components/forms/passwordInput/PasswordInput.tsx +86 -0
- package/src/components/forms/passwordInput/__tests__/PasswordInput.test.tsx +129 -0
- package/src/components/forms/passwordInput/index.ts +1 -0
- package/src/components/forms/passwordInput/styles/PasswordInput.scss +120 -0
- package/src/components/forms/radio/Radio.tsx +32 -35
- package/src/components/forms/subcomponents/DisplayFormError.tsx +7 -0
- package/src/components/forms/textarea/Textarea.stories.tsx +15 -21
- package/src/components/forms/textarea/Textarea.tsx +64 -62
- package/src/components/forms/textarea/__tests__/Textarea.test.tsx +1 -1
- package/src/components/forms/textarea/styles/Textarea.scss +1 -1
- package/src/components/forms/toggle/Toggle.tsx +30 -37
- package/src/components/index.ts +2 -0
- package/src/index.ts +2 -0
- package/src/styles/index.scss +2 -0
- package/lib/src/components/forms/subcomponents/ErrorList.d.ts +0 -6
- package/src/components/forms/subcomponents/ErrorList.tsx +0 -14
- package/src/components/forms/subcomponents/__tests__/ErrorList.test.tsx +0 -16
- /package/lib/src/components/forms/{subcomponents/__tests__/ErrorList.test.d.ts → form/__tests__/Form.test.d.ts} +0 -0
|
@@ -9,43 +9,36 @@ export interface ToggleProps {
|
|
|
9
9
|
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
10
10
|
isDisabled?: boolean;
|
|
11
11
|
isChecked?: boolean;
|
|
12
|
+
defaultChecked?: boolean;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
export const Toggle = (
|
|
15
|
-
ref
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
aria-describedby={id}
|
|
41
|
-
aria-label={label}
|
|
42
|
-
{...rest}
|
|
43
|
-
/>
|
|
44
|
-
<label htmlFor={id} className="switch"></label>
|
|
45
|
-
<label className={'toggle-label'} htmlFor={id}>
|
|
46
|
-
{label}
|
|
47
|
-
</label>
|
|
15
|
+
export const Toggle = React.forwardRef<HTMLInputElement, ToggleProps>(
|
|
16
|
+
({ id, label, name, value, onChange, isDisabled, isChecked, ...rest }, ref) => {
|
|
17
|
+
return (
|
|
18
|
+
<div className="form-control">
|
|
19
|
+
<div className="toggle-wrapper">
|
|
20
|
+
<input
|
|
21
|
+
data-testid={`form-toggle-input-${name}`}
|
|
22
|
+
className="toggle-input"
|
|
23
|
+
type="checkbox"
|
|
24
|
+
id={id}
|
|
25
|
+
checked={isChecked}
|
|
26
|
+
name={name}
|
|
27
|
+
value={value}
|
|
28
|
+
disabled={isDisabled}
|
|
29
|
+
ref={ref}
|
|
30
|
+
onChange={onChange}
|
|
31
|
+
tabIndex={0}
|
|
32
|
+
aria-describedby={id}
|
|
33
|
+
aria-label={label}
|
|
34
|
+
{...rest}
|
|
35
|
+
/>
|
|
36
|
+
<label htmlFor={id} className="switch"></label>
|
|
37
|
+
<label className={'toggle-label'} htmlFor={id}>
|
|
38
|
+
{label}
|
|
39
|
+
</label>
|
|
40
|
+
</div>
|
|
48
41
|
</div>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
);
|
|
43
|
+
},
|
|
44
|
+
);
|
package/src/components/index.ts
CHANGED
|
@@ -6,3 +6,5 @@ export { Input } from './forms/input';
|
|
|
6
6
|
export { Radio } from './forms/radio';
|
|
7
7
|
export { Checkbox } from './forms/checkbox';
|
|
8
8
|
export { Toggle } from './forms/toggle';
|
|
9
|
+
export { Textarea } from './forms/textarea';
|
|
10
|
+
export { PasswordInput } from './forms/passwordInput';
|
package/src/index.ts
CHANGED
|
@@ -65,3 +65,5 @@ export { Input } from './components/forms/input';
|
|
|
65
65
|
export { Radio as RadioInput } from './components/forms/radio';
|
|
66
66
|
export { Checkbox } from './components/forms/checkbox';
|
|
67
67
|
export { Toggle as ToggleInput } from './components/forms/toggle';
|
|
68
|
+
export { Textarea } from './components/forms/textarea';
|
|
69
|
+
export { PasswordInput } from './components/forms/passwordInput';
|
package/src/styles/index.scss
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
@import '../components/forms/radio/styles/Radio.scss';
|
|
11
11
|
@import '../components/forms/checkbox/styles/Checkbox.scss';
|
|
12
12
|
@import '../components/forms/textarea/styles/Textarea.scss';
|
|
13
|
+
@import '../components/forms/passwordInput/styles/PasswordInput.scss';
|
|
14
|
+
@import '../components/forms/form/styles/Form.scss';
|
|
13
15
|
|
|
14
16
|
@import '../components/forms/toggle/styles/Toggle.scss';
|
|
15
17
|
@import 'typography';
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
interface ErrorListProps {
|
|
2
|
-
name: string;
|
|
3
|
-
errorList: string[];
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export const ErrorList = ({ errorList, name }: ErrorListProps) => {
|
|
7
|
-
return (
|
|
8
|
-
<ul className="error-list" id={`${name}-helper`}>
|
|
9
|
-
{(errorList ?? []).map((error, index) => (
|
|
10
|
-
<li key={index}>{error}</li>
|
|
11
|
-
))}
|
|
12
|
-
</ul>
|
|
13
|
-
);
|
|
14
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { render, screen } from '@testing-library/react';
|
|
2
|
-
import { ErrorList } from '@/components/forms/subcomponents/ErrorList';
|
|
3
|
-
|
|
4
|
-
describe('ErrorList', () => {
|
|
5
|
-
it('renders the error list', () => {
|
|
6
|
-
render(<ErrorList name="name" errorList={['error1', 'error2']} />);
|
|
7
|
-
expect(screen.getByText('error1')).toBeInTheDocument();
|
|
8
|
-
expect(screen.getByText('error2')).toBeInTheDocument();
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it('does not render the error list when it is empty', () => {
|
|
12
|
-
render(<ErrorList name="name" errorList={[]} />);
|
|
13
|
-
expect(screen.queryByText('error1')).not.toBeInTheDocument();
|
|
14
|
-
expect(screen.queryByText('error2')).not.toBeInTheDocument();
|
|
15
|
-
});
|
|
16
|
-
});
|
|
File without changes
|