@marianmeres/stuic 2.27.0 → 2.29.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.
@@ -26,6 +26,13 @@ export declare function closePopover(id: string): void;
26
26
  * @param id - The popover ID to toggle
27
27
  */
28
28
  export declare function togglePopover(id: string): void;
29
+ /**
30
+ * Check if a popover is currently open by its registered ID.
31
+ *
32
+ * @param id - The popover ID to check
33
+ * @returns true if the popover is open, false otherwise
34
+ */
35
+ export declare function isPopoverOpen(id: string): boolean;
29
36
  /**
30
37
  * Checks if the browser supports CSS Anchor Positioning for popovers.
31
38
  *
@@ -6,6 +6,8 @@ import PopoverContent from "./PopoverContent.svelte";
6
6
  import "./index.css";
7
7
  // Registry of open popover hide functions for closeOthers feature
8
8
  const openPopovers = new Set();
9
+ // Reactive state tracking which popovers are open by ID
10
+ const popoverOpenStates = $state({});
9
11
  // Registry of popovers by ID for programmatic control
10
12
  const popoverRegistry = new Map();
11
13
  // Track if an open was just requested (to prevent same-click outside close)
@@ -54,6 +56,15 @@ export function closePopover(id) {
54
56
  export function togglePopover(id) {
55
57
  popoverRegistry.get(id)?.toggle();
56
58
  }
59
+ /**
60
+ * Check if a popover is currently open by its registered ID.
61
+ *
62
+ * @param id - The popover ID to check
63
+ * @returns true if the popover is open, false otherwise
64
+ */
65
+ export function isPopoverOpen(id) {
66
+ return popoverOpenStates[id] ?? false;
67
+ }
57
68
  const SHOW_DELAY = 100;
58
69
  const HIDE_DELAY = 200;
59
70
  const TRANSITION = 200;
@@ -310,6 +321,9 @@ export function popover(anchorEl, fn) {
310
321
  // Register this popover
311
322
  openPopovers.add(hide);
312
323
  isVisible = true;
324
+ if (currentOptions.id) {
325
+ popoverOpenStates[currentOptions.id] = true;
326
+ }
313
327
  anchorEl.setAttribute("aria-expanded", "true");
314
328
  const offsetValue = currentOptions.offset || "0.25rem";
315
329
  const useAnchorPositioning = isSupported && !currentOptions.forceFallback;
@@ -409,6 +423,9 @@ export function popover(anchorEl, fn) {
409
423
  if (!isVisible)
410
424
  return;
411
425
  isVisible = false;
426
+ if (currentOptions.id) {
427
+ popoverOpenStates[currentOptions.id] = false;
428
+ }
412
429
  // Unregister from open popovers
413
430
  openPopovers.delete(hide);
414
431
  anchorEl.setAttribute("aria-expanded", "false");
@@ -547,6 +564,7 @@ export function popover(anchorEl, fn) {
547
564
  // Unregister from popover registry
548
565
  if (currentOptions.id) {
549
566
  popoverRegistry.delete(currentOptions.id);
567
+ delete popoverOpenStates[currentOptions.id];
550
568
  }
551
569
  document.removeEventListener("keydown", onEscape);
552
570
  document.removeEventListener("click", onClickOutside);
@@ -29,7 +29,7 @@ export function isTooltipSupported() {
29
29
  }
30
30
  const _classTooltip = `
31
31
  bg-tooltip-bg dark:bg-tooltip-bg-dark text-tooltip-text dark:text-tooltip-text-dark
32
- text-xs tracking-tight rounded my-1
32
+ text-sm tracking-tight rounded my-1
33
33
  px-2.5 py-1.5
34
34
  max-w-64
35
35
  z-50
@@ -301,7 +301,7 @@
301
301
  <div class="p-1">
302
302
  {#if _optgroup}
303
303
  <div
304
- class="text-xs capitalize opacity-50 border-b border-black/10 mb-1 p-1"
304
+ class="text-sm capitalize opacity-50 border-b border-black/10 mb-1 p-1"
305
305
  >
306
306
  {_optgroup}
307
307
  </div>
@@ -129,7 +129,7 @@
129
129
  "form-input",
130
130
  "block border-0 w-full text-sm!",
131
131
  "file:rounded file:border-0 file:mr-4 file:bg-neutral-200",
132
- "file:px-2 file:py-0.5 file:cursor-pointer file:text-sm",
132
+ "file:px-2 file:py-1 file:cursor-pointer file:text-sm",
133
133
  "focus-visible:ring-0 focus:ring-0 focus:leading-0",
134
134
  renderSize,
135
135
  classInput
@@ -617,7 +617,7 @@
617
617
  type="button"
618
618
  onclick={() => _selectedColl.addMany(options.items)}
619
619
  class={twMerge(
620
- "control flex items-center p-1 m-1 text-xs opacity-75 underline rounded",
620
+ "control flex items-center p-1 m-1 text-sm opacity-75 underline rounded",
621
621
  "hover:opacity-100 focus-visible:outline-neutral-400 focus-visible:opacity-100"
622
622
  )}
623
623
  tabindex={4}
@@ -633,7 +633,7 @@
633
633
  input?.focus();
634
634
  }}
635
635
  class={twMerge(
636
- "control flex items-center p-1 m-1 text-xs opacity-75 underline rounded",
636
+ "control flex items-center p-1 m-1 text-sm opacity-75 underline rounded",
637
637
  "hover:opacity-100 focus-visible:outline-neutral-400 focus-visible:opacity-100"
638
638
  )}
639
639
  class:opacity-20={!selected.items.length}
@@ -643,8 +643,8 @@
643
643
  {@html t(cardinality === 1 ? "clear" : "clear_all")}
644
644
  </button>
645
645
 
646
- <span class="p-1 m-1 text-xs">&nbsp;</span>
647
- <span class="flex-1 block justify-end opacity-50 text-right text-xs p-1 pr-2">
646
+ <span class="p-1 m-1 text-sm">&nbsp;</span>
647
+ <span class="flex-1 block justify-end opacity-50 text-right text-sm p-1 pr-2">
648
648
  {selected.items.length}
649
649
  {#if cardinality > 0 && cardinality < Infinity}
650
650
  {@html t("cardinality_of")} {cardinality}
@@ -694,7 +694,7 @@
694
694
  {#if _optgroup}
695
695
  <div
696
696
  class={twMerge(
697
- "text-xs capitalize opacity-50 border-b border-black/10 mb-0.5 p-1 mx-1",
697
+ "text-sm capitalize opacity-50 border-b border-black/10 mb-0.5 p-1 mx-1",
698
698
  classOptgroup
699
699
  )}
700
700
  >
@@ -767,7 +767,7 @@
767
767
  </div>
768
768
  <!-- {/if} -->
769
769
  <div class="p-2 px-3 flex items-end justify-between">
770
- <div class="text-xs opacity-50">
770
+ <div class="text-sm opacity-50">
771
771
  <!-- Use arrows to navigate. Spacebar and Enter to select and/or submit. -->
772
772
  {#if allowUnknown}
773
773
  {@html t("unknown_allowed")}
@@ -115,7 +115,7 @@
115
115
  class={twMerge(
116
116
  "validation-box",
117
117
  _classCommon,
118
- `mt-1 px-2 text-xs text-input-accent dark:text-input-accent-dark
118
+ `mt-1 px-2 text-sm text-input-accent dark:text-input-accent-dark
119
119
  tracking-tight`,
120
120
  classValidationBox
121
121
  )}
@@ -10,6 +10,7 @@
10
10
  .stuic-input {
11
11
  .form-input {
12
12
  @apply rounded-md border-0 w-full flex-1
13
+ py-2.5
13
14
  text-base placeholder:text-base
14
15
  bg-transparent
15
16
  tracking-tight
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/stuic",
3
- "version": "2.27.0",
3
+ "version": "2.29.0",
4
4
  "files": [
5
5
  "dist",
6
6
  "!dist/**/*.test.*",