@indico-data/design-system 2.7.0 → 2.9.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 +195 -19
- package/lib/index.d.ts +14 -2
- package/lib/index.esm.css +195 -19
- package/lib/index.esm.js +7 -2
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +7 -1
- package/lib/index.js.map +1 -1
- package/lib/src/components/forms/textarea/Textarea.d.ts +22 -0
- package/lib/src/components/forms/textarea/Textarea.stories.d.ts +11 -0
- package/lib/src/components/forms/textarea/__tests__/Textarea.test.d.ts +1 -0
- package/lib/src/components/forms/textarea/index.d.ts +1 -0
- package/lib/src/components/forms/toggle/Toggle.d.ts +12 -0
- package/lib/src/components/forms/toggle/Toggle.stories.d.ts +6 -0
- package/lib/src/components/forms/toggle/__tests__/Toggle.test.d.ts +1 -0
- package/lib/src/components/forms/toggle/index.d.ts +1 -0
- package/lib/src/components/index.d.ts +1 -0
- package/lib/src/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/forms/checkbox/Checkbox.mdx +6 -1
- package/src/components/forms/checkbox/Checkbox.stories.tsx +10 -4
- package/src/components/forms/checkbox/Checkbox.tsx +1 -1
- package/src/components/forms/checkbox/styles/Checkbox.scss +16 -16
- package/src/components/forms/input/Input.stories.tsx +70 -64
- package/src/components/forms/input/styles/Input.scss +10 -3
- package/src/components/forms/textarea/Textarea.mdx +19 -0
- package/src/components/forms/textarea/Textarea.stories.tsx +363 -0
- package/src/components/forms/textarea/Textarea.tsx +85 -0
- package/src/components/forms/textarea/__tests__/Textarea.test.tsx +103 -0
- package/src/components/forms/textarea/index.ts +1 -0
- package/src/components/forms/textarea/styles/Textarea.scss +102 -0
- package/src/components/forms/toggle/Toggle.mdx +15 -0
- package/src/components/forms/toggle/Toggle.stories.tsx +126 -0
- package/src/components/forms/toggle/Toggle.tsx +51 -0
- package/src/components/forms/toggle/__tests__/Toggle.test.tsx +19 -0
- package/src/components/forms/toggle/index.ts +1 -0
- package/src/components/forms/toggle/styles/Toggle.scss +72 -0
- package/src/components/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/styles/index.scss +2 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface TextareaProps {
|
|
3
|
+
ref?: React.LegacyRef<HTMLTextAreaElement>;
|
|
4
|
+
label: string;
|
|
5
|
+
name: string;
|
|
6
|
+
placeholder: string;
|
|
7
|
+
value: string;
|
|
8
|
+
onChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
9
|
+
isRequired?: boolean;
|
|
10
|
+
isDisabled?: boolean;
|
|
11
|
+
errorList?: string[];
|
|
12
|
+
helpText?: string;
|
|
13
|
+
hasHiddenLabel?: boolean;
|
|
14
|
+
rows?: number;
|
|
15
|
+
cols?: number;
|
|
16
|
+
readonly?: boolean;
|
|
17
|
+
wrap?: 'hard' | 'soft';
|
|
18
|
+
form?: string;
|
|
19
|
+
maxLength?: number;
|
|
20
|
+
autofocus?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare const Textarea: ({ ref, label, name, placeholder, value, onChange, isRequired, isDisabled, errorList, helpText, hasHiddenLabel, rows, cols, readonly, wrap, form, maxLength, autofocus, ...rest }: TextareaProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Textarea } from './Textarea';
|
|
3
|
+
declare const meta: Meta;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Textarea>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Errors: Story;
|
|
8
|
+
export declare const HiddenLabel: Story;
|
|
9
|
+
export declare const HelpText: Story;
|
|
10
|
+
export declare const Disabled: Story;
|
|
11
|
+
export declare const Readonly: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Textarea } from './Textarea';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ToggleProps {
|
|
3
|
+
ref?: React.LegacyRef<HTMLInputElement>;
|
|
4
|
+
id: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
name: string;
|
|
7
|
+
value?: string;
|
|
8
|
+
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
9
|
+
isDisabled?: boolean;
|
|
10
|
+
isChecked?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const Toggle: ({ ref, id, label, name, value, onChange, isDisabled, isChecked, ...rest }: ToggleProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Toggle } from './Toggle';
|
package/lib/src/index.d.ts
CHANGED
|
@@ -10,3 +10,4 @@ export { Table } from './components/table';
|
|
|
10
10
|
export { Input } from './components/forms/input';
|
|
11
11
|
export { Radio as RadioInput } from './components/forms/radio';
|
|
12
12
|
export { Checkbox } from './components/forms/checkbox';
|
|
13
|
+
export { Toggle as ToggleInput } from './components/forms/toggle';
|
package/package.json
CHANGED
|
@@ -8,10 +8,15 @@ This component may be used on it's on or as part of a group. The source code is
|
|
|
8
8
|
|
|
9
9
|
<Canvas of={Checkbox.Default} source={{
|
|
10
10
|
code: `
|
|
11
|
+
const [isChecked, setIsChecked] = useState<boolean>(false);
|
|
12
|
+
const handleChange = () => {
|
|
13
|
+
setIsChecked(!isChecked);
|
|
14
|
+
};
|
|
15
|
+
|
|
11
16
|
<div>
|
|
12
17
|
<h2 className="mb-2">Checkbox Buttons</h2>
|
|
13
18
|
<Checkbox
|
|
14
|
-
onChange={
|
|
19
|
+
onChange={handleChange}
|
|
15
20
|
id={id}
|
|
16
21
|
label={label}
|
|
17
22
|
name={name}
|
|
@@ -78,7 +78,7 @@ const meta: Meta = {
|
|
|
78
78
|
defaultValue: { summary: false },
|
|
79
79
|
},
|
|
80
80
|
isChecked: {
|
|
81
|
-
control:
|
|
81
|
+
control: false,
|
|
82
82
|
description: 'Toggles the checked state of the checkbox field when true',
|
|
83
83
|
table: {
|
|
84
84
|
category: 'Props',
|
|
@@ -111,18 +111,24 @@ export const Default: Story = {
|
|
|
111
111
|
isChecked: false,
|
|
112
112
|
},
|
|
113
113
|
render: (args) => {
|
|
114
|
+
const [isChecked, setIsChecked] = useState<boolean>(false);
|
|
115
|
+
|
|
116
|
+
const handleChange = () => {
|
|
117
|
+
setIsChecked(!isChecked);
|
|
118
|
+
};
|
|
119
|
+
|
|
114
120
|
return (
|
|
115
121
|
<div>
|
|
116
|
-
<h2 className="mb-2">Checkbox
|
|
122
|
+
<h2 className="mb-2">Checkbox Button</h2>
|
|
117
123
|
<Checkbox
|
|
118
124
|
key={args.id}
|
|
119
|
-
onChange={
|
|
125
|
+
onChange={handleChange}
|
|
120
126
|
id={args.id}
|
|
121
127
|
label={args.label}
|
|
122
128
|
name={args.name}
|
|
123
129
|
value={args.value}
|
|
124
130
|
isDisabled={args.isDisabled}
|
|
125
|
-
isChecked={
|
|
131
|
+
isChecked={isChecked}
|
|
126
132
|
/>
|
|
127
133
|
</div>
|
|
128
134
|
);
|
|
@@ -28,7 +28,6 @@ export const Checkbox = ({
|
|
|
28
28
|
<div className="checkbox-wrapper">
|
|
29
29
|
<input
|
|
30
30
|
data-testid={`form-checkbox-input-${name}`}
|
|
31
|
-
{...rest}
|
|
32
31
|
className="checkbox-input"
|
|
33
32
|
type="checkbox"
|
|
34
33
|
id={id}
|
|
@@ -41,6 +40,7 @@ export const Checkbox = ({
|
|
|
41
40
|
tabIndex={0}
|
|
42
41
|
aria-describedby={id}
|
|
43
42
|
aria-label={label}
|
|
43
|
+
{...rest}
|
|
44
44
|
/>
|
|
45
45
|
<label
|
|
46
46
|
htmlFor={id}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
// Dark Theme Specific Variables
|
|
12
12
|
:root [data-theme='dark'] {
|
|
13
|
-
--pf-checkbox-background-color:
|
|
13
|
+
--pf-checkbox-background-color: var(--pf-primary-color-200);
|
|
14
14
|
--pf-checkbox-check-color: var(--pf-white-color);
|
|
15
15
|
--pf-checkbox-border-color: var(--pf-white-color);
|
|
16
16
|
--pf-checkbox-disabled-color: var(--pf-gray-color-300);
|
|
@@ -30,21 +30,21 @@
|
|
|
30
30
|
.checkbox-input-label {
|
|
31
31
|
cursor: pointer;
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
.checkbox-input:checked,
|
|
34
|
+
.checkbox-input:not(:checked) {
|
|
35
35
|
position: absolute;
|
|
36
36
|
left: -9999px;
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
.checkbox-input:checked + label,
|
|
39
|
+
.checkbox-input:not(:checked) + label {
|
|
40
40
|
position: relative;
|
|
41
41
|
padding-left: var(--pf-padding-7);
|
|
42
42
|
cursor: pointer;
|
|
43
43
|
line-height: 20px;
|
|
44
44
|
display: inline-block;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
.checkbox-input:checked + label:before,
|
|
47
|
+
.checkbox-input:not(:checked) + label:before {
|
|
48
48
|
content: '';
|
|
49
49
|
position: absolute;
|
|
50
50
|
left: 0;
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
border-radius: var(--pf-rounded);
|
|
56
56
|
background: var(--pf-checkbox-background-color);
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
.checkbox-input:checked + label:after,
|
|
59
|
+
.checkbox-input:not(:checked) + label:after {
|
|
60
60
|
content: '';
|
|
61
61
|
width: 12px;
|
|
62
62
|
height: 12px;
|
|
@@ -68,31 +68,31 @@
|
|
|
68
68
|
-webkit-transition: all 0.2s ease;
|
|
69
69
|
transition: all 0.2s ease;
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
.checkbox-input:not(:checked) + label:after {
|
|
72
72
|
opacity: 0;
|
|
73
73
|
-webkit-transform: scale(0);
|
|
74
74
|
transform: scale(0);
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
.checkbox-input:checked + label:after {
|
|
77
77
|
opacity: 1;
|
|
78
78
|
-webkit-transform: scale(1);
|
|
79
79
|
transform: scale(1);
|
|
80
80
|
}
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
.checkbox-input:disabled,
|
|
82
|
+
.checkbox-input:disabled + label {
|
|
83
83
|
cursor: not-allowed;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
.checkbox-input:disabled + label {
|
|
87
87
|
color: var(--pf-checkbox-disabled-color);
|
|
88
88
|
opacity: 0.5;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
.checkbox-input:disabled + label:before {
|
|
92
92
|
border-color: var(--pf-checkbox-disabled-color);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
.checkbox-input:disabled + label:after {
|
|
96
96
|
background: var(--pf-checkbox-disabled-color);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
import { Input, InputProps } from './Input';
|
|
3
|
-
import { useState } from 'react';
|
|
3
|
+
import { SetStateAction, useEffect, useState } from 'react';
|
|
4
4
|
import { iconNames } from 'build/generated/iconTypes';
|
|
5
5
|
|
|
6
6
|
const meta: Meta = {
|
|
@@ -174,15 +174,15 @@ export const Default: Story = {
|
|
|
174
174
|
},
|
|
175
175
|
render: (args) => {
|
|
176
176
|
const [value, setValue] = useState('');
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
177
|
+
|
|
178
|
+
useEffect(() => {
|
|
179
|
+
setValue(args.value);
|
|
180
|
+
}, [args.value]);
|
|
181
|
+
|
|
182
|
+
const handleChange = (e: { target: { value: SetStateAction<string> } }) => {
|
|
183
|
+
setValue(e.target.value);
|
|
184
|
+
};
|
|
185
|
+
return <Input {...args} value={value} onChange={handleChange} />;
|
|
186
186
|
},
|
|
187
187
|
};
|
|
188
188
|
|
|
@@ -193,15 +193,16 @@ export const Errors: Story = {
|
|
|
193
193
|
},
|
|
194
194
|
render: (args) => {
|
|
195
195
|
const [value, setValue] = useState('');
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
196
|
+
|
|
197
|
+
useEffect(() => {
|
|
198
|
+
setValue(args.value);
|
|
199
|
+
}, [args.value]);
|
|
200
|
+
|
|
201
|
+
const handleChange = (e: { target: { value: SetStateAction<string> } }) => {
|
|
202
|
+
setValue(e.target.value);
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
return <Input {...args} value={value} onChange={handleChange} />;
|
|
205
206
|
},
|
|
206
207
|
};
|
|
207
208
|
|
|
@@ -212,15 +213,16 @@ export const HiddenLabel: Story = {
|
|
|
212
213
|
},
|
|
213
214
|
render: (args) => {
|
|
214
215
|
const [value, setValue] = useState('');
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
216
|
+
|
|
217
|
+
useEffect(() => {
|
|
218
|
+
setValue(args.value);
|
|
219
|
+
}, [args.value]);
|
|
220
|
+
|
|
221
|
+
const handleChange = (e: { target: { value: SetStateAction<string> } }) => {
|
|
222
|
+
setValue(e.target.value);
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
return <Input {...args} value={value} onChange={handleChange} />;
|
|
224
226
|
},
|
|
225
227
|
};
|
|
226
228
|
|
|
@@ -231,15 +233,16 @@ export const HelpText: Story = {
|
|
|
231
233
|
},
|
|
232
234
|
render: (args) => {
|
|
233
235
|
const [value, setValue] = useState('');
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
236
|
+
|
|
237
|
+
useEffect(() => {
|
|
238
|
+
setValue(args.value);
|
|
239
|
+
}, [args.value]);
|
|
240
|
+
|
|
241
|
+
const handleChange = (e: { target: { value: SetStateAction<string> } }) => {
|
|
242
|
+
setValue(e.target.value);
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
return <Input {...args} value={value} onChange={handleChange} />;
|
|
243
246
|
},
|
|
244
247
|
};
|
|
245
248
|
|
|
@@ -250,15 +253,16 @@ export const Clearable: Story = {
|
|
|
250
253
|
},
|
|
251
254
|
render: (args) => {
|
|
252
255
|
const [value, setValue] = useState('');
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
256
|
+
|
|
257
|
+
useEffect(() => {
|
|
258
|
+
setValue(args.value);
|
|
259
|
+
}, [args.value]);
|
|
260
|
+
|
|
261
|
+
const handleChange = (e: { target: { value: SetStateAction<string> } }) => {
|
|
262
|
+
setValue(e.target.value);
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
return <Input {...args} value={value} onChange={handleChange} />;
|
|
262
266
|
},
|
|
263
267
|
};
|
|
264
268
|
|
|
@@ -269,15 +273,16 @@ export const Icon: Story = {
|
|
|
269
273
|
},
|
|
270
274
|
render: (args) => {
|
|
271
275
|
const [value, setValue] = useState('');
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
276
|
+
|
|
277
|
+
useEffect(() => {
|
|
278
|
+
setValue(args.value);
|
|
279
|
+
}, [args.value]);
|
|
280
|
+
|
|
281
|
+
const handleChange = (e: { target: { value: SetStateAction<string> } }) => {
|
|
282
|
+
setValue(e.target.value);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
return <Input {...args} value={value} onChange={handleChange} />;
|
|
281
286
|
},
|
|
282
287
|
};
|
|
283
288
|
|
|
@@ -288,14 +293,15 @@ export const Required: Story = {
|
|
|
288
293
|
},
|
|
289
294
|
render: (args) => {
|
|
290
295
|
const [value, setValue] = useState('');
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
296
|
+
|
|
297
|
+
useEffect(() => {
|
|
298
|
+
setValue(args.value);
|
|
299
|
+
}, [args.value]);
|
|
300
|
+
|
|
301
|
+
const handleChange = (e: { target: { value: SetStateAction<string> } }) => {
|
|
302
|
+
setValue(e.target.value);
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
return <Input {...args} value={value} onChange={handleChange} />;
|
|
300
306
|
},
|
|
301
307
|
};
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
--pf-input-text-color: var(--pf-gray-color);
|
|
9
9
|
--pf-input-placeholder-text-color: var(--pf-gray-color-300);
|
|
10
10
|
--pf-input-help-text-color: var(--pf-gray-color-400);
|
|
11
|
+
--pf-input-disabled-background-color: var(--pf-gray-color-100);
|
|
12
|
+
--pf-input-border-color: var(--pf-gray-color);
|
|
13
|
+
--pf-input-disabled-color: var(--pf-gray-color-400);
|
|
14
|
+
--pf-input-border-color: var(--pf-gray-color);
|
|
11
15
|
|
|
12
16
|
// input Radius
|
|
13
17
|
--pf-input-rounded: var(--pf-rounded);
|
|
@@ -20,6 +24,9 @@
|
|
|
20
24
|
--pf-input-text-color: var(--pf-gray-color-100);
|
|
21
25
|
--pf-input-placeholder-text-color: var(--pf-gray-color);
|
|
22
26
|
--pf-input-help-text-color: var(--pf-gray-color-200);
|
|
27
|
+
--pf-input-disabled-background-color: var(--pf-primary-color-200);
|
|
28
|
+
--pf-input-disabled-border-color: var(--pf-gray-color-300);
|
|
29
|
+
--pf-input-disabled-color: var(--pf-gray-color-400);
|
|
23
30
|
}
|
|
24
31
|
|
|
25
32
|
.input {
|
|
@@ -56,9 +63,9 @@
|
|
|
56
63
|
}
|
|
57
64
|
|
|
58
65
|
&:disabled {
|
|
59
|
-
background-color: var(--pf-
|
|
60
|
-
border-color: var(--pf-
|
|
61
|
-
color: var(--pf-
|
|
66
|
+
background-color: var(--pf-input-disabled-background-color);
|
|
67
|
+
border-color: var(--pf-input-disabled-border-color);
|
|
68
|
+
color: var(--pf-input-disabled-color);
|
|
62
69
|
}
|
|
63
70
|
&--has-icon {
|
|
64
71
|
padding-left: var(--pf-padding-7);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Canvas, Meta, Controls } from '@storybook/blocks';
|
|
2
|
+
import * as Textarea from './Textarea.stories';
|
|
3
|
+
|
|
4
|
+
<Meta title="Forms/Textarea" name="Textarea" />
|
|
5
|
+
|
|
6
|
+
# Textarea
|
|
7
|
+
|
|
8
|
+
The Textarea component is the building block of any form. Below you will find the accepted properties for this component. It is encouraged to build forms utilizing [React Hook Form](https://react-hook-form.com/) library in your application. This will facilitate form state management and enforce best practices. (***Our components are compatible with but do not provide the plugin***)
|
|
9
|
+
|
|
10
|
+
<Canvas
|
|
11
|
+
of={Textarea.Default}
|
|
12
|
+
source={{
|
|
13
|
+
code: `
|
|
14
|
+
<Textarea name="first_name" isRequired helpText="This Is Help Text" placeholder="This is a placeholder" value="''" onChange={handleChange} label="Label Name" />
|
|
15
|
+
`,
|
|
16
|
+
}}
|
|
17
|
+
/>
|
|
18
|
+
|
|
19
|
+
<Controls of={Textarea.Default} />
|