@marianmeres/stuic 3.4.2 → 3.4.3
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/popover/popover.svelte.d.ts +0 -1
- package/dist/actions/popover/popover.svelte.js +4 -15
- package/dist/actions/tooltip/tooltip.svelte.d.ts +0 -1
- package/dist/actions/tooltip/tooltip.svelte.js +0 -2
- package/dist/components/Avatar/Avatar.svelte +4 -2
- package/dist/components/Avatar/index.css +1 -1
- package/dist/components/Button/Button.svelte +14 -2
- package/dist/components/Button/Button.svelte.d.ts +9 -1
- package/dist/components/DropdownMenu/DropdownMenu.svelte +8 -15
- package/dist/components/DropdownMenu/index.css +0 -25
- package/dist/components/X/index.css +45 -0
- package/dist/index.css +5 -0
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { mount, unmount } from "svelte";
|
|
2
2
|
import { twMerge } from "../../utils/tw-merge.js";
|
|
3
3
|
import { addAnchorName, removeAnchorName } from "../../utils/anchor-name.js";
|
|
4
|
+
import { iconX } from "../../icons/index.js";
|
|
4
5
|
import { BodyScroll } from "../../utils/body-scroll-locker.js";
|
|
5
6
|
import PopoverContent from "./PopoverContent.svelte";
|
|
6
7
|
//
|
|
7
|
-
import "./index.css";
|
|
8
8
|
// Registry of open popover hide functions for closeOthers feature
|
|
9
9
|
const openPopovers = new Set();
|
|
10
10
|
// Reactive state tracking which popovers are open by ID
|
|
@@ -415,20 +415,9 @@ export function popover(anchorEl, fn) {
|
|
|
415
415
|
const closeBtn = document.createElement("button");
|
|
416
416
|
closeBtn.setAttribute("type", "button");
|
|
417
417
|
closeBtn.setAttribute("aria-label", "Close");
|
|
418
|
-
closeBtn.
|
|
419
|
-
closeBtn.style.cssText = `
|
|
420
|
-
|
|
421
|
-
top: 4px;
|
|
422
|
-
right: 4px;
|
|
423
|
-
background: black;
|
|
424
|
-
color: white;
|
|
425
|
-
border: none;
|
|
426
|
-
border-radius: 0.25rem;
|
|
427
|
-
cursor: pointer;
|
|
428
|
-
opacity: 0.6;
|
|
429
|
-
padding: 0.33rem;
|
|
430
|
-
line-height: 1;
|
|
431
|
-
`;
|
|
418
|
+
closeBtn.classList.add("stuic-close-button");
|
|
419
|
+
closeBtn.style.cssText = `position: absolute; top: 4px; right: 4px;`;
|
|
420
|
+
closeBtn.innerHTML = iconX();
|
|
432
421
|
closeBtn.addEventListener("click", hide);
|
|
433
422
|
popoverEl.appendChild(closeBtn);
|
|
434
423
|
}
|
|
@@ -60,10 +60,12 @@
|
|
|
60
60
|
el = $bindable(),
|
|
61
61
|
}: Props = $props();
|
|
62
62
|
|
|
63
|
+
const DEFAULT_ICON_SIZE = 24;
|
|
64
|
+
|
|
63
65
|
// Icon sizes for preset sizes (visual sizes are handled by CSS)
|
|
64
66
|
const ICON_SIZES: Record<string, number> = {
|
|
65
67
|
sm: 16,
|
|
66
|
-
md:
|
|
68
|
+
md: DEFAULT_ICON_SIZE,
|
|
67
69
|
lg: 28,
|
|
68
70
|
xl: 32,
|
|
69
71
|
"2xl": 36,
|
|
@@ -159,7 +161,7 @@
|
|
|
159
161
|
return parseInt(match[1]) * 2;
|
|
160
162
|
}
|
|
161
163
|
|
|
162
|
-
return
|
|
164
|
+
return DEFAULT_ICON_SIZE; // Default fallback
|
|
163
165
|
});
|
|
164
166
|
|
|
165
167
|
let colors = $derived(
|
|
@@ -37,7 +37,15 @@
|
|
|
37
37
|
el?: HTMLElement;
|
|
38
38
|
/** Optional tooltip configuration or direct content */
|
|
39
39
|
tooltip?: string | TooltipConfig;
|
|
40
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Is this button a "X" button (this is a pragmatic convenience).
|
|
42
|
+
*
|
|
43
|
+
* Note: this does NOT use the shared `.stuic-close-button` styling (see X/index.css)
|
|
44
|
+
* because `<Button x>` is a general-purpose "button with an X icon" (tags, toolbars,
|
|
45
|
+
* dialogs...), styled by the Button system (intent/variant/size). The `.stuic-close-button`
|
|
46
|
+
* class is specifically for floating overlay dismiss controls (popover/dropdown fallback).
|
|
47
|
+
* For that look, use: `<Button x unstyled class="stuic-close-button" />`
|
|
48
|
+
*/
|
|
41
49
|
x?: boolean | XProps;
|
|
42
50
|
/** Optional out-of-the-box spinner support */
|
|
43
51
|
spinner?: boolean | THC;
|
|
@@ -92,9 +100,13 @@
|
|
|
92
100
|
return _tooltip ? _tooltip : () => ({ enabled: false });
|
|
93
101
|
});
|
|
94
102
|
|
|
103
|
+
const DEFAULT_X_CLS = "size-7 -m-2";
|
|
104
|
+
|
|
95
105
|
let _xProps: undefined | XProps = $derived.by(() => {
|
|
96
106
|
if (x) {
|
|
97
|
-
|
|
107
|
+
const props = typeof x === "boolean" ? { class: "" } : { ...x };
|
|
108
|
+
props.class = twMerge(DEFAULT_X_CLS, props.class);
|
|
109
|
+
return props;
|
|
98
110
|
}
|
|
99
111
|
});
|
|
100
112
|
|
|
@@ -36,7 +36,15 @@ export interface Props extends Omit<HTMLButtonAttributes, "children"> {
|
|
|
36
36
|
el?: HTMLElement;
|
|
37
37
|
/** Optional tooltip configuration or direct content */
|
|
38
38
|
tooltip?: string | TooltipConfig;
|
|
39
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Is this button a "X" button (this is a pragmatic convenience).
|
|
41
|
+
*
|
|
42
|
+
* Note: this does NOT use the shared `.stuic-close-button` styling (see X/index.css)
|
|
43
|
+
* because `<Button x>` is a general-purpose "button with an X icon" (tags, toolbars,
|
|
44
|
+
* dialogs...), styled by the Button system (intent/variant/size). The `.stuic-close-button`
|
|
45
|
+
* class is specifically for floating overlay dismiss controls (popover/dropdown fallback).
|
|
46
|
+
* For that look, use: `<Button x unstyled class="stuic-close-button" />`
|
|
47
|
+
*/
|
|
40
48
|
x?: boolean | XProps;
|
|
41
49
|
/** Optional out-of-the-box spinner support */
|
|
42
50
|
spinner?: boolean | THC;
|
|
@@ -533,7 +533,12 @@
|
|
|
533
533
|
}
|
|
534
534
|
});
|
|
535
535
|
|
|
536
|
-
// Runtime viewport overflow detection
|
|
536
|
+
// Runtime viewport overflow detection.
|
|
537
|
+
// Known issue: Safari (as of 18.x) does not honor CSS position-try-fallbacks
|
|
538
|
+
// for anchor-positioned elements, so this JS check + centered modal fallback
|
|
539
|
+
// is the actual mechanism that handles overflow on Safari/iOS.
|
|
540
|
+
// On Chrome/Android, CSS position-try-fallbacks (defined in index.css) handles
|
|
541
|
+
// overflow natively and this check rarely fires.
|
|
537
542
|
$effect(() => {
|
|
538
543
|
if (!isOpen || !dropdownEl || forceFallback || runtimeFallback) return;
|
|
539
544
|
if (!isAnchorPositioningSupported()) return;
|
|
@@ -842,25 +847,13 @@
|
|
|
842
847
|
<button
|
|
843
848
|
type="button"
|
|
844
849
|
aria-label="Close"
|
|
845
|
-
class="stuic-
|
|
850
|
+
class="stuic-close-button absolute right-0 top-0 pointer-events-auto"
|
|
846
851
|
onclick={() => {
|
|
847
852
|
isOpen = false;
|
|
848
853
|
triggerEl?.focus();
|
|
849
854
|
}}
|
|
850
855
|
>
|
|
851
|
-
|
|
852
|
-
fill="none"
|
|
853
|
-
viewBox="0 0 24 24"
|
|
854
|
-
stroke-width="2.5"
|
|
855
|
-
stroke="currentColor"
|
|
856
|
-
class="w-5 h-5"
|
|
857
|
-
>
|
|
858
|
-
<path
|
|
859
|
-
stroke-linecap="round"
|
|
860
|
-
stroke-linejoin="round"
|
|
861
|
-
d="M6 18 18 6M6 6l12 12"
|
|
862
|
-
/>
|
|
863
|
-
</svg>
|
|
856
|
+
{@html iconX()}
|
|
864
857
|
</button>
|
|
865
858
|
</div>
|
|
866
859
|
{/if}
|
|
@@ -56,12 +56,6 @@
|
|
|
56
56
|
--stuic-dropdown-menu-backdrop-bg: rgb(0 0 0 / 0.25);
|
|
57
57
|
--stuic-dropdown-menu-backdrop-z-index: 40;
|
|
58
58
|
|
|
59
|
-
/* Close button (fallback mode) */
|
|
60
|
-
--stuic-dropdown-menu-close-bg: var(--stuic-color-foreground);
|
|
61
|
-
--stuic-dropdown-menu-close-text: var(--stuic-color-background);
|
|
62
|
-
--stuic-dropdown-menu-close-opacity: 0.6;
|
|
63
|
-
--stuic-dropdown-menu-close-opacity-hover: 1;
|
|
64
|
-
|
|
65
59
|
/* Expandable section indent */
|
|
66
60
|
--stuic-dropdown-menu-expandable-indent: calc(var(--spacing) * 4);
|
|
67
61
|
|
|
@@ -196,25 +190,6 @@
|
|
|
196
190
|
transition-property: opacity;
|
|
197
191
|
}
|
|
198
192
|
|
|
199
|
-
/* =============================================================================
|
|
200
|
-
CLOSE BUTTON (Fallback Mode)
|
|
201
|
-
============================================================================= */
|
|
202
|
-
|
|
203
|
-
.stuic-dropdown-menu-close {
|
|
204
|
-
background: var(--stuic-dropdown-menu-close-bg);
|
|
205
|
-
color: var(--stuic-dropdown-menu-close-text);
|
|
206
|
-
opacity: var(--stuic-dropdown-menu-close-opacity);
|
|
207
|
-
border-radius: var(--stuic-dropdown-menu-radius);
|
|
208
|
-
padding: calc(var(--spacing) * 2);
|
|
209
|
-
cursor: pointer;
|
|
210
|
-
line-height: 1;
|
|
211
|
-
transition: opacity var(--stuic-dropdown-menu-transition);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
.stuic-dropdown-menu-close:hover {
|
|
215
|
-
opacity: var(--stuic-dropdown-menu-close-opacity-hover);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
193
|
/* =============================================================================
|
|
219
194
|
EXPANDABLE SECTION
|
|
220
195
|
============================================================================= */
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/* =============================================================================
|
|
2
|
+
CLOSE BUTTON - Shared "floating X dismiss" for fallback/modal contexts
|
|
3
|
+
Override globally: :root { --stuic-close-button-radius: 0.25rem; }
|
|
4
|
+
Override locally: .my-component .stuic-close-button { --stuic-close-button-opacity: 0.8; }
|
|
5
|
+
============================================================================= */
|
|
6
|
+
|
|
7
|
+
:root {
|
|
8
|
+
--stuic-close-button-bg: var(--stuic-color-foreground);
|
|
9
|
+
--stuic-close-button-text: var(--stuic-color-background);
|
|
10
|
+
--stuic-close-button-opacity: 0.6;
|
|
11
|
+
--stuic-close-button-opacity-hover: 1;
|
|
12
|
+
--stuic-close-button-radius: 9999px;
|
|
13
|
+
--stuic-close-button-padding: calc(var(--spacing) * 2);
|
|
14
|
+
--stuic-close-button-min-size: 44px;
|
|
15
|
+
--stuic-close-button-transition: 150ms;
|
|
16
|
+
--stuic-close-button-icon-size: 1.75rem;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@layer components {
|
|
20
|
+
.stuic-close-button {
|
|
21
|
+
display: inline-flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
background: var(--stuic-close-button-bg);
|
|
25
|
+
color: var(--stuic-close-button-text);
|
|
26
|
+
opacity: var(--stuic-close-button-opacity);
|
|
27
|
+
border: none;
|
|
28
|
+
border-radius: var(--stuic-close-button-radius);
|
|
29
|
+
padding: var(--stuic-close-button-padding);
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
line-height: 1;
|
|
32
|
+
min-height: var(--stuic-close-button-min-size);
|
|
33
|
+
min-width: var(--stuic-close-button-min-size);
|
|
34
|
+
transition: opacity var(--stuic-close-button-transition);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.stuic-close-button:hover {
|
|
38
|
+
opacity: var(--stuic-close-button-opacity-hover);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.stuic-close-button svg {
|
|
42
|
+
width: var(--stuic-close-button-icon-size);
|
|
43
|
+
height: var(--stuic-close-button-icon-size);
|
|
44
|
+
}
|
|
45
|
+
}
|
package/dist/index.css
CHANGED
|
@@ -48,6 +48,11 @@ In practice:
|
|
|
48
48
|
@import "./components/TabbedMenu/index.css";
|
|
49
49
|
@import "./components/ThemePreview/index.css";
|
|
50
50
|
@import "./components/TwCheck/index.css";
|
|
51
|
+
@import "./components/X/index.css";
|
|
52
|
+
|
|
53
|
+
/* Action CSS */
|
|
54
|
+
@import "./actions/popover/index.css";
|
|
55
|
+
@import "./actions/tooltip/index.css";
|
|
51
56
|
|
|
52
57
|
/* Base styles for STUIC components */
|
|
53
58
|
@layer base {
|