pixel-react 1.1.0 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- package/.yarn/install-state.gz +0 -0
- package/lib/components/Charts/DashboardDonutChart/DashboardDonutChart.d.ts +5 -0
- package/lib/components/Charts/DashboardDonutChart/DashboardDonutChart.stories.d.ts +7 -0
- package/lib/components/Charts/DashboardDonutChart/index.d.ts +1 -0
- package/lib/components/Charts/DashboardDonutChart/types.d.ts +21 -0
- package/lib/components/Charts/PieChart/PieChart.d.ts +5 -0
- package/lib/components/Charts/PieChart/PieChart.stories.d.ts +7 -0
- package/lib/components/Charts/PieChart/index.d.ts +1 -0
- package/lib/components/Charts/PieChart/types.d.ts +27 -0
- package/lib/components/FF_Captcha/Recaptcha.d.ts +5 -0
- package/lib/components/FF_Captcha/captcha.stories.d.ts +8 -0
- package/lib/components/FF_Captcha/types.d.ts +20 -0
- package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/lib/components/MultiSelect/MultiSelectTypes.d.ts +1 -1
- package/lib/components/NLPInput/NlpInput.d.ts +4 -0
- package/lib/components/NLPInput/NlpInput.stories.d.ts +7 -0
- package/lib/components/NLPInput/components/NlpDropDown/NlpDropDownType.d.ts +19 -0
- package/lib/components/NLPInput/components/NlpDropDown/NlpDropdown.d.ts +4 -0
- package/lib/components/NLPInput/index.d.ts +1 -0
- package/lib/components/NLPInput/type.d.ts +70 -0
- package/lib/components/Table/Table.d.ts +1 -1
- package/lib/index.d.ts +96 -19
- package/lib/index.esm.js +2951 -249
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +2953 -247
- package/lib/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/getEncryptedData/getEncryptedData.d.ts +2 -0
- package/lib/utils/getEncryptedData/getEncryptedData.stories.d.ts +6 -0
- package/package.json +6 -2
- package/src/StyleGuide/ColorPalette/ColorPalette.tsx +2 -4
- package/src/StyleGuide/ColorPalette/colorPaletteList.ts +95 -20
- package/src/assets/Themes/BaseTheme.scss +2 -3
- package/src/assets/Themes/DarkTheme.scss +9 -8
- package/src/assets/icons/wswb_delete_icon.svg +4 -0
- package/src/assets/icons/wswb_plus_icon.svg +5 -0
- package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.scss +145 -0
- package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.stories.tsx +52 -0
- package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.tsx +335 -0
- package/src/components/Charts/DashboardDonutChart/index.ts +1 -0
- package/src/components/Charts/DashboardDonutChart/types.ts +33 -0
- package/src/components/Charts/PieChart/PieChart.scss +39 -0
- package/src/components/Charts/PieChart/PieChart.stories.tsx +46 -0
- package/src/components/Charts/PieChart/PieChart.tsx +193 -0
- package/src/components/Charts/PieChart/index.ts +1 -0
- package/src/components/Charts/PieChart/types.ts +28 -0
- package/src/components/FF_Captcha/Recaptcha.scss +11 -0
- package/src/components/FF_Captcha/Recaptcha.tsx +41 -0
- package/src/components/FF_Captcha/captcha.stories.tsx +40 -0
- package/src/components/FF_Captcha/index.ts +0 -0
- package/src/components/FF_Captcha/types.ts +22 -0
- package/src/components/Icon/iconList.ts +6 -0
- package/src/components/Modal/modal.scss +1 -1
- package/src/components/MultiSelect/MultiSelect.stories.tsx +2 -3
- package/src/components/MultiSelect/MultiSelect.tsx +35 -23
- package/src/components/MultiSelect/MultiSelectTypes.ts +1 -1
- package/src/components/NLPInput/NLPInput.scss +246 -0
- package/src/components/NLPInput/NlpInput.stories.tsx +136 -0
- package/src/components/NLPInput/NlpInput.tsx +374 -0
- package/src/components/NLPInput/components/NlpDropDown/NlpDropDownType.ts +60 -0
- package/src/components/NLPInput/components/NlpDropDown/NlpDropdown.scss +83 -0
- package/src/components/NLPInput/components/NlpDropDown/NlpDropdown.tsx +180 -0
- package/src/components/NLPInput/index.ts +1 -0
- package/src/components/NLPInput/type.tsx +124 -0
- package/src/components/Table/Table.scss +5 -0
- package/src/components/Table/Table.stories.tsx +12 -0
- package/src/components/Table/Table.tsx +25 -14
- package/src/components/TextArea/Textarea.scss +1 -1
- package/src/index.ts +8 -1
- package/src/utils/getEncryptedData/getEncryptedData.stories.tsx +55 -0
- package/src/utils/getEncryptedData/getEncryptedData.ts +10 -0
- 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/lib/components/AddButton/types.d.ts +0 -4
@@ -0,0 +1,136 @@
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
2
|
+
import NlpInput from './NlpInput';
|
3
|
+
// import { useState } from 'react';
|
4
|
+
// import { Option } from '../NLPInput/type';
|
5
|
+
|
6
|
+
const meta: Meta<typeof NlpInput> = {
|
7
|
+
title: 'Components/NlpInput',
|
8
|
+
component: NlpInput,
|
9
|
+
parameters: {
|
10
|
+
layout: 'centered',
|
11
|
+
},
|
12
|
+
tags: ['autodocs'],
|
13
|
+
};
|
14
|
+
|
15
|
+
type Story = StoryObj<typeof NlpInput>;
|
16
|
+
|
17
|
+
export const Primary: Story = {
|
18
|
+
args: {
|
19
|
+
label: 'NLP Input',
|
20
|
+
optionsList: [
|
21
|
+
{
|
22
|
+
desc: 'randomNumber',
|
23
|
+
displayName: 'randomNumber',
|
24
|
+
failMessage: 'randomNumber has failed',
|
25
|
+
isNonPE: false,
|
26
|
+
name: 'randomNumber',
|
27
|
+
nlpName: 'randomNumber',
|
28
|
+
nlpType: 'PROGRAM_ELEMENTS',
|
29
|
+
packageName: 'com.tyss.optimize.programelement.LIC3813PJT1001.Logics',
|
30
|
+
parentId: 'PKJ1017',
|
31
|
+
passMessage: 'randomNumber has passed',
|
32
|
+
programElementId: 'PRG_ELE1001',
|
33
|
+
projectId: 'PJT1001',
|
34
|
+
returnType: 'java.lang.Integer',
|
35
|
+
searchName: 'randomNumber',
|
36
|
+
stepInputs: [{}], // Placeholder, replace with actual data if needed
|
37
|
+
toolTip: 'Logics : randomNumber',
|
38
|
+
_class: 'com.tyss.optimize.data.models.db.model.ProgramElementNlp',
|
39
|
+
_id: 'PE_NLPdbed27d0-b05a-4354-b9d3-c2f85307b4f2',
|
40
|
+
},
|
41
|
+
{
|
42
|
+
desc: 'randomNumber',
|
43
|
+
displayName: 'randomNumber',
|
44
|
+
failMessage: 'randomNumber has failed',
|
45
|
+
isNonPE: false,
|
46
|
+
name: 'randomNumber',
|
47
|
+
nlpName: 'randomNumber',
|
48
|
+
nlpType: 'PROGRAM_ELEMENTS',
|
49
|
+
packageName: 'com.tyss.optimize.programelement.LIC3813PJT1001.Logics',
|
50
|
+
parentId: 'PKJ1017',
|
51
|
+
passMessage: 'randomNumber has passed',
|
52
|
+
programElementId: 'PRG_ELE1001',
|
53
|
+
projectId: 'PJT1001',
|
54
|
+
returnType: 'java.lang.Integer',
|
55
|
+
searchName: 'randomNumber',
|
56
|
+
stepInputs: [
|
57
|
+
{ name: 'Range Of The Number', type: 'java.lang.Integer' },
|
58
|
+
], // Placeholder, replace with actual data if needed
|
59
|
+
toolTip: 'Logics : randomNumber',
|
60
|
+
_class: 'com.tyss.optimize.data.models.db.model.ProgramElementNlp',
|
61
|
+
_id: 'PE_NLPdbed27d0-b05a-4354-b9d3-c2f85307b4f2',
|
62
|
+
},
|
63
|
+
{
|
64
|
+
description: '',
|
65
|
+
displayName: 'Open Browser 1',
|
66
|
+
failMessage: 'Open Browser is failed',
|
67
|
+
imported: false,
|
68
|
+
libraryId: 'LIB1002',
|
69
|
+
name: 'Open Browser',
|
70
|
+
nlpName: 'Open Browser',
|
71
|
+
nlpType: 'STEP_GROUP',
|
72
|
+
parentId: 'STP_GRP1001',
|
73
|
+
passMessage: 'Open Browser is passed',
|
74
|
+
path: '/Root/Open and Close Browser/Open Browser',
|
75
|
+
platform: 'Web',
|
76
|
+
projectId: 'PJT1001',
|
77
|
+
returnType: 'void',
|
78
|
+
searchName: 'Open Browser',
|
79
|
+
stepInputs: [], // Empty array for step inputs
|
80
|
+
toolTip: 'Open and Close Browser : Open Browser : Web',
|
81
|
+
_class: 'com.tyss.optimize.data.models.db.model.StepGroupNlp',
|
82
|
+
_id: 'SG_NLP1001',
|
83
|
+
},
|
84
|
+
],
|
85
|
+
},
|
86
|
+
};
|
87
|
+
|
88
|
+
export const Disable: Story = {
|
89
|
+
args: {
|
90
|
+
label: 'NLP Input',
|
91
|
+
optionsList: [],
|
92
|
+
disabled: true,
|
93
|
+
},
|
94
|
+
};
|
95
|
+
|
96
|
+
// export const WithInitialValue: Story = {
|
97
|
+
// args: {
|
98
|
+
// label: 'NLP Input',
|
99
|
+
// selectedOption: { label: 'Option 2', value: '2' },
|
100
|
+
// optionsList: [
|
101
|
+
// { label: 'NLP 1', value: '1' },
|
102
|
+
// { label: 'NLP 2', value: '2' },
|
103
|
+
// { label: 'NLP 3', value: '3' },
|
104
|
+
// ],
|
105
|
+
// },
|
106
|
+
// };
|
107
|
+
|
108
|
+
// export const OptionSelection: Story = {
|
109
|
+
// render: () => {
|
110
|
+
// const optionsList = [
|
111
|
+
// { label: 'NLP 1', value: '1' },
|
112
|
+
// { label: 'NLP 2', value: '2' },
|
113
|
+
// { label: 'NLP 3', value: '3' },
|
114
|
+
// ];
|
115
|
+
|
116
|
+
// const [selectedOption, setSelectedOption] = useState<Option>({
|
117
|
+
// label: 'NLP 2',
|
118
|
+
// value: '2',
|
119
|
+
// });
|
120
|
+
|
121
|
+
// const handleChange = (option: Option) => {
|
122
|
+
// setSelectedOption(option);
|
123
|
+
// };
|
124
|
+
|
125
|
+
// return (
|
126
|
+
// <NlpInput
|
127
|
+
// label="NLP Input"
|
128
|
+
// optionsList={optionsList}
|
129
|
+
// selectedOption={selectedOption}
|
130
|
+
// onChange={handleChange}
|
131
|
+
// />
|
132
|
+
// );
|
133
|
+
// },
|
134
|
+
// };
|
135
|
+
|
136
|
+
export default meta;
|
@@ -0,0 +1,374 @@
|
|
1
|
+
import { useReducer, useRef, useEffect, useMemo } from 'react';
|
2
|
+
import { Option, SelectAction, SelectProps, SelectState } from './type';
|
3
|
+
import { checkEmpty } from '../../utils/checkEmpty/checkEmpty';
|
4
|
+
import { createPortal } from 'react-dom';
|
5
|
+
import classNames from 'classnames';
|
6
|
+
import Dropdown from './components/NlpDropDown/NlpDropdown';
|
7
|
+
import Icon from '../Icon';
|
8
|
+
import './NlpInput.scss';
|
9
|
+
import usePortalPosition from '../../hooks/usePortalPosition';
|
10
|
+
import Typography from '../Typography';
|
11
|
+
|
12
|
+
const nlpInputReducer = (
|
13
|
+
state: SelectState,
|
14
|
+
action: SelectAction
|
15
|
+
): SelectState => {
|
16
|
+
switch (action.type) {
|
17
|
+
case 'FOCUS_INPUT':
|
18
|
+
return {
|
19
|
+
...state,
|
20
|
+
isInputFocused: true,
|
21
|
+
iconColor: 'var(--ff-nlp-input-brand-color)',
|
22
|
+
isIconClick: true,
|
23
|
+
showOptions: true,
|
24
|
+
};
|
25
|
+
case 'BLUR_INPUT':
|
26
|
+
return {
|
27
|
+
...state,
|
28
|
+
isInputFocused: false,
|
29
|
+
options: action.payload.optionsList,
|
30
|
+
option: action.payload.option,
|
31
|
+
|
32
|
+
// todo color need to be add in style guide
|
33
|
+
iconColor: 'var(--ff-nlp-input-default-color)',
|
34
|
+
isIconClick: false,
|
35
|
+
showOptions: false,
|
36
|
+
dropdownPosition: {
|
37
|
+
positionX: 0,
|
38
|
+
positionY: 0,
|
39
|
+
width: 0,
|
40
|
+
fromBottom: 0,
|
41
|
+
},
|
42
|
+
};
|
43
|
+
case 'MOUSE_ENTER':
|
44
|
+
return state.isInputFocused
|
45
|
+
? state
|
46
|
+
: { ...state, iconColor: 'var(--ff-nlp-input-text-hover-color)' };
|
47
|
+
case 'MOUSE_LEAVE':
|
48
|
+
return state.isInputFocused
|
49
|
+
? state
|
50
|
+
: // todo color need to be add in style guide
|
51
|
+
{
|
52
|
+
...state,
|
53
|
+
iconColor: 'var(--ff-nlp-input-default-color)',
|
54
|
+
isIconClick: false,
|
55
|
+
};
|
56
|
+
|
57
|
+
case 'UPDATE_DROPDOWN_POSITION':
|
58
|
+
const { positionX, positionY, width, fromBottom } = action.payload || {};
|
59
|
+
return {
|
60
|
+
...state,
|
61
|
+
dropdownPosition: {
|
62
|
+
positionX,
|
63
|
+
positionY,
|
64
|
+
width,
|
65
|
+
fromBottom,
|
66
|
+
},
|
67
|
+
};
|
68
|
+
|
69
|
+
case 'UPDATE_OPTION':
|
70
|
+
return {
|
71
|
+
...state,
|
72
|
+
option: action.payload,
|
73
|
+
};
|
74
|
+
|
75
|
+
case 'UPDATE_OPTION_LIST':
|
76
|
+
return {
|
77
|
+
...state,
|
78
|
+
options: action.payload,
|
79
|
+
};
|
80
|
+
case 'SHOW_ERROR':
|
81
|
+
return {
|
82
|
+
...state,
|
83
|
+
isInputFocused: true,
|
84
|
+
isIconClick: false,
|
85
|
+
showOptions: false,
|
86
|
+
options: action.payload.optionsList,
|
87
|
+
option: action.payload.option,
|
88
|
+
|
89
|
+
iconColor: 'var(--ff-nlp-input-default-color)',
|
90
|
+
dropdownPosition: {
|
91
|
+
positionX: 0,
|
92
|
+
positionY: 0,
|
93
|
+
width: 0,
|
94
|
+
fromBottom: 0,
|
95
|
+
},
|
96
|
+
};
|
97
|
+
|
98
|
+
default:
|
99
|
+
return state;
|
100
|
+
}
|
101
|
+
};
|
102
|
+
|
103
|
+
const NlpInput = ({
|
104
|
+
label = '',
|
105
|
+
showLabel = true,
|
106
|
+
optionsList = [],
|
107
|
+
selectedOption = {
|
108
|
+
displayName: '',
|
109
|
+
projectId: '',
|
110
|
+
nlpType: '',
|
111
|
+
platform: '',
|
112
|
+
},
|
113
|
+
onChange = () => {},
|
114
|
+
errorMsg = '',
|
115
|
+
className = '',
|
116
|
+
optionZIndex = 100,
|
117
|
+
disabled = false,
|
118
|
+
borderRadius = true,
|
119
|
+
showBorder = true,
|
120
|
+
required = false,
|
121
|
+
}: SelectProps) => {
|
122
|
+
const initialState: SelectState = useMemo(
|
123
|
+
() => ({
|
124
|
+
isInputFocused: false,
|
125
|
+
|
126
|
+
// todo color need to be added in style guide
|
127
|
+
iconColor: 'var(--ff-nlp-input-default-color)',
|
128
|
+
isIconClick: false,
|
129
|
+
showOptions: false,
|
130
|
+
options: optionsList,
|
131
|
+
option: checkEmpty(selectedOption) ? '' : selectedOption?.projectId,
|
132
|
+
dropdownPosition: { positionX: 0, positionY: 0, width: 0, fromBottom: 0 },
|
133
|
+
}),
|
134
|
+
[optionsList, selectedOption]
|
135
|
+
);
|
136
|
+
|
137
|
+
const [selectControlState, dispatch] = useReducer(
|
138
|
+
nlpInputReducer,
|
139
|
+
initialState
|
140
|
+
);
|
141
|
+
|
142
|
+
const DropDownRef = useRef<HTMLDivElement>(null);
|
143
|
+
const InputRef = useRef<HTMLInputElement>(null);
|
144
|
+
|
145
|
+
const {
|
146
|
+
isInputFocused,
|
147
|
+
iconColor,
|
148
|
+
isIconClick,
|
149
|
+
showOptions,
|
150
|
+
dropdownPosition,
|
151
|
+
options,
|
152
|
+
option,
|
153
|
+
} = selectControlState;
|
154
|
+
|
155
|
+
const calculatePosition = usePortalPosition(DropDownRef, showOptions);
|
156
|
+
|
157
|
+
const handleSelectAction = (
|
158
|
+
actionType:
|
159
|
+
| 'FOCUS_INPUT'
|
160
|
+
| 'MOUSE_ENTER'
|
161
|
+
| 'MOUSE_LEAVE'
|
162
|
+
| 'SHOW_ERROR'
|
163
|
+
| 'BLUR_INPUT'
|
164
|
+
) => {
|
165
|
+
if (!disabled) {
|
166
|
+
if (actionType === 'SHOW_ERROR' || actionType === 'BLUR_INPUT') {
|
167
|
+
dispatch({
|
168
|
+
type: actionType,
|
169
|
+
payload: { optionsList, option: selectedOption.projectId },
|
170
|
+
});
|
171
|
+
} else {
|
172
|
+
dispatch({ type: actionType });
|
173
|
+
}
|
174
|
+
}
|
175
|
+
};
|
176
|
+
|
177
|
+
const onSelectInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
178
|
+
if (disabled) return;
|
179
|
+
const { value } = e.target;
|
180
|
+
|
181
|
+
const filteredOptions = optionsList.filter((option) => {
|
182
|
+
return option.displayName
|
183
|
+
.toLowerCase()
|
184
|
+
.includes(value.toLowerCase().trim());
|
185
|
+
});
|
186
|
+
|
187
|
+
dispatch({ type: 'UPDATE_OPTION_LIST', payload: filteredOptions });
|
188
|
+
dispatch({ type: 'UPDATE_OPTION', payload: value });
|
189
|
+
};
|
190
|
+
|
191
|
+
const onSelectBlur = () => {
|
192
|
+
if (disabled) return;
|
193
|
+
|
194
|
+
if (errorMsg) {
|
195
|
+
handleSelectAction('SHOW_ERROR');
|
196
|
+
} else {
|
197
|
+
handleSelectAction('BLUR_INPUT');
|
198
|
+
}
|
199
|
+
};
|
200
|
+
|
201
|
+
const onSelectOptionSelector = (option: Option) => {
|
202
|
+
if (!disabled) {
|
203
|
+
onSelectBlur();
|
204
|
+
dispatch({ type: 'UPDATE_OPTION', payload: option.projectId });
|
205
|
+
if (onChange) {
|
206
|
+
onChange(option);
|
207
|
+
}
|
208
|
+
}
|
209
|
+
};
|
210
|
+
|
211
|
+
const onSelectUpdatePosition = () => {
|
212
|
+
if (!showOptions || !DropDownRef?.current || disabled) return;
|
213
|
+
const { positionX, positionY, width, fromBottom } =
|
214
|
+
calculatePosition(DropDownRef);
|
215
|
+
dispatch({
|
216
|
+
type: 'UPDATE_DROPDOWN_POSITION',
|
217
|
+
payload: { positionX, positionY, width, fromBottom },
|
218
|
+
});
|
219
|
+
};
|
220
|
+
|
221
|
+
const onSelectToggleScroll = (isEnabled: boolean) => {
|
222
|
+
const bodyScrollWidth = window.innerWidth - document.body.clientWidth;
|
223
|
+
document.body.style.paddingRight = isEnabled ? '' : `${bodyScrollWidth}px`;
|
224
|
+
document.body.style.overflow = isEnabled ? '' : 'hidden';
|
225
|
+
};
|
226
|
+
|
227
|
+
useEffect(() => {
|
228
|
+
if (disabled) return;
|
229
|
+
if (showOptions) {
|
230
|
+
onSelectToggleScroll(!showOptions);
|
231
|
+
}
|
232
|
+
onSelectUpdatePosition();
|
233
|
+
|
234
|
+
const handleResizeOrScroll = () => onSelectUpdatePosition();
|
235
|
+
|
236
|
+
window.addEventListener('resize', handleResizeOrScroll);
|
237
|
+
window.addEventListener('scroll', handleResizeOrScroll);
|
238
|
+
return () => {
|
239
|
+
onSelectToggleScroll(true);
|
240
|
+
window.removeEventListener('resize', handleResizeOrScroll);
|
241
|
+
window.removeEventListener('scroll', handleResizeOrScroll);
|
242
|
+
};
|
243
|
+
}, [showOptions]);
|
244
|
+
|
245
|
+
useEffect(() => {
|
246
|
+
if (errorMsg) {
|
247
|
+
handleSelectAction('SHOW_ERROR');
|
248
|
+
}
|
249
|
+
}, []);
|
250
|
+
|
251
|
+
const applyActiveOptionClasses = !isInputFocused && Boolean(option);
|
252
|
+
|
253
|
+
return (
|
254
|
+
<div className={classNames(`ff-nlp-input-wrapper ${className}`)}>
|
255
|
+
<div className="ff-nlp-input">
|
256
|
+
<input
|
257
|
+
type="text"
|
258
|
+
className={classNames('ff-nlp-input-input', {
|
259
|
+
'ff-nlp-input-input--default': !isInputFocused,
|
260
|
+
'ff-nlp-input-input--active': applyActiveOptionClasses,
|
261
|
+
'ff-nlp-input-input--no-label': !showLabel,
|
262
|
+
'ff-nlp-input-input--error':
|
263
|
+
errorMsg && !isInputFocused && !Boolean(option),
|
264
|
+
'ff-nlp-input-input--border-radius': !borderRadius,
|
265
|
+
'ff-nlp-input-input--disable': disabled,
|
266
|
+
'ff-nlp-input-input--no-border': !showBorder,
|
267
|
+
})}
|
268
|
+
// inline css required due to multiple overlay scenarios are present
|
269
|
+
style={{ zIndex: optionZIndex }}
|
270
|
+
onFocus={() => handleSelectAction('FOCUS_INPUT')}
|
271
|
+
onMouseEnter={() => handleSelectAction('MOUSE_ENTER')}
|
272
|
+
onMouseLeave={() => handleSelectAction('MOUSE_LEAVE')}
|
273
|
+
onChange={onSelectInputChange}
|
274
|
+
value={option}
|
275
|
+
disabled={disabled}
|
276
|
+
autoComplete="off"
|
277
|
+
spellCheck="false"
|
278
|
+
ref={InputRef}
|
279
|
+
/>
|
280
|
+
|
281
|
+
{showLabel && (
|
282
|
+
<div
|
283
|
+
className={classNames('ff-nlp-input-label', {
|
284
|
+
'ff-nlp-input-label--default': !isInputFocused,
|
285
|
+
'ff-nlp-input-label--active': isInputFocused || Boolean(option),
|
286
|
+
'ff-nlp-input-label--error': errorMsg,
|
287
|
+
})}
|
288
|
+
>
|
289
|
+
{required && (
|
290
|
+
<Typography
|
291
|
+
color="var(--$error-light)"
|
292
|
+
className="ff-nlp-input-label--required"
|
293
|
+
>
|
294
|
+
*
|
295
|
+
</Typography>
|
296
|
+
)}
|
297
|
+
{label}
|
298
|
+
</div>
|
299
|
+
)}
|
300
|
+
|
301
|
+
<Icon
|
302
|
+
name="arrow_up"
|
303
|
+
height={7}
|
304
|
+
width={12}
|
305
|
+
className={classNames('ff-nlp-input-arrow', {
|
306
|
+
'ff-nlp-input-arrow--down': isIconClick,
|
307
|
+
'ff-nlp-input-arrow--no-label': !showLabel,
|
308
|
+
})}
|
309
|
+
color={iconColor}
|
310
|
+
/>
|
311
|
+
<fieldset
|
312
|
+
className={classNames('ff-nlp-input-fieldset', {
|
313
|
+
'ff-nlp-input-fieldset--no-label': !showLabel,
|
314
|
+
'ff-nlp-input-fieldset--default': !isInputFocused,
|
315
|
+
'ff-nlp-input-fieldset--active': isInputFocused,
|
316
|
+
'ff-nlp-input-fieldset--option': applyActiveOptionClasses,
|
317
|
+
'ff-nlp-input-fieldset--error': errorMsg,
|
318
|
+
'ff-nlp-input-fieldset--border-radius': !borderRadius,
|
319
|
+
'ff-nlp-input-fieldset--no-border': !showBorder,
|
320
|
+
})}
|
321
|
+
>
|
322
|
+
{/* {showLabel && (
|
323
|
+
<legend
|
324
|
+
className={classNames('ff-nlp-input-legend', {
|
325
|
+
'ff-nlp-input-legend--default': !isInputFocused,
|
326
|
+
'ff-nlp-input-legend--active': isInputFocused,
|
327
|
+
'ff-nlp-input-legend--option': applyActiveOptionClasses,
|
328
|
+
'ff-nlp-input-legend--error': errorMsg,
|
329
|
+
})}
|
330
|
+
>
|
331
|
+
{required && (
|
332
|
+
<Typography
|
333
|
+
fontSize={8}
|
334
|
+
color={'var(--$error-light)'}
|
335
|
+
className="ff-nlp-input-legend--required"
|
336
|
+
>
|
337
|
+
*
|
338
|
+
</Typography>
|
339
|
+
)}
|
340
|
+
{label}
|
341
|
+
</legend>
|
342
|
+
)} */}
|
343
|
+
</fieldset>
|
344
|
+
</div>
|
345
|
+
|
346
|
+
{errorMsg && (
|
347
|
+
<Typography
|
348
|
+
className="ff-nlp-input-wrapper-error-text"
|
349
|
+
fontSize={8}
|
350
|
+
color={'var(--error-light)'}
|
351
|
+
>
|
352
|
+
{errorMsg}
|
353
|
+
</Typography>
|
354
|
+
)}
|
355
|
+
|
356
|
+
<div ref={DropDownRef}>
|
357
|
+
{showOptions &&
|
358
|
+
createPortal(
|
359
|
+
<Dropdown
|
360
|
+
onSelectBlur={onSelectBlur}
|
361
|
+
onSelectOptionSelector={onSelectOptionSelector}
|
362
|
+
dropdownPosition={dropdownPosition}
|
363
|
+
options={options}
|
364
|
+
optionZIndex={optionZIndex}
|
365
|
+
inputRef={InputRef}
|
366
|
+
/>,
|
367
|
+
document.body
|
368
|
+
)}
|
369
|
+
</div>
|
370
|
+
</div>
|
371
|
+
);
|
372
|
+
};
|
373
|
+
|
374
|
+
export default NlpInput;
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import { DrowdownPosition, Option } from '../../type';
|
2
|
+
|
3
|
+
export interface NlpDropDownListProps {
|
4
|
+
/*
|
5
|
+
* Callback function triggered on blur event
|
6
|
+
*/
|
7
|
+
onSelectBlur: () => void;
|
8
|
+
|
9
|
+
/*
|
10
|
+
* Callback function triggered when an option is selected
|
11
|
+
*/
|
12
|
+
onSelectOptionSelector: (option: Option) => void;
|
13
|
+
|
14
|
+
/*
|
15
|
+
* Position of the dropdown relative to the input
|
16
|
+
*/
|
17
|
+
dropdownPosition: DrowdownPosition;
|
18
|
+
|
19
|
+
/*
|
20
|
+
* List of options to display in the dropdown
|
21
|
+
*/
|
22
|
+
options?: Option[];
|
23
|
+
|
24
|
+
/*
|
25
|
+
* Optional z-index for controlling the dropdown's stacking order
|
26
|
+
*/
|
27
|
+
optionZIndex?: number;
|
28
|
+
|
29
|
+
/*
|
30
|
+
* Reference to the input element
|
31
|
+
*/
|
32
|
+
inputRef?: React.RefObject<HTMLInputElement>;
|
33
|
+
|
34
|
+
/*
|
35
|
+
* Optional label for the dropdown
|
36
|
+
*/
|
37
|
+
label?: string;
|
38
|
+
|
39
|
+
/*
|
40
|
+
* If true, shows an error message related to the dropdown
|
41
|
+
*/
|
42
|
+
hasError?: boolean;
|
43
|
+
|
44
|
+
/*
|
45
|
+
* Error message to display when hasError is true
|
46
|
+
*/
|
47
|
+
errorMessage?: string;
|
48
|
+
|
49
|
+
/*
|
50
|
+
* If true, disables the dropdown
|
51
|
+
*/
|
52
|
+
disabled?: boolean;
|
53
|
+
}
|
54
|
+
|
55
|
+
export const nlpDropdownDefaultCSSData = {
|
56
|
+
margin: 6,
|
57
|
+
optionHeight: 32,
|
58
|
+
selectInputHeight: 38,
|
59
|
+
dropDownWrapperPadding: 0,
|
60
|
+
};
|
@@ -0,0 +1,83 @@
|
|
1
|
+
@use '../../../../assets/styles/fonts';
|
2
|
+
|
3
|
+
@mixin absolute-position($top: auto, $right: auto, $bottom: auto, $left: auto) {
|
4
|
+
position: absolute;
|
5
|
+
top: $top;
|
6
|
+
right: $right;
|
7
|
+
bottom: $bottom;
|
8
|
+
left: $left;
|
9
|
+
}
|
10
|
+
|
11
|
+
.ff-nlp-dropdown-wrapper {
|
12
|
+
.ff-nlp-options-wrapper {
|
13
|
+
max-height: 160px;
|
14
|
+
z-index: 100;
|
15
|
+
position: absolute;
|
16
|
+
min-width: 100px;
|
17
|
+
border: 1px solid var(--ff-select-option-border-color);
|
18
|
+
box-sizing: border-box;
|
19
|
+
margin-top: 4px;
|
20
|
+
border-radius: 4px;
|
21
|
+
background-color: var(--ff-select-background-color);
|
22
|
+
box-shadow: 0px 1px 4px 0px var(--ff-select-option-wrapper-box-shadow);
|
23
|
+
overflow: hidden auto;
|
24
|
+
display: flex;
|
25
|
+
justify-content: space-between;
|
26
|
+
|
27
|
+
.ff-nlp-options-wrapper1 {
|
28
|
+
max-height: 160px;
|
29
|
+
z-index: 100;
|
30
|
+
min-width: auto;
|
31
|
+
box-sizing: border-box;
|
32
|
+
}
|
33
|
+
&::-webkit-scrollbar {
|
34
|
+
width: 4px;
|
35
|
+
height: 12px;
|
36
|
+
|
37
|
+
&-thumb {
|
38
|
+
background-color: var(--ff-select-scroll-thumb-color);
|
39
|
+
border-radius: 4px;
|
40
|
+
}
|
41
|
+
|
42
|
+
&-track {
|
43
|
+
background-color: transparent;
|
44
|
+
border-radius: 4px;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
.ff-nlp-option {
|
49
|
+
width: calc(100% - 18px);
|
50
|
+
border: 1px solid transparent;
|
51
|
+
border-radius: 4px;
|
52
|
+
padding: 0px 8px;
|
53
|
+
overflow: hidden;
|
54
|
+
white-space: nowrap;
|
55
|
+
text-overflow: ellipsis;
|
56
|
+
cursor: pointer;
|
57
|
+
|
58
|
+
&:hover {
|
59
|
+
border-color: var(--ff-select-background-color);
|
60
|
+
background-color: var(--ff-select-option-hover-color);
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
.ff-nlp-no-option {
|
65
|
+
width: calc(100% - 16px);
|
66
|
+
margin: 0;
|
67
|
+
overflow: hidden;
|
68
|
+
padding: 0px 8px;
|
69
|
+
white-space: nowrap;
|
70
|
+
text-overflow: ellipsis;
|
71
|
+
cursor: not-allowed;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
.ff-nlp-data {
|
75
|
+
width: 200px;
|
76
|
+
height: 134px;
|
77
|
+
|
78
|
+
border: 1px solid transparent;
|
79
|
+
border-radius: 5px;
|
80
|
+
box-shadow: 0px 1px 4px 0px var(--ff-select-option-wrapper-box-shadow);
|
81
|
+
overflow: scroll;
|
82
|
+
}
|
83
|
+
}
|