pixel-react 1.0.5 → 1.0.7
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/.yarn/install-state.gz +0 -0
- package/lib/StyleGuide/ColorPalette/types.d.ts +2 -0
- package/lib/assets/utils/functionUtils.d.ts +3 -0
- package/lib/components/DatePicker/DatePicker.d.ts +5 -0
- package/lib/components/DatePicker/DatePicker.stories.d.ts +9 -0
- package/lib/components/DatePicker/Timepicker.d.ts +4 -0
- package/lib/components/DatePicker/index.d.ts +1 -0
- package/lib/components/DatePicker/types.d.ts +81 -0
- package/lib/components/DragAndDrop/DragAndDrop.d.ts +9 -0
- package/lib/components/DragAndDrop/DragAndDrop.stories.d.ts +6 -0
- package/lib/components/DragAndDrop/DragAndDropList.d.ts +20 -0
- package/lib/components/DragAndDrop/index.d.ts +1 -0
- package/lib/components/Drawer/Drawer.d.ts +2 -1
- package/lib/components/IconButton/IconButton.d.ts +5 -0
- package/lib/components/IconButton/IconButton.stories.d.ts +6 -0
- package/lib/components/IconButton/index.d.ts +1 -0
- package/lib/components/{AddButton → IconButton}/types.d.ts +3 -2
- package/lib/components/InputWithDropdown/InputWithDropdown.d.ts +1 -1
- package/lib/components/InputWithDropdown/types.d.ts +3 -7
- package/lib/components/Modal/Modal.d.ts +5 -0
- package/lib/components/Modal/Modal.stories.d.ts +7 -0
- package/lib/components/Modal/index.d.ts +1 -0
- package/lib/components/Modal/types.d.ts +26 -0
- package/lib/components/TableTree/TableTree.d.ts +2 -2
- package/lib/components/ThemeProvider/CustomThemeProvider.d.ts +8 -0
- package/lib/hooks/useCustomThemeProvider.d.ts +11 -0
- package/lib/index.d.ts +76 -16
- package/lib/index.esm.js +13365 -414
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +13368 -415
- package/lib/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +28 -23
- package/src/StyleGuide/ColorPalette/ColorPalette.scss +5 -0
- package/src/StyleGuide/ColorPalette/ColorPalette.tsx +10 -1
- package/src/StyleGuide/ColorPalette/colorPaletteList.ts +2 -2
- package/src/StyleGuide/ColorPalette/types.ts +2 -0
- package/src/assets/Themes/BaseTheme.scss +9 -1
- package/src/assets/Themes/DarkTheme.scss +8 -1
- package/src/assets/icons/add_variable_icon.svg +5 -0
- package/src/assets/icons/calendar_icon.svg +9 -0
- package/src/assets/icons/clock_icon.svg +11 -0
- package/src/assets/icons/collapse-icon.svg +6 -0
- package/src/assets/icons/copy-icon.svg +3 -0
- package/src/assets/icons/download-icon.svg +3 -0
- package/src/assets/icons/expand-icon.svg +6 -0
- package/src/assets/icons/info_icon.svg +4 -0
- package/src/assets/icons/left_arrow_icon.svg +3 -0
- package/src/assets/icons/license_info.svg +28 -0
- package/src/assets/icons/license_warning.svg +10 -0
- package/src/assets/icons/refresh-icon.svg +4 -0
- package/src/assets/icons/right_arrow_icon.svg +4 -0
- package/src/assets/styles/_mixins.scss +1 -0
- package/src/assets/utils/functionUtils.ts +37 -0
- package/src/components/DatePicker/DatePicker.scss +387 -0
- package/src/components/DatePicker/DatePicker.stories.tsx +161 -0
- package/src/components/DatePicker/DatePicker.tsx +438 -0
- package/src/components/DatePicker/Timepicker.tsx +372 -0
- package/src/components/DatePicker/index.ts +1 -0
- package/src/components/DatePicker/types.ts +100 -0
- package/src/components/DragAndDrop/DragAndDrop.d.ts +5 -0
- package/src/components/DragAndDrop/DragAndDrop.stories.tsx +25 -0
- package/src/components/DragAndDrop/DragAndDrop.ts +7 -0
- package/src/components/DragAndDrop/DragAndDropList.scss +69 -0
- package/src/components/DragAndDrop/DragAndDropList.tsx +150 -0
- package/src/components/DragAndDrop/index.ts +1 -0
- package/src/components/Drawer/Drawer.scss +0 -1
- package/src/components/Drawer/Drawer.tsx +7 -15
- package/src/components/Icon/iconList.ts +31 -9
- package/src/components/{AddButton/AddButton.scss → IconButton/IconButton.scss} +6 -2
- package/src/components/IconButton/IconButton.stories.tsx +25 -0
- package/src/components/{AddButton/AddButton.tsx → IconButton/IconButton.tsx} +10 -7
- package/src/components/IconButton/index.ts +1 -0
- package/src/components/{AddButton → IconButton}/types.ts +3 -2
- package/src/components/InputWithDropdown/InputWithDropdown.scss +1 -1
- package/src/components/InputWithDropdown/InputWithDropdown.stories.tsx +10 -13
- package/src/components/InputWithDropdown/InputWithDropdown.tsx +10 -8
- package/src/components/InputWithDropdown/types.ts +4 -7
- package/src/components/Modal/Modal.stories.tsx +63 -0
- package/src/components/Modal/Modal.tsx +71 -0
- package/src/components/Modal/index.tsx +1 -0
- package/src/components/Modal/modal.scss +37 -0
- package/src/components/Modal/types.ts +37 -0
- package/src/components/RadioButton/RadioButton.scss +3 -3
- package/src/components/Select/Select.scss +1 -1
- package/src/components/TableTree/TableTree.tsx +5 -1
- package/src/components/ThemeProvider/ThemeProvider.tsx +11 -8
- package/src/index.ts +6 -6
- package/lib/components/AddButton/AddButton.d.ts +0 -5
- package/lib/components/AddButton/AddButton.stories.d.ts +0 -6
- package/lib/components/AddButton/index.d.ts +0 -1
- package/src/assets/icons/expired_license_icon.svg +0 -3
- package/src/assets/icons/expiringSoon_license_icon.svg +0 -3
- package/src/components/AddButton/AddButton.stories.tsx +0 -24
- package/src/components/AddButton/index.ts +0 -1
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import DragAndDrop from './DragAndDrop';
|
|
3
|
+
const {
|
|
4
|
+
DNDCore: {
|
|
5
|
+
DndContext,
|
|
6
|
+
KeyboardSensor,
|
|
7
|
+
PointerSensor,
|
|
8
|
+
useSensor,
|
|
9
|
+
useSensors,
|
|
10
|
+
closestCorners,
|
|
11
|
+
},
|
|
12
|
+
DNDSortable: {
|
|
13
|
+
useSortable,
|
|
14
|
+
arrayMove,
|
|
15
|
+
sortableKeyboardCoordinates,
|
|
16
|
+
SortableContext,
|
|
17
|
+
verticalListSortingStrategy,
|
|
18
|
+
},
|
|
19
|
+
DNDUtilities: { CSS },
|
|
20
|
+
} = DragAndDrop;
|
|
21
|
+
import Typography from '../Typography';
|
|
22
|
+
|
|
23
|
+
import './DragAndDropList.scss';
|
|
24
|
+
|
|
25
|
+
interface TaskProps {
|
|
26
|
+
id: number;
|
|
27
|
+
title: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const Task = ({ id, title }: TaskProps) => {
|
|
31
|
+
const { attributes, listeners, setNodeRef, transform, transition } =
|
|
32
|
+
useSortable({ id });
|
|
33
|
+
|
|
34
|
+
const style = {
|
|
35
|
+
transition,
|
|
36
|
+
transform: CSS.Transform.toString(transform),
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div
|
|
41
|
+
ref={setNodeRef}
|
|
42
|
+
style={style}
|
|
43
|
+
{...attributes}
|
|
44
|
+
{...listeners}
|
|
45
|
+
className="task"
|
|
46
|
+
>
|
|
47
|
+
<Typography as='h1' fontSize={16} className='task-title'>{title}</Typography>
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
interface ColumnProps {
|
|
53
|
+
id: string;
|
|
54
|
+
tasks: { id: number; title: string }[];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const Column: React.FC<ColumnProps> = ({ tasks }) => {
|
|
58
|
+
return (
|
|
59
|
+
<div className="column">
|
|
60
|
+
<SortableContext items={tasks} strategy={verticalListSortingStrategy}>
|
|
61
|
+
{tasks.map((task) => (
|
|
62
|
+
<Task key={task.id} id={task.id} title={task.title} />
|
|
63
|
+
))}
|
|
64
|
+
</SortableContext>
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
interface InputProps {
|
|
70
|
+
onSubmit: (input: string) => void;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export const Input: React.FC<InputProps> = ({ onSubmit }) => {
|
|
74
|
+
const [input, setInput] = useState('');
|
|
75
|
+
|
|
76
|
+
const handleSubmit = () => {
|
|
77
|
+
if (!input) return;
|
|
78
|
+
|
|
79
|
+
onSubmit(input);
|
|
80
|
+
|
|
81
|
+
setInput('');
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<div className="container">
|
|
86
|
+
<input
|
|
87
|
+
className="input"
|
|
88
|
+
type="text"
|
|
89
|
+
value={input}
|
|
90
|
+
onChange={(e) => setInput(e.target.value)}
|
|
91
|
+
/>
|
|
92
|
+
<button onClick={handleSubmit} className="button">
|
|
93
|
+
<Typography fontSize={14}>Add</Typography>
|
|
94
|
+
</button>
|
|
95
|
+
</div>
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const DragAndDropList = () => {
|
|
100
|
+
const [tasks, setTasks] = useState([
|
|
101
|
+
{ id: 1, title: 'Add tests to homepage' },
|
|
102
|
+
{ id: 2, title: 'Fix styling in about section' },
|
|
103
|
+
{ id: 3, title: 'Learn how to center a div' },
|
|
104
|
+
]);
|
|
105
|
+
|
|
106
|
+
const addTask = (title: any) => {
|
|
107
|
+
setTasks((tasks) => [...tasks, { id: tasks.length + 1, title }]);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const sensors = useSensors(
|
|
111
|
+
useSensor(PointerSensor),
|
|
112
|
+
useSensor(KeyboardSensor, {
|
|
113
|
+
coordinateGetter: sortableKeyboardCoordinates,
|
|
114
|
+
})
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
const getTaskPos = (id: number): number =>
|
|
118
|
+
tasks.findIndex((task) => task.id === id);
|
|
119
|
+
|
|
120
|
+
const handleDragEnd = (event: any) => {
|
|
121
|
+
const { active, over } = event;
|
|
122
|
+
|
|
123
|
+
if (active.id === over.id) return;
|
|
124
|
+
|
|
125
|
+
setTasks((tasks) => {
|
|
126
|
+
const originalPos = getTaskPos(active.id);
|
|
127
|
+
const newPos = getTaskPos(over.id);
|
|
128
|
+
|
|
129
|
+
return arrayMove(tasks, originalPos, newPos);
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<div className="drag-and-drop-list">
|
|
135
|
+
<Typography fontSize={32} fontWeight="semi-bold">
|
|
136
|
+
Drag and Drop test ✅
|
|
137
|
+
</Typography>
|
|
138
|
+
<Input onSubmit={addTask} />
|
|
139
|
+
<DndContext
|
|
140
|
+
sensors={sensors}
|
|
141
|
+
collisionDetection={closestCorners}
|
|
142
|
+
onDragEnd={handleDragEnd}
|
|
143
|
+
>
|
|
144
|
+
<Column id="toDo" tasks={tasks} />
|
|
145
|
+
</DndContext>
|
|
146
|
+
</div>
|
|
147
|
+
);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export default DragAndDropList;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DragAndDrop';
|
|
@@ -3,11 +3,11 @@ import { DrawerProps } from './Types.js';
|
|
|
3
3
|
import Button from '../Button/Button.js';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import './Drawer.scss';
|
|
6
|
-
import { useEffect, useState } from 'react';
|
|
6
|
+
import { FC, useContext, useEffect, useState } from 'react';
|
|
7
7
|
import Icon from '../Icon';
|
|
8
8
|
import useEscapeKey from '../../hooks/keyboardevents/useEscKeyEvent.js';
|
|
9
|
-
|
|
10
|
-
const Drawer = ({
|
|
9
|
+
import { ThemeContext } from '../ThemeProvider/ThemeProvider.js';
|
|
10
|
+
const Drawer: FC<DrawerProps> = ({
|
|
11
11
|
isOpen = true,
|
|
12
12
|
children = 'Drawer content area',
|
|
13
13
|
onClose = () => {},
|
|
@@ -57,9 +57,10 @@ const Drawer = ({
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
const drawerSize = isExpanded ? 'x-large' : size;
|
|
60
|
-
|
|
60
|
+
const themeContext = useContext(ThemeContext);
|
|
61
|
+
const currentTheme = themeContext?.currentTheme;
|
|
61
62
|
return createPortal(
|
|
62
|
-
<div className=
|
|
63
|
+
<div className={classNames('ff-drawer-container', currentTheme)}>
|
|
63
64
|
{overlay && <div className="ff-overlay" />}
|
|
64
65
|
|
|
65
66
|
<div
|
|
@@ -102,16 +103,7 @@ const Drawer = ({
|
|
|
102
103
|
<div className="ff-drawer-title">{title}</div>
|
|
103
104
|
</div>
|
|
104
105
|
{_isCloseModalButtonVisible && (
|
|
105
|
-
<
|
|
106
|
-
<button onClick={onClose}>
|
|
107
|
-
<Icon
|
|
108
|
-
name="info"
|
|
109
|
-
height={16}
|
|
110
|
-
width={16}
|
|
111
|
-
hoverEffect={false}
|
|
112
|
-
/>
|
|
113
|
-
</button>
|
|
114
|
-
</div>
|
|
106
|
+
<Icon name="close" hoverEffect={false} onClick={onClose} />
|
|
115
107
|
)}
|
|
116
108
|
</div>
|
|
117
109
|
</div>
|
|
@@ -29,23 +29,34 @@ import WrongMarkIcon from '../../assets/icons/wrong_mark.svg?react';
|
|
|
29
29
|
import Tick from '../../assets/Icons/tick_icon.svg?react';
|
|
30
30
|
import Search from '../../assets/icons/search.svg?react';
|
|
31
31
|
import Filter from '../../assets/icons/filter.svg?react';
|
|
32
|
+
import RightArrow from '../../assets/icons/right_arrow_icon.svg?react';
|
|
33
|
+
import LeftArrow from '../../assets/icons/left_arrow_icon.svg?react';
|
|
34
|
+
import ClockIcon from '../../assets/icons/clock_icon.svg?react';
|
|
32
35
|
import Edit from '../../assets/icons/edit_icon.svg?react';
|
|
33
36
|
import ViewIcon from '../../assets/icons/view_icon.svg?react';
|
|
34
|
-
import HideIcon from '../../assets/icons/hide_icon.svg?react';
|
|
35
37
|
import ExportCollection from '../../assets/icons/export_collection_icon.svg?react';
|
|
36
38
|
import RunIcon from '../../assets/icons/run_icon.svg?react';
|
|
39
|
+
import AddVariable from '../../assets/icons/add_variable_icon.svg?react';
|
|
37
40
|
|
|
38
|
-
import
|
|
39
|
-
import ExpiredLicenseIcon from '../../assets/icons/expired_license_icon.svg?react';
|
|
40
|
-
import ExpiringSoonLicenseIcon from '../../assets/icons/expiringSoon_license_icon.svg?react';
|
|
41
|
+
import LicenseIcon from '../../assets/icons/active_license_icon.svg?react';
|
|
41
42
|
import DeleteIcon from '../../assets/icons/delete.svg?react';
|
|
42
43
|
import DetailsIcon from '../../assets/icons/details.svg?react';
|
|
43
44
|
import ImpactListIcon from '../../assets/icons/impactList.svg?react';
|
|
45
|
+
import InfoIcon from '../../assets/icons/info_icon.svg?react';
|
|
46
|
+
import CalendarIcon from '../../assets/icons/calendar_icon.svg?react';
|
|
47
|
+
import HideIcon from '../../assets/icons/hide_icon.svg?react';
|
|
48
|
+
import CollapseIcon from '../../assets/icons/collapse-icon.svg?react';
|
|
49
|
+
import ExpandIcon from '../../assets/icons/expand-icon.svg?react';
|
|
50
|
+
import CopyIcon from '../../assets/icons/copy-icon.svg?react';
|
|
51
|
+
import DownloadFile from '../../assets/icons/download-icon.svg?react';
|
|
52
|
+
import RefreshIcon from '../../assets/icons/refresh-icon.svg?react';
|
|
53
|
+
import LicenseInfo from '../../assets/icons/license_info.svg?react';
|
|
54
|
+
import LicenseWarning from '../../assets/icons/license_warning.svg?react';
|
|
44
55
|
//icons
|
|
45
56
|
Components['delete_info'] = DeleteInfoIcon;
|
|
46
57
|
Components['success'] = ToastSuccessIcon;
|
|
47
58
|
Components['warning'] = WarningIcon;
|
|
48
|
-
Components['
|
|
59
|
+
Components['toast_info'] = ToastInfoIcon;
|
|
49
60
|
Components['error'] = ToastErrorIcon;
|
|
50
61
|
Components['close'] = ToastCloseIcon;
|
|
51
62
|
Components['more'] = MoreIcon;
|
|
@@ -71,16 +82,27 @@ Components['tick'] = Tick;
|
|
|
71
82
|
Components['arrow_right'] = ArrowRight;
|
|
72
83
|
Components['search'] = Search;
|
|
73
84
|
Components['filter'] = Filter;
|
|
85
|
+
Components['right_arrow_icon'] = RightArrow;
|
|
86
|
+
Components['left_arrow_icon'] = LeftArrow;
|
|
87
|
+
Components['clock_icon'] = ClockIcon;
|
|
74
88
|
Components['edit'] = Edit;
|
|
75
89
|
Components['view_icon'] = ViewIcon;
|
|
76
|
-
Components['hide_icon'] = HideIcon;
|
|
77
90
|
Components['export_collection'] = ExportCollection;
|
|
78
91
|
Components['run_icon'] = RunIcon;
|
|
79
|
-
Components['
|
|
80
|
-
Components['expired_license_icon'] = ExpiredLicenseIcon;
|
|
81
|
-
Components['expiringSoon_license_icon'] = ExpiringSoonLicenseIcon;
|
|
92
|
+
Components['license'] = LicenseIcon;
|
|
82
93
|
Components['delete'] = DeleteIcon;
|
|
83
94
|
Components['details'] = DetailsIcon;
|
|
84
95
|
Components['impactList'] = ImpactListIcon;
|
|
96
|
+
Components['add_variable'] = AddVariable;
|
|
97
|
+
Components['info'] = InfoIcon;
|
|
98
|
+
Components['calendar_icon'] = CalendarIcon;
|
|
99
|
+
Components['hide_icon'] = HideIcon;
|
|
100
|
+
Components['collapse_icon'] = CollapseIcon;
|
|
101
|
+
Components['refresh_icon'] = RefreshIcon;
|
|
102
|
+
Components['download_file'] = DownloadFile;
|
|
103
|
+
Components['copy_icon'] = CopyIcon;
|
|
104
|
+
Components['expand_icon'] = ExpandIcon;
|
|
105
|
+
Components['license_info'] = LicenseInfo;
|
|
106
|
+
Components['license_warning'] = LicenseWarning;
|
|
85
107
|
|
|
86
108
|
export default Components;
|
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
padding: 2px 8px 2px 2px;
|
|
16
16
|
border: 1px solid transparent;
|
|
17
17
|
.ff-icon-color {
|
|
18
|
-
|
|
18
|
+
path {
|
|
19
|
+
color: var(--primary-icon-color);
|
|
20
|
+
}
|
|
19
21
|
}
|
|
20
22
|
.icon-name {
|
|
21
23
|
min-width: 33px;
|
|
@@ -32,7 +34,9 @@
|
|
|
32
34
|
color: var(--secondary-icon-color);
|
|
33
35
|
}
|
|
34
36
|
.ff-icon-color {
|
|
35
|
-
|
|
37
|
+
path {
|
|
38
|
+
color: var(--secondary-icon-color);
|
|
39
|
+
}
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import IconButton from './IconButton';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof IconButton> = {
|
|
5
|
+
title: 'Components/IconButton',
|
|
6
|
+
component: IconButton,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: 'centered',
|
|
9
|
+
},
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type Story = StoryObj<typeof IconButton>;
|
|
14
|
+
|
|
15
|
+
export const PrimaryIconButton: Story = {
|
|
16
|
+
render: () => {
|
|
17
|
+
const name = 'Project';
|
|
18
|
+
const icon = 'plus_icon';
|
|
19
|
+
const onClick = () => {};
|
|
20
|
+
|
|
21
|
+
return <IconButton label={name} iconName={icon} onClick={onClick} />;
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default meta;
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Icon from '../Icon';
|
|
3
|
-
import './
|
|
3
|
+
import './IconButton.scss';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import Typography from '../Typography';
|
|
6
|
-
import {
|
|
6
|
+
import { IconButtonProps } from './types';
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const IconButton: React.FC<IconButtonProps> = ({
|
|
9
|
+
label,
|
|
10
|
+
iconName = 'plus_icon',
|
|
11
|
+
onClick,
|
|
12
|
+
}) => {
|
|
9
13
|
return (
|
|
10
14
|
<button onClick={onClick} className={classNames('ff-plus-icon')}>
|
|
11
15
|
<Icon
|
|
12
16
|
height={20}
|
|
13
17
|
width={20}
|
|
14
|
-
name={
|
|
15
|
-
color=''
|
|
18
|
+
name={iconName}
|
|
16
19
|
className={'ff-icon-color'}
|
|
17
20
|
/>
|
|
18
21
|
<Typography as="div" textAlign="center" className="icon-name">
|
|
19
|
-
{
|
|
22
|
+
{label}
|
|
20
23
|
</Typography>
|
|
21
24
|
</button>
|
|
22
25
|
);
|
|
23
26
|
};
|
|
24
27
|
|
|
25
|
-
export default
|
|
28
|
+
export default IconButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './IconButton';
|
|
@@ -43,8 +43,7 @@ export const DisabledWithValue: Story = {
|
|
|
43
43
|
args: {
|
|
44
44
|
...defaultArgs,
|
|
45
45
|
variant: 'primary',
|
|
46
|
-
|
|
47
|
-
value: 'Disabled',
|
|
46
|
+
value: 12345,
|
|
48
47
|
disabled: true,
|
|
49
48
|
required: true,
|
|
50
49
|
},
|
|
@@ -52,7 +51,7 @@ export const DisabledWithValue: Story = {
|
|
|
52
51
|
|
|
53
52
|
export const Controlled: Story = {
|
|
54
53
|
render: () => {
|
|
55
|
-
const [value, setValue] = useState<
|
|
54
|
+
const [value, setValue] = useState<number>(0);
|
|
56
55
|
const [error, setError] = useState<boolean>(false);
|
|
57
56
|
const [helperText, setHelperText] = useState<string>('');
|
|
58
57
|
|
|
@@ -70,18 +69,18 @@ export const Controlled: Story = {
|
|
|
70
69
|
|
|
71
70
|
const onDropdownChangeHandler = (option: Option) => {
|
|
72
71
|
setSelectedOption(option);
|
|
73
|
-
setValue(
|
|
72
|
+
setValue(0);
|
|
74
73
|
};
|
|
75
74
|
|
|
76
75
|
const onInputChangeHandler = (event: ChangeEvent<HTMLInputElement>) => {
|
|
77
|
-
const inputValue = event.target.value;
|
|
76
|
+
const inputValue = parseInt(event.target.value);
|
|
78
77
|
setValue(inputValue);
|
|
79
78
|
|
|
80
79
|
if (event.target) {
|
|
81
|
-
if (inputValue
|
|
80
|
+
if (inputValue < 0 || checkEmpty(value)) {
|
|
82
81
|
setError(true);
|
|
83
82
|
setHelperText(`${event.target.name} is required`);
|
|
84
|
-
} else if (inputValue
|
|
83
|
+
} else if (inputValue > 999) {
|
|
85
84
|
setError(true);
|
|
86
85
|
setHelperText(`${event.target.name} should be upto 999`);
|
|
87
86
|
} else {
|
|
@@ -98,7 +97,6 @@ export const Controlled: Story = {
|
|
|
98
97
|
label="ImplicitTime"
|
|
99
98
|
placeholder={`Enter ImplicitTime here`}
|
|
100
99
|
value={value}
|
|
101
|
-
type="number"
|
|
102
100
|
required={true}
|
|
103
101
|
error={error}
|
|
104
102
|
helperText={helperText}
|
|
@@ -113,7 +111,7 @@ export const Controlled: Story = {
|
|
|
113
111
|
|
|
114
112
|
export const InputWithStaticLabelWithoutOptions: Story = {
|
|
115
113
|
render: () => {
|
|
116
|
-
const [value, setValue] = useState<
|
|
114
|
+
const [value, setValue] = useState<number>(0);
|
|
117
115
|
const [error, setError] = useState<boolean>(false);
|
|
118
116
|
const [helperText, setHelperText] = useState<string>('');
|
|
119
117
|
|
|
@@ -126,18 +124,18 @@ export const InputWithStaticLabelWithoutOptions: Story = {
|
|
|
126
124
|
|
|
127
125
|
const onDropdownChangeHandler = (option: Option) => {
|
|
128
126
|
setSelectedOption(option);
|
|
129
|
-
setValue(
|
|
127
|
+
setValue(0);
|
|
130
128
|
};
|
|
131
129
|
|
|
132
130
|
const onInputChangeHandler = (event: ChangeEvent<HTMLInputElement>) => {
|
|
133
|
-
const inputValue = event.target.value;
|
|
131
|
+
const inputValue = parseInt(event.target.value);
|
|
134
132
|
setValue(inputValue);
|
|
135
133
|
|
|
136
134
|
if (event.target) {
|
|
137
135
|
if (checkEmpty(inputValue)) {
|
|
138
136
|
setError(true);
|
|
139
137
|
setHelperText(`${event.target.name} is required`);
|
|
140
|
-
} else if (
|
|
138
|
+
} else if (inputValue >= 366) {
|
|
141
139
|
setError(true);
|
|
142
140
|
setHelperText(`${event.target.name} should be upto 365`);
|
|
143
141
|
} else {
|
|
@@ -154,7 +152,6 @@ export const InputWithStaticLabelWithoutOptions: Story = {
|
|
|
154
152
|
label="Duration"
|
|
155
153
|
placeholder={`Enter Duration here`}
|
|
156
154
|
value={value}
|
|
157
|
-
type="number"
|
|
158
155
|
required={true}
|
|
159
156
|
error={error}
|
|
160
157
|
helperText={helperText}
|
|
@@ -8,7 +8,6 @@ const InputWithDropdown = ({
|
|
|
8
8
|
name = '',
|
|
9
9
|
label,
|
|
10
10
|
value,
|
|
11
|
-
type,
|
|
12
11
|
disabled = false,
|
|
13
12
|
required = false,
|
|
14
13
|
placeholder,
|
|
@@ -18,18 +17,20 @@ const InputWithDropdown = ({
|
|
|
18
17
|
selectedOption,
|
|
19
18
|
onDropdownChangeHandler = () => {},
|
|
20
19
|
onInputChangeHandler,
|
|
20
|
+
onInputBlurHandler,
|
|
21
21
|
optionsRequired = true,
|
|
22
22
|
}: InputWithDropdownProps) => {
|
|
23
|
+
const isValueFilled = value !== undefined && value >= 0;
|
|
23
24
|
return (
|
|
24
25
|
<div
|
|
25
26
|
className={classNames('ff-input-with-dropdown-container', {
|
|
26
|
-
'ff-input-with-dropdown-container--filled':
|
|
27
|
+
'ff-input-with-dropdown-container--filled': isValueFilled,
|
|
27
28
|
})}
|
|
28
29
|
>
|
|
29
30
|
<fieldset
|
|
30
31
|
className={classNames('ff-input-with-dropdown', {
|
|
31
|
-
'ff-input-with-dropdown--filled':
|
|
32
|
-
'ff-input-with-dropdown--no-hover':
|
|
32
|
+
'ff-input-with-dropdown--filled': isValueFilled,
|
|
33
|
+
'ff-input-with-dropdown--no-hover': isValueFilled,
|
|
33
34
|
'ff-input-with-dropdown--disabled': !!disabled,
|
|
34
35
|
'ff-input-with-dropdown--error': !!error,
|
|
35
36
|
})}
|
|
@@ -39,8 +40,8 @@ const InputWithDropdown = ({
|
|
|
39
40
|
as="label"
|
|
40
41
|
htmlFor={name}
|
|
41
42
|
className={classNames('ff-floating-label', {
|
|
42
|
-
'ff-floating-label--filled':
|
|
43
|
-
'ff-floating-label--no-hover':
|
|
43
|
+
'ff-floating-label--filled': isValueFilled,
|
|
44
|
+
'ff-floating-label--no-hover': isValueFilled,
|
|
44
45
|
'ff-floating-label--error': !!error,
|
|
45
46
|
})}
|
|
46
47
|
>
|
|
@@ -49,15 +50,16 @@ const InputWithDropdown = ({
|
|
|
49
50
|
</Typography>
|
|
50
51
|
<input
|
|
51
52
|
name={name}
|
|
52
|
-
type=
|
|
53
|
+
type="number"
|
|
53
54
|
id={name}
|
|
54
55
|
value={value}
|
|
55
56
|
onChange={onInputChangeHandler}
|
|
57
|
+
onBlur={onInputBlurHandler}
|
|
56
58
|
placeholder={placeholder}
|
|
57
59
|
required={required}
|
|
58
60
|
disabled={disabled}
|
|
59
61
|
className={classNames('ff-floating-input', {
|
|
60
|
-
'ff-floating-input--filled':
|
|
62
|
+
'ff-floating-input--filled': isValueFilled,
|
|
61
63
|
'ff-floating-input--disabled': !!disabled,
|
|
62
64
|
'ff-floating-input--error': !!error,
|
|
63
65
|
})}
|
|
@@ -19,17 +19,14 @@ export interface InputWithDropdownProps {
|
|
|
19
19
|
/**
|
|
20
20
|
* value | input field value
|
|
21
21
|
*/
|
|
22
|
-
value
|
|
22
|
+
value?: number;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* variants to set color/style of the input field
|
|
26
26
|
*/
|
|
27
27
|
variant?: 'default' | 'primary';
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
* type to set the input field type
|
|
31
|
-
*/
|
|
32
|
-
type: 'text' | 'password' | 'number' | 'time';
|
|
29
|
+
|
|
33
30
|
|
|
34
31
|
/**
|
|
35
32
|
* error | If true, error message will be displayed
|
|
@@ -82,9 +79,9 @@ export interface InputWithDropdownProps {
|
|
|
82
79
|
onDropdownChangeHandler?: (option: Option) => void;
|
|
83
80
|
|
|
84
81
|
/**
|
|
85
|
-
*
|
|
82
|
+
* onInputBlurHandler action for input field
|
|
86
83
|
*/
|
|
87
|
-
|
|
84
|
+
onInputBlurHandler?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
88
85
|
|
|
89
86
|
/**
|
|
90
87
|
* id to select the input field uniquely
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Modal from './Modal';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import Button from '../Button';
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof Modal> = {
|
|
7
|
+
title: 'Components/Modal',
|
|
8
|
+
component: Modal,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'centered',
|
|
11
|
+
},
|
|
12
|
+
tags: ['autodocs'],
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type Story = StoryObj<typeof Modal>;
|
|
16
|
+
|
|
17
|
+
export const DefaultModalStory: Story = {
|
|
18
|
+
args: {
|
|
19
|
+
isOpen: true,
|
|
20
|
+
contentLabel: 'modal',
|
|
21
|
+
ariaHideApp: true,
|
|
22
|
+
isHeaderDisplayed: true,
|
|
23
|
+
headerContent: <h2>title</h2>,
|
|
24
|
+
children: <h2>Hello</h2>,
|
|
25
|
+
isFooterDisplayed:true,
|
|
26
|
+
footerContent: <Button variant="primary" label="continue" />,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const Controlled: Story = {
|
|
31
|
+
render: () => {
|
|
32
|
+
const [openModal, setModal] = useState(false);
|
|
33
|
+
return (
|
|
34
|
+
<>
|
|
35
|
+
<Button
|
|
36
|
+
variant="primary"
|
|
37
|
+
onClick={() => {
|
|
38
|
+
setModal(true);
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
Show Modal
|
|
42
|
+
</Button>
|
|
43
|
+
{openModal && (
|
|
44
|
+
<Modal
|
|
45
|
+
overlayClassName="custom-overlay"
|
|
46
|
+
isOpen={openModal}
|
|
47
|
+
onClose={() => {
|
|
48
|
+
setModal(false);
|
|
49
|
+
}}
|
|
50
|
+
headerContent={<div>title</div>}
|
|
51
|
+
isHeaderDisplayed={true}
|
|
52
|
+
children={<div>Hello</div>}
|
|
53
|
+
ariaHideApp={true}
|
|
54
|
+
isFooterDisplayed={true}
|
|
55
|
+
footerContent={<Button variant="primary" label='continue'/>}
|
|
56
|
+
/>
|
|
57
|
+
)}
|
|
58
|
+
</>
|
|
59
|
+
);
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export default meta;
|