pixel-react 1.4.1 → 1.4.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.
@@ -58,9 +58,9 @@ const Modal: React.FC<ModalProps> = ({
58
58
  <div
59
59
  style={{
60
60
  boxShadow: boxShadow,
61
- borderRadius: isHeaderDisplayed || isFooterDisplayed ? '12px' : '0px', // Apply based on conditions
61
+ borderRadius: '12px' ,
62
62
  }}
63
- className="ff-modal-container" // New container class for consistency
63
+ className="ff-modal-container"
64
64
  >
65
65
  <div
66
66
  className={classNames(
@@ -29,6 +29,7 @@ const Select: FC<SelectProps> = ({
29
29
  height = 32,
30
30
  width = '100%',
31
31
  onBlur = () => {},
32
+ disableInput = false
32
33
  }) => {
33
34
  const selectWidth = typeof width === 'number' ? `${width}px` : width;
34
35
 
@@ -176,6 +177,7 @@ const Select: FC<SelectProps> = ({
176
177
  style={{ zIndex: optionZIndex, color: selectedOptionColor }}
177
178
  disabled={disabled}
178
179
  onChange={handleChange}
180
+ readOnly={disableInput}
179
181
  />
180
182
  {optionsRequired && (
181
183
  <div
@@ -93,6 +93,11 @@ export interface SelectProps {
93
93
  * Provide the onBlur functionality for the select
94
94
  */
95
95
  onBlur?: () => void;
96
+
97
+ /*
98
+ * Disable the select component input
99
+ */
100
+ disableInput?: boolean;
96
101
  }
97
102
 
98
103
  export interface DrowdownPosition {
@@ -129,7 +129,9 @@ const StateDropdown = ({
129
129
  optionsList={options}
130
130
  selectedOption={selectedOption}
131
131
  showLabel={false}
132
- showBorder={true}
132
+ showBorder={false}
133
+ disableInput={true}
134
+ height={24}
133
135
  />
134
136
  ) : (
135
137
  <Select
@@ -139,7 +141,9 @@ const StateDropdown = ({
139
141
  optionsList={options}
140
142
  selectedOption={selectedOption}
141
143
  showLabel={false}
142
- showBorder={true}
144
+ showBorder={false}
145
+ disableInput={true}
146
+ height={24}
143
147
  />
144
148
  );
145
149
  } else if (
@@ -154,7 +158,9 @@ const StateDropdown = ({
154
158
  optionsList={options}
155
159
  selectedOption={selectedOption}
156
160
  showLabel={false}
157
- showBorder={true}
161
+ showBorder={false}
162
+ disableInput={true}
163
+ height={24}
158
164
  />
159
165
  );
160
166
  } else if (currentState === 'APPROVED') {
@@ -166,7 +172,9 @@ const StateDropdown = ({
166
172
  optionsList={options}
167
173
  selectedOption={selectedOption}
168
174
  showLabel={false}
169
- showBorder={true}
175
+ showBorder={false}
176
+ disableInput={true}
177
+ height={24}
170
178
  />
171
179
  );
172
180
  } else if (currentState === 'REJECTED' && userHasOnlyViewAccess) {
@@ -178,7 +186,9 @@ const StateDropdown = ({
178
186
  optionsList={options}
179
187
  selectedOption={selectedOption}
180
188
  showLabel={false}
181
- showBorder={true}
189
+ showBorder={false}
190
+ disableInput={true}
191
+ height={24}
182
192
  />
183
193
  );
184
194
  } else if (currentState === 'NEW' && userHasOnlyViewAccess) {
@@ -190,7 +200,9 @@ const StateDropdown = ({
190
200
  optionsList={options}
191
201
  selectedOption={selectedOption}
192
202
  showLabel={false}
193
- showBorder={true}
203
+ showBorder={false}
204
+ disableInput={true}
205
+ height={24}
194
206
  />
195
207
  );
196
208
  } else {
package/src/index.ts CHANGED
@@ -80,6 +80,7 @@ import MultiRadialChart from './components/Charts/MultiRadialChart';
80
80
  import Editor from './components/Editor/Editor';
81
81
  import { getSequentialPayload } from './utils/getSequentialPayload/getSequentialPayload';
82
82
  import ConnectingBranch from './components/ConnectingBranch/ConnectingBranch';
83
+ import { saveFileFromBlob } from './utils/downloadFile/saveFileFromBlob'
83
84
 
84
85
  export {
85
86
  Button,
@@ -163,4 +164,5 @@ export {
163
164
  getEncryptedData,
164
165
  truncateText,
165
166
  getSequentialPayload,
167
+ saveFileFromBlob,
166
168
  };
@@ -0,0 +1,62 @@
1
+ import { saveFileFromBlob } from './saveFileFromBlob';
2
+ import { Toastify, toast } from '../../components/Toastify/Toastify';
3
+
4
+ export default {
5
+ title: 'Utils/saveFileFromBlob',
6
+ component: saveFileFromBlob,
7
+ };
8
+
9
+ export const Default = () => {
10
+ const testCases = [
11
+ {
12
+ blob: new Blob(['Hello, world!'], { type: 'text/plain' }),
13
+ filename: 'hello.txt',
14
+ },
15
+ {
16
+ blob: new Blob(['{ "key": "value" }'], { type: 'application/json' }),
17
+ filename: 'data.json',
18
+ },
19
+ {
20
+ blob: null,
21
+ filename: 'invalid.txt',
22
+ expectedError: 'Invalid Blob object',
23
+ },
24
+ ];
25
+
26
+ const handleDownload = (blob: Blob | null, filename: string) => {
27
+ try {
28
+ if (blob instanceof Blob) {
29
+ saveFileFromBlob(blob, filename);
30
+ toast.success(`File "${filename}" downloaded successfully!`);
31
+ } else {
32
+ throw new Error('Invalid Blob object');
33
+ }
34
+ } catch (error: any) {
35
+ toast.error(error.message);
36
+ }
37
+ };
38
+
39
+ return (
40
+ <>
41
+ <div>
42
+ <h1>saveFileFromBlob - Test Cases</h1>
43
+ {testCases.map(({ blob, filename, expectedError }, index) => (
44
+ <div key={index} style={{ marginBottom: '1rem' }}>
45
+ <button
46
+ onClick={() => handleDownload(blob as Blob, filename)}
47
+ style={{ marginRight: '1rem' }}
48
+ >
49
+ Download {filename}
50
+ </button>
51
+ {expectedError && (
52
+ <span style={{ color: 'red' }}>
53
+ Expected Error: {expectedError}
54
+ </span>
55
+ )}
56
+ </div>
57
+ ))}
58
+ </div>
59
+ <Toastify />
60
+ </>
61
+ );
62
+ };
@@ -0,0 +1,40 @@
1
+ // saveFileFromBlob.ts
2
+
3
+ /**
4
+ * Save a file from a Blob object.
5
+ * This utility handles downloading files in browsers, including IE support.
6
+ *
7
+ * @param blob - The Blob object representing the file.
8
+ * @param filename - The name of the file to save.
9
+ */
10
+ interface NavigatorWithMsSaveBlob extends Navigator {
11
+ msSaveOrOpenBlob?: (_blob: Blob, _filename: string) => void;
12
+ }
13
+
14
+ export const saveFileFromBlob = (blob: Blob, filename: string): void => {
15
+ if (!blob || !(blob instanceof Blob)) {
16
+ console.error('Invalid Blob object');
17
+ throw new Error('Invalid Blob object');
18
+ }
19
+
20
+ const navigatorWithMsSaveBlob = window.navigator as NavigatorWithMsSaveBlob;
21
+
22
+ if (navigatorWithMsSaveBlob.msSaveOrOpenBlob) {
23
+ const saveBlob = navigatorWithMsSaveBlob.msSaveOrOpenBlob;
24
+ if (saveBlob) {
25
+ saveBlob(blob, filename);
26
+ }
27
+ } else {
28
+ // For modern browsers
29
+ const anchorElement = document.createElement('a');
30
+ document.body.appendChild(anchorElement);
31
+ const objectURL = window.URL.createObjectURL(blob);
32
+ anchorElement.href = objectURL;
33
+ anchorElement.download = filename;
34
+ anchorElement.click();
35
+ setTimeout(() => {
36
+ window.URL.revokeObjectURL(objectURL);
37
+ document.body.removeChild(anchorElement);
38
+ }, 0);
39
+ }
40
+ };