pixel-react-excel-sheet 1.0.19 → 1.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/lib/components/ConditionalDropdown/ConditionalDropdown.d.ts +5 -0
  2. package/lib/components/ConditionalDropdown/index.d.ts +1 -0
  3. package/lib/components/ConditionalDropdown/types.d.ts +99 -0
  4. package/lib/components/CreateVariable/types.d.ts +2 -2
  5. package/lib/components/InputWithDropdown/InputWithDropdown.d.ts +1 -1
  6. package/lib/components/Modal/types.d.ts +1 -1
  7. package/lib/components/PopUpModal/types.d.ts +2 -1
  8. package/lib/components/TableTree/TableTree.d.ts +2 -2
  9. package/lib/components/TableTree/Utils/getAllChildIds.d.ts +1 -0
  10. package/lib/index.d.ts +77 -12
  11. package/lib/index.esm.js +119 -120
  12. package/lib/index.esm.js.map +1 -1
  13. package/lib/index.js +119 -120
  14. package/lib/index.js.map +1 -1
  15. package/lib/tsconfig.tsbuildinfo +1 -1
  16. package/package.json +1 -1
  17. package/src/assets/icons/import_icon.svg +4 -0
  18. package/src/components/ConditionalDropdown/ConditionalDropdown.stories.tsx +82 -0
  19. package/src/components/{AddVariables/AddVariables.tsx → ConditionalDropdown/ConditionalDropdown.tsx} +30 -14
  20. package/src/components/ConditionalDropdown/index.ts +1 -0
  21. package/src/components/ConditionalDropdown/types.ts +103 -0
  22. package/src/components/CreateVariable/CreateVariableSlider.tsx +2 -2
  23. package/src/components/CreateVariable/types.ts +2 -2
  24. package/src/components/Excel/ExcelFile/ExcelFileComponents/ColumnIndicator.tsx +9 -26
  25. package/src/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.scss +4 -2
  26. package/src/components/Excel/ExcelFile.stories.tsx +1 -1
  27. package/src/components/Icon/iconList.ts +3 -0
  28. package/src/components/InputWithDropdown/InputWithDropdown.tsx +102 -95
  29. package/src/components/Modal/types.ts +1 -1
  30. package/src/components/PopUpModal/PopUpModal.stories.tsx +15 -10
  31. package/src/components/PopUpModal/PopUpModal.tsx +5 -4
  32. package/src/components/PopUpModal/types.ts +2 -1
  33. package/src/components/TableTree/TableTree.stories.tsx +2 -5
  34. package/src/components/TableTree/TableTree.tsx +5 -167
  35. package/src/components/TableTree/Utils/getAllChildIds.ts +2 -0
  36. package/src/index.ts +2 -3
  37. package/src/components/AddVariables/AddVariables.stories.tsx +0 -44
  38. package/src/components/AddVariables/index.ts +0 -1
  39. package/src/components/AddVariables/types.ts +0 -36
  40. /package/src/components/{AddVariables/AddVariables.scss → ConditionalDropdown/ConditionalDropdown.scss} +0 -0
@@ -1,3 +1,4 @@
1
+ import { forwardRef } from 'react';
1
2
  import classNames from 'classnames';
2
3
  import './InputWithDropdown.scss';
3
4
  import { InputWithDropdownProps } from './types';
@@ -5,44 +6,101 @@ import Select from '../Select/Select';
5
6
  import Typography from '../Typography';
6
7
  import { checkEmpty } from '../../utils/checkEmpty/checkEmpty';
7
8
 
8
- const InputWithDropdown = ({
9
- name = '',
10
- label,
11
- value,
12
- disabled = false,
13
- required = false,
14
- placeholder,
15
- error,
16
- helperText,
17
- optionsList,
18
- selectedOption,
19
- autoComplete = 'off',
20
- onDropdownChangeHandler = () => {},
21
- onInputChangeHandler,
22
- onInputBlurHandler,
23
- optionsRequired = true,
24
- dropdownPosition = 'right',
25
- type = 'text',
26
- }: InputWithDropdownProps) => {
27
- const isValueFilled = !checkEmpty(value) || dropdownPosition === 'left';
9
+ const InputWithDropdown = forwardRef<HTMLInputElement, InputWithDropdownProps>(
10
+ (
11
+ {
12
+ name = '',
13
+ label,
14
+ value,
15
+ disabled = false,
16
+ required = false,
17
+ placeholder,
18
+ error,
19
+ helperText,
20
+ optionsList,
21
+ selectedOption,
22
+ autoComplete = 'off',
23
+ onDropdownChangeHandler = () => {},
24
+ onInputChangeHandler,
25
+ onInputBlurHandler,
26
+ optionsRequired = true,
27
+ dropdownPosition = 'right',
28
+ type = 'text',
29
+ },
30
+ ref
31
+ ) => {
32
+ const isValueFilled = !checkEmpty(value) || dropdownPosition === 'left';
28
33
 
29
- return (
30
- <div
31
- className={classNames('ff-input-with-dropdown-container', {
32
- 'ff-input-with-dropdown-container--filled': isValueFilled,
33
- })}
34
- >
35
- <fieldset
36
- className={classNames('ff-input-with-dropdown', {
37
- 'ff-input-with-dropdown--filled': isValueFilled,
38
- 'ff-input-with-dropdown--no-hover': isValueFilled,
39
- 'ff-input-with-dropdown--disabled': !!disabled,
40
- 'ff-input-with-dropdown--error': !!error,
41
- [`ff-input-with-dropdown--${dropdownPosition}`]: dropdownPosition,
34
+ return (
35
+ <div
36
+ className={classNames('ff-input-with-dropdown-container', {
37
+ 'ff-input-with-dropdown-container--filled': isValueFilled,
42
38
  })}
43
39
  >
44
- {dropdownPosition === 'left' && (
45
- <>
40
+ <fieldset
41
+ className={classNames('ff-input-with-dropdown', {
42
+ 'ff-input-with-dropdown--filled': isValueFilled,
43
+ 'ff-input-with-dropdown--no-hover': isValueFilled,
44
+ 'ff-input-with-dropdown--disabled': !!disabled,
45
+ 'ff-input-with-dropdown--error': !!error,
46
+ [`ff-input-with-dropdown--${dropdownPosition}`]: dropdownPosition,
47
+ })}
48
+ >
49
+ {dropdownPosition === 'left' && (
50
+ <>
51
+ <Select
52
+ optionsList={optionsList}
53
+ selectedOption={selectedOption}
54
+ showLabel={false}
55
+ showBorder={false}
56
+ onChange={onDropdownChangeHandler}
57
+ disabled={disabled || !optionsRequired}
58
+ optionsRequired={optionsRequired}
59
+ className={classNames('ff-floating-dropdown', {
60
+ 'ff-floating-dropdown--disabled': !!disabled,
61
+ 'ff-floating-dropdown--error': !!error,
62
+ 'ff-floating-dropdown--left': dropdownPosition === 'left',
63
+ })}
64
+ width={94}
65
+ height={30}
66
+ />
67
+ <div className="seperatorline" />
68
+ </>
69
+ )}
70
+ <div className={classNames('ff-floating-label-input-container')}>
71
+ <Typography
72
+ as="label"
73
+ htmlFor={name}
74
+ className={classNames('ff-floating-label', {
75
+ 'ff-floating-label--filled': isValueFilled,
76
+ 'ff-floating-label--no-hover': isValueFilled,
77
+ 'ff-floating-label--error': !!error,
78
+ })}
79
+ required={required}
80
+ >
81
+ {label}
82
+ </Typography>
83
+ <input
84
+ ref={ref}
85
+ name={name}
86
+ type={type}
87
+ id={name}
88
+ value={value}
89
+ onChange={onInputChangeHandler}
90
+ onBlur={onInputBlurHandler}
91
+ placeholder={placeholder}
92
+ autoComplete={autoComplete}
93
+ required={required}
94
+ disabled={disabled}
95
+ className={classNames('ff-floating-input', {
96
+ 'ff-floating-input--filled': isValueFilled,
97
+ 'ff-floating-input--disabled': !!disabled,
98
+ 'ff-floating-input--error': !!error,
99
+ 'ff-floating-input--left-dropdown': dropdownPosition === 'left',
100
+ })}
101
+ />
102
+ </div>
103
+ {dropdownPosition === 'right' && (
46
104
  <Select
47
105
  optionsList={optionsList}
48
106
  selectedOption={selectedOption}
@@ -54,69 +112,18 @@ const InputWithDropdown = ({
54
112
  className={classNames('ff-floating-dropdown', {
55
113
  'ff-floating-dropdown--disabled': !!disabled,
56
114
  'ff-floating-dropdown--error': !!error,
57
- 'ff-floating-dropdown--left': dropdownPosition === 'left',
58
115
  })}
59
- width={94}
116
+ width={120}
60
117
  height={30}
61
118
  />
62
- <div className="seperatorline" />
63
- </>
64
- )}
65
- <div className={classNames('ff-floating-label-input-container')}>
66
- <Typography
67
- as="label"
68
- htmlFor={name}
69
- className={classNames('ff-floating-label', {
70
- 'ff-floating-label--filled': isValueFilled,
71
- 'ff-floating-label--no-hover': isValueFilled,
72
- 'ff-floating-label--error': !!error,
73
- })}
74
- required={required}
75
- >
76
- {label}
77
- </Typography>
78
- <input
79
- name={name}
80
- type={type}
81
- id={name}
82
- value={value}
83
- onChange={onInputChangeHandler}
84
- onBlur={onInputBlurHandler}
85
- placeholder={placeholder}
86
- autoComplete={autoComplete}
87
- required={required}
88
- disabled={disabled}
89
- className={classNames('ff-floating-input', {
90
- 'ff-floating-input--filled': isValueFilled,
91
- 'ff-floating-input--disabled': !!disabled,
92
- 'ff-floating-input--error': !!error,
93
- 'ff-floating-input--left-dropdown': dropdownPosition === 'left',
94
- })}
95
- />
96
- </div>
97
- {dropdownPosition === 'right' && (
98
- <Select
99
- optionsList={optionsList}
100
- selectedOption={selectedOption}
101
- showLabel={false}
102
- showBorder={false}
103
- onChange={onDropdownChangeHandler}
104
- disabled={disabled || !optionsRequired}
105
- optionsRequired={optionsRequired}
106
- className={classNames('ff-floating-dropdown', {
107
- 'ff-floating-dropdown--disabled': !!disabled,
108
- 'ff-floating-dropdown--error': !!error,
109
- })}
110
- width={120}
111
- height={30}
112
- />
119
+ )}
120
+ </fieldset>
121
+ {error && helperText && (
122
+ <span className="ff-helper-text">{helperText}</span>
113
123
  )}
114
- </fieldset>
115
- {error && helperText && (
116
- <span className="ff-helper-text">{helperText}</span>
117
- )}
118
- </div>
119
- );
120
- };
124
+ </div>
125
+ );
126
+ }
127
+ );
121
128
 
122
129
  export default InputWithDropdown;
@@ -34,7 +34,7 @@ export interface ModalProps {
34
34
  /***Content to be displayed inside the modal */
35
35
  children: ReactNode;
36
36
  isFooterDisplayed: boolean;
37
- customWidth: string;
37
+ customWidth?: string;
38
38
  customHeight?: string;
39
39
  zIndex?: number;
40
40
  boxShadow?: string;
@@ -2,6 +2,7 @@ import React, { useState } from 'react';
2
2
  import type { Meta, StoryObj } from '@storybook/react';
3
3
  import PopUpModal from './PopUpModal';
4
4
  import Button from '../Button';
5
+ import Typography from '../Typography';
5
6
 
6
7
  const meta: Meta<typeof PopUpModal> = {
7
8
  title: 'Components/PopUpModal',
@@ -15,16 +16,17 @@ const meta: Meta<typeof PopUpModal> = {
15
16
  type Story = StoryObj<typeof PopUpModal>;
16
17
 
17
18
  const defaultArgs = {
18
- iconName: "license_warning",
19
- titleMessage: "Warning!",
20
- subTitleMessage: "Unsaved Changes.",
21
- modalMessage: "Your web service data will be lost. Are you sure you want to exit?",
22
- footerMessage: "How do you want to proceed?",
23
- firstButtonLabel: "Cancel",
24
- secondButtonLabel: "Continue",
25
- buttonVariant: "warning",
26
- border: '1px solid var(--warning-modal-border-color)',
27
- colorForTitleMessage: 'var(--status-button-bg-warning)'
19
+ iconName:"license_warning",
20
+ titleMessage:"Warning!",
21
+ subTitleMessage:"Unsaved Changes.",
22
+ modalMessage:"Your web service data will be lost. Are you sure you want to exit?",
23
+ firstButtonLabel:"Cancel",
24
+ secondButtonLabel:"Continue",
25
+ buttonVariant:"warning",
26
+ border:'1px solid var(--warning-modal-border-color)',
27
+ colorForTitleMessage: 'var(--status-button-bg-warning)',
28
+ popupWidth:'420',
29
+ footerContent:<Typography children='How do you want to proceed?' fontSize={16}/>
28
30
  }
29
31
 
30
32
  export const DefaultModal: Story = {
@@ -35,6 +37,8 @@ export const DefaultModal: Story = {
35
37
  iconName: 'license_warning',
36
38
  titleMessage: 'Warning!',
37
39
  subTitleMessage: 'Unsaved Changes.',
40
+ popupWidth: "420",
41
+ footerContent:<Typography children='How do you want to proceed?' fontSize={16}/>,
38
42
  },
39
43
  };
40
44
 
@@ -53,6 +57,7 @@ export const ControlledPopUp: Story = {
53
57
  isOpen={isOpen}
54
58
  onClose={() => setIsOpen(false)}
55
59
  onContinue={handleContinue}
60
+ footerContent={<Typography children='How do you want to proceed?' fontSize={16}/>}
56
61
  />
57
62
  </>
58
63
  );
@@ -14,12 +14,13 @@ const PopUpModal: FC<PopUpModalProps> = ({
14
14
  subTitleMessage = 'Unsaved Changes.',
15
15
  iconName,
16
16
  modalMessage = 'Your web service data will be lost. Are you sure you want to exit?',
17
- footerMessage = 'How do you want to proceed?',
18
17
  firstButtonLabel = 'Cancel',
19
18
  secondButtonLabel = 'Continue',
20
19
  buttonVariant = 'warning',
21
20
  border = '1px solid var(--warning-modal-border-color)',
22
- colorForTitleMessage = 'var(--status-button-bg-warning)'
21
+ popupWidth = '420',
22
+ colorForTitleMessage = 'var(--status-button-bg-warning)',
23
+ footerContent,
23
24
  }) => {
24
25
  return (
25
26
  <Modal
@@ -55,7 +56,7 @@ const PopUpModal: FC<PopUpModalProps> = ({
55
56
  </Typography>
56
57
  <div className="warning_modal_message_wrapper">
57
58
  <Typography fontSize={16}>{modalMessage}</Typography>
58
- <Typography fontSize={16}>{footerMessage}</Typography>
59
+ <Typography as='div'>{footerContent}</Typography>
59
60
  </div>
60
61
  </div>
61
62
  </div>
@@ -75,7 +76,7 @@ const PopUpModal: FC<PopUpModalProps> = ({
75
76
  }
76
77
  ariaHideApp
77
78
  isFooterDisplayed={false}
78
- customWidth="420px"
79
+ customWidth={`${popupWidth}px`}
79
80
  customHeight="226px"
80
81
  boxShadow="0px 1px 4px 0px var(--toaster-boxshadow)"
81
82
  border={border}
@@ -6,10 +6,11 @@ export interface PopUpModalProps {
6
6
  subTitleMessage?: string;
7
7
  iconName: string;
8
8
  modalMessage: string;
9
- footerMessage: string;
10
9
  firstButtonLabel?: string;
11
10
  secondButtonLabel: string;
12
11
  buttonVariant: any;
13
12
  border: string;
13
+ popupWidth?:string,
14
14
  colorForTitleMessage?: string;
15
+ footerContent?:React.ReactNode;
15
16
  }
@@ -109,7 +109,6 @@ export const Default: Story = {
109
109
  onPagination: (node) => {
110
110
  console.log(node);
111
111
  },
112
- expandedNodes: ['MOD1102'],
113
112
  onExpand: (isExpand, node) => {
114
113
  console.log(isExpand, node);
115
114
  },
@@ -131,12 +130,11 @@ export const ControlledCheckBox: Story = {
131
130
  const [selected, setSelected] = useState<string[]>([]);
132
131
  return (
133
132
  <TableTree
134
- expandedNodes={['MOD1102']}
135
133
  onExpand={(isExpand, node) => {
136
134
  console.log(isExpand, node);
137
135
  }}
138
136
  select="checkbox"
139
- onChange={(nodes: string[]) => {
137
+ onChange={(e, nodes: string[]) => {
140
138
  setSelected(nodes);
141
139
  }}
142
140
  selected={selected}
@@ -146,7 +144,7 @@ export const ControlledCheckBox: Story = {
146
144
  console.log('🚀 ~ e, data:', e, data); //Todo:need to remove
147
145
  }}
148
146
  onPagination={(direction) => {
149
- console.log(direction,'-------------------');
147
+ console.log(direction, '-------------------');
150
148
  }}
151
149
  />
152
150
  );
@@ -157,7 +155,6 @@ export const ControlledRadio: Story = {
157
155
  const [selected, setSelected] = useState<string[]>([]);
158
156
  return (
159
157
  <TableTree
160
- expandedNodes={['MOD1102']}
161
158
  onExpand={(isExpand, node) => {
162
159
  console.log(isExpand, node);
163
160
  }}
@@ -1,22 +1,8 @@
1
- import React, { useMemo, useCallback } from 'react';
1
+ import React, { useCallback, memo } from 'react';
2
2
  import './TableTree.scss';
3
- import { prepareData } from '../../utils/TableCell/TableCell';
4
- import Arrow from '../../assets/icons/arrows_down_icon.svg?react';
5
- import Checkbox from '../Checkbox';
6
- import RadioButton from '../RadioButton';
7
- import {
8
- TableBodyProps,
9
- TableCellProps,
10
- TableHeadProps,
11
- TableRowProps,
12
- TreeTableProps,
13
- } from './types';
14
-
15
- // Helper to render spaces for levels
16
- const renderSpaces = (level: number) =>
17
- Array.from({ length: level }).map((_, i) => (
18
- <span key={i} className="tree-table-space-block" />
19
- ));
3
+ import { TreeTableProps } from './types';
4
+ import TableHead from './Components/TableHead';
5
+ import TableBody from './Components/TableBody';
20
6
 
21
7
  // Recursive function to get all child node IDs (including nested children)
22
8
  const getAllChildIds = (nodeId: string, data: any[]): string[] => {
@@ -32,154 +18,6 @@ const getAllChildIds = (nodeId: string, data: any[]): string[] => {
32
18
  return result;
33
19
  };
34
20
 
35
- // Component: TableCell
36
- const TableCell = React.memo(
37
- ({
38
- col,
39
- node,
40
- level,
41
- selected,
42
- select,
43
- onCheckBoxChange,
44
- onToggleExpand,
45
- }: TableCellProps) => (
46
- <td>
47
- {col.isTree && renderSpaces(level + 1)}
48
- {col.isTree && (
49
- <span
50
- className={`tree-table-space-block last-block ${
51
- node.isExpanded ? 'tree-row-expanded' : 'tree-row-collapsed'
52
- } ${node.folder ? '' : 'no-folder'}`}
53
- onClick={() => onToggleExpand(node)}
54
- >
55
- {node.folder && <Arrow />}
56
- </span>
57
- )}
58
- <span className="tree-table-td-content">
59
- {col.isTree && select === 'checkbox' && (
60
- <Checkbox
61
- checked={selected.includes(node.id)}
62
- onChange={() => onCheckBoxChange('checkbox', node)}
63
- />
64
- )}
65
- {col.isTree && select === 'radio' && (
66
- <RadioButton
67
- name={node.title}
68
- checked={selected.includes(node.id)}
69
- value={node.id}
70
- onChange={() => onCheckBoxChange('radio', node)}
71
- />
72
- )}
73
- {prepareData(node, col)}
74
- </span>
75
- {col.actions && (
76
- <div className="table-tree-row-action">{col.actions(node)}</div>
77
- )}
78
- </td>
79
- )
80
- );
81
-
82
- // Component: TableRow
83
- const TableRow = React.memo(
84
- ({
85
- node,
86
- level,
87
- columnsData,
88
- selected,
89
- select,
90
- onRowClick,
91
- onToggleExpand,
92
- onCheckBoxChange,
93
- }: TableRowProps) => (
94
- <tr
95
- data-level={level}
96
- className="show"
97
- onClick={(e) => onRowClick(e, node)}
98
- >
99
- {columnsData.map((col) => (
100
- <TableCell
101
- key={col.name}
102
- col={col}
103
- node={node}
104
- level={level}
105
- selected={selected}
106
- select={select}
107
- onCheckBoxChange={onCheckBoxChange}
108
- onToggleExpand={onToggleExpand}
109
- />
110
- ))}
111
- </tr>
112
- )
113
- );
114
-
115
- // Component: TableHead
116
- const TableHead = React.memo(({ columnsData }: TableHeadProps) => {
117
- const hasDefaultValues = useMemo(
118
- () => columnsData.some(({ defaultValue }) => !!defaultValue),
119
- [columnsData]
120
- );
121
-
122
- return (
123
- <thead>
124
- <tr>
125
- {columnsData.map(({ name }) => (
126
- <th key={name}>{name}</th>
127
- ))}
128
- </tr>
129
- {hasDefaultValues && (
130
- <tr>
131
- {columnsData.map(({ defaultValue, defaultActions }, index) => (
132
- <td key={index}>
133
- {defaultValue && (
134
- <span className="">
135
- {defaultValue}
136
- {defaultActions && (
137
- <div className="table-tree-row-action">
138
- {defaultActions()}
139
- </div>
140
- )}
141
- </span>
142
- )}
143
- </td>
144
- ))}
145
- </tr>
146
- )}
147
- </thead>
148
- );
149
- });
150
-
151
- // Component: TableBody
152
- const TableBody = React.memo(
153
- ({
154
- flattenedTreeData,
155
- columnsData,
156
- selected,
157
- select,
158
- onRowClick,
159
- onToggleExpand,
160
- onCheckBoxChange,
161
- }: TableBodyProps) => (
162
- <tbody>
163
- {flattenedTreeData.map(({ node, level }) => {
164
- return (
165
- <TableRow
166
- key={node.id}
167
- node={node}
168
- level={level}
169
- columnsData={columnsData}
170
- selected={selected}
171
- select={select}
172
- onRowClick={onRowClick}
173
- onToggleExpand={onToggleExpand}
174
- onCheckBoxChange={onCheckBoxChange}
175
- />
176
- );
177
- })}
178
- </tbody>
179
- )
180
- );
181
-
182
- // Component: TreeTable
183
21
  const TreeTable: React.FC<TreeTableProps> = ({
184
22
  treeData,
185
23
  columnsData,
@@ -242,4 +80,4 @@ const TreeTable: React.FC<TreeTableProps> = ({
242
80
  );
243
81
  };
244
82
 
245
- export default TreeTable;
83
+ export default memo(TreeTable);
@@ -10,3 +10,5 @@ const getAllChildIds = (nodeId: string, data: any[]): string[] => {
10
10
 
11
11
  return result;
12
12
  };
13
+
14
+ export default getAllChildIds;
package/src/index.ts CHANGED
@@ -96,7 +96,7 @@ import Comments from './components/Comment/Comments';
96
96
  import useFileDropzone from './hooks/useFileDropzone';
97
97
  import PopUpModal from './components/PopUpModal/PopUpModal';
98
98
  import FormatString from './utils/FormatString/FormatString';
99
- import AddVariables from './components/AddVariables/AddVariables';
99
+ import ConditionalDropdown from './components/ConditionalDropdown/ConditionalDropdown';
100
100
  import { hasDuplicateFile } from './utils/checkDuplicates/checkDuplicates';
101
101
  import PhoneInputField from './components/PhoneInput';
102
102
 
@@ -179,9 +179,8 @@ export {
179
179
  Comments,
180
180
  PopUpModal,
181
181
  CreateVariableSlider,
182
- AddVariables,
182
+ ConditionalDropdown,
183
183
  PhoneInputField,
184
-
185
184
  TableWithAccordion,
186
185
  // utils exports
187
186
  checkEmpty,
@@ -1,44 +0,0 @@
1
- import React, { useState } from 'react';
2
- import { Meta, StoryFn } from '@storybook/react';
3
- import AddVariables from './AddVariables';
4
- import { AddVariableProps } from './types';
5
- import { variableList } from '../Editor/constants';
6
-
7
- export default {
8
- title: 'Components/AddVariables',
9
- component: AddVariables,
10
- args: {
11
- label: 'Add Variables',
12
- placeholder: 'Enter text',
13
- variableList,
14
- dropdownWidth: '138px',
15
- },
16
- parameters: {
17
- layout: 'centered',
18
- },
19
- } as Meta<AddVariableProps>;
20
-
21
- // Wrapper component to handle state inside Storybook stories
22
- const Template: StoryFn<AddVariableProps> = (args) => {
23
- const [inputValue, setInputValue] = useState<string>('');
24
-
25
- return (
26
- <AddVariables
27
- {...args}
28
- onChange={(value: string) => setInputValue(value)}
29
- value={inputValue}
30
- />
31
- );
32
- };
33
-
34
- export const Default = Template.bind({});
35
- Default.args = {
36
- onCreateVariableClick: () => alert('Create Variable clicked'),
37
- };
38
-
39
- // Customized story with pre-filled input value
40
- export const WithInitialValue = Template.bind({});
41
- WithInitialValue.args = {
42
- inputValue: 'Initial Text with $',
43
- onCreateVariableClick: () => alert('Create Variable clicked'),
44
- };
@@ -1 +0,0 @@
1
- export { default } from './AddVariables';
@@ -1,36 +0,0 @@
1
- export type dynamicObject = {
2
- [key: string]: any;
3
- };
4
-
5
- export interface AddVariableProps {
6
- /**
7
- * Label for the field
8
- */
9
- label?: string;
10
- /**
11
- * List of variables
12
- */
13
- variableList?: dynamicObject[];
14
- /**
15
- * Place holder for the input field
16
- */
17
- placeholder?: string;
18
- /**
19
- * Function to handle input change
20
- * @param value
21
- * @returns
22
- */
23
- onChange: (value: string) => void;
24
- /**
25
- * Function to handle create variable icon click
26
- */
27
- onCreateVariableClick?: () => void;
28
- /**
29
- * Value of the input field
30
- */
31
- value: string;
32
- /**
33
- * Width of the dropdown
34
- */
35
- dropdownWidth?: string;
36
- }