@cloudparker/moldex.js 0.0.124 → 4.1.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/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
package/dist/types.d.ts
ADDED
package/dist/types.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var DropdownStateEnum;
|
|
2
|
+
(function (DropdownStateEnum) {
|
|
3
|
+
DropdownStateEnum[DropdownStateEnum["OPEN"] = 0] = "OPEN";
|
|
4
|
+
DropdownStateEnum[DropdownStateEnum["OPENED"] = 1] = "OPENED";
|
|
5
|
+
DropdownStateEnum[DropdownStateEnum["CLOSE"] = 2] = "CLOSE";
|
|
6
|
+
DropdownStateEnum[DropdownStateEnum["CLOSED"] = 3] = "CLOSED";
|
|
7
|
+
})(DropdownStateEnum || (DropdownStateEnum = {}));
|
|
@@ -1,87 +1,139 @@
|
|
|
1
|
-
<script module lang="ts"
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export type ButtonAppearance =
|
|
3
|
+
| 'none'
|
|
4
|
+
| 'primary'
|
|
5
|
+
| 'base'
|
|
6
|
+
| 'border'
|
|
7
|
+
| 'border-base'
|
|
8
|
+
| 'border-primary';
|
|
2
9
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
10
|
+
export type ButtonSize = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
11
|
+
|
|
12
|
+
export type ButtonType = 'button' | 'submit' | 'reset';
|
|
13
|
+
|
|
14
|
+
export type ButtonProps = {
|
|
15
|
+
title?: string;
|
|
16
|
+
id?: string;
|
|
17
|
+
type?: ButtonType;
|
|
18
|
+
appearance?: ButtonAppearance;
|
|
19
|
+
size?: ButtonSize;
|
|
20
|
+
form?: string | null;
|
|
21
|
+
className?: string;
|
|
22
|
+
iconPath?: string;
|
|
23
|
+
iconClassName?: string;
|
|
24
|
+
label?: string;
|
|
25
|
+
rightIconPath?: string;
|
|
26
|
+
rightIconClassName?: string;
|
|
27
|
+
spinner?: boolean;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
spinnerClassName?: string;
|
|
30
|
+
onlySpinner?: boolean;
|
|
31
|
+
children?: Snippet;
|
|
32
|
+
hasRipple?: boolean;
|
|
33
|
+
rippleColor?: string | 'light' | 'dark';
|
|
34
|
+
url?: string;
|
|
35
|
+
target?: string;
|
|
36
|
+
hasOpenInNew?: boolean;
|
|
37
|
+
openInNewIconClassName?: string;
|
|
38
|
+
openInNewIcon?: string;
|
|
39
|
+
onClick?: (ev: MouseEvent) => void;
|
|
40
|
+
onDblClick?: (ev: MouseEvent) => void;
|
|
41
|
+
onContextMenu?: (ev: MouseEvent) => void;
|
|
42
|
+
onDrop?: (ev: DragEvent) => void;
|
|
43
|
+
onDragStart?: (ev: DragEvent) => void;
|
|
44
|
+
onDragEnd?: (ev: DragEvent) => void;
|
|
45
|
+
onDragEnter?: (ev: DragEvent) => void;
|
|
46
|
+
onDragLeave?: (ev: DragEvent) => void;
|
|
47
|
+
onDragOver?: (ev: DragEvent) => void;
|
|
48
|
+
};
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<script lang="ts">
|
|
52
|
+
import { ripple, type RipplePropsType } from '../../../../../actions/ripple.js';
|
|
53
|
+
import { Icon, mdiOpenInNew } from '../../../icon';
|
|
54
|
+
import { Spinner } from '../../../spinner';
|
|
55
|
+
import type { Snippet } from 'svelte';
|
|
56
|
+
|
|
57
|
+
let {
|
|
58
|
+
title,
|
|
59
|
+
appearance = 'none',
|
|
60
|
+
id = '',
|
|
61
|
+
form = undefined,
|
|
62
|
+
type = 'button',
|
|
63
|
+
label = '',
|
|
64
|
+
className = '',
|
|
65
|
+
iconPath = '',
|
|
66
|
+
iconClassName = '',
|
|
67
|
+
rightIconPath = '',
|
|
68
|
+
rightIconClassName = '',
|
|
69
|
+
spinner = false,
|
|
70
|
+
disabled = false,
|
|
71
|
+
size = 'md',
|
|
72
|
+
spinnerClassName = '',
|
|
73
|
+
onlySpinner = false,
|
|
74
|
+
children,
|
|
75
|
+
hasRipple = true,
|
|
76
|
+
rippleColor,
|
|
77
|
+
onClick = (ev: MouseEvent) => {},
|
|
78
|
+
url,
|
|
79
|
+
target,
|
|
80
|
+
hasOpenInNew,
|
|
81
|
+
openInNewIconClassName,
|
|
82
|
+
openInNewIcon = mdiOpenInNew,
|
|
83
|
+
onDblClick,
|
|
84
|
+
onContextMenu,
|
|
85
|
+
onDrop,
|
|
86
|
+
onDragStart,
|
|
87
|
+
onDragEnd,
|
|
88
|
+
onDragEnter,
|
|
89
|
+
onDragLeave,
|
|
90
|
+
onDragOver
|
|
91
|
+
}: ButtonProps = $props();
|
|
92
|
+
|
|
93
|
+
let btnAppearanceClassName = $derived.by(() => {
|
|
94
|
+
switch (appearance) {
|
|
95
|
+
case 'none':
|
|
96
|
+
return 'text-base-800 dark:text-base-300 hover:text-base-900 disabled:text-base-400 dark:disabled:text-base-500 dark:hover:text-base-200';
|
|
97
|
+
case 'base':
|
|
98
|
+
return 'text-base-800 dark:text-base-300 hover:text-base-900 disabled:text-base-400 dark:disabled:text-base-500 dark:hover:text-base-200 bg-base-200 dark:bg-base-700 hover:bg-base-300 dark:hover:bg-base-600 disabled:hover:bg-base-200 dark:disabled:hover:bg-base-700 ';
|
|
99
|
+
case 'primary':
|
|
100
|
+
return 'text-primary-100 hover:text-primary-50 bg-primary-600 hover:bg-primary-500 disabled:text-base-400 dark:disabled:text-base-500 disabled:bg-base-200 dark:disabled:bg-base-700 disabled:hover:bg-base-200 dark:disabled:hover:bg-base-700 ';
|
|
101
|
+
case 'border':
|
|
102
|
+
case 'border-base':
|
|
103
|
+
return 'border-2 text-base-800 dark:text-base-300 hover:text-base-900 disabled:text-base-400 dark:disabled:text-base-500 dark:hover:text-base-200 border-base-200 hover:border-base-300 dark:border-base-700 dark:hover:border-base-600 dark:disabled:border-base-200 dark:disabled:hover:border-base-200 dark:disabled:border-base-700 dark:disabled:hover:border-base-700 ';
|
|
104
|
+
case 'border-primary':
|
|
105
|
+
return 'border-2 text-primary hover:text-primary-500 disabled:text-base-400 dark:disabled:text-base-500 border-primary hover:border-primary-500 dark:border-primary-600 dark:hover:border-primary-500 dark:disabled:border-base-200 dark:disabled:hover:border-base-200 dark:disabled:border-base-700 dark:disabled:hover:border-base-700 ';
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
let btnSizeClassName = $derived.by(() => {
|
|
110
|
+
switch (size) {
|
|
111
|
+
case 'none':
|
|
112
|
+
return '';
|
|
113
|
+
case 'xs':
|
|
114
|
+
return 'px-1 py-0 text-xs';
|
|
115
|
+
case 'sm':
|
|
116
|
+
return 'px-3 py-1 text-sm';
|
|
117
|
+
case 'md':
|
|
118
|
+
return 'px-4 py-2';
|
|
119
|
+
case 'lg':
|
|
120
|
+
return 'px-6 py-3 text-lg';
|
|
121
|
+
case 'xl':
|
|
122
|
+
return 'px-8 py-4 text-xl';
|
|
123
|
+
case '2xl':
|
|
124
|
+
return 'px-10 py-6 text-2xl';
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
function handleRipple(node: HTMLElement, options?: RipplePropsType) {
|
|
129
|
+
if (hasRipple) {
|
|
130
|
+
options = options || { color: rippleColor };
|
|
131
|
+
return ripple(node, options);
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
destroy() {}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
85
137
|
</script>
|
|
86
138
|
|
|
87
139
|
{#snippet buttonContent()}
|
|
@@ -1,18 +1,31 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { isSmallScreen } from '../../../../../services';
|
|
3
|
+
import { mdiArrowLeft } from '../../../icon';
|
|
4
|
+
import Button from '../button/button.svelte';
|
|
5
|
+
|
|
6
|
+
type PropsType = {
|
|
7
|
+
id?: string;
|
|
8
|
+
iconPath?: string;
|
|
9
|
+
iconClassName?: string;
|
|
10
|
+
className?: string;
|
|
11
|
+
onlyMobile?: boolean;
|
|
12
|
+
onClick?: (ev: MouseEvent) => void;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
id,
|
|
17
|
+
iconPath = mdiArrowLeft,
|
|
18
|
+
iconClassName = '',
|
|
19
|
+
className = '',
|
|
20
|
+
onlyMobile,
|
|
21
|
+
onClick
|
|
22
|
+
}: PropsType = $props();
|
|
23
|
+
|
|
24
|
+
let isMobileScreen = $state(false);
|
|
25
|
+
|
|
26
|
+
$effect(() => {
|
|
27
|
+
isMobileScreen = isSmallScreen();
|
|
28
|
+
});
|
|
16
29
|
</script>
|
|
17
30
|
|
|
18
31
|
{#snippet button()}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Button, { type ButtonProps } from '../button/button.svelte';
|
|
3
|
+
|
|
4
|
+
let { className, ...props }: ButtonProps = $props();
|
|
3
5
|
</script>
|
|
4
6
|
|
|
5
7
|
<Button {...props} size="none" className="bg-gray-100 focus:bg-gray-200 p-2 px-4 {className}" />
|
|
@@ -1,18 +1,32 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { isSmallScreen } from '../../../../../services';
|
|
3
|
+
import { mdiArrowLeft, mdiChevronRight, mdiClose } from '../../../icon';
|
|
4
|
+
import Button from '../button/button.svelte';
|
|
5
|
+
|
|
6
|
+
type PropsType = {
|
|
7
|
+
id?: string;
|
|
8
|
+
iconPath?: string;
|
|
9
|
+
iconClassName?: string;
|
|
10
|
+
className?: string;
|
|
11
|
+
onlyWeb?: boolean;
|
|
12
|
+
|
|
13
|
+
onClick?: (ev: MouseEvent) => void;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
id,
|
|
18
|
+
iconPath = mdiClose,
|
|
19
|
+
iconClassName = '',
|
|
20
|
+
className = '',
|
|
21
|
+
onlyWeb,
|
|
22
|
+
onClick
|
|
23
|
+
}: PropsType = $props();
|
|
24
|
+
|
|
25
|
+
let isMobileScreen = $state(false);
|
|
26
|
+
|
|
27
|
+
$effect(() => {
|
|
28
|
+
isMobileScreen = isSmallScreen();
|
|
29
|
+
});
|
|
16
30
|
</script>
|
|
17
31
|
|
|
18
32
|
{#snippet button()}
|
|
@@ -1,71 +1,95 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
} from
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { DropdownStateEnum } from '../../../../../types.js';
|
|
3
|
+
import Button, {
|
|
4
|
+
type ButtonAppearance,
|
|
5
|
+
type ButtonSize,
|
|
6
|
+
type ButtonType
|
|
7
|
+
} from '../button/button.svelte';
|
|
8
|
+
import { onMount, type Snippet } from 'svelte';
|
|
9
|
+
|
|
10
|
+
export type ButtonDropdownProps = {
|
|
11
|
+
appearance?: ButtonAppearance;
|
|
12
|
+
size?: ButtonSize;
|
|
13
|
+
label?: string;
|
|
14
|
+
type?: ButtonType;
|
|
15
|
+
children?: Snippet;
|
|
16
|
+
dropdownSnippet?: Snippet;
|
|
17
|
+
id?: string;
|
|
18
|
+
backdropClassName?: string;
|
|
19
|
+
className?: string;
|
|
20
|
+
containerClassName?: string;
|
|
21
|
+
dropdownClassName?: string;
|
|
22
|
+
dropdownCloseClassName?: string;
|
|
23
|
+
dropdownOpenClassName?: string;
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
dropPosition?: 'top' | 'bottom' | 'middle';
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
let {
|
|
29
|
+
id,
|
|
30
|
+
appearance,
|
|
31
|
+
size,
|
|
32
|
+
label,
|
|
33
|
+
type,
|
|
34
|
+
children,
|
|
35
|
+
dropdownSnippet,
|
|
36
|
+
backdropClassName = '',
|
|
37
|
+
className = '',
|
|
38
|
+
containerClassName = '',
|
|
39
|
+
dropdownClassName = '',
|
|
40
|
+
dropdownCloseClassName = '',
|
|
41
|
+
dropdownOpenClassName = '',
|
|
42
|
+
disabled = false,
|
|
43
|
+
dropPosition = 'bottom',
|
|
44
|
+
...others
|
|
45
|
+
}: ButtonDropdownProps = $props();
|
|
46
|
+
|
|
47
|
+
let placement = $state(false);
|
|
48
|
+
let dropdownState = $state(DropdownStateEnum.CLOSED);
|
|
49
|
+
let openUpward = $state(false);
|
|
50
|
+
let openMiddle = $state(false);
|
|
51
|
+
let buttonElement: HTMLDivElement;
|
|
52
|
+
|
|
53
|
+
export function toggleDropdown(ev: MouseEvent | TouchEvent) {
|
|
54
|
+
ev.stopPropagation();
|
|
55
|
+
|
|
56
|
+
if (placement) {
|
|
57
|
+
dropdownState = DropdownStateEnum.CLOSED;
|
|
58
|
+
setTimeout(() => (placement = false), 100);
|
|
59
|
+
} else {
|
|
60
|
+
placement = true;
|
|
61
|
+
setTimeout(() => (dropdownState = DropdownStateEnum.OPENED), 1);
|
|
62
|
+
adjustDropdownPosition();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function adjustDropdownPosition() {
|
|
67
|
+
if (buttonElement) {
|
|
68
|
+
const rect = buttonElement?.getBoundingClientRect();
|
|
69
|
+
const viewportHeight = window.innerHeight;
|
|
70
|
+
const spaceBelow = viewportHeight - rect.bottom;
|
|
71
|
+
const spaceAbove = rect.top;
|
|
72
|
+
const dropdownHeight = 200;
|
|
73
|
+
|
|
74
|
+
openUpward = false;
|
|
75
|
+
openMiddle = false;
|
|
76
|
+
|
|
77
|
+
switch (dropPosition) {
|
|
78
|
+
case 'top':
|
|
79
|
+
openUpward = true;
|
|
80
|
+
break;
|
|
81
|
+
case 'middle':
|
|
82
|
+
openMiddle = true;
|
|
83
|
+
break;
|
|
84
|
+
default:
|
|
85
|
+
openUpward = spaceBelow < dropdownHeight && spaceAbove > dropdownHeight;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
onMount(() => {
|
|
91
|
+
window.addEventListener('resize', adjustDropdownPosition);
|
|
92
|
+
});
|
|
69
93
|
</script>
|
|
70
94
|
|
|
71
95
|
<div class="relative max-w-min {containerClassName}" bind:this={buttonElement}>
|
|
@@ -89,7 +113,7 @@ onMount(() => {
|
|
|
89
113
|
<div
|
|
90
114
|
aria-label="backdrop"
|
|
91
115
|
id="{id}-dropdown-backdrop"
|
|
92
|
-
class="
|
|
116
|
+
class="fixed inset-0 z-10 cursor-auto {backdropClassName}"
|
|
93
117
|
onmousedown={(e) => {
|
|
94
118
|
e.stopPropagation();
|
|
95
119
|
e.stopImmediatePropagation();
|
|
@@ -111,10 +135,10 @@ onMount(() => {
|
|
|
111
135
|
|
|
112
136
|
<div
|
|
113
137
|
role="dialog"
|
|
114
|
-
class="absolute z-10
|
|
138
|
+
class="absolute right-0 z-10 max-h-[50vh] min-w-40 origin-top overflow-y-auto rounded-md bg-white shadow-lg transition duration-100 ease-out dark:bg-base-800 dark:shadow-black {dropdownClassName} {dropdownState ===
|
|
115
139
|
DropdownStateEnum.OPENED
|
|
116
|
-
? `transform opacity-100
|
|
117
|
-
: `transform opacity-0
|
|
140
|
+
? `scale-100 transform opacity-100 ${dropdownOpenClassName}`
|
|
141
|
+
: `scale-60 transform opacity-0 ${dropdownCloseClassName}`}"
|
|
118
142
|
style={openMiddle
|
|
119
143
|
? 'top: 50%; transform: translateY(-50%);'
|
|
120
144
|
: openUpward
|