pixel-react-excel-sheet 1.0.19 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/Chip/types.d.ts +1 -1
- package/lib/components/ConditionalDropdown/ConditionalDropdown.d.ts +5 -0
- package/lib/components/ConditionalDropdown/OptionsDropdown.d.ts +5 -0
- package/lib/components/ConditionalDropdown/index.d.ts +1 -0
- package/lib/components/ConditionalDropdown/types.d.ts +145 -0
- package/lib/components/CreateVariable/types.d.ts +2 -2
- package/lib/components/InputWithDropdown/InputWithDropdown.d.ts +1 -1
- package/lib/components/LabelEditTextField/types.d.ts +1 -0
- package/lib/components/MachineInputField/types.d.ts +1 -0
- package/lib/components/MenuOption/MenuOption.d.ts +1 -1
- package/lib/components/MenuOption/types.d.ts +2 -1
- package/lib/components/MiniModal/types.d.ts +1 -0
- package/lib/components/Modal/types.d.ts +1 -1
- package/lib/components/NLPInput/NlpInput.d.ts +2 -2
- package/lib/components/NLPInput/components/NlpDropDown/NlpDropDownType.d.ts +6 -3
- package/lib/components/NLPInput/components/NlpDropDown/NlpDropdown.d.ts +1 -1
- package/lib/components/NLPInput/sampleData.d.ts +104 -0
- package/lib/components/NLPInput/types.d.ts +80 -0
- package/lib/components/PopUpModal/types.d.ts +2 -1
- package/lib/components/ProgressBar/ProgressBar.d.ts +5 -0
- package/lib/components/ProgressBar/index.d.ts +1 -0
- package/lib/components/ProgressBar/types.d.ts +12 -0
- package/lib/components/SequentialConnectingBranch/components/Branches/Branches.d.ts +1 -1
- package/lib/components/SequentialConnectingBranch/components/Branches/types.d.ts +1 -0
- package/lib/components/SequentialConnectingBranch/components/ConnectingBranches/ConnectingBranches.d.ts +1 -1
- package/lib/components/SequentialConnectingBranch/components/ConnectingBranches/types.d.ts +1 -0
- package/lib/components/SequentialConnectingBranch/types.d.ts +1 -1
- package/lib/components/TableTree/TableTree.d.ts +2 -2
- package/lib/components/TableTree/Utils/getAllChildIds.d.ts +1 -0
- package/lib/components/TableTree/types.d.ts +1 -1
- package/lib/hooks/useIntersectionObserver.d.ts +9 -0
- package/lib/index.d.ts +154 -37
- package/lib/index.esm.js +817 -516
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +818 -516
- package/lib/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/functionCheck/functionCheck.d.ts +2 -0
- package/package.json +1 -1
- package/src/StyleGuide/ColorPalette/colorPaletteList.ts +5 -0
- package/src/assets/Themes/BaseTheme.scss +18 -3
- package/src/assets/Themes/DarkTheme.scss +15 -2
- package/src/assets/icons/ai_search.svg +9 -0
- package/src/assets/icons/help_icon.svg +10 -0
- package/src/assets/icons/import_icon.svg +4 -0
- package/src/assets/icons/ios_icon.svg +11 -0
- package/src/assets/icons/plus_round_icon.svg +38 -0
- package/src/assets/icons/tick_icon.svg +2 -2
- package/src/assets/styles/_colors.scss +1 -1
- package/src/components/AttachmentButton/AttachmentButton.tsx +1 -1
- package/src/components/Checkbox/Checkbox.scss +3 -1
- package/src/components/Checkbox/Checkbox.stories.tsx +32 -77
- package/src/components/Checkbox/Checkbox.tsx +3 -4
- package/src/components/Chip/Chip.scss +15 -5
- package/src/components/Chip/Chip.stories.tsx +10 -1
- package/src/components/Chip/Chip.tsx +5 -1
- package/src/components/Chip/types.ts +1 -1
- package/src/components/{AddVariables/AddVariables.scss → ConditionalDropdown/ConditionalDropdown.scss} +4 -0
- package/src/components/ConditionalDropdown/ConditionalDropdown.stories.tsx +147 -0
- package/src/components/ConditionalDropdown/ConditionalDropdown.tsx +159 -0
- package/src/components/ConditionalDropdown/OptionsDropdown.tsx +44 -0
- package/src/components/ConditionalDropdown/index.ts +1 -0
- package/src/components/ConditionalDropdown/types.ts +160 -0
- package/src/components/CreateVariable/CreateVariableSlider.tsx +2 -2
- package/src/components/CreateVariable/types.ts +2 -2
- package/src/components/EditTextField/EditTextField.scss +1 -1
- package/src/components/EditTextField/EditTextField.tsx +14 -20
- package/src/components/Excel/ExcelFile/ExcelFileComponents/ColumnIndicator.tsx +9 -26
- package/src/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.scss +4 -2
- package/src/components/Excel/ExcelFile.stories.tsx +1 -1
- package/src/components/Form/Forms.tsx +0 -2
- package/src/components/Icon/iconList.ts +12 -0
- package/src/components/InputWithDropdown/InputWithDropdown.tsx +102 -95
- package/src/components/LabelEditTextField/LabelEditTextField.scss +1 -1
- package/src/components/LabelEditTextField/LabelEditTextField.tsx +29 -36
- package/src/components/LabelEditTextField/types.ts +1 -0
- package/src/components/MachineInputField/MachineInputField.scss +1 -5
- package/src/components/MachineInputField/MachineInputField.stories.tsx +4 -4
- package/src/components/MachineInputField/MachineInputField.tsx +4 -1
- package/src/components/MachineInputField/types.ts +1 -0
- package/src/components/MenuOption/MenuOption.scss +7 -7
- package/src/components/MenuOption/MenuOption.stories.tsx +83 -28
- package/src/components/MenuOption/MenuOption.tsx +9 -13
- package/src/components/MenuOption/types.ts +3 -2
- package/src/components/MiniModal/MiniModal.scss +0 -1
- package/src/components/MiniModal/MiniModal.stories.tsx +6 -1
- package/src/components/MiniModal/MiniModal.tsx +3 -1
- package/src/components/MiniModal/types.ts +1 -0
- package/src/components/Modal/types.ts +1 -1
- package/src/components/MultiSelect/Dropdown.scss +3 -4
- package/src/components/MultiSelect/Dropdown.tsx +4 -3
- package/src/components/MultiSelect/MultiSelect.scss +1 -0
- package/src/components/MultiSelect/MultiSelect.tsx +1 -0
- package/src/components/NLPInput/NLPInput.scss +77 -21
- package/src/components/NLPInput/NlpInput.stories.tsx +43 -109
- package/src/components/NLPInput/NlpInput.tsx +95 -59
- package/src/components/NLPInput/components/NlpDropDown/NlpDropDownType.ts +6 -4
- package/src/components/NLPInput/components/NlpDropDown/NlpDropdown.scss +86 -35
- package/src/components/NLPInput/components/NlpDropDown/NlpDropdown.tsx +220 -80
- package/src/components/NLPInput/sampleData.ts +162 -0
- package/src/components/NLPInput/{type.tsx → types.tsx} +23 -11
- package/src/components/PopUpModal/PopUpModal.stories.tsx +15 -10
- package/src/components/PopUpModal/PopUpModal.tsx +5 -4
- package/src/components/PopUpModal/types.ts +2 -1
- package/src/components/ProgressBar/ProgressBar.scss +46 -0
- package/src/components/ProgressBar/ProgressBar.stories.tsx +22 -0
- package/src/components/ProgressBar/ProgressBar.tsx +61 -0
- package/src/components/ProgressBar/index.ts +1 -0
- package/src/components/ProgressBar/types.ts +12 -0
- package/src/components/Search/Search.tsx +9 -1
- package/src/components/SequentialConnectingBranch/SequentialConnectingBranch.tsx +2 -0
- package/src/components/SequentialConnectingBranch/components/Branches/Branches.tsx +8 -0
- package/src/components/SequentialConnectingBranch/components/Branches/types.ts +1 -0
- package/src/components/SequentialConnectingBranch/components/ConnectingBranches/ConnectingBranches.tsx +2 -0
- package/src/components/SequentialConnectingBranch/components/ConnectingBranches/types.ts +1 -0
- package/src/components/SequentialConnectingBranch/types.ts +1 -1
- package/src/components/Table/Table.scss +1 -0
- package/src/components/TableTree/Components/TableBody.tsx +3 -1
- package/src/components/TableTree/TableTree.stories.tsx +4 -7
- package/src/components/TableTree/TableTree.tsx +29 -181
- package/src/components/TableTree/Utils/getAllChildIds.ts +2 -0
- package/src/components/TableTree/data.ts +45 -0
- package/src/components/TableTree/types.ts +1 -1
- package/src/hooks/useIntersectionObserver.tsx +56 -0
- package/src/index.ts +4 -3
- package/src/utils/functionCheck/functionCheck.ts +8 -0
- package/src/components/AddVariables/AddVariables.stories.tsx +0 -44
- package/src/components/AddVariables/AddVariables.tsx +0 -113
- package/src/components/AddVariables/index.ts +0 -1
- package/src/components/AddVariables/types.ts +0 -36
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
3
|
import Chip from './Chip';
|
|
3
4
|
import '../../assets/styles/_colors.scss';
|
|
4
5
|
import './Chip.scss';
|
|
5
6
|
import Typography from '../Typography';
|
|
7
|
+
|
|
6
8
|
const meta: Meta<typeof Chip> = {
|
|
7
9
|
title: 'Components/Chip',
|
|
8
10
|
component: Chip,
|
|
@@ -111,7 +113,14 @@ export const Disabled: Story = {
|
|
|
111
113
|
...defaultArgs,
|
|
112
114
|
variant: 'disabled',
|
|
113
115
|
fullText: 'Sub Modules 0',
|
|
114
|
-
},
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
export const Count: Story = {
|
|
119
|
+
args: {
|
|
120
|
+
...defaultArgs,
|
|
121
|
+
variant: 'count',
|
|
122
|
+
fullText: 'Sub Modules 0',
|
|
123
|
+
},
|
|
115
124
|
};
|
|
116
125
|
|
|
117
126
|
export default meta;
|
|
@@ -26,7 +26,11 @@ const Chip = ({
|
|
|
26
26
|
{ ['ff-default-chip-style--fullText']: !!fullText }
|
|
27
27
|
)}
|
|
28
28
|
>
|
|
29
|
-
{labelText &&
|
|
29
|
+
{labelText && (
|
|
30
|
+
<Typography as="p" fontSize={10} fontWeight="semi-bold">
|
|
31
|
+
{labelText}
|
|
32
|
+
</Typography>
|
|
33
|
+
)}
|
|
30
34
|
</button>
|
|
31
35
|
</div>
|
|
32
36
|
);
|
|
@@ -10,7 +10,7 @@ export interface ChipsProps {
|
|
|
10
10
|
/**
|
|
11
11
|
* The variant of the Chip.
|
|
12
12
|
*/
|
|
13
|
-
variant?: 'primary' | 'success' | 'error' | 'warning' | 'custom' | 'public' | 'partial-public' | 'private' | 'disabled';
|
|
13
|
+
variant?: 'primary' | 'success' | 'error' | 'warning' | 'custom' | 'public' | 'partial-public' | 'private' | 'disabled' | 'count';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* The callback function to be executed when the Chip is clicked.
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Meta, StoryFn, StoryObj } from '@storybook/react';
|
|
3
|
+
import ConditionalDropdown from './ConditionalDropdown';
|
|
4
|
+
import { ConditionalDropdownProps, dynamicObject } from './types';
|
|
5
|
+
import { variableList } from '../Editor/constants';
|
|
6
|
+
import CreateVariableSlider from '../CreateVariable/CreateVariableSlider';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: 'Components/ConditionalDropdown',
|
|
10
|
+
component: ConditionalDropdown,
|
|
11
|
+
args: {
|
|
12
|
+
label: 'Add Variables',
|
|
13
|
+
placeholder: 'Enter text',
|
|
14
|
+
variableList,
|
|
15
|
+
dropdownWidth: '138px',
|
|
16
|
+
variant: 'primary',
|
|
17
|
+
},
|
|
18
|
+
parameters: {
|
|
19
|
+
layout: 'centered',
|
|
20
|
+
},
|
|
21
|
+
} as Meta<ConditionalDropdownProps>;
|
|
22
|
+
|
|
23
|
+
type Story = StoryObj<typeof ConditionalDropdown>;
|
|
24
|
+
|
|
25
|
+
const Template: StoryFn<ConditionalDropdownProps> = (args) => {
|
|
26
|
+
const [inputValue, setInputValue] = useState<string>('');
|
|
27
|
+
const [openCreateVariable, setOpenCreateVariable] = useState<boolean>(false);
|
|
28
|
+
const [variableName, setVariableName] = useState<string>('');
|
|
29
|
+
const [variableValue, setVariableValue] = useState<string>('');
|
|
30
|
+
const [selectedVariable, setSelectedVariable] = useState<dynamicObject>({
|
|
31
|
+
label: 'Local Variable',
|
|
32
|
+
value: 'LOCAL',
|
|
33
|
+
});
|
|
34
|
+
const [hideValue, setHideValue] = useState<boolean>(false);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<>
|
|
38
|
+
<ConditionalDropdown
|
|
39
|
+
{...args}
|
|
40
|
+
onChange={(value: string) => setInputValue(value)}
|
|
41
|
+
value={inputValue}
|
|
42
|
+
onCreateVariableClick={() => setOpenCreateVariable(true)}
|
|
43
|
+
/>
|
|
44
|
+
{openCreateVariable && (
|
|
45
|
+
<CreateVariableSlider
|
|
46
|
+
isOpen={openCreateVariable}
|
|
47
|
+
onClose={() => setOpenCreateVariable(false)}
|
|
48
|
+
variableName={variableName}
|
|
49
|
+
value={variableValue}
|
|
50
|
+
hideValue={hideValue}
|
|
51
|
+
handleSubmit={() => {
|
|
52
|
+
alert('Variable Created');
|
|
53
|
+
}}
|
|
54
|
+
onHideChange={(value) => {
|
|
55
|
+
setHideValue(value);
|
|
56
|
+
}}
|
|
57
|
+
onNameChange={(value) => {
|
|
58
|
+
setVariableName(value);
|
|
59
|
+
}}
|
|
60
|
+
onValueChange={(value) => setVariableValue(value)}
|
|
61
|
+
onVariableTypeChange={(option) => setSelectedVariable(option)}
|
|
62
|
+
selectedVariableType={selectedVariable}
|
|
63
|
+
variableTypesList={[
|
|
64
|
+
{ label: 'Local Variable', value: 'LOCAL' },
|
|
65
|
+
{ label: 'Global Variable', value: 'GLOBAL' },
|
|
66
|
+
]}
|
|
67
|
+
/>
|
|
68
|
+
)}
|
|
69
|
+
</>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const Default = Template.bind({});
|
|
74
|
+
Default.args = {
|
|
75
|
+
onCreateVariableClick: () => alert('Create Variable clicked'),
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const WithInitialValue = Template.bind({});
|
|
79
|
+
WithInitialValue.args = {
|
|
80
|
+
inputValue: 'Initial Text with $',
|
|
81
|
+
onCreateVariableClick: () => alert('Create Variable clicked'),
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const DropdownOnHash: Story = {
|
|
85
|
+
render: () => {
|
|
86
|
+
const [hashInputValue, setHashInputValue] = useState<
|
|
87
|
+
dynamicObject | undefined
|
|
88
|
+
>();
|
|
89
|
+
const testData = [
|
|
90
|
+
{
|
|
91
|
+
_id: '1',
|
|
92
|
+
name: 'File1.txt',
|
|
93
|
+
actualPath: '/documents/File1.txt',
|
|
94
|
+
searchKey: 'file1',
|
|
95
|
+
parentId: 'root',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
_id: '2',
|
|
99
|
+
name: 'File2.doc',
|
|
100
|
+
actualPath: '/documents/File2.doc',
|
|
101
|
+
searchKey: 'file2',
|
|
102
|
+
parentId: 'root',
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
_id: '3',
|
|
106
|
+
name: 'Image1.png',
|
|
107
|
+
actualPath: '/images/Image1.png',
|
|
108
|
+
searchKey: 'image1',
|
|
109
|
+
parentId: 'folder1',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
_id: '4',
|
|
113
|
+
name: 'Presentation.ppt',
|
|
114
|
+
actualPath: '/presentations/Presentation.ppt',
|
|
115
|
+
searchKey: 'presentation',
|
|
116
|
+
parentId: 'folder2',
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
_id: '5',
|
|
120
|
+
name: 'Spreadsheet.xlsx',
|
|
121
|
+
actualPath: '/spreadsheets/Spreadsheet.xlsx',
|
|
122
|
+
searchKey: 'spreadsheet',
|
|
123
|
+
parentId: 'folder3',
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
_id: '6',
|
|
127
|
+
name: 'Code.js',
|
|
128
|
+
actualPath: '/projects/Code.js',
|
|
129
|
+
searchKey: 'code',
|
|
130
|
+
parentId: 'folder4',
|
|
131
|
+
},
|
|
132
|
+
];
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<>
|
|
136
|
+
<ConditionalDropdown
|
|
137
|
+
label="Select Path Using #"
|
|
138
|
+
placeholder="Enter # to search files"
|
|
139
|
+
isHash
|
|
140
|
+
dataFiles={testData}
|
|
141
|
+
dropdownWidth="auto"
|
|
142
|
+
setHashInputValue={setHashInputValue}
|
|
143
|
+
/>
|
|
144
|
+
</>
|
|
145
|
+
);
|
|
146
|
+
},
|
|
147
|
+
};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { checkEmpty } from '../../utils/checkEmpty/checkEmpty';
|
|
2
|
+
import VariableDropdown from '../Editor/VariableDropdown';
|
|
3
|
+
import Icon from '../Icon';
|
|
4
|
+
import Input from '../Input';
|
|
5
|
+
import { ConditionalDropdownProps, dynamicObject } from './types';
|
|
6
|
+
import './ConditionalDropdown.scss';
|
|
7
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
8
|
+
import OptionsDropdown from './OptionsDropdown';
|
|
9
|
+
|
|
10
|
+
const ConditionalDropdown: React.FC<ConditionalDropdownProps> = ({
|
|
11
|
+
label = '',
|
|
12
|
+
hashInputValue = '',
|
|
13
|
+
setHashInputValue,
|
|
14
|
+
variableList = [],
|
|
15
|
+
placeholder = 'Enter text',
|
|
16
|
+
onChange,
|
|
17
|
+
onCreateVariableClick,
|
|
18
|
+
value = '',
|
|
19
|
+
dropdownWidth = 'inherit',
|
|
20
|
+
isHash = false,
|
|
21
|
+
dataFiles = [],
|
|
22
|
+
...props
|
|
23
|
+
}) => {
|
|
24
|
+
const [inputValue, setInputValue] = useState<string>('');
|
|
25
|
+
const [showDropdown, setShowDropdown] = useState<boolean>(false);
|
|
26
|
+
const [cursorPosition, setCursorPosition] = useState<number | null>(null);
|
|
27
|
+
const [showCreateVariableIcon, setShowCreateVariableIcon] =
|
|
28
|
+
useState<boolean>(false);
|
|
29
|
+
const [filteredOptions, setFilteredOptions] = useState<dynamicObject[]>([]);
|
|
30
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (cursorPosition !== null && inputRef.current) {
|
|
34
|
+
inputRef.current.setSelectionRange(cursorPosition, cursorPosition);
|
|
35
|
+
inputRef.current.focus();
|
|
36
|
+
}
|
|
37
|
+
}, [cursorPosition]);
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (inputValue.startsWith('#') && isHash) {
|
|
41
|
+
const searchQuery = inputValue.slice(1).toLowerCase();
|
|
42
|
+
const filtered = dataFiles.filter((file) =>
|
|
43
|
+
file.name.toLowerCase().includes(searchQuery)
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
setFilteredOptions(filtered);
|
|
47
|
+
setShowDropdown(filtered.length > 0);
|
|
48
|
+
} else if (!isHash) {
|
|
49
|
+
const newPayload = replaceVariablesWithIds(inputValue);
|
|
50
|
+
onChange?.(newPayload);
|
|
51
|
+
}
|
|
52
|
+
}, [inputValue]);
|
|
53
|
+
|
|
54
|
+
const replaceVariablesWithIds = (input: string): string => {
|
|
55
|
+
return input.replace(/\${.*?_(.*?)}/g, (_, variableName) => {
|
|
56
|
+
const foundVariable = variableList.find(
|
|
57
|
+
(varaible) => varaible.name === variableName.trim()
|
|
58
|
+
);
|
|
59
|
+
return foundVariable ? `\${${foundVariable.id}}` : `\${${variableName}}`;
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
64
|
+
const fieldValue = event.target.value;
|
|
65
|
+
setInputValue(fieldValue);
|
|
66
|
+
const cursorPos = inputRef.current?.selectionStart || 0;
|
|
67
|
+
const isDollarTyped = fieldValue[cursorPos - 1] === '$';
|
|
68
|
+
|
|
69
|
+
if (isHash) {
|
|
70
|
+
setShowDropdown(fieldValue.startsWith('#'));
|
|
71
|
+
} else {
|
|
72
|
+
if (isDollarTyped) {
|
|
73
|
+
setShowDropdown(true);
|
|
74
|
+
} else {
|
|
75
|
+
setShowDropdown(false);
|
|
76
|
+
}
|
|
77
|
+
if (fieldValue?.includes('$')) {
|
|
78
|
+
setShowCreateVariableIcon(false);
|
|
79
|
+
} else {
|
|
80
|
+
setShowCreateVariableIcon(true);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const handleDropdownClick = (item: dynamicObject) => {
|
|
86
|
+
if (inputRef.current) {
|
|
87
|
+
const { selectionStart, selectionEnd } = inputRef.current;
|
|
88
|
+
const dollarSyntax = `{${
|
|
89
|
+
item.type === 'LOCAL'
|
|
90
|
+
? 'LV'
|
|
91
|
+
: item.type === 'GLOBAL'
|
|
92
|
+
? 'GV'
|
|
93
|
+
: item.type === 'GROUP'
|
|
94
|
+
? 'SG'
|
|
95
|
+
: 'PEV'
|
|
96
|
+
}_${item.name}}`;
|
|
97
|
+
|
|
98
|
+
let newValue;
|
|
99
|
+
if (isHash && inputValue[0] === '#') {
|
|
100
|
+
newValue = item.name + inputValue.slice(selectionEnd || 1);
|
|
101
|
+
} else {
|
|
102
|
+
newValue =
|
|
103
|
+
inputValue.slice(0, selectionStart || 0) +
|
|
104
|
+
dollarSyntax +
|
|
105
|
+
inputValue.slice(selectionEnd || 0);
|
|
106
|
+
}
|
|
107
|
+
setHashInputValue?.(item);
|
|
108
|
+
setInputValue(newValue);
|
|
109
|
+
setCursorPosition((selectionStart || 0) + dollarSyntax.length);
|
|
110
|
+
setShowDropdown(false);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<div className="ff-add-variable-container">
|
|
116
|
+
<div className="ff-add-variable-input">
|
|
117
|
+
<Input
|
|
118
|
+
{...props}
|
|
119
|
+
name="add_variable"
|
|
120
|
+
ref={inputRef}
|
|
121
|
+
type="text"
|
|
122
|
+
value={inputValue}
|
|
123
|
+
onChange={handleChange}
|
|
124
|
+
variant="primary"
|
|
125
|
+
label={label}
|
|
126
|
+
placeholder={placeholder}
|
|
127
|
+
/>
|
|
128
|
+
{!checkEmpty(value) && !isHash && showCreateVariableIcon && (
|
|
129
|
+
<Icon
|
|
130
|
+
onClick={onCreateVariableClick}
|
|
131
|
+
name="add_variable"
|
|
132
|
+
width={24}
|
|
133
|
+
height={24}
|
|
134
|
+
hoverEffect
|
|
135
|
+
/>
|
|
136
|
+
)}
|
|
137
|
+
</div>
|
|
138
|
+
{showDropdown && (
|
|
139
|
+
isHash ? (
|
|
140
|
+
<OptionsDropdown
|
|
141
|
+
position="relative"
|
|
142
|
+
width={dropdownWidth}
|
|
143
|
+
filteredOptions={filteredOptions}
|
|
144
|
+
onSelectVariable={handleDropdownClick}
|
|
145
|
+
/>
|
|
146
|
+
) : (
|
|
147
|
+
<VariableDropdown
|
|
148
|
+
position="relative"
|
|
149
|
+
width={dropdownWidth}
|
|
150
|
+
optionsList={variableList}
|
|
151
|
+
onSelectVariable={handleDropdownClick}
|
|
152
|
+
/>
|
|
153
|
+
)
|
|
154
|
+
)}
|
|
155
|
+
</div>
|
|
156
|
+
);
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export default ConditionalDropdown;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { FC, ReactNode } from 'react';
|
|
2
|
+
import { dynamicObject, OptionsDropdownProps } from './types';
|
|
3
|
+
import './ConditionalDropdown.scss';
|
|
4
|
+
import Typography from '../Typography';
|
|
5
|
+
import classNames from 'classnames';
|
|
6
|
+
|
|
7
|
+
const OptionsDropdown:FC<OptionsDropdownProps> = ({
|
|
8
|
+
onSelectVariable,
|
|
9
|
+
dropdownPosition,
|
|
10
|
+
filteredOptions= [],
|
|
11
|
+
position = 'relative',
|
|
12
|
+
width = '300px',
|
|
13
|
+
}): ReactNode => {
|
|
14
|
+
return (
|
|
15
|
+
<div
|
|
16
|
+
className={classNames('ff-variable-dropdown', position)}
|
|
17
|
+
style={
|
|
18
|
+
dropdownPosition
|
|
19
|
+
? {
|
|
20
|
+
top: dropdownPosition.top + 30,
|
|
21
|
+
left: dropdownPosition.left - 30,
|
|
22
|
+
width,
|
|
23
|
+
}
|
|
24
|
+
: { width }
|
|
25
|
+
}
|
|
26
|
+
>
|
|
27
|
+
{filteredOptions?.map((option: dynamicObject): ReactNode => {
|
|
28
|
+
return (
|
|
29
|
+
<div
|
|
30
|
+
className="ff-variable-option"
|
|
31
|
+
onClick={() => onSelectVariable(option)}
|
|
32
|
+
key={option?.id}
|
|
33
|
+
>
|
|
34
|
+
<Typography as="span" fontSize={14}>
|
|
35
|
+
{option?.name}
|
|
36
|
+
</Typography>
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
})}
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default OptionsDropdown;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ConditionalDropdown';
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { dropdownPositionType } from "../Editor/types";
|
|
2
|
+
|
|
3
|
+
export type dynamicObject = {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type TestDataObject = {
|
|
8
|
+
_id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
actualPath: string;
|
|
11
|
+
searchKey: string;
|
|
12
|
+
parentId: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ConditionalDropdownProps {
|
|
16
|
+
/**
|
|
17
|
+
* Label for the field
|
|
18
|
+
*/
|
|
19
|
+
label?: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Value in the input should stored in this state
|
|
23
|
+
*/
|
|
24
|
+
hashInputValue?: TestDataObject | dynamicObject;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Function storing and updating the inputValue state
|
|
28
|
+
*/
|
|
29
|
+
setHashInputValue?:(value: dynamicObject | undefined) => void;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* List of variables
|
|
33
|
+
*/
|
|
34
|
+
variableList?: dynamicObject[];
|
|
35
|
+
/**
|
|
36
|
+
* Place holder for the input field
|
|
37
|
+
*/
|
|
38
|
+
placeholder?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Function to handle input change
|
|
41
|
+
* @param value
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
onChange?: (value: string) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Function to handle create variable icon click
|
|
47
|
+
*/
|
|
48
|
+
onCreateVariableClick?: () => void;
|
|
49
|
+
/**
|
|
50
|
+
* Width of the dropdown
|
|
51
|
+
*/
|
|
52
|
+
dropdownWidth?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Name | name of the input field
|
|
55
|
+
*/
|
|
56
|
+
name?: string;
|
|
57
|
+
/**
|
|
58
|
+
* value | input field value
|
|
59
|
+
*/
|
|
60
|
+
value?: string;
|
|
61
|
+
/**
|
|
62
|
+
* variants to set color/style of the input field
|
|
63
|
+
*/
|
|
64
|
+
variant?: 'default' | 'primary';
|
|
65
|
+
/**
|
|
66
|
+
* type to set color/style of the input field
|
|
67
|
+
*/
|
|
68
|
+
type?: 'text' | 'password' | 'number' | 'email' | 'url' | 'time';
|
|
69
|
+
/**
|
|
70
|
+
* error | If true, error message will be displayed
|
|
71
|
+
*/
|
|
72
|
+
error?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* helperText | error, success, warning message to be shown
|
|
75
|
+
*/
|
|
76
|
+
helperText?: string;
|
|
77
|
+
/**
|
|
78
|
+
* to disable the input field
|
|
79
|
+
*/
|
|
80
|
+
disabled?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* if true, input field will be mandatory
|
|
83
|
+
*/
|
|
84
|
+
required?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* classnames to style the input field
|
|
87
|
+
*/
|
|
88
|
+
className?: string;
|
|
89
|
+
/**
|
|
90
|
+
* noBorder prop 'true' removes border of input
|
|
91
|
+
*/
|
|
92
|
+
noBorder?: boolean;
|
|
93
|
+
|
|
94
|
+
onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
95
|
+
|
|
96
|
+
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
97
|
+
|
|
98
|
+
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
99
|
+
/**
|
|
100
|
+
* id to select the input field uniquely
|
|
101
|
+
*/
|
|
102
|
+
id?: string;
|
|
103
|
+
/**
|
|
104
|
+
* if on, suggestion popup will be displayed
|
|
105
|
+
*/
|
|
106
|
+
autoComplete?: 'on' | 'off';
|
|
107
|
+
/**
|
|
108
|
+
* minimum and maximum values for the number type input field and their functions
|
|
109
|
+
*/
|
|
110
|
+
minValue?: number;
|
|
111
|
+
maxValue?: number;
|
|
112
|
+
/**
|
|
113
|
+
* background of the input field prop
|
|
114
|
+
*/
|
|
115
|
+
transparentBackground?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* size for the input field
|
|
118
|
+
*/
|
|
119
|
+
size?: 'small' | 'medium';
|
|
120
|
+
/**
|
|
121
|
+
* isLabelRequired for the input field without label,showing placeholder
|
|
122
|
+
*/
|
|
123
|
+
isLabelRequired?: boolean;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* If true, dropdown opens when '#' is entered at the first position.
|
|
127
|
+
*/
|
|
128
|
+
isHash?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Options for the dropdown when `isHash` is true.
|
|
131
|
+
*/
|
|
132
|
+
dataFiles?: dynamicObject[];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface OptionsDropdownProps {
|
|
136
|
+
/**
|
|
137
|
+
* Position whether absoloute or relative
|
|
138
|
+
*/
|
|
139
|
+
position: 'absolute' | 'relative';
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Dropdown width
|
|
143
|
+
*/
|
|
144
|
+
width: string;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* chars entered to search in Input :
|
|
148
|
+
*/
|
|
149
|
+
filteredOptions?: dynamicObject[];
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Function to handle click on variable
|
|
153
|
+
*/
|
|
154
|
+
onSelectVariable: (variable: object) => void;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Dropdown postion used for dropdown placement
|
|
158
|
+
*/
|
|
159
|
+
dropdownPosition?: dropdownPositionType;
|
|
160
|
+
}
|
|
@@ -57,7 +57,7 @@ const CreateVariableSlider: FC<CreateVariableProps> = ({
|
|
|
57
57
|
required
|
|
58
58
|
type="text"
|
|
59
59
|
name="variable name"
|
|
60
|
-
value={variableName}
|
|
60
|
+
value={variableName || ''}
|
|
61
61
|
onChange={(event) => onNameChange(event.target.value)}
|
|
62
62
|
/>
|
|
63
63
|
<Select
|
|
@@ -73,7 +73,7 @@ const CreateVariableSlider: FC<CreateVariableProps> = ({
|
|
|
73
73
|
required
|
|
74
74
|
type="text"
|
|
75
75
|
name="value"
|
|
76
|
-
value={value}
|
|
76
|
+
value={value || ''}
|
|
77
77
|
onChange={(event) => onValueChange(event.target.value)}
|
|
78
78
|
/>
|
|
79
79
|
<div className="ff-hide-value-content">
|
|
@@ -38,11 +38,11 @@ export interface CreateVariableProps {
|
|
|
38
38
|
/**
|
|
39
39
|
* onChange of name
|
|
40
40
|
*/
|
|
41
|
-
onNameChange: (value: string
|
|
41
|
+
onNameChange: (value: string) => void;
|
|
42
42
|
/**
|
|
43
43
|
* onChange of value
|
|
44
44
|
*/
|
|
45
|
-
onValueChange: (value: string
|
|
45
|
+
onValueChange: (value: string) => void;
|
|
46
46
|
/**
|
|
47
47
|
* Hide value
|
|
48
48
|
*/
|
|
@@ -6,6 +6,7 @@ import HighlightText from '../HighlightText';
|
|
|
6
6
|
import Icon from '../Icon';
|
|
7
7
|
import Tooltip from '../Tooltip';
|
|
8
8
|
import { capitalize } from '../../utils/capitalize/capitalize';
|
|
9
|
+
import Input from '../Input/Input';
|
|
9
10
|
|
|
10
11
|
const getErrorMessage = (
|
|
11
12
|
inputValue: string,
|
|
@@ -38,8 +39,8 @@ const EditTextField: FC<LabelEditTextFieldTypes> = ({
|
|
|
38
39
|
cancelIcon,
|
|
39
40
|
editIcon,
|
|
40
41
|
dropdownData = [],
|
|
41
|
-
width = '
|
|
42
|
-
height = '
|
|
42
|
+
// width = '',
|
|
43
|
+
// height = '',
|
|
43
44
|
isOpen = false,
|
|
44
45
|
confirmAction,
|
|
45
46
|
onClick,
|
|
@@ -52,6 +53,7 @@ const EditTextField: FC<LabelEditTextFieldTypes> = ({
|
|
|
52
53
|
);
|
|
53
54
|
const [showError, setShowError] = useState('');
|
|
54
55
|
const [isTextFieldModified, setIsTextFieldModified] = useState(false);
|
|
56
|
+
const isThrowingError = showError && isEditing ? true : false;
|
|
55
57
|
const containerRef = useRef<HTMLDivElement | null>(null);
|
|
56
58
|
const cancelRef = useRef<HTMLDivElement | null>(null);
|
|
57
59
|
|
|
@@ -96,27 +98,19 @@ const EditTextField: FC<LabelEditTextFieldTypes> = ({
|
|
|
96
98
|
{isEditing ? (
|
|
97
99
|
<div className="ff-label-text-field">
|
|
98
100
|
<div className="ff-label-text-field-without-dropdown">
|
|
99
|
-
<
|
|
100
|
-
|
|
101
|
+
<Input
|
|
102
|
+
name="input"
|
|
103
|
+
label={label ? label : ''}
|
|
104
|
+
disabled={false}
|
|
105
|
+
error={isThrowingError}
|
|
106
|
+
placeholder="Enter your name"
|
|
101
107
|
value={inputValue}
|
|
102
108
|
onChange={handleTextFieldChange}
|
|
103
|
-
className={`
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
} ${isTextFieldModified ? 'modified' : ''}`}
|
|
108
|
-
placeholder=" "
|
|
109
|
-
style={{ width, height }}
|
|
109
|
+
className={`
|
|
110
|
+
|
|
111
|
+
${isTextFieldModified ? 'modified' : ''}`}
|
|
112
|
+
type="text"
|
|
110
113
|
/>
|
|
111
|
-
<label
|
|
112
|
-
className={`ff-textfield-label ${
|
|
113
|
-
showError && isEditing
|
|
114
|
-
? 'ff-text-field-error-text'
|
|
115
|
-
: 'ff-text-field-text'
|
|
116
|
-
}`}
|
|
117
|
-
>
|
|
118
|
-
{label}
|
|
119
|
-
</label>
|
|
120
114
|
</div>
|
|
121
115
|
<div className="ff-icon-container">
|
|
122
116
|
{confirmIcon && (
|