@cloudparker/moldex.js 0.0.124 → 4.1.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/types.d.ts +6 -0
- package/dist/types.js +7 -0
- package/dist/views/core/button/components/button/button.svelte +135 -83
- package/dist/views/core/button/components/button-back/button-back.svelte +28 -15
- package/dist/views/core/button/components/button-close/button-close.svelte +4 -2
- package/dist/views/core/button/components/button-close-icon/button-close-icon.svelte +29 -15
- package/dist/views/core/button/components/button-dropdown/button-dropdown.svelte +96 -72
- package/dist/views/core/button/components/button-dropdown/button-dropdown.svelte.d.ts +1 -1
- package/dist/views/core/button/components/button-list-item/button-list-item.svelte +98 -52
- package/dist/views/core/button/components/button-menu/button-menu.svelte +79 -43
- package/dist/views/core/button/components/button-ok/button-ok.svelte +4 -2
- package/dist/views/core/button/components/button-search/button-search.svelte +45 -21
- package/dist/views/core/button/components/switch/switch.svelte +50 -37
- package/dist/views/core/common/components/content-area/content-area.svelte +40 -27
- package/dist/views/core/common/components/loading/loading.svelte +9 -2
- package/dist/views/core/common/components/virtual-scrolling/virtual-scrolling-list.svelte +37 -20
- package/dist/views/core/dialog/components/cropper-dialog/cropper-dialog.svelte +52 -36
- package/dist/views/core/dialog/components/dialog/dialog.svelte +298 -177
- package/dist/views/core/dialog/components/loading-dialog/loading-dialog.svelte +30 -18
- package/dist/views/core/dialog/components/msg-dialog/msg-dialog.svelte +17 -7
- package/dist/views/core/dialog/components/number-field-dialog/number-field-dialog.svelte +41 -26
- package/dist/views/core/dialog/components/picker-dialog/picker-dialog.svelte +150 -105
- package/dist/views/core/dialog/components/text-field-dialog/text-field-dialog.svelte +40 -25
- package/dist/views/core/dialog/components/textarea-field-dialog/textarea-field-dialog.svelte +40 -25
- package/dist/views/core/drawer/components/drawer/drawer.svelte +58 -36
- package/dist/views/core/icon/components/icon/icon.svelte +24 -12
- package/dist/views/core/icon/components/icon-circle/icon-circle.svelte +10 -2
- package/dist/views/core/input/components/checkbox-field/checkbox-field.svelte +44 -25
- package/dist/views/core/input/components/color-field/color-field.svelte +81 -69
- package/dist/views/core/input/components/combobox-field/combobox-field.svelte +359 -269
- package/dist/views/core/input/components/date-field/date-field.svelte +39 -30
- package/dist/views/core/input/components/datetime-field/datetime-field.svelte +18 -12
- package/dist/views/core/input/components/email-field/email-field.svelte +17 -12
- package/dist/views/core/input/components/file-field/file-field.svelte +78 -64
- package/dist/views/core/input/components/input-field/input-field.svelte +267 -164
- package/dist/views/core/input/components/label/label.svelte +24 -10
- package/dist/views/core/input/components/number-field/number-field.svelte +18 -12
- package/dist/views/core/input/components/password-field/password-field.svelte +70 -57
- package/dist/views/core/input/components/phone-field/phone-field.svelte +155 -104
- package/dist/views/core/input/components/radio-field/radio-field.svelte +83 -52
- package/dist/views/core/input/components/range-field/range-field.svelte +67 -44
- package/dist/views/core/input/components/search-field/search-field.svelte +62 -45
- package/dist/views/core/input/components/text-field/text-field.svelte +21 -16
- package/dist/views/core/input/components/textarea-field/textarea-field.svelte +17 -12
- package/dist/views/core/input/components/time-field/time-field.svelte +17 -12
- package/dist/views/core/navbar/components/navbar/navbar.svelte +76 -38
- package/dist/views/core/no-data/components/no-data/no-data.svelte +36 -19
- package/dist/views/core/pagination/components/pagination/pagination.svelte +90 -66
- package/dist/views/core/progressbar/components/progressbar/progressbar.svelte +36 -22
- package/dist/views/core/ruler/components/vertical-ruler/verticcal-ruler.svelte +5 -1
- package/dist/views/core/screen-detector/components/screen-detector.svelte +13 -9
- package/dist/views/core/sidebar/components/sidebar.svelte +36 -23
- package/dist/views/core/spinner/components/spinner/spinner.svelte +6 -1
- package/dist/views/core/text/components/text-await/text-await.svelte +9 -1
- package/dist/views/core/text/components/text-copy/text-copy.svelte +27 -16
- package/dist/views/core/text/components/text-currency/text-currency.svelte +13 -2
- package/dist/views/core/text/components/text-date/text-date.svelte +32 -20
- package/dist/views/core/text/components/text-email/text-email.svelte +12 -3
- package/dist/views/core/text/components/text-html/text-html.svelte +2 -1
- package/dist/views/core/text/components/text-phone/text-phone.svelte +12 -3
- package/dist/views/core/toast/components/toast/toast.svelte +43 -20
- package/dist/views/extra/fields/country-combobox-field.svelte +23 -15
- package/dist/views/extra/loaders/country-loader.svelte +33 -15
- package/dist/views/extra/texts/text-country-state.svelte +36 -28
- package/dist/views/extra/texts/text-country.svelte +16 -8
- package/package.json +3 -12
- package/readme.md +57 -2
- package/dist/tailwind.css +0 -1
- package/dist/theme.css +0 -27
|
@@ -1,40 +1,56 @@
|
|
|
1
|
-
<script module lang="ts"
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export type CropperDialogPropsType = {
|
|
3
|
+
outputAspectRatio?: number;
|
|
4
|
+
outputWidth?: number;
|
|
5
|
+
outputFormat?: OutputImageFormats;
|
|
6
|
+
outputQuality?: number;
|
|
7
|
+
outputType?: 'file' | 'base64';
|
|
8
|
+
inputImageFile?: File | null;
|
|
9
|
+
className?: string;
|
|
10
|
+
};
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
import EasyCropperjs from '@cloudparker/easy-cropperjs-svelte';
|
|
15
|
+
import type { DialogExports } from '../dialog/dialog.svelte';
|
|
16
|
+
import { OutputImageFormatEnum, type OutputImageFormats } from '../../../../../services';
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
outputWidth,
|
|
20
|
+
outputFormat = OutputImageFormatEnum.WEBP,
|
|
21
|
+
outputQuality = 0.8,
|
|
22
|
+
outputType = 'file',
|
|
23
|
+
inputImageFile,
|
|
24
|
+
outputAspectRatio,
|
|
25
|
+
className,
|
|
26
|
+
setOnOkClick,
|
|
27
|
+
setResult,
|
|
28
|
+
closeDialog,
|
|
29
|
+
setOnData,
|
|
30
|
+
...props
|
|
31
|
+
}: CropperDialogPropsType & DialogExports = $props();
|
|
32
|
+
|
|
33
|
+
let easyCropperjsRef: EasyCropperjs | null = $state(null);
|
|
34
|
+
|
|
35
|
+
setOnOkClick(async () => {
|
|
36
|
+
console.log('setOnOkClick', easyCropperjsRef);
|
|
37
|
+
if (easyCropperjsRef) {
|
|
38
|
+
let targetOutoutImageFormat: any = outputFormat.split('/')[1] || 'webp';
|
|
39
|
+
let res = await easyCropperjsRef.crop({
|
|
40
|
+
outputWidth,
|
|
41
|
+
outputFormat: targetOutoutImageFormat,
|
|
42
|
+
outputQuality,
|
|
43
|
+
outputType
|
|
44
|
+
});
|
|
45
|
+
console.log('res', res);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
2
48
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
outputQuality = 0.8,
|
|
9
|
-
outputType = "file",
|
|
10
|
-
inputImageFile,
|
|
11
|
-
outputAspectRatio,
|
|
12
|
-
className,
|
|
13
|
-
setOnOkClick,
|
|
14
|
-
setResult,
|
|
15
|
-
closeDialog,
|
|
16
|
-
setOnData,
|
|
17
|
-
...props
|
|
18
|
-
} = $props();
|
|
19
|
-
let easyCropperjsRef = $state(null);
|
|
20
|
-
setOnOkClick(async () => {
|
|
21
|
-
console.log("setOnOkClick", easyCropperjsRef);
|
|
22
|
-
if (easyCropperjsRef) {
|
|
23
|
-
let targetOutoutImageFormat = outputFormat.split("/")[1] || "webp";
|
|
24
|
-
let res = await easyCropperjsRef.crop({
|
|
25
|
-
outputWidth,
|
|
26
|
-
outputFormat: targetOutoutImageFormat,
|
|
27
|
-
outputQuality,
|
|
28
|
-
outputType
|
|
29
|
-
});
|
|
30
|
-
console.log("res", res);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
function handleCropped(result) {
|
|
34
|
-
console.log("handleCropped", result);
|
|
35
|
-
setResult(result);
|
|
36
|
-
closeDialog();
|
|
37
|
-
}
|
|
49
|
+
function handleCropped(result: any) {
|
|
50
|
+
console.log('handleCropped', result);
|
|
51
|
+
setResult(result);
|
|
52
|
+
closeDialog();
|
|
53
|
+
}
|
|
38
54
|
</script>
|
|
39
55
|
|
|
40
56
|
<div class="h-full w-full overflow-hidden {className}">
|
|
@@ -1,182 +1,303 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import ButtonBack from '../../../button/components/button-back/button-back.svelte';
|
|
3
|
+
import ButtonClose from '../../../button/components/button-close-icon/button-close-icon.svelte';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Return a Promise<boolean> value, whic=h will indiacate dialog to close or not.
|
|
7
|
+
* false -> Dont close Dialog
|
|
8
|
+
* true -> Close dialog
|
|
9
|
+
*/
|
|
10
|
+
type DialogCloseButtonClickFunction = (ev: MouseEvent | TouchEvent) => Promise<boolean>;
|
|
11
|
+
|
|
12
|
+
export type DialogSize =
|
|
13
|
+
| DialogSizeEnum.XS
|
|
14
|
+
| DialogSizeEnum.SM
|
|
15
|
+
| DialogSizeEnum.MD
|
|
16
|
+
| DialogSizeEnum.LG
|
|
17
|
+
| DialogSizeEnum.XL
|
|
18
|
+
| DialogSizeEnum.FULL;
|
|
19
|
+
|
|
20
|
+
export type DialogProps = {
|
|
21
|
+
backdropClassName?: string;
|
|
22
|
+
bodyClassName?: string;
|
|
23
|
+
bodyComponent?: any;
|
|
24
|
+
cancelable?: boolean;
|
|
25
|
+
scrollable?: boolean;
|
|
26
|
+
children?: Snippet;
|
|
27
|
+
className?: string;
|
|
28
|
+
component?: any;
|
|
29
|
+
containerClassName?: string;
|
|
30
|
+
footerClassName?: string;
|
|
31
|
+
footerCloseButtonClassName?: string;
|
|
32
|
+
footerCloseButtonLabel?: string;
|
|
33
|
+
footerOkButtonClassName?: string;
|
|
34
|
+
footerOkButtonEnabled?: boolean;
|
|
35
|
+
footerOkButtonSpinner?: boolean;
|
|
36
|
+
footerOkButtonType?: 'button' | 'submit' | 'reset';
|
|
37
|
+
footerOkButtonLabel?: string;
|
|
38
|
+
hasFooter?: boolean;
|
|
39
|
+
hasFooterCloseButton?: boolean;
|
|
40
|
+
hasFooterOkButton?: boolean;
|
|
41
|
+
hasFooterShadow?: boolean;
|
|
42
|
+
hasHeader?: boolean;
|
|
43
|
+
hasHeaderBack?: boolean;
|
|
44
|
+
hasHeaderClose?: boolean;
|
|
45
|
+
hasHeaderShadow?: boolean;
|
|
46
|
+
hasSubtitle?: boolean;
|
|
47
|
+
hasTitle?: boolean;
|
|
48
|
+
hasHeaderOkButton?: boolean;
|
|
49
|
+
headerBackButtonClassName?: string;
|
|
50
|
+
headerBackIconClassName?: string;
|
|
51
|
+
headerBackIconPath?: string;
|
|
52
|
+
headerClassName?: string;
|
|
53
|
+
headerCloseButtonClassName?: string;
|
|
54
|
+
headerCloseIconClassName?: string;
|
|
55
|
+
headerCloseIconPath?: string;
|
|
56
|
+
headerOkButtonClassName?: string;
|
|
57
|
+
headerOkButtonLabel?: string;
|
|
58
|
+
headerOkButtonIconPath?: string;
|
|
59
|
+
headerOkButtonIconClassName?: string;
|
|
60
|
+
id?: string;
|
|
61
|
+
onClose?: () => void;
|
|
62
|
+
onCloseClick?: DialogCloseButtonClickFunction;
|
|
63
|
+
onOkClick?: (ev: MouseEvent | TouchEvent, options: DialogExports) => void;
|
|
64
|
+
onResult?: (value: any) => void;
|
|
65
|
+
onData?: (data: any) => void;
|
|
66
|
+
props?: any;
|
|
67
|
+
size?: DialogSize;
|
|
68
|
+
targetFormId?: string;
|
|
69
|
+
subtitle?: string;
|
|
70
|
+
subtitleClassName?: string;
|
|
71
|
+
title?: string;
|
|
72
|
+
titleClassName?: string;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export type DialogExports = {
|
|
76
|
+
closeDialog: (result?: any) => void;
|
|
77
|
+
setResult: (result: any) => void;
|
|
78
|
+
setOkSpinner: (enable: boolean) => void;
|
|
79
|
+
setOkEnabled: (enable: boolean) => void;
|
|
80
|
+
setOnOkClick: (onclick: (ev: MouseEvent | TouchEvent) => void) => void;
|
|
81
|
+
setOnCloseClick: (onclick: DialogCloseButtonClickFunction) => void;
|
|
82
|
+
setOnData: (listener: (data: any) => void) => void;
|
|
83
|
+
setHeaderSnippet: (snippet: Snippet) => void;
|
|
84
|
+
setFooterSnippet: (snippet: Snippet) => void;
|
|
85
|
+
setDialogTitle: (title: string) => void;
|
|
86
|
+
};
|
|
3
87
|
</script>
|
|
4
88
|
|
|
5
|
-
<script lang="ts">
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
let
|
|
81
|
-
let
|
|
82
|
-
|
|
83
|
-
let
|
|
84
|
-
let
|
|
85
|
-
|
|
86
|
-
let
|
|
87
|
-
|
|
88
|
-
let
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
let
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
export function
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
function
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
function
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
function
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
89
|
+
<script lang="ts">
|
|
90
|
+
import Button from '../../../button/components/button/button.svelte';
|
|
91
|
+
import { type Component as ComponetType, type Snippet } from 'svelte';
|
|
92
|
+
import { mdiArrowLeft, mdiClose } from '../../../icon';
|
|
93
|
+
import { DialogSizeEnum, isMobileScreen } from '../../../../../services';
|
|
94
|
+
|
|
95
|
+
let {
|
|
96
|
+
backdropClassName = '',
|
|
97
|
+
bodyClassName = '',
|
|
98
|
+
bodyComponent,
|
|
99
|
+
cancelable = true,
|
|
100
|
+
scrollable = true,
|
|
101
|
+
children,
|
|
102
|
+
className = '',
|
|
103
|
+
component,
|
|
104
|
+
containerClassName = '',
|
|
105
|
+
footerClassName = '',
|
|
106
|
+
footerCloseButtonClassName = '',
|
|
107
|
+
footerCloseButtonLabel = 'Close',
|
|
108
|
+
footerOkButtonClassName = '',
|
|
109
|
+
footerOkButtonEnabled = true,
|
|
110
|
+
footerOkButtonSpinner = false,
|
|
111
|
+
footerOkButtonType = 'button',
|
|
112
|
+
footerOkButtonLabel = 'Save',
|
|
113
|
+
hasFooter = false,
|
|
114
|
+
hasFooterCloseButton = false,
|
|
115
|
+
hasFooterOkButton = false,
|
|
116
|
+
hasFooterShadow = false,
|
|
117
|
+
hasHeader = false,
|
|
118
|
+
hasHeaderOkButton = false,
|
|
119
|
+
|
|
120
|
+
hasHeaderShadow = false,
|
|
121
|
+
hasSubtitle = false,
|
|
122
|
+
hasTitle = false,
|
|
123
|
+
headerOkButtonClassName = '',
|
|
124
|
+
headerOkButtonLabel = '',
|
|
125
|
+
headerOkButtonIconPath = '',
|
|
126
|
+
headerOkButtonIconClassName = '',
|
|
127
|
+
headerBackButtonClassName = '',
|
|
128
|
+
headerBackIconClassName = '',
|
|
129
|
+
headerBackIconPath = mdiArrowLeft,
|
|
130
|
+
headerClassName = '',
|
|
131
|
+
headerCloseButtonClassName = '',
|
|
132
|
+
headerCloseIconClassName = '',
|
|
133
|
+
headerCloseIconPath = mdiClose,
|
|
134
|
+
hasHeaderBack = isMobileScreen(),
|
|
135
|
+
hasHeaderClose = !isMobileScreen(),
|
|
136
|
+
size = isMobileScreen() ? DialogSizeEnum.FULL : DialogSizeEnum.SM,
|
|
137
|
+
id = '',
|
|
138
|
+
onClose,
|
|
139
|
+
onCloseClick,
|
|
140
|
+
onOkClick,
|
|
141
|
+
onResult,
|
|
142
|
+
onData,
|
|
143
|
+
props = {},
|
|
144
|
+
targetFormId = undefined,
|
|
145
|
+
subtitle = '',
|
|
146
|
+
subtitleClassName = '',
|
|
147
|
+
title = '',
|
|
148
|
+
titleClassName = ''
|
|
149
|
+
}: DialogProps = $props();
|
|
150
|
+
|
|
151
|
+
let dialogExports: DialogExports = {
|
|
152
|
+
closeDialog,
|
|
153
|
+
setResult,
|
|
154
|
+
setOkSpinner,
|
|
155
|
+
setOkEnabled,
|
|
156
|
+
setOnCloseClick,
|
|
157
|
+
setOnOkClick,
|
|
158
|
+
setOnData,
|
|
159
|
+
setHeaderSnippet,
|
|
160
|
+
setFooterSnippet,
|
|
161
|
+
setDialogTitle
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
let isPlaced: boolean = $state(false);
|
|
165
|
+
let isOpened: boolean = $state(false);
|
|
166
|
+
|
|
167
|
+
let headerSnippet: Snippet | null = $state(null);
|
|
168
|
+
let footerSnippet: Snippet | null = $state(null);
|
|
169
|
+
|
|
170
|
+
let CustomComponent: ComponetType | null = $derived(component);
|
|
171
|
+
|
|
172
|
+
let BodyComponent: ComponetType | null = $derived(bodyComponent);
|
|
173
|
+
|
|
174
|
+
let result: any;
|
|
175
|
+
|
|
176
|
+
let xsSizeClassName = 'w-64';
|
|
177
|
+
let smSizeClassName = 'w-96';
|
|
178
|
+
let mdSizeClassName = 'w-1/3';
|
|
179
|
+
let lgSizeClassName = 'w-1/2';
|
|
180
|
+
let xlSizeClassName = 'w-7/10';
|
|
181
|
+
let fullSizeClassName = 'fixed inset-0 w-screen h-screen ';
|
|
182
|
+
|
|
183
|
+
let screenSizeClassNameMap: { [key: string]: string } = {
|
|
184
|
+
xs: xsSizeClassName,
|
|
185
|
+
sm: smSizeClassName,
|
|
186
|
+
md: mdSizeClassName,
|
|
187
|
+
lg: lgSizeClassName,
|
|
188
|
+
xl: xlSizeClassName,
|
|
189
|
+
full: fullSizeClassName
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
let customTitle: string = $state('');
|
|
193
|
+
|
|
194
|
+
export function toggleDialog() {
|
|
195
|
+
if (isOpened) {
|
|
196
|
+
closeDialog();
|
|
197
|
+
} else {
|
|
198
|
+
openDialog();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export function openDialog() {
|
|
203
|
+
isPlaced = true;
|
|
204
|
+
|
|
205
|
+
// Disable background scroll
|
|
206
|
+
document.body.style.overflow = 'hidden';
|
|
207
|
+
|
|
208
|
+
setTimeout(() => {
|
|
209
|
+
isOpened = true;
|
|
210
|
+
}, 0);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export function closeDialog(value?: any): Promise<any> {
|
|
214
|
+
return new Promise((resolve) => {
|
|
215
|
+
isOpened = false;
|
|
216
|
+
|
|
217
|
+
// Re-enable background scroll
|
|
218
|
+
document.body.style.overflow = '';
|
|
219
|
+
|
|
220
|
+
setTimeout(() => {
|
|
221
|
+
isPlaced = false;
|
|
222
|
+
onClose && onClose();
|
|
223
|
+
onResult && onResult(result || value);
|
|
224
|
+
resolve(result);
|
|
225
|
+
}, 300);
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export function setResult(value: any) {
|
|
230
|
+
result = value;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export function setOkEnabled(value: boolean) {
|
|
234
|
+
footerOkButtonEnabled = value;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export function setOkSpinner(value: boolean) {
|
|
238
|
+
footerOkButtonSpinner = value;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export function setOnData(listener: (data: any) => void) {
|
|
242
|
+
onData = listener;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export function setOnOkClick(
|
|
246
|
+
onclick: (event: MouseEvent | TouchEvent, options: DialogExports) => void
|
|
247
|
+
) {
|
|
248
|
+
onOkClick = onclick;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export function setOnCloseClick(onclick: DialogCloseButtonClickFunction) {
|
|
252
|
+
onCloseClick = onclick;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export function postData(data: any) {
|
|
256
|
+
onData && onData(data);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export function setHeaderSnippet(snippet: Snippet) {
|
|
260
|
+
headerSnippet = snippet;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export function setFooterSnippet(snippet: Snippet) {
|
|
264
|
+
footerSnippet = snippet;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export function setDialogTitle(dialogTitle: string) {
|
|
268
|
+
customTitle = dialogTitle;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function handleBackdropClick() {
|
|
272
|
+
if (cancelable) {
|
|
273
|
+
closeDialog();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
async function handleClose(ev: MouseEvent | TouchEvent) {
|
|
278
|
+
if (onCloseClick) {
|
|
279
|
+
if (await onCloseClick(ev)) {
|
|
280
|
+
closeDialog();
|
|
281
|
+
}
|
|
282
|
+
} else {
|
|
283
|
+
closeDialog();
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function handleKeyDown(event: KeyboardEvent) {
|
|
288
|
+
if (event.key === 'Escape' || event.key === 'Esc') {
|
|
289
|
+
if (cancelable) {
|
|
290
|
+
event.stopPropagation();
|
|
291
|
+
closeDialog();
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function handleOkClick(event: MouseEvent | TouchEvent) {
|
|
297
|
+
if (onOkClick) {
|
|
298
|
+
onOkClick(event, dialogExports);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
180
301
|
</script>
|
|
181
302
|
|
|
182
303
|
{#snippet dialogContent()}
|
|
@@ -1,21 +1,33 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Spinner } from '../../../spinner';
|
|
3
|
+
import type { DialogExports } from '../dialog/dialog.svelte';
|
|
4
|
+
|
|
5
|
+
type PropsType = {
|
|
6
|
+
msg?: string;
|
|
7
|
+
msgClassName?: string;
|
|
8
|
+
spinnerClassName?: string;
|
|
9
|
+
containerClassName?: string;
|
|
10
|
+
className?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
let {
|
|
14
|
+
msg = 'Please wait...',
|
|
15
|
+
msgClassName,
|
|
16
|
+
spinnerClassName,
|
|
17
|
+
containerClassName,
|
|
18
|
+
className,
|
|
19
|
+
setOnOkClick,
|
|
20
|
+
setResult,
|
|
21
|
+
closeDialog,
|
|
22
|
+
setOnData,
|
|
23
|
+
...props
|
|
24
|
+
}: PropsType & DialogExports = $props();
|
|
25
|
+
|
|
26
|
+
setOnData((data: any) => {
|
|
27
|
+
if (data?.msg) {
|
|
28
|
+
msg = data?.msg || '';
|
|
29
|
+
}
|
|
30
|
+
});
|
|
19
31
|
</script>
|
|
20
32
|
|
|
21
33
|
<div class="p-6 {containerClassName}">
|
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { DialogExports } from '../dialog/dialog.svelte';
|
|
3
|
+
|
|
4
|
+
type PropsType = {
|
|
5
|
+
className?: string;
|
|
6
|
+
msg?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
let { className, msg, setOnOkClick, setResult, closeDialog }: PropsType & DialogExports =
|
|
10
|
+
$props();
|
|
11
|
+
|
|
12
|
+
$effect(() => {
|
|
13
|
+
setOnOkClick(() => {
|
|
14
|
+
setResult(true);
|
|
15
|
+
closeDialog();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
8
18
|
</script>
|
|
9
19
|
|
|
10
20
|
<div class="p-6 text-base-800 dark:text-base-300 {className}">
|