pixel-react 1.1.6 → 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. package/lib/components/AddButton/AddButton.d.ts +5 -0
  2. package/lib/components/AddButton/AddButton.stories.d.ts +6 -0
  3. package/lib/components/AddButton/index.d.ts +1 -0
  4. package/lib/components/AddButton/types.d.ts +4 -0
  5. package/lib/components/IconButton/IconButton.stories.d.ts +1 -0
  6. package/lib/components/Input/Input.d.ts +1 -1
  7. package/lib/components/Input/types.d.ts +4 -0
  8. package/lib/components/MiniModal/MiniModal.stories.d.ts +1 -1
  9. package/lib/components/MiniModal/types.d.ts +12 -0
  10. package/lib/index.d.ts +5 -1
  11. package/lib/index.esm.js +489 -96
  12. package/lib/index.esm.js.map +1 -1
  13. package/lib/index.js +489 -96
  14. package/lib/index.js.map +1 -1
  15. package/lib/utils/find/findAndInsert.d.ts +7 -0
  16. package/lib/utils/find/findAndInsert.stories.d.ts +7 -0
  17. package/package.json +1 -1
  18. package/src/assets/Themes/BaseTheme.scss +8 -1
  19. package/src/assets/Themes/DarkTheme.scss +7 -0
  20. package/src/assets/icons/app_switch.svg +11 -0
  21. package/src/assets/icons/backward_icon.svg +3 -0
  22. package/src/assets/icons/cloud_server_host_icon.svg +3 -0
  23. package/src/assets/icons/continue_without_sign.svg +3 -0
  24. package/src/assets/icons/forward_icon.svg +3 -0
  25. package/src/assets/icons/hamburger_menu.svg +3 -0
  26. package/src/assets/icons/plus_user_icon.svg +3 -0
  27. package/src/assets/icons/reload.svg +3 -0
  28. package/src/assets/icons/toast_close.svg +2 -2
  29. package/src/assets/icons/user_profile.svg +3 -0
  30. package/src/assets/icons/window_maximize.svg +4 -0
  31. package/src/assets/icons/window_minimize.svg +3 -0
  32. package/src/components/AppHeader/AppHeader.scss +2 -1
  33. package/src/components/Chip/Chip.scss +14 -13
  34. package/src/components/Icon/Icon.stories.tsx +1 -1
  35. package/src/components/Icon/Icons.scss +1 -1
  36. package/src/components/Icon/iconList.ts +23 -0
  37. package/src/components/IconButton/IconButton.scss +23 -12
  38. package/src/components/IconButton/IconButton.stories.tsx +9 -1
  39. package/src/components/IconButton/IconButton.tsx +5 -3
  40. package/src/components/Input/Input.scss +6 -1
  41. package/src/components/Input/Input.tsx +8 -4
  42. package/src/components/Input/types.ts +4 -0
  43. package/src/components/MiniModal/MiniModal.scss +39 -8
  44. package/src/components/MiniModal/MiniModal.stories.tsx +199 -75
  45. package/src/components/MiniModal/MiniModal.tsx +46 -2
  46. package/src/components/MiniModal/types.ts +13 -0
@@ -27,6 +27,9 @@ const useModal = () => {
27
27
  const BasicModalComponent = () => {
28
28
  const btnRef1 = useRef<HTMLButtonElement>(null);
29
29
  const btnRef2 = useRef<HTMLButtonElement>(null);
30
+ const btnRef3 = useRef<HTMLButtonElement>(null);
31
+ const btnRef4 = useRef<HTMLButtonElement>(null);
32
+ const btnRef5 = useRef<HTMLButtonElement>(null);
30
33
  const { currentModal, openModal, closeModal } = useModal();
31
34
 
32
35
  const handleCancel = () => {
@@ -45,6 +48,7 @@ const BasicModalComponent = () => {
45
48
  {currentModal === 1 && (
46
49
  <MiniModal
47
50
  anchorRef={btnRef1}
51
+ modalProperties={{ width: 300, height: 180 }}
48
52
  headerProps={
49
53
  <>
50
54
  <Typography as="p">Modal 1</Typography>
@@ -68,7 +72,9 @@ const BasicModalComponent = () => {
68
72
  onClick: () => {},
69
73
  }}
70
74
  isWrapped={false}
75
+ isPopOver={false}
71
76
  isAnimated={true}
77
+ modalPosition="left"
72
78
  />
73
79
  )}
74
80
 
@@ -82,17 +88,16 @@ const BasicModalComponent = () => {
82
88
  {currentModal === 2 && (
83
89
  <MiniModal
84
90
  anchorRef={btnRef2}
91
+ modalProperties={{ width: 300, height: 180 }}
85
92
  headerProps={
86
93
  <>
87
- <Typography as="p" fontSize={12} fontWeight="regular">
88
- Modal 2
89
- </Typography>
94
+ <Typography as="p">Modal 2</Typography>
90
95
  <hr />
91
96
  </>
92
97
  }
93
98
  childContent={
94
99
  <>
95
- <Typography as="p" fontSize={12} fontWeight="regular">
100
+ <Typography as="p">
96
101
  This is some content inside the second modal.
97
102
  </Typography>
98
103
  </>
@@ -107,47 +112,31 @@ const BasicModalComponent = () => {
107
112
  }}
108
113
  isWrapped={false}
109
114
  isAnimated={false}
115
+ isPopOver={false}
116
+ modalPosition="top"
110
117
  />
111
118
  )}
112
- </div>
113
- );
114
- };
115
- export const BasicModal: Story = {
116
- render: () => <BasicModalComponent />,
117
- };
118
- export const CustomModalWithWrapper = () => {
119
- const btnRef1 = useRef<HTMLButtonElement>(null);
120
- const btnRef2 = useRef<HTMLButtonElement>(null);
121
- const btnRef3 = useRef<HTMLButtonElement>(null);
122
- const { currentModal, openModal, closeModal } = useModal();
123
-
124
- const handleCancel = () => {
125
- closeModal();
126
- };
127
-
128
- return (
129
- <div className="ff-mini-modal-buttons-flex ff-mini-modal-gap-10">
130
119
  <Button
131
- onClick={() => openModal(1)}
132
- ref={btnRef1}
133
- label="1"
134
- variant={currentModal === 1 ? 'primary' : 'secondary'}
120
+ onClick={() => openModal(3)}
121
+ ref={btnRef3}
122
+ label="3"
123
+ variant={currentModal === 3 ? 'primary' : 'secondary'}
135
124
  />
136
125
 
137
- {currentModal === 1 && (
126
+ {currentModal === 3 && (
138
127
  <MiniModal
139
- anchorRef={btnRef1}
140
- modalProperties={{ width: 487, height: 180 }}
128
+ anchorRef={btnRef3}
129
+ modalProperties={{ width: 300, height: 180 }}
141
130
  headerProps={
142
131
  <>
143
- <Typography as="p">Update Label For Scripts</Typography>
132
+ <Typography as="p">Modal 3</Typography>
144
133
  <hr />
145
134
  </>
146
135
  }
147
136
  childContent={
148
137
  <>
149
138
  <Typography as="p">
150
- This is some content inside the first modal.
139
+ This is some content inside the second modal.
151
140
  </Typography>
152
141
  </>
153
142
  }
@@ -156,76 +145,74 @@ export const CustomModalWithWrapper = () => {
156
145
  onClick: handleCancel,
157
146
  }}
158
147
  proceedButtonProps={{
159
- text: 'Update',
148
+ text: 'Proceed',
160
149
  onClick: () => {},
161
150
  }}
162
- isWrapped={true}
163
- isAnimated={true}
164
- firstAnchorRef={btnRef1}
165
- anchorRefLeftNum={164}
166
- anchorLeftDistanceForWrapper={170}
167
- extraTopSpace={{ normalModal: 5 }}
151
+ isWrapped={false}
152
+ isAnimated={false}
153
+ isPopOver={false}
154
+ modalPosition="top"
168
155
  />
169
156
  )}
170
-
171
157
  <Button
172
- onClick={() => openModal(2)}
173
- ref={btnRef2}
174
- label="2"
175
- variant={currentModal === 2 ? 'primary' : 'secondary'}
158
+ onClick={() => openModal(4)}
159
+ ref={btnRef4}
160
+ label="4"
161
+ variant={currentModal === 4 ? 'primary' : 'secondary'}
176
162
  />
177
163
 
178
- {currentModal === 2 && (
164
+ {currentModal === 4 && (
179
165
  <MiniModal
180
- anchorRef={btnRef2}
181
- modalProperties={{ width: 358, height: 135 }}
166
+ anchorRef={btnRef4}
167
+ modalProperties={{ width: 300, height: 180 }}
182
168
  headerProps={
183
169
  <>
184
- <Typography as="p">Export Selected scripts</Typography>
170
+ <Typography as="p">Modal 4</Typography>
185
171
  <hr />
186
172
  </>
187
173
  }
188
174
  childContent={
189
- <Typography as="p">Child content modify here</Typography>
175
+ <>
176
+ <Typography as="p">
177
+ This is some content inside the second modal.
178
+ </Typography>
179
+ </>
190
180
  }
191
181
  cancelButtonProps={{
192
182
  text: 'Cancel',
193
183
  onClick: handleCancel,
194
184
  }}
195
185
  proceedButtonProps={{
196
- text: 'Export',
186
+ text: 'Proceed',
197
187
  onClick: () => {},
198
188
  }}
199
- isWrapped={true}
189
+ isWrapped={false}
200
190
  isAnimated={false}
201
- firstAnchorRef={btnRef1}
202
- anchorRefLeftNum={193}
203
- anchorLeftDistanceForWrapper={170}
204
- extraTopSpace={{ normalModal: 5 }}
191
+ isPopOver={false}
192
+ modalPosition="bottom"
205
193
  />
206
194
  )}
207
-
208
195
  <Button
209
- onClick={() => openModal(3)}
210
- ref={btnRef3}
211
- label="3"
212
- variant={currentModal === 3 ? 'primary' : 'secondary'}
196
+ onClick={() => openModal(5)}
197
+ ref={btnRef5}
198
+ label="5"
199
+ variant={currentModal === 5 ? 'primary' : 'secondary'}
213
200
  />
214
201
 
215
- {currentModal === 3 && (
202
+ {currentModal === 5 && (
216
203
  <MiniModal
217
- anchorRef={btnRef3}
218
- modalProperties={{ width: 487, height: 210 }}
204
+ anchorRef={btnRef5}
205
+ modalProperties={{ width: 300, height: 180 }}
219
206
  headerProps={
220
207
  <>
221
- <Typography as="p">Delete Selected Scripts</Typography>
208
+ <Typography as="p">Modal 5</Typography>
222
209
  <hr />
223
210
  </>
224
211
  }
225
212
  childContent={
226
213
  <>
227
214
  <Typography as="p">
228
- This is some content inside the third modal.
215
+ This is some content inside the second modal.
229
216
  </Typography>
230
217
  </>
231
218
  }
@@ -234,20 +221,22 @@ export const CustomModalWithWrapper = () => {
234
221
  onClick: handleCancel,
235
222
  }}
236
223
  proceedButtonProps={{
237
- text: 'Delete',
224
+ text: 'Proceed',
238
225
  onClick: () => {},
239
226
  }}
240
- isWrapped={true}
241
- isAnimated={true}
242
- firstAnchorRef={btnRef1}
243
- anchorRefLeftNum={225}
244
- anchorLeftDistanceForWrapper={170}
245
- extraTopSpace={{ normalModal: 5 }}
227
+ isWrapped={false}
228
+ isAnimated={false}
229
+ isPopOver={false}
230
+ modalPosition="right"
246
231
  />
247
232
  )}
248
233
  </div>
249
234
  );
250
235
  };
236
+ export const BasicModal: Story = {
237
+ render: () => <BasicModalComponent />,
238
+ };
239
+
251
240
  export const CustomModalWithArrow = () => {
252
241
  const btnRef1 = useRef<HTMLButtonElement>(null);
253
242
  const btnRef2 = useRef<HTMLButtonElement>(null);
@@ -272,7 +261,7 @@ export const CustomModalWithArrow = () => {
272
261
  {currentModal === 1 && (
273
262
  <MiniModal
274
263
  anchorRef={btnRef1}
275
- modalProperties={{ width: 400, height: 350 }}
264
+ modalProperties={{ width: 300, height: 250 }}
276
265
  headerProps={
277
266
  <>
278
267
  <Typography as="p">Modal 1</Typography>
@@ -315,7 +304,7 @@ export const CustomModalWithArrow = () => {
315
304
 
316
305
  {currentModal === 2 && (
317
306
  <MiniModal
318
- modalProperties={{ width: 400, height: 350 }}
307
+ modalProperties={{ width: 300, height: 350 }}
319
308
  anchorRef={btnRef2}
320
309
  headerProps={
321
310
  <>
@@ -343,6 +332,7 @@ export const CustomModalWithArrow = () => {
343
332
  isAnimated={false}
344
333
  isPopOver={true}
345
334
  modalPosition="right"
335
+ leftTopArrow={false}
346
336
  extraRightSpace={{ middleLeftArrow: 4 }}
347
337
  extraLeftSpace={{ rightAlignModal: 40 }}
348
338
  />
@@ -357,6 +347,7 @@ export const CustomModalWithArrow = () => {
357
347
  {currentModal === 3 && (
358
348
  <MiniModal
359
349
  anchorRef={btnRef3}
350
+ modalProperties={{ width: 300, height: 250 }}
360
351
  headerProps={
361
352
  <>
362
353
  <Typography as="p">Modal 3</Typography>
@@ -396,7 +387,7 @@ export const CustomModalWithArrow = () => {
396
387
  {currentModal === 4 && (
397
388
  <MiniModal
398
389
  anchorRef={btnRef4}
399
- modalProperties={{ height: 148 }}
390
+ modalProperties={{ width: 300, height: 200 }}
400
391
  headerProps={
401
392
  <>
402
393
  <Typography as="p">Modal 4</Typography>
@@ -437,7 +428,7 @@ export const CustomModalWithArrow = () => {
437
428
  {currentModal === 5 && (
438
429
  <MiniModal
439
430
  anchorRef={btnRef5}
440
- modalProperties={{ height: 148, width: 404 }}
431
+ modalProperties={{ height: 148, width: 304 }}
441
432
  headerProps={
442
433
  <>
443
434
  <Typography as="p">Modal 5</Typography>
@@ -471,5 +462,138 @@ export const CustomModalWithArrow = () => {
471
462
  </div>
472
463
  );
473
464
  };
465
+ export const CustomModalWithWrapper = () => {
466
+ const btnRef1 = useRef<HTMLButtonElement>(null);
467
+ const btnRef2 = useRef<HTMLButtonElement>(null);
468
+ const btnRef3 = useRef<HTMLButtonElement>(null);
469
+ const { currentModal, openModal, closeModal } = useModal();
470
+
471
+ const handleCancel = () => {
472
+ closeModal();
473
+ };
474
+
475
+ return (
476
+ <div className="ff-mini-modal-buttons-flex ff-mini-modal-gap-10">
477
+ <Button
478
+ onClick={() => openModal(1)}
479
+ ref={btnRef1}
480
+ label="1"
481
+ variant={currentModal === 1 ? 'primary' : 'secondary'}
482
+ />
483
+
484
+ {currentModal === 1 && (
485
+ <MiniModal
486
+ anchorRef={btnRef1}
487
+ modalProperties={{ width: 487, height: 180 }}
488
+ headerProps={
489
+ <>
490
+ <Typography as="p">Update Label For Scripts</Typography>
491
+ <hr />
492
+ </>
493
+ }
494
+ childContent={
495
+ <>
496
+ <Typography as="p">
497
+ This is some content inside the first modal.
498
+ </Typography>
499
+ </>
500
+ }
501
+ cancelButtonProps={{
502
+ text: 'Cancel',
503
+ onClick: handleCancel,
504
+ }}
505
+ proceedButtonProps={{
506
+ text: 'Update',
507
+ onClick: () => {},
508
+ }}
509
+ isWrapped={true}
510
+ isAnimated={true}
511
+ firstAnchorRef={btnRef1}
512
+ anchorRefLeftNum={164}
513
+ anchorLeftDistanceForWrapper={170}
514
+ extraTopSpace={{ normalModal: 5 }}
515
+ />
516
+ )}
517
+
518
+ <Button
519
+ onClick={() => openModal(2)}
520
+ ref={btnRef2}
521
+ label="2"
522
+ variant={currentModal === 2 ? 'primary' : 'secondary'}
523
+ />
524
+
525
+ {currentModal === 2 && (
526
+ <MiniModal
527
+ anchorRef={btnRef2}
528
+ modalProperties={{ width: 358, height: 135 }}
529
+ headerProps={
530
+ <>
531
+ <Typography as="p">Export Selected scripts</Typography>
532
+ <hr />
533
+ </>
534
+ }
535
+ childContent={
536
+ <Typography as="p">Child content modify here</Typography>
537
+ }
538
+ cancelButtonProps={{
539
+ text: 'Cancel',
540
+ onClick: handleCancel,
541
+ }}
542
+ proceedButtonProps={{
543
+ text: 'Export',
544
+ onClick: () => {},
545
+ }}
546
+ isWrapped={true}
547
+ isAnimated={false}
548
+ firstAnchorRef={btnRef1}
549
+ anchorRefLeftNum={193}
550
+ anchorLeftDistanceForWrapper={170}
551
+ extraTopSpace={{ normalModal: 5 }}
552
+ />
553
+ )}
554
+
555
+ <Button
556
+ onClick={() => openModal(3)}
557
+ ref={btnRef3}
558
+ label="3"
559
+ variant={currentModal === 3 ? 'primary' : 'secondary'}
560
+ />
561
+
562
+ {currentModal === 3 && (
563
+ <MiniModal
564
+ anchorRef={btnRef3}
565
+ modalProperties={{ width: 487, height: 210 }}
566
+ headerProps={
567
+ <>
568
+ <Typography as="p">Delete Selected Scripts</Typography>
569
+ <hr />
570
+ </>
571
+ }
572
+ childContent={
573
+ <>
574
+ <Typography as="p">
575
+ This is some content inside the third modal.
576
+ </Typography>
577
+ </>
578
+ }
579
+ cancelButtonProps={{
580
+ text: 'Cancel',
581
+ onClick: handleCancel,
582
+ }}
583
+ proceedButtonProps={{
584
+ text: 'Delete',
585
+ onClick: () => {},
586
+ }}
587
+ isWrapped={true}
588
+ isAnimated={true}
589
+ firstAnchorRef={btnRef1}
590
+ anchorRefLeftNum={225}
591
+ anchorLeftDistanceForWrapper={170}
592
+ extraTopSpace={{ normalModal: 5 }}
593
+ />
594
+ )}
595
+ </div>
596
+ );
597
+ };
474
598
 
475
599
  export default meta;
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useRef, useState, useCallback, forwardRef } from 'react';
2
2
  import { createPortal } from 'react-dom';
3
- import { MiniEditModalProps } from './types.js';
3
+ import { MiniEditModalProps, Rect, AvailableSpace } from './types.js';
4
4
  import Button from '../Button/Button.js';
5
5
  import useEscapeKey from '../../hooks/keyboardevents/useEscKeyEvent.js';
6
6
  import useClickOutside from '../../hooks/useClickOutside';
@@ -38,6 +38,47 @@ const MiniModal = forwardRef<HTMLDivElement, MiniEditModalProps>(
38
38
  });
39
39
  const [isVisible, setIsVisible] = useState(false);
40
40
  const modalRef = useRef<HTMLDivElement>(null);
41
+ // Function to calculate available space
42
+ const getAvailableSpace = (rect: Rect): AvailableSpace => {
43
+ const { top, left, bottom, right } = rect;
44
+ const viewportWidth = window.innerWidth;
45
+ const viewportHeight = window.innerHeight;
46
+
47
+ return {
48
+ spaceTop: top,
49
+ spaceLeft: left,
50
+ spaceRight: viewportWidth - right,
51
+ spaceBottom: viewportHeight - bottom,
52
+ };
53
+ };
54
+ const anchorRect = anchorRef.current?.getBoundingClientRect();
55
+ if (!isWrapped && anchorRect) {
56
+ const availableSpace = getAvailableSpace(anchorRect);
57
+ switch (modalPosition) {
58
+ case 'top':
59
+ if (availableSpace.spaceTop < (modalProperties?.height ?? 150)) {
60
+ modalPosition = 'bottom';
61
+ }
62
+ break;
63
+ case 'left':
64
+ if (availableSpace.spaceLeft < (modalProperties?.width ?? 480)) {
65
+ modalPosition = 'right';
66
+ }
67
+ break;
68
+ case 'right':
69
+ if (availableSpace.spaceRight < (modalProperties?.width ?? 480)) {
70
+ modalPosition = 'left';
71
+ }
72
+ break;
73
+ case 'bottom':
74
+ if (availableSpace.spaceBottom < (modalProperties?.height ?? 150)) {
75
+ modalPosition = 'top';
76
+ }
77
+ break;
78
+ default:
79
+ break;
80
+ }
81
+ }
41
82
 
42
83
  //specify for the wrapper div left position
43
84
  const calculateAnchorRefLeft = (anchorRefLeftNum?: number) => {
@@ -174,7 +215,10 @@ const MiniModal = forwardRef<HTMLDivElement, MiniEditModalProps>(
174
215
  ></div>
175
216
  )}
176
217
  <div
177
- className="mini-edit-modal"
218
+ className={classNames('mini-edit-modal', {
219
+ 'mini-edit-modal-wrapper-shadow': !!isWrapped,
220
+ 'mini-edit-modal-arrow-shadow': !!isPopOver,
221
+ })}
178
222
  style={{
179
223
  minWidth: isWrapped ? '358px' : '',
180
224
  width: `${modalProperties?.width}px`,
@@ -86,3 +86,16 @@ export interface MiniEditModalProps {
86
86
  rightAlignModal?: number;
87
87
  };
88
88
  }
89
+ export interface Rect {
90
+ top: number;
91
+ left: number;
92
+ bottom: number;
93
+ right: number;
94
+ }
95
+
96
+ export interface AvailableSpace {
97
+ spaceTop: number;
98
+ spaceLeft: number;
99
+ spaceRight: number;
100
+ spaceBottom: number;
101
+ }