@x33025/sveltely 0.0.52 → 0.0.54
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/components/Popover/Popover.svelte +47 -2
- package/dist/style/index.css +6 -12
- package/dist/style.css +32 -15
- package/package.json +1 -1
|
@@ -39,9 +39,11 @@
|
|
|
39
39
|
|
|
40
40
|
let triggerEl = $state<HTMLElement | null>(null);
|
|
41
41
|
let panelEl = $state<HTMLElement | null>(null);
|
|
42
|
+
let contentEl = $state<HTMLElement | null>(null);
|
|
42
43
|
let panelCoords = $state({ top: 0, left: 0 });
|
|
43
44
|
let panelTransform = $state('none');
|
|
44
45
|
let resolvedAnchor = $state<Anchor>('bottom');
|
|
46
|
+
let computedPanelRadius = $state<string | null>(null);
|
|
45
47
|
|
|
46
48
|
const popoverId = createPopoverId();
|
|
47
49
|
let parentPopoverId = $state<string | null>(null);
|
|
@@ -131,10 +133,49 @@
|
|
|
131
133
|
];
|
|
132
134
|
};
|
|
133
135
|
|
|
136
|
+
const parsePx = (value: string) => {
|
|
137
|
+
const first = value.split(' ')[0];
|
|
138
|
+
const parsed = Number.parseFloat(first);
|
|
139
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const updateRadiusFromSource = () => {
|
|
143
|
+
if (!panelEl || !contentEl) {
|
|
144
|
+
computedPanelRadius = null;
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const sourceEl = contentEl.querySelector<HTMLElement>('[data-popover-radius-source]');
|
|
149
|
+
if (!sourceEl) {
|
|
150
|
+
computedPanelRadius = null;
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const sourceStyle = getComputedStyle(sourceEl);
|
|
155
|
+
const sourceRadius = parsePx(sourceStyle.borderTopLeftRadius);
|
|
156
|
+
const sourceRect = sourceEl.getBoundingClientRect();
|
|
157
|
+
const effectiveSourceRadius = Math.min(
|
|
158
|
+
sourceRadius,
|
|
159
|
+
sourceRect.height / 2,
|
|
160
|
+
sourceRect.width / 2
|
|
161
|
+
);
|
|
162
|
+
const panelStyle = getComputedStyle(panelEl);
|
|
163
|
+
const panelPadding = Math.min(parsePx(panelStyle.paddingTop), parsePx(panelStyle.paddingLeft));
|
|
164
|
+
const panelRect = panelEl.getBoundingClientRect();
|
|
165
|
+
const panelRadius = Math.min(
|
|
166
|
+
Math.max(0, effectiveSourceRadius + panelPadding),
|
|
167
|
+
panelRect.height / 2,
|
|
168
|
+
panelRect.width / 2
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
computedPanelRadius = `${panelRadius}px`;
|
|
172
|
+
};
|
|
173
|
+
|
|
134
174
|
const positionAndMeasure = async () => {
|
|
135
175
|
await tick();
|
|
136
176
|
await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));
|
|
137
177
|
positionPanel();
|
|
178
|
+
updateRadiusFromSource();
|
|
138
179
|
};
|
|
139
180
|
|
|
140
181
|
const getPopoverIdsFromEvent = (event: Event) => {
|
|
@@ -171,6 +212,7 @@
|
|
|
171
212
|
|
|
172
213
|
function closePanel() {
|
|
173
214
|
open = false;
|
|
215
|
+
computedPanelRadius = null;
|
|
174
216
|
}
|
|
175
217
|
|
|
176
218
|
function toggle() {
|
|
@@ -248,13 +290,16 @@
|
|
|
248
290
|
data-popover
|
|
249
291
|
data-popover-id={popoverId}
|
|
250
292
|
data-popover-parent-id={parentPopoverId ?? ''}
|
|
251
|
-
style="top: {panelCoords.top}px; left: {panelCoords.left}px; transform: {panelTransform};
|
|
293
|
+
style="top: {panelCoords.top}px; left: {panelCoords.left}px; transform: {panelTransform}; border-radius: {computedPanelRadius ??
|
|
294
|
+
''};"
|
|
252
295
|
role="dialog"
|
|
253
296
|
aria-modal="false"
|
|
254
297
|
tabindex="-1"
|
|
255
298
|
bind:this={panelEl}
|
|
256
299
|
>
|
|
257
|
-
{
|
|
300
|
+
<div role="none" bind:this={contentEl}>
|
|
301
|
+
{@render children()}
|
|
302
|
+
</div>
|
|
258
303
|
</div>
|
|
259
304
|
{/if}
|
|
260
305
|
</div>
|
package/dist/style/index.css
CHANGED
|
@@ -94,22 +94,16 @@
|
|
|
94
94
|
@apply rounded p-1.5 hover:bg-zinc-100;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
.
|
|
98
|
-
@apply
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.dropdown-item {
|
|
102
|
-
@apply rounded-md;
|
|
97
|
+
.popover {
|
|
98
|
+
@apply border border-gray-200 bg-white p-1 shadow-md;
|
|
103
99
|
}
|
|
104
100
|
|
|
105
|
-
.
|
|
106
|
-
@apply
|
|
101
|
+
.popover-item {
|
|
102
|
+
@apply rounded-md px-2 py-1;
|
|
107
103
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
@apply rounded-md border border-gray-200 bg-white p-2 shadow-md;
|
|
104
|
+
.popover-item:hover {
|
|
105
|
+
@apply bg-zinc-200;
|
|
111
106
|
}
|
|
112
|
-
|
|
113
107
|
.sheet {
|
|
114
108
|
@apply rounded-md bg-white p-4 shadow-md;
|
|
115
109
|
}
|
package/dist/style.css
CHANGED
|
@@ -7,8 +7,11 @@
|
|
|
7
7
|
"Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
|
8
8
|
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
|
|
9
9
|
"Courier New", monospace;
|
|
10
|
+
--color-red-100: oklch(93.6% 0.032 17.717);
|
|
11
|
+
--color-red-200: oklch(88.5% 0.062 18.334);
|
|
10
12
|
--color-red-500: oklch(63.7% 0.237 25.331);
|
|
11
13
|
--color-red-600: oklch(57.7% 0.245 27.325);
|
|
14
|
+
--color-red-700: oklch(50.5% 0.213 27.518);
|
|
12
15
|
--color-gray-200: oklch(92.8% 0.006 264.531);
|
|
13
16
|
--color-gray-700: oklch(37.3% 0.034 259.733);
|
|
14
17
|
--color-gray-900: oklch(21% 0.034 264.665);
|
|
@@ -390,12 +393,18 @@
|
|
|
390
393
|
.border-zinc-300 {
|
|
391
394
|
border-color: var(--color-zinc-300);
|
|
392
395
|
}
|
|
396
|
+
.bg-red-100 {
|
|
397
|
+
background-color: var(--color-red-100);
|
|
398
|
+
}
|
|
393
399
|
.bg-white {
|
|
394
400
|
background-color: var(--color-white);
|
|
395
401
|
}
|
|
396
402
|
.bg-zinc-50 {
|
|
397
403
|
background-color: var(--color-zinc-50);
|
|
398
404
|
}
|
|
405
|
+
.bg-zinc-100 {
|
|
406
|
+
background-color: var(--color-zinc-100);
|
|
407
|
+
}
|
|
399
408
|
.bg-zinc-900 {
|
|
400
409
|
background-color: var(--color-zinc-900);
|
|
401
410
|
}
|
|
@@ -456,6 +465,9 @@
|
|
|
456
465
|
.text-red-600 {
|
|
457
466
|
color: var(--color-red-600);
|
|
458
467
|
}
|
|
468
|
+
.text-red-700 {
|
|
469
|
+
color: var(--color-red-700);
|
|
470
|
+
}
|
|
459
471
|
.text-white {
|
|
460
472
|
color: var(--color-white);
|
|
461
473
|
}
|
|
@@ -524,6 +536,13 @@
|
|
|
524
536
|
--tw-outline-style: none;
|
|
525
537
|
outline-style: none;
|
|
526
538
|
}
|
|
539
|
+
.hover\:bg-red-200 {
|
|
540
|
+
&:hover {
|
|
541
|
+
@media (hover: hover) {
|
|
542
|
+
background-color: var(--color-red-200);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
527
546
|
.hover\:bg-zinc-100 {
|
|
528
547
|
&:hover {
|
|
529
548
|
@media (hover: hover) {
|
|
@@ -531,6 +550,13 @@
|
|
|
531
550
|
}
|
|
532
551
|
}
|
|
533
552
|
}
|
|
553
|
+
.hover\:bg-zinc-200 {
|
|
554
|
+
&:hover {
|
|
555
|
+
@media (hover: hover) {
|
|
556
|
+
background-color: var(--color-zinc-200);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
534
560
|
.focus\:border-zinc-400 {
|
|
535
561
|
&:focus {
|
|
536
562
|
border-color: var(--color-zinc-400);
|
|
@@ -685,8 +711,7 @@
|
|
|
685
711
|
}
|
|
686
712
|
}
|
|
687
713
|
}
|
|
688
|
-
.
|
|
689
|
-
border-radius: var(--radius-md);
|
|
714
|
+
.popover {
|
|
690
715
|
border-style: var(--tw-border-style);
|
|
691
716
|
border-width: 1px;
|
|
692
717
|
border-color: var(--color-gray-200);
|
|
@@ -695,21 +720,13 @@
|
|
|
695
720
|
--tw-shadow: 0 4px 6px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 2px 4px -2px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
|
|
696
721
|
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
|
697
722
|
}
|
|
698
|
-
.
|
|
723
|
+
.popover-item {
|
|
699
724
|
border-radius: var(--radius-md);
|
|
725
|
+
padding-inline: calc(var(--spacing) * 2);
|
|
726
|
+
padding-block: calc(var(--spacing) * 1);
|
|
700
727
|
}
|
|
701
|
-
.
|
|
702
|
-
background-color: var(--color-zinc-
|
|
703
|
-
}
|
|
704
|
-
.popover {
|
|
705
|
-
border-radius: var(--radius-md);
|
|
706
|
-
border-style: var(--tw-border-style);
|
|
707
|
-
border-width: 1px;
|
|
708
|
-
border-color: var(--color-gray-200);
|
|
709
|
-
background-color: var(--color-white);
|
|
710
|
-
padding: calc(var(--spacing) * 2);
|
|
711
|
-
--tw-shadow: 0 4px 6px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 2px 4px -2px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
|
|
712
|
-
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
|
728
|
+
.popover-item:hover {
|
|
729
|
+
background-color: var(--color-zinc-200);
|
|
713
730
|
}
|
|
714
731
|
.sheet {
|
|
715
732
|
border-radius: var(--radius-md);
|