@marianmeres/stuic 1.73.0 → 1.74.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.
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
<script>import { createEventDispatcher, onMount } from "svelte";
|
|
1
|
+
<script context="module">import { createEventDispatcher, onMount } from "svelte";
|
|
2
2
|
import { focusTrap } from "../../actions/focus-trap.js";
|
|
3
|
-
|
|
3
|
+
import { writable } from "svelte/store";
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<script>const dispatch = createEventDispatcher();
|
|
4
7
|
export let openOnMount = false;
|
|
5
8
|
export let closeOnOutsideClick = true;
|
|
6
9
|
export let closeOnEscape = true;
|
|
@@ -9,29 +12,35 @@ export { _class as class };
|
|
|
9
12
|
export let style = "";
|
|
10
13
|
let _el;
|
|
11
14
|
let _open = !!openOnMount;
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
export function toggle() {
|
|
16
|
+
_open = !_open;
|
|
17
|
+
}
|
|
18
|
+
export function open() {
|
|
19
|
+
_open = true;
|
|
20
|
+
}
|
|
21
|
+
export function close() {
|
|
22
|
+
_open = false;
|
|
23
|
+
}
|
|
15
24
|
$:
|
|
16
25
|
_open ? _el?.showModal() : _el?.close();
|
|
17
26
|
$:
|
|
18
27
|
dispatch(_open ? "open" : "close");
|
|
19
|
-
export
|
|
28
|
+
export const isOpen = writable(_open);
|
|
20
29
|
$:
|
|
21
|
-
isOpen = _open;
|
|
30
|
+
$isOpen = _open;
|
|
22
31
|
onMount(() => {
|
|
23
32
|
const _unsubs = [];
|
|
24
|
-
const _handleClose = (e) =>
|
|
33
|
+
const _handleClose = (e) => close();
|
|
25
34
|
_el.addEventListener("close", _handleClose);
|
|
26
35
|
_unsubs.push(() => _el.removeEventListener("close", _handleClose));
|
|
27
36
|
const _handleCancel = (e) => e.preventDefault();
|
|
28
37
|
_el.addEventListener("cancel", _handleCancel);
|
|
29
38
|
_unsubs.push(() => _el.removeEventListener("cancel", _handleCancel));
|
|
30
|
-
const _handleKeyDown = (e) => closeOnEscape && e.key === "Escape" &&
|
|
39
|
+
const _handleKeyDown = (e) => closeOnEscape && e.key === "Escape" && close();
|
|
31
40
|
document.addEventListener("keydown", _handleKeyDown, true);
|
|
32
41
|
_unsubs.push(() => document.removeEventListener("keydown", _handleKeyDown, true));
|
|
33
42
|
const _handleClick = (e) => {
|
|
34
|
-
closeOnOutsideClick && /dialog/i.test(e.target?.tagName) &&
|
|
43
|
+
closeOnOutsideClick && /dialog/i.test(e.target?.tagName) && close();
|
|
35
44
|
};
|
|
36
45
|
_el.addEventListener("click", _handleClick);
|
|
37
46
|
_unsubs.push(() => _el.removeEventListener("click", _handleClick));
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
+
import { type Writable } from 'svelte/store';
|
|
3
|
+
export interface ModalDialogAPI {
|
|
4
|
+
open: () => void;
|
|
5
|
+
close: () => void;
|
|
6
|
+
isOpen: Writable<boolean>;
|
|
7
|
+
}
|
|
2
8
|
declare const __propDef: {
|
|
3
9
|
props: {
|
|
4
10
|
openOnMount?: boolean | undefined;
|
|
@@ -6,10 +12,10 @@ declare const __propDef: {
|
|
|
6
12
|
closeOnEscape?: boolean | undefined;
|
|
7
13
|
class?: string | undefined;
|
|
8
14
|
style?: string | undefined;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
isOpen?: boolean | undefined;
|
|
15
|
+
toggle?: (() => void) | undefined;
|
|
16
|
+
open?: (() => void) | undefined;
|
|
17
|
+
close?: (() => void) | undefined;
|
|
18
|
+
isOpen?: Writable<boolean> | undefined;
|
|
13
19
|
};
|
|
14
20
|
events: {
|
|
15
21
|
[evt: string]: CustomEvent<any>;
|
|
@@ -22,8 +28,9 @@ export type ModalDialogProps = typeof __propDef.props;
|
|
|
22
28
|
export type ModalDialogEvents = typeof __propDef.events;
|
|
23
29
|
export type ModalDialogSlots = typeof __propDef.slots;
|
|
24
30
|
export default class ModalDialog extends SvelteComponent<ModalDialogProps, ModalDialogEvents, ModalDialogSlots> {
|
|
25
|
-
get
|
|
26
|
-
get
|
|
27
|
-
get
|
|
31
|
+
get toggle(): () => void;
|
|
32
|
+
get open(): () => void;
|
|
33
|
+
get close(): () => void;
|
|
34
|
+
get isOpen(): Writable<boolean>;
|
|
28
35
|
}
|
|
29
36
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export { default as FieldCheckbox, FieldCheckboxConfig, type FieldCheckboxConfig
|
|
|
14
14
|
export { default as FieldRadios, FieldRadiosConfig, type FieldRadiosConfigClasses, type FieldRadiosConfigClassesBySize, } from './components/Input/FieldRadios.svelte';
|
|
15
15
|
export { default as FieldSelect, FieldSelectConfig, type FieldSelectConfigClasses, type FieldSelectConfigClassesBySize, } from './components/Input/FieldSelect.svelte';
|
|
16
16
|
export { default as Fieldset, FieldsetConfig, type FieldsetConfigClasses, } from './components/Input/Fieldset.svelte';
|
|
17
|
-
export { default as ModalDialog } from './components/ModalDialog/ModalDialog.svelte';
|
|
17
|
+
export { default as ModalDialog, type ModalDialogAPI, } from './components/ModalDialog/ModalDialog.svelte';
|
|
18
18
|
export { createNotificationsStore, NOTIFICATION_EVENT, type NotiticationsCreateStoreOptions, type NotificationCreateParam, type Notification, type NotificationInput, type NotificationType, type NotificationOnEventHandler, type NotificationsSortOrder, type NotificationKnownClasses, } from './components/Notifications/notifications.js';
|
|
19
19
|
export { default as Notifications, NotificationsConfig, } from './components/Notifications/Notifications.svelte';
|
|
20
20
|
export { default as Popover } from './components/Popover/Popover.svelte';
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@ export { default as FieldCheckbox, FieldCheckboxConfig, } from './components/Inp
|
|
|
24
24
|
export { default as FieldRadios, FieldRadiosConfig, } from './components/Input/FieldRadios.svelte';
|
|
25
25
|
export { default as FieldSelect, FieldSelectConfig, } from './components/Input/FieldSelect.svelte';
|
|
26
26
|
export { default as Fieldset, FieldsetConfig, } from './components/Input/Fieldset.svelte';
|
|
27
|
-
export { default as ModalDialog } from './components/ModalDialog/ModalDialog.svelte';
|
|
27
|
+
export { default as ModalDialog, } from './components/ModalDialog/ModalDialog.svelte';
|
|
28
28
|
//
|
|
29
29
|
export { createNotificationsStore, NOTIFICATION_EVENT, } from './components/Notifications/notifications.js';
|
|
30
30
|
export { default as Notifications, NotificationsConfig, } from './components/Notifications/Notifications.svelte';
|