@indico-data/design-system 2.8.0 → 2.10.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.
Files changed (38) hide show
  1. package/lib/index.css +216 -4
  2. package/lib/index.d.ts +41 -2
  3. package/lib/index.esm.css +216 -4
  4. package/lib/index.esm.js +19 -3
  5. package/lib/index.esm.js.map +1 -1
  6. package/lib/index.js +20 -2
  7. package/lib/index.js.map +1 -1
  8. package/lib/src/components/forms/input/Input.d.ts +2 -1
  9. package/lib/src/components/forms/passwordInput/PasswordInput.d.ts +16 -0
  10. package/lib/src/components/forms/passwordInput/PasswordInput.stories.d.ts +11 -0
  11. package/lib/src/components/forms/passwordInput/__tests__/PasswordInput.test.d.ts +1 -0
  12. package/lib/src/components/forms/passwordInput/index.d.ts +1 -0
  13. package/lib/src/components/forms/textarea/Textarea.d.ts +22 -0
  14. package/lib/src/components/forms/textarea/Textarea.stories.d.ts +11 -0
  15. package/lib/src/components/forms/textarea/__tests__/Textarea.test.d.ts +1 -0
  16. package/lib/src/components/forms/textarea/index.d.ts +1 -0
  17. package/lib/src/components/index.d.ts +2 -0
  18. package/lib/src/index.d.ts +2 -0
  19. package/package.json +1 -1
  20. package/src/components/forms/checkbox/styles/Checkbox.scss +1 -1
  21. package/src/components/forms/input/Input.stories.tsx +70 -69
  22. package/src/components/forms/input/Input.tsx +3 -1
  23. package/src/components/forms/input/styles/Input.scss +11 -3
  24. package/src/components/forms/passwordInput/PasswordInput.mdx +28 -0
  25. package/src/components/forms/passwordInput/PasswordInput.stories.tsx +269 -0
  26. package/src/components/forms/passwordInput/PasswordInput.tsx +82 -0
  27. package/src/components/forms/passwordInput/__tests__/PasswordInput.test.tsx +129 -0
  28. package/src/components/forms/passwordInput/index.ts +1 -0
  29. package/src/components/forms/passwordInput/styles/PasswordInput.scss +120 -0
  30. package/src/components/forms/textarea/Textarea.mdx +19 -0
  31. package/src/components/forms/textarea/Textarea.stories.tsx +363 -0
  32. package/src/components/forms/textarea/Textarea.tsx +85 -0
  33. package/src/components/forms/textarea/__tests__/Textarea.test.tsx +103 -0
  34. package/src/components/forms/textarea/index.ts +1 -0
  35. package/src/components/forms/textarea/styles/Textarea.scss +102 -0
  36. package/src/components/index.ts +2 -0
  37. package/src/index.ts +2 -0
  38. package/src/styles/index.scss +2 -0
@@ -14,5 +14,6 @@ export interface InputProps {
14
14
  hasHiddenLabel?: boolean;
15
15
  iconName?: IconName;
16
16
  isClearable?: boolean;
17
+ className?: string;
17
18
  }
18
- export declare const Input: ({ ref, label, name, placeholder, value, onChange, isRequired, isDisabled, errorList, helpText, iconName, hasHiddenLabel, isClearable, ...rest }: InputProps) => import("react/jsx-runtime").JSX.Element;
19
+ export declare const Input: ({ ref, label, name, placeholder, value, onChange, isRequired, isDisabled, errorList, helpText, iconName, hasHiddenLabel, isClearable, className, ...rest }: InputProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ export interface PasswordInputProps {
3
+ ref?: React.LegacyRef<HTMLInputElement>;
4
+ label: string;
5
+ name: string;
6
+ placeholder: string;
7
+ value: string;
8
+ onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
9
+ isRequired?: boolean;
10
+ isDisabled?: boolean;
11
+ errorList?: string[];
12
+ helpText?: string;
13
+ hasHiddenLabel?: boolean;
14
+ hasShowPassword?: boolean;
15
+ }
16
+ export declare const PasswordInput: ({ label, name, placeholder, value, onChange, isRequired, isDisabled, errorList, helpText, hasHiddenLabel, hasShowPassword, ...rest }: PasswordInputProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { PasswordInput } from './PasswordInput';
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ type Story = StoryObj<typeof PasswordInput>;
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 Required: Story;
11
+ export declare const NoTogglePasswordVisibility: Story;
@@ -0,0 +1 @@
1
+ export { PasswordInput } from './PasswordInput';
@@ -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 { Textarea } from './Textarea';
@@ -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';
@@ -11,3 +11,5 @@ 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
13
  export { Toggle as ToggleInput } from './components/forms/toggle';
14
+ export { Textarea } from './components/forms/textarea';
15
+ export { PasswordInput } from './components/forms/passwordInput';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indico-data/design-system",
3
- "version": "2.8.0",
3
+ "version": "2.10.0",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "lib/index.js",
@@ -10,7 +10,7 @@
10
10
 
11
11
  // Dark Theme Specific Variables
12
12
  :root [data-theme='dark'] {
13
- --pf-checkbox-background-color: transparent;
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);
@@ -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 = {
@@ -27,7 +27,6 @@ const meta: Meta = {
27
27
  summary: 'string',
28
28
  },
29
29
  },
30
- defaultValue: { summary: '' },
31
30
  },
32
31
  name: {
33
32
  control: 'text',
@@ -38,7 +37,6 @@ const meta: Meta = {
38
37
  summary: 'string',
39
38
  },
40
39
  },
41
- defaultValue: { summary: '' },
42
40
  },
43
41
  placeholder: {
44
42
  control: 'text',
@@ -49,7 +47,6 @@ const meta: Meta = {
49
47
  summary: 'string',
50
48
  },
51
49
  },
52
- defaultValue: { summary: '' },
53
50
  },
54
51
  value: {
55
52
  control: 'text',
@@ -60,7 +57,6 @@ const meta: Meta = {
60
57
  summary: 'string',
61
58
  },
62
59
  },
63
- defaultValue: { summary: '' },
64
60
  },
65
61
  isRequired: {
66
62
  control: 'boolean',
@@ -104,7 +100,6 @@ const meta: Meta = {
104
100
  summary: 'string',
105
101
  },
106
102
  },
107
- defaultValue: { summary: '' },
108
103
  },
109
104
  hasHiddenLabel: {
110
105
  control: 'boolean',
@@ -174,15 +169,15 @@ export const Default: Story = {
174
169
  },
175
170
  render: (args) => {
176
171
  const [value, setValue] = useState('');
177
- return (
178
- <Input
179
- {...args}
180
- value={value}
181
- onChange={(e) => {
182
- setValue(e.target.value);
183
- }}
184
- />
185
- );
172
+
173
+ useEffect(() => {
174
+ setValue(args.value);
175
+ }, [args.value]);
176
+
177
+ const handleChange = (e: { target: { value: SetStateAction<string> } }) => {
178
+ setValue(e.target.value);
179
+ };
180
+ return <Input {...args} value={value} onChange={handleChange} />;
186
181
  },
187
182
  };
188
183
 
@@ -193,15 +188,16 @@ export const Errors: Story = {
193
188
  },
194
189
  render: (args) => {
195
190
  const [value, setValue] = useState('');
196
- return (
197
- <Input
198
- {...args}
199
- value={value}
200
- onChange={(e) => {
201
- setValue(e.target.value);
202
- }}
203
- />
204
- );
191
+
192
+ useEffect(() => {
193
+ setValue(args.value);
194
+ }, [args.value]);
195
+
196
+ const handleChange = (e: { target: { value: SetStateAction<string> } }) => {
197
+ setValue(e.target.value);
198
+ };
199
+
200
+ return <Input {...args} value={value} onChange={handleChange} />;
205
201
  },
206
202
  };
207
203
 
@@ -212,15 +208,16 @@ export const HiddenLabel: Story = {
212
208
  },
213
209
  render: (args) => {
214
210
  const [value, setValue] = useState('');
215
- return (
216
- <Input
217
- {...args}
218
- value={value}
219
- onChange={(e) => {
220
- setValue(e.target.value);
221
- }}
222
- />
223
- );
211
+
212
+ useEffect(() => {
213
+ setValue(args.value);
214
+ }, [args.value]);
215
+
216
+ const handleChange = (e: { target: { value: SetStateAction<string> } }) => {
217
+ setValue(e.target.value);
218
+ };
219
+
220
+ return <Input {...args} value={value} onChange={handleChange} />;
224
221
  },
225
222
  };
226
223
 
@@ -231,15 +228,16 @@ export const HelpText: Story = {
231
228
  },
232
229
  render: (args) => {
233
230
  const [value, setValue] = useState('');
234
- return (
235
- <Input
236
- {...args}
237
- value={value}
238
- onChange={(e) => {
239
- setValue(e.target.value);
240
- }}
241
- />
242
- );
231
+
232
+ useEffect(() => {
233
+ setValue(args.value);
234
+ }, [args.value]);
235
+
236
+ const handleChange = (e: { target: { value: SetStateAction<string> } }) => {
237
+ setValue(e.target.value);
238
+ };
239
+
240
+ return <Input {...args} value={value} onChange={handleChange} />;
243
241
  },
244
242
  };
245
243
 
@@ -250,15 +248,16 @@ export const Clearable: Story = {
250
248
  },
251
249
  render: (args) => {
252
250
  const [value, setValue] = useState('');
253
- return (
254
- <Input
255
- {...args}
256
- value={value}
257
- onChange={(e) => {
258
- setValue(e.target.value);
259
- }}
260
- />
261
- );
251
+
252
+ useEffect(() => {
253
+ setValue(args.value);
254
+ }, [args.value]);
255
+
256
+ const handleChange = (e: { target: { value: SetStateAction<string> } }) => {
257
+ setValue(e.target.value);
258
+ };
259
+
260
+ return <Input {...args} value={value} onChange={handleChange} />;
262
261
  },
263
262
  };
264
263
 
@@ -269,15 +268,16 @@ export const Icon: Story = {
269
268
  },
270
269
  render: (args) => {
271
270
  const [value, setValue] = useState('');
272
- return (
273
- <Input
274
- {...args}
275
- value={value}
276
- onChange={(e) => {
277
- setValue(e.target.value);
278
- }}
279
- />
280
- );
271
+
272
+ useEffect(() => {
273
+ setValue(args.value);
274
+ }, [args.value]);
275
+
276
+ const handleChange = (e: { target: { value: SetStateAction<string> } }) => {
277
+ setValue(e.target.value);
278
+ };
279
+
280
+ return <Input {...args} value={value} onChange={handleChange} />;
281
281
  },
282
282
  };
283
283
 
@@ -288,14 +288,15 @@ export const Required: Story = {
288
288
  },
289
289
  render: (args) => {
290
290
  const [value, setValue] = useState('');
291
- return (
292
- <Input
293
- {...args}
294
- value={value}
295
- onChange={(e) => {
296
- setValue(e.target.value);
297
- }}
298
- />
299
- );
291
+
292
+ useEffect(() => {
293
+ setValue(args.value);
294
+ }, [args.value]);
295
+
296
+ const handleChange = (e: { target: { value: SetStateAction<string> } }) => {
297
+ setValue(e.target.value);
298
+ };
299
+
300
+ return <Input {...args} value={value} onChange={handleChange} />;
300
301
  },
301
302
  };
@@ -18,6 +18,7 @@ export interface InputProps {
18
18
  hasHiddenLabel?: boolean;
19
19
  iconName?: IconName;
20
20
  isClearable?: boolean;
21
+ className?: string;
21
22
  }
22
23
 
23
24
  export const Input = ({
@@ -34,6 +35,7 @@ export const Input = ({
34
35
  iconName,
35
36
  hasHiddenLabel,
36
37
  isClearable,
38
+ className = '',
37
39
  ...rest
38
40
  }: InputProps) => {
39
41
  const hasErrors = errorList && errorList.length > 0;
@@ -58,7 +60,7 @@ export const Input = ({
58
60
  placeholder={placeholder}
59
61
  value={value}
60
62
  onChange={onChange}
61
- className={`input ${hasErrors ? 'error' : ''} ${iconName ? 'input--has-icon' : ''}`}
63
+ className={`input ${hasErrors ? 'error' : ''} ${iconName ? 'input--has-icon' : ''} ${className}`}
62
64
  aria-invalid={hasErrors}
63
65
  aria-describedby={hasErrors || helpText ? `${name}-helper` : undefined}
64
66
  aria-required={isRequired}
@@ -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-gray-color-100);
60
- border-color: var(--pf-gray-color-300);
61
- color: var(--pf-gray-color-400);
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);
@@ -93,6 +100,7 @@
93
100
  top: var(--pf-margin-3);
94
101
  right: var(--pf-margin-2);
95
102
  color: var(--pf-input-text-color);
103
+ cursor: pointer;
96
104
  }
97
105
  }
98
106
  .is-visually-hidden {
@@ -0,0 +1,28 @@
1
+ import { Canvas, Meta, Controls } from '@storybook/blocks';
2
+ import * as PasswordInput from './PasswordInput.stories';
3
+
4
+ <Meta title="Forms/PasswordInput" name="PasswordInput" />
5
+
6
+ # Password Input
7
+
8
+ The password input 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={PasswordInput.Default}
12
+ source={{
13
+ code: `
14
+ <PasswordInput
15
+ name="first_name"
16
+ isRequired
17
+ hasShowPassword
18
+ placeholder="Placeholder Text"
19
+ value=''
20
+ onChange={() => {}}
21
+ helpText="This Is Help Text"
22
+ label="Label Name"
23
+ />
24
+ `,
25
+ }}
26
+ />
27
+
28
+ <Controls of={PasswordInput.Default} />