@softwareone/spi-sv5-library 1.13.0 → 1.14.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.
@@ -0,0 +1,44 @@
1
+ <script lang="ts">
2
+ import { Button, Modal, Spinner, addToast } from '../index.js';
3
+
4
+ interface Props {
5
+ title: string;
6
+ confirmationText: string;
7
+ confirmButtonText?: string;
8
+ showModal?: boolean;
9
+ onconfirm: () => Promise<string | void> | string | void;
10
+ onclose?: VoidFunction;
11
+ }
12
+
13
+ let {
14
+ title,
15
+ confirmationText,
16
+ confirmButtonText = 'Proceed',
17
+ showModal = $bindable(false),
18
+ onconfirm,
19
+ onclose
20
+ }: Props = $props();
21
+
22
+ let isLoading = $state(false);
23
+
24
+ const handleConfirm = async () => {
25
+ isLoading = true;
26
+
27
+ const error = await onconfirm();
28
+ if (error === undefined) {
29
+ showModal = false;
30
+ } else {
31
+ addToast({ message: error, type: 'danger' });
32
+ }
33
+
34
+ isLoading = false;
35
+ };
36
+ </script>
37
+
38
+ <Modal {title} bind:showModal {onclose}>
39
+ <Spinner show={isLoading} />
40
+ <p>{confirmationText}</p>
41
+ {#snippet footer()}
42
+ <Button type="button" onclick={handleConfirm}>{confirmButtonText}</Button>
43
+ {/snippet}
44
+ </Modal>
@@ -0,0 +1,11 @@
1
+ interface Props {
2
+ title: string;
3
+ confirmationText: string;
4
+ confirmButtonText?: string;
5
+ showModal?: boolean;
6
+ onconfirm: () => Promise<string | void> | string | void;
7
+ onclose?: VoidFunction;
8
+ }
9
+ declare const Confirmation: import("svelte").Component<Props, {}, "showModal">;
10
+ type Confirmation = ReturnType<typeof Confirmation>;
11
+ export default Confirmation;
@@ -5,9 +5,8 @@
5
5
  confirmationName?: string;
6
6
  enableDoubleConfirmation?: boolean;
7
7
  showModal?: boolean;
8
- ondelete: () => Promise<boolean> | boolean;
8
+ ondelete: () => Promise<string | void> | string | void;
9
9
  onclose?: VoidFunction;
10
- ondeleteSuccess?: () => Promise<void> | void;
11
10
  }
12
11
 
13
12
  let {
@@ -15,8 +14,7 @@
15
14
  enableDoubleConfirmation = false,
16
15
  showModal = $bindable(false),
17
16
  ondelete,
18
- onclose,
19
- ondeleteSuccess
17
+ onclose
20
18
  }: DeleteConfirmationProps = $props();
21
19
 
22
20
  let confirmationText = $derived(
@@ -29,13 +27,11 @@
29
27
  const handleDelete = async () => {
30
28
  isLoading = true;
31
29
 
32
- const isSuccessful = await ondelete();
33
-
34
- if (isSuccessful) {
35
- await ondeleteSuccess?.();
30
+ const error = await ondelete();
31
+ if (error === undefined) {
36
32
  showModal = false;
37
33
  } else {
38
- addToast({ message: 'There was an unexpected error.', type: 'danger' });
34
+ addToast({ message: error, type: 'danger' });
39
35
  }
40
36
 
41
37
  isLoading = false;
@@ -2,9 +2,8 @@ interface DeleteConfirmationProps {
2
2
  confirmationName?: string;
3
3
  enableDoubleConfirmation?: boolean;
4
4
  showModal?: boolean;
5
- ondelete: () => Promise<boolean> | boolean;
5
+ ondelete: () => Promise<string | void> | string | void;
6
6
  onclose?: VoidFunction;
7
- ondeleteSuccess?: () => Promise<void> | void;
8
7
  }
9
8
  declare const DeleteConfirmation: import("svelte").Component<DeleteConfirmationProps, {}, "showModal">;
10
9
  type DeleteConfirmation = ReturnType<typeof DeleteConfirmation>;
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ import Breadcrumbs from './Breadcrumbs/Breadcrumbs.svelte';
4
4
  import Button from './Button/Button.svelte';
5
5
  import Card from './Card/Card.svelte';
6
6
  import Chips from './Chips/Chips.svelte';
7
+ import ConfirmationModal from './Confirmation/Confirmation.svelte';
7
8
  import DeleteConfirmationModal from './DeleteConfirmation/DeleteConfirmation.svelte';
8
9
  import ErrorPage from './ErrorPage/ErrorPage.svelte';
9
10
  import Footer from './Footer/Footer.svelte';
@@ -57,4 +58,4 @@ import type { Tab } from './Tabs/tabsState.svelte.js';
57
58
  import type { Toast } from './Toast/toastState.svelte.js';
58
59
  import type { WaffleItem } from './Waffle/waffleState.svelte.js';
59
60
  import type { NotificationProps } from './Notification/notificationState.svelte.js';
60
- export { Accordion, AttachFile, Avatar, Breadcrumbs, Button, Card, Chips, DeleteConfirmationModal, ErrorPage, Footer, Header, HeaderAccount, HeaderLoader, HeaderLogo, HighlightPanel, Home, Input, Label, Link, Menu, Modal, Notification, Processing, ProgressPage, ProgressWizard, RadioGroup, Search, Select, Sidebar, Spinner, Switcher, Tabs, TextArea, Toaster, Toggle, Tooltip, Waffle, addBreadcrumbsNameMap, addToast, getProgressWizardContext, setProgressWizardStepsContext, setStepValidity, getSubMenuItemsFromMenu, createTabComponent, ChipType, ColumnType, ImageType, type AnnouncementItem, type BreadcrumbsNameMap, type HighlightPanelColumn, type HomeItem, type MainMenu, type MenuItem, type ModalProps, type ProgressWizardStep, type RadioOption, type SelectOption, type SubMenuItem, type SwitcherOption, type Tab, type Toast, type WaffleItem, type NotificationProps };
61
+ export { Accordion, AttachFile, Avatar, Breadcrumbs, Button, Card, Chips, ConfirmationModal, DeleteConfirmationModal, ErrorPage, Footer, Header, HeaderAccount, HeaderLoader, HeaderLogo, HighlightPanel, Home, Input, Label, Link, Menu, Modal, Notification, Processing, ProgressPage, ProgressWizard, RadioGroup, Search, Select, Sidebar, Spinner, Switcher, Tabs, TextArea, Toaster, Toggle, Tooltip, Waffle, addBreadcrumbsNameMap, addToast, getProgressWizardContext, setProgressWizardStepsContext, setStepValidity, getSubMenuItemsFromMenu, createTabComponent, ChipType, ColumnType, ImageType, type AnnouncementItem, type BreadcrumbsNameMap, type HighlightPanelColumn, type HomeItem, type MainMenu, type MenuItem, type ModalProps, type ProgressWizardStep, type RadioOption, type SelectOption, type SubMenuItem, type SwitcherOption, type Tab, type Toast, type WaffleItem, type NotificationProps };
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ import Breadcrumbs from './Breadcrumbs/Breadcrumbs.svelte';
5
5
  import Button from './Button/Button.svelte';
6
6
  import Card from './Card/Card.svelte';
7
7
  import Chips from './Chips/Chips.svelte';
8
+ import ConfirmationModal from './Confirmation/Confirmation.svelte';
8
9
  import DeleteConfirmationModal from './DeleteConfirmation/DeleteConfirmation.svelte';
9
10
  import ErrorPage from './ErrorPage/ErrorPage.svelte';
10
11
  import Footer from './Footer/Footer.svelte';
@@ -47,7 +48,7 @@ import { getSubMenuItemsFromMenu } from './Menu/MenuState.svelte.js';
47
48
  import { createTabComponent } from './Tabs/tabsState.svelte.js';
48
49
  export {
49
50
  // Components
50
- Accordion, AttachFile, Avatar, Breadcrumbs, Button, Card, Chips, DeleteConfirmationModal, ErrorPage, Footer, Header, HeaderAccount, HeaderLoader, HeaderLogo, HighlightPanel, Home, Input, Label, Link, Menu, Modal, Notification, Processing, ProgressPage, ProgressWizard, RadioGroup, Search, Select, Sidebar, Spinner, Switcher, Tabs, TextArea, Toaster, Toggle, Tooltip, Waffle,
51
+ Accordion, AttachFile, Avatar, Breadcrumbs, Button, Card, Chips, ConfirmationModal, DeleteConfirmationModal, ErrorPage, Footer, Header, HeaderAccount, HeaderLoader, HeaderLogo, HighlightPanel, Home, Input, Label, Link, Menu, Modal, Notification, Processing, ProgressPage, ProgressWizard, RadioGroup, Search, Select, Sidebar, Spinner, Switcher, Tabs, TextArea, Toaster, Toggle, Tooltip, Waffle,
51
52
  // Functions and helpers
52
53
  addBreadcrumbsNameMap, addToast, getProgressWizardContext, setProgressWizardStepsContext, setStepValidity, getSubMenuItemsFromMenu, createTabComponent,
53
54
  // Enums
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softwareone/spi-sv5-library",
3
- "version": "1.13.0",
3
+ "version": "1.14.0",
4
4
  "description": "Svelte components",
5
5
  "keywords": [
6
6
  "svelte",