pixel-react 1.2.0 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/components/AppHeader/types.d.ts +11 -2
- package/lib/components/Avatar/Avatar.d.ts +5 -0
- package/lib/components/Avatar/Avatar.stories.d.ts +10 -0
- package/lib/components/Avatar/index.d.ts +1 -0
- package/lib/components/Avatar/types.d.ts +26 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/ActiveCell.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/ColumnIndicator.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/Copied.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/CornerIndicator.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/DataEditor.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/DataViewer.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/FloatingRect.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/HeaderRow.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/Row.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/RowIndicator.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/Selected.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/Spreadsheet.d.ts +6 -7
- package/lib/components/ExcelFile/ExcelFile/Excel/Table.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/actions.d.ts +49 -5
- package/lib/components/ExcelFile/ExcelFile/Excel/context.d.ts +3 -3
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/engine.d.ts +5 -5
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/formula.d.ts +6 -6
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/index.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-graph.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-hash.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-set.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/index.d.ts +11 -11
- package/lib/components/ExcelFile/ExcelFile/Excel/matrix.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/point-range.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/reducer.d.ts +5 -5
- package/lib/components/ExcelFile/ExcelFile/Excel/selection.d.ts +3 -3
- package/lib/components/ExcelFile/ExcelFile/Excel/types.d.ts +11 -48
- package/lib/components/ExcelFile/ExcelFile/Excel/use-dispatch.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/use-selector.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/util.d.ts +11 -12
- package/lib/components/ExcelFile/ExcelFile/ExcelFile.d.ts +16 -0
- package/lib/components/ExcelFile/ExcelSheetBar/ExcelSheetBar.d.ts +0 -3
- package/lib/components/ExcelFile/ExcelToolBar/ExcelToolBar.d.ts +12 -0
- package/lib/components/ExcelFile/Types.d.ts +2 -49
- package/lib/components/Form/Form.d.ts +1 -15
- package/lib/components/Form/Form.stories.d.ts +6 -5
- package/lib/components/Form/Forms.d.ts +8 -0
- package/lib/components/Form/index.d.ts +1 -1
- package/lib/components/InputWithDropdown/types.d.ts +1 -1
- package/lib/components/LabelEditTextField/LabelEditTextField.d.ts +5 -0
- package/lib/components/LabelEditTextField/LabelEditTextField.stories.d.ts +11 -0
- package/lib/components/LabelEditTextField/index.d.ts +1 -0
- package/lib/components/LabelEditTextField/types.d.ts +38 -0
- package/lib/components/MenuOption/types.d.ts +7 -7
- package/lib/components/ModulesChip/ModuleChip.d.ts +4 -0
- package/lib/components/ModulesChip/ModuleChip.stories.d.ts +6 -0
- package/lib/components/ModulesChip/index.d.ts +1 -0
- package/lib/components/ModulesChip/types.d.ts +14 -0
- package/lib/components/MultiSelect/MultiSelectTypes.d.ts +1 -0
- package/lib/components/Select/Select.d.ts +1 -1
- package/lib/components/Select/components/Dropdown/Dropdown.d.ts +1 -1
- package/lib/components/Select/components/Dropdown/dropdownTypes.d.ts +2 -0
- package/lib/components/Select/types.d.ts +11 -4
- package/lib/components/Toastify/Toastify.d.ts +8 -0
- package/lib/components/Toastify/Toastify.stories.d.ts +6 -0
- package/lib/components/Toastify/index.d.ts +1 -0
- package/lib/components/Toastify/types.d.ts +7 -0
- package/lib/components/Tooltip/types.d.ts +6 -0
- package/lib/components/Typography/types.d.ts +1 -0
- package/lib/index.d.ts +130 -29
- package/lib/index.esm.js +26882 -872
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +26881 -866
- package/lib/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/getSelectOptionValue/getSelectOptionValue.d.ts +8 -0
- package/package.json +1 -1
- package/src/StyleGuide/ColorPalette/colorPaletteList.ts +10 -0
- package/src/assets/Themes/BaseTheme.scss +10 -1
- package/src/assets/Themes/DarkTheme.scss +19 -8
- package/src/assets/icons/client_profile.svg +4 -0
- package/src/assets/icons/fireflink_finder_logo.svg +7 -0
- package/src/assets/icons/fireflink_platform.svg +4 -0
- package/src/assets/icons/license_expired.svg +20 -0
- package/src/components/AppHeader/AppHeader.scss +5 -2
- package/src/components/AppHeader/AppHeader.stories.tsx +24 -3
- package/src/components/AppHeader/AppHeader.tsx +29 -11
- package/src/components/AppHeader/types.ts +11 -3
- package/src/components/Avatar/Avatar.scss +24 -0
- package/src/components/Avatar/Avatar.stories.tsx +56 -0
- package/src/components/Avatar/Avatar.tsx +25 -0
- package/src/components/Avatar/index.ts +1 -0
- package/src/components/Avatar/types.ts +27 -0
- package/src/components/Drawer/Drawer.scss +0 -1
- package/src/components/Drawer/Drawer.tsx +1 -1
- package/src/components/ExcelFile/ColorBarselector/ColorBarSelector.scss +0 -2
- package/src/components/ExcelFile/ContextMenu/ContextMenu.scss +1 -4
- package/src/components/ExcelFile/ContextMenu/ContextMenu.tsx +0 -1
- package/src/components/ExcelFile/ExcelFile/Excel/ActiveCell.tsx +13 -13
- package/src/components/ExcelFile/ExcelFile/Excel/Cell.tsx +13 -12
- package/src/components/ExcelFile/ExcelFile/Excel/ColumnIndicator.tsx +40 -32
- package/src/components/ExcelFile/ExcelFile/Excel/Copied.tsx +4 -4
- package/src/components/ExcelFile/ExcelFile/Excel/CornerIndicator.tsx +10 -10
- package/src/components/ExcelFile/ExcelFile/Excel/DataEditor.tsx +5 -5
- package/src/components/ExcelFile/ExcelFile/Excel/DataViewer.tsx +10 -10
- package/src/components/ExcelFile/ExcelFile/Excel/FloatingRect.tsx +6 -6
- package/src/components/ExcelFile/ExcelFile/Excel/HeaderRow.tsx +1 -1
- package/src/components/ExcelFile/ExcelFile/Excel/Row.tsx +1 -1
- package/src/components/ExcelFile/ExcelFile/Excel/RowIndicator.tsx +34 -27
- package/src/components/ExcelFile/ExcelFile/Excel/Selected.tsx +5 -5
- package/src/components/ExcelFile/ExcelFile/Excel/{Spreadsheet.css → Spreadsheet.scss} +21 -37
- package/src/components/ExcelFile/ExcelFile/Excel/Spreadsheet.tsx +87 -78
- package/src/components/ExcelFile/ExcelFile/Excel/Table.tsx +2 -2
- package/src/components/ExcelFile/ExcelFile/Excel/actions.ts +121 -31
- package/src/components/ExcelFile/ExcelFile/Excel/areModelsEqual.ts +1 -1
- package/src/components/ExcelFile/ExcelFile/Excel/context.ts +4 -4
- package/src/components/ExcelFile/ExcelFile/Excel/engine/engine.ts +7 -7
- package/src/components/ExcelFile/ExcelFile/Excel/engine/formula.ts +11 -11
- package/src/components/ExcelFile/ExcelFile/Excel/engine/index.ts +2 -2
- package/src/components/ExcelFile/ExcelFile/Excel/engine/point-graph.ts +3 -3
- package/src/components/ExcelFile/ExcelFile/Excel/engine/point-hash.ts +2 -2
- package/src/components/ExcelFile/ExcelFile/Excel/engine/point-set.ts +2 -2
- package/src/components/ExcelFile/ExcelFile/Excel/index.ts +12 -11
- package/src/components/ExcelFile/ExcelFile/Excel/matrix.ts +18 -24
- package/src/components/ExcelFile/ExcelFile/Excel/point-range.ts +1 -1
- package/src/components/ExcelFile/ExcelFile/Excel/reducer.ts +311 -41
- package/src/components/ExcelFile/ExcelFile/Excel/selection.ts +5 -5
- package/src/components/ExcelFile/ExcelFile/Excel/types.ts +14 -66
- package/src/components/ExcelFile/ExcelFile/Excel/typings/fast-formula-parser.d.ts +8 -8
- package/src/components/ExcelFile/ExcelFile/Excel/use-dispatch.ts +2 -2
- package/src/components/ExcelFile/ExcelFile/Excel/use-selector.ts +3 -3
- package/src/components/ExcelFile/ExcelFile/Excel/util.ts +21 -22
- package/src/components/ExcelFile/ExcelFile/ExcelFile.scss +0 -3
- package/src/components/ExcelFile/ExcelFile/ExcelFile.tsx +45 -403
- package/src/components/ExcelFile/ExcelFile.stories.tsx +10 -29
- package/src/components/ExcelFile/ExcelSheetBar/ExcelSheetBar.tsx +1 -12
- package/src/components/ExcelFile/ExcelToolBar/ExcelToolBar.scss +0 -3
- package/src/components/ExcelFile/ExcelToolBar/ExcelToolBar.tsx +147 -127
- package/src/components/ExcelFile/Types.ts +3 -70
- package/src/components/ExcelFile/index.ts +1 -1
- package/src/components/Form/Form.d.ts +3 -0
- package/src/components/Form/Form.scss +31 -4
- package/src/components/Form/Form.stories.tsx +172 -138
- package/src/components/Form/Form.ts +2 -0
- package/src/components/Form/Forms.tsx +25 -0
- package/src/components/Form/index.ts +1 -1
- package/src/components/Icon/Icons.scss +1 -0
- package/src/components/Icon/iconList.ts +8 -0
- package/src/components/IconButton/IconButton.scss +1 -1
- package/src/components/InputWithDropdown/types.ts +1 -1
- package/src/components/LabelEditTextField/LabelEditTextField.scss +85 -0
- package/src/components/LabelEditTextField/LabelEditTextField.stories.tsx +136 -0
- package/src/components/LabelEditTextField/LabelEditTextField.tsx +207 -0
- package/src/components/LabelEditTextField/index.ts +1 -0
- package/src/components/LabelEditTextField/types.ts +38 -0
- package/src/components/MenuOption/types.ts +7 -6
- package/src/components/ModulesChip/ModuleChip.scss +20 -0
- package/src/components/ModulesChip/ModuleChip.stories.tsx +41 -0
- package/src/components/ModulesChip/ModuleChip.tsx +31 -0
- package/src/components/ModulesChip/index.ts +1 -0
- package/src/components/ModulesChip/types.ts +14 -0
- package/src/components/MultiSelect/Dropdown.tsx +6 -1
- package/src/components/MultiSelect/MultiSelect.scss +17 -10
- package/src/components/MultiSelect/MultiSelect.stories.tsx +16 -4
- package/src/components/MultiSelect/MultiSelect.tsx +11 -4
- package/src/components/MultiSelect/MultiSelectTypes.ts +4 -3
- package/src/components/Select/Select.scss +4 -0
- package/src/components/Select/Select.stories.tsx +5 -3
- package/src/components/Select/Select.tsx +15 -7
- package/src/components/Select/components/Dropdown/Dropdown.tsx +3 -1
- package/src/components/Select/components/Dropdown/dropdownTypes.ts +3 -0
- package/src/components/Select/types.ts +12 -5
- package/src/components/Toastify/Toastify.stories.tsx +52 -0
- package/src/components/Toastify/Toastify.tsx +66 -0
- package/src/components/Toastify/index.ts +1 -0
- package/src/components/Toastify/types.ts +8 -0
- package/src/components/Tooltip/Tooltip.tsx +2 -1
- package/src/components/Tooltip/types.ts +6 -0
- package/src/components/Typography/Typography.scss +12 -4
- package/src/components/Typography/Typography.stories.tsx +2 -0
- package/src/components/Typography/Typography.tsx +2 -0
- package/src/components/Typography/types.ts +1 -0
- package/src/index.ts +12 -2
- package/src/utils/getSelectOptionValue/getSelectOptionValue.ts +31 -0
- package/src/components/ExcelFile/ChangeExcelStyles.tsx +0 -78
- package/src/components/ExcelFile/ImportExcelStyles.tsx +0 -86
- package/src/components/Form/Form.tsx +0 -57
@@ -0,0 +1,207 @@
|
|
1
|
+
import React, { useState, useRef, useEffect, FC } from 'react';
|
2
|
+
import './LabelEditTextField.scss';
|
3
|
+
import { LabelEditTextFieldTypes } from './types';
|
4
|
+
import Typography from '../Typography';
|
5
|
+
import HighlightText from '../HighlightText';
|
6
|
+
import Icon from '../Icon';
|
7
|
+
|
8
|
+
const getErrorMessage = (
|
9
|
+
inputValue: string,
|
10
|
+
text: string,
|
11
|
+
customError?: string
|
12
|
+
): string => {
|
13
|
+
if (inputValue === text) {
|
14
|
+
return 'No changes were made.';
|
15
|
+
} else if (!inputValue) {
|
16
|
+
return 'Text is required';
|
17
|
+
} else if (inputValue.length < 3) {
|
18
|
+
return 'Please enter at least 3 characters.';
|
19
|
+
} else if (customError) {
|
20
|
+
return customError;
|
21
|
+
}
|
22
|
+
return '';
|
23
|
+
};
|
24
|
+
const LabelEditTextField: FC<LabelEditTextFieldTypes> = ({
|
25
|
+
label,
|
26
|
+
text,
|
27
|
+
highlightText,
|
28
|
+
customError,
|
29
|
+
confirmIcon,
|
30
|
+
cancelIcon,
|
31
|
+
variant = 'textField',
|
32
|
+
dropdownData = [],
|
33
|
+
width = '300px',
|
34
|
+
height = '22px',
|
35
|
+
confirmAction,
|
36
|
+
}) => {
|
37
|
+
const [isEditing, setIsEditing] = useState(false);
|
38
|
+
const [inputValue, setInputValue] = useState(text);
|
39
|
+
const [dropdownValue, setDropdownValue] = useState(
|
40
|
+
dropdownData[0]?.value ?? ''
|
41
|
+
);
|
42
|
+
const [showError, setShowError] = useState('');
|
43
|
+
const [isTextFieldModified, setIsTextFieldModified] = useState(false);
|
44
|
+
const [isDropdownModified, setIsDropdownModified] = useState(false);
|
45
|
+
const containerRef = useRef<HTMLDivElement | null>(null);
|
46
|
+
const cancelRef = useRef<HTMLDivElement | null>(null); // New ref for cancel icon
|
47
|
+
|
48
|
+
const handleDoubleClick = () => {
|
49
|
+
setIsEditing(true);
|
50
|
+
setShowError('');
|
51
|
+
};
|
52
|
+
|
53
|
+
const handleConfirm = () => {
|
54
|
+
const errorMessage = getErrorMessage(inputValue, text, customError);
|
55
|
+
|
56
|
+
if (errorMessage && isEditing) {
|
57
|
+
setShowError(errorMessage);
|
58
|
+
} else {
|
59
|
+
setIsEditing(false);
|
60
|
+
setShowError('');
|
61
|
+
if (confirmAction) confirmAction(inputValue, dropdownValue);
|
62
|
+
}
|
63
|
+
};
|
64
|
+
|
65
|
+
const handleCancel = () => {
|
66
|
+
setInputValue(text);
|
67
|
+
setDropdownValue(dropdownData[0]?.value ?? '');
|
68
|
+
setIsEditing(false);
|
69
|
+
setShowError('');
|
70
|
+
setIsTextFieldModified(false);
|
71
|
+
setIsDropdownModified(false);
|
72
|
+
};
|
73
|
+
|
74
|
+
const handleTextFieldChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
75
|
+
setInputValue(e.target.value);
|
76
|
+
setIsTextFieldModified(true);
|
77
|
+
setShowError('');
|
78
|
+
};
|
79
|
+
|
80
|
+
const handleDropdownChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
81
|
+
setDropdownValue(e.target.value);
|
82
|
+
setIsDropdownModified(true);
|
83
|
+
setShowError('');
|
84
|
+
};
|
85
|
+
|
86
|
+
const handleBlur = (e: MouseEvent) => {
|
87
|
+
if (
|
88
|
+
containerRef.current &&
|
89
|
+
!containerRef.current.contains(e.target as Node) &&
|
90
|
+
cancelRef.current !== e.target // Exclude clicks on cancel icon
|
91
|
+
) {
|
92
|
+
const errorMessage = getErrorMessage(inputValue, text, customError);
|
93
|
+
|
94
|
+
if (errorMessage && isEditing) {
|
95
|
+
setShowError(errorMessage);
|
96
|
+
} else {
|
97
|
+
setIsEditing(false);
|
98
|
+
setShowError('');
|
99
|
+
}
|
100
|
+
}
|
101
|
+
};
|
102
|
+
|
103
|
+
useEffect(() => {
|
104
|
+
document.addEventListener('click', handleBlur);
|
105
|
+
return () => {
|
106
|
+
document.removeEventListener('click', handleBlur);
|
107
|
+
};
|
108
|
+
}, [inputValue]);
|
109
|
+
|
110
|
+
return (
|
111
|
+
<div
|
112
|
+
className="ff-label-edit-text-field"
|
113
|
+
ref={containerRef}
|
114
|
+
style={{ width }}
|
115
|
+
>
|
116
|
+
{isEditing ? (
|
117
|
+
<div className="ff-label-text-field">
|
118
|
+
{variant === 'textFieldWithDropdown' ? (
|
119
|
+
<div
|
120
|
+
className={`ff-label-text-field-with-dropdown ${
|
121
|
+
isEditing ? 'open' : ''
|
122
|
+
}`}
|
123
|
+
style={{ height }}
|
124
|
+
>
|
125
|
+
<input
|
126
|
+
type="text"
|
127
|
+
value={inputValue}
|
128
|
+
onChange={handleTextFieldChange}
|
129
|
+
className={`ff-text-dropdown-field ${
|
130
|
+
isTextFieldModified ? 'modified' : ''
|
131
|
+
}`}
|
132
|
+
placeholder=" "
|
133
|
+
style={{
|
134
|
+
width,
|
135
|
+
}}
|
136
|
+
/>
|
137
|
+
{label && <label className="ff-label">{label}</label>}
|
138
|
+
<select
|
139
|
+
value={dropdownValue}
|
140
|
+
onChange={handleDropdownChange}
|
141
|
+
className={`dropdown ${isDropdownModified ? 'modified' : ''}`}
|
142
|
+
>
|
143
|
+
{dropdownData.map((item) => (
|
144
|
+
<option key={item.id} value={item.value}>
|
145
|
+
{item.label}
|
146
|
+
</option>
|
147
|
+
))}
|
148
|
+
</select>
|
149
|
+
</div>
|
150
|
+
) : (
|
151
|
+
<div className="ff-label-text-field-without-dropdown">
|
152
|
+
<input
|
153
|
+
type="text"
|
154
|
+
value={inputValue}
|
155
|
+
onChange={handleTextFieldChange}
|
156
|
+
className={`ff-text-field ${
|
157
|
+
isTextFieldModified ? 'modified' : ''
|
158
|
+
}`}
|
159
|
+
placeholder=" "
|
160
|
+
style={{ width, height }}
|
161
|
+
/>
|
162
|
+
<label className="ff-textfield-label">{label}</label>
|
163
|
+
</div>
|
164
|
+
)}
|
165
|
+
<div className="ff-icon-container">
|
166
|
+
{confirmIcon && (
|
167
|
+
<Icon
|
168
|
+
color="var(--label-edit-confirm-icon)"
|
169
|
+
height={20}
|
170
|
+
width={20}
|
171
|
+
name={confirmIcon.name}
|
172
|
+
className="confirm-icon"
|
173
|
+
onClick={handleConfirm}
|
174
|
+
/>
|
175
|
+
)}
|
176
|
+
{cancelIcon && (
|
177
|
+
<Icon
|
178
|
+
color="var(--label-edit-cancel-icon)"
|
179
|
+
height={12}
|
180
|
+
width={20}
|
181
|
+
name={cancelIcon.name}
|
182
|
+
className="cancel-icon"
|
183
|
+
onClick={handleCancel}
|
184
|
+
ref={cancelRef}
|
185
|
+
/>
|
186
|
+
)}
|
187
|
+
</div>
|
188
|
+
</div>
|
189
|
+
) : (
|
190
|
+
<span
|
191
|
+
className="display-text"
|
192
|
+
onDoubleClick={handleDoubleClick}
|
193
|
+
role="button"
|
194
|
+
>
|
195
|
+
<HighlightText text={inputValue} highlight={highlightText} />
|
196
|
+
</span>
|
197
|
+
)}
|
198
|
+
{showError && isEditing && (
|
199
|
+
<Typography as="p" fontSize={8} className="error-text">
|
200
|
+
{showError}
|
201
|
+
</Typography>
|
202
|
+
)}
|
203
|
+
</div>
|
204
|
+
);
|
205
|
+
};
|
206
|
+
|
207
|
+
export default LabelEditTextField;
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './LabelEditTextField';
|
@@ -0,0 +1,38 @@
|
|
1
|
+
export interface IconProps {
|
2
|
+
/** Name of the icon to be displayed. */
|
3
|
+
name: string;
|
4
|
+
/** Optional click handler function for the icon. */
|
5
|
+
onClick?: () => void;
|
6
|
+
}
|
7
|
+
export interface DropdownOption {
|
8
|
+
/** Unique identifier for the dropdown option. */
|
9
|
+
id: number;
|
10
|
+
/** Value associated with the dropdown option. */
|
11
|
+
value: string;
|
12
|
+
/** Label displayed for the dropdown option. */
|
13
|
+
label: string;
|
14
|
+
}
|
15
|
+
export interface LabelEditTextFieldTypes {
|
16
|
+
/** Label text displayed above the input field. */
|
17
|
+
label?: string;
|
18
|
+
/** Initial text displayed in the input field. */
|
19
|
+
text: string;
|
20
|
+
/** Text to be highlighted within the displayed text, if provided. */
|
21
|
+
highlightText?: string;
|
22
|
+
/** Custom error message to be displayed, if applicable. */
|
23
|
+
customError?: string;
|
24
|
+
/** Confirm icon properties including icon name and click handler. */
|
25
|
+
confirmIcon?: IconProps;
|
26
|
+
/** Cancel icon properties including icon name and click handler. */
|
27
|
+
cancelIcon?: IconProps;
|
28
|
+
/** Type of input field - standard text field or text field with a dropdown. */
|
29
|
+
variant?: 'textFieldWithDropdown' | 'textField';
|
30
|
+
/** Array of dropdown options used if the dropdown variant is selected. */
|
31
|
+
dropdownData?: DropdownOption[];
|
32
|
+
/** Width of the input field component. */
|
33
|
+
width?: string;
|
34
|
+
/** Height of the input field component. */
|
35
|
+
height?: string;
|
36
|
+
/** Function called when confirming input changes, with input and dropdown values as arguments. */
|
37
|
+
confirmAction?: (inputValue: string, dropdownValue: string) => void;
|
38
|
+
}
|
@@ -105,17 +105,18 @@ interface MenuOptionProps {
|
|
105
105
|
*/
|
106
106
|
dropdownPlacement?: string | 'top' | 'left' | 'right' | 'down';
|
107
107
|
|
108
|
-
|
109
|
-
*
|
110
|
-
* @type {
|
108
|
+
/**
|
109
|
+
* The variant of the menu option, either 'dark' or 'light'.
|
110
|
+
* @type {'dark' | 'light'}
|
111
|
+
* @default 'light'
|
111
112
|
* @optional
|
112
113
|
*/
|
113
114
|
|
114
115
|
variant?: 'dark' | 'light';
|
116
|
+
|
115
117
|
/**
|
116
|
-
*
|
117
|
-
* @type {
|
118
|
-
* @default 'light'
|
118
|
+
* Callback function triggered when the icon is clicked.
|
119
|
+
* @type {function}
|
119
120
|
* @optional
|
120
121
|
*/
|
121
122
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
@use '../../assets/styles/fonts';
|
2
|
+
@use '../../assets/styles/mixins';
|
3
|
+
|
4
|
+
.ff-expandable-chip-menu {
|
5
|
+
width: 75px;
|
6
|
+
height: 32px;
|
7
|
+
border: 0.5px solid;
|
8
|
+
border-radius: 16px;
|
9
|
+
color: var(--brand-color);
|
10
|
+
cursor: pointer;
|
11
|
+
@include mixins.center-content();
|
12
|
+
.ff-label-chip {
|
13
|
+
&--active {
|
14
|
+
color: var(--ff-header-text-color);
|
15
|
+
}
|
16
|
+
}
|
17
|
+
&--active {
|
18
|
+
background: var(--brand-color);
|
19
|
+
}
|
20
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
2
|
+
import ModuleChip from './ModuleChip';
|
3
|
+
import { useState } from 'react';
|
4
|
+
|
5
|
+
const meta: Meta<typeof ModuleChip> = {
|
6
|
+
title: 'Components/ModuleChip',
|
7
|
+
component: ModuleChip,
|
8
|
+
parameters: {
|
9
|
+
layout: 'center',
|
10
|
+
},
|
11
|
+
argTypes: {
|
12
|
+
isActive: Boolean,
|
13
|
+
},
|
14
|
+
tags: ['autodocs'],
|
15
|
+
};
|
16
|
+
|
17
|
+
type Story = StoryObj<typeof ModuleChip>;
|
18
|
+
|
19
|
+
const defaultArgs = {
|
20
|
+
label: 'Modules',
|
21
|
+
isActive: false,
|
22
|
+
};
|
23
|
+
|
24
|
+
export const Controlled: Story = {
|
25
|
+
render: () => {
|
26
|
+
const [selectedMenu, setSelectedMenu] = useState<boolean>(true);
|
27
|
+
const handleChipClick = () => {
|
28
|
+
setSelectedMenu(!selectedMenu);
|
29
|
+
};
|
30
|
+
|
31
|
+
return (
|
32
|
+
<ModuleChip
|
33
|
+
{...defaultArgs}
|
34
|
+
isActive={selectedMenu}
|
35
|
+
onClick={handleChipClick}
|
36
|
+
/>
|
37
|
+
);
|
38
|
+
},
|
39
|
+
};
|
40
|
+
|
41
|
+
export default meta;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import './ModuleChip.scss';
|
2
|
+
import classNames from 'classnames';
|
3
|
+
import { ModuleChipProps } from './types';
|
4
|
+
import Typography from '../Typography';
|
5
|
+
|
6
|
+
const ModuleChip: React.FC<ModuleChipProps> = ({
|
7
|
+
label = '',
|
8
|
+
isActive = true,
|
9
|
+
onClick = () => {},
|
10
|
+
}) => {
|
11
|
+
return (
|
12
|
+
<div
|
13
|
+
className={classNames('ff-expandable-chip-menu', {
|
14
|
+
'ff-expandable-chip-menu--active': isActive,
|
15
|
+
})}
|
16
|
+
onClick={onClick}
|
17
|
+
>
|
18
|
+
<div
|
19
|
+
className={classNames(`ff-label-chip `, {
|
20
|
+
'ff-label-chip--active': isActive,
|
21
|
+
})}
|
22
|
+
>
|
23
|
+
<Typography fontSize={'14px'} fontWeight="regular" lineHeight="21px">
|
24
|
+
{label}
|
25
|
+
</Typography>
|
26
|
+
</div>
|
27
|
+
</div>
|
28
|
+
);
|
29
|
+
};
|
30
|
+
|
31
|
+
export default ModuleChip;
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './ModuleChip';
|
@@ -0,0 +1,14 @@
|
|
1
|
+
export interface ModuleChipProps {
|
2
|
+
/**
|
3
|
+
* mandatory | label for the ModuleChip component
|
4
|
+
*/
|
5
|
+
label: string;
|
6
|
+
/**
|
7
|
+
* mandatory | isActive for the ModuleChip component
|
8
|
+
*/
|
9
|
+
isActive: boolean;
|
10
|
+
/**
|
11
|
+
* mandatory | onClick for the ModuleChip component
|
12
|
+
*/
|
13
|
+
onClick: () => void;
|
14
|
+
}
|
@@ -5,6 +5,7 @@ import './Dropdown.scss';
|
|
5
5
|
import { ThemeContext } from '../ThemeProvider/ThemeProvider';
|
6
6
|
import classNames from 'classnames';
|
7
7
|
import Button from '../Button';
|
8
|
+
import Typography from '../Typography';
|
8
9
|
|
9
10
|
const Dropdown = forwardRef<HTMLDivElement, DropdownProps>(
|
10
11
|
(
|
@@ -82,7 +83,11 @@ const Dropdown = forwardRef<HTMLDivElement, DropdownProps>(
|
|
82
83
|
onClick={() => handleOptionChange(info, !info.isChecked)}
|
83
84
|
>
|
84
85
|
<input type="checkbox" checked={info.isChecked} readOnly />
|
85
|
-
<
|
86
|
+
<Typography
|
87
|
+
as="span"
|
88
|
+
className="dropdown-option-label"
|
89
|
+
children={info.label}
|
90
|
+
/>
|
86
91
|
</div>
|
87
92
|
))
|
88
93
|
)}
|
@@ -38,16 +38,16 @@
|
|
38
38
|
cursor: pointer;
|
39
39
|
position: relative;
|
40
40
|
border: 1px solid var(--default-icon-color);
|
41
|
-
border-radius:
|
41
|
+
border-radius: 4px;
|
42
42
|
background: var(--drawer-footer-bg);
|
43
43
|
min-width: 150px;
|
44
44
|
width: 100%;
|
45
45
|
height: 32px;
|
46
46
|
.ff-multiselect {
|
47
47
|
position: relative;
|
48
|
-
padding:
|
48
|
+
padding: 3px;
|
49
49
|
border: none;
|
50
|
-
border-radius:
|
50
|
+
border-radius: 4px;
|
51
51
|
@include flex-center;
|
52
52
|
&__main {
|
53
53
|
display: flex;
|
@@ -61,6 +61,8 @@
|
|
61
61
|
|
62
62
|
.active-default-label {
|
63
63
|
@extend .font-size-8;
|
64
|
+
font-size: 8px !important;
|
65
|
+
height: 8px;
|
64
66
|
@include label-styles;
|
65
67
|
background-color: var(--multi-select-label-bg);
|
66
68
|
line-height: 12px;
|
@@ -87,6 +89,9 @@
|
|
87
89
|
@extend .fontXs;
|
88
90
|
line-height: 14px;
|
89
91
|
color: var(--tooltip-bg-color);
|
92
|
+
&.pr-2 {
|
93
|
+
padding: 5px 2px;
|
94
|
+
}
|
90
95
|
}
|
91
96
|
.ff-multiselect-chip-close-icon {
|
92
97
|
cursor: pointer;
|
@@ -108,13 +113,15 @@
|
|
108
113
|
}
|
109
114
|
}
|
110
115
|
}
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
116
|
+
}
|
117
|
+
.ff-multiselect-more-chip {
|
118
|
+
display: flex;
|
119
|
+
align-items: center;
|
120
|
+
width: 1.2rem;
|
121
|
+
@extend .fontSm;
|
122
|
+
font-weight: 600;
|
123
|
+
line-height: 16px;
|
124
|
+
color: var(--brand-color);
|
118
125
|
}
|
119
126
|
}
|
120
127
|
&__toggle {
|
@@ -55,13 +55,25 @@ export const Default3: Story = {
|
|
55
55
|
export const EmailGroup: Story = {
|
56
56
|
render: () => {
|
57
57
|
const [options] = useState([
|
58
|
-
{
|
58
|
+
{
|
59
|
+
label: 'Sample1@gmail.com',
|
60
|
+
value: 'sample1@gmail.com',
|
61
|
+
isDisabled: true,
|
62
|
+
},
|
59
63
|
{ label: 'Sample2@gmail.com', value: 'sample2@gmail.com' },
|
60
64
|
]);
|
61
65
|
const [selectedOptions, setSelectedOptions] = useState<
|
62
|
-
{ label?: string; value?: string }[]
|
63
|
-
>([
|
64
|
-
|
66
|
+
{ label?: string; value?: string; isDisabled?: boolean }[]
|
67
|
+
>([
|
68
|
+
{
|
69
|
+
label: 'Sample1@gmail.com',
|
70
|
+
value: 'sample1@gmail.com',
|
71
|
+
isDisabled: true,
|
72
|
+
},
|
73
|
+
]);
|
74
|
+
const onChange = (
|
75
|
+
options: { label?: string; value?: string; isDisabled?: boolean }[]
|
76
|
+
) => {
|
65
77
|
setSelectedOptions(options);
|
66
78
|
};
|
67
79
|
return (
|
@@ -5,6 +5,7 @@ import './MultiSelect.scss';
|
|
5
5
|
import Dropdown from './Dropdown';
|
6
6
|
import Icon from '../Icon';
|
7
7
|
import { MultiSelectProps, Option } from './MultiSelectTypes';
|
8
|
+
import Typography from '../Typography';
|
8
9
|
|
9
10
|
const ChipElement = ({
|
10
11
|
label,
|
@@ -22,6 +23,8 @@ const ChipElement = ({
|
|
22
23
|
className="ff-multiselect-chip-close-icon"
|
23
24
|
onClick={onChipCloseClick}
|
24
25
|
name="close_pill"
|
26
|
+
height={13} //as per the latest chnages in icon container we have to give this
|
27
|
+
width={13}
|
25
28
|
/>
|
26
29
|
</div>
|
27
30
|
);
|
@@ -46,6 +49,9 @@ const MultiSelect = ({
|
|
46
49
|
}: MultiSelectProps) => {
|
47
50
|
const [isOpen, setIsOpen] = useState<boolean>(false);
|
48
51
|
const [allOptions, setAllOptions] = useState(options);
|
52
|
+
useEffect(() => {
|
53
|
+
setAllOptions(options);
|
54
|
+
}, [options]);
|
49
55
|
|
50
56
|
const [searchedKeyword, setSearchedKeyword] = useState('');
|
51
57
|
const [isSelectFocusedOnce, setIsSelectFocusedOnce] =
|
@@ -236,7 +242,8 @@ const MultiSelect = ({
|
|
236
242
|
>
|
237
243
|
<div className="ff-multiselect" onClick={handleClick}>
|
238
244
|
<div className="ff-multiselect__main">
|
239
|
-
<
|
245
|
+
<Typography
|
246
|
+
as="span"
|
240
247
|
className={classNames({
|
241
248
|
'active-default-label':
|
242
249
|
isOpen ||
|
@@ -244,9 +251,9 @@ const MultiSelect = ({
|
|
244
251
|
(isFieldSkipped && required),
|
245
252
|
'default-label': !isOpen && !selectedOptions?.length,
|
246
253
|
})}
|
247
|
-
|
248
|
-
|
249
|
-
|
254
|
+
children={label}
|
255
|
+
/>
|
256
|
+
|
250
257
|
<div className="ff-multiselect-chip-container">
|
251
258
|
{displayCount ? (
|
252
259
|
<>
|
@@ -3,10 +3,11 @@ interface Option {
|
|
3
3
|
value?: string;
|
4
4
|
accessor?: string;
|
5
5
|
isChecked?: boolean;
|
6
|
+
isDisabled?: boolean;
|
6
7
|
}
|
7
8
|
interface MultiSelectProps {
|
8
9
|
options: Option[];
|
9
|
-
type
|
10
|
+
type?: 'email' | 'text';
|
10
11
|
label: string;
|
11
12
|
selectedOptions?: Option[];
|
12
13
|
disabled?: boolean;
|
@@ -18,7 +19,7 @@ interface MultiSelectProps {
|
|
18
19
|
errorMessage?: string;
|
19
20
|
withSelectButton?: boolean;
|
20
21
|
onSelect?: () => void;
|
21
|
-
displayCount?:boolean;
|
22
|
+
displayCount?: boolean;
|
22
23
|
}
|
23
24
|
|
24
|
-
export { Option, MultiSelectProps };
|
25
|
+
export { Option, MultiSelectProps };
|
@@ -17,10 +17,12 @@ type Story = StoryObj<typeof Select>;
|
|
17
17
|
export const Primary: Story = {
|
18
18
|
args: {
|
19
19
|
label: 'Select',
|
20
|
+
labelAccessor: 'name',
|
21
|
+
valueAccessor: 'value',
|
20
22
|
optionsList: [
|
21
|
-
{ label: 'Option 1', value: '1' },
|
22
|
-
{ label: 'Option 2', value: '2' },
|
23
|
-
{ label: 'Option 3', value: '3' },
|
23
|
+
{ label: 'Option 1', value: '1', name: 'abcd' },
|
24
|
+
{ label: 'Option 2', value: '2', name: '123' },
|
25
|
+
{ label: 'Option 3', value: '3', name: '456' },
|
24
26
|
],
|
25
27
|
},
|
26
28
|
};
|
@@ -8,6 +8,7 @@ import Icon from '../Icon';
|
|
8
8
|
import './Select.scss';
|
9
9
|
import usePortalPosition from '../../hooks/usePortalPosition';
|
10
10
|
import Typography from '../Typography';
|
11
|
+
import { getValue } from '../../utils/getSelectOptionValue/getSelectOptionValue';
|
11
12
|
|
12
13
|
const selectReducer = (
|
13
14
|
state: SelectState,
|
@@ -116,6 +117,8 @@ const Select = ({
|
|
116
117
|
required = false,
|
117
118
|
optionsRequired = true,
|
118
119
|
selectedOptionColor = 'var(--ff-select-text-color)',
|
120
|
+
labelAccessor,
|
121
|
+
valueAccessor,
|
119
122
|
}: SelectProps) => {
|
120
123
|
const initialState: SelectState = useMemo(
|
121
124
|
() => ({
|
@@ -164,7 +167,7 @@ const Select = ({
|
|
164
167
|
if (actionType === 'SHOW_ERROR' || actionType === 'BLUR_INPUT') {
|
165
168
|
dispatch({
|
166
169
|
type: actionType,
|
167
|
-
payload: { optionsList, option: selectedOption
|
170
|
+
payload: { optionsList, option: getValue(selectedOption) },
|
168
171
|
});
|
169
172
|
} else {
|
170
173
|
dispatch({ type: actionType });
|
@@ -176,9 +179,10 @@ const Select = ({
|
|
176
179
|
if (disabled) return;
|
177
180
|
const { value } = e.target;
|
178
181
|
const filteredOptions = optionsList.filter((option) => {
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
+
const valueData = getValue(option, valueAccessor);
|
183
|
+
return typeof valueData === 'string'
|
184
|
+
? valueData.toLowerCase().includes(value.toLowerCase().trim())
|
185
|
+
: valueData === Number(value);
|
182
186
|
});
|
183
187
|
dispatch({ type: 'UPDATE_OPTION_LIST', payload: filteredOptions });
|
184
188
|
dispatch({ type: 'UPDATE_OPTION', payload: value });
|
@@ -197,7 +201,10 @@ const Select = ({
|
|
197
201
|
const onSelectOptionSelector = (option: Option) => {
|
198
202
|
if (!disabled) {
|
199
203
|
onSelectBlur();
|
200
|
-
dispatch({
|
204
|
+
dispatch({
|
205
|
+
type: 'UPDATE_OPTION',
|
206
|
+
payload: getValue(option, valueAccessor),
|
207
|
+
});
|
201
208
|
if (onChange) {
|
202
209
|
onChange(option);
|
203
210
|
}
|
@@ -247,8 +254,8 @@ const Select = ({
|
|
247
254
|
const applyActiveOptionClasses = !isInputFocused && Boolean(option);
|
248
255
|
|
249
256
|
return (
|
250
|
-
<div className={classNames(`ff-select-wrapper
|
251
|
-
<div className=
|
257
|
+
<div className={classNames(`ff-select-wrapper`)}>
|
258
|
+
<div className={`ff-select ${className}`}>
|
252
259
|
<input
|
253
260
|
type="text"
|
254
261
|
className={classNames('ff-select-input', {
|
@@ -361,6 +368,7 @@ const Select = ({
|
|
361
368
|
options={options}
|
362
369
|
optionZIndex={optionZIndex}
|
363
370
|
inputRef={InputRef}
|
371
|
+
labelAccessor={labelAccessor}
|
364
372
|
/>,
|
365
373
|
document.body
|
366
374
|
)}
|