pixel-priya 0.0.1 → 0.0.2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pixel-priya",
3
3
  "description": "Great for pixel-perfect, design-focused components in React",
4
- "version": "0.0.1",
4
+ "version": "0.0.2",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.esm.js",
7
7
  "types": "lib/index.d.ts",
@@ -436,5 +436,49 @@ export const SelectWithToolTip: Story = {
436
436
  );
437
437
  },
438
438
  };
439
+ export const ApiSearchSelect: Story = {
440
+ render: () => {
441
+ const optionsList = [
442
+ {
443
+ label: 'fire-flink-LIC4900-onPrem',
444
+ value: 'fire-flink-LIC4900-onPrem',
445
+ },
446
+ {
447
+ label: 'fire-flink-LIC3179',
448
+ value: 'fire-flink-LIC3179',
449
+ },
450
+ {
451
+ label: 'fire-flink-LIC4937',
452
+ value: 'fire-flink-LIC4937',
453
+ },
454
+ {
455
+ label: 'fire-flink-LIC4999',
456
+ value: 'fire-flink-LIC4999',
457
+ },
458
+ ];
459
+
460
+ const [selectedOption, setSelectedOption] = useState<Option>({
461
+ label: 'demo',
462
+ value: 'demo',
463
+ });
464
+ const handleChange = (option: Option) => {
465
+ setSelectedOption(option);
466
+ };
467
+ const search = (option: string) => {
468
+ console.log('option',option);
469
+ };
470
+
471
+ return (
472
+ <Select
473
+ label="Option"
474
+ optionsList={optionsList}
475
+ selectedOption={selectedOption}
476
+ onChange={handleChange}
477
+ apiSearch={true}
478
+ onApiSearch={search}
479
+ />
480
+ );
481
+ },
482
+ };
439
483
 
440
484
  export default meta;
@@ -34,7 +34,7 @@ const Select: FC<SelectProps> = ({
34
34
  placeHolder = '',
35
35
  showToolTip = false,
36
36
  apiSearch = false,
37
- onapiSearch =() => {},
37
+ onApiSearch =() => {},
38
38
  }) => {
39
39
  const selectWidth = typeof width === 'number' ? `${width}px` : width;
40
40
 
@@ -72,10 +72,10 @@ const Select: FC<SelectProps> = ({
72
72
  };
73
73
 
74
74
  const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
75
- const { value } = event.target as HTMLInputElement;;
76
- if (event.key === 'Enter' && !checkEmpty(value)) {
77
- onapiSearch(value.trim());
78
- }
75
+ const { value } = event.target as HTMLInputElement;
76
+ if (event.key === 'Enter' && !checkEmpty(value) && apiSearch) {
77
+ onApiSearch(value.trim());
78
+ }
79
79
  };
80
80
  const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
81
81
  const { value } = event.target;
@@ -90,11 +90,11 @@ const Select: FC<SelectProps> = ({
90
90
  });
91
91
 
92
92
  setSelectOptionList(filteredOptions);
93
- setSearchedOption({
94
- ...searchedOption,
95
- searchedText: value,
96
- });
97
93
  }
94
+ setSearchedOption({
95
+ ...searchedOption,
96
+ searchedText: value,
97
+ });
98
98
  };
99
99
 
100
100
  const onSelectUpdatePosition = () => {
@@ -121,11 +121,11 @@ export interface SelectProps {
121
121
  /**
122
122
  * Callback function to be called when the search button is clicked or enter key is pressed
123
123
  */
124
- onapiSearch?: (query: string) => void;
124
+ onApiSearch?: (query: string) => void;
125
125
  /**
126
126
  * Provide the boolean value if apiSearch is required or not
127
127
  */
128
- apiSearch?: boolean
128
+ apiSearch?: boolean
129
129
  }
130
130
 
131
131
  export interface DropdownPosition {