pixel-react-excel-sheet 1.0.12 → 1.0.14

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 (71) hide show
  1. package/lib/components/Charts/BarChart/BarChart.d.ts +1 -0
  2. package/lib/components/Charts/DashboardDonutChart/types.d.ts +6 -0
  3. package/lib/components/FileDropzone/RadioFilePreview.d.ts +4 -0
  4. package/lib/components/FileDropzone/types.d.ts +61 -0
  5. package/lib/components/MenuOption/types.d.ts +3 -2
  6. package/lib/components/Search/Search.d.ts +1 -1
  7. package/lib/components/Search/types.d.ts +4 -0
  8. package/lib/components/Table/Types.d.ts +1 -1
  9. package/lib/components/Tabs/types.d.ts +1 -0
  10. package/lib/index.d.ts +93 -23
  11. package/lib/index.esm.js +509 -291
  12. package/lib/index.esm.js.map +1 -1
  13. package/lib/index.js +510 -290
  14. package/lib/index.js.map +1 -1
  15. package/lib/tsconfig.tsbuildinfo +1 -1
  16. package/lib/utils/FormatString/FormatString.d.ts +1 -0
  17. package/package.json +1 -1
  18. package/src/StyleGuide/ColorPalette/colorPaletteList.ts +15 -0
  19. package/src/assets/Themes/BaseTheme.scss +5 -3
  20. package/src/assets/Themes/DarkTheme.scss +5 -3
  21. package/src/assets/icons/window_maximize.svg +1 -2
  22. package/src/assets/icons/window_restore.svg +4 -0
  23. package/src/components/Charts/BarChart/BarChart.scss +4 -1
  24. package/src/components/Charts/BarChart/BarChart.tsx +23 -9
  25. package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.scss +10 -3
  26. package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.stories.tsx +2 -1
  27. package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.tsx +54 -25
  28. package/src/components/Charts/DashboardDonutChart/types.ts +7 -1
  29. package/src/components/Charts/LineChart/LineChart.scss +13 -9
  30. package/src/components/Charts/LineChart/LineChart.tsx +6 -2
  31. package/src/components/DatePicker/DatePicker.scss +11 -0
  32. package/src/components/DatePicker/DatePicker.stories.tsx +19 -0
  33. package/src/components/DatePicker/DatePicker.tsx +73 -22
  34. package/src/components/Excel/ExcelFile/ExcelFile.scss +0 -2
  35. package/src/components/Excel/ExcelFile/ExcelFile.tsx +4 -4
  36. package/src/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.scss +2 -3
  37. package/src/components/FileDropzone/Dropzone.tsx +76 -28
  38. package/src/components/FileDropzone/FileDropzone.scss +30 -2
  39. package/src/components/FileDropzone/FileDropzone.stories.tsx +125 -4
  40. package/src/components/FileDropzone/FileDropzone.tsx +46 -13
  41. package/src/components/FileDropzone/RadioFilePreview.tsx +76 -0
  42. package/src/components/FileDropzone/types.ts +73 -0
  43. package/src/components/Icon/iconList.ts +2 -0
  44. package/src/components/Input/Input.scss +137 -125
  45. package/src/components/Input/Input.tsx +69 -63
  46. package/src/components/InputWithDropdown/InputWithDropdown.scss +9 -2
  47. package/src/components/InputWithDropdown/types.ts +3 -3
  48. package/src/components/MenuOption/MenuOption.stories.tsx +4 -3
  49. package/src/components/MenuOption/MenuOption.tsx +1 -1
  50. package/src/components/MenuOption/types.ts +4 -2
  51. package/src/components/ModulesChip/ModuleChip.scss +21 -8
  52. package/src/components/ModulesChip/ModuleChip.stories.tsx +2 -2
  53. package/src/components/ModulesChip/ModuleChip.tsx +6 -9
  54. package/src/components/MultiSelect/Dropdown.tsx +12 -5
  55. package/src/components/MultiSelect/MultiSelect.stories.tsx +12 -9
  56. package/src/components/MultiSelect/MultiSelect.tsx +10 -9
  57. package/src/components/PopUpModal/PopUpModal.stories.tsx +1 -1
  58. package/src/components/Search/Search.stories.tsx +28 -9
  59. package/src/components/Search/Search.tsx +32 -29
  60. package/src/components/Search/types.ts +4 -0
  61. package/src/components/Table/Table.scss +6 -5
  62. package/src/components/Table/Types.ts +1 -1
  63. package/src/components/Tabs/Tabs.scss +58 -4
  64. package/src/components/Tabs/Tabs.stories.tsx +31 -12
  65. package/src/components/Tabs/Tabs.tsx +27 -18
  66. package/src/components/Tabs/types.ts +1 -1
  67. package/src/components/TextArea/Textarea.stories.tsx +1 -1
  68. package/src/hooks/useFileDropzone.tsx +2 -1
  69. package/src/index.ts +4 -0
  70. package/src/utils/FormatString/FormatString.stories.tsx +58 -0
  71. package/src/utils/FormatString/FormatString.tsx +41 -0
@@ -35,78 +35,84 @@ const Input = forwardRef<HTMLInputElement, InputProps>(
35
35
  const isValueFilled = !checkEmpty(value);
36
36
 
37
37
  return (
38
- <div
39
- className={classNames('ff-input-container', {
40
- 'ff-input-container--float': isValueFilled,
41
- 'ff-input-container--disabled': !!disabled,
38
+ <fieldset
39
+ className={classNames('ff-input-fieldset', {
40
+ 'ff-input-fieldset--disabled': disabled,
42
41
  })}
43
42
  >
44
- {isLabelRequired && (
45
- <label
46
- htmlFor={name}
47
- className={classNames(
48
- `ff-input-label-container ff-input-label-container--${size}`,
49
- {
50
- 'ff-input-label-container--danger': !!error,
51
- }
52
- )}
53
- >
54
- {required && <span className="required-asterisk">*</span>}
55
- <span
43
+ <div
44
+ className={classNames('ff-input-container', {
45
+ 'ff-input-container--float': isValueFilled,
46
+ 'ff-input-container--disabled': !!disabled,
47
+ })}
48
+ >
49
+ {isLabelRequired && (
50
+ <label
51
+ htmlFor={name}
56
52
  className={classNames(
57
- `ff-input-label ff-input-label--${variant}`,
53
+ `ff-input-label-container ff-input-label-container--${size}`,
58
54
  {
59
- 'ff-input-label--no-hover': !!value,
60
- 'ff-input-label--disabled': !!disabled,
61
- 'ff-input-label--danger': !!error,
55
+ 'ff-input-label-container--danger': !!error,
62
56
  }
63
57
  )}
64
58
  >
65
- {label}
66
- </span>
67
- </label>
68
- )}
69
-
70
- <input
71
- ref={ref} // Forward the ref here
72
- name={name}
73
- value={value}
74
- type={type}
75
- spellCheck={false}
76
- id={name}
77
- className={classNames(
78
- `ff-input ff-input-${variant} default-input ff-input--${size}`,
79
- {
80
- ['ff-input--transparentBackground']: !!transparentBackground,
81
- 'ff-input--no-hover': !!value,
82
- 'ff-input--disabled': !!disabled,
83
- 'ff-input--danger': !!error,
84
- 'ff-input--no-border': !!noBorder,
85
- 'ff-input--placeholder': !isLabelRequired,
86
- },
87
- `${className}`
59
+ {required && <span className="required-asterisk">*</span>}
60
+ <span
61
+ className={classNames(
62
+ `ff-input-label ff-input-label--${variant}`,
63
+ {
64
+ 'ff-input-label--no-hover': !!value,
65
+ 'ff-input-label--disabled': !!disabled,
66
+ 'ff-input-label--danger': !!error,
67
+ }
68
+ )}
69
+ >
70
+ {label}
71
+ </span>
72
+ </label>
88
73
  )}
89
- placeholder={placeholder}
90
- disabled={disabled}
91
- onChange={onChange}
92
- onFocus={onFocus}
93
- onBlur={onBlur}
94
- autoComplete={autoComplete}
95
- min={minValue}
96
- max={maxValue}
97
- {...props}
98
- />
99
74
 
100
- {helperText && error && (
101
- <span
102
- className={classNames('ff-input-message', {
103
- 'ff-input-message--danger': !!error,
104
- })}
105
- >
106
- {helperText}
107
- </span>
108
- )}
109
- </div>
75
+ <input
76
+ ref={ref} // Forward the ref here
77
+ name={name}
78
+ value={value}
79
+ type={type}
80
+ spellCheck={false}
81
+ id={name}
82
+ className={classNames(
83
+ `ff-input ff-input-${variant} default-input ff-input--${size}`,
84
+ {
85
+ ['ff-input--transparentBackground']: !!transparentBackground,
86
+ 'ff-input--no-hover': !!value,
87
+ 'ff-input--disabled': !!disabled,
88
+ 'ff-input--danger': !!error,
89
+ 'ff-input--no-border': !!noBorder,
90
+ 'ff-input--placeholder': !isLabelRequired,
91
+ },
92
+ `${className}`
93
+ )}
94
+ placeholder={placeholder}
95
+ disabled={disabled}
96
+ onChange={onChange}
97
+ onFocus={onFocus}
98
+ onBlur={onBlur}
99
+ autoComplete={autoComplete}
100
+ min={minValue}
101
+ max={maxValue}
102
+ {...props}
103
+ />
104
+
105
+ {helperText && error && (
106
+ <span
107
+ className={classNames('ff-input-message', {
108
+ 'ff-input-message--danger': !!error,
109
+ })}
110
+ >
111
+ {helperText}
112
+ </span>
113
+ )}
114
+ </div>
115
+ </fieldset>
110
116
  );
111
117
  }
112
118
  );
@@ -10,6 +10,8 @@
10
10
  border-radius: 4px;
11
11
  padding: 0;
12
12
  position: relative;
13
+ justify-content: space-between;
14
+
13
15
  .ff-input-with-dropdown--left {
14
16
  display: flex;
15
17
  flex-direction: row-reverse;
@@ -24,6 +26,8 @@
24
26
  }
25
27
 
26
28
  .ff-floating-label-input-container {
29
+ display: flex;
30
+ flex: 1;
27
31
  .ff-floating-label {
28
32
  position: absolute;
29
33
  z-index: 9;
@@ -48,7 +52,7 @@
48
52
  }
49
53
 
50
54
  .ff-floating-input {
51
- position: relative;
55
+ width: 100%;
52
56
  padding: 6px 7px;
53
57
  line-height: 18px;
54
58
  border: none;
@@ -92,7 +96,7 @@
92
96
  }
93
97
 
94
98
  .ff-floating-dropdown {
95
- min-width: 120px;
99
+ width: 100%;
96
100
  border: none;
97
101
  outline: none;
98
102
  margin: 0;
@@ -100,6 +104,9 @@
100
104
  &:disabled {
101
105
  cursor: not-allowed;
102
106
  }
107
+ &:hover {
108
+ background-color: var(--dropdown-bg-color);
109
+ }
103
110
  }
104
111
 
105
112
  .ff-floating-dropdown--left {
@@ -19,9 +19,9 @@ export interface InputWithDropdownProps {
19
19
  /**
20
20
  * value | input field value
21
21
  */
22
- value?: string | number
22
+ value?: string | number;
23
23
 
24
- type?: 'text' | 'password' | 'number' | 'email' | 'url' | 'time'
24
+ type?: 'text' | 'password' | 'number' | 'email' | 'url' | 'time';
25
25
 
26
26
  /**
27
27
  * variants to set color/style of the input field
@@ -109,5 +109,5 @@ export interface InputWithDropdownProps {
109
109
  */
110
110
  optionsRequired?: boolean;
111
111
 
112
- dropdownPosition?: 'left' | 'right'
112
+ dropdownPosition?: 'left' | 'right';
113
113
  }
@@ -1,7 +1,8 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
2
  import MenuOption from './MenuOption';
3
3
  import './MenuOption.scss';
4
- import React from 'react';
4
+ import React, { ReactNode } from 'react';
5
+ import Icon from '../Icon';
5
6
 
6
7
  const meta: Meta<typeof MenuOption> = {
7
8
  title: 'Components/MenuOption',
@@ -48,7 +49,7 @@ const meta: Meta<typeof MenuOption> = {
48
49
  type Story = StoryObj<typeof MenuOption>;
49
50
 
50
51
  const options = [
51
- { label: 'Option 1', value: 'opt1', icon: 'success' },
52
+ { label: <div style={{display:'flex', justifyContent:"center", alignItems:"center",gap:"8px"}}>hello <Icon name='edit'/></div>, value: 'opt1', icon: 'success' },
52
53
  { label: 'Option 2', value: 'opt2', icon: 'success' },
53
54
  {
54
55
  label: 'Delete',
@@ -58,7 +59,7 @@ const options = [
58
59
  },
59
60
  ];
60
61
 
61
- const handleOptionClick = (option: { label: string }) => {
62
+ const handleOptionClick = (option: { label: string|ReactNode }) => {
62
63
  alert(`Option clicked: ${option.label}`);
63
64
  };
64
65
 
@@ -106,7 +106,7 @@ const OptionCard = ({
106
106
  ref={optionCardRef}
107
107
  >
108
108
  {options.map((opt) => (
109
- <Option key={opt.label} option={opt} onClick={onClick} />
109
+ <Option key={opt.value} option={opt} onClick={onClick} />
110
110
  ))}
111
111
  </div>,
112
112
  document.body
@@ -1,10 +1,12 @@
1
+ import { ReactNode } from "react";
2
+
1
3
  interface OptionClick {
2
4
  /**
3
5
  * The label displayed for the option.
4
6
  * @type {string}
5
7
  * @required
6
8
  */
7
- label: string;
9
+ label: string |ReactNode;
8
10
 
9
11
  /**
10
12
  * The value(s) associated with the option, which can be a single string or an array of strings.
@@ -24,7 +26,7 @@ interface OptionType extends OptionClick {
24
26
 
25
27
  iconColor?: string;
26
28
 
27
- name?: string;
29
+ name?: string | ReactNode;
28
30
 
29
31
  /**
30
32
  * Indicates whether the option is disabled.
@@ -2,19 +2,32 @@
2
2
  @use '../../assets/styles/mixins';
3
3
 
4
4
  .ff-Module-chip {
5
- width: 75px;
6
- height: 32px;
7
- border: 0.5px solid;
5
+ width: 68px;
6
+ height: 30px;
7
+ color: var(--table-column-text-color);
8
+ border: 1px solid var(--ff-editor-line-bg);
8
9
  border-radius: 16px;
9
- color: var(--brand-color);
10
10
  cursor: pointer;
11
11
  @include mixins.center-content();
12
- .ff-Module-label-chip {
13
- &--active {
14
- color: var(--ff-header-text-color);
15
- }
12
+ .module-typography {
13
+ color: var(--table-column-text-color);
16
14
  }
17
15
  &--active {
16
+ border: 0.5px solid var(--brand-color);
18
17
  background: var(--brand-color);
18
+ .module-typography {
19
+ color: var(--base-bg-color);
20
+ font-weight: 600;
21
+ }
22
+ }
23
+ &--hover {
24
+ &:hover {
25
+ border: 0.5px solid var(--brand-color);
26
+ background-color: var(--hover-color);
27
+ .module-typography {
28
+ color: var(--table-column-text-color);
29
+ font-weight: 600;
30
+ }
31
+ }
19
32
  }
20
33
  }
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import type { Meta, StoryObj } from '@storybook/react';
2
3
  import ModuleChip from './ModuleChip';
3
4
  import { useState } from 'react';
@@ -6,7 +7,7 @@ const meta: Meta<typeof ModuleChip> = {
6
7
  title: 'Components/ModuleChip',
7
8
  component: ModuleChip,
8
9
  parameters: {
9
- layout: 'center',
10
+ layout: 'centered',
10
11
  },
11
12
  argTypes: {
12
13
  isActive: Boolean,
@@ -18,7 +19,6 @@ type Story = StoryObj<typeof ModuleChip>;
18
19
 
19
20
  const defaultArgs = {
20
21
  label: 'Modules',
21
- isActive: false,
22
22
  };
23
23
 
24
24
  export const Controlled: Story = {
@@ -12,18 +12,15 @@ const ModuleChip: React.FC<ModuleChipProps> = ({
12
12
  <div
13
13
  className={classNames('ff-Module-chip', {
14
14
  'ff-Module-chip--active': isActive,
15
+ 'ff-Module-chip--hover': !isActive,
15
16
  })}
16
17
  onClick={onClick}
17
18
  >
18
- <div
19
- className={classNames(`ff-Module-label-chip `, {
20
- 'ff-Module-label-chip--active': isActive,
21
- })}
22
- >
23
- <Typography fontSize={'14px'} fontWeight="regular" lineHeight="21px">
24
- {label}
25
- </Typography>
26
- </div>
19
+ <Typography
20
+ lineHeight="18px"
21
+ className="module-typography"
22
+ children={label}
23
+ />
27
24
  </div>
28
25
  );
29
26
  };
@@ -9,7 +9,7 @@ import Typography from '../Typography';
9
9
  import Checkbox from '../Checkbox';
10
10
  import Tooltip from '../Tooltip';
11
11
  import { truncateText } from '../../utils/truncateText/truncateText';
12
- import { getLabel } from '../../utils/getSelectOptionValue/getSelectOptionValue';
12
+ import { getLabel, getValue } from '../../utils/getSelectOptionValue/getSelectOptionValue';
13
13
 
14
14
  const Dropdown = forwardRef<HTMLDivElement, DropdownProps>(
15
15
  (
@@ -20,13 +20,14 @@ const Dropdown = forwardRef<HTMLDivElement, DropdownProps>(
20
20
  dropdownPosition = {},
21
21
  zIndex,
22
22
  withSelectButton,
23
- labelAccessor,
23
+ labelAccessor='label',
24
+ valueAccessor='value'
24
25
  },
25
26
  ref
26
27
  ) => {
27
28
  const filteredOptions = options
28
29
  ? options.filter((option) =>
29
- getLabel(option, labelAccessor)
30
+ getValue(option, valueAccessor)
30
31
  ?.toLowerCase()
31
32
  .includes(searchedKeyword.toLowerCase())
32
33
  )
@@ -38,6 +39,12 @@ const Dropdown = forwardRef<HTMLDivElement, DropdownProps>(
38
39
  e.stopPropagation();
39
40
  handleOptionChange({}, false);
40
41
  };
42
+ const renderOption=(info:any, labelAccessor:string)=>{
43
+ if(typeof info[labelAccessor] ==='string'){
44
+ return truncateText(getLabel(info, labelAccessor), 25)
45
+ }
46
+ return info[labelAccessor]
47
+ }
41
48
  const topPosition = useMemo(() => {
42
49
  let calculatedDropdownHeight = Math.min(
43
50
  filteredOptions.length * optionHeight,
@@ -107,14 +114,14 @@ const Dropdown = forwardRef<HTMLDivElement, DropdownProps>(
107
114
  <Tooltip
108
115
  zIndex={zIndex + 1}
109
116
  title={
110
- getLabel(info, labelAccessor).length > 25
117
+ typeof info[labelAccessor]==='string' && getLabel(info, labelAccessor)?.length > 25
111
118
  ? getLabel(info, labelAccessor)
112
119
  : ''
113
120
  }
114
121
  children={
115
122
  <Typography
116
123
  className="dropdown-option-label"
117
- children={truncateText(getLabel(info, labelAccessor), 25)}
124
+ children={renderOption(info,labelAccessor)}
118
125
  />
119
126
  }
120
127
  />
@@ -80,11 +80,7 @@ export const NameAccessor: Story = {
80
80
  },
81
81
  };
82
82
 
83
- export const Default3: Story = {
84
- args: {
85
- ...defaultArgs,
86
- },
87
- };
83
+
88
84
  export const EmailGroup: Story = {
89
85
  render: () => {
90
86
  const [options, setOptions] = useState([
@@ -124,6 +120,7 @@ export const EmailGroup: Story = {
124
120
  acceptNewOption={true}
125
121
  displayCount={true}
126
122
  labelAccessor="label"
123
+ valueAccessor='value'
127
124
  onEnter={onEnter}
128
125
  />
129
126
  );
@@ -234,19 +231,19 @@ export const Machines: Story = {
234
231
  render: () => {
235
232
  const [options] = useState<Option[]>([
236
233
  {
237
- label: 'Machine 1',
234
+ label: <h2>Machine 1</h2>,
238
235
  value: 'machine 1',
239
236
  },
240
237
  {
241
- label: 'Machine 2',
238
+ label: <h2>Machine 2</h2>,
242
239
  value: 'machine 2',
243
240
  },
244
241
  {
245
- label: 'Machine 3',
242
+ label: <h2>Machine 3</h2>,
246
243
  value: 'machine 3',
247
244
  },
248
245
  {
249
- label: 'Machine 4',
246
+ label: <h2>Machine 4</h2>,
250
247
  value: 'machine 4',
251
248
  },
252
249
  ]);
@@ -265,6 +262,8 @@ export const Machines: Story = {
265
262
  key={index}
266
263
  label="Machines"
267
264
  variant="machines"
265
+ // labelAccessor='label'
266
+ // valueAccessor='value'
268
267
  options={options}
269
268
  onSelectButtonClick={handleSelectChange}
270
269
  highlightedMachine={machine.label}
@@ -273,6 +272,8 @@ export const Machines: Story = {
273
272
  ))}
274
273
  <MultiSelect
275
274
  label="Machines"
275
+ labelAccessor='label'
276
+ valueAccessor='value'
276
277
  withSelectButton
277
278
  options={options}
278
279
  onSelectButtonClick={handleSelectChange}
@@ -284,4 +285,6 @@ export const Machines: Story = {
284
285
  },
285
286
  };
286
287
 
288
+
289
+
287
290
  export default meta;
@@ -38,7 +38,8 @@ const ChipElement = ({
38
38
  zIndex={zIndex + 1}
39
39
  >
40
40
  <Typography fontSize={10} lineHeight={'14px'} className="stye">
41
- {truncateText(label, 25)}
41
+
42
+ {typeof label==='string'? truncateText(label, 25):label}
42
43
  </Typography>
43
44
  </Tooltip>
44
45
  </span>
@@ -73,9 +74,9 @@ const MultiSelect = ({
73
74
  onManageLabelsClick = () => { },
74
75
  className = '',
75
76
  highlightedMachine = '',
76
- onSelectButtonClick = () => { },
77
- labelAccessor = '',
78
- valueAccessor = labelAccessor,
77
+ onSelectButtonClick = () => {},
78
+ labelAccessor = 'label',
79
+ valueAccessor = 'value',
79
80
  withSelectButton = variant === 'machines' ? true : false,
80
81
  onEnter = () => { },
81
82
  }: MultiSelectProps) => {
@@ -203,7 +204,7 @@ const MultiSelect = ({
203
204
  if (input.length > 2) {
204
205
  const matchedOption = allOptions.find(
205
206
  (option) =>
206
- getLabel(option, labelAccessor)?.toLowerCase() === input.toLowerCase()
207
+ getLabel(option, valueAccessor)?.toLowerCase() === input.toLowerCase()
207
208
  );
208
209
  setDisplayIcon(!matchedOption);
209
210
  } else {
@@ -256,10 +257,10 @@ const MultiSelect = ({
256
257
  };
257
258
  }, [isOpen]);
258
259
  useEffect(() => {
259
- if (!checkEmpty(options?.length)) {
260
- let initializeOptions = options;
261
- if (!checkEmpty(selectedOptions?.length)) {
262
- initializeOptions = options.map((option) => ({
260
+ if (!checkEmpty(options)) {
261
+ let initializeOptions=options;
262
+ if(!checkEmpty(selectedOptions)){
263
+ initializeOptions = options.map((option) => ({
263
264
  ...option,
264
265
  isChecked: selectedOptions.some(
265
266
  (selectedOption) =>
@@ -24,7 +24,7 @@ const defaultArgs = {
24
24
  secondButtonLabel: "Continue",
25
25
  buttonVariant: "warning",
26
26
  border: '1px solid var(--warning-modal-border-color)',
27
- colorForTitleMessage: 'var(--select-license-header-text-color)'
27
+ colorForTitleMessage: 'var(--status-button-bg-warning)'
28
28
  }
29
29
 
30
30
  export const DefaultModal: Story = {
@@ -1,6 +1,6 @@
1
-
2
1
  import type { Meta, StoryObj } from '@storybook/react';
3
2
  import Search from './Search';
3
+ import React,{ useState } from 'react';
4
4
  const meta: Meta<typeof Search> = {
5
5
  title: 'Components/Search',
6
6
  component: Search,
@@ -11,15 +11,34 @@ const meta: Meta<typeof Search> = {
11
11
  };
12
12
 
13
13
  type Story = StoryObj<typeof Search>;
14
- const defaultArgs = {
15
- placeholder: 'Search',
16
- onSearch: (query: string) => alert(`Searching for: ${query}`),
17
- disabled: false,
18
- width: 200,
19
- };
20
14
  export const Default: Story = {
21
- args: {
22
- ...defaultArgs,
15
+ render: () => {
16
+ const [isExpand, setIsExpand] = useState(false);
17
+ const [searchValue, setSearchValue] = useState('');
18
+
19
+ const handleSearch = (value: string) => {
20
+ alert(`Searching for: ${value}`);
21
+ setSearchValue(value);
22
+ };
23
+
24
+ const handleClose = () => {
25
+ setIsExpand(false);
26
+ setSearchValue('');
27
+ };
28
+ return (
29
+ <div>
30
+ <Search
31
+ placeholder="Search here..."
32
+ isExpand={isExpand}
33
+ value={searchValue}
34
+ onSearch={handleSearch}
35
+ onExpand={(expand) => setIsExpand(expand)}
36
+ onClose={handleClose}
37
+ disabled={false}
38
+ width={200}
39
+ />
40
+ </div>
41
+ );
23
42
  },
24
43
  };
25
44