@memori.ai/memori-react 7.21.1 → 7.23.0
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/CHANGELOG.md +56 -0
- package/dist/components/CompletionProviderStatus/CompletionProviderStatus.css +33 -23
- package/dist/components/CompletionProviderStatus/CompletionProviderStatus.js +85 -8
- package/dist/components/CompletionProviderStatus/CompletionProviderStatus.js.map +1 -1
- package/dist/components/KnownFacts/KnownFacts.js +1 -1
- package/dist/components/KnownFacts/KnownFacts.js.map +1 -1
- package/dist/components/StartPanel/StartPanel.css +29 -0
- package/dist/components/StartPanel/StartPanel.js +2 -1
- package/dist/components/StartPanel/StartPanel.js.map +1 -1
- package/dist/components/Typing/Typing.js +49 -47
- package/dist/components/Typing/Typing.js.map +1 -1
- package/dist/components/UploadButton/UploadButton.d.ts +1 -0
- package/dist/components/UploadButton/UploadButton.js +142 -3
- package/dist/components/UploadButton/UploadButton.js.map +1 -1
- package/dist/components/icons/Alert.d.ts +5 -0
- package/dist/components/icons/Alert.js +6 -0
- package/dist/components/icons/Alert.js.map +1 -0
- package/dist/components/icons/Info.d.ts +5 -0
- package/dist/components/icons/Info.js +6 -0
- package/dist/components/icons/Info.js.map +1 -0
- package/dist/components/icons/Warning.js +1 -1
- package/dist/components/icons/Warning.js.map +1 -1
- package/dist/components/ui/ConfirmDialog.css +42 -0
- package/dist/components/ui/ConfirmDialog.d.ts +11 -0
- package/dist/components/ui/ConfirmDialog.js +12 -0
- package/dist/components/ui/ConfirmDialog.js.map +1 -0
- package/dist/components/ui/Drawer.css +121 -96
- package/dist/components/ui/Drawer.d.ts +15 -6
- package/dist/components/ui/Drawer.js +44 -13
- package/dist/components/ui/Drawer.js.map +1 -1
- package/dist/locales/de.json +15 -0
- package/dist/locales/en.json +15 -0
- package/dist/locales/es.json +15 -0
- package/dist/locales/fr.json +7 -0
- package/dist/locales/it.json +15 -0
- package/dist/styles.css +6 -4
- package/esm/components/CompletionProviderStatus/CompletionProviderStatus.css +33 -23
- package/esm/components/CompletionProviderStatus/CompletionProviderStatus.js +85 -8
- package/esm/components/CompletionProviderStatus/CompletionProviderStatus.js.map +1 -1
- package/esm/components/KnownFacts/KnownFacts.js +1 -1
- package/esm/components/KnownFacts/KnownFacts.js.map +1 -1
- package/esm/components/StartPanel/StartPanel.css +29 -0
- package/esm/components/StartPanel/StartPanel.js +2 -1
- package/esm/components/StartPanel/StartPanel.js.map +1 -1
- package/esm/components/Typing/Typing.js +49 -47
- package/esm/components/Typing/Typing.js.map +1 -1
- package/esm/components/UploadButton/UploadButton.d.ts +1 -0
- package/esm/components/UploadButton/UploadButton.js +142 -3
- package/esm/components/UploadButton/UploadButton.js.map +1 -1
- package/esm/components/icons/Alert.d.ts +5 -0
- package/esm/components/icons/Alert.js +4 -0
- package/esm/components/icons/Alert.js.map +1 -0
- package/esm/components/icons/Info.d.ts +5 -0
- package/esm/components/icons/Info.js +4 -0
- package/esm/components/icons/Info.js.map +1 -0
- package/esm/components/icons/Warning.js +1 -1
- package/esm/components/icons/Warning.js.map +1 -1
- package/esm/components/ui/ConfirmDialog.css +42 -0
- package/esm/components/ui/ConfirmDialog.d.ts +11 -0
- package/esm/components/ui/ConfirmDialog.js +9 -0
- package/esm/components/ui/ConfirmDialog.js.map +1 -0
- package/esm/components/ui/Drawer.css +121 -96
- package/esm/components/ui/Drawer.d.ts +15 -6
- package/esm/components/ui/Drawer.js +45 -14
- package/esm/components/ui/Drawer.js.map +1 -1
- package/esm/locales/de.json +15 -0
- package/esm/locales/en.json +15 -0
- package/esm/locales/es.json +15 -0
- package/esm/locales/fr.json +7 -0
- package/esm/locales/it.json +15 -0
- package/esm/styles.css +6 -4
- package/package.json +1 -1
- package/src/components/BlockedMemoriBadge/__snapshots__/BlockedMemoriBadge.test.tsx.snap +10 -0
- package/src/components/CompletionProviderStatus/CompletionProviderStatus.css +33 -23
- package/src/components/CompletionProviderStatus/CompletionProviderStatus.stories.tsx +274 -21
- package/src/components/CompletionProviderStatus/CompletionProviderStatus.tsx +117 -21
- package/src/components/CompletionProviderStatus/__snapshots__/CompletionProviderStatus.test.tsx.snap +39 -21
- package/src/components/KnownFacts/KnownFacts.tsx +1 -1
- package/src/components/StartPanel/StartPanel.css +29 -0
- package/src/components/StartPanel/StartPanel.tsx +47 -0
- package/src/components/StartPanel/__snapshots__/StartPanel.test.tsx.snap +827 -7
- package/src/components/Typing/Typing.tsx +52 -47
- package/src/components/UploadButton/UploadButton.tsx +206 -5
- package/src/components/UploadButton/__snapshots__/UploadButton.test.tsx.snap +1 -1
- package/src/components/icons/Alert.tsx +31 -0
- package/src/components/icons/Info.tsx +31 -0
- package/src/components/icons/Warning.tsx +2 -1
- package/src/components/layouts/__snapshots__/Chat.test.tsx.snap +74 -0
- package/src/components/layouts/__snapshots__/FullPage.test.tsx.snap +148 -0
- package/src/components/layouts/__snapshots__/Totem.test.tsx.snap +74 -0
- package/src/components/layouts/__snapshots__/ZoomedFullBody.test.tsx.snap +74 -0
- package/src/components/ui/ConfirmDialog.css +42 -0
- package/src/components/ui/ConfirmDialog.stories.tsx +216 -0
- package/src/components/ui/ConfirmDialog.test.tsx +124 -0
- package/src/components/ui/ConfirmDialog.tsx +58 -0
- package/src/components/ui/Drawer.css +121 -96
- package/src/components/ui/Drawer.stories.tsx +152 -67
- package/src/components/ui/Drawer.test.tsx +6 -2
- package/src/components/ui/Drawer.tsx +195 -89
- package/src/components/ui/__snapshots__/ConfirmDialog.test.tsx.snap +35 -0
- package/src/locales/de.json +15 -0
- package/src/locales/en.json +15 -0
- package/src/locales/es.json +15 -0
- package/src/locales/fr.json +7 -0
- package/src/locales/it.json +15 -0
- package/src/styles.css +6 -4
|
@@ -376,6 +376,80 @@ exports[`renders FullPage layout unchanged 1`] = `
|
|
|
376
376
|
</option>
|
|
377
377
|
</select>
|
|
378
378
|
</div>
|
|
379
|
+
<div
|
|
380
|
+
class="memori--start-privacy-explanation-container"
|
|
381
|
+
>
|
|
382
|
+
<p
|
|
383
|
+
class="memori--start-privacy-explanation"
|
|
384
|
+
>
|
|
385
|
+
Le conversazioni sono visibili all'autore dell'agente
|
|
386
|
+
</p>
|
|
387
|
+
<div
|
|
388
|
+
class="memori-tooltip memori-tooltip--align-right"
|
|
389
|
+
>
|
|
390
|
+
<div
|
|
391
|
+
class="memori-tooltip--content"
|
|
392
|
+
>
|
|
393
|
+
<div
|
|
394
|
+
class="memori--privacy-tooltip-content"
|
|
395
|
+
>
|
|
396
|
+
<p>
|
|
397
|
+
|
|
398
|
+
Tutte le conversazioni con questo agente sono visibili all'autore dell'agente
|
|
399
|
+
</p>
|
|
400
|
+
<ul
|
|
401
|
+
class="memori--privacy-tooltip-content-list"
|
|
402
|
+
>
|
|
403
|
+
<li>
|
|
404
|
+
Per utenti anonimi: l'autore vedrà il contenuto e l'indirizzo IP
|
|
405
|
+
</li>
|
|
406
|
+
<li>
|
|
407
|
+
Per utenti registrati: l'autore vedrà il contenuto e il nome utente
|
|
408
|
+
</li>
|
|
409
|
+
</ul>
|
|
410
|
+
<p>
|
|
411
|
+
L'autore utilizza queste informazioni per migliorare le funzionalità dell'agente. Continuando, accetti queste condizioni.
|
|
412
|
+
</p>
|
|
413
|
+
<a
|
|
414
|
+
href="https://memori.ai/en/privacy-policy"
|
|
415
|
+
rel="noopener noreferrer"
|
|
416
|
+
target="_blank"
|
|
417
|
+
>
|
|
418
|
+
Informativa sulla privacy
|
|
419
|
+
</a>
|
|
420
|
+
</div>
|
|
421
|
+
</div>
|
|
422
|
+
<div
|
|
423
|
+
class="memori-tooltip--trigger"
|
|
424
|
+
>
|
|
425
|
+
<svg
|
|
426
|
+
aria-hidden="true"
|
|
427
|
+
class="memori--start-privacy-explanation-icon"
|
|
428
|
+
fill="none"
|
|
429
|
+
focusable="false"
|
|
430
|
+
role="img"
|
|
431
|
+
stroke="currentColor"
|
|
432
|
+
stroke-linecap="round"
|
|
433
|
+
stroke-linejoin="round"
|
|
434
|
+
stroke-width="1.5"
|
|
435
|
+
viewBox="0 0 24 24"
|
|
436
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
437
|
+
>
|
|
438
|
+
<circle
|
|
439
|
+
cx="12"
|
|
440
|
+
cy="12"
|
|
441
|
+
r="10"
|
|
442
|
+
/>
|
|
443
|
+
<path
|
|
444
|
+
d="M9.09 9a3 3 0 015.83 1c0 2-3 3-3 3"
|
|
445
|
+
/>
|
|
446
|
+
<path
|
|
447
|
+
d="M12 17L12.01 17"
|
|
448
|
+
/>
|
|
449
|
+
</svg>
|
|
450
|
+
</div>
|
|
451
|
+
</div>
|
|
452
|
+
</div>
|
|
379
453
|
<button
|
|
380
454
|
class="memori-button memori-button--primary memori-button--rounded memori-button--padded memori--start-button"
|
|
381
455
|
>
|
|
@@ -838,6 +912,80 @@ exports[`renders FullPage layout with root css properties unchanged 1`] = `
|
|
|
838
912
|
</option>
|
|
839
913
|
</select>
|
|
840
914
|
</div>
|
|
915
|
+
<div
|
|
916
|
+
class="memori--start-privacy-explanation-container"
|
|
917
|
+
>
|
|
918
|
+
<p
|
|
919
|
+
class="memori--start-privacy-explanation"
|
|
920
|
+
>
|
|
921
|
+
Le conversazioni sono visibili all'autore dell'agente
|
|
922
|
+
</p>
|
|
923
|
+
<div
|
|
924
|
+
class="memori-tooltip memori-tooltip--align-right"
|
|
925
|
+
>
|
|
926
|
+
<div
|
|
927
|
+
class="memori-tooltip--content"
|
|
928
|
+
>
|
|
929
|
+
<div
|
|
930
|
+
class="memori--privacy-tooltip-content"
|
|
931
|
+
>
|
|
932
|
+
<p>
|
|
933
|
+
|
|
934
|
+
Tutte le conversazioni con questo agente sono visibili all'autore dell'agente
|
|
935
|
+
</p>
|
|
936
|
+
<ul
|
|
937
|
+
class="memori--privacy-tooltip-content-list"
|
|
938
|
+
>
|
|
939
|
+
<li>
|
|
940
|
+
Per utenti anonimi: l'autore vedrà il contenuto e l'indirizzo IP
|
|
941
|
+
</li>
|
|
942
|
+
<li>
|
|
943
|
+
Per utenti registrati: l'autore vedrà il contenuto e il nome utente
|
|
944
|
+
</li>
|
|
945
|
+
</ul>
|
|
946
|
+
<p>
|
|
947
|
+
L'autore utilizza queste informazioni per migliorare le funzionalità dell'agente. Continuando, accetti queste condizioni.
|
|
948
|
+
</p>
|
|
949
|
+
<a
|
|
950
|
+
href="https://memori.ai/en/privacy-policy"
|
|
951
|
+
rel="noopener noreferrer"
|
|
952
|
+
target="_blank"
|
|
953
|
+
>
|
|
954
|
+
Informativa sulla privacy
|
|
955
|
+
</a>
|
|
956
|
+
</div>
|
|
957
|
+
</div>
|
|
958
|
+
<div
|
|
959
|
+
class="memori-tooltip--trigger"
|
|
960
|
+
>
|
|
961
|
+
<svg
|
|
962
|
+
aria-hidden="true"
|
|
963
|
+
class="memori--start-privacy-explanation-icon"
|
|
964
|
+
fill="none"
|
|
965
|
+
focusable="false"
|
|
966
|
+
role="img"
|
|
967
|
+
stroke="currentColor"
|
|
968
|
+
stroke-linecap="round"
|
|
969
|
+
stroke-linejoin="round"
|
|
970
|
+
stroke-width="1.5"
|
|
971
|
+
viewBox="0 0 24 24"
|
|
972
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
973
|
+
>
|
|
974
|
+
<circle
|
|
975
|
+
cx="12"
|
|
976
|
+
cy="12"
|
|
977
|
+
r="10"
|
|
978
|
+
/>
|
|
979
|
+
<path
|
|
980
|
+
d="M9.09 9a3 3 0 015.83 1c0 2-3 3-3 3"
|
|
981
|
+
/>
|
|
982
|
+
<path
|
|
983
|
+
d="M12 17L12.01 17"
|
|
984
|
+
/>
|
|
985
|
+
</svg>
|
|
986
|
+
</div>
|
|
987
|
+
</div>
|
|
988
|
+
</div>
|
|
841
989
|
<button
|
|
842
990
|
class="memori-button memori-button--primary memori-button--rounded memori-button--padded memori--start-button"
|
|
843
991
|
>
|
|
@@ -430,6 +430,80 @@ exports[`renders Totem layout unchanged 1`] = `
|
|
|
430
430
|
</option>
|
|
431
431
|
</select>
|
|
432
432
|
</div>
|
|
433
|
+
<div
|
|
434
|
+
class="memori--start-privacy-explanation-container"
|
|
435
|
+
>
|
|
436
|
+
<p
|
|
437
|
+
class="memori--start-privacy-explanation"
|
|
438
|
+
>
|
|
439
|
+
Le conversazioni sono visibili all'autore dell'agente
|
|
440
|
+
</p>
|
|
441
|
+
<div
|
|
442
|
+
class="memori-tooltip memori-tooltip--align-right"
|
|
443
|
+
>
|
|
444
|
+
<div
|
|
445
|
+
class="memori-tooltip--content"
|
|
446
|
+
>
|
|
447
|
+
<div
|
|
448
|
+
class="memori--privacy-tooltip-content"
|
|
449
|
+
>
|
|
450
|
+
<p>
|
|
451
|
+
|
|
452
|
+
Tutte le conversazioni con questo agente sono visibili all'autore dell'agente
|
|
453
|
+
</p>
|
|
454
|
+
<ul
|
|
455
|
+
class="memori--privacy-tooltip-content-list"
|
|
456
|
+
>
|
|
457
|
+
<li>
|
|
458
|
+
Per utenti anonimi: l'autore vedrà il contenuto e l'indirizzo IP
|
|
459
|
+
</li>
|
|
460
|
+
<li>
|
|
461
|
+
Per utenti registrati: l'autore vedrà il contenuto e il nome utente
|
|
462
|
+
</li>
|
|
463
|
+
</ul>
|
|
464
|
+
<p>
|
|
465
|
+
L'autore utilizza queste informazioni per migliorare le funzionalità dell'agente. Continuando, accetti queste condizioni.
|
|
466
|
+
</p>
|
|
467
|
+
<a
|
|
468
|
+
href="https://memori.ai/en/privacy-policy"
|
|
469
|
+
rel="noopener noreferrer"
|
|
470
|
+
target="_blank"
|
|
471
|
+
>
|
|
472
|
+
Informativa sulla privacy
|
|
473
|
+
</a>
|
|
474
|
+
</div>
|
|
475
|
+
</div>
|
|
476
|
+
<div
|
|
477
|
+
class="memori-tooltip--trigger"
|
|
478
|
+
>
|
|
479
|
+
<svg
|
|
480
|
+
aria-hidden="true"
|
|
481
|
+
class="memori--start-privacy-explanation-icon"
|
|
482
|
+
fill="none"
|
|
483
|
+
focusable="false"
|
|
484
|
+
role="img"
|
|
485
|
+
stroke="currentColor"
|
|
486
|
+
stroke-linecap="round"
|
|
487
|
+
stroke-linejoin="round"
|
|
488
|
+
stroke-width="1.5"
|
|
489
|
+
viewBox="0 0 24 24"
|
|
490
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
491
|
+
>
|
|
492
|
+
<circle
|
|
493
|
+
cx="12"
|
|
494
|
+
cy="12"
|
|
495
|
+
r="10"
|
|
496
|
+
/>
|
|
497
|
+
<path
|
|
498
|
+
d="M9.09 9a3 3 0 015.83 1c0 2-3 3-3 3"
|
|
499
|
+
/>
|
|
500
|
+
<path
|
|
501
|
+
d="M12 17L12.01 17"
|
|
502
|
+
/>
|
|
503
|
+
</svg>
|
|
504
|
+
</div>
|
|
505
|
+
</div>
|
|
506
|
+
</div>
|
|
433
507
|
<button
|
|
434
508
|
class="memori-button memori-button--primary memori-button--rounded memori-button--padded memori--start-button"
|
|
435
509
|
>
|
|
@@ -376,6 +376,80 @@ exports[`renders ZOOMED_FULL_BODY layout unchanged 1`] = `
|
|
|
376
376
|
</option>
|
|
377
377
|
</select>
|
|
378
378
|
</div>
|
|
379
|
+
<div
|
|
380
|
+
class="memori--start-privacy-explanation-container"
|
|
381
|
+
>
|
|
382
|
+
<p
|
|
383
|
+
class="memori--start-privacy-explanation"
|
|
384
|
+
>
|
|
385
|
+
Le conversazioni sono visibili all'autore dell'agente
|
|
386
|
+
</p>
|
|
387
|
+
<div
|
|
388
|
+
class="memori-tooltip memori-tooltip--align-right"
|
|
389
|
+
>
|
|
390
|
+
<div
|
|
391
|
+
class="memori-tooltip--content"
|
|
392
|
+
>
|
|
393
|
+
<div
|
|
394
|
+
class="memori--privacy-tooltip-content"
|
|
395
|
+
>
|
|
396
|
+
<p>
|
|
397
|
+
|
|
398
|
+
Tutte le conversazioni con questo agente sono visibili all'autore dell'agente
|
|
399
|
+
</p>
|
|
400
|
+
<ul
|
|
401
|
+
class="memori--privacy-tooltip-content-list"
|
|
402
|
+
>
|
|
403
|
+
<li>
|
|
404
|
+
Per utenti anonimi: l'autore vedrà il contenuto e l'indirizzo IP
|
|
405
|
+
</li>
|
|
406
|
+
<li>
|
|
407
|
+
Per utenti registrati: l'autore vedrà il contenuto e il nome utente
|
|
408
|
+
</li>
|
|
409
|
+
</ul>
|
|
410
|
+
<p>
|
|
411
|
+
L'autore utilizza queste informazioni per migliorare le funzionalità dell'agente. Continuando, accetti queste condizioni.
|
|
412
|
+
</p>
|
|
413
|
+
<a
|
|
414
|
+
href="https://memori.ai/en/privacy-policy"
|
|
415
|
+
rel="noopener noreferrer"
|
|
416
|
+
target="_blank"
|
|
417
|
+
>
|
|
418
|
+
Informativa sulla privacy
|
|
419
|
+
</a>
|
|
420
|
+
</div>
|
|
421
|
+
</div>
|
|
422
|
+
<div
|
|
423
|
+
class="memori-tooltip--trigger"
|
|
424
|
+
>
|
|
425
|
+
<svg
|
|
426
|
+
aria-hidden="true"
|
|
427
|
+
class="memori--start-privacy-explanation-icon"
|
|
428
|
+
fill="none"
|
|
429
|
+
focusable="false"
|
|
430
|
+
role="img"
|
|
431
|
+
stroke="currentColor"
|
|
432
|
+
stroke-linecap="round"
|
|
433
|
+
stroke-linejoin="round"
|
|
434
|
+
stroke-width="1.5"
|
|
435
|
+
viewBox="0 0 24 24"
|
|
436
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
437
|
+
>
|
|
438
|
+
<circle
|
|
439
|
+
cx="12"
|
|
440
|
+
cy="12"
|
|
441
|
+
r="10"
|
|
442
|
+
/>
|
|
443
|
+
<path
|
|
444
|
+
d="M9.09 9a3 3 0 015.83 1c0 2-3 3-3 3"
|
|
445
|
+
/>
|
|
446
|
+
<path
|
|
447
|
+
d="M12 17L12.01 17"
|
|
448
|
+
/>
|
|
449
|
+
</svg>
|
|
450
|
+
</div>
|
|
451
|
+
</div>
|
|
452
|
+
</div>
|
|
379
453
|
<button
|
|
380
454
|
class="memori-button memori-button--primary memori-button--rounded memori-button--padded memori--start-button"
|
|
381
455
|
>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* Confirmation dialog styles */
|
|
2
|
+
.memori-confirm-dialog--backdrop {
|
|
3
|
+
position: fixed;
|
|
4
|
+
z-index: 100;
|
|
5
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
6
|
+
inset: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.memori-confirm-dialog--container {
|
|
10
|
+
position: fixed;
|
|
11
|
+
z-index: 101;
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
padding: 1rem;
|
|
16
|
+
inset: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.memori-confirm-dialog--panel {
|
|
20
|
+
width: 100%;
|
|
21
|
+
max-width: 28rem;
|
|
22
|
+
padding: 1.5rem;
|
|
23
|
+
border-radius: 0.5rem;
|
|
24
|
+
background-color: white;
|
|
25
|
+
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.memori-confirm-dialog--title {
|
|
29
|
+
margin-bottom: 0.75rem;
|
|
30
|
+
font-size: 1.25rem;
|
|
31
|
+
font-weight: 600;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.memori-confirm-dialog--message {
|
|
35
|
+
margin-bottom: 1.5rem;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.memori-confirm-dialog--actions {
|
|
39
|
+
display: flex;
|
|
40
|
+
justify-content: flex-end;
|
|
41
|
+
gap: 0.5rem;
|
|
42
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, Story } from '@storybook/react';
|
|
3
|
+
import ConfirmDialog from './ConfirmDialog';
|
|
4
|
+
import Button from './Button';
|
|
5
|
+
|
|
6
|
+
import './ConfirmDialog.css';
|
|
7
|
+
|
|
8
|
+
type Props = React.ComponentProps<typeof ConfirmDialog>;
|
|
9
|
+
|
|
10
|
+
const meta: Meta = {
|
|
11
|
+
title: 'UI/ConfirmDialog',
|
|
12
|
+
component: ConfirmDialog,
|
|
13
|
+
argTypes: {
|
|
14
|
+
isOpen: {
|
|
15
|
+
control: {
|
|
16
|
+
type: 'boolean',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
title: {
|
|
20
|
+
control: {
|
|
21
|
+
type: 'text',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
message: {
|
|
25
|
+
control: {
|
|
26
|
+
type: 'text',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
confirmText: {
|
|
30
|
+
control: {
|
|
31
|
+
type: 'text',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
cancelText: {
|
|
35
|
+
control: {
|
|
36
|
+
type: 'text',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
parameters: {
|
|
41
|
+
controls: { expanded: true },
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default meta;
|
|
46
|
+
|
|
47
|
+
const Template: Story<Props> = args => {
|
|
48
|
+
const [isOpen, setIsOpen] = React.useState(!!args.isOpen || false);
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<>
|
|
52
|
+
<Button onClick={() => setIsOpen(true)}>Open Confirm Dialog</Button>
|
|
53
|
+
<ConfirmDialog
|
|
54
|
+
{...args}
|
|
55
|
+
isOpen={isOpen}
|
|
56
|
+
onClose={() => setIsOpen(false)}
|
|
57
|
+
onConfirm={() => {
|
|
58
|
+
console.log('Confirmed!');
|
|
59
|
+
setIsOpen(false);
|
|
60
|
+
}}
|
|
61
|
+
/>
|
|
62
|
+
</>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// Basic examples
|
|
67
|
+
export const Default = Template.bind({});
|
|
68
|
+
Default.args = {
|
|
69
|
+
isOpen: false,
|
|
70
|
+
title: 'Confirm Action',
|
|
71
|
+
message: 'Are you sure you want to proceed with this action?',
|
|
72
|
+
confirmText: 'Confirm',
|
|
73
|
+
cancelText: 'Cancel',
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const Open = Template.bind({});
|
|
77
|
+
Open.args = {
|
|
78
|
+
isOpen: true,
|
|
79
|
+
title: 'Confirm Action',
|
|
80
|
+
message: 'Are you sure you want to proceed with this action?',
|
|
81
|
+
confirmText: 'Confirm',
|
|
82
|
+
cancelText: 'Cancel',
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const WithCustomTitle = Template.bind({});
|
|
86
|
+
WithCustomTitle.args = {
|
|
87
|
+
isOpen: true,
|
|
88
|
+
title: 'Delete Item',
|
|
89
|
+
message: 'Are you sure you want to proceed with this action?',
|
|
90
|
+
confirmText: 'Confirm',
|
|
91
|
+
cancelText: 'Cancel',
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const WithCustomMessage = Template.bind({});
|
|
95
|
+
WithCustomMessage.args = {
|
|
96
|
+
isOpen: true,
|
|
97
|
+
title: 'Confirm Action',
|
|
98
|
+
message: 'This action cannot be undone. All associated data will be permanently deleted from the system.',
|
|
99
|
+
confirmText: 'Confirm',
|
|
100
|
+
cancelText: 'Cancel',
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const WithCustomButtonText = Template.bind({});
|
|
104
|
+
WithCustomButtonText.args = {
|
|
105
|
+
isOpen: true,
|
|
106
|
+
title: 'Delete Item',
|
|
107
|
+
message: 'Are you sure you want to delete this item? This action cannot be undone.',
|
|
108
|
+
confirmText: 'Yes, Delete',
|
|
109
|
+
cancelText: 'No, Keep It',
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// Use case examples
|
|
113
|
+
const DeleteTemplate: Story<Props> = args => {
|
|
114
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
115
|
+
const [isDeleted, setIsDeleted] = React.useState(false);
|
|
116
|
+
|
|
117
|
+
const handleConfirm = () => {
|
|
118
|
+
setIsDeleted(true);
|
|
119
|
+
setIsOpen(false);
|
|
120
|
+
console.log('Item deleted!');
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<>
|
|
125
|
+
{isDeleted ? (
|
|
126
|
+
<div style={{
|
|
127
|
+
padding: '12px',
|
|
128
|
+
background: '#f8d7da',
|
|
129
|
+
color: '#721c24',
|
|
130
|
+
borderRadius: '4px',
|
|
131
|
+
marginBottom: '20px'
|
|
132
|
+
}}>
|
|
133
|
+
Item has been deleted successfully!
|
|
134
|
+
</div>
|
|
135
|
+
) : (
|
|
136
|
+
<Button onClick={() => setIsOpen(true)}>Delete Item</Button>
|
|
137
|
+
)}
|
|
138
|
+
|
|
139
|
+
<ConfirmDialog
|
|
140
|
+
{...args}
|
|
141
|
+
isOpen={isOpen}
|
|
142
|
+
onClose={() => setIsOpen(false)}
|
|
143
|
+
onConfirm={handleConfirm}
|
|
144
|
+
/>
|
|
145
|
+
</>
|
|
146
|
+
);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export const DeleteConfirmation = DeleteTemplate.bind({});
|
|
150
|
+
DeleteConfirmation.args = {
|
|
151
|
+
title: 'Delete Item',
|
|
152
|
+
message: 'Are you sure you want to delete this item? This action cannot be undone.',
|
|
153
|
+
confirmText: 'Delete',
|
|
154
|
+
cancelText: 'Cancel',
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const SaveTemplate: Story<Props> = args => {
|
|
158
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
159
|
+
const [navigatedAway, setNavigatedAway] = React.useState(false);
|
|
160
|
+
|
|
161
|
+
const handleTryNavigate = () => {
|
|
162
|
+
setIsOpen(true);
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const handleConfirm = () => {
|
|
166
|
+
setNavigatedAway(true);
|
|
167
|
+
setIsOpen(false);
|
|
168
|
+
console.log('Navigated without saving!');
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<>
|
|
173
|
+
{navigatedAway ? (
|
|
174
|
+
<div style={{
|
|
175
|
+
padding: '12px',
|
|
176
|
+
background: '#d4edda',
|
|
177
|
+
color: '#155724',
|
|
178
|
+
borderRadius: '4px',
|
|
179
|
+
marginBottom: '20px'
|
|
180
|
+
}}>
|
|
181
|
+
Navigated away without saving changes.
|
|
182
|
+
</div>
|
|
183
|
+
) : (
|
|
184
|
+
<div>
|
|
185
|
+
<div style={{
|
|
186
|
+
padding: '20px',
|
|
187
|
+
border: '1px solid #ddd',
|
|
188
|
+
borderRadius: '4px',
|
|
189
|
+
marginBottom: '20px'
|
|
190
|
+
}}>
|
|
191
|
+
<h3>Unsaved Form</h3>
|
|
192
|
+
<p>This is a form with unsaved changes.</p>
|
|
193
|
+
<input type="text" placeholder="Your name" style={{ padding: '8px', marginBottom: '10px', width: '100%' }} />
|
|
194
|
+
<textarea placeholder="Your message" style={{ padding: '8px', width: '100%', height: '100px' }} />
|
|
195
|
+
</div>
|
|
196
|
+
<Button onClick={handleTryNavigate}>Navigate Away</Button>
|
|
197
|
+
</div>
|
|
198
|
+
)}
|
|
199
|
+
|
|
200
|
+
<ConfirmDialog
|
|
201
|
+
{...args}
|
|
202
|
+
isOpen={isOpen}
|
|
203
|
+
onClose={() => setIsOpen(false)}
|
|
204
|
+
onConfirm={handleConfirm}
|
|
205
|
+
/>
|
|
206
|
+
</>
|
|
207
|
+
);
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
export const UnsavedChanges = SaveTemplate.bind({});
|
|
211
|
+
UnsavedChanges.args = {
|
|
212
|
+
title: 'Unsaved Changes',
|
|
213
|
+
message: 'You have unsaved changes. Are you sure you want to leave without saving?',
|
|
214
|
+
confirmText: 'Leave',
|
|
215
|
+
cancelText: 'Stay',
|
|
216
|
+
};
|