@rkosafo/cai.components 0.0.74 → 0.0.78
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/README.md +8 -8
- package/dist/baseEditor/index.svelte +32 -32
- package/dist/builders/filters/FilterBuilder.svelte +641 -641
- package/dist/forms/FormCheckbox/FormCheckbox.svelte +53 -53
- package/dist/forms/FormClEditor/ClEdito.svelte +68 -68
- package/dist/forms/FormDatepicker/FormDatepicker.svelte +159 -159
- package/dist/forms/FormFileUpload/FormFileUplad.svelte +134 -134
- package/dist/forms/FormInput/FormInput.svelte +87 -87
- package/dist/forms/FormRadio/FormRadio.svelte +53 -53
- package/dist/forms/FormSelect/FormSelect.svelte +88 -88
- package/dist/forms/FormTextarea/FormTextarea.svelte +78 -78
- package/dist/forms/button-toggle/ButtonToggle.svelte +119 -0
- package/dist/forms/button-toggle/ButtonToggle.svelte.d.ts +139 -0
- package/dist/forms/button-toggle/ButtonToggleGroup.svelte +0 -0
- package/dist/forms/button-toggle/ButtonToggleGroup.svelte.d.ts +26 -0
- package/dist/forms/button-toggle/CheckIcon.svelte +28 -0
- package/dist/forms/button-toggle/CheckIcon.svelte.d.ts +4 -0
- package/dist/forms/button-toggle/index.d.ts +4 -0
- package/dist/forms/button-toggle/index.js +4 -0
- package/dist/forms/button-toggle/theme.d.ts +347 -0
- package/dist/forms/button-toggle/theme.js +129 -0
- package/dist/forms/checkbox/Checkbox.svelte +82 -82
- package/dist/forms/checkbox/CheckboxButton.svelte +92 -92
- package/dist/forms/datepicker/Datepicker.svelte +707 -707
- package/dist/forms/form/Form.svelte +69 -69
- package/dist/forms/input/Input.svelte +363 -363
- package/dist/forms/label/Label.svelte +38 -38
- package/dist/forms/radio/Radio.svelte +48 -48
- package/dist/forms/radio/RadioButton.svelte +22 -22
- package/dist/forms/select/Select.svelte +56 -56
- package/dist/forms/textarea/Textarea.svelte +165 -165
- package/dist/forms/toggle/Toggle.svelte +70 -0
- package/dist/forms/toggle/Toggle.svelte.d.ts +3 -0
- package/dist/forms/toggle/index.d.ts +2 -0
- package/dist/forms/toggle/index.js +2 -0
- package/dist/forms/toggle/theme.d.ts +280 -0
- package/dist/forms/toggle/theme.js +97 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/layout/Chat/CategorySelector.svelte +52 -52
- package/dist/layout/Chat/ChatEntry.svelte +246 -246
- package/dist/layout/Chat/ChatEntrySkeleton.svelte +81 -81
- package/dist/layout/Chat/ChatHeader.svelte +172 -172
- package/dist/layout/Chat/ChatInput.svelte +207 -207
- package/dist/layout/Chat/DraggableWindow.svelte +230 -230
- package/dist/layout/Chat/PreviewPage.svelte +182 -182
- package/dist/layout/Chat/RichText.svelte +216 -216
- package/dist/layout/ComponentCanvas/Canvas.svelte +40 -40
- package/dist/layout/ComponentCanvas/ComponentRenderer.svelte +85 -85
- package/dist/layout/TF/Content/Content.svelte +21 -21
- package/dist/layout/TF/Header/Header.svelte +166 -166
- package/dist/layout/TF/Sidebar/Sidebar.svelte +148 -148
- package/dist/layout/TF/Wrapper/Wrapper.svelte +17 -17
- package/dist/layout/mailing/MailPaginator.svelte +36 -36
- package/dist/layout/mailing/MailSidebar.svelte +39 -39
- package/dist/layout/mailing/MailToolBar.svelte +174 -174
- package/dist/layout/mailing/MailingContent.svelte +10 -10
- package/dist/layout/mailing/MailingHeader.svelte +55 -55
- package/dist/layout/mailing/MailingMessageCard.svelte +112 -112
- package/dist/layout/mailing/MailingMessageViewer.svelte +87 -87
- package/dist/layout/mailing/MailingModule.svelte +448 -448
- package/dist/styles/docs.css +615 -615
- package/dist/styles/tf-layout.css +185 -185
- package/dist/themes/ThemeProvider.svelte +20 -20
- package/dist/themes/themes.d.ts +3 -0
- package/dist/themes/themes.js +3 -0
- package/dist/types/index.d.ts +59 -2
- package/dist/typography/heading/Heading.svelte +35 -35
- package/dist/ui/accordion/Accordion.svelte +49 -49
- package/dist/ui/accordion/AccordionItem.svelte +173 -173
- package/dist/ui/alert/Alert.svelte +83 -83
- package/dist/ui/alertDialog/AlertDialog.svelte +40 -40
- package/dist/ui/avatar/Avatar.svelte +77 -77
- package/dist/ui/box/Box.svelte +28 -28
- package/dist/ui/breadcrumb/Breadcrumb.svelte +39 -28
- package/dist/ui/buttons/ActionButton.svelte +234 -234
- package/dist/ui/buttons/Button.svelte +102 -102
- package/dist/ui/buttons/GradientButton.svelte +59 -59
- package/dist/ui/datatable/Datatable.svelte +525 -525
- package/dist/ui/drawer/Drawer.svelte +300 -300
- package/dist/ui/dropdown/Dropdown.svelte +36 -36
- package/dist/ui/dropdown/DropdownDivider.svelte +11 -11
- package/dist/ui/dropdown/DropdownGroup.svelte +14 -14
- package/dist/ui/dropdown/DropdownHeader.svelte +14 -14
- package/dist/ui/dropdown/DropdownItem.svelte +52 -52
- package/dist/ui/footer/Footer.svelte +15 -15
- package/dist/ui/footer/FooterBrand.svelte +37 -37
- package/dist/ui/footer/FooterCopyright.svelte +45 -45
- package/dist/ui/footer/FooterIcon.svelte +22 -22
- package/dist/ui/footer/FooterLink.svelte +33 -33
- package/dist/ui/footer/FooterLinkGroup.svelte +13 -13
- package/dist/ui/icons/IconifyIcon.svelte +7 -7
- package/dist/ui/indicator/Indicator.svelte +42 -42
- package/dist/ui/modal/Modal.svelte +265 -265
- package/dist/ui/modal/theme.d.ts +26 -26
- package/dist/ui/modal/theme.js +25 -25
- package/dist/ui/notificationList/NotificationList.svelte +123 -123
- package/dist/ui/pageLoader/PageLoader.svelte +14 -14
- package/dist/ui/paginate/Paginate.svelte +96 -96
- package/dist/ui/speedDial/SpeedDial.svelte +77 -0
- package/dist/ui/speedDial/SpeedDial.svelte.d.ts +21 -0
- package/dist/ui/speedDial/SpeedDialButton.svelte +75 -0
- package/dist/ui/speedDial/SpeedDialButton.svelte.d.ts +20 -0
- package/dist/ui/speedDial/SpeedDialTrigger.svelte +79 -0
- package/dist/ui/speedDial/SpeedDialTrigger.svelte.d.ts +18 -0
- package/dist/ui/speedDial/index.d.ts +4 -0
- package/dist/ui/speedDial/index.js +4 -0
- package/dist/ui/speedDial/theme.d.ts +75 -0
- package/dist/ui/speedDial/theme.js +35 -0
- package/dist/ui/tab/Tab.svelte +67 -67
- package/dist/ui/table/Table.svelte +396 -394
- package/dist/ui/tableLoader/TableLoader.svelte +24 -24
- package/dist/ui/toast/Toast.svelte +337 -337
- package/dist/ui/toast/Toast.svelte.d.ts +10 -10
- package/dist/ui/toast/index.d.ts +1 -2
- package/dist/ui/toast/index.js +3 -1
- package/dist/ui/toolbar/Toolbar.svelte +59 -59
- package/dist/ui/toolbar/ToolbarButton.svelte +56 -56
- package/dist/ui/toolbar/ToolbarGroup.svelte +43 -43
- package/dist/ui/tooltip/Tooltip.svelte +51 -51
- package/dist/utils/Popper.svelte +257 -257
- package/dist/utils/closeButton/CloseButton.svelte +88 -88
- package/dist/utils/index.d.ts +3 -2
- package/dist/utils/index.js +13 -3
- package/dist/utils/singleSelection.svelte.js +48 -48
- package/dist/youtube/index.svelte +12 -12
- package/package.json +2 -1
|
@@ -1,230 +1,230 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { fade } from 'svelte/transition';
|
|
3
|
-
import type { DraggableWindowProps } from './types.js';
|
|
4
|
-
|
|
5
|
-
let {
|
|
6
|
-
title,
|
|
7
|
-
isOpen = $bindable(true),
|
|
8
|
-
isCollapsed = $bindable(false),
|
|
9
|
-
width = '500px',
|
|
10
|
-
height = '400px',
|
|
11
|
-
x = $bindable(100),
|
|
12
|
-
y = $bindable(100),
|
|
13
|
-
minWidth = '300px',
|
|
14
|
-
minHeight = '200px',
|
|
15
|
-
zIndex = 3000,
|
|
16
|
-
onBringToFront
|
|
17
|
-
}: DraggableWindowProps = $props();
|
|
18
|
-
|
|
19
|
-
let startX = $state<number | undefined>();
|
|
20
|
-
let startY = $state<number | undefined>();
|
|
21
|
-
let isDragging = $state(false);
|
|
22
|
-
let isResizing = $state(false);
|
|
23
|
-
let resizeDirection: 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw' | null = null;
|
|
24
|
-
let startWidth = $state<number | undefined>();
|
|
25
|
-
let startHeight = $state<number | undefined>();
|
|
26
|
-
|
|
27
|
-
function startDrag(e: MouseEvent) {
|
|
28
|
-
if (isResizing) return;
|
|
29
|
-
isDragging = true;
|
|
30
|
-
startX = e.clientX - x;
|
|
31
|
-
startY = e.clientY - y;
|
|
32
|
-
window.addEventListener('mousemove', handleDrag);
|
|
33
|
-
window.addEventListener('mouseup', stopDrag);
|
|
34
|
-
// bringToFront();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function handleDrag(e: MouseEvent) {
|
|
38
|
-
if (isDragging) {
|
|
39
|
-
x = e.clientX - startX!;
|
|
40
|
-
y = e.clientY - startY!;
|
|
41
|
-
} else if (isResizing) {
|
|
42
|
-
const deltaX = e.clientX - startX!;
|
|
43
|
-
const deltaY = e.clientY - startY!;
|
|
44
|
-
|
|
45
|
-
if (resizeDirection?.includes('e')) {
|
|
46
|
-
width = `${Math.max(parseInt(minWidth), startWidth! + deltaX)}px`;
|
|
47
|
-
}
|
|
48
|
-
if (resizeDirection?.includes('w')) {
|
|
49
|
-
const newWidth = Math.max(parseInt(minWidth), startWidth! - deltaX);
|
|
50
|
-
width = `${newWidth}px`;
|
|
51
|
-
x += startWidth! - newWidth;
|
|
52
|
-
}
|
|
53
|
-
if (resizeDirection?.includes('s')) {
|
|
54
|
-
height = `${Math.max(parseInt(minHeight), startHeight! + deltaY)}px`;
|
|
55
|
-
}
|
|
56
|
-
if (resizeDirection?.includes('n')) {
|
|
57
|
-
const newHeight = Math.max(parseInt(minHeight), startHeight! - deltaY);
|
|
58
|
-
height = `${newHeight}px`;
|
|
59
|
-
y += startHeight! - newHeight;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function stopDrag() {
|
|
65
|
-
isDragging = false;
|
|
66
|
-
isResizing = false;
|
|
67
|
-
resizeDirection = null;
|
|
68
|
-
window.removeEventListener('mousemove', handleDrag);
|
|
69
|
-
window.removeEventListener('mouseup', stopDrag);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function startResize(e: MouseEvent, direction: typeof resizeDirection) {
|
|
73
|
-
e.stopPropagation();
|
|
74
|
-
isResizing = true;
|
|
75
|
-
resizeDirection = direction;
|
|
76
|
-
startX = e.clientX;
|
|
77
|
-
startY = e.clientY;
|
|
78
|
-
startWidth = parseInt(width);
|
|
79
|
-
startHeight = parseInt(height);
|
|
80
|
-
window.addEventListener('mousemove', handleDrag);
|
|
81
|
-
window.addEventListener('mouseup', stopDrag);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function toggleCollapse(event: any) {
|
|
85
|
-
event.stopPropagation();
|
|
86
|
-
isCollapsed = !isCollapsed;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function bringToFront() {
|
|
90
|
-
onBringToFront?.();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function closeWindow(event: any) {
|
|
94
|
-
event.stopPropagation();
|
|
95
|
-
isOpen = false;
|
|
96
|
-
}
|
|
97
|
-
function handleWindowClick() {
|
|
98
|
-
if (!isDragging && !isResizing) {
|
|
99
|
-
bringToFront();
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
</script>
|
|
103
|
-
|
|
104
|
-
{#if isOpen}
|
|
105
|
-
<div
|
|
106
|
-
class="absolute flex flex-col overflow-hidden rounded-lg border border-gray-200 bg-white shadow-xl"
|
|
107
|
-
style={`width: ${width}; height: ${isCollapsed ? '40px' : height}; left: ${x}px; top: ${y}px; min-width: ${minWidth}; min-height: ${isCollapsed ? '40px' : minHeight}; z-index: ${zIndex};`}
|
|
108
|
-
transition:fade={{ duration: 150 }}
|
|
109
|
-
onclick={handleWindowClick}
|
|
110
|
-
>
|
|
111
|
-
<div
|
|
112
|
-
class="flex cursor-move items-center justify-between border-b border-gray-200 bg-gray-100 px-3 py-2"
|
|
113
|
-
onmousedown={startDrag}
|
|
114
|
-
>
|
|
115
|
-
<div class="font-medium text-gray-700">{title}</div>
|
|
116
|
-
<div class="flex space-x-2">
|
|
117
|
-
<button
|
|
118
|
-
class="flex h-6 w-6 items-center justify-center text-gray-500 hover:text-gray-700"
|
|
119
|
-
onclick={toggleCollapse}
|
|
120
|
-
>
|
|
121
|
-
{#if isCollapsed}
|
|
122
|
-
<svg
|
|
123
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
124
|
-
width="16"
|
|
125
|
-
height="16"
|
|
126
|
-
viewBox="0 0 24 24"
|
|
127
|
-
fill="none"
|
|
128
|
-
stroke="currentColor"
|
|
129
|
-
stroke-width="2"
|
|
130
|
-
stroke-linecap="round"
|
|
131
|
-
stroke-linejoin="round"
|
|
132
|
-
>
|
|
133
|
-
<polyline points="4 14 10 14 10 20"></polyline>
|
|
134
|
-
<polyline points="20 10 14 10 14 4"></polyline>
|
|
135
|
-
</svg>
|
|
136
|
-
{:else}
|
|
137
|
-
<svg
|
|
138
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
139
|
-
width="16"
|
|
140
|
-
height="16"
|
|
141
|
-
viewBox="0 0 24 24"
|
|
142
|
-
fill="none"
|
|
143
|
-
stroke="currentColor"
|
|
144
|
-
stroke-width="2"
|
|
145
|
-
stroke-linecap="round"
|
|
146
|
-
stroke-linejoin="round"
|
|
147
|
-
>
|
|
148
|
-
<polyline points="4 14 10 14 10 20"></polyline>
|
|
149
|
-
<polyline points="20 10 14 10 14 4"></polyline>
|
|
150
|
-
</svg>
|
|
151
|
-
{/if}
|
|
152
|
-
</button>
|
|
153
|
-
<button
|
|
154
|
-
class="flex h-6 w-6 items-center justify-center text-gray-500 hover:text-gray-700"
|
|
155
|
-
onclick={closeWindow}
|
|
156
|
-
>
|
|
157
|
-
<svg
|
|
158
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
159
|
-
width="16"
|
|
160
|
-
height="16"
|
|
161
|
-
viewBox="0 0 24 24"
|
|
162
|
-
fill="none"
|
|
163
|
-
stroke="currentColor"
|
|
164
|
-
stroke-width="2"
|
|
165
|
-
stroke-linecap="round"
|
|
166
|
-
stroke-linejoin="round"
|
|
167
|
-
>
|
|
168
|
-
<line x1="18" y1="6" x2="6" y2="18"></line>
|
|
169
|
-
<line x1="6" y1="6" x2="18" y2="18"></line>
|
|
170
|
-
</svg>
|
|
171
|
-
</button>
|
|
172
|
-
</div>
|
|
173
|
-
</div>
|
|
174
|
-
|
|
175
|
-
<div class="flex-grow overflow-auto p-4" class:hidden={isCollapsed}>
|
|
176
|
-
<slot />
|
|
177
|
-
</div>
|
|
178
|
-
|
|
179
|
-
<!-- Resize handles -->
|
|
180
|
-
<div
|
|
181
|
-
class="absolute top-0 left-0 h-2 w-2 cursor-nw-resize"
|
|
182
|
-
onmousedown={(e) => startResize(e, 'nw')}
|
|
183
|
-
></div>
|
|
184
|
-
<div
|
|
185
|
-
class="absolute top-0 left-0 h-2 w-full cursor-n-resize"
|
|
186
|
-
onmousedown={(e) => startResize(e, 'n')}
|
|
187
|
-
></div>
|
|
188
|
-
<div
|
|
189
|
-
class="absolute top-0 right-0 h-2 w-2 cursor-ne-resize"
|
|
190
|
-
onmousedown={(e) => startResize(e, 'ne')}
|
|
191
|
-
></div>
|
|
192
|
-
<div
|
|
193
|
-
class="absolute top-0 right-0 h-full w-2 cursor-e-resize"
|
|
194
|
-
onmousedown={(e) => startResize(e, 'e')}
|
|
195
|
-
></div>
|
|
196
|
-
<div
|
|
197
|
-
class="absolute right-0 bottom-0 h-2 w-2 cursor-se-resize"
|
|
198
|
-
onmousedown={(e) => startResize(e, 'se')}
|
|
199
|
-
></div>
|
|
200
|
-
<div
|
|
201
|
-
class="absolute bottom-0 left-0 h-2 w-full cursor-s-resize"
|
|
202
|
-
onmousedown={(e) => startResize(e, 's')}
|
|
203
|
-
></div>
|
|
204
|
-
<div
|
|
205
|
-
class="absolute bottom-0 left-0 h-2 w-2 cursor-sw-resize"
|
|
206
|
-
onmousedown={(e) => startResize(e, 'sw')}
|
|
207
|
-
></div>
|
|
208
|
-
<div
|
|
209
|
-
class="absolute top-0 left-0 h-full w-2 cursor-w-resize"
|
|
210
|
-
onmousedown={(e) => startResize(e, 'w')}
|
|
211
|
-
></div>
|
|
212
|
-
</div>
|
|
213
|
-
{/if}
|
|
214
|
-
|
|
215
|
-
<style>
|
|
216
|
-
.cursor-nw-resize,
|
|
217
|
-
.cursor-ne-resize,
|
|
218
|
-
.cursor-se-resize,
|
|
219
|
-
.cursor-sw-resize {
|
|
220
|
-
cursor: nwse-resize;
|
|
221
|
-
}
|
|
222
|
-
.cursor-n-resize,
|
|
223
|
-
.cursor-s-resize {
|
|
224
|
-
cursor: ns-resize;
|
|
225
|
-
}
|
|
226
|
-
.cursor-e-resize,
|
|
227
|
-
.cursor-w-resize {
|
|
228
|
-
cursor: ew-resize;
|
|
229
|
-
}
|
|
230
|
-
</style>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { fade } from 'svelte/transition';
|
|
3
|
+
import type { DraggableWindowProps } from './types.js';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
title,
|
|
7
|
+
isOpen = $bindable(true),
|
|
8
|
+
isCollapsed = $bindable(false),
|
|
9
|
+
width = '500px',
|
|
10
|
+
height = '400px',
|
|
11
|
+
x = $bindable(100),
|
|
12
|
+
y = $bindable(100),
|
|
13
|
+
minWidth = '300px',
|
|
14
|
+
minHeight = '200px',
|
|
15
|
+
zIndex = 3000,
|
|
16
|
+
onBringToFront
|
|
17
|
+
}: DraggableWindowProps = $props();
|
|
18
|
+
|
|
19
|
+
let startX = $state<number | undefined>();
|
|
20
|
+
let startY = $state<number | undefined>();
|
|
21
|
+
let isDragging = $state(false);
|
|
22
|
+
let isResizing = $state(false);
|
|
23
|
+
let resizeDirection: 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw' | null = null;
|
|
24
|
+
let startWidth = $state<number | undefined>();
|
|
25
|
+
let startHeight = $state<number | undefined>();
|
|
26
|
+
|
|
27
|
+
function startDrag(e: MouseEvent) {
|
|
28
|
+
if (isResizing) return;
|
|
29
|
+
isDragging = true;
|
|
30
|
+
startX = e.clientX - x;
|
|
31
|
+
startY = e.clientY - y;
|
|
32
|
+
window.addEventListener('mousemove', handleDrag);
|
|
33
|
+
window.addEventListener('mouseup', stopDrag);
|
|
34
|
+
// bringToFront();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function handleDrag(e: MouseEvent) {
|
|
38
|
+
if (isDragging) {
|
|
39
|
+
x = e.clientX - startX!;
|
|
40
|
+
y = e.clientY - startY!;
|
|
41
|
+
} else if (isResizing) {
|
|
42
|
+
const deltaX = e.clientX - startX!;
|
|
43
|
+
const deltaY = e.clientY - startY!;
|
|
44
|
+
|
|
45
|
+
if (resizeDirection?.includes('e')) {
|
|
46
|
+
width = `${Math.max(parseInt(minWidth), startWidth! + deltaX)}px`;
|
|
47
|
+
}
|
|
48
|
+
if (resizeDirection?.includes('w')) {
|
|
49
|
+
const newWidth = Math.max(parseInt(minWidth), startWidth! - deltaX);
|
|
50
|
+
width = `${newWidth}px`;
|
|
51
|
+
x += startWidth! - newWidth;
|
|
52
|
+
}
|
|
53
|
+
if (resizeDirection?.includes('s')) {
|
|
54
|
+
height = `${Math.max(parseInt(minHeight), startHeight! + deltaY)}px`;
|
|
55
|
+
}
|
|
56
|
+
if (resizeDirection?.includes('n')) {
|
|
57
|
+
const newHeight = Math.max(parseInt(minHeight), startHeight! - deltaY);
|
|
58
|
+
height = `${newHeight}px`;
|
|
59
|
+
y += startHeight! - newHeight;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function stopDrag() {
|
|
65
|
+
isDragging = false;
|
|
66
|
+
isResizing = false;
|
|
67
|
+
resizeDirection = null;
|
|
68
|
+
window.removeEventListener('mousemove', handleDrag);
|
|
69
|
+
window.removeEventListener('mouseup', stopDrag);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function startResize(e: MouseEvent, direction: typeof resizeDirection) {
|
|
73
|
+
e.stopPropagation();
|
|
74
|
+
isResizing = true;
|
|
75
|
+
resizeDirection = direction;
|
|
76
|
+
startX = e.clientX;
|
|
77
|
+
startY = e.clientY;
|
|
78
|
+
startWidth = parseInt(width);
|
|
79
|
+
startHeight = parseInt(height);
|
|
80
|
+
window.addEventListener('mousemove', handleDrag);
|
|
81
|
+
window.addEventListener('mouseup', stopDrag);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function toggleCollapse(event: any) {
|
|
85
|
+
event.stopPropagation();
|
|
86
|
+
isCollapsed = !isCollapsed;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function bringToFront() {
|
|
90
|
+
onBringToFront?.();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function closeWindow(event: any) {
|
|
94
|
+
event.stopPropagation();
|
|
95
|
+
isOpen = false;
|
|
96
|
+
}
|
|
97
|
+
function handleWindowClick() {
|
|
98
|
+
if (!isDragging && !isResizing) {
|
|
99
|
+
bringToFront();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
</script>
|
|
103
|
+
|
|
104
|
+
{#if isOpen}
|
|
105
|
+
<div
|
|
106
|
+
class="absolute flex flex-col overflow-hidden rounded-lg border border-gray-200 bg-white shadow-xl"
|
|
107
|
+
style={`width: ${width}; height: ${isCollapsed ? '40px' : height}; left: ${x}px; top: ${y}px; min-width: ${minWidth}; min-height: ${isCollapsed ? '40px' : minHeight}; z-index: ${zIndex};`}
|
|
108
|
+
transition:fade={{ duration: 150 }}
|
|
109
|
+
onclick={handleWindowClick}
|
|
110
|
+
>
|
|
111
|
+
<div
|
|
112
|
+
class="flex cursor-move items-center justify-between border-b border-gray-200 bg-gray-100 px-3 py-2"
|
|
113
|
+
onmousedown={startDrag}
|
|
114
|
+
>
|
|
115
|
+
<div class="font-medium text-gray-700">{title}</div>
|
|
116
|
+
<div class="flex space-x-2">
|
|
117
|
+
<button
|
|
118
|
+
class="flex h-6 w-6 items-center justify-center text-gray-500 hover:text-gray-700"
|
|
119
|
+
onclick={toggleCollapse}
|
|
120
|
+
>
|
|
121
|
+
{#if isCollapsed}
|
|
122
|
+
<svg
|
|
123
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
124
|
+
width="16"
|
|
125
|
+
height="16"
|
|
126
|
+
viewBox="0 0 24 24"
|
|
127
|
+
fill="none"
|
|
128
|
+
stroke="currentColor"
|
|
129
|
+
stroke-width="2"
|
|
130
|
+
stroke-linecap="round"
|
|
131
|
+
stroke-linejoin="round"
|
|
132
|
+
>
|
|
133
|
+
<polyline points="4 14 10 14 10 20"></polyline>
|
|
134
|
+
<polyline points="20 10 14 10 14 4"></polyline>
|
|
135
|
+
</svg>
|
|
136
|
+
{:else}
|
|
137
|
+
<svg
|
|
138
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
139
|
+
width="16"
|
|
140
|
+
height="16"
|
|
141
|
+
viewBox="0 0 24 24"
|
|
142
|
+
fill="none"
|
|
143
|
+
stroke="currentColor"
|
|
144
|
+
stroke-width="2"
|
|
145
|
+
stroke-linecap="round"
|
|
146
|
+
stroke-linejoin="round"
|
|
147
|
+
>
|
|
148
|
+
<polyline points="4 14 10 14 10 20"></polyline>
|
|
149
|
+
<polyline points="20 10 14 10 14 4"></polyline>
|
|
150
|
+
</svg>
|
|
151
|
+
{/if}
|
|
152
|
+
</button>
|
|
153
|
+
<button
|
|
154
|
+
class="flex h-6 w-6 items-center justify-center text-gray-500 hover:text-gray-700"
|
|
155
|
+
onclick={closeWindow}
|
|
156
|
+
>
|
|
157
|
+
<svg
|
|
158
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
159
|
+
width="16"
|
|
160
|
+
height="16"
|
|
161
|
+
viewBox="0 0 24 24"
|
|
162
|
+
fill="none"
|
|
163
|
+
stroke="currentColor"
|
|
164
|
+
stroke-width="2"
|
|
165
|
+
stroke-linecap="round"
|
|
166
|
+
stroke-linejoin="round"
|
|
167
|
+
>
|
|
168
|
+
<line x1="18" y1="6" x2="6" y2="18"></line>
|
|
169
|
+
<line x1="6" y1="6" x2="18" y2="18"></line>
|
|
170
|
+
</svg>
|
|
171
|
+
</button>
|
|
172
|
+
</div>
|
|
173
|
+
</div>
|
|
174
|
+
|
|
175
|
+
<div class="flex-grow overflow-auto p-4" class:hidden={isCollapsed}>
|
|
176
|
+
<slot />
|
|
177
|
+
</div>
|
|
178
|
+
|
|
179
|
+
<!-- Resize handles -->
|
|
180
|
+
<div
|
|
181
|
+
class="absolute top-0 left-0 h-2 w-2 cursor-nw-resize"
|
|
182
|
+
onmousedown={(e) => startResize(e, 'nw')}
|
|
183
|
+
></div>
|
|
184
|
+
<div
|
|
185
|
+
class="absolute top-0 left-0 h-2 w-full cursor-n-resize"
|
|
186
|
+
onmousedown={(e) => startResize(e, 'n')}
|
|
187
|
+
></div>
|
|
188
|
+
<div
|
|
189
|
+
class="absolute top-0 right-0 h-2 w-2 cursor-ne-resize"
|
|
190
|
+
onmousedown={(e) => startResize(e, 'ne')}
|
|
191
|
+
></div>
|
|
192
|
+
<div
|
|
193
|
+
class="absolute top-0 right-0 h-full w-2 cursor-e-resize"
|
|
194
|
+
onmousedown={(e) => startResize(e, 'e')}
|
|
195
|
+
></div>
|
|
196
|
+
<div
|
|
197
|
+
class="absolute right-0 bottom-0 h-2 w-2 cursor-se-resize"
|
|
198
|
+
onmousedown={(e) => startResize(e, 'se')}
|
|
199
|
+
></div>
|
|
200
|
+
<div
|
|
201
|
+
class="absolute bottom-0 left-0 h-2 w-full cursor-s-resize"
|
|
202
|
+
onmousedown={(e) => startResize(e, 's')}
|
|
203
|
+
></div>
|
|
204
|
+
<div
|
|
205
|
+
class="absolute bottom-0 left-0 h-2 w-2 cursor-sw-resize"
|
|
206
|
+
onmousedown={(e) => startResize(e, 'sw')}
|
|
207
|
+
></div>
|
|
208
|
+
<div
|
|
209
|
+
class="absolute top-0 left-0 h-full w-2 cursor-w-resize"
|
|
210
|
+
onmousedown={(e) => startResize(e, 'w')}
|
|
211
|
+
></div>
|
|
212
|
+
</div>
|
|
213
|
+
{/if}
|
|
214
|
+
|
|
215
|
+
<style>
|
|
216
|
+
.cursor-nw-resize,
|
|
217
|
+
.cursor-ne-resize,
|
|
218
|
+
.cursor-se-resize,
|
|
219
|
+
.cursor-sw-resize {
|
|
220
|
+
cursor: nwse-resize;
|
|
221
|
+
}
|
|
222
|
+
.cursor-n-resize,
|
|
223
|
+
.cursor-s-resize {
|
|
224
|
+
cursor: ns-resize;
|
|
225
|
+
}
|
|
226
|
+
.cursor-e-resize,
|
|
227
|
+
.cursor-w-resize {
|
|
228
|
+
cursor: ew-resize;
|
|
229
|
+
}
|
|
230
|
+
</style>
|