@marianmeres/stuic 1.71.0 → 1.73.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/dist/actions/focus-trap.js +2 -1
- package/dist/components/AlertConfirmPrompt/alert-confirm-prompt.d.ts +1 -1
- package/dist/components/ModalDialog/ModalDialog.svelte +52 -0
- package/dist/components/ModalDialog/ModalDialog.svelte.d.ts +29 -0
- package/dist/components/Switch/Switch.svelte.d.ts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/package.json +1 -1
|
@@ -85,7 +85,8 @@ export function focusTrap(node, options = {}) {
|
|
|
85
85
|
// Lifecycle
|
|
86
86
|
return {
|
|
87
87
|
update(options = {}) {
|
|
88
|
-
options?.enabled
|
|
88
|
+
enabled = !!options?.enabled;
|
|
89
|
+
enabled ? queryElements(false) : cleanup();
|
|
89
90
|
},
|
|
90
91
|
destroy() {
|
|
91
92
|
cleanup();
|
|
@@ -7,7 +7,7 @@ export declare enum AlertConfirmPromptType {
|
|
|
7
7
|
export type AlertConfirmPromptVariant = 'info' | 'success' | 'warn' | 'error';
|
|
8
8
|
type FnOnOK = (value: any) => any;
|
|
9
9
|
type FnOnCancel = (value: false) => any;
|
|
10
|
-
type FnOnEscape = () =>
|
|
10
|
+
type FnOnEscape = () => void;
|
|
11
11
|
type FnOnCustom = (value: any) => any;
|
|
12
12
|
export interface AlertConfirmPromptKnownClasses {
|
|
13
13
|
dialog: string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<script>import { createEventDispatcher, onMount } from "svelte";
|
|
2
|
+
import { focusTrap } from "../../actions/focus-trap.js";
|
|
3
|
+
const dispatch = createEventDispatcher();
|
|
4
|
+
export let openOnMount = false;
|
|
5
|
+
export let closeOnOutsideClick = true;
|
|
6
|
+
export let closeOnEscape = true;
|
|
7
|
+
let _class = "";
|
|
8
|
+
export { _class as class };
|
|
9
|
+
export let style = "";
|
|
10
|
+
let _el;
|
|
11
|
+
let _open = !!openOnMount;
|
|
12
|
+
export const doToggle = () => _open = !_open;
|
|
13
|
+
export const doOpen = () => _open = true;
|
|
14
|
+
export const doClose = () => _open = false;
|
|
15
|
+
$:
|
|
16
|
+
_open ? _el?.showModal() : _el?.close();
|
|
17
|
+
$:
|
|
18
|
+
dispatch(_open ? "open" : "close");
|
|
19
|
+
export let isOpen = _open;
|
|
20
|
+
$:
|
|
21
|
+
isOpen = _open;
|
|
22
|
+
onMount(() => {
|
|
23
|
+
const _unsubs = [];
|
|
24
|
+
const _handleClose = (e) => doClose();
|
|
25
|
+
_el.addEventListener("close", _handleClose);
|
|
26
|
+
_unsubs.push(() => _el.removeEventListener("close", _handleClose));
|
|
27
|
+
const _handleCancel = (e) => e.preventDefault();
|
|
28
|
+
_el.addEventListener("cancel", _handleCancel);
|
|
29
|
+
_unsubs.push(() => _el.removeEventListener("cancel", _handleCancel));
|
|
30
|
+
const _handleKeyDown = (e) => closeOnEscape && e.key === "Escape" && doClose();
|
|
31
|
+
document.addEventListener("keydown", _handleKeyDown, true);
|
|
32
|
+
_unsubs.push(() => document.removeEventListener("keydown", _handleKeyDown, true));
|
|
33
|
+
const _handleClick = (e) => {
|
|
34
|
+
closeOnOutsideClick && /dialog/i.test(e.target?.tagName) && doClose();
|
|
35
|
+
};
|
|
36
|
+
_el.addEventListener("click", _handleClick);
|
|
37
|
+
_unsubs.push(() => _el.removeEventListener("click", _handleClick));
|
|
38
|
+
return () => _unsubs.forEach((fn) => fn());
|
|
39
|
+
});
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<!--
|
|
43
|
+
NOTE: the below padding:0 is important because of otherwise not-trivial onOutsideClick implementation
|
|
44
|
+
-->
|
|
45
|
+
<dialog
|
|
46
|
+
bind:this={_el}
|
|
47
|
+
use:focusTrap={{ enabled: _open }}
|
|
48
|
+
style="{style ? `${style}; ` : ''}padding: 0 !important;"
|
|
49
|
+
class={_class}
|
|
50
|
+
>
|
|
51
|
+
<slot />
|
|
52
|
+
</dialog>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
openOnMount?: boolean | undefined;
|
|
5
|
+
closeOnOutsideClick?: boolean | undefined;
|
|
6
|
+
closeOnEscape?: boolean | undefined;
|
|
7
|
+
class?: string | undefined;
|
|
8
|
+
style?: string | undefined;
|
|
9
|
+
doToggle?: (() => boolean) | undefined;
|
|
10
|
+
doOpen?: (() => boolean) | undefined;
|
|
11
|
+
doClose?: (() => boolean) | undefined;
|
|
12
|
+
isOpen?: boolean | undefined;
|
|
13
|
+
};
|
|
14
|
+
events: {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
};
|
|
17
|
+
slots: {
|
|
18
|
+
default: {};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type ModalDialogProps = typeof __propDef.props;
|
|
22
|
+
export type ModalDialogEvents = typeof __propDef.events;
|
|
23
|
+
export type ModalDialogSlots = typeof __propDef.slots;
|
|
24
|
+
export default class ModalDialog extends SvelteComponent<ModalDialogProps, ModalDialogEvents, ModalDialogSlots> {
|
|
25
|
+
get doToggle(): () => boolean;
|
|
26
|
+
get doOpen(): () => boolean;
|
|
27
|
+
get doClose(): () => boolean;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
+
export type SwitchPreHook = (previosValue: boolean) => Promise<void | boolean>;
|
|
2
3
|
export declare class SwitchConfig {
|
|
3
4
|
static defaultSize: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
4
5
|
static defaultVariant: string | undefined;
|
|
@@ -34,7 +35,7 @@ declare const __propDef: {
|
|
|
34
35
|
variant?: string | undefined;
|
|
35
36
|
stopPropagation?: boolean | undefined;
|
|
36
37
|
preventDefault?: boolean | undefined;
|
|
37
|
-
preHook?:
|
|
38
|
+
preHook?: SwitchPreHook | undefined;
|
|
38
39
|
size?: "sm" | "md" | "lg" | "xs" | "xl" | undefined;
|
|
39
40
|
};
|
|
40
41
|
events: {
|
package/dist/index.d.ts
CHANGED
|
@@ -14,10 +14,11 @@ 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
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';
|
|
18
19
|
export { default as Notifications, NotificationsConfig, } from './components/Notifications/Notifications.svelte';
|
|
19
20
|
export { default as Popover } from './components/Popover/Popover.svelte';
|
|
20
|
-
export { default as Switch, SwitchConfig } from './components/Switch/Switch.svelte';
|
|
21
|
+
export { default as Switch, SwitchConfig, type SwitchPreHook, } from './components/Switch/Switch.svelte';
|
|
21
22
|
export { default as Thc, type THC, isTHCNotEmpty } from './components/Thc/Thc.svelte';
|
|
22
23
|
export { default as X } from './components/X/X.svelte';
|
|
23
24
|
export { autogrow } from './actions/autogrow.js';
|
package/dist/index.js
CHANGED
|
@@ -24,13 +24,14 @@ 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
28
|
//
|
|
28
29
|
export { createNotificationsStore, NOTIFICATION_EVENT, } from './components/Notifications/notifications.js';
|
|
29
30
|
export { default as Notifications, NotificationsConfig, } from './components/Notifications/Notifications.svelte';
|
|
30
31
|
//
|
|
31
32
|
export { default as Popover } from './components/Popover/Popover.svelte';
|
|
32
33
|
//
|
|
33
|
-
export { default as Switch, SwitchConfig } from './components/Switch/Switch.svelte';
|
|
34
|
+
export { default as Switch, SwitchConfig, } from './components/Switch/Switch.svelte';
|
|
34
35
|
export { default as Thc, isTHCNotEmpty } from './components/Thc/Thc.svelte';
|
|
35
36
|
//
|
|
36
37
|
export { default as X } from './components/X/X.svelte';
|