@cloudparker/moldex.js 0.0.1
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/badge.d.ts +12 -0
- package/dist/actions/badge.js +22 -0
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/index.js +2 -0
- package/dist/actions/ripple.d.ts +16 -0
- package/dist/actions/ripple.js +78 -0
- package/dist/button/components/button/button.svelte +59 -0
- package/dist/button/components/button/button.svelte.d.ts +36 -0
- package/dist/button/components/button-list-item/button-list-item.svelte +119 -0
- package/dist/button/components/button-list-item/button-list-item.svelte.d.ts +60 -0
- package/dist/button/components/button-menu/button-menu.svelte +185 -0
- package/dist/button/components/button-menu/button-menu.svelte.d.ts +61 -0
- package/dist/button/index.d.ts +3 -0
- package/dist/button/index.js +3 -0
- package/dist/common/components/drawer/drawer.svelte +61 -0
- package/dist/common/components/drawer/drawer.svelte.d.ts +31 -0
- package/dist/common/components/navbar/navbar.svelte +82 -0
- package/dist/common/components/navbar/navbar.svelte.d.ts +46 -0
- package/dist/common/components/spinner/spinner.svelte +16 -0
- package/dist/common/components/spinner/spinner.svelte.d.ts +20 -0
- package/dist/common/components/vertical-rule/verticcal-rule.svelte +4 -0
- package/dist/common/components/vertical-rule/verticcal-rule.svelte.d.ts +20 -0
- package/dist/common/index.d.ts +4 -0
- package/dist/common/index.js +4 -0
- package/dist/dialog/components/dialog/dialog.svelte +253 -0
- package/dist/dialog/components/dialog/dialog.svelte.d.ts +80 -0
- package/dist/dialog/index.d.ts +2 -0
- package/dist/dialog/index.js +2 -0
- package/dist/dialog/services/dialog-service.d.ts +2 -0
- package/dist/dialog/services/dialog-service.js +25 -0
- package/dist/icon/components/icon/icon.svelte +15 -0
- package/dist/icon/components/icon/icon.svelte.d.ts +24 -0
- package/dist/icon/index.d.ts +2 -0
- package/dist/icon/index.js +2 -0
- package/dist/icon/services/icon-path-service.d.ts +9 -0
- package/dist/icon/services/icon-path-service.js +10 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/package.json +32 -0
- package/readme.md +3 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<script lang="ts">let {
|
|
2
|
+
id = "",
|
|
3
|
+
children,
|
|
4
|
+
backdropClassName = "",
|
|
5
|
+
className = "bg-indigo-600 text-white",
|
|
6
|
+
containerClassName = "",
|
|
7
|
+
drawerContainerClassName = "",
|
|
8
|
+
drawerClassName = ""
|
|
9
|
+
} = $props();
|
|
10
|
+
let isPlaced = $state(false);
|
|
11
|
+
let isOpened = $state(false);
|
|
12
|
+
function handelBackdropClick() {
|
|
13
|
+
toggleDrawer();
|
|
14
|
+
}
|
|
15
|
+
export function toggleDrawer() {
|
|
16
|
+
if (!isPlaced) {
|
|
17
|
+
openDrawer();
|
|
18
|
+
} else {
|
|
19
|
+
closeDrawer();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function openDrawer() {
|
|
23
|
+
isPlaced = true;
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
isOpened = true;
|
|
26
|
+
}, 0);
|
|
27
|
+
}
|
|
28
|
+
export function closeDrawer() {
|
|
29
|
+
isOpened = false;
|
|
30
|
+
setTimeout(() => {
|
|
31
|
+
isPlaced = false;
|
|
32
|
+
}, 300);
|
|
33
|
+
}
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
{#if isPlaced}
|
|
37
|
+
<div {id} class="relative z-50 {containerClassName}" role="dialog" aria-modal="true">
|
|
38
|
+
<!-- Backdrop -->
|
|
39
|
+
<div
|
|
40
|
+
class="fixed inset-0 bg-gray-900/10 transition-opacity ease-linear duration-300 {isOpened
|
|
41
|
+
? 'opacity-100'
|
|
42
|
+
: 'opacity-0'} {backdropClassName}"
|
|
43
|
+
aria-hidden="true"
|
|
44
|
+
></div>
|
|
45
|
+
<!-- Drawer -->
|
|
46
|
+
<div class="fixed inset-0 flex {drawerContainerClassName}">
|
|
47
|
+
<div
|
|
48
|
+
class="relative flex w-full max-w-xs flex-1 transition ease-in-out duration-300 transform {isOpened
|
|
49
|
+
? 'translate-x-0'
|
|
50
|
+
: '-translate-x-full'} {drawerClassName}"
|
|
51
|
+
>
|
|
52
|
+
<div class="flex grow flex-col gap-y-5 overflow-y-auto w-72 {className}">
|
|
53
|
+
{#if children}
|
|
54
|
+
{@render children()}
|
|
55
|
+
{/if}
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
<button class="flex-grow cursor-auto" type="button" onclick={handelBackdropClick}></button>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
{/if}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const Drawer: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
+
children?: Snippet;
|
|
17
|
+
id?: string;
|
|
18
|
+
backdropClassName?: string;
|
|
19
|
+
className?: string;
|
|
20
|
+
containerClassName?: string;
|
|
21
|
+
drawerContainerClassName?: string;
|
|
22
|
+
drawerClassName?: string;
|
|
23
|
+
}, {
|
|
24
|
+
[evt: string]: CustomEvent<any>;
|
|
25
|
+
}, {}, {
|
|
26
|
+
toggleDrawer: () => void;
|
|
27
|
+
openDrawer: () => void;
|
|
28
|
+
closeDrawer: () => void;
|
|
29
|
+
}, "">;
|
|
30
|
+
type Drawer = InstanceType<typeof Drawer>;
|
|
31
|
+
export default Drawer;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<script lang="ts">import Button from "../../../button/components/button/button.svelte";
|
|
2
|
+
import Icon from "../../../icon/components/icon/icon.svelte";
|
|
3
|
+
import { mdiMenu } from "../../../icon/services/icon-path-service.js";
|
|
4
|
+
let {
|
|
5
|
+
id = "",
|
|
6
|
+
children,
|
|
7
|
+
leftChildren,
|
|
8
|
+
centerChildren,
|
|
9
|
+
rightChildren,
|
|
10
|
+
className = "",
|
|
11
|
+
drawerIconPath = mdiMenu,
|
|
12
|
+
drawerButtonClassName = "",
|
|
13
|
+
hasDrawer = false,
|
|
14
|
+
hasLogo = false,
|
|
15
|
+
logoButtonClassName = "",
|
|
16
|
+
logoIconPath,
|
|
17
|
+
logoIconClassName = "text-indigo-600",
|
|
18
|
+
logoImgSrc,
|
|
19
|
+
logoImgClassName = "",
|
|
20
|
+
leftContainerClassName = "",
|
|
21
|
+
centerContainerClassName = "",
|
|
22
|
+
rightContainerClassName = "",
|
|
23
|
+
title = "",
|
|
24
|
+
subtitle = "",
|
|
25
|
+
titleClassName = "",
|
|
26
|
+
subtitleClassName = "",
|
|
27
|
+
hasTitle = false,
|
|
28
|
+
hasSubtitle = false,
|
|
29
|
+
ondrawer,
|
|
30
|
+
onlogo
|
|
31
|
+
} = $props();
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<div
|
|
35
|
+
class="sticky top-0 z-10 flex h-16 shrink-0 items-center px-2 border-b border-gray-200 bg-white shadow-sm {className}"
|
|
36
|
+
>
|
|
37
|
+
{#if children}
|
|
38
|
+
{@render children()}
|
|
39
|
+
{:else}
|
|
40
|
+
{#if hasDrawer}
|
|
41
|
+
<Button
|
|
42
|
+
className="h-full px-2 text-gray-500 hover:text-gray-600 {drawerButtonClassName}"
|
|
43
|
+
iconPath={drawerIconPath}
|
|
44
|
+
disabled={!ondrawer}
|
|
45
|
+
onclick={ondrawer}
|
|
46
|
+
></Button>
|
|
47
|
+
{/if}
|
|
48
|
+
{#if hasLogo}
|
|
49
|
+
<Button className="h-full px-2 {logoButtonClassName}" disabled={!onlogo} onclick={onlogo}>
|
|
50
|
+
{#if logoIconPath}
|
|
51
|
+
<Icon path={logoIconPath} className="h-10 w-10 {logoIconClassName}" />
|
|
52
|
+
{/if}
|
|
53
|
+
{#if logoImgSrc}
|
|
54
|
+
<img src={logoImgSrc} class="h-8 w-8 bg-gray-50 {logoImgClassName}" alt="logo" />
|
|
55
|
+
{/if}
|
|
56
|
+
</Button>
|
|
57
|
+
{/if}
|
|
58
|
+
{/if}
|
|
59
|
+
<div>
|
|
60
|
+
{#if hasTitle}
|
|
61
|
+
<div class="font-bold {titleClassName}">{title || ''}</div>
|
|
62
|
+
{/if}
|
|
63
|
+
{#if hasSubtitle}
|
|
64
|
+
<div class="text-sm text-gray-400 {subtitleClassName}">{subtitle || ''}</div>
|
|
65
|
+
{/if}
|
|
66
|
+
</div>
|
|
67
|
+
<div class={leftContainerClassName}>
|
|
68
|
+
{#if leftChildren}
|
|
69
|
+
{@render leftChildren()}
|
|
70
|
+
{/if}
|
|
71
|
+
</div>
|
|
72
|
+
<div class="flex-grow flex justify-center {centerContainerClassName}">
|
|
73
|
+
{#if centerChildren}
|
|
74
|
+
{@render centerChildren()}
|
|
75
|
+
{/if}
|
|
76
|
+
</div>
|
|
77
|
+
<div class={rightContainerClassName}>
|
|
78
|
+
{#if rightChildren}
|
|
79
|
+
{@render rightChildren()}
|
|
80
|
+
{/if}
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const Navbar: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
+
id?: string;
|
|
17
|
+
className?: String;
|
|
18
|
+
hasDrawer?: boolean;
|
|
19
|
+
drawerIconPath?: string;
|
|
20
|
+
drawerButtonClassName?: string;
|
|
21
|
+
logoButtonClassName?: string;
|
|
22
|
+
hasLogo?: boolean;
|
|
23
|
+
logoIconPath?: string;
|
|
24
|
+
logoIconClassName?: string;
|
|
25
|
+
logoImgSrc?: string;
|
|
26
|
+
logoImgClassName?: string;
|
|
27
|
+
leftContainerClassName?: string;
|
|
28
|
+
centerContainerClassName?: string;
|
|
29
|
+
rightContainerClassName?: string;
|
|
30
|
+
title?: string;
|
|
31
|
+
subtitle?: string;
|
|
32
|
+
titleClassName?: string;
|
|
33
|
+
subtitleClassName?: string;
|
|
34
|
+
hasTitle?: boolean;
|
|
35
|
+
hasSubtitle?: boolean;
|
|
36
|
+
children?: Snippet;
|
|
37
|
+
leftChildren?: Snippet;
|
|
38
|
+
centerChildren?: Snippet;
|
|
39
|
+
rightChildren?: Snippet;
|
|
40
|
+
ondrawer?: () => void;
|
|
41
|
+
onlogo?: () => void;
|
|
42
|
+
}, {
|
|
43
|
+
[evt: string]: CustomEvent<any>;
|
|
44
|
+
}, {}, {}, "">;
|
|
45
|
+
type Navbar = InstanceType<typeof Navbar>;
|
|
46
|
+
export default Navbar;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script lang="ts">let { className = "" } = $props();
|
|
2
|
+
</script>
|
|
3
|
+
|
|
4
|
+
<svg
|
|
5
|
+
class="animate-spin h-5 w-5 text-gray-900 {className}"
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
fill="none"
|
|
8
|
+
viewBox="0 0 24 24"
|
|
9
|
+
>
|
|
10
|
+
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
|
11
|
+
<path
|
|
12
|
+
class="opacity-75"
|
|
13
|
+
fill="currentColor"
|
|
14
|
+
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
15
|
+
></path>
|
|
16
|
+
</svg>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: Props & {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const Spinner: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
+
className?: string;
|
|
16
|
+
}, {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
}, {}, {}, "">;
|
|
19
|
+
type Spinner = InstanceType<typeof Spinner>;
|
|
20
|
+
export default Spinner;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: Props & {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const VerticcalRule: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
+
className?: string;
|
|
16
|
+
}, {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
}, {}, {}, "">;
|
|
19
|
+
type VerticcalRule = InstanceType<typeof VerticcalRule>;
|
|
20
|
+
export default VerticcalRule;
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
<script lang="ts" context="module"></script>
|
|
2
|
+
|
|
3
|
+
<script lang="ts">import Button from "../../../button/components/button/button.svelte";
|
|
4
|
+
import { mdiArrowLeft, mdiClose } from "../../../icon/services/icon-path-service.js";
|
|
5
|
+
let {
|
|
6
|
+
id = "",
|
|
7
|
+
formId = void 0,
|
|
8
|
+
cancelable = true,
|
|
9
|
+
className = "",
|
|
10
|
+
containerClassName = "",
|
|
11
|
+
backdropClassName = "",
|
|
12
|
+
hasHeaderShadow = false,
|
|
13
|
+
hasTitle = false,
|
|
14
|
+
hasSubtitle = false,
|
|
15
|
+
title = "",
|
|
16
|
+
subtitle = "",
|
|
17
|
+
titleClassName = "",
|
|
18
|
+
subtitleClassName = "",
|
|
19
|
+
hasHeader = false,
|
|
20
|
+
headerClassName = "",
|
|
21
|
+
hasHeaderClose = false,
|
|
22
|
+
headerCloseButtonClassName = "",
|
|
23
|
+
headerCloseIconPath = mdiClose,
|
|
24
|
+
headerCloseIconClassName = "",
|
|
25
|
+
hasHeaderBack = false,
|
|
26
|
+
headerBackButtonClassName = "",
|
|
27
|
+
headerBackIconPath = mdiArrowLeft,
|
|
28
|
+
headerBackIconClassName = "",
|
|
29
|
+
hasFooter = false,
|
|
30
|
+
hasFooterShadow = false,
|
|
31
|
+
hasFooterCloseButton = false,
|
|
32
|
+
hasFooterOkButton = false,
|
|
33
|
+
footerClassName = "",
|
|
34
|
+
footerCloseLabel = "Close",
|
|
35
|
+
footerCloseButtonClassName = "",
|
|
36
|
+
footerOkLable = "Save",
|
|
37
|
+
footerOkButtonClassName = "",
|
|
38
|
+
footerOkButtonType = "button",
|
|
39
|
+
footerOkButtonSpinner = false,
|
|
40
|
+
footerOkButtonDisabled = false,
|
|
41
|
+
size = "sm",
|
|
42
|
+
bodyClassName = "",
|
|
43
|
+
component,
|
|
44
|
+
componetProps = {},
|
|
45
|
+
children,
|
|
46
|
+
headerChildren,
|
|
47
|
+
bodyChildren,
|
|
48
|
+
footerChildren,
|
|
49
|
+
onclose,
|
|
50
|
+
onresult
|
|
51
|
+
} = $props();
|
|
52
|
+
let dialogExports = { closeDialog, setResult, setOkSpinner, setOkDisabled };
|
|
53
|
+
let isPlaced = $state(false);
|
|
54
|
+
let isOpened = $state(false);
|
|
55
|
+
let result;
|
|
56
|
+
let smSizeClassName = "w-11/12 sm:w-3/4 md:w-1/2 lg:w-1/3 xl:w-1/4";
|
|
57
|
+
let mdSizeClassName = "w-11/12 sm:w-3/4 md:w-2/3 lg:w-1/2 xl:w-1/3";
|
|
58
|
+
let lgSizeClassName = "w-11/12 sm:w-3/4 md:w-3/4 lg:w-2/3 xl:w-1/2";
|
|
59
|
+
let fullSizeClassName = "fixed inset-0 w-screen h-screen ";
|
|
60
|
+
let screenSizeClassNameMap = {
|
|
61
|
+
sm: smSizeClassName,
|
|
62
|
+
md: mdSizeClassName,
|
|
63
|
+
lg: lgSizeClassName,
|
|
64
|
+
full: fullSizeClassName
|
|
65
|
+
};
|
|
66
|
+
export function toggleDialog() {
|
|
67
|
+
if (isOpened) {
|
|
68
|
+
closeDialog();
|
|
69
|
+
} else {
|
|
70
|
+
openDialog();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export function openDialog() {
|
|
74
|
+
isPlaced = true;
|
|
75
|
+
setTimeout(() => {
|
|
76
|
+
isOpened = true;
|
|
77
|
+
}, 0);
|
|
78
|
+
}
|
|
79
|
+
export function closeDialog() {
|
|
80
|
+
return new Promise((resolve) => {
|
|
81
|
+
isOpened = false;
|
|
82
|
+
setTimeout(() => {
|
|
83
|
+
isPlaced = false;
|
|
84
|
+
onclose && onclose();
|
|
85
|
+
onresult && onresult(result);
|
|
86
|
+
resolve(result);
|
|
87
|
+
}, 300);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
export function setResult(value) {
|
|
91
|
+
result = value;
|
|
92
|
+
}
|
|
93
|
+
export function setOkDisabled(value) {
|
|
94
|
+
footerOkButtonDisabled = value;
|
|
95
|
+
}
|
|
96
|
+
export function setOkSpinner(value) {
|
|
97
|
+
footerOkButtonSpinner = value;
|
|
98
|
+
}
|
|
99
|
+
function handleBackdropClick() {
|
|
100
|
+
if (cancelable) {
|
|
101
|
+
closeDialog();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function handleClose() {
|
|
105
|
+
closeDialog();
|
|
106
|
+
}
|
|
107
|
+
function handleKeyDown(event) {
|
|
108
|
+
if (event.key === "Escape" || event.key === "Esc") {
|
|
109
|
+
if (cancelable) {
|
|
110
|
+
event.stopPropagation();
|
|
111
|
+
closeDialog();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
</script>
|
|
116
|
+
|
|
117
|
+
{#snippet dialogContent()}
|
|
118
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
119
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
120
|
+
<div
|
|
121
|
+
tabindex="-1"
|
|
122
|
+
class="relative flex flex-col max-h-screen transform overflow-hidden bg-white text-left transition-all outline-none {screenSizeClassNameMap[
|
|
123
|
+
size
|
|
124
|
+
]} {isOpened
|
|
125
|
+
? 'ease-out duration-300 opacity-100 translate-y-0 sm:scale-100'
|
|
126
|
+
: 'ease-in duration-200 opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95'} {size == 'full'
|
|
127
|
+
? ''
|
|
128
|
+
: 'rounded-lg shadow-xl'} {className}"
|
|
129
|
+
onclick={(ev: MouseEvent) => ev.stopPropagation()}
|
|
130
|
+
>
|
|
131
|
+
{#if hasHeader}
|
|
132
|
+
<div
|
|
133
|
+
class="flex items-start gap-4 w-full cursor-default py-2 {hasHeaderShadow
|
|
134
|
+
? 'border-b shadow-sm'
|
|
135
|
+
: ''} {headerClassName}"
|
|
136
|
+
>
|
|
137
|
+
<div>
|
|
138
|
+
{#if hasHeaderBack}
|
|
139
|
+
<Button
|
|
140
|
+
iconPath={headerBackIconPath}
|
|
141
|
+
className="p-3 rounded-full text-gray-500 hover:text-gray-600 hover:bg-gray-50 {headerBackButtonClassName}"
|
|
142
|
+
iconClassName={headerBackIconClassName}
|
|
143
|
+
onclick={handleClose}
|
|
144
|
+
/>
|
|
145
|
+
{/if}
|
|
146
|
+
</div>
|
|
147
|
+
<div class="py-2">
|
|
148
|
+
{#if hasTitle}
|
|
149
|
+
<div class="text-xl {titleClassName}">{title || ''}</div>
|
|
150
|
+
{/if}
|
|
151
|
+
{#if hasSubtitle}
|
|
152
|
+
<div class="text-sm {subtitleClassName}">{subtitle || ''}</div>
|
|
153
|
+
{/if}
|
|
154
|
+
</div>
|
|
155
|
+
<div class="flex-grow">
|
|
156
|
+
{#if headerChildren}
|
|
157
|
+
{@render headerChildren(dialogExports)}
|
|
158
|
+
{/if}
|
|
159
|
+
</div>
|
|
160
|
+
<div>
|
|
161
|
+
{#if hasHeaderClose}
|
|
162
|
+
<Button
|
|
163
|
+
id="close"
|
|
164
|
+
className="p-3 rounded-full text-gray-500 hover:text-gray-600 hover:bg-gray-50 {headerCloseButtonClassName}"
|
|
165
|
+
iconPath={headerCloseIconPath}
|
|
166
|
+
iconClassName={headerCloseIconClassName}
|
|
167
|
+
onclick={handleClose}
|
|
168
|
+
></Button>
|
|
169
|
+
{/if}
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
{/if}
|
|
173
|
+
|
|
174
|
+
<div class="p-4 flex-grow overflow-y-auto {bodyClassName}">
|
|
175
|
+
{#if children}
|
|
176
|
+
{@render children()}
|
|
177
|
+
{:else if bodyChildren}
|
|
178
|
+
{@render bodyChildren(dialogExports)}
|
|
179
|
+
{:else if component}
|
|
180
|
+
<svelte:component this={component} ...componetProps ...dialogExports />
|
|
181
|
+
{/if}
|
|
182
|
+
</div>
|
|
183
|
+
|
|
184
|
+
{#if hasFooter}
|
|
185
|
+
<div
|
|
186
|
+
class="flex items-center justify-end p-4 gap-4 {hasFooterShadow
|
|
187
|
+
? 'border-t'
|
|
188
|
+
: ''} {footerClassName}"
|
|
189
|
+
>
|
|
190
|
+
<div class="flex-grow">
|
|
191
|
+
{#if footerChildren}
|
|
192
|
+
{@render footerChildren(dialogExports)}
|
|
193
|
+
{/if}
|
|
194
|
+
</div>
|
|
195
|
+
{#if hasFooterOkButton}
|
|
196
|
+
<Button
|
|
197
|
+
id="btn-ok"
|
|
198
|
+
form={formId}
|
|
199
|
+
type={formId ? 'submit' : footerOkButtonType}
|
|
200
|
+
className="p-2 px-5 rounded bg-indigo-600 hover:bg-indigo-700 text-white {footerOkButtonClassName}"
|
|
201
|
+
label={footerOkLable}
|
|
202
|
+
disabled={footerOkButtonDisabled}
|
|
203
|
+
spinner={footerOkButtonSpinner}
|
|
204
|
+
spinnerClassName="text-white w-4 h-4"
|
|
205
|
+
/>
|
|
206
|
+
{/if}
|
|
207
|
+
{#if hasFooterCloseButton}
|
|
208
|
+
<Button
|
|
209
|
+
id="btn-close"
|
|
210
|
+
type="button"
|
|
211
|
+
className="p-2 px-5 rounded bg-gray-100 hover:bg-gray-200 {footerCloseButtonClassName}"
|
|
212
|
+
label={footerCloseLabel}
|
|
213
|
+
onclick={handleClose}
|
|
214
|
+
/>
|
|
215
|
+
{/if}
|
|
216
|
+
</div>
|
|
217
|
+
{/if}
|
|
218
|
+
</div>
|
|
219
|
+
{/snippet}
|
|
220
|
+
|
|
221
|
+
{#snippet dialog()}
|
|
222
|
+
<div
|
|
223
|
+
{id}
|
|
224
|
+
class="relative z-20 {containerClassName}"
|
|
225
|
+
aria-labelledby="modal-title"
|
|
226
|
+
role="dialog"
|
|
227
|
+
aria-modal="true"
|
|
228
|
+
>
|
|
229
|
+
<div
|
|
230
|
+
id="backdrop"
|
|
231
|
+
class="fixed inset-0 bg-gray-500/20 transition-opacity {isOpened
|
|
232
|
+
? 'ease-out duration-300 opacity-100'
|
|
233
|
+
: 'ease-in duration-200 opacity-0'} {backdropClassName}"
|
|
234
|
+
aria-hidden="true"
|
|
235
|
+
></div>
|
|
236
|
+
|
|
237
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
238
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
239
|
+
<div
|
|
240
|
+
class="fixed inset-0 z-20 w-screen cursor-auto"
|
|
241
|
+
onclick={handleBackdropClick}
|
|
242
|
+
onkeydown={handleKeyDown}
|
|
243
|
+
>
|
|
244
|
+
<div class="flex min-h-full justify-center items-center">
|
|
245
|
+
{@render dialogContent()}
|
|
246
|
+
</div>
|
|
247
|
+
</div>
|
|
248
|
+
</div>
|
|
249
|
+
{/snippet}
|
|
250
|
+
|
|
251
|
+
{#if isPlaced}
|
|
252
|
+
{@render dialog()}
|
|
253
|
+
{/if}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export type DialogPropsType = {
|
|
2
|
+
id?: string;
|
|
3
|
+
formId?: string | null;
|
|
4
|
+
cancelable?: boolean;
|
|
5
|
+
className?: string;
|
|
6
|
+
containerClassName?: string;
|
|
7
|
+
backdropClassName?: string;
|
|
8
|
+
isFullScreen?: boolean;
|
|
9
|
+
hasTitle?: boolean;
|
|
10
|
+
hasSubtitle?: boolean;
|
|
11
|
+
title?: string;
|
|
12
|
+
subtitle?: string;
|
|
13
|
+
titleClassName?: string;
|
|
14
|
+
subtitleClassName?: string;
|
|
15
|
+
hasHeader?: boolean;
|
|
16
|
+
hasHeaderShadow?: boolean;
|
|
17
|
+
headerClassName?: string;
|
|
18
|
+
hasHeaderClose?: boolean;
|
|
19
|
+
headerCloseButtonClassName?: string;
|
|
20
|
+
headerCloseIconPath?: string;
|
|
21
|
+
headerCloseIconClassName?: string;
|
|
22
|
+
hasHeaderBack?: boolean;
|
|
23
|
+
headerBackButtonClassName?: string;
|
|
24
|
+
headerBackIconPath?: string;
|
|
25
|
+
headerBackIconClassName?: string;
|
|
26
|
+
hasFooter?: boolean;
|
|
27
|
+
hasFooterShadow?: boolean;
|
|
28
|
+
hasFooterCloseButton?: boolean;
|
|
29
|
+
hasFooterOkButton?: boolean;
|
|
30
|
+
footerClassName?: string;
|
|
31
|
+
footerCloseLabel?: string;
|
|
32
|
+
footerCloseButtonClassName?: string;
|
|
33
|
+
footerOkLable?: string;
|
|
34
|
+
footerOkButtonClassName?: string;
|
|
35
|
+
footerOkButtonType?: 'button' | 'submit' | 'reset';
|
|
36
|
+
footerOkButtonSpinner?: boolean;
|
|
37
|
+
footerOkButtonDisabled?: boolean;
|
|
38
|
+
bodyClassName?: string;
|
|
39
|
+
component?: any;
|
|
40
|
+
componetProps?: any;
|
|
41
|
+
size?: 'sm' | 'md' | 'lg' | 'full';
|
|
42
|
+
children?: Snippet;
|
|
43
|
+
headerChildren?: Snippet<[dialogExports: DialogExportsType]>;
|
|
44
|
+
bodyChildren?: Snippet<[dialogExports: DialogExportsType]>;
|
|
45
|
+
footerChildren?: Snippet<[dialogExports: DialogExportsType]>;
|
|
46
|
+
onclose?: () => void;
|
|
47
|
+
onresult?: (value: any) => void;
|
|
48
|
+
};
|
|
49
|
+
export type DialogExportsType = {
|
|
50
|
+
closeDialog: () => void;
|
|
51
|
+
setResult: (value: any) => void;
|
|
52
|
+
setOkSpinner: (value: boolean) => void;
|
|
53
|
+
setOkDisabled: (value: boolean) => void;
|
|
54
|
+
};
|
|
55
|
+
import type { Snippet } from 'svelte';
|
|
56
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
57
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
58
|
+
$$bindings?: Bindings;
|
|
59
|
+
} & Exports;
|
|
60
|
+
(internal: unknown, props: Props & {
|
|
61
|
+
$$events?: Events;
|
|
62
|
+
$$slots?: Slots;
|
|
63
|
+
}): Exports & {
|
|
64
|
+
$set?: any;
|
|
65
|
+
$on?: any;
|
|
66
|
+
};
|
|
67
|
+
z_$$bindings?: Bindings;
|
|
68
|
+
}
|
|
69
|
+
declare const Dialog: $$__sveltets_2_IsomorphicComponent<DialogPropsType, {
|
|
70
|
+
[evt: string]: CustomEvent<any>;
|
|
71
|
+
}, {}, {
|
|
72
|
+
toggleDialog: () => void;
|
|
73
|
+
openDialog: () => void;
|
|
74
|
+
closeDialog: () => Promise<any>;
|
|
75
|
+
setResult: (value: any) => void;
|
|
76
|
+
setOkDisabled: (value: boolean) => void;
|
|
77
|
+
setOkSpinner: (value: boolean) => void;
|
|
78
|
+
}, "">;
|
|
79
|
+
type Dialog = InstanceType<typeof Dialog>;
|
|
80
|
+
export default Dialog;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { mount, unmount } from 'svelte';
|
|
2
|
+
import Dialog, {} from '../components/dialog/dialog.svelte';
|
|
3
|
+
function addDialog(props) {
|
|
4
|
+
const dialog = mount(Dialog, { target: document.getElementsByTagName('body')[0], props });
|
|
5
|
+
dialog.openDialog();
|
|
6
|
+
return dialog;
|
|
7
|
+
}
|
|
8
|
+
export function openDialog(props = {}) {
|
|
9
|
+
return new Promise((resolve) => {
|
|
10
|
+
let dialog = addDialog({ ...props, onclose, onresult, });
|
|
11
|
+
function onclose() {
|
|
12
|
+
if (dialog) {
|
|
13
|
+
if (props.onclose) {
|
|
14
|
+
props.onclose();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function onresult(value) {
|
|
19
|
+
resolve(value);
|
|
20
|
+
if (props.onresult) {
|
|
21
|
+
onresult(value);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script lang="ts">let {
|
|
2
|
+
path,
|
|
3
|
+
className = "",
|
|
4
|
+
size = 24,
|
|
5
|
+
fill = "currentColor",
|
|
6
|
+
viewBox = ""
|
|
7
|
+
} = $props();
|
|
8
|
+
$effect(() => {
|
|
9
|
+
viewBox = viewBox || `0 0 ${size} ${size}`;
|
|
10
|
+
});
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<svg class=" h-6 w-6 align-middle {className}" {viewBox} fill="currentColor">
|
|
14
|
+
<path d={path} />
|
|
15
|
+
</svg>
|